From ef422016a57ce93b281f00ead627b605b72203d5 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 15 Aug 2026 23:20:37 +0000 Subject: [PATCH 01/16] Add load-path review experience: history, graph overlays, and editor marks. Walks stay the product: click-through brief to graph, seed vs downstream coloring, contract field sides, merge checklist, command palette, j/k read-order, working-tree watch, loadpath.yml editor, HTML export, restore on launch, architecture health, CODEOWNERS, and VS Code/Cursor gutter marks. Co-authored-by: zord.lack.net --- CONTRIBUTING.md | 4 + README.md | 4 +- desktop/main.mjs | 4 +- desktop/urls.mjs | 11 + desktop/urls.test.mjs | 11 +- editors/vscode/README.md | 16 + editors/vscode/extension.js | 72 +++ editors/vscode/package.json | 31 + src/loadpath/config.py | 107 ++++ src/loadpath/mcp/compact.py | 5 + src/loadpath/mcp/server.py | 12 + src/loadpath/mcp/tools.py | 80 +++ src/loadpath/review/codeowners.py | 108 ++++ src/loadpath/review/editor.py | 99 +++ src/loadpath/review/engine.py | 2 + src/loadpath/review/experience.py | 540 +++++++++++++++++ src/loadpath/review/whatif.py | 2 + src/loadpath/server/app.py | 214 ++++++- ...DBrjUozl.js => LayeredGraph3D-B-dkkPpV.js} | 2 +- ...{index-C3YNVD8c.css => index-Bmsup5i5.css} | 2 +- src/loadpath/static/assets/index-Dg2mxCJ9.js | 62 ++ src/loadpath/static/assets/index-PXVMaQl_.js | 62 -- src/loadpath/static/index.html | 4 +- src/loadpath/workspace.py | 22 + tests/e2e/test_api_flow.py | 31 + tests/e2e/test_ui_flows.py | 18 + tests/unit/test_experience.py | 281 +++++++++ ui/src/App.tsx | 572 +++++++++++++++++- ui/src/CommandPalette.tsx | 111 ++++ ui/src/ConfigEditor.tsx | 199 ++++++ ui/src/ImpactGraph.tsx | 275 +++++++-- ui/src/api.ts | 80 ++- ui/src/experience.test.ts | 24 + ui/src/graphView.test.ts | 28 + ui/src/graphView.ts | 78 +++ ui/src/openEditor.ts | 44 ++ ui/src/styles.css | 171 ++++++ ui/src/types.ts | 125 +++- 38 files changed, 3352 insertions(+), 161 deletions(-) create mode 100644 editors/vscode/README.md create mode 100644 editors/vscode/extension.js create mode 100644 editors/vscode/package.json create mode 100644 src/loadpath/review/codeowners.py create mode 100644 src/loadpath/review/editor.py create mode 100644 src/loadpath/review/experience.py rename src/loadpath/static/assets/{LayeredGraph3D-DBrjUozl.js => LayeredGraph3D-B-dkkPpV.js} (99%) rename src/loadpath/static/assets/{index-C3YNVD8c.css => index-Bmsup5i5.css} (86%) create mode 100644 src/loadpath/static/assets/index-Dg2mxCJ9.js delete mode 100644 src/loadpath/static/assets/index-PXVMaQl_.js create mode 100644 tests/unit/test_experience.py create mode 100644 ui/src/CommandPalette.tsx create mode 100644 ui/src/ConfigEditor.tsx create mode 100644 ui/src/experience.test.ts create mode 100644 ui/src/openEditor.ts diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1659c75..6ebf27b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,6 +43,10 @@ npm run dev # Vite, proxies /api to the Django-shaped FastAPI server If you change `ui/` and only run `loadpath serve`, you are looking at a stale bundle until you `npm run build`. +## Editor gutter + +`editors/vscode` is a local Cursor/VS Code extension that polls `/api/marks` and badges files on the current load path (`S` seed, `!` untested sink, `C` contract). Install from that folder; `loadpath serve` must be running. + ## Desktop ```bash diff --git a/README.md b/README.md index 8fefcb0..cb4c35f 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ It is a local CLI, a desktop UI, and an MCP server you can point Cursor at. Not ## App -`loadpath serve --port 7345` opens a local desktop-style UI: icon rail, labeled toolbar, merge-box confidence, and an inspectable impact graph. The same process hosts MCP at `/mcp` (OAuth). AI is used **only** for residual uncertainty the graph cannot close. Twenty-four themes live in Settings and `localStorage`. Last repo, git range, and SCM slug are remembered the same way. Copy the markdown brief, or post **one** PR comment (updated in place) from the Review tab. Keyboard: `1`–`5` switches tabs. Outside Settings and Pull requests, `⌘`/`Ctrl`+`Enter` runs a review. +`loadpath serve --port 7345` opens a local desktop-style UI: icon rail, labeled toolbar, merge-box confidence, and an inspectable impact graph. The same process hosts MCP at `/mcp` (OAuth). AI is used **only** for residual uncertainty the graph cannot close. Twenty-four themes live in Settings and `localStorage`. Last repo, git range, SCM slug, and the last review id are remembered the same way. Copy the markdown brief, save HTML, or post **one** PR comment (updated in place) from the Review tab. Keyboard: `1`–`5` switches tabs. `⌘`/`Ctrl`+`K` opens the command palette. `j`/`k` walks read-order. Outside Settings and Pull requests, `⌘`/`Ctrl`+`Enter` runs a review. Click a finding, sink, or inspector neighbor to select it on the graph; Open in editor uses Cursor / VS Code. Watch the working tree to re-walk on save. Architecture edits `loadpath.yml` in place. ### Empty review @@ -247,7 +247,7 @@ MCP URL: `https://your-tunnel.example/mcp` (or `http://127.0.0.1:7345/mcp` on th **Cursor / Claude / ChatGPT / Gemini (HTTP + OAuth)** — add that MCP URL in the host’s connectors. The first connect opens a consent page on the Loadpath machine. -Tools: `list_workspaces`, `init_repo`, `index_repo`, `architecture`, `review`, `detect_repo`, `list_pull_requests`, `list_remote_repositories`, `post_review_comment`, `what_if`, `review_pull_request`. `review` returns the load-path brief (confidence, sinks, reviewers, contract-break, auth, suggested tests, trend) — not hunk comments. `review_pull_request` fetches GitHub / GitLab / Bitbucket refs into a local clone first. +Tools: `list_workspaces`, `init_repo`, `index_repo`, `architecture`, `review`, `detect_repo`, `list_pull_requests`, `list_remote_repositories`, `post_review_comment`, `what_if`, `review_pull_request`, `load_path_marks`, `list_reviews`, `save_config`. `review` returns the load-path brief (confidence, sinks, reviewers, contract-break, auth, suggested tests, trend, checklist) — not hunk comments. `load_path_marks` is the gutter feed for the Cursor/VS Code extension in [`editors/vscode`](editors/vscode). `review_pull_request` fetches GitHub / GitLab / Bitbucket refs into a local clone first. Put `loadpath.yml` at the repo root (see [`loadpath.yml.example`](loadpath.yml.example) and [`fixtures/demo_monorepo/loadpath.yml`](fixtures/demo_monorepo/loadpath.yml)). The tool is opinionated about *your* architecture, not a generic module graph. diff --git a/desktop/main.mjs b/desktop/main.mjs index 20a3ec7..fa4dbc2 100644 --- a/desktop/main.mjs +++ b/desktop/main.mjs @@ -5,7 +5,7 @@ import path from "node:path"; import { fileURLToPath } from "node:url"; import { backendCommand, pickFreePort, waitForHealth } from "./backend.mjs"; -import { isAllowedExternalUrl, isAppOrigin } from "./urls.mjs"; +import { isAllowedExternalUrl, isAppOrigin, isEditorUrl } from "./urls.mjs"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); @@ -19,7 +19,7 @@ function repoRoot() { } function openExternalIfAllowed(url) { - if (!isAllowedExternalUrl(url)) return; + if (!isAllowedExternalUrl(url) && !isEditorUrl(url)) return; shell.openExternal(url).catch((err) => { dialog.showErrorBox("Loadpath", `Could not open link: ${err.message}`); }); diff --git a/desktop/urls.mjs b/desktop/urls.mjs index ed89b1a..a5ef3f1 100644 --- a/desktop/urls.mjs +++ b/desktop/urls.mjs @@ -1,3 +1,14 @@ +export function isEditorUrl(url) { + let parsed; + try { + parsed = new URL(url); + } catch { + return false; + } + if (parsed.username || parsed.password) return false; + return parsed.protocol === "vscode:" || parsed.protocol === "cursor:" || parsed.protocol === "vscode-insiders:"; +} + export function isAllowedExternalUrl(url) { let parsed; try { diff --git a/desktop/urls.test.mjs b/desktop/urls.test.mjs index cb01926..0db2bb9 100644 --- a/desktop/urls.test.mjs +++ b/desktop/urls.test.mjs @@ -1,7 +1,7 @@ import assert from "node:assert/strict"; import { describe, it } from "node:test"; -import { isAllowedExternalUrl, isAppOrigin } from "./urls.mjs"; +import { isAllowedExternalUrl, isAppOrigin, isEditorUrl } from "./urls.mjs"; describe("isAllowedExternalUrl", () => { it("allows GitHub, GitLab, and Bitbucket https PR links", () => { @@ -24,6 +24,15 @@ describe("isAllowedExternalUrl", () => { }); }); +describe("isEditorUrl", () => { + it("allows vscode and cursor file URLs without credentials", () => { + assert.equal(isEditorUrl("vscode://file/tmp/acme/a.py:12"), true); + assert.equal(isEditorUrl("cursor://file/tmp/acme/a.py"), true); + assert.equal(isEditorUrl("vscode://user:pass@file/tmp"), false); + assert.equal(isEditorUrl("https://github.com"), false); + }); +}); + describe("isAppOrigin", () => { it("allows only the loopback backend origin", () => { assert.equal(isAppOrigin("http://127.0.0.1:7345/api/health", 7345), true); diff --git a/editors/vscode/README.md b/editors/vscode/README.md new file mode 100644 index 0000000..254fe80 --- /dev/null +++ b/editors/vscode/README.md @@ -0,0 +1,16 @@ +# Loadpath editor gutter + +Marks files on the current Loadpath walk while `loadpath serve` is running on this machine. + +``` +code --install-extension /path/to/PR-Reviewer/editors/vscode +``` + +Or in Cursor: **Install from Location** → `editors/vscode`. + +Settings: + +- `loadpath.url` — default `http://127.0.0.1:7345` +- `loadpath.repoPath` — defaults to the workspace folder + +Badges: `S` seed (the diff), `!` untested sink, `C` contract, `✓` tested, `→` downstream. diff --git a/editors/vscode/extension.js b/editors/vscode/extension.js new file mode 100644 index 0000000..3c95bf0 --- /dev/null +++ b/editors/vscode/extension.js @@ -0,0 +1,72 @@ +const vscode = require("vscode"); + +function badgeColor(roles) { + if (roles.includes("untested")) return new vscode.ThemeColor("list.warningForeground"); + if (roles.includes("seed")) return new vscode.ThemeColor("list.highlightForeground"); + if (roles.includes("tested")) return new vscode.ThemeColor("testing.iconPassed"); + return new vscode.ThemeColor("foreground"); +} + +class LoadpathDecorations { + constructor() { + this._onDidChange = new vscode.EventEmitter(); + this.onDidChangeFileDecorations = this._onDidChange.event; + this.byPath = new Map(); + } + + provideFileDecoration(uri) { + const item = this.byPath.get(uri.fsPath) || this.byPath.get(uri.path); + if (!item) return; + return { + badge: item.badge || "·", + tooltip: item.tooltip || "On the Loadpath walk", + color: badgeColor(item.roles || []), + propagate: true, + }; + } + + replace(files, folder) { + this.byPath = new Map(); + for (const file of files || []) { + const abs = folder ? require("path").join(folder, file.path) : file.path; + this.byPath.set(abs, file); + this.byPath.set(file.path, file); + } + this._onDidChange.fire(undefined); + } +} + +async function fetchMarks(url, repoPath) { + const endpoint = `${url.replace(/\/$/, "")}/api/marks?repo_path=${encodeURIComponent(repoPath)}`; + const res = await fetch(endpoint); + if (!res.ok) throw new Error(`Loadpath marks ${res.status}`); + return res.json(); +} + +function activate(context) { + const decorations = new LoadpathDecorations(); + context.subscriptions.push(vscode.window.registerFileDecorationProvider(decorations)); + + const refresh = async () => { + const folder = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath; + const cfg = vscode.workspace.getConfiguration("loadpath"); + const url = cfg.get("url") || "http://127.0.0.1:7345"; + const repoPath = cfg.get("repoPath") || folder; + if (!repoPath) return; + try { + const payload = await fetchMarks(url, repoPath); + decorations.replace(payload.files || [], folder || repoPath); + } catch { + decorations.replace([], folder); + } + }; + + context.subscriptions.push(vscode.commands.registerCommand("loadpath.refreshMarks", refresh)); + const timer = setInterval(refresh, 4000); + context.subscriptions.push({ dispose: () => clearInterval(timer) }); + void refresh(); +} + +function deactivate() {} + +module.exports = { activate, deactivate }; diff --git a/editors/vscode/package.json b/editors/vscode/package.json new file mode 100644 index 0000000..a4d6173 --- /dev/null +++ b/editors/vscode/package.json @@ -0,0 +1,31 @@ +{ + "name": "loadpath", + "displayName": "Loadpath", + "description": "Gutter marks for files on the current Loadpath review (seed, untested sink, contract).", + "version": "0.1.0", + "publisher": "loadpath", + "engines": { "vscode": "^1.85.0" }, + "categories": ["Other"], + "activationEvents": ["onStartupFinished"], + "main": "./extension.js", + "contributes": { + "commands": [ + { "command": "loadpath.refreshMarks", "title": "Loadpath: Refresh load-path marks" } + ], + "configuration": { + "title": "Loadpath", + "properties": { + "loadpath.url": { + "type": "string", + "default": "http://127.0.0.1:7345", + "description": "Local Loadpath server origin (loadpath serve)." + }, + "loadpath.repoPath": { + "type": "string", + "default": "", + "description": "Repository path sent to Loadpath. Empty uses the first workspace folder." + } + } + } + } +} diff --git a/src/loadpath/config.py b/src/loadpath/config.py index 60a63ae..f57ec0b 100644 --- a/src/loadpath/config.py +++ b/src/loadpath/config.py @@ -145,3 +145,110 @@ def load_config(repo_root: Path, config_path: Path | None = None) -> LoadpathCon extra=raw, boot_django=bool(raw.get("boot_django", False)), ) + + +def config_document(cfg: LoadpathConfig) -> dict[str, Any]: + path = find_config(cfg.repo_root) + return { + "repo_root": str(cfg.repo_root), + "path": str(path or (cfg.repo_root / "loadpath.yml")), + "exists": path is not None, + "contexts": { + name: { + "name": name, + "django_apps": list(ctx.django_apps), + "react": list(ctx.react), + "public_api": list(ctx.public_api), + "owners": list(ctx.owners), + } + for name, ctx in cfg.contexts.items() + }, + "rules": list(cfg.rules), + "available_rules": list(DEFAULT_RULES), + "waivers": [ + {"rule": w.rule, "node": w.node, "reason": w.reason} for w in cfg.waivers + ], + "django_root": cfg.django_root, + "react_root": cfg.react_root, + "openapi_paths": list(cfg.openapi_paths), + "boot_django": cfg.boot_django, + "layers": {"django": list(cfg.django_layers), "react": list(cfg.react_layers)}, + } + + +def _dump_config_payload(raw: dict[str, Any]) -> str: + header = ( + "# Loadpath architecture manifest. Contexts, public_api, owners, and waivers " + "are the rules Loadpath will enforce.\n" + ) + return header + yaml.safe_dump(raw, sort_keys=False, allow_unicode=True) + + +def write_config(repo_root: Path, document: dict[str, Any]) -> dict[str, Any]: + """Write loadpath.yml from an editor document. Preserves unknown keys.""" + repo_root = repo_root.resolve() + path = find_config(repo_root) or (repo_root / "loadpath.yml") + raw: dict[str, Any] = {} + if path.is_file(): + raw = yaml.safe_load(path.read_text(encoding="utf-8")) or {} + if not isinstance(raw, dict): + raw = {} + + if "contexts" in document: + contexts: dict[str, Any] = {} + for name, data in (document.get("contexts") or {}).items(): + data = data or {} + name = str(name).strip() + if not name: + continue + contexts[name] = { + "django_apps": list(data.get("django_apps") or []), + "react": list(data.get("react") or []), + "public_api": list(data.get("public_api") or []), + "owners": list(data.get("owners") or []), + } + raw["contexts"] = contexts + if "rules" in document and document["rules"] is not None: + raw["rules"] = [str(r) for r in document["rules"] if str(r).strip()] + if "waivers" in document: + waivers = [] + for w in document.get("waivers") or []: + rule = str((w or {}).get("rule") or "").strip() + if not rule: + continue + item: dict[str, Any] = {"rule": rule} + if (w or {}).get("node"): + item["node"] = w["node"] + if (w or {}).get("reason"): + item["reason"] = w["reason"] + waivers.append(item) + raw["waivers"] = waivers + if document.get("django_root") is not None: + raw["django_root"] = document["django_root"] + if document.get("react_root") is not None: + raw["react_root"] = document["react_root"] + if "openapi_paths" in document and document["openapi_paths"] is not None: + raw["openapi_paths"] = list(document["openapi_paths"]) + if document.get("boot_django") is not None: + raw["boot_django"] = bool(document["boot_django"]) + layers = document.get("layers") + if isinstance(layers, dict): + raw["layers"] = { + "django": list(layers.get("django") or raw.get("layers", {}).get("django") or ["route", "view", "service", "model"]), + "react": list(layers.get("react") or raw.get("layers", {}).get("react") or ["route", "page", "feature", "shared"]), + } + + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(_dump_config_payload(raw), encoding="utf-8") + return config_document(load_config(repo_root, path)) + + +def add_waiver(repo_root: Path, rule: str, node: str | None = None, reason: str = "") -> dict[str, Any]: + cfg = load_config(repo_root) + doc = config_document(cfg) + waivers = list(doc.get("waivers") or []) + entry = {"rule": rule, "node": node, "reason": reason} + if not any(w.get("rule") == rule and w.get("node") == node for w in waivers): + waivers.append(entry) + doc["waivers"] = waivers + return write_config(repo_root, doc) diff --git a/src/loadpath/mcp/compact.py b/src/loadpath/mcp/compact.py index 5df0bcf..9e2a7bc 100644 --- a/src/loadpath/mcp/compact.py +++ b/src/loadpath/mcp/compact.py @@ -48,4 +48,9 @@ def compact_review(review: dict[str, Any]) -> dict[str, Any]: "trend": review.get("trend"), "index": review.get("index"), "workspace": review.get("workspace"), + "checklist": review.get("checklist") or [], + "marks": review.get("marks") or [], + "seed_ids": review.get("seed_ids") or [], + "codeowners": review.get("codeowners"), + "codeowners_reviewers": review.get("codeowners_reviewers") or [], } diff --git a/src/loadpath/mcp/server.py b/src/loadpath/mcp/server.py index 5546cac..a78b9bd 100644 --- a/src/loadpath/mcp/server.py +++ b/src/loadpath/mcp/server.py @@ -83,6 +83,18 @@ def _register_tools(mcp: MCPServer) -> None: name="review_pull_request", description="Fetch a GitHub/GitLab/Bitbucket PR into a local clone and review the three-dot range.", )(tools.review_pull_request) + mcp.tool( + name="load_path_marks", + description="Files on the current load path with roles for editor gutters: seed, untested sink, contract, tested.", + )(tools.load_path_marks) + mcp.tool( + name="list_reviews", + description="List stored Loadpath reviews for a workspace (confidence, sinks, contract) without the full graph.", + )(tools.list_reviews) + mcp.tool( + name="save_config", + description="Write loadpath.yml contexts, owners, rules, and waivers for a repo.", + )(tools.save_config) def create_mcp_server( diff --git a/src/loadpath/mcp/tools.py b/src/loadpath/mcp/tools.py index 8104dc9..467434d 100644 --- a/src/loadpath/mcp/tools.py +++ b/src/loadpath/mcp/tools.py @@ -244,3 +244,83 @@ def review_pull_request( compact = compact_review(review) compact["pull_request"] = prepared return compact + + +def load_path_marks(repo_path: str, review_id: str | None = None) -> dict[str, Any]: + """Files on the current load path with gutter roles (seed, untested sink, contract).""" + root = _repo(repo_path) + if isinstance(root, dict): + return root + from loadpath.graph.store import GraphStore + from loadpath.index import default_db_path + from loadpath.review.experience import attach_experience, summarize_stored_review + + db = default_db_path(root) + if not db.is_file(): + return {"error": "Index the repo first", "files": []} + store = GraphStore(db) + item = store.get_review(review_id) if review_id else None + if item is None: + listed = store.list_reviews(include_payload=True, limit=1) + item = listed[0] if listed else None + store.close() + if not item: + return {"repo_path": str(root), "review_id": None, "files": []} + payload = attach_experience(dict(item.get("payload") or {}), repo_root=root) + return { + "repo_path": str(root), + "review_id": payload.get("id") or item.get("id"), + "title": payload.get("title"), + "level": (payload.get("confidence") or {}).get("level"), + "files": payload.get("marks") or [], + "summary": summarize_stored_review(item), + } + + +def list_reviews(repo_path: str, limit: int = 20) -> dict[str, Any]: + """Stored load-path reviews for a workspace (no full graphs).""" + root = _repo(repo_path) + if isinstance(root, dict): + return root + from loadpath.graph.store import GraphStore + from loadpath.index import default_db_path + from loadpath.review.experience import summarize_stored_review + + db = default_db_path(root) + if not db.is_file(): + return {"reviews": []} + store = GraphStore(db) + items = store.list_reviews(include_payload=True, limit=limit) + store.close() + return {"reviews": [summarize_stored_review(item) for item in items]} + + +def save_config( + repo_path: str, + contexts: dict[str, Any] | None = None, + rules: list[str] | None = None, + waivers: list[dict[str, Any]] | None = None, + django_root: str | None = None, + react_root: str | None = None, + boot_django: bool | None = None, +) -> dict[str, Any]: + """Write loadpath.yml contexts, owners, rules, and waivers.""" + root = _repo(repo_path) + if isinstance(root, dict): + return root + from loadpath.config import write_config + + document: dict[str, Any] = {} + if contexts is not None: + document["contexts"] = contexts + if rules is not None: + document["rules"] = rules + if waivers is not None: + document["waivers"] = waivers + if django_root is not None: + document["django_root"] = django_root + if react_root is not None: + document["react_root"] = react_root + if boot_django is not None: + document["boot_django"] = boot_django + return write_config(root, document) diff --git a/src/loadpath/review/codeowners.py b/src/loadpath/review/codeowners.py new file mode 100644 index 0000000..790a965 --- /dev/null +++ b/src/loadpath/review/codeowners.py @@ -0,0 +1,108 @@ +"""Parse GitHub/GitLab CODEOWNERS and match review files.""" + +from __future__ import annotations + +import re +from pathlib import Path +from typing import Any + +_COMMENT = re.compile(r"\s+#.*$") +_OWNER = re.compile(r"@[^\s]+|[^\s]+") + + +def find_codeowners(repo_root: Path) -> Path | None: + root = repo_root.resolve() + for rel in ("CODEOWNERS", ".github/CODEOWNERS", "docs/CODEOWNERS", ".gitlab/CODEOWNERS"): + path = root / rel + if path.is_file(): + return path + return None + + +def parse_codeowners(text: str) -> list[tuple[str, list[str]]]: + """Return (pattern, owners) in file order. Last matching pattern wins.""" + rules: list[tuple[str, list[str]]] = [] + for raw in text.splitlines(): + line = _COMMENT.sub("", raw).strip() + if not line or line.startswith("#"): + continue + parts = line.split() + if len(parts) < 2: + continue + pattern, rest = parts[0], parts[1:] + owners = [p for p in rest if p and not p.startswith("#")] + if owners: + rules.append((pattern, owners)) + return rules + + +def _glob_to_re(pattern: str) -> re.Pattern[str]: + pat = pattern.replace("\\", "/").strip() + if pat.startswith("/"): + pat = pat[1:] + anchored = True + else: + anchored = False + if pat.endswith("/"): + pat = pat + "**" + escaped: list[str] = [] + i = 0 + while i < len(pat): + if pat.startswith("**/", i): + escaped.append("(?:.*/)?") + i += 3 + continue + if pat.startswith("**", i): + escaped.append(".*") + i += 2 + continue + ch = pat[i] + if ch == "*": + escaped.append("[^/]*") + elif ch == "?": + escaped.append("[^/]") + else: + escaped.append(re.escape(ch)) + i += 1 + body = "".join(escaped) + if anchored: + return re.compile(rf"^{body}(?:/.*)?$") + return re.compile(rf"(?:^|/){body}(?:/.*)?$") + + +def owners_for_path(path: str, rules: list[tuple[str, list[str]]]) -> list[str]: + normalized = path.replace("\\", "/").lstrip("./") + matched: list[str] = [] + for pattern, owners in rules: + try: + rx = _glob_to_re(pattern) + except re.error: + continue + if rx.search(normalized): + matched = owners + return list(matched) + + +def review_codeowners(repo_root: Path, file_paths: list[str]) -> dict[str, Any]: + path = find_codeowners(repo_root) + if path is None: + return {"path": None, "owners": [], "files": []} + rules = parse_codeowners(path.read_text(encoding="utf-8")) + files: list[dict[str, Any]] = [] + seen: list[str] = [] + have: set[str] = set() + for rel in file_paths: + owners = owners_for_path(rel, rules) + if not owners: + continue + files.append({"path": rel, "owners": owners}) + for owner in owners: + if owner not in have: + have.add(owner) + seen.append(owner) + root = repo_root.resolve() + return { + "path": str(path.relative_to(root)) if path.is_relative_to(root) else str(path), + "owners": seen, + "files": files[:40], + } diff --git a/src/loadpath/review/editor.py b/src/loadpath/review/editor.py new file mode 100644 index 0000000..545473e --- /dev/null +++ b/src/loadpath/review/editor.py @@ -0,0 +1,99 @@ +"""Open a repo file in the local editor (Cursor / VS Code / system).""" + +from __future__ import annotations + +import os +import shutil +import subprocess +import sys +from pathlib import Path +from typing import Any + +_TIMEOUT = 8 +_EDITORS = { + "cursor": ["cursor", "cursor.cmd"], + "vscode": ["code", "code.cmd"], + "system": [], +} + + +def _safe_file(repo_root: Path, rel_or_abs: str) -> Path: + root = repo_root.resolve() + raw = Path(rel_or_abs).expanduser() + full = raw.resolve() if raw.is_absolute() else (root / raw).resolve() + try: + full.relative_to(root) + except ValueError as exc: + raise ValueError(f"Path is outside the repository: {rel_or_abs}") from exc + if not full.exists(): + raise FileNotFoundError(f"File not found: {full}") + return full + + +def editor_urls(full: Path, line: int | None) -> dict[str, str]: + path = str(full) + suffix = f":{line}" if line and line > 0 else "" + # vscode/cursor URI: vscode://file/: + encoded = path.replace("\\", "/") + if not encoded.startswith("/"): + encoded = "/" + encoded + loc = f"{encoded}{suffix}" + return { + "cursor": f"cursor://file{loc}", + "vscode": f"vscode://file{loc}", + "vscode-insiders": f"vscode-insiders://file{loc}", + "file": full.as_uri() + (f"#L{line}" if line and line > 0 else ""), + } + + +def open_in_editor( + repo_root: Path, + path: str, + line: int | None = None, + editor: str | None = None, +) -> dict[str, Any]: + full = _safe_file(repo_root, path) + urls = editor_urls(full, line) + wanted = (editor or os.environ.get("LOADPATH_EDITOR") or "auto").strip().lower() + commands: list[list[str]] = [] + if wanted in {"cursor", "auto"}: + binary = next((b for b in _EDITORS["cursor"] if shutil.which(b)), None) + if binary: + goto = f"{full}:{line}" if line and line > 0 else str(full) + commands.append([binary, "--goto", goto]) + if wanted in {"vscode", "code", "auto"}: + binary = next((b for b in _EDITORS["vscode"] if shutil.which(b)), None) + if binary: + args = [binary, "-g", f"{full}:{line}"] if line and line > 0 else [binary, str(full)] + commands.append(args) + if wanted in {"system", "auto"}: + if os.name == "nt": + commands.append(["cmd", "/c", "start", "", str(full)]) + elif sys.platform == "darwin": + commands.append(["open", str(full)]) + else: + commands.append(["xdg-open", str(full)]) + + last_error = "" + for cmd in commands: + try: + subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + return { + "ok": True, + "path": str(full.relative_to(repo_root.resolve())), + "abs_path": str(full), + "line": line, + "opened_with": cmd[0], + "urls": urls, + } + except OSError as exc: + last_error = str(exc) + return { + "ok": False, + "path": str(full.relative_to(repo_root.resolve())), + "abs_path": str(full), + "line": line, + "opened_with": None, + "urls": urls, + "error": last_error or "No editor binary found. Use the cursor:// or vscode:// link.", + } diff --git a/src/loadpath/review/engine.py b/src/loadpath/review/engine.py index b45754a..eda2375 100644 --- a/src/loadpath/review/engine.py +++ b/src/loadpath/review/engine.py @@ -16,6 +16,7 @@ from loadpath.review.contract import classify_contract_break from loadpath.review.diff import DiffSet, git_diff from loadpath.review.evolution import analyze_evolution +from loadpath.review.experience import attach_experience from loadpath.review.suggested_tests import suggested_tests as sketches_for from loadpath.review.trend import confidence_trend from loadpath.stitch.openapi import published_route @@ -528,6 +529,7 @@ def run_review( auth=auth, ), } + attach_experience(payload, seed_ids=seed_ids, repo_root=repo_root) store.save_review(payload["id"], payload["created_at"], str(repo_root), diff.base, diff.head, payload) payload["trend"] = confidence_trend(store, base=diff.base, head=diff.head) store.close() diff --git a/src/loadpath/review/experience.py b/src/loadpath/review/experience.py new file mode 100644 index 0000000..0deea8d --- /dev/null +++ b/src/loadpath/review/experience.py @@ -0,0 +1,540 @@ +"""Review experience: roles, checklist, marks, history, path isolate, health.""" + +from __future__ import annotations + +from collections import defaultdict +from typing import Any + +from loadpath.review.codeowners import review_codeowners +from loadpath.types import CONTRACT_TYPES, SINK_TYPES, EdgeType, NodeType + +SINK_TYPE_VALUES = {t.value for t in SINK_TYPES} +CONTRACT_TYPE_VALUES = {t.value for t in CONTRACT_TYPES} +TEST_TYPES = {NodeType.TEST.value, NodeType.REACT_TEST.value} + + +def tested_src_ids(edges: list[dict[str, Any]]) -> set[str]: + return {e["src"] for e in edges if e.get("type") == EdgeType.TESTED_BY.value} + + +def node_roles( + nodes: list[dict[str, Any]], + edges: list[dict[str, Any]], + seed_ids: set[str] | None = None, +) -> dict[str, list[str]]: + seeds = set(seed_ids or []) + tested = tested_src_ids(edges) + roles: dict[str, list[str]] = {} + for n in nodes: + nid = n.get("id") or "" + tags: list[str] = [] + ntype = n.get("type") or "" + extra = n.get("extra") or {} + if nid in seeds: + tags.append("seed") + elif seeds: + tags.append("downstream") + if ntype in SINK_TYPE_VALUES: + tags.append("sink") + if ntype in CONTRACT_TYPE_VALUES: + tags.append("contract") + if ntype in TEST_TYPES: + tags.append("test") + if nid in tested: + tags.append("tested") + elif ntype in SINK_TYPE_VALUES: + tags.append("untested") + if extra.get("inferred"): + tags.append("inferred") + roles[nid] = tags + for e in edges: + if (e.get("extra") or {}).get("overlap") or (e.get("confidence") or 1) < 0.8: + for key in (e.get("src"), e.get("dst")): + if key and key in roles and "inferred" not in roles[key]: + roles[key].append("inferred") + return roles + + +def contract_sides(nodes: list[dict[str, Any]], fields: list[str] | None = None) -> dict[str, Any]: + serializer: set[str] = set() + zod: set[str] = set() + openapi: set[str] = set() + graphql: set[str] = set() + for n in nodes: + extra = n.get("extra") or {} + ntype = n.get("type") or "" + if ntype in {NodeType.SERIALIZER_FIELD.value, NodeType.FIELD.value}: + if n.get("name"): + serializer.add(str(n["name"])) + if ntype == NodeType.SERIALIZER.value: + serializer.update(str(x) for x in (extra.get("fields") or []) if x) + if ntype == NodeType.FORM_SCHEMA.value: + zod.update(str(x) for x in (extra.get("fields") or extra.get("form_fields") or []) if x) + if ntype in {NodeType.COMPONENT.value, NodeType.PAGE.value}: + zod.update(str(x) for x in (extra.get("form_fields") or []) if x) + if ntype == NodeType.OPENAPI_PATH.value: + openapi.update(str(x) for x in (extra.get("fields") or []) if x) + if n.get("name"): + openapi.add(str(n["name"])) + if ntype in {NodeType.GRAPHQL_FIELD.value, NodeType.GRAPHQL_TYPE.value}: + if n.get("name"): + graphql.add(str(n["name"])) + graphql.update(str(x) for x in (extra.get("fields") or []) if x) + + hinted = [f for f in (fields or []) if f and f not in {"id", "pk", "extra_kwargs", "required"}] + names = sorted((serializer | zod | graphql | set(hinted)) - {"id", "pk"}) + rows: list[dict[str, Any]] = [] + for name in names[:40]: + in_ser = name in serializer + in_zod = name in zod + in_gql = name in graphql + if in_ser and (in_zod or in_gql or not (zod or graphql)): + status = "aligned" if (in_zod or in_gql or not (zod or graphql)) else "missing_client" + elif in_ser and not in_zod and zod: + status = "missing_client" + elif (in_zod or in_gql) and not in_ser and serializer: + status = "missing_server" + elif name in hinted: + status = "changed" + else: + status = "partial" + if in_ser and in_zod: + status = "aligned" + rows.append( + { + "field": name, + "serializer": in_ser, + "zod": in_zod, + "openapi": name in openapi, + "graphql": in_gql, + "status": status, + } + ) + return { + "serializer": sorted(serializer - {"id", "pk"})[:40], + "zod": sorted(zod)[:40], + "openapi": sorted(openapi)[:20], + "graphql": sorted(graphql)[:40], + "rows": rows, + } + + +def checklist(review: dict[str, Any]) -> list[dict[str, Any]]: + items: list[dict[str, Any]] = [] + conf = review.get("confidence") or {} + findings = [f for f in (review.get("findings") or []) if not f.get("waived")] + waived = [f for f in (review.get("findings") or []) if f.get("waived")] + sketches = {s.get("sink"): s for s in (review.get("suggested_tests") or [])} + + blockers = [f for f in findings if f.get("severity") == "blocker"] + warnings = [f for f in findings if f.get("severity") != "blocker"] + for f in blockers: + items.append( + { + "id": f"finding:{f.get('rule')}:{f.get('node_id') or f.get('message')}", + "kind": "finding", + "status": "todo", + "title": f"Fix blocker · {f.get('rule')}", + "detail": f.get("message") or "", + "node_id": f.get("node_id"), + "file_path": f.get("file_path"), + "rule": f.get("rule"), + "action": "fix", + } + ) + for f in warnings: + items.append( + { + "id": f"finding:{f.get('rule')}:{f.get('node_id') or f.get('message')}", + "kind": "finding", + "status": "todo", + "title": f"Resolve · {f.get('rule')}", + "detail": f.get("message") or "", + "node_id": f.get("node_id"), + "file_path": f.get("file_path"), + "rule": f.get("rule"), + "action": "fix", + } + ) + + contract = review.get("contract_break") or {} + if contract.get("kind") and contract["kind"] != "none": + items.append( + { + "id": f"contract:{contract['kind']}", + "kind": "contract", + "status": "todo" if contract["kind"] in {"breaking", "drift"} else "info", + "title": f"Contract {contract['kind']}", + "detail": "; ".join(contract.get("reasons") or []) or "Public contract changed", + "action": "review-contract", + } + ) + + auth = review.get("auth") or {} + for missing in auth.get("missing_permissions") or []: + items.append( + { + "id": f"auth:{missing.get('id')}", + "kind": "auth", + "status": "todo", + "title": f"Gate {missing.get('name')}", + "detail": auth.get("note") or "Missing permission_classes", + "node_id": missing.get("id"), + "action": "fix", + } + ) + + for sink in conf.get("untested_sinks") or []: + sketch = sketches.get(sink.get("name")) or sketches.get(sink.get("id")) + items.append( + { + "id": f"test:{sink.get('id')}", + "kind": "test", + "status": "todo", + "title": f"Test {sink.get('name')}", + "detail": (sketch or {}).get("title") or "Sink on the path has no test that still reaches the change", + "node_id": sink.get("id"), + "body": (sketch or {}).get("body"), + "action": "write-test", + } + ) + + for residual in (review.get("residuals") or [])[:8]: + items.append( + { + "id": f"residual:{residual[:80]}", + "kind": "residual", + "status": "info", + "title": "Residual the graph could not close", + "detail": residual, + "action": "ask-ai", + } + ) + + for f in waived: + items.append( + { + "id": f"waived:{f.get('rule')}:{f.get('node_id')}", + "kind": "waiver", + "status": "done", + "title": f"Waived · {f.get('rule')}", + "detail": f.get("message") or "", + "node_id": f.get("node_id"), + "file_path": f.get("file_path"), + "rule": f.get("rule"), + "action": "none", + } + ) + + todo = [i for i in items if i["status"] == "todo"] + if not todo and (conf.get("level") == "high" or review.get("low_risk")): + items.insert( + 0, + { + "id": "ready", + "kind": "ready", + "status": "done", + "title": "Ready to merge", + "detail": "No blockers, untested sinks, or breaking contract on this walk.", + "action": "none", + }, + ) + elif not todo and conf.get("level") == "medium": + items.insert( + 0, + { + "id": "glance", + "kind": "ready", + "status": "info", + "title": "Glance review", + "detail": "Medium confidence — read the residual list and contract panel.", + "action": "none", + }, + ) + return items + + +def file_marks(review: dict[str, Any]) -> list[dict[str, Any]]: + roles = review.get("node_roles") or node_roles( + review.get("nodes") or [], + review.get("edges") or [], + set(review.get("seed_ids") or []), + ) + by_path: dict[str, dict[str, Any]] = {} + for n in review.get("nodes") or []: + path = n.get("file_path") + if not path: + continue + tags = roles.get(n.get("id") or "", []) + current = by_path.setdefault( + path, + { + "path": path, + "line": n.get("start_line"), + "roles": [], + "node_id": n.get("id"), + "badge": "", + "tooltip": "", + }, + ) + for tag in tags: + if tag not in current["roles"]: + current["roles"].append(tag) + if n.get("start_line") and (current.get("line") is None or n["start_line"] < current["line"]): + current["line"] = n["start_line"] + current["node_id"] = n.get("id") + if "seed" in tags: + current["node_id"] = n.get("id") + current["line"] = n.get("start_line") or current.get("line") + + order = ["seed", "untested", "contract", "sink", "tested", "downstream"] + badge_for = { + "seed": "S", + "untested": "!", + "contract": "C", + "sink": "↓", + "tested": "✓", + "downstream": "→", + } + out: list[dict[str, Any]] = [] + for path, item in sorted(by_path.items()): + lead = next((r for r in order if r in item["roles"]), item["roles"][0] if item["roles"] else "path") + item["badge"] = badge_for.get(lead, "·") + item["tooltip"] = f"{path} — " + ", ".join(item["roles"] or ["on load path"]) + out.append(item) + return out + + +def isolate_paths( + nodes: list[dict[str, Any]], + edges: list[dict[str, Any]], + source_id: str, + target_id: str | None = None, +) -> dict[str, Any]: + """Keep nodes/edges on directed paths from source to target (or any sink).""" + ids = {n["id"] for n in nodes if n.get("id")} + if source_id not in ids: + return {"node_ids": [], "edge_ids": [], "targets": []} + succ: dict[str, list[tuple[str, str]]] = defaultdict(list) + pred: dict[str, list[tuple[str, str]]] = defaultdict(list) + for e in edges: + src, dst, eid = e.get("src"), e.get("dst"), e.get("id") + if src not in ids or dst not in ids or not eid: + continue + succ[src].append((dst, eid)) + pred[dst].append((src, eid)) + + sinks = {n["id"] for n in nodes if n.get("type") in SINK_TYPE_VALUES} + targets = {target_id} if target_id and target_id in ids else (sinks or ids) + if source_id in targets and target_id is None: + targets = (sinks - {source_id}) or targets + + reachable: set[str] = set() + stack = [source_id] + while stack: + cur = stack.pop() + if cur in reachable: + continue + reachable.add(cur) + for nxt, _ in succ.get(cur, []): + if nxt not in reachable: + stack.append(nxt) + + can_reach_target: set[str] = set() + stack = [t for t in targets if t in reachable] + seen_t = set(stack) + while stack: + cur = stack.pop() + can_reach_target.add(cur) + for prev, _ in pred.get(cur, []): + if prev in reachable and prev not in seen_t: + seen_t.add(prev) + stack.append(prev) + + keep = can_reach_target | {source_id} + if target_id: + keep.add(target_id) + edge_ids = [ + e["id"] + for e in edges + if e.get("src") in keep and e.get("dst") in keep and e.get("id") + ] + hit_targets = sorted(t for t in targets if t in keep and t != source_id) + return {"node_ids": sorted(keep), "edge_ids": edge_ids, "targets": hit_targets} + + +def summarize_stored_review(item: dict[str, Any]) -> dict[str, Any]: + payload = item.get("payload") or {} + conf = payload.get("confidence") or {} + contract = payload.get("contract_break") or {} + findings = [f for f in (payload.get("findings") or []) if not f.get("waived")] + return { + "id": item.get("id") or payload.get("id"), + "created_at": item.get("created_at") or payload.get("created_at"), + "base_ref": item.get("base_ref") or payload.get("base"), + "head_ref": item.get("head_ref") or payload.get("head"), + "title": payload.get("title"), + "level": conf.get("level"), + "sinks": conf.get("sinks"), + "covered_sinks": conf.get("covered_sinks"), + "contract_break": contract.get("kind"), + "findings": len(findings), + "low_risk": payload.get("low_risk"), + "labels": payload.get("labels") or [], + "what_if": bool(payload.get("what_if")), + "contexts": sorted( + {n.get("context") for n in (payload.get("nodes") or []) if n.get("context")} + ), + } + + +def diff_reviews(current: dict[str, Any], previous: dict[str, Any]) -> dict[str, Any]: + def sink_names(review: dict[str, Any]) -> set[str]: + return {s.get("name") or s.get("id") for s in (review.get("sinks") or []) if s} + + def finding_keys(review: dict[str, Any]) -> set[str]: + return { + f"{f.get('rule')}:{f.get('node_id') or f.get('message')}" + for f in (review.get("findings") or []) + if not f.get("waived") + } + + now, then = sink_names(current), sink_names(previous) + now_f, then_f = finding_keys(current), finding_keys(previous) + now_level = (current.get("confidence") or {}).get("level") + then_level = (previous.get("confidence") or {}).get("level") + now_kind = (current.get("contract_break") or {}).get("kind") or "none" + then_kind = (previous.get("contract_break") or {}).get("kind") or "none" + rank = {"high": 2, "medium": 1, "low": 0} + direction = "same" + if rank.get(now_level, -1) > rank.get(then_level, -1): + direction = "rose" + elif rank.get(now_level, -1) < rank.get(then_level, -1): + direction = "dropped" + added, removed = sorted(now - then), sorted(then - now) + note_bits = [] + if direction != "same": + note_bits.append(f"Confidence {direction} ({then_level} → {now_level})") + if added: + note_bits.append("New sinks: " + ", ".join(added[:4])) + if removed: + note_bits.append("Gone: " + ", ".join(removed[:4])) + if now_kind != then_kind: + note_bits.append(f"Contract {then_kind} → {now_kind}") + return { + "direction": direction, + "added_sinks": added, + "removed_sinks": removed, + "added_findings": len(now_f - then_f), + "removed_findings": len(then_f - now_f), + "from_level": then_level, + "to_level": now_level, + "from_contract": then_kind, + "to_contract": now_kind, + "note": "; ".join(note_bits) or "Same sinks and confidence as the compared walk.", + } + + +def architecture_health(reviews: list[dict[str, Any]]) -> dict[str, Any]: + """Pulse from stored reviews: confidence, findings, inferred-edge ratio, per-context hits.""" + points: list[dict[str, Any]] = [] + context_series: dict[str, list[dict[str, Any]]] = defaultdict(list) + for item in reviews: + payload = item.get("payload") or item + conf = payload.get("confidence") or {} + edges = payload.get("edges") or [] + inferred = sum(1 for e in edges if (e.get("confidence") or 1) < 0.8) + ratio = (inferred / len(edges)) if edges else 0.0 + findings = [f for f in (payload.get("findings") or []) if not f.get("waived")] + by_ctx: dict[str, int] = defaultdict(int) + nodes = {n.get("id"): n for n in (payload.get("nodes") or [])} + for f in findings: + ctx = (nodes.get(f.get("node_id") or "") or {}).get("context") or "unscoped" + by_ctx[ctx] += 1 + point = { + "id": item.get("id") or payload.get("id"), + "created_at": item.get("created_at") or payload.get("created_at"), + "level": conf.get("level"), + "sinks": conf.get("sinks") or 0, + "covered_sinks": conf.get("covered_sinks") or 0, + "findings": len(findings), + "inferred_ratio": round(ratio, 3), + "contexts": dict(by_ctx), + "title": payload.get("title"), + } + points.append(point) + for ctx, count in by_ctx.items(): + context_series[ctx].append( + {"created_at": point["created_at"], "findings": count, "level": point["level"]} + ) + points.sort(key=lambda p: p.get("created_at") or "") + return { + "points": points[-24:], + "contexts": {k: v[-24:] for k, v in sorted(context_series.items())}, + } + + +def match_reviews_to_prs( + summaries: list[dict[str, Any]], + pull_requests: list[dict[str, Any]], +) -> list[dict[str, Any]]: + out: list[dict[str, Any]] = [] + for pr in pull_requests: + item = dict(pr) + source = str(pr.get("source_branch") or "") + target = str(pr.get("target_branch") or "") + head_sha = str(pr.get("head_sha") or "") + base_sha = str(pr.get("base_sha") or "") + hit = None + for summary in summaries: + head = str(summary.get("head_ref") or "") + base = str(summary.get("base_ref") or "") + if head_sha and head.startswith(head_sha[:7]): + hit = summary + break + if source and (head == source or head.endswith("/" + source)): + if not target or base == target or target in base: + hit = summary + break + if base_sha and base.startswith(base_sha[:7]) and head_sha and head.startswith(head_sha[:7]): + hit = summary + break + if hit: + item["loadpath"] = hit + out.append(item) + return out + + +def attach_experience( + review: dict[str, Any], + *, + seed_ids: set[str] | None = None, + repo_root: Any | None = None, +) -> dict[str, Any]: + """Fill roles, checklist, marks, contract sides, CODEOWNERS. Safe on old stored reviews.""" + nodes = review.get("nodes") or [] + edges = review.get("edges") or [] + seeds = set(seed_ids or review.get("seed_ids") or []) + if not seeds: + seeds = { + n["id"] + for n in nodes + if n.get("id") and (n.get("file_path") in {r.get("path") for r in (review.get("read_order") or [])}) + } + review["seed_ids"] = sorted(seeds) + review["node_roles"] = node_roles(nodes, edges, seeds) + contract = dict(review.get("contract_break") or {}) + if "sides" not in contract: + contract["sides"] = contract_sides(nodes, contract.get("fields") or []) + review["contract_break"] = contract + review["checklist"] = checklist(review) + review["marks"] = file_marks(review) + if repo_root is not None and "codeowners" not in review: + paths = [r.get("path") for r in (review.get("read_order") or []) if r.get("path")] + paths.extend(n.get("file_path") for n in nodes if n.get("file_path")) + review["codeowners"] = review_codeowners(repo_root, [p for p in paths if p]) + yml = list(review.get("suggested_reviewers") or []) + extra = [o for o in (review["codeowners"].get("owners") or []) if o not in yml] + review["codeowners_reviewers"] = extra + review["suggested_reviewers"] = yml + extra + return review diff --git a/src/loadpath/review/whatif.py b/src/loadpath/review/whatif.py index 22b11ce..dbbbf25 100644 --- a/src/loadpath/review/whatif.py +++ b/src/loadpath/review/whatif.py @@ -23,6 +23,7 @@ collect_residuals, suggested_reviewers, ) +from loadpath.review.experience import attach_experience def simulate_node(repo_root: Path, node_id: str, *, hops: int = 8) -> dict: @@ -82,6 +83,7 @@ def simulate_node(repo_root: Path, node_id: str, *, hops: int = 8) -> dict: "seed_type": seed.get("type"), "counts": {"nodes": len(nodes), "edges": len(edges)}, } + attach_experience(payload, seed_ids={node_id}, repo_root=repo_root) store.close() return payload diff --git a/src/loadpath/server/app.py b/src/loadpath/server/app.py index 8d972c4..295d3bb 100644 --- a/src/loadpath/server/app.py +++ b/src/loadpath/server/app.py @@ -6,7 +6,7 @@ from fastapi import FastAPI, HTTPException, Query, Request from fastapi.middleware.cors import CORSMiddleware -from fastapi.responses import HTMLResponse +from fastapi.responses import HTMLResponse, Response from fastapi.staticfiles import StaticFiles from pydantic import BaseModel, Field import httpx @@ -25,7 +25,7 @@ ) from loadpath.ai.providers import client_for, residual_prompt from loadpath.architecture.snapshot import architecture_graph, architecture_report, summarize_index -from loadpath.config import load_config +from loadpath.config import load_config, config_document, write_config, add_waiver from loadpath.detect import detect_layout, write_draft_config from loadpath.graph.store import GraphStore from loadpath.index import default_db_path, index_repo @@ -44,9 +44,18 @@ ) from loadpath.providers.scm import attach_local_paths, provider_for from loadpath.review.engine import run_review +from loadpath.review.experience import ( + architecture_health, + attach_experience, + diff_reviews, + isolate_paths, + match_reviews_to_prs, + summarize_stored_review, +) +from loadpath.review.editor import open_in_editor from loadpath.review.render import render_html, render_markdown from loadpath.settings import AppSettings, public_settings, register_workspace, settings_path, _should_update_secret -from loadpath.workspace import DEFAULT_COMMIT_LIMIT, list_directory, list_git_refs +from loadpath.workspace import DEFAULT_COMMIT_LIMIT, list_directory, list_git_refs, workspace_status class IndexRequest(BaseModel): @@ -106,6 +115,7 @@ class PRListRequest(BaseModel): state: str = "open" token: str | None = None username: str | None = None + repo_path: str | None = None class ResidualRequest(BaseModel): @@ -134,6 +144,46 @@ class PRReviewRequest(BaseModel): incremental: bool = True +class ConfigUpdate(BaseModel): + repo_path: str + contexts: dict[str, Any] | None = None + rules: list[str] | None = None + waivers: list[dict[str, Any]] | None = None + django_root: str | None = None + react_root: str | None = None + openapi_paths: list[str] | None = None + boot_django: bool | None = None + layers: dict[str, Any] | None = None + + +class WaiverRequest(BaseModel): + repo_path: str + rule: str + node: str | None = None + reason: str = "" + + +class OpenEditorRequest(BaseModel): + repo_path: str + path: str + line: int | None = None + editor: str | None = None + + +class ExportRequest(BaseModel): + repo_path: str | None = None + review_id: str | None = None + review: dict[str, Any] | None = None + + +class IsolateRequest(BaseModel): + repo_path: str | None = None + nodes: list[dict[str, Any]] = Field(default_factory=list) + edges: list[dict[str, Any]] = Field(default_factory=list) + source_id: str + target_id: str | None = None + + def require_repo_path(path: str | None) -> Path: if not (path or "").strip(): raise HTTPException(400, "repo_path is required") @@ -183,6 +233,31 @@ def require_loopback(request: Request) -> None: raise HTTPException(403, "SCM sign-in and repo listing are only available from the local Loadpath UI") +def _attach_loadpath(listed: list[dict[str, Any]], repo_path: str | None) -> list[dict[str, Any]]: + if not repo_path: + return listed + root = require_repo_path(repo_path) + db = default_db_path(root) + if not db.is_file(): + return listed + store = GraphStore(db) + summaries = [summarize_stored_review(item) for item in store.list_reviews(include_payload=True, limit=40)] + store.close() + return match_reviews_to_prs(summaries, listed) + + +def _hydrate_review(item: dict[str, Any]) -> dict[str, Any]: + payload = dict(item.get("payload") or {}) + payload.setdefault("id", item.get("id")) + payload.setdefault("created_at", item.get("created_at")) + payload.setdefault("base", item.get("base_ref") or payload.get("base")) + payload.setdefault("head", item.get("head_ref") or payload.get("head")) + root = item.get("repo_root") + attach_experience(payload, repo_root=Path(root) if root else None) + payload["markdown"] = render_markdown(payload) + return payload + + def create_app( public_url: str | None = None, oauth_pin: str | None = None, @@ -382,25 +457,54 @@ def api_review(body: ReviewRequest) -> dict[str, Any]: return review @app.get("/api/reviews") - def api_reviews(repo_path: str) -> dict[str, Any]: + def api_reviews(repo_path: str, limit: int = 40) -> dict[str, Any]: root = require_repo_path(repo_path) db = default_db_path(root) if not db.is_file(): return {"reviews": []} store = GraphStore(db) - items = store.list_reviews() + items = store.list_reviews(include_payload=True, limit=limit) store.close() - return {"reviews": items} + return {"reviews": [summarize_stored_review(item) for item in items]} @app.get("/api/reviews/{review_id}") def api_review_get(review_id: str, repo_path: str) -> dict[str, Any]: + root = require_repo_path(repo_path) + db = default_db_path(root) + if not db.is_file(): + raise HTTPException(404, "Review not found") + store = GraphStore(db) + item = store.get_review(review_id) + store.close() + if not item: + raise HTTPException(404, "Review not found") + return _hydrate_review(item) + + @app.get("/api/reviews/{review_id}/diff") + def api_review_diff(review_id: str, repo_path: str, other: str) -> dict[str, Any]: + root = require_repo_path(repo_path) + store = GraphStore(default_db_path(root)) + current = store.get_review(review_id) + previous = store.get_review(other) + store.close() + if not current or not previous: + raise HTTPException(404, "Review not found") + return diff_reviews(_hydrate_review(current), _hydrate_review(previous)) + + @app.get("/api/reviews/{review_id}/html") + def api_review_html(review_id: str, repo_path: str) -> Response: root = require_repo_path(repo_path) store = GraphStore(default_db_path(root)) item = store.get_review(review_id) store.close() if not item: raise HTTPException(404, "Review not found") - return item + html = render_html(_hydrate_review(item)) + return Response( + content=html, + media_type="text/html", + headers={"Content-Disposition": f'attachment; filename="loadpath-{review_id[:8]}.html"'}, + ) @app.get("/api/graph") def api_graph(repo_path: str, scope: str = "full") -> dict[str, Any]: @@ -425,14 +529,96 @@ def api_architecture(repo_path: str) -> dict[str, Any]: @app.get("/api/config") def api_config(repo_path: str) -> dict[str, Any]: root = require_repo_path(repo_path) - cfg = load_config(root) + return config_document(load_config(root)) + + @app.put("/api/config") + def api_config_put(body: ConfigUpdate) -> dict[str, Any]: + root = require_repo_path(body.repo_path) + document = body.model_dump(exclude_unset=True) + document.pop("repo_path", None) + return write_config(root, document) + + @app.post("/api/config/waiver") + def api_config_waiver(body: WaiverRequest) -> dict[str, Any]: + root = require_repo_path(body.repo_path) + if not body.rule.strip(): + raise HTTPException(400, "rule is required") + return add_waiver(root, body.rule.strip(), body.node, body.reason) + + @app.get("/api/marks") + def api_marks(repo_path: str, review_id: str | None = None) -> dict[str, Any]: + root = require_repo_path(repo_path) + db = default_db_path(root) + if not db.is_file(): + return {"repo_path": str(root), "review_id": None, "files": []} + store = GraphStore(db) + item = store.get_review(review_id) if review_id else None + if item is None: + listed = store.list_reviews(include_payload=True, limit=1) + item = listed[0] if listed else None + store.close() + if not item: + return {"repo_path": str(root), "review_id": None, "files": []} + payload = _hydrate_review(item) return { - "contexts": {k: vars(v) for k, v in cfg.contexts.items()}, - "rules": cfg.rules, - "django_root": cfg.django_root, - "react_root": cfg.react_root, + "repo_path": str(root), + "review_id": payload.get("id"), + "title": payload.get("title"), + "level": (payload.get("confidence") or {}).get("level"), + "files": payload.get("marks") or [], } + @app.get("/api/architecture/health") + def api_architecture_health(repo_path: str) -> dict[str, Any]: + root = require_repo_path(repo_path) + db = default_db_path(root) + if not db.is_file(): + return {"points": [], "contexts": {}} + store = GraphStore(db) + items = store.list_reviews(include_payload=True, limit=40) + store.close() + return architecture_health(items) + + @app.get("/api/workspace/status") + def api_workspace_status(repo_path: str) -> dict[str, Any]: + root = require_repo_path(repo_path) + return workspace_status(root) + + @app.post("/api/open") + def api_open(body: OpenEditorRequest) -> dict[str, Any]: + root = require_repo_path(body.repo_path) + try: + return open_in_editor(root, body.path, body.line, body.editor) + except ValueError as exc: + raise HTTPException(400, str(exc)) from exc + except FileNotFoundError as exc: + raise HTTPException(404, str(exc)) from exc + + @app.post("/api/export/html") + def api_export_html(body: ExportRequest) -> Response: + review = body.review + if not review and body.repo_path and body.review_id: + root = require_repo_path(body.repo_path) + store = GraphStore(default_db_path(root)) + item = store.get_review(body.review_id) + store.close() + if not item: + raise HTTPException(404, "Review not found") + review = _hydrate_review(item) + if not review: + raise HTTPException(400, "review or review_id is required") + html = render_html(review) + name = (review.get("id") or "review")[:8] + return Response( + content=html, + media_type="text/html", + headers={"Content-Disposition": f'attachment; filename="loadpath-{name}.html"'}, + ) + + @app.post("/api/graph/isolate") + def api_graph_isolate(body: IsolateRequest) -> dict[str, Any]: + return isolate_paths(body.nodes, body.edges, body.source_id, body.target_id) + @app.post("/api/prs") def api_prs(body: PRListRequest) -> dict[str, Any]: settings = AppSettings.load() @@ -447,7 +633,7 @@ def api_prs(body: PRListRequest) -> dict[str, Any]: raise HTTPException(400, str(exc)) from exc except Exception as exc: # noqa: BLE001 raise HTTPException(502, str(exc)) from exc - return {"pull_requests": [p.to_dict() for p in prs]} + return {"pull_requests": _attach_loadpath([p.to_dict() for p in prs], body.repo_path)} try: prs = _call_scm(body.provider, lambda scm: scm.list_pull_requests(body.repo, state=body.state)) except HTTPException: @@ -456,7 +642,7 @@ def api_prs(body: PRListRequest) -> dict[str, Any]: raise HTTPException(400, str(exc)) from exc except Exception as exc: # noqa: BLE001 raise HTTPException(502, str(exc)) from exc - return {"pull_requests": [p.to_dict() for p in prs]} + return {"pull_requests": _attach_loadpath([p.to_dict() for p in prs], body.repo_path)} @app.post("/api/init") def api_init(body: InitRequest) -> dict[str, Any]: diff --git a/src/loadpath/static/assets/LayeredGraph3D-DBrjUozl.js b/src/loadpath/static/assets/LayeredGraph3D-B-dkkPpV.js similarity index 99% rename from src/loadpath/static/assets/LayeredGraph3D-DBrjUozl.js rename to src/loadpath/static/assets/LayeredGraph3D-B-dkkPpV.js index f5edaf4..2b386f8 100644 --- a/src/loadpath/static/assets/LayeredGraph3D-DBrjUozl.js +++ b/src/loadpath/static/assets/LayeredGraph3D-B-dkkPpV.js @@ -1,4 +1,4 @@ -import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-PXVMaQl_.js";/** +import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-Dg2mxCJ9.js";/** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT diff --git a/src/loadpath/static/assets/index-C3YNVD8c.css b/src/loadpath/static/assets/index-Bmsup5i5.css similarity index 86% rename from src/loadpath/static/assets/index-C3YNVD8c.css rename to src/loadpath/static/assets/index-Bmsup5i5.css index a7121cf..9546aef 100644 --- a/src/loadpath/static/assets/index-C3YNVD8c.css +++ b/src/loadpath/static/assets/index-Bmsup5i5.css @@ -1 +1 @@ -.react-flow{direction:ltr;--xy-edge-stroke-default: #b1b1b7;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #555;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(255, 255, 255, .5);--xy-minimap-background-color-default: #fff;--xy-minimap-mask-background-color-default: rgba(240, 240, 240, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #e2e2e2;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: transparent;--xy-background-pattern-dots-color-default: #91919a;--xy-background-pattern-lines-color-default: #eee;--xy-background-pattern-cross-color-default: #e2e2e2;background-color:var(--xy-background-color, var(--xy-background-color-default));--xy-node-color-default: inherit;--xy-node-border-default: 1px solid #1a192b;--xy-node-background-color-default: #fff;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #1a192b;--xy-node-border-radius-default: 3px;--xy-handle-background-color-default: #1a192b;--xy-handle-border-color-default: #fff;--xy-selection-background-color-default: rgba(0, 89, 220, .08);--xy-selection-border-default: 1px dotted rgba(0, 89, 220, .8);--xy-controls-button-background-color-default: #fefefe;--xy-controls-button-background-color-hover-default: #f4f4f4;--xy-controls-button-color-default: inherit;--xy-controls-button-color-hover-default: inherit;--xy-controls-button-border-color-default: #eee;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #ffffff;--xy-edge-label-color-default: inherit;--xy-resize-background-color-default: #3367d9}.react-flow.dark{--xy-edge-stroke-default: #3e3e3e;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #727272;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(150, 150, 150, .25);--xy-minimap-background-color-default: #141414;--xy-minimap-mask-background-color-default: rgba(60, 60, 60, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #2b2b2b;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: #141414;--xy-background-pattern-dots-color-default: #555;--xy-background-pattern-lines-color-default: #333;--xy-background-pattern-cross-color-default: #333;--xy-node-color-default: #f8f8f8;--xy-node-border-default: 1px solid #3c3c3c;--xy-node-background-color-default: #1e1e1e;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #999;--xy-handle-background-color-default: #bebebe;--xy-handle-border-color-default: #1e1e1e;--xy-selection-background-color-default: rgba(200, 200, 220, .08);--xy-selection-border-default: 1px dotted rgba(200, 200, 220, .8);--xy-controls-button-background-color-default: #2b2b2b;--xy-controls-button-background-color-hover-default: #3e3e3e;--xy-controls-button-color-default: #f8f8f8;--xy-controls-button-color-hover-default: #fff;--xy-controls-button-border-color-default: #5b5b5b;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #141414;--xy-edge-label-color-default: #f8f8f8}.react-flow__background{background-color:var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1;touch-action:none}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{overflow:visible;position:absolute;pointer-events:none}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__arrowhead polyline{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:dashdraw .5s linear infinite}svg.react-flow__connectionline{z-index:1001;overflow:visible;position:absolute}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background-color:var(--xy-handle-background-color, var(--xy-handle-background-color-default));border:1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));border-radius:100%}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:0;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__pane.selection .react-flow__panel{pointer-events:none}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.top.center,.react-flow__panel.bottom.center{left:50%;transform:translate(-15px) translate(-50%)}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.left.center,.react-flow__panel.right.center{top:50%;transform:translateY(-15px) translateY(-50%)}.react-flow__attribution{font-size:10px;background:var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;left:0;top:0}.react-flow__viewport-portal{position:absolute;width:100%;height:100%;left:0;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__minimap{background:var( --xy-minimap-background-color-props, var(--xy-minimap-background-color, var(--xy-minimap-background-color-default)) )}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var( --xy-minimap-mask-background-color-props, var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default)) );stroke:var( --xy-minimap-mask-stroke-color-props, var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default)) );stroke-width:var( --xy-minimap-mask-stroke-width-props, var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default)) )}.react-flow__minimap-node{fill:var( --xy-minimap-node-background-color-props, var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default)) );stroke:var( --xy-minimap-node-stroke-color-props, var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default)) );stroke-width:var( --xy-minimap-node-stroke-width-props, var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default)) )}.react-flow__background-pattern.dots{fill:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default)) )}.react-flow__background-pattern.lines{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default)) )}.react-flow__background-pattern.cross{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default)) )}.react-flow__controls{display:flex;flex-direction:column;box-shadow:var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default))}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{display:flex;justify-content:center;align-items:center;height:26px;width:26px;padding:4px;border:none;background:var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));border-bottom:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) );color:var( --xy-controls-button-color-props, var(--xy-controls-button-color, var(--xy-controls-button-color-default)) );cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px;fill:currentColor}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:var(--xy-node-border-radius, var(--xy-node-border-radius-default));width:150px;font-size:12px;color:var(--xy-node-color, var(--xy-node-color-default));text-align:center;border:var(--xy-node-border, var(--xy-node-border-default));background-color:var(--xy-node-background-color, var(--xy-node-background-color-default))}.react-flow__node-input.selectable:hover,.react-flow__node-default.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default))}.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default))}.react-flow__node-group{background-color:var(--xy-node-group-background-color, var(--xy-node-group-background-color-default))}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color, var(--xy-selection-background-color-default));border:var(--xy-selection-border, var(--xy-selection-border-default))}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls-button:hover{background:var( --xy-controls-button-background-color-hover-props, var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default)) );color:var( --xy-controls-button-color-hover-props, var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default)) )}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__controls-button:last-child{border-bottom:none}.react-flow__controls.horizontal .react-flow__controls-button{border-bottom:none;border-right:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) )}.react-flow__controls.horizontal .react-flow__controls-button:last-child{border-right:none}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:5px;height:5px;border:1px solid #fff;border-radius:1px;background-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));translate:-50% -50%}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}.react-flow__edge-textbg{fill:var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default))}.react-flow__edge-text{fill:var(--xy-edge-label-color, var(--xy-edge-label-color-default))}:root,[data-theme=obsidian]{--bg: #070b10;--bg-2: #0d141c;--surface: #121a24;--line: #1e2c3c;--ink: #e7eef6;--muted: #8b9bb0;--high: #2a9d8f;--medium: #e9c46a;--low: #e76f51;--critical: #e85d04;--accent: #4cc9f0;--rail-from: #0b1219;--rail-to: #070b10;--rail-active: #15202c;--btn: #173044;--btn-line: #24506c;--btn-primary: #134e4a;--btn-primary-line: #2a9d8f;--node-bg: #101822;--node-line: #2a3d52;--graph-bg: #070b10;--graph-grid: rgba(42, 80, 120, .09);--edge-cheap: #4a5568;--edge-expensive: #f4a261;--edge-critical: #e85d04;--shadow: rgba(76, 201, 240, .08)}[data-theme=nord]{--bg: #2e3440;--bg-2: #3b4252;--surface: #434c5e;--line: #4c566a;--ink: #eceff4;--muted: #d8dee9;--high: #a3be8c;--medium: #ebcb8b;--low: #bf616a;--critical: #d08770;--accent: #88c0d0;--rail-from: #3b4252;--rail-to: #2e3440;--rail-active: #4c566a;--btn: #434c5e;--btn-line: #81a1c1;--btn-primary: #5e81ac;--btn-primary-line: #88c0d0;--node-bg: #3b4252;--node-line: #81a1c1;--graph-bg: #2e3440;--graph-grid: rgba(136, 192, 208, .12);--edge-cheap: #4c566a;--edge-expensive: #d08770;--edge-critical: #bf616a;--shadow: rgba(136, 192, 208, .12)}[data-theme=solarized-dark]{--bg: #002b36;--bg-2: #073642;--surface: #0a3944;--line: #16444f;--ink: #eee8d5;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #2aa198;--rail-from: #073642;--rail-to: #002b36;--rail-active: #16444f;--btn: #073642;--btn-line: #268bd2;--btn-primary: #0a4a42;--btn-primary-line: #2aa198;--node-bg: #073642;--node-line: #268bd2;--graph-bg: #002b36;--graph-grid: rgba(42, 161, 152, .12);--edge-cheap: #586e75;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(42, 161, 152, .12)}[data-theme=forest]{--bg: #0e1510;--bg-2: #152019;--surface: #1b2a20;--line: #2c4334;--ink: #e4f0e6;--muted: #8eaa96;--high: #6ab04c;--medium: #c8a951;--low: #e17055;--critical: #d35400;--accent: #7bed9f;--rail-from: #152019;--rail-to: #0e1510;--rail-active: #1f3326;--btn: #1f3326;--btn-line: #3d6b4f;--btn-primary: #1e4d32;--btn-primary-line: #6ab04c;--node-bg: #16241b;--node-line: #3d6b4f;--graph-bg: #0e1510;--graph-grid: rgba(123, 237, 159, .1);--edge-cheap: #3d6b4f;--edge-expensive: #c8a951;--edge-critical: #d35400;--shadow: rgba(123, 237, 159, .1)}[data-theme=rose]{--bg: #191724;--bg-2: #1f1d2e;--surface: #26233a;--line: #403d52;--ink: #e0def4;--muted: #908caa;--high: #9ccfd8;--medium: #f6c177;--low: #eb6f92;--critical: #eb6f92;--accent: #c4a7e7;--rail-from: #1f1d2e;--rail-to: #191724;--rail-active: #26233a;--btn: #26233a;--btn-line: #c4a7e7;--btn-primary: #3a2f4d;--btn-primary-line: #c4a7e7;--node-bg: #1f1d2e;--node-line: #524f67;--graph-bg: #191724;--graph-grid: rgba(196, 167, 231, .12);--edge-cheap: #524f67;--edge-expensive: #f6c177;--edge-critical: #eb6f92;--shadow: rgba(196, 167, 231, .12)}[data-theme=amber]{--bg: #120e0a;--bg-2: #1c1610;--surface: #261e16;--line: #3d2f22;--ink: #f4e6d0;--muted: #b59a78;--high: #c4d6a0;--medium: #e9b44c;--low: #d8572a;--critical: #c0392b;--accent: #f0a05a;--rail-from: #1c1610;--rail-to: #120e0a;--rail-active: #2b2218;--btn: #2b2218;--btn-line: #8a5a2b;--btn-primary: #4a3418;--btn-primary-line: #f0a05a;--node-bg: #1c1610;--node-line: #8a5a2b;--graph-bg: #120e0a;--graph-grid: rgba(240, 160, 90, .12);--edge-cheap: #5c4a38;--edge-expensive: #e9b44c;--edge-critical: #d8572a;--shadow: rgba(240, 160, 90, .12)}[data-theme=volcano]{--bg: #14090a;--bg-2: #1e0e10;--surface: #2a1416;--line: #4a2226;--ink: #fde8e4;--muted: #c48b86;--high: #7bed9f;--medium: #f6c90e;--low: #ff6b6b;--critical: #ff3b3b;--accent: #ff7b54;--rail-from: #1e0e10;--rail-to: #14090a;--rail-active: #32181b;--btn: #32181b;--btn-line: #ff7b54;--btn-primary: #5a1f18;--btn-primary-line: #ff7b54;--node-bg: #1e0e10;--node-line: #7a3330;--graph-bg: #14090a;--graph-grid: rgba(255, 123, 84, .12);--edge-cheap: #5a3330;--edge-expensive: #ff7b54;--edge-critical: #ff3b3b;--shadow: rgba(255, 123, 84, .14)}[data-theme=lavender]{--bg: #12101c;--bg-2: #1a1730;--surface: #221e3c;--line: #3b3560;--ink: #efeaff;--muted: #b3a7d6;--high: #80ffdb;--medium: #ffd166;--low: #ff6b9d;--critical: #ff4d6d;--accent: #c77dff;--rail-from: #1a1730;--rail-to: #12101c;--rail-active: #2a2550;--btn: #2a2550;--btn-line: #c77dff;--btn-primary: #3d2a66;--btn-primary-line: #c77dff;--node-bg: #1a1730;--node-line: #5a4d8a;--graph-bg: #12101c;--graph-grid: rgba(199, 125, 255, .12);--edge-cheap: #5a4d8a;--edge-expensive: #ffd166;--edge-critical: #ff4d6d;--shadow: rgba(199, 125, 255, .14)}[data-theme=neon-noir]{--bg: #05060a;--bg-2: #0a0c14;--surface: #10131c;--line: #1e2436;--ink: #f0f4ff;--muted: #8b93b0;--high: #39ff88;--medium: #ffe66d;--low: #ff2d95;--critical: #ff3d5a;--accent: #00f0ff;--rail-from: #0a0c14;--rail-to: #05060a;--rail-active: #151a2a;--btn: #151a2a;--btn-line: #00f0ff;--btn-primary: #063a40;--btn-primary-line: #00f0ff;--node-bg: #0a0c14;--node-line: #2a3550;--graph-bg: #05060a;--graph-grid: rgba(0, 240, 255, .12);--edge-cheap: #3a4560;--edge-expensive: #ff2d95;--edge-critical: #ff3d5a;--shadow: rgba(0, 240, 255, .22)}[data-theme=synthwave]{--bg: #1a0a2e;--bg-2: #240b3d;--surface: #2d1250;--line: #4a1d7a;--ink: #ffe6fb;--muted: #c49ad8;--high: #00f5d4;--medium: #ffd60a;--low: #ff6b9d;--critical: #ff006e;--accent: #ff2bd6;--rail-from: #240b3d;--rail-to: #1a0a2e;--rail-active: #3a1570;--btn: #3a1570;--btn-line: #ff2bd6;--btn-primary: #5a0a4a;--btn-primary-line: #ff2bd6;--node-bg: #240b3d;--node-line: #7b2cbf;--graph-bg: #1a0a2e;--graph-grid: rgba(255, 43, 214, .16);--edge-cheap: #5a3a80;--edge-expensive: #ff9e00;--edge-critical: #ff006e;--shadow: rgba(255, 43, 214, .24)}[data-theme=phosphor]{--bg: #020804;--bg-2: #061208;--surface: #0a1a0e;--line: #163c1e;--ink: #c8ffc8;--muted: #5aaa5a;--high: #39ff14;--medium: #c8f542;--low: #ffb000;--critical: #ff5e00;--accent: #00ff66;--rail-from: #061208;--rail-to: #020804;--rail-active: #0e2414;--btn: #0e2414;--btn-line: #00ff66;--btn-primary: #0a3a18;--btn-primary-line: #00ff66;--node-bg: #061208;--node-line: #1e6a32;--graph-bg: #020804;--graph-grid: rgba(0, 255, 102, .12);--edge-cheap: #1e5a2a;--edge-expensive: #c8f542;--edge-critical: #ff5e00;--shadow: rgba(0, 255, 102, .2)}[data-theme=aurora]{--bg: #071018;--bg-2: #0c1c28;--surface: #122636;--line: #1e3d52;--ink: #e8fff6;--muted: #7eb8a8;--high: #5fffcf;--medium: #ffe566;--low: #ff7eb6;--critical: #ff4d6d;--accent: #7cffb2;--rail-from: #0c1c28;--rail-to: #071018;--rail-active: #163044;--btn: #163044;--btn-line: #7cffb2;--btn-primary: #0e3d3a;--btn-primary-line: #7cffb2;--node-bg: #0c1c28;--node-line: #2a6a78;--graph-bg: #071018;--graph-grid: rgba(124, 255, 178, .12);--edge-cheap: #2a5a68;--edge-expensive: #c9a0ff;--edge-critical: #ff4d6d;--shadow: rgba(124, 255, 178, .18)}[data-theme=biolume]{--bg: #02141c;--bg-2: #042430;--surface: #073040;--line: #0a4a5c;--ink: #e6fffb;--muted: #6eb8b0;--high: #5dffb0;--medium: #ffe066;--low: #ff79c6;--critical: #ff4d6d;--accent: #18e7d4;--rail-from: #042430;--rail-to: #02141c;--rail-active: #0a3848;--btn: #0a3848;--btn-line: #18e7d4;--btn-primary: #0a4a48;--btn-primary-line: #18e7d4;--node-bg: #042430;--node-line: #1a7080;--graph-bg: #02141c;--graph-grid: rgba(24, 231, 212, .12);--edge-cheap: #1a5a68;--edge-expensive: #ff79c6;--edge-critical: #ff4d6d;--shadow: rgba(24, 231, 212, .2)}[data-theme=carbon]{--bg: #0d0d0f;--bg-2: #16161a;--surface: #1e1e24;--line: #33333c;--ink: #f2f2f4;--muted: #9a9aa8;--high: #3dd68c;--medium: #f0c040;--low: #ff5a5a;--critical: #ff2a2a;--accent: #ff2a2a;--rail-from: #16161a;--rail-to: #0d0d0f;--rail-active: #24242c;--btn: #24242c;--btn-line: #ff2a2a;--btn-primary: #4a1212;--btn-primary-line: #ff2a2a;--node-bg: #16161a;--node-line: #4a4a55;--graph-bg: #0d0d0f;--graph-grid: rgba(255, 42, 42, .1);--edge-cheap: #4a4a55;--edge-expensive: #ff8a3d;--edge-critical: #ff2a2a;--shadow: rgba(255, 42, 42, .18)}[data-theme=paper]{--bg: #f6f1e8;--bg-2: #efe6d6;--surface: #fffaf2;--line: #d9cbb6;--ink: #2b241c;--muted: #6f6456;--high: #2a7a4b;--medium: #b5811a;--low: #c0392b;--critical: #a93226;--accent: #1d6a7a;--rail-from: #efe6d6;--rail-to: #e7dcc8;--rail-active: #e2d3bb;--btn: #fffaf2;--btn-line: #c9b79a;--btn-primary: #d7eee0;--btn-primary-line: #2a7a4b;--node-bg: #fffaf2;--node-line: #c9b79a;--graph-bg: #f6f1e8;--graph-grid: rgba(29, 106, 122, .1);--edge-cheap: #b7a48c;--edge-expensive: #c0392b;--edge-critical: #a93226;--shadow: rgba(43, 36, 28, .08)}[data-theme=solarized-light]{--bg: #fdf6e3;--bg-2: #eee8d5;--surface: #f5efdc;--line: #d6cba9;--ink: #657b83;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #268bd2;--rail-from: #eee8d5;--rail-to: #e6dfc8;--rail-active: #e0d9c0;--btn: #fdf6e3;--btn-line: #93a1a1;--btn-primary: #e8efc8;--btn-primary-line: #859900;--node-bg: #fdf6e3;--node-line: #93a1a1;--graph-bg: #fdf6e3;--graph-grid: rgba(38, 139, 210, .12);--edge-cheap: #93a1a1;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(101, 123, 131, .1)}[data-theme=seafoam]{--bg: #eef7f4;--bg-2: #dff0ea;--surface: #ffffff;--line: #b7d5cc;--ink: #17332c;--muted: #4d7268;--high: #1b8a5a;--medium: #c48a14;--low: #c44536;--critical: #9b2d22;--accent: #1d9a8a;--rail-from: #dff0ea;--rail-to: #cfe6de;--rail-active: #c4ddd4;--btn: #ffffff;--btn-line: #8fbfb2;--btn-primary: #d4f0e4;--btn-primary-line: #1b8a5a;--node-bg: #ffffff;--node-line: #8fbfb2;--graph-bg: #eef7f4;--graph-grid: rgba(29, 154, 138, .12);--edge-cheap: #8fbfb2;--edge-expensive: #c48a14;--edge-critical: #c44536;--shadow: rgba(23, 51, 44, .08)}[data-theme=high-contrast]{--bg: #ffffff;--bg-2: #f2f2f2;--surface: #ffffff;--line: #111111;--ink: #000000;--muted: #222222;--high: #007a33;--medium: #8a5a00;--low: #b00000;--critical: #9b0000;--accent: #0033cc;--rail-from: #f2f2f2;--rail-to: #e6e6e6;--rail-active: #d9d9d9;--btn: #ffffff;--btn-line: #000000;--btn-primary: #d9f2e3;--btn-primary-line: #007a33;--node-bg: #ffffff;--node-line: #000000;--graph-bg: #ffffff;--graph-grid: rgba(0, 0, 0, .12);--edge-cheap: #444444;--edge-expensive: #8a5a00;--edge-critical: #b00000;--shadow: rgba(0, 0, 0, .12)}[data-theme=sakura]{--bg: #fff0f5;--bg-2: #ffe4ee;--surface: #fff7fa;--line: #f5b8cc;--ink: #4a1830;--muted: #a05a78;--high: #1a8a5c;--medium: #c48a14;--low: #d63d6e;--critical: #b01040;--accent: #e84a8a;--rail-from: #ffe4ee;--rail-to: #f8d4e0;--rail-active: #f5c8d8;--btn: #fff7fa;--btn-line: #e89ab0;--btn-primary: #ffd6e6;--btn-primary-line: #e84a8a;--node-bg: #fff7fa;--node-line: #e89ab0;--graph-bg: #fff0f5;--graph-grid: rgba(232, 74, 138, .12);--edge-cheap: #d4a0b0;--edge-expensive: #d63d6e;--edge-critical: #b01040;--shadow: rgba(74, 24, 48, .1)}[data-theme=citrus]{--bg: #fffce8;--bg-2: #fff3b0;--surface: #fffef5;--line: #e8d44a;--ink: #2a2a08;--muted: #6a6a20;--high: #2a8a20;--medium: #d4a000;--low: #e85d04;--critical: #c0392b;--accent: #5aad14;--rail-from: #fff3b0;--rail-to: #ffe98a;--rail-active: #ffe066;--btn: #fffef5;--btn-line: #d4c030;--btn-primary: #e8f5b8;--btn-primary-line: #5aad14;--node-bg: #fffef5;--node-line: #d4c030;--graph-bg: #fffce8;--graph-grid: rgba(90, 173, 20, .14);--edge-cheap: #c4b040;--edge-expensive: #e85d04;--edge-critical: #c0392b;--shadow: rgba(42, 42, 8, .1)}[data-theme=peach]{--bg: #fff3eb;--bg-2: #ffe0cc;--surface: #fffaf6;--line: #f0c4a8;--ink: #3a2218;--muted: #8a5a48;--high: #2a8a5c;--medium: #d48a14;--low: #e85d3a;--critical: #c0392b;--accent: #ff6b35;--rail-from: #ffe0cc;--rail-to: #ffd4b8;--rail-active: #ffc8a8;--btn: #fffaf6;--btn-line: #e8a888;--btn-primary: #ffe0cc;--btn-primary-line: #ff6b35;--node-bg: #fffaf6;--node-line: #e8a888;--graph-bg: #fff3eb;--graph-grid: rgba(255, 107, 53, .12);--edge-cheap: #d4a088;--edge-expensive: #e85d3a;--edge-critical: #c0392b;--shadow: rgba(58, 34, 24, .1)}[data-theme=candy]{--bg: #f4f0ff;--bg-2: #e8dcff;--surface: #fbf8ff;--line: #d4c0f0;--ink: #2a1848;--muted: #6a5890;--high: #1a8a6a;--medium: #c48a14;--low: #e84a8a;--critical: #c01060;--accent: #ff5eb1;--rail-from: #e8dcff;--rail-to: #ddd0ff;--rail-active: #d4c4ff;--btn: #fbf8ff;--btn-line: #c4a8e8;--btn-primary: #ffd6ec;--btn-primary-line: #ff5eb1;--node-bg: #fbf8ff;--node-line: #c4a8e8;--graph-bg: #f4f0ff;--graph-grid: rgba(255, 94, 177, .14);--edge-cheap: #b0a0d0;--edge-expensive: #e84a8a;--edge-critical: #c01060;--shadow: rgba(42, 24, 72, .1)}[data-theme=sky]{--bg: #e8f4ff;--bg-2: #cfe8ff;--surface: #f5faff;--line: #90c8f0;--ink: #0a2848;--muted: #3a6080;--high: #0a8a4a;--medium: #c48a14;--low: #e85d3a;--critical: #c0392b;--accent: #0077ff;--rail-from: #cfe8ff;--rail-to: #b8dcff;--rail-active: #a8d4ff;--btn: #f5faff;--btn-line: #70b0e0;--btn-primary: #cfe8ff;--btn-primary-line: #0077ff;--node-bg: #f5faff;--node-line: #70b0e0;--graph-bg: #e8f4ff;--graph-grid: rgba(0, 119, 255, .12);--edge-cheap: #80b0d0;--edge-expensive: #e85d3a;--edge-critical: #c0392b;--shadow: rgba(10, 40, 72, .1)}[data-theme=coral]{--bg: #fff1ee;--bg-2: #ffddd6;--surface: #fff8f6;--line: #f0b0a4;--ink: #3a1814;--muted: #8a5048;--high: #0d9488;--medium: #d48a14;--low: #e85d4a;--critical: #c0392b;--accent: #0d9488;--rail-from: #ffddd6;--rail-to: #ffd0c6;--rail-active: #ffc4b8;--btn: #fff8f6;--btn-line: #e89888;--btn-primary: #d4f4ee;--btn-primary-line: #0d9488;--node-bg: #fff8f6;--node-line: #e89888;--graph-bg: #fff1ee;--graph-grid: rgba(13, 148, 136, .14);--edge-cheap: #d4a098;--edge-expensive: #e85d4a;--edge-critical: #c0392b;--shadow: rgba(58, 24, 20, .1)}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}:root{--radius: 6px;--radius-lg: 10px;--control-h: 32px;--font: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;--mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;--focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);--space: 8px}body{background:var(--bg);color:var(--ink);font-family:var(--font);font-size:13px;line-height:1.45;-webkit-font-smoothing:antialiased}button,input,select,textarea{font-family:inherit;font-size:inherit;color:inherit}button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,a:focus-visible,summary:focus-visible{outline:none;box-shadow:var(--focus-ring)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.skip{position:absolute;left:12px;top:-40px;z-index:50;background:var(--surface);color:var(--ink);border:1px solid var(--accent);border-radius:var(--radius);padding:8px 12px}.skip:focus{top:12px}.app{display:grid;grid-template-columns:232px 1fr;height:100%}.rail{border-right:1px solid var(--line);background:linear-gradient(180deg,var(--rail-from),var(--rail-to));padding:16px 12px;display:flex;flex-direction:column;gap:2px;min-width:0}.brand{display:flex;flex-direction:column;gap:2px;padding:4px 8px 16px}.brand-mark{font-family:var(--mono);letter-spacing:.16em;font-size:11px;text-transform:uppercase;color:var(--accent);font-weight:600}.brand-sub{font-size:11px;color:var(--muted)}.nav-item{display:flex;align-items:center;gap:10px;background:transparent;border:0;text-align:left;padding:8px 10px;border-radius:var(--radius);color:var(--muted);cursor:pointer;width:100%}.nav-item:hover{background:color-mix(in srgb,var(--rail-active) 70%,transparent);color:var(--ink)}.nav-item.active{background:var(--rail-active);color:var(--ink);font-weight:500}.nav-item svg{flex-shrink:0}.theme-pick{margin-top:14px;display:grid;gap:4px;padding:0 2px}.theme-pick label{font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);font-weight:500}.theme-pick select,.field select,.field input,.topbar input,.topbar select,.settings input,.settings select,.explorer-path input{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:0 10px;height:var(--control-h);width:100%}.rail-foot{margin-top:auto;padding:12px 8px 4px;border-top:1px solid var(--line);display:grid;gap:6px}.kbd-hint{font-size:11px;color:var(--muted)}kbd{font-family:var(--mono);font-size:10px;border:1px solid var(--line);border-radius:4px;padding:0 4px;background:var(--surface)}.main{display:flex;flex-direction:column;min-width:0;min-height:0;position:relative;background:var(--bg)}.progress{position:absolute;top:0;left:0;right:0;height:2px;overflow:hidden;z-index:30;background:color-mix(in srgb,var(--accent) 20%,transparent)}.progress i{display:block;height:100%;width:32%;background:var(--accent);animation:indeterminate 1.1s ease-in-out infinite}.progress.determinate i{width:0;animation:none;transform:none;transition:width .2s ease-out}@keyframes indeterminate{0%{transform:translate(-120%)}to{transform:translate(400%)}}.topbar{display:flex;gap:10px;align-items:flex-end;padding:10px 16px;border-bottom:1px solid var(--line);background:var(--bg-2);flex-wrap:wrap}.field{display:grid;gap:4px;min-width:0}.field>span{font-size:11px;color:var(--muted);font-weight:500}.field.path{flex:1;min-width:180px}.field.ref{width:188px;flex:0 0 188px}.field.workspace{width:180px;flex:0 0 180px}.path-row,.combo-row{display:flex;min-width:0}.path-row input,.combo-row input{flex:1;min-width:0}.combo{position:relative;min-width:0}.combo-row input{border-top-right-radius:0;border-bottom-right-radius:0}.topbar .icon-btn{width:var(--control-h);padding:0;flex:0 0 var(--control-h)}.combo-toggle{border-top-left-radius:0;border-bottom-left-radius:0;border-left:0}.combo-menu{position:absolute;top:calc(100% + 4px);right:0;left:auto;min-width:340px;max-width:min(480px,70vw);max-height:360px;overflow:auto;z-index:40;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:0 12px 32px var(--shadow);padding:6px 0}.combo-heading{font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);font-weight:600;padding:8px 12px 4px}.combo-menu .combo-option{display:flex;flex-direction:column;align-items:flex-start;gap:2px;width:100%;text-align:left;background:transparent;border:0;border-radius:0;height:auto;padding:6px 12px;color:var(--ink);cursor:pointer}.combo-menu .combo-option:hover,.combo-menu .combo-option.active{background:var(--rail-active)}.combo-label{font-family:var(--mono);font-size:12px}.combo-detail{color:var(--muted);font-size:12px;line-height:1.35;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}.combo-empty{padding:10px 12px}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:50;background:color-mix(in srgb,var(--bg) 72%,transparent);display:grid;place-items:center;padding:24px}.modal{width:min(720px,100%);max-height:min(640px,90vh);background:var(--bg-2);border:1px solid var(--line);border-radius:var(--radius-lg);box-shadow:0 16px 48px var(--shadow);display:flex;flex-direction:column;overflow:hidden}.modal-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:14px 16px 10px;border-bottom:1px solid var(--line)}.modal-head h2{font-size:15px}.modal-head .muted{margin:4px 0 0}.explorer-path{display:flex;gap:8px;padding:12px 16px;border-bottom:1px solid var(--line)}.explorer-path input{flex:1;min-width:0}.explorer-list{flex:1;overflow:auto;padding:8px;min-height:220px}.explorer-row{display:flex;align-items:center;gap:8px;width:100%;text-align:left;background:transparent;border:0;border-radius:var(--radius);padding:8px 10px;color:var(--ink);cursor:pointer;height:auto}.explorer-row:hover,.explorer-row.active{background:var(--rail-active)}.explorer-name{min-width:0;overflow:hidden;text-overflow:ellipsis}.git-badge{margin-left:auto;margin-bottom:0}.explorer-empty{padding:18px 10px}.modal-foot{display:flex;align-items:center;gap:12px;padding:12px 16px;border-top:1px solid var(--line)}.explorer-current{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--mono);font-size:12px}.topbar input,.topbar select{min-width:0}.topbar-actions{display:flex;gap:8px;margin-left:auto;align-items:center;padding-bottom:0}.btn,.topbar button{background:var(--btn);border:1px solid var(--btn-line);border-radius:var(--radius);height:var(--control-h);padding:0 12px;cursor:pointer;font-weight:500;display:inline-flex;align-items:center;justify-content:center;gap:6px;white-space:nowrap}.btn:hover,.topbar button:hover{filter:brightness(1.08)}.btn:disabled,.topbar button:disabled{opacity:.55;cursor:not-allowed;filter:none}.btn.primary{background:var(--btn-primary);border-color:var(--btn-primary-line)}.btn.ghost{background:transparent}.alerts{display:grid;gap:8px;padding:10px 16px 0}.alerts:empty{display:none;padding:0}.stage{flex:1;min-height:0;display:flex;flex-direction:column}.content{flex:1;min-height:0;display:grid;grid-template-columns:minmax(340px,420px) 1fr}.brief{overflow:auto;border-right:1px solid var(--line);padding:16px 18px 24px;background:radial-gradient(circle at 0 0,color-mix(in srgb,var(--accent) 8%,transparent),transparent 42%),var(--bg)}.graph-wrap{position:relative;min-height:0;display:flex;flex-direction:column}.impact-graph{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-toolbar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.graph-count{margin-left:auto;font-size:11px}.chip-btn{background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.chip-btn:hover{color:var(--ink)}.chip-btn.active{background:var(--rail-active);color:var(--ink)}.chip-btn:disabled{opacity:.45;cursor:not-allowed}.graph-stage{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-stage .react-flow,.graph-3d,.graph-3d-host,.graph-3d-canvas-host{flex:1;width:100%;height:100%;min-height:280px}.graph-3d{position:relative;background:var(--graph-bg);display:flex;flex-direction:column}.graph-3d-host{position:relative;min-height:0;display:flex;flex-direction:column}.graph-3d-canvas-host{position:relative;min-height:0;background:var(--graph-bg)}.graph-3d canvas{display:block;width:100%;height:100%}.graph-3d-tip{position:absolute;pointer-events:none;z-index:2;max-width:320px;padding:6px 8px;border-radius:var(--radius);background:var(--surface);border:1px solid var(--line);color:var(--ink);font-size:11px;line-height:1.35;box-shadow:0 8px 24px var(--shadow)}.graph-3d-tip .t{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.graph-3d-tip .n{font-weight:600}.graph-3d-hint{position:absolute;left:10px;bottom:10px;z-index:2;margin:0;font-size:11px;color:var(--muted);max-width:min(420px,calc(100% - 24px));pointer-events:none}.graph-wrap .react-flow{background-color:var(--graph-bg);background-image:linear-gradient(var(--graph-grid) 1px,transparent 1px),linear-gradient(90deg,var(--graph-grid) 1px,transparent 1px);background-size:24px 24px}.react-flow__minimap{background:var(--graph-bg)!important;border:1px solid var(--line)!important;border-radius:var(--radius);overflow:hidden;box-shadow:0 8px 24px var(--shadow)}.react-flow__minimap-node{fill:var(--muted);stroke:none}.react-flow__minimap-node.selected{fill:var(--accent)}.react-flow__minimap-mask{fill:#00000073!important;stroke:var(--accent)!important}.react-flow__controls{box-shadow:none!important}.react-flow__controls-button{background:var(--surface)!important;border-bottom:1px solid var(--line)!important;fill:var(--ink)!important}h1{font-size:18px;margin:0 0 6px;font-weight:600}h2{font-size:13px;margin:0;font-weight:600}.merge-box{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:12px 14px;margin-bottom:12px}.merge-box.high{border-color:color-mix(in srgb,var(--high) 55%,var(--line))}.merge-box.medium{border-color:color-mix(in srgb,var(--medium) 55%,var(--line))}.merge-box.low{border-color:color-mix(in srgb,var(--low) 55%,var(--line))}.level{font-family:var(--mono);font-weight:600;font-size:14px}.level.high{color:var(--high)}.level.medium{color:var(--medium)}.level.low{color:var(--low)}.merge-title{margin-top:4px;font-size:13px;color:var(--ink)}.reasons{margin:10px 0 0;padding:0 0 0 18px;color:var(--muted)}.reasons li{margin:0 0 4px}.metrics{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:0 0 14px}.metric{border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);padding:8px 10px}.metric .n{font-family:var(--mono);font-size:16px;font-weight:600;font-variant-numeric:tabular-nums}.metric .l{font-size:11px;color:var(--muted);margin-top:2px}.section{border-top:1px solid var(--line);padding:8px 0 4px}.section>summary{cursor:pointer;list-style:none;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.07em;font-weight:600;padding:6px 0}.section>summary::-webkit-details-marker{display:none}.section>summary .count{font-family:var(--mono);letter-spacing:0;text-transform:none;border:1px solid var(--line);border-radius:999px;padding:0 7px;height:18px;display:inline-flex;align-items:center;font-size:11px}.kicker{color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.08em;margin:16px 0 6px;font-weight:600}.chip{display:inline-flex;align-items:center;font-size:11px;padding:2px 8px;border-radius:999px;border:1px solid var(--line);margin:0 6px 6px 0;color:var(--muted);background:var(--surface)}.chip.blocker{color:var(--low);border-color:var(--low)}.chip.warning{color:var(--medium);border-color:var(--medium)}.chip.strong{color:var(--low);border-color:var(--low)}.chip.worth_exploring{color:var(--medium);border-color:var(--medium)}.chip.speculative{color:var(--muted);border-color:var(--line)}.chip.open{color:var(--high);border-color:color-mix(in srgb,var(--high) 50%,var(--line))}.file{font-family:var(--mono);font-size:12px;color:var(--accent)}.read-item,.finding,.residual{padding:8px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.read-item:last-child,.finding:last-child{border-bottom:0}.read-item.tour-current{background:color-mix(in srgb,var(--accent) 12%,var(--surface));border-color:var(--accent)}.tour-row{margin-top:8px;align-items:center}.field.dirty .chip-btn{height:32px}.muted{color:var(--muted);font-size:13px;line-height:1.45}.error{color:var(--low);padding:8px 12px;border:1px solid var(--low);background:color-mix(in srgb,var(--low) 10%,var(--surface));border-radius:var(--radius);display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.banner{padding:8px 12px;border-radius:var(--radius);border:1px solid var(--line);background:var(--surface);font-size:13px;line-height:1.45;display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.banner.warn{border-color:var(--medium);color:var(--medium)}.banner.stale{border-color:var(--low);color:var(--low)}.banner .dismiss{background:transparent;border:0;color:inherit;cursor:pointer;height:auto;padding:0 2px;opacity:.7}.empty{padding:24px 8px;color:var(--muted);font-size:13px;line-height:1.55}.workspace-loading{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;min-height:220px;padding:48px 16px}.empty h2{font-size:16px;color:var(--ink);margin-bottom:8px}.empty ol{margin:12px 0 0 18px;padding:0}.empty code,code{font-family:var(--mono);font-size:12px;color:var(--accent)}.btn-row{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}.pr-list{padding:16px;overflow:auto}.pr-toolbar{display:flex;gap:8px;align-items:flex-end;margin-bottom:14px}.pr-toolbar .field{flex:1}.pr-toolbar .field.provider{flex:0 0 140px}.scm-count{margin:0 0 12px;font-size:12px}.scm-login{display:flex;justify-content:space-between;gap:12px;align-items:center;padding:10px 0;border-top:1px solid var(--line)}.scm-login:first-of-type{border-top:0;padding-top:0}.scm-login .btn-row{margin-top:0}.scm-login p{margin:2px 0 0}.oauth-code{font-size:13px;margin:0}.oauth-code code{font-size:14px;letter-spacing:.08em}.pr{border:1px solid var(--line);background:var(--surface);padding:12px 14px;border-radius:var(--radius-lg);margin-bottom:10px}.pr h3{margin:0 0 4px;font-size:14px;font-weight:600}.pr-meta{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center;margin:6px 0 10px}.pr-actions{display:flex;gap:8px;align-items:center}.settings{padding:24px;max-width:760px;overflow:auto;display:grid;gap:16px}.settings-card{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:16px;display:grid;gap:8px}.settings-card h2{font-size:14px;margin-bottom:2px}.settings label{font-size:12px;color:var(--muted);font-weight:500}.theme-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px}.theme-swatch{border:1px solid var(--line);background:var(--bg);color:var(--ink);border-radius:var(--radius);padding:10px;text-align:left;cursor:pointer;height:auto;box-shadow:0 1px 8px var(--shadow)}.theme-swatch.active{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent),0 1px 8px var(--shadow)}.theme-swatch .swatch-bar{height:6px;border-radius:3px;margin-bottom:8px;background:linear-gradient(90deg,var(--accent),var(--high),var(--medium),var(--low))}.theme-swatch .name{font-size:13px;font-weight:600}.theme-swatch .group{font-size:11px;color:var(--muted)}.headline{white-space:pre-wrap;font-family:var(--mono);font-size:12px;color:var(--muted);margin:8px 0 0}.graph-modes{display:flex;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.seg{display:inline-flex;border:1px solid var(--line);border-radius:999px;padding:2px;background:var(--surface)}.seg button,.graph-modes button{background:transparent;border:0;border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.seg button.active,.graph-modes button.active{background:var(--rail-active);color:var(--ink)}.legend{margin-left:auto;display:flex;gap:12px;color:var(--muted);font-size:11px}.legend i{display:inline-block;width:14px;height:2px;margin-right:6px;vertical-align:middle;background:var(--edge-cheap)}.legend i.exp{background:var(--edge-expensive)}.legend i.crit{background:var(--edge-critical);height:3px}.legend i.dash{border-top:2px dashed var(--muted);background:none;height:0}.inspector{position:absolute;top:12px;right:12px;z-index:5;width:300px;max-width:calc(100% - 24px);max-height:calc(100% - 24px);overflow-x:hidden;overflow-y:auto;overflow-wrap:break-word;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-lg);padding:10px 12px;box-shadow:0 8px 24px var(--shadow);font-size:12px}.inspector .t{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}.inspector .n,.inspector .file,.inspector .muted{overflow-wrap:break-word}.inspector .n{font-weight:600;margin:4px 0}.inspector-head{display:flex;align-items:flex-start;gap:8px}.inspector-roles{display:flex;flex-wrap:wrap;justify-content:flex-end;flex:1;gap:4px}.inspector-chip{font-size:10px;text-transform:uppercase;letter-spacing:.04em;padding:1px 6px;border-radius:999px;border:1px solid var(--line);color:var(--muted);white-space:nowrap}.inspector-close{flex:0 0 auto;width:24px;height:24px;padding:0;border:1px solid var(--line);border-radius:var(--radius);background:transparent;color:var(--muted);font-size:16px;line-height:1;cursor:pointer}.inspector-close:hover{color:var(--ink)}.inspector-purpose{margin:6px 0 8px;color:var(--ink);font-size:12px;line-height:1.4}.inspector-layer{margin-top:4px;font-size:11px}.inspector-degree{font-size:11px}.inspector-path{margin:6px 0 0;font-size:12px;line-height:1.4;color:var(--muted)}.inspector-facts{margin:10px 0 0;padding-top:8px;border-top:1px solid var(--line)}.inspector-fact{display:grid;grid-template-columns:minmax(64px,92px) minmax(0,1fr);gap:8px;padding:3px 0;align-items:start}.inspector-fact dt{color:var(--muted);font-size:11px;margin:0}.inspector-fact dd{margin:0;overflow-wrap:break-word}.inspector-section{margin-top:10px;padding-top:8px;border-top:1px solid var(--line)}.inspector-section h3{margin:0 0 6px;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.07em;font-weight:600}.inspector-section .count{font-family:var(--mono);letter-spacing:0;text-transform:none;border:1px solid var(--line);border-radius:999px;padding:0 7px;height:18px;display:inline-flex;align-items:center;font-size:11px}.inspector-section ul{list-style:none;margin:0;padding:0}.inspector-section li{padding:4px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.inspector-section li:last-child{border-bottom:0}.inspector-link-name{display:block;font-weight:600;overflow-wrap:break-word}.inspector-link-meta{display:block;color:var(--muted);font-size:11px}.lp-node{padding:8px 10px;border-radius:var(--radius);border:1px solid var(--node-line);background:var(--node-bg);width:208px;max-width:100%;height:64px;box-sizing:border-box;box-shadow:0 0 0 1px var(--shadow);overflow:visible;position:relative}.lp-node .t{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.lp-node .n{font-size:13px;font-weight:600;line-height:1.2;overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow-wrap:anywhere}.lp-node.selected{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}.react-flow__node-load .react-flow__handle{width:8px;height:8px;border:none;background:transparent;opacity:0}.type-table{width:100%;border-collapse:collapse;font-size:12px}.type-table td{padding:3px 0}.type-table td:last-child{text-align:right;font-family:var(--mono);font-variant-numeric:tabular-nums;color:var(--muted)}@media(prefers-reduced-motion:reduce){.progress i{animation:none;width:100%}.progress.determinate i{width:var(--progress, 100%)}*{scroll-behavior:auto!important}}@media(max-width:960px){.app{grid-template-columns:56px 1fr}.brand-sub,.nav-item span,.theme-pick,.kbd-hint,.rail-foot .muted{display:none}.nav-item{justify-content:center;padding:10px}.content{grid-template-columns:1fr}.brief{border-right:0;border-bottom:1px solid var(--line);max-height:42vh}} +.react-flow{direction:ltr;--xy-edge-stroke-default: #b1b1b7;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #555;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(255, 255, 255, .5);--xy-minimap-background-color-default: #fff;--xy-minimap-mask-background-color-default: rgba(240, 240, 240, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #e2e2e2;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: transparent;--xy-background-pattern-dots-color-default: #91919a;--xy-background-pattern-lines-color-default: #eee;--xy-background-pattern-cross-color-default: #e2e2e2;background-color:var(--xy-background-color, var(--xy-background-color-default));--xy-node-color-default: inherit;--xy-node-border-default: 1px solid #1a192b;--xy-node-background-color-default: #fff;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #1a192b;--xy-node-border-radius-default: 3px;--xy-handle-background-color-default: #1a192b;--xy-handle-border-color-default: #fff;--xy-selection-background-color-default: rgba(0, 89, 220, .08);--xy-selection-border-default: 1px dotted rgba(0, 89, 220, .8);--xy-controls-button-background-color-default: #fefefe;--xy-controls-button-background-color-hover-default: #f4f4f4;--xy-controls-button-color-default: inherit;--xy-controls-button-color-hover-default: inherit;--xy-controls-button-border-color-default: #eee;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #ffffff;--xy-edge-label-color-default: inherit;--xy-resize-background-color-default: #3367d9}.react-flow.dark{--xy-edge-stroke-default: #3e3e3e;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #727272;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(150, 150, 150, .25);--xy-minimap-background-color-default: #141414;--xy-minimap-mask-background-color-default: rgba(60, 60, 60, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #2b2b2b;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: #141414;--xy-background-pattern-dots-color-default: #555;--xy-background-pattern-lines-color-default: #333;--xy-background-pattern-cross-color-default: #333;--xy-node-color-default: #f8f8f8;--xy-node-border-default: 1px solid #3c3c3c;--xy-node-background-color-default: #1e1e1e;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #999;--xy-handle-background-color-default: #bebebe;--xy-handle-border-color-default: #1e1e1e;--xy-selection-background-color-default: rgba(200, 200, 220, .08);--xy-selection-border-default: 1px dotted rgba(200, 200, 220, .8);--xy-controls-button-background-color-default: #2b2b2b;--xy-controls-button-background-color-hover-default: #3e3e3e;--xy-controls-button-color-default: #f8f8f8;--xy-controls-button-color-hover-default: #fff;--xy-controls-button-border-color-default: #5b5b5b;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #141414;--xy-edge-label-color-default: #f8f8f8}.react-flow__background{background-color:var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1;touch-action:none}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{overflow:visible;position:absolute;pointer-events:none}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__arrowhead polyline{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:dashdraw .5s linear infinite}svg.react-flow__connectionline{z-index:1001;overflow:visible;position:absolute}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background-color:var(--xy-handle-background-color, var(--xy-handle-background-color-default));border:1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));border-radius:100%}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:0;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__pane.selection .react-flow__panel{pointer-events:none}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.top.center,.react-flow__panel.bottom.center{left:50%;transform:translate(-15px) translate(-50%)}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.left.center,.react-flow__panel.right.center{top:50%;transform:translateY(-15px) translateY(-50%)}.react-flow__attribution{font-size:10px;background:var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;left:0;top:0}.react-flow__viewport-portal{position:absolute;width:100%;height:100%;left:0;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__minimap{background:var( --xy-minimap-background-color-props, var(--xy-minimap-background-color, var(--xy-minimap-background-color-default)) )}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var( --xy-minimap-mask-background-color-props, var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default)) );stroke:var( --xy-minimap-mask-stroke-color-props, var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default)) );stroke-width:var( --xy-minimap-mask-stroke-width-props, var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default)) )}.react-flow__minimap-node{fill:var( --xy-minimap-node-background-color-props, var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default)) );stroke:var( --xy-minimap-node-stroke-color-props, var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default)) );stroke-width:var( --xy-minimap-node-stroke-width-props, var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default)) )}.react-flow__background-pattern.dots{fill:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default)) )}.react-flow__background-pattern.lines{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default)) )}.react-flow__background-pattern.cross{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default)) )}.react-flow__controls{display:flex;flex-direction:column;box-shadow:var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default))}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{display:flex;justify-content:center;align-items:center;height:26px;width:26px;padding:4px;border:none;background:var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));border-bottom:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) );color:var( --xy-controls-button-color-props, var(--xy-controls-button-color, var(--xy-controls-button-color-default)) );cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px;fill:currentColor}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:var(--xy-node-border-radius, var(--xy-node-border-radius-default));width:150px;font-size:12px;color:var(--xy-node-color, var(--xy-node-color-default));text-align:center;border:var(--xy-node-border, var(--xy-node-border-default));background-color:var(--xy-node-background-color, var(--xy-node-background-color-default))}.react-flow__node-input.selectable:hover,.react-flow__node-default.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default))}.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default))}.react-flow__node-group{background-color:var(--xy-node-group-background-color, var(--xy-node-group-background-color-default))}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color, var(--xy-selection-background-color-default));border:var(--xy-selection-border, var(--xy-selection-border-default))}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls-button:hover{background:var( --xy-controls-button-background-color-hover-props, var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default)) );color:var( --xy-controls-button-color-hover-props, var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default)) )}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__controls-button:last-child{border-bottom:none}.react-flow__controls.horizontal .react-flow__controls-button{border-bottom:none;border-right:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) )}.react-flow__controls.horizontal .react-flow__controls-button:last-child{border-right:none}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:5px;height:5px;border:1px solid #fff;border-radius:1px;background-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));translate:-50% -50%}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}.react-flow__edge-textbg{fill:var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default))}.react-flow__edge-text{fill:var(--xy-edge-label-color, var(--xy-edge-label-color-default))}:root,[data-theme=obsidian]{--bg: #070b10;--bg-2: #0d141c;--surface: #121a24;--line: #1e2c3c;--ink: #e7eef6;--muted: #8b9bb0;--high: #2a9d8f;--medium: #e9c46a;--low: #e76f51;--critical: #e85d04;--accent: #4cc9f0;--rail-from: #0b1219;--rail-to: #070b10;--rail-active: #15202c;--btn: #173044;--btn-line: #24506c;--btn-primary: #134e4a;--btn-primary-line: #2a9d8f;--node-bg: #101822;--node-line: #2a3d52;--graph-bg: #070b10;--graph-grid: rgba(42, 80, 120, .09);--edge-cheap: #4a5568;--edge-expensive: #f4a261;--edge-critical: #e85d04;--shadow: rgba(76, 201, 240, .08)}[data-theme=nord]{--bg: #2e3440;--bg-2: #3b4252;--surface: #434c5e;--line: #4c566a;--ink: #eceff4;--muted: #d8dee9;--high: #a3be8c;--medium: #ebcb8b;--low: #bf616a;--critical: #d08770;--accent: #88c0d0;--rail-from: #3b4252;--rail-to: #2e3440;--rail-active: #4c566a;--btn: #434c5e;--btn-line: #81a1c1;--btn-primary: #5e81ac;--btn-primary-line: #88c0d0;--node-bg: #3b4252;--node-line: #81a1c1;--graph-bg: #2e3440;--graph-grid: rgba(136, 192, 208, .12);--edge-cheap: #4c566a;--edge-expensive: #d08770;--edge-critical: #bf616a;--shadow: rgba(136, 192, 208, .12)}[data-theme=solarized-dark]{--bg: #002b36;--bg-2: #073642;--surface: #0a3944;--line: #16444f;--ink: #eee8d5;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #2aa198;--rail-from: #073642;--rail-to: #002b36;--rail-active: #16444f;--btn: #073642;--btn-line: #268bd2;--btn-primary: #0a4a42;--btn-primary-line: #2aa198;--node-bg: #073642;--node-line: #268bd2;--graph-bg: #002b36;--graph-grid: rgba(42, 161, 152, .12);--edge-cheap: #586e75;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(42, 161, 152, .12)}[data-theme=forest]{--bg: #0e1510;--bg-2: #152019;--surface: #1b2a20;--line: #2c4334;--ink: #e4f0e6;--muted: #8eaa96;--high: #6ab04c;--medium: #c8a951;--low: #e17055;--critical: #d35400;--accent: #7bed9f;--rail-from: #152019;--rail-to: #0e1510;--rail-active: #1f3326;--btn: #1f3326;--btn-line: #3d6b4f;--btn-primary: #1e4d32;--btn-primary-line: #6ab04c;--node-bg: #16241b;--node-line: #3d6b4f;--graph-bg: #0e1510;--graph-grid: rgba(123, 237, 159, .1);--edge-cheap: #3d6b4f;--edge-expensive: #c8a951;--edge-critical: #d35400;--shadow: rgba(123, 237, 159, .1)}[data-theme=rose]{--bg: #191724;--bg-2: #1f1d2e;--surface: #26233a;--line: #403d52;--ink: #e0def4;--muted: #908caa;--high: #9ccfd8;--medium: #f6c177;--low: #eb6f92;--critical: #eb6f92;--accent: #c4a7e7;--rail-from: #1f1d2e;--rail-to: #191724;--rail-active: #26233a;--btn: #26233a;--btn-line: #c4a7e7;--btn-primary: #3a2f4d;--btn-primary-line: #c4a7e7;--node-bg: #1f1d2e;--node-line: #524f67;--graph-bg: #191724;--graph-grid: rgba(196, 167, 231, .12);--edge-cheap: #524f67;--edge-expensive: #f6c177;--edge-critical: #eb6f92;--shadow: rgba(196, 167, 231, .12)}[data-theme=amber]{--bg: #120e0a;--bg-2: #1c1610;--surface: #261e16;--line: #3d2f22;--ink: #f4e6d0;--muted: #b59a78;--high: #c4d6a0;--medium: #e9b44c;--low: #d8572a;--critical: #c0392b;--accent: #f0a05a;--rail-from: #1c1610;--rail-to: #120e0a;--rail-active: #2b2218;--btn: #2b2218;--btn-line: #8a5a2b;--btn-primary: #4a3418;--btn-primary-line: #f0a05a;--node-bg: #1c1610;--node-line: #8a5a2b;--graph-bg: #120e0a;--graph-grid: rgba(240, 160, 90, .12);--edge-cheap: #5c4a38;--edge-expensive: #e9b44c;--edge-critical: #d8572a;--shadow: rgba(240, 160, 90, .12)}[data-theme=volcano]{--bg: #14090a;--bg-2: #1e0e10;--surface: #2a1416;--line: #4a2226;--ink: #fde8e4;--muted: #c48b86;--high: #7bed9f;--medium: #f6c90e;--low: #ff6b6b;--critical: #ff3b3b;--accent: #ff7b54;--rail-from: #1e0e10;--rail-to: #14090a;--rail-active: #32181b;--btn: #32181b;--btn-line: #ff7b54;--btn-primary: #5a1f18;--btn-primary-line: #ff7b54;--node-bg: #1e0e10;--node-line: #7a3330;--graph-bg: #14090a;--graph-grid: rgba(255, 123, 84, .12);--edge-cheap: #5a3330;--edge-expensive: #ff7b54;--edge-critical: #ff3b3b;--shadow: rgba(255, 123, 84, .14)}[data-theme=lavender]{--bg: #12101c;--bg-2: #1a1730;--surface: #221e3c;--line: #3b3560;--ink: #efeaff;--muted: #b3a7d6;--high: #80ffdb;--medium: #ffd166;--low: #ff6b9d;--critical: #ff4d6d;--accent: #c77dff;--rail-from: #1a1730;--rail-to: #12101c;--rail-active: #2a2550;--btn: #2a2550;--btn-line: #c77dff;--btn-primary: #3d2a66;--btn-primary-line: #c77dff;--node-bg: #1a1730;--node-line: #5a4d8a;--graph-bg: #12101c;--graph-grid: rgba(199, 125, 255, .12);--edge-cheap: #5a4d8a;--edge-expensive: #ffd166;--edge-critical: #ff4d6d;--shadow: rgba(199, 125, 255, .14)}[data-theme=neon-noir]{--bg: #05060a;--bg-2: #0a0c14;--surface: #10131c;--line: #1e2436;--ink: #f0f4ff;--muted: #8b93b0;--high: #39ff88;--medium: #ffe66d;--low: #ff2d95;--critical: #ff3d5a;--accent: #00f0ff;--rail-from: #0a0c14;--rail-to: #05060a;--rail-active: #151a2a;--btn: #151a2a;--btn-line: #00f0ff;--btn-primary: #063a40;--btn-primary-line: #00f0ff;--node-bg: #0a0c14;--node-line: #2a3550;--graph-bg: #05060a;--graph-grid: rgba(0, 240, 255, .12);--edge-cheap: #3a4560;--edge-expensive: #ff2d95;--edge-critical: #ff3d5a;--shadow: rgba(0, 240, 255, .22)}[data-theme=synthwave]{--bg: #1a0a2e;--bg-2: #240b3d;--surface: #2d1250;--line: #4a1d7a;--ink: #ffe6fb;--muted: #c49ad8;--high: #00f5d4;--medium: #ffd60a;--low: #ff6b9d;--critical: #ff006e;--accent: #ff2bd6;--rail-from: #240b3d;--rail-to: #1a0a2e;--rail-active: #3a1570;--btn: #3a1570;--btn-line: #ff2bd6;--btn-primary: #5a0a4a;--btn-primary-line: #ff2bd6;--node-bg: #240b3d;--node-line: #7b2cbf;--graph-bg: #1a0a2e;--graph-grid: rgba(255, 43, 214, .16);--edge-cheap: #5a3a80;--edge-expensive: #ff9e00;--edge-critical: #ff006e;--shadow: rgba(255, 43, 214, .24)}[data-theme=phosphor]{--bg: #020804;--bg-2: #061208;--surface: #0a1a0e;--line: #163c1e;--ink: #c8ffc8;--muted: #5aaa5a;--high: #39ff14;--medium: #c8f542;--low: #ffb000;--critical: #ff5e00;--accent: #00ff66;--rail-from: #061208;--rail-to: #020804;--rail-active: #0e2414;--btn: #0e2414;--btn-line: #00ff66;--btn-primary: #0a3a18;--btn-primary-line: #00ff66;--node-bg: #061208;--node-line: #1e6a32;--graph-bg: #020804;--graph-grid: rgba(0, 255, 102, .12);--edge-cheap: #1e5a2a;--edge-expensive: #c8f542;--edge-critical: #ff5e00;--shadow: rgba(0, 255, 102, .2)}[data-theme=aurora]{--bg: #071018;--bg-2: #0c1c28;--surface: #122636;--line: #1e3d52;--ink: #e8fff6;--muted: #7eb8a8;--high: #5fffcf;--medium: #ffe566;--low: #ff7eb6;--critical: #ff4d6d;--accent: #7cffb2;--rail-from: #0c1c28;--rail-to: #071018;--rail-active: #163044;--btn: #163044;--btn-line: #7cffb2;--btn-primary: #0e3d3a;--btn-primary-line: #7cffb2;--node-bg: #0c1c28;--node-line: #2a6a78;--graph-bg: #071018;--graph-grid: rgba(124, 255, 178, .12);--edge-cheap: #2a5a68;--edge-expensive: #c9a0ff;--edge-critical: #ff4d6d;--shadow: rgba(124, 255, 178, .18)}[data-theme=biolume]{--bg: #02141c;--bg-2: #042430;--surface: #073040;--line: #0a4a5c;--ink: #e6fffb;--muted: #6eb8b0;--high: #5dffb0;--medium: #ffe066;--low: #ff79c6;--critical: #ff4d6d;--accent: #18e7d4;--rail-from: #042430;--rail-to: #02141c;--rail-active: #0a3848;--btn: #0a3848;--btn-line: #18e7d4;--btn-primary: #0a4a48;--btn-primary-line: #18e7d4;--node-bg: #042430;--node-line: #1a7080;--graph-bg: #02141c;--graph-grid: rgba(24, 231, 212, .12);--edge-cheap: #1a5a68;--edge-expensive: #ff79c6;--edge-critical: #ff4d6d;--shadow: rgba(24, 231, 212, .2)}[data-theme=carbon]{--bg: #0d0d0f;--bg-2: #16161a;--surface: #1e1e24;--line: #33333c;--ink: #f2f2f4;--muted: #9a9aa8;--high: #3dd68c;--medium: #f0c040;--low: #ff5a5a;--critical: #ff2a2a;--accent: #ff2a2a;--rail-from: #16161a;--rail-to: #0d0d0f;--rail-active: #24242c;--btn: #24242c;--btn-line: #ff2a2a;--btn-primary: #4a1212;--btn-primary-line: #ff2a2a;--node-bg: #16161a;--node-line: #4a4a55;--graph-bg: #0d0d0f;--graph-grid: rgba(255, 42, 42, .1);--edge-cheap: #4a4a55;--edge-expensive: #ff8a3d;--edge-critical: #ff2a2a;--shadow: rgba(255, 42, 42, .18)}[data-theme=paper]{--bg: #f6f1e8;--bg-2: #efe6d6;--surface: #fffaf2;--line: #d9cbb6;--ink: #2b241c;--muted: #6f6456;--high: #2a7a4b;--medium: #b5811a;--low: #c0392b;--critical: #a93226;--accent: #1d6a7a;--rail-from: #efe6d6;--rail-to: #e7dcc8;--rail-active: #e2d3bb;--btn: #fffaf2;--btn-line: #c9b79a;--btn-primary: #d7eee0;--btn-primary-line: #2a7a4b;--node-bg: #fffaf2;--node-line: #c9b79a;--graph-bg: #f6f1e8;--graph-grid: rgba(29, 106, 122, .1);--edge-cheap: #b7a48c;--edge-expensive: #c0392b;--edge-critical: #a93226;--shadow: rgba(43, 36, 28, .08)}[data-theme=solarized-light]{--bg: #fdf6e3;--bg-2: #eee8d5;--surface: #f5efdc;--line: #d6cba9;--ink: #657b83;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #268bd2;--rail-from: #eee8d5;--rail-to: #e6dfc8;--rail-active: #e0d9c0;--btn: #fdf6e3;--btn-line: #93a1a1;--btn-primary: #e8efc8;--btn-primary-line: #859900;--node-bg: #fdf6e3;--node-line: #93a1a1;--graph-bg: #fdf6e3;--graph-grid: rgba(38, 139, 210, .12);--edge-cheap: #93a1a1;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(101, 123, 131, .1)}[data-theme=seafoam]{--bg: #eef7f4;--bg-2: #dff0ea;--surface: #ffffff;--line: #b7d5cc;--ink: #17332c;--muted: #4d7268;--high: #1b8a5a;--medium: #c48a14;--low: #c44536;--critical: #9b2d22;--accent: #1d9a8a;--rail-from: #dff0ea;--rail-to: #cfe6de;--rail-active: #c4ddd4;--btn: #ffffff;--btn-line: #8fbfb2;--btn-primary: #d4f0e4;--btn-primary-line: #1b8a5a;--node-bg: #ffffff;--node-line: #8fbfb2;--graph-bg: #eef7f4;--graph-grid: rgba(29, 154, 138, .12);--edge-cheap: #8fbfb2;--edge-expensive: #c48a14;--edge-critical: #c44536;--shadow: rgba(23, 51, 44, .08)}[data-theme=high-contrast]{--bg: #ffffff;--bg-2: #f2f2f2;--surface: #ffffff;--line: #111111;--ink: #000000;--muted: #222222;--high: #007a33;--medium: #8a5a00;--low: #b00000;--critical: #9b0000;--accent: #0033cc;--rail-from: #f2f2f2;--rail-to: #e6e6e6;--rail-active: #d9d9d9;--btn: #ffffff;--btn-line: #000000;--btn-primary: #d9f2e3;--btn-primary-line: #007a33;--node-bg: #ffffff;--node-line: #000000;--graph-bg: #ffffff;--graph-grid: rgba(0, 0, 0, .12);--edge-cheap: #444444;--edge-expensive: #8a5a00;--edge-critical: #b00000;--shadow: rgba(0, 0, 0, .12)}[data-theme=sakura]{--bg: #fff0f5;--bg-2: #ffe4ee;--surface: #fff7fa;--line: #f5b8cc;--ink: #4a1830;--muted: #a05a78;--high: #1a8a5c;--medium: #c48a14;--low: #d63d6e;--critical: #b01040;--accent: #e84a8a;--rail-from: #ffe4ee;--rail-to: #f8d4e0;--rail-active: #f5c8d8;--btn: #fff7fa;--btn-line: #e89ab0;--btn-primary: #ffd6e6;--btn-primary-line: #e84a8a;--node-bg: #fff7fa;--node-line: #e89ab0;--graph-bg: #fff0f5;--graph-grid: rgba(232, 74, 138, .12);--edge-cheap: #d4a0b0;--edge-expensive: #d63d6e;--edge-critical: #b01040;--shadow: rgba(74, 24, 48, .1)}[data-theme=citrus]{--bg: #fffce8;--bg-2: #fff3b0;--surface: #fffef5;--line: #e8d44a;--ink: #2a2a08;--muted: #6a6a20;--high: #2a8a20;--medium: #d4a000;--low: #e85d04;--critical: #c0392b;--accent: #5aad14;--rail-from: #fff3b0;--rail-to: #ffe98a;--rail-active: #ffe066;--btn: #fffef5;--btn-line: #d4c030;--btn-primary: #e8f5b8;--btn-primary-line: #5aad14;--node-bg: #fffef5;--node-line: #d4c030;--graph-bg: #fffce8;--graph-grid: rgba(90, 173, 20, .14);--edge-cheap: #c4b040;--edge-expensive: #e85d04;--edge-critical: #c0392b;--shadow: rgba(42, 42, 8, .1)}[data-theme=peach]{--bg: #fff3eb;--bg-2: #ffe0cc;--surface: #fffaf6;--line: #f0c4a8;--ink: #3a2218;--muted: #8a5a48;--high: #2a8a5c;--medium: #d48a14;--low: #e85d3a;--critical: #c0392b;--accent: #ff6b35;--rail-from: #ffe0cc;--rail-to: #ffd4b8;--rail-active: #ffc8a8;--btn: #fffaf6;--btn-line: #e8a888;--btn-primary: #ffe0cc;--btn-primary-line: #ff6b35;--node-bg: #fffaf6;--node-line: #e8a888;--graph-bg: #fff3eb;--graph-grid: rgba(255, 107, 53, .12);--edge-cheap: #d4a088;--edge-expensive: #e85d3a;--edge-critical: #c0392b;--shadow: rgba(58, 34, 24, .1)}[data-theme=candy]{--bg: #f4f0ff;--bg-2: #e8dcff;--surface: #fbf8ff;--line: #d4c0f0;--ink: #2a1848;--muted: #6a5890;--high: #1a8a6a;--medium: #c48a14;--low: #e84a8a;--critical: #c01060;--accent: #ff5eb1;--rail-from: #e8dcff;--rail-to: #ddd0ff;--rail-active: #d4c4ff;--btn: #fbf8ff;--btn-line: #c4a8e8;--btn-primary: #ffd6ec;--btn-primary-line: #ff5eb1;--node-bg: #fbf8ff;--node-line: #c4a8e8;--graph-bg: #f4f0ff;--graph-grid: rgba(255, 94, 177, .14);--edge-cheap: #b0a0d0;--edge-expensive: #e84a8a;--edge-critical: #c01060;--shadow: rgba(42, 24, 72, .1)}[data-theme=sky]{--bg: #e8f4ff;--bg-2: #cfe8ff;--surface: #f5faff;--line: #90c8f0;--ink: #0a2848;--muted: #3a6080;--high: #0a8a4a;--medium: #c48a14;--low: #e85d3a;--critical: #c0392b;--accent: #0077ff;--rail-from: #cfe8ff;--rail-to: #b8dcff;--rail-active: #a8d4ff;--btn: #f5faff;--btn-line: #70b0e0;--btn-primary: #cfe8ff;--btn-primary-line: #0077ff;--node-bg: #f5faff;--node-line: #70b0e0;--graph-bg: #e8f4ff;--graph-grid: rgba(0, 119, 255, .12);--edge-cheap: #80b0d0;--edge-expensive: #e85d3a;--edge-critical: #c0392b;--shadow: rgba(10, 40, 72, .1)}[data-theme=coral]{--bg: #fff1ee;--bg-2: #ffddd6;--surface: #fff8f6;--line: #f0b0a4;--ink: #3a1814;--muted: #8a5048;--high: #0d9488;--medium: #d48a14;--low: #e85d4a;--critical: #c0392b;--accent: #0d9488;--rail-from: #ffddd6;--rail-to: #ffd0c6;--rail-active: #ffc4b8;--btn: #fff8f6;--btn-line: #e89888;--btn-primary: #d4f4ee;--btn-primary-line: #0d9488;--node-bg: #fff8f6;--node-line: #e89888;--graph-bg: #fff1ee;--graph-grid: rgba(13, 148, 136, .14);--edge-cheap: #d4a098;--edge-expensive: #e85d4a;--edge-critical: #c0392b;--shadow: rgba(58, 24, 20, .1)}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}:root{--radius: 6px;--radius-lg: 10px;--control-h: 32px;--font: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;--mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;--focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);--space: 8px}body{background:var(--bg);color:var(--ink);font-family:var(--font);font-size:13px;line-height:1.45;-webkit-font-smoothing:antialiased}button,input,select,textarea{font-family:inherit;font-size:inherit;color:inherit}button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,a:focus-visible,summary:focus-visible{outline:none;box-shadow:var(--focus-ring)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.skip{position:absolute;left:12px;top:-40px;z-index:50;background:var(--surface);color:var(--ink);border:1px solid var(--accent);border-radius:var(--radius);padding:8px 12px}.skip:focus{top:12px}.app{display:grid;grid-template-columns:232px 1fr;height:100%}.rail{border-right:1px solid var(--line);background:linear-gradient(180deg,var(--rail-from),var(--rail-to));padding:16px 12px;display:flex;flex-direction:column;gap:2px;min-width:0}.brand{display:flex;flex-direction:column;gap:2px;padding:4px 8px 16px}.brand-mark{font-family:var(--mono);letter-spacing:.16em;font-size:11px;text-transform:uppercase;color:var(--accent);font-weight:600}.brand-sub{font-size:11px;color:var(--muted)}.nav-item{display:flex;align-items:center;gap:10px;background:transparent;border:0;text-align:left;padding:8px 10px;border-radius:var(--radius);color:var(--muted);cursor:pointer;width:100%}.nav-item:hover{background:color-mix(in srgb,var(--rail-active) 70%,transparent);color:var(--ink)}.nav-item.active{background:var(--rail-active);color:var(--ink);font-weight:500}.nav-item svg{flex-shrink:0}.theme-pick{margin-top:14px;display:grid;gap:4px;padding:0 2px}.theme-pick label{font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);font-weight:500}.theme-pick select,.field select,.field input,.topbar input,.topbar select,.settings input,.settings select,.explorer-path input{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:0 10px;height:var(--control-h);width:100%}.rail-foot{margin-top:auto;padding:12px 8px 4px;border-top:1px solid var(--line);display:grid;gap:6px}.kbd-hint{font-size:11px;color:var(--muted)}kbd{font-family:var(--mono);font-size:10px;border:1px solid var(--line);border-radius:4px;padding:0 4px;background:var(--surface)}.main{display:flex;flex-direction:column;min-width:0;min-height:0;position:relative;background:var(--bg)}.progress{position:absolute;top:0;left:0;right:0;height:2px;overflow:hidden;z-index:30;background:color-mix(in srgb,var(--accent) 20%,transparent)}.progress i{display:block;height:100%;width:32%;background:var(--accent);animation:indeterminate 1.1s ease-in-out infinite}.progress.determinate i{width:0;animation:none;transform:none;transition:width .2s ease-out}@keyframes indeterminate{0%{transform:translate(-120%)}to{transform:translate(400%)}}.topbar{display:flex;gap:10px;align-items:flex-end;padding:10px 16px;border-bottom:1px solid var(--line);background:var(--bg-2);flex-wrap:wrap}.field{display:grid;gap:4px;min-width:0}.field>span{font-size:11px;color:var(--muted);font-weight:500}.field.path{flex:1;min-width:180px}.field.ref{width:188px;flex:0 0 188px}.field.workspace{width:180px;flex:0 0 180px}.path-row,.combo-row{display:flex;min-width:0}.path-row input,.combo-row input{flex:1;min-width:0}.combo{position:relative;min-width:0}.combo-row input{border-top-right-radius:0;border-bottom-right-radius:0}.topbar .icon-btn{width:var(--control-h);padding:0;flex:0 0 var(--control-h)}.combo-toggle{border-top-left-radius:0;border-bottom-left-radius:0;border-left:0}.combo-menu{position:absolute;top:calc(100% + 4px);right:0;left:auto;min-width:340px;max-width:min(480px,70vw);max-height:360px;overflow:auto;z-index:40;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:0 12px 32px var(--shadow);padding:6px 0}.combo-heading{font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);font-weight:600;padding:8px 12px 4px}.combo-menu .combo-option{display:flex;flex-direction:column;align-items:flex-start;gap:2px;width:100%;text-align:left;background:transparent;border:0;border-radius:0;height:auto;padding:6px 12px;color:var(--ink);cursor:pointer}.combo-menu .combo-option:hover,.combo-menu .combo-option.active{background:var(--rail-active)}.combo-label{font-family:var(--mono);font-size:12px}.combo-detail{color:var(--muted);font-size:12px;line-height:1.35;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}.combo-empty{padding:10px 12px}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:50;background:color-mix(in srgb,var(--bg) 72%,transparent);display:grid;place-items:center;padding:24px}.modal{width:min(720px,100%);max-height:min(640px,90vh);background:var(--bg-2);border:1px solid var(--line);border-radius:var(--radius-lg);box-shadow:0 16px 48px var(--shadow);display:flex;flex-direction:column;overflow:hidden}.modal-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:14px 16px 10px;border-bottom:1px solid var(--line)}.modal-head h2{font-size:15px}.modal-head .muted{margin:4px 0 0}.explorer-path{display:flex;gap:8px;padding:12px 16px;border-bottom:1px solid var(--line)}.explorer-path input{flex:1;min-width:0}.explorer-list{flex:1;overflow:auto;padding:8px;min-height:220px}.explorer-row{display:flex;align-items:center;gap:8px;width:100%;text-align:left;background:transparent;border:0;border-radius:var(--radius);padding:8px 10px;color:var(--ink);cursor:pointer;height:auto}.explorer-row:hover,.explorer-row.active{background:var(--rail-active)}.explorer-name{min-width:0;overflow:hidden;text-overflow:ellipsis}.git-badge{margin-left:auto;margin-bottom:0}.explorer-empty{padding:18px 10px}.modal-foot{display:flex;align-items:center;gap:12px;padding:12px 16px;border-top:1px solid var(--line)}.explorer-current{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--mono);font-size:12px}.topbar input,.topbar select{min-width:0}.topbar-actions{display:flex;gap:8px;margin-left:auto;align-items:center;padding-bottom:0}.btn,.topbar button{background:var(--btn);border:1px solid var(--btn-line);border-radius:var(--radius);height:var(--control-h);padding:0 12px;cursor:pointer;font-weight:500;display:inline-flex;align-items:center;justify-content:center;gap:6px;white-space:nowrap}.btn:hover,.topbar button:hover{filter:brightness(1.08)}.btn:disabled,.topbar button:disabled{opacity:.55;cursor:not-allowed;filter:none}.btn.primary{background:var(--btn-primary);border-color:var(--btn-primary-line)}.btn.ghost{background:transparent}.alerts{display:grid;gap:8px;padding:10px 16px 0}.alerts:empty{display:none;padding:0}.stage{flex:1;min-height:0;display:flex;flex-direction:column}.content{flex:1;min-height:0;display:grid;grid-template-columns:minmax(340px,420px) 1fr}.brief{overflow:auto;border-right:1px solid var(--line);padding:16px 18px 24px;background:radial-gradient(circle at 0 0,color-mix(in srgb,var(--accent) 8%,transparent),transparent 42%),var(--bg)}.graph-wrap{position:relative;min-height:0;display:flex;flex-direction:column}.impact-graph{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-toolbar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.graph-count{margin-left:auto;font-size:11px}.chip-btn{background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.chip-btn:hover{color:var(--ink)}.chip-btn.active{background:var(--rail-active);color:var(--ink)}.chip-btn:disabled{opacity:.45;cursor:not-allowed}.graph-stage{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-stage .react-flow,.graph-3d,.graph-3d-host,.graph-3d-canvas-host{flex:1;width:100%;height:100%;min-height:280px}.graph-3d{position:relative;background:var(--graph-bg);display:flex;flex-direction:column}.graph-3d-host{position:relative;min-height:0;display:flex;flex-direction:column}.graph-3d-canvas-host{position:relative;min-height:0;background:var(--graph-bg)}.graph-3d canvas{display:block;width:100%;height:100%}.graph-3d-tip{position:absolute;pointer-events:none;z-index:2;max-width:320px;padding:6px 8px;border-radius:var(--radius);background:var(--surface);border:1px solid var(--line);color:var(--ink);font-size:11px;line-height:1.35;box-shadow:0 8px 24px var(--shadow)}.graph-3d-tip .t{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.graph-3d-tip .n{font-weight:600}.graph-3d-hint{position:absolute;left:10px;bottom:10px;z-index:2;margin:0;font-size:11px;color:var(--muted);max-width:min(420px,calc(100% - 24px));pointer-events:none}.graph-wrap .react-flow{background-color:var(--graph-bg);background-image:linear-gradient(var(--graph-grid) 1px,transparent 1px),linear-gradient(90deg,var(--graph-grid) 1px,transparent 1px);background-size:24px 24px}.react-flow__minimap{background:var(--graph-bg)!important;border:1px solid var(--line)!important;border-radius:var(--radius);overflow:hidden;box-shadow:0 8px 24px var(--shadow)}.react-flow__minimap-node{fill:var(--muted);stroke:none}.react-flow__minimap-node.selected{fill:var(--accent)}.react-flow__minimap-mask{fill:#00000073!important;stroke:var(--accent)!important}.react-flow__controls{box-shadow:none!important}.react-flow__controls-button{background:var(--surface)!important;border-bottom:1px solid var(--line)!important;fill:var(--ink)!important}h1{font-size:18px;margin:0 0 6px;font-weight:600}h2{font-size:13px;margin:0;font-weight:600}.merge-box{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:12px 14px;margin-bottom:12px}.merge-box.high{border-color:color-mix(in srgb,var(--high) 55%,var(--line))}.merge-box.medium{border-color:color-mix(in srgb,var(--medium) 55%,var(--line))}.merge-box.low{border-color:color-mix(in srgb,var(--low) 55%,var(--line))}.level{font-family:var(--mono);font-weight:600;font-size:14px}.level.high{color:var(--high)}.level.medium{color:var(--medium)}.level.low{color:var(--low)}.merge-title{margin-top:4px;font-size:13px;color:var(--ink)}.reasons{margin:10px 0 0;padding:0 0 0 18px;color:var(--muted)}.reasons li{margin:0 0 4px}.metrics{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:0 0 14px}.metric{border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);padding:8px 10px}.metric .n{font-family:var(--mono);font-size:16px;font-weight:600;font-variant-numeric:tabular-nums}.metric .l{font-size:11px;color:var(--muted);margin-top:2px}.section{border-top:1px solid var(--line);padding:8px 0 4px}.section>summary{cursor:pointer;list-style:none;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.07em;font-weight:600;padding:6px 0}.section>summary::-webkit-details-marker{display:none}.section>summary .count{font-family:var(--mono);letter-spacing:0;text-transform:none;border:1px solid var(--line);border-radius:999px;padding:0 7px;height:18px;display:inline-flex;align-items:center;font-size:11px}.kicker{color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.08em;margin:16px 0 6px;font-weight:600}.chip{display:inline-flex;align-items:center;font-size:11px;padding:2px 8px;border-radius:999px;border:1px solid var(--line);margin:0 6px 6px 0;color:var(--muted);background:var(--surface)}.chip.blocker{color:var(--low);border-color:var(--low)}.chip.warning{color:var(--medium);border-color:var(--medium)}.chip.strong{color:var(--low);border-color:var(--low)}.chip.worth_exploring{color:var(--medium);border-color:var(--medium)}.chip.speculative{color:var(--muted);border-color:var(--line)}.chip.open{color:var(--high);border-color:color-mix(in srgb,var(--high) 50%,var(--line))}.file{font-family:var(--mono);font-size:12px;color:var(--accent)}.read-item,.finding,.residual{padding:8px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.read-item:last-child,.finding:last-child{border-bottom:0}.read-item.tour-current{background:color-mix(in srgb,var(--accent) 12%,var(--surface));border-color:var(--accent)}.tour-row{margin-top:8px;align-items:center}.field.dirty .chip-btn{height:32px}.muted{color:var(--muted);font-size:13px;line-height:1.45}.error{color:var(--low);padding:8px 12px;border:1px solid var(--low);background:color-mix(in srgb,var(--low) 10%,var(--surface));border-radius:var(--radius);display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.banner{padding:8px 12px;border-radius:var(--radius);border:1px solid var(--line);background:var(--surface);font-size:13px;line-height:1.45;display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.banner.warn{border-color:var(--medium);color:var(--medium)}.banner.stale{border-color:var(--low);color:var(--low)}.banner .dismiss{background:transparent;border:0;color:inherit;cursor:pointer;height:auto;padding:0 2px;opacity:.7}.empty{padding:24px 8px;color:var(--muted);font-size:13px;line-height:1.55}.workspace-loading{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;min-height:220px;padding:48px 16px}.empty h2{font-size:16px;color:var(--ink);margin-bottom:8px}.empty ol{margin:12px 0 0 18px;padding:0}.empty code,code{font-family:var(--mono);font-size:12px;color:var(--accent)}.btn-row{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}.pr-list{padding:16px;overflow:auto}.pr-toolbar{display:flex;gap:8px;align-items:flex-end;margin-bottom:14px}.pr-toolbar .field{flex:1}.pr-toolbar .field.provider{flex:0 0 140px}.scm-count{margin:0 0 12px;font-size:12px}.scm-login{display:flex;justify-content:space-between;gap:12px;align-items:center;padding:10px 0;border-top:1px solid var(--line)}.scm-login:first-of-type{border-top:0;padding-top:0}.scm-login .btn-row{margin-top:0}.scm-login p{margin:2px 0 0}.oauth-code{font-size:13px;margin:0}.oauth-code code{font-size:14px;letter-spacing:.08em}.pr{border:1px solid var(--line);background:var(--surface);padding:12px 14px;border-radius:var(--radius-lg);margin-bottom:10px}.pr h3{margin:0 0 4px;font-size:14px;font-weight:600}.pr-meta{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center;margin:6px 0 10px}.pr-actions{display:flex;gap:8px;align-items:center}.settings{padding:24px;max-width:760px;overflow:auto;display:grid;gap:16px}.settings-card{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:16px;display:grid;gap:8px}.settings-card h2{font-size:14px;margin-bottom:2px}.settings label{font-size:12px;color:var(--muted);font-weight:500}.theme-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px}.theme-swatch{border:1px solid var(--line);background:var(--bg);color:var(--ink);border-radius:var(--radius);padding:10px;text-align:left;cursor:pointer;height:auto;box-shadow:0 1px 8px var(--shadow)}.theme-swatch.active{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent),0 1px 8px var(--shadow)}.theme-swatch .swatch-bar{height:6px;border-radius:3px;margin-bottom:8px;background:linear-gradient(90deg,var(--accent),var(--high),var(--medium),var(--low))}.theme-swatch .name{font-size:13px;font-weight:600}.theme-swatch .group{font-size:11px;color:var(--muted)}.headline{white-space:pre-wrap;font-family:var(--mono);font-size:12px;color:var(--muted);margin:8px 0 0}.graph-modes{display:flex;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.seg{display:inline-flex;border:1px solid var(--line);border-radius:999px;padding:2px;background:var(--surface)}.seg button,.graph-modes button{background:transparent;border:0;border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.seg button.active,.graph-modes button.active{background:var(--rail-active);color:var(--ink)}.legend{margin-left:auto;display:flex;gap:12px;color:var(--muted);font-size:11px}.legend i{display:inline-block;width:14px;height:2px;margin-right:6px;vertical-align:middle;background:var(--edge-cheap)}.legend i.exp{background:var(--edge-expensive)}.legend i.crit{background:var(--edge-critical);height:3px}.legend i.dash{border-top:2px dashed var(--muted);background:none;height:0}.legend i.seed{height:10px;width:10px;border-radius:2px;background:color-mix(in srgb,var(--medium) 70%,var(--node-bg))}.legend i.down{height:10px;width:10px;border-radius:2px;border:1px solid color-mix(in srgb,var(--accent) 45%,var(--node-line));background:var(--node-bg)}.inspector{position:absolute;top:12px;right:12px;z-index:5;width:300px;max-width:calc(100% - 24px);max-height:calc(100% - 24px);overflow-x:hidden;overflow-y:auto;overflow-wrap:break-word;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-lg);padding:10px 12px;box-shadow:0 8px 24px var(--shadow);font-size:12px}.inspector .t{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}.inspector .n,.inspector .file,.inspector .muted{overflow-wrap:break-word}.inspector .n{font-weight:600;margin:4px 0}.inspector-head{display:flex;align-items:flex-start;gap:8px}.inspector-roles{display:flex;flex-wrap:wrap;justify-content:flex-end;flex:1;gap:4px}.inspector-chip{font-size:10px;text-transform:uppercase;letter-spacing:.04em;padding:1px 6px;border-radius:999px;border:1px solid var(--line);color:var(--muted);white-space:nowrap}.inspector-close{flex:0 0 auto;width:24px;height:24px;padding:0;border:1px solid var(--line);border-radius:var(--radius);background:transparent;color:var(--muted);font-size:16px;line-height:1;cursor:pointer}.inspector-close:hover{color:var(--ink)}.inspector-purpose{margin:6px 0 8px;color:var(--ink);font-size:12px;line-height:1.4}.inspector-layer{margin-top:4px;font-size:11px}.inspector-degree{font-size:11px}.inspector-path{margin:6px 0 0;font-size:12px;line-height:1.4;color:var(--muted)}.inspector-facts{margin:10px 0 0;padding-top:8px;border-top:1px solid var(--line)}.inspector-fact{display:grid;grid-template-columns:minmax(64px,92px) minmax(0,1fr);gap:8px;padding:3px 0;align-items:start}.inspector-fact dt{color:var(--muted);font-size:11px;margin:0}.inspector-fact dd{margin:0;overflow-wrap:break-word}.inspector-section{margin-top:10px;padding-top:8px;border-top:1px solid var(--line)}.inspector-section h3{margin:0 0 6px;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.07em;font-weight:600}.inspector-section .count{font-family:var(--mono);letter-spacing:0;text-transform:none;border:1px solid var(--line);border-radius:999px;padding:0 7px;height:18px;display:inline-flex;align-items:center;font-size:11px}.inspector-section ul{list-style:none;margin:0;padding:0}.inspector-section li{padding:4px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.inspector-section li:last-child{border-bottom:0}.inspector-link-name{display:block;font-weight:600;overflow-wrap:break-word}.inspector-link-meta{display:block;color:var(--muted);font-size:11px}.lp-node{padding:8px 10px;border-radius:var(--radius);border:1px solid var(--node-line);background:var(--node-bg);width:208px;max-width:100%;height:64px;box-sizing:border-box;box-shadow:0 0 0 1px var(--shadow);overflow:visible;position:relative}.lp-node .t{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.lp-node .n{font-size:13px;font-weight:600;line-height:1.2;overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow-wrap:anywhere}.lp-node.selected{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}.lp-node.role-seed{border-color:var(--medium);background:color-mix(in srgb,var(--medium) 14%,var(--node-bg))}.lp-node.role-downstream{border-color:color-mix(in srgb,var(--accent) 45%,var(--node-line))}.lp-node.role-untested{box-shadow:inset 3px 0 0 var(--low)}.lp-node.role-tested{box-shadow:inset 3px 0 0 var(--high)}.lp-node.role-contract{outline:1px dashed color-mix(in srgb,var(--accent) 50%,transparent)}.lp-node.dim{opacity:.38}.merge-box.compact{padding:6px 10px;min-width:92px;margin:0}.merge-box.compact .level{font-size:12px}.palette-scrim{position:fixed;top:0;right:0;bottom:0;left:0;background:color-mix(in srgb,var(--bg) 55%,transparent);z-index:40;display:grid;place-items:start center;padding-top:12vh}.palette{width:min(640px,calc(100vw - 32px));background:var(--surface);border:1px solid var(--line);border-radius:12px;box-shadow:0 18px 60px var(--shadow);overflow:hidden}.palette input{width:100%;border:0;border-bottom:1px solid var(--line);background:transparent;color:var(--ink);padding:14px 16px;font:inherit}.palette ul{list-style:none;margin:0;padding:6px;max-height:360px;overflow:auto}.palette li button{width:100%;display:flex;justify-content:space-between;gap:12px;text-align:left;background:transparent;border:0;color:var(--ink);padding:8px 10px;border-radius:8px;cursor:pointer}.palette li button.active,.palette li button:hover{background:var(--rail-active)}.palette-foot{padding:8px 12px 10px}.graph-search{position:relative;min-width:140px}.graph-search input{width:100%;background:var(--bg-2);border:1px solid var(--line);color:var(--ink);border-radius:8px;padding:6px 8px;font:inherit}.graph-search-hits{position:absolute;z-index:5;left:0;right:0;top:calc(100% + 4px);background:var(--surface);border:1px solid var(--line);border-radius:8px;list-style:none;margin:0;padding:4px;max-height:240px;overflow:auto}.graph-search-hits button{width:100%;display:flex;justify-content:space-between;gap:8px;background:transparent;border:0;color:var(--ink);text-align:left;padding:6px 8px;cursor:pointer}.graph-search-hits button:hover{background:var(--rail-active)}.inspector-link{display:flex;flex-direction:column;width:100%;background:transparent;border:0;color:inherit;text-align:left;cursor:pointer;padding:0}.file-row{display:flex;flex-direction:column;gap:6px}.linkish{background:none;border:0;color:inherit;font:inherit;text-align:left;cursor:pointer;padding:0}.history-item,.check-item{display:flex;flex-wrap:wrap;gap:8px;align-items:baseline;width:100%;background:transparent;border:0;color:inherit;font:inherit;text-align:left;padding:6px 0;cursor:pointer}.history-item.current{color:var(--accent)}.check-row{display:flex;gap:8px;align-items:center;margin:4px 0}.sparkline{display:flex;align-items:flex-end;gap:3px;height:36px;margin:8px 0}.sparkline i{flex:1;background:var(--muted);border-radius:2px 2px 0 0;min-width:4px}.sparkline i.high{background:var(--high)}.sparkline i.medium{background:var(--medium)}.sparkline i.low{background:var(--low)}.config-editor .field{display:flex;flex-direction:column;gap:4px;margin:8px 0}.config-editor input,.config-editor select{background:var(--bg-2);border:1px solid var(--line);color:var(--ink);border-radius:8px;padding:6px 8px}.react-flow__node-load .react-flow__handle{width:8px;height:8px;border:none;background:transparent;opacity:0}.type-table{width:100%;border-collapse:collapse;font-size:12px}.type-table td{padding:3px 0}.type-table td:last-child{text-align:right;font-family:var(--mono);font-variant-numeric:tabular-nums;color:var(--muted)}@media(prefers-reduced-motion:reduce){.progress i{animation:none;width:100%}.progress.determinate i{width:var(--progress, 100%)}*{scroll-behavior:auto!important}}@media(max-width:960px){.app{grid-template-columns:56px 1fr}.brand-sub,.nav-item span,.theme-pick,.kbd-hint,.rail-foot .muted{display:none}.nav-item{justify-content:center;padding:10px}.content{grid-template-columns:1fr}.brief{border-right:0;border-bottom:1px solid var(--line);max-height:42vh}} diff --git a/src/loadpath/static/assets/index-Dg2mxCJ9.js b/src/loadpath/static/assets/index-Dg2mxCJ9.js new file mode 100644 index 0000000..23e1c1d --- /dev/null +++ b/src/loadpath/static/assets/index-Dg2mxCJ9.js @@ -0,0 +1,62 @@ +(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function wp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Eu={exports:{}},Ho={},Cu={exports:{}},Ie={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Gf;function Zy(){if(Gf)return Ie;Gf=1;var t=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),x=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),m=Symbol.iterator;function y(P){return P===null||typeof P!="object"?null:(P=m&&P[m]||P["@@iterator"],typeof P=="function"?P:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,j={};function E(P,z,ie){this.props=P,this.context=z,this.refs=j,this.updater=ie||_}E.prototype.isReactComponent={},E.prototype.setState=function(P,z){if(typeof P!="object"&&typeof P!="function"&&P!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,P,z,"setState")},E.prototype.forceUpdate=function(P){this.updater.enqueueForceUpdate(this,P,"forceUpdate")};function w(){}w.prototype=E.prototype;function M(P,z,ie){this.props=P,this.context=z,this.refs=j,this.updater=ie||_}var k=M.prototype=new w;k.constructor=M,N(k,E.prototype),k.isPureReactComponent=!0;var b=Array.isArray,A=Object.prototype.hasOwnProperty,$={current:null},V={key:!0,ref:!0,__self:!0,__source:!0};function X(P,z,ie){var oe,de={},pe=null,he=null;if(z!=null)for(oe in z.ref!==void 0&&(he=z.ref),z.key!==void 0&&(pe=""+z.key),z)A.call(z,oe)&&!V.hasOwnProperty(oe)&&(de[oe]=z[oe]);var Q=arguments.length-2;if(Q===1)de.children=ie;else if(1>>1,z=C[P];if(0>>1;Pa(de,B))pea(he,de)?(C[P]=he,C[pe]=B,P=pe):(C[P]=de,C[oe]=B,P=oe);else if(pea(he,B))C[P]=he,C[pe]=B,P=pe;else break e}}return D}function a(C,D){var B=C.sortIndex-D.sortIndex;return B!==0?B:C.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,h=c.now();t.unstable_now=function(){return c.now()-h}}var p=[],x=[],v=1,m=null,y=3,_=!1,N=!1,j=!1,E=typeof setTimeout=="function"?setTimeout:null,w=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function k(C){for(var D=o(x);D!==null;){if(D.callback===null)s(x);else if(D.startTime<=C)s(x),D.sortIndex=D.expirationTime,r(p,D);else break;D=o(x)}}function b(C){if(j=!1,k(C),!N)if(o(p)!==null)N=!0,H(A);else{var D=o(x);D!==null&&U(b,D.startTime-C)}}function A(C,D){N=!1,j&&(j=!1,w(X),X=-1),_=!0;var B=y;try{for(k(D),m=o(p);m!==null&&(!(m.expirationTime>D)||C&&!Z());){var P=m.callback;if(typeof P=="function"){m.callback=null,y=m.priorityLevel;var z=P(m.expirationTime<=D);D=t.unstable_now(),typeof z=="function"?m.callback=z:m===o(p)&&s(p),k(D)}else s(p);m=o(p)}if(m!==null)var ie=!0;else{var oe=o(x);oe!==null&&U(b,oe.startTime-D),ie=!1}return ie}finally{m=null,y=B,_=!1}}var $=!1,V=null,X=-1,G=5,J=-1;function Z(){return!(t.unstable_now()-JC||125P?(C.sortIndex=B,r(x,C),o(p)===null&&C===o(x)&&(j?(w(X),X=-1):j=!0,U(b,B-P))):(C.sortIndex=z,r(p,C),N||_||(N=!0,H(A))),C},t.unstable_shouldYield=Z,t.unstable_wrapCallback=function(C){var D=y;return function(){var B=y;y=D;try{return C.apply(this,arguments)}finally{y=B}}}})(Iu)),Iu}var Zf;function r0(){return Zf||(Zf=1,Pu.exports=n0()),Pu.exports}/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Jf;function i0(){if(Jf)return Dt;Jf=1;var t=os(),r=r0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,x=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},m={};function y(e){return p.call(m,e)?!0:p.call(v,e)?!1:x.test(e)?m[e]=!0:(v[e]=!0,!1)}function _(e,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function N(e,n,i,l){if(n===null||typeof n>"u"||_(e,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function j(e,n,i,l,f,g,S){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=f,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=g,this.removeEmptyString=S}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){E[e]=new j(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];E[n]=new j(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){E[e]=new j(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){E[e]=new j(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){E[e]=new j(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){E[e]=new j(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){E[e]=new j(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){E[e]=new j(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){E[e]=new j(e,5,!1,e.toLowerCase(),null,!1,!1)});var w=/[\-:]([a-z])/g;function M(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(w,M);E[n]=new j(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(w,M);E[n]=new j(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(w,M);E[n]=new j(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){E[e]=new j(e,1,!1,e.toLowerCase(),null,!1,!1)}),E.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){E[e]=new j(e,1,!1,e.toLowerCase(),null,!0,!0)});function k(e,n,i,l){var f=E.hasOwnProperty(n)?E[n]:null;(f!==null?f.type!==0:l||!(2T||f[S]!==g[T]){var O=` +`+f[S].replace(" at new "," at ");return e.displayName&&O.includes("")&&(O=O.replace("",e.displayName)),O}while(1<=S&&0<=T);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?z(e):""}function de(e){switch(e.tag){case 5:return z(e.type);case 16:return z("Lazy");case 13:return z("Suspense");case 19:return z("SuspenseList");case 0:case 2:case 15:return e=oe(e.type,!1),e;case 11:return e=oe(e.type.render,!1),e;case 1:return e=oe(e.type,!0),e;default:return""}}function pe(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case V:return"Fragment";case $:return"Portal";case G:return"Profiler";case X:return"StrictMode";case te:return"Suspense";case I:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Z:return(e.displayName||"Context")+".Consumer";case J:return(e._context.displayName||"Context")+".Provider";case re:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case W:return n=e.displayName||null,n!==null?n:pe(e.type)||"Memo";case H:n=e._payload,e=e._init;try{return pe(e(n))}catch{}}return null}function he(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return pe(n);case 8:return n===X?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Q(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ae(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=ae(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function ke(e){e._valueTracker||(e._valueTracker=me(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=ae(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function ne(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return B({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Q(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Re(e,n){n=n.checked,n!=null&&k(e,"checked",n,!1)}function Le(e,n){Re(e,n);var i=Q(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?pt(e,n.type,i):n.hasOwnProperty("defaultValue")&&pt(e,n.type,Q(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function Ze(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function pt(e,n,i){(n!=="number"||ne(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var Xe=Array.isArray;function it(e,n,i,l){if(e=e.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=Pt.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function sn(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var qt={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},no=["Webkit","ms","Moz","O"];Object.keys(qt).forEach(function(e){no.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),qt[n]=qt[e]})});function rr(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||qt.hasOwnProperty(e)&&qt[e]?(""+n).trim():n+"px"}function ui(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=rr(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,f):e[i]=f}}var ci=B({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ir(e,n){if(n){if(ci[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function Nn(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Nt=null;function jn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var bn=null,It=null,Ft=null;function En(e){if(e=bo(e)){if(typeof bn!="function")throw Error(o(280));var n=e.stateNode;n&&(n=bs(n),bn(e.stateNode,e.type,n))}}function yt(e){It?Ft?Ft.push(e):Ft=[e]:It=e}function Rr(){if(It){var e=It,n=Ft;if(Ft=It=null,En(e),n)for(e=0;e>>=0,e===0?32:31-(Dr(e)/vi|0)|0}var Vn=64,Pn=4194304;function Wn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Qt(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,f=e.suspendedLanes,g=e.pingedLanes,S=i&268435455;if(S!==0){var T=S&~f;T!==0?l=Wn(T):(g&=S,g!==0&&(l=Wn(g)))}else S=i&~f,S!==0?l=Wn(S):g!==0&&(l=Wn(g));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,g=n&-n,f>=g||f===16&&(g&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function Rn(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-xt(n),e[n]=i}function _i(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=yo),Oc=" ",Fc=!1;function Hc(e,n){switch(e){case"keyup":return Gm.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Bc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ni=!1;function qm(e,n){switch(e){case"compositionend":return Bc(n);case"keypress":return n.which!==32?null:(Fc=!0,Oc);case"textInput":return e=n.data,e===Oc&&Fc?null:e;default:return null}}function Km(e,n){if(Ni)return e==="compositionend"||!la&&Hc(e,n)?(e=Tc(),gs=ta=dr=null,Ni=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=qc(i)}}function Qc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Qc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Zc(){for(var e=window,n=ne();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=ne(e.document)}return n}function ca(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function oy(e){var n=Zc(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Qc(i.ownerDocument.documentElement,i)){if(l!==null&&ca(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var f=i.textContent.length,g=Math.min(l.start,f);l=l.end===void 0?g:Math.min(l.end,f),!e.extend&&g>l&&(f=l,l=g,g=f),f=Kc(i,g);var S=Kc(i,l);f&&S&&(e.rangeCount!==1||e.anchorNode!==f.node||e.anchorOffset!==f.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),e.removeAllRanges(),g>l?(e.addRange(n),e.extend(S.node,S.offset)):(n.setEnd(S.node,S.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,ji=null,da=null,_o=null,fa=!1;function Jc(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;fa||ji==null||ji!==ne(l)||(l=ji,"selectionStart"in l&&ca(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),_o&&wo(_o,l)||(_o=l,l=ks(da,"onSelect"),0Pi||(e.current=Na[Pi],Na[Pi]=null,Pi--)}function Be(e,n){Pi++,Na[Pi]=e.current,e.current=n}var gr={},wt=pr(gr),Tt=pr(!1),Br=gr;function Ii(e,n){var i=e.type.contextTypes;if(!i)return gr;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in i)f[g]=n[g];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=f),f}function Lt(e){return e=e.childContextTypes,e!=null}function Es(){Ue(Tt),Ue(wt)}function pd(e,n,i){if(wt.current!==gr)throw Error(o(168));Be(wt,n),Be(Tt,i)}function gd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,he(e)||"Unknown",f));return B({},i,l)}function Cs(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||gr,Br=wt.current,Be(wt,e),Be(Tt,Tt.current),!0}function md(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=gd(e,n,Br),l.__reactInternalMemoizedMergedChildContext=e,Ue(Tt),Ue(wt),Be(wt,e)):Ue(Tt),Be(Tt,i)}var Gn=null,Ms=!1,ja=!1;function yd(e){Gn===null?Gn=[e]:Gn.push(e)}function yy(e){Ms=!0,yd(e)}function mr(){if(!ja&&Gn!==null){ja=!0;var e=0,n=De;try{var i=Gn;for(De=1;e>=S,f-=S,Xn=1<<32-xt(n)+f|i<Ce?(ct=be,be=null):ct=be.sibling;var Oe=se(q,be,K[Ce],ce);if(Oe===null){be===null&&(be=ct);break}e&&be&&Oe.alternate===null&&n(q,be),F=g(Oe,F,Ce),je===null?_e=Oe:je.sibling=Oe,je=Oe,be=ct}if(Ce===K.length)return i(q,be),Ge&&Wr(q,Ce),_e;if(be===null){for(;CeCe?(ct=be,be=null):ct=be.sibling;var jr=se(q,be,Oe.value,ce);if(jr===null){be===null&&(be=ct);break}e&&be&&jr.alternate===null&&n(q,be),F=g(jr,F,Ce),je===null?_e=jr:je.sibling=jr,je=jr,be=ct}if(Oe.done)return i(q,be),Ge&&Wr(q,Ce),_e;if(be===null){for(;!Oe.done;Ce++,Oe=K.next())Oe=ue(q,Oe.value,ce),Oe!==null&&(F=g(Oe,F,Ce),je===null?_e=Oe:je.sibling=Oe,je=Oe);return Ge&&Wr(q,Ce),_e}for(be=l(q,be);!Oe.done;Ce++,Oe=K.next())Oe=ge(be,q,Ce,Oe.value,ce),Oe!==null&&(e&&Oe.alternate!==null&&be.delete(Oe.key===null?Ce:Oe.key),F=g(Oe,F,Ce),je===null?_e=Oe:je.sibling=Oe,je=Oe);return e&&be.forEach(function(Qy){return n(q,Qy)}),Ge&&Wr(q,Ce),_e}function et(q,F,K,ce){if(typeof K=="object"&&K!==null&&K.type===V&&K.key===null&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case A:e:{for(var _e=K.key,je=F;je!==null;){if(je.key===_e){if(_e=K.type,_e===V){if(je.tag===7){i(q,je.sibling),F=f(je,K.props.children),F.return=q,q=F;break e}}else if(je.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===H&&kd(_e)===je.type){i(q,je.sibling),F=f(je,K.props),F.ref=Eo(q,je,K),F.return=q,q=F;break e}i(q,je);break}else n(q,je);je=je.sibling}K.type===V?(F=Zr(K.props.children,q.mode,ce,K.key),F.return=q,q=F):(ce=rl(K.type,K.key,K.props,null,q.mode,ce),ce.ref=Eo(q,F,K),ce.return=q,q=ce)}return S(q);case $:e:{for(je=K.key;F!==null;){if(F.key===je)if(F.tag===4&&F.stateNode.containerInfo===K.containerInfo&&F.stateNode.implementation===K.implementation){i(q,F.sibling),F=f(F,K.children||[]),F.return=q,q=F;break e}else{i(q,F);break}else n(q,F);F=F.sibling}F=Su(K,q.mode,ce),F.return=q,q=F}return S(q);case H:return je=K._init,et(q,F,je(K._payload),ce)}if(Xe(K))return xe(q,F,K,ce);if(D(K))return we(q,F,K,ce);Ts(q,K)}return typeof K=="string"&&K!==""||typeof K=="number"?(K=""+K,F!==null&&F.tag===6?(i(q,F.sibling),F=f(F,K),F.return=q,q=F):(i(q,F),F=_u(K,q.mode,ce),F.return=q,q=F),S(q)):i(q,F)}return et}var Ai=Nd(!0),jd=Nd(!1),Ls=pr(null),As=null,$i=null,Ia=null;function Ra(){Ia=$i=As=null}function Ta(e){var n=Ls.current;Ue(Ls),e._currentValue=n}function La(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function zi(e,n){As=e,Ia=$i=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(At=!0),e.firstContext=null)}function en(e){var n=e._currentValue;if(Ia!==e)if(e={context:e,memoizedValue:n,next:null},$i===null){if(As===null)throw Error(o(308));$i=e,As.dependencies={lanes:0,firstContext:e}}else $i=$i.next=e;return n}var Ur=null;function Aa(e){Ur===null?Ur=[e]:Ur.push(e)}function bd(e,n,i,l){var f=n.interleaved;return f===null?(i.next=i,Aa(n)):(i.next=f.next,f.next=i),n.interleaved=i,Kn(e,l)}function Kn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var yr=!1;function $a(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ed(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Qn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function vr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,($e&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,Kn(e,i)}return f=l.interleaved,f===null?(n.next=n,Aa(l)):(n.next=f.next,f.next=n),l.interleaved=n,Kn(e,i)}function $s(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,Un(e,i)}}function Cd(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var S={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?f=g=S:g=g.next=S,i=i.next}while(i!==null);g===null?f=g=n:g=g.next=n}else f=g=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function zs(e,n,i,l){var f=e.updateQueue;yr=!1;var g=f.firstBaseUpdate,S=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,ee=O.next;O.next=null,S===null?g=ee:S.next=ee,S=O;var le=e.alternate;le!==null&&(le=le.updateQueue,T=le.lastBaseUpdate,T!==S&&(T===null?le.firstBaseUpdate=ee:T.next=ee,le.lastBaseUpdate=O))}if(g!==null){var ue=f.baseState;S=0,le=ee=O=null,T=g;do{var se=T.lane,ge=T.eventTime;if((l&se)===se){le!==null&&(le=le.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var xe=e,we=T;switch(se=n,ge=i,we.tag){case 1:if(xe=we.payload,typeof xe=="function"){ue=xe.call(ge,ue,se);break e}ue=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=we.payload,se=typeof xe=="function"?xe.call(ge,ue,se):xe,se==null)break e;ue=B({},ue,se);break e;case 2:yr=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,se=f.effects,se===null?f.effects=[T]:se.push(T))}else ge={eventTime:ge,lane:se,tag:T.tag,payload:T.payload,callback:T.callback,next:null},le===null?(ee=le=ge,O=ue):le=le.next=ge,S|=se;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;se=T,T=se.next,se.next=null,f.lastBaseUpdate=se,f.shared.pending=null}}while(!0);if(le===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=ee,f.lastBaseUpdate=le,n=f.shared.interleaved,n!==null){f=n;do S|=f.lane,f=f.next;while(f!==n)}else g===null&&(f.shared.lanes=0);Xr|=S,e.lanes=S,e.memoizedState=ue}}function Md(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=Ha.transition;Ha.transition={};try{e(!1),n()}finally{De=i,Ha.transition=l}}function Xd(){return tn().memoizedState}function _y(e,n,i){var l=Sr(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},qd(e))Kd(n,i);else if(i=bd(e,n,i,l),i!==null){var f=Ct();gn(i,e,l,f),Qd(i,n,l)}}function Sy(e,n,i){var l=Sr(e),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(qd(e))Kd(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,T=g(S,i);if(f.hasEagerState=!0,f.eagerState=T,cn(T,S)){var O=n.interleaved;O===null?(f.next=f,Aa(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=bd(e,n,f,l),i!==null&&(f=Ct(),gn(i,e,l,f),Qd(i,n,l))}}function qd(e){var n=e.alternate;return e===Ke||n!==null&&n===Ke}function Kd(e,n){Io=Fs=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Qd(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,Un(e,i)}}var Vs={readContext:en,useCallback:_t,useContext:_t,useEffect:_t,useImperativeHandle:_t,useInsertionEffect:_t,useLayoutEffect:_t,useMemo:_t,useReducer:_t,useRef:_t,useState:_t,useDebugValue:_t,useDeferredValue:_t,useTransition:_t,useMutableSource:_t,useSyncExternalStore:_t,useId:_t,unstable_isNewReconciler:!1},ky={readContext:en,useCallback:function(e,n){return $n().memoizedState=[e,n===void 0?null:n],e},useContext:en,useEffect:Fd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Hs(4194308,4,Vd.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Hs(4194308,4,e,n)},useInsertionEffect:function(e,n){return Hs(4,2,e,n)},useMemo:function(e,n){var i=$n();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=$n();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=_y.bind(null,Ke,e),[l.memoizedState,e]},useRef:function(e){var n=$n();return e={current:e},n.memoizedState=e},useState:Dd,useDebugValue:Xa,useDeferredValue:function(e){return $n().memoizedState=e},useTransition:function(){var e=Dd(!1),n=e[0];return e=wy.bind(null,e[1]),$n().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=Ke,f=$n();if(Ge){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ut===null)throw Error(o(349));(Gr&30)!==0||Td(l,n,i)}f.memoizedState=i;var g={value:i,getSnapshot:n};return f.queue=g,Fd(Ad.bind(null,l,g,e),[e]),l.flags|=2048,Lo(9,Ld.bind(null,l,g,i,n),void 0,null),i},useId:function(){var e=$n(),n=ut.identifierPrefix;if(Ge){var i=qn,l=Xn;i=(l&~(1<<32-xt(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=Ro++,0<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=S.createElement(i,{is:l.is}):(e=S.createElement(i),i==="select"&&(S=e,l.multiple?S.multiple=!0:l.size&&(S.size=l.size))):e=S.createElementNS(e,i),e[Ln]=n,e[jo]=l,vf(e,n,!1,!1),n.stateNode=e;e:{switch(S=Nn(i,l),i){case"dialog":We("cancel",e),We("close",e),f=l;break;case"iframe":case"object":case"embed":We("load",e),f=l;break;case"video":case"audio":for(f=0;fBi&&(n.flags|=128,l=!0,Ao(g,!1),n.lanes=4194304)}else{if(!l)if(e=Ds(S),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Ao(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Ge)return St(n),null}else 2*Ve()-g.renderingStartTime>Bi&&i!==1073741824&&(n.flags|=128,l=!0,Ao(g,!1),n.lanes=4194304);g.isBackwards?(S.sibling=n.child,n.child=S):(i=g.last,i!==null?i.sibling=S:n.child=S,g.last=S)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(St(n),null);case 22:case 23:return vu(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Yt&1073741824)!==0&&(St(n),n.subtreeFlags&6&&(n.flags|=8192)):St(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function Iy(e,n){switch(Ea(n),n.tag){case 1:return Lt(n.type)&&Es(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Di(),Ue(Tt),Ue(wt),Fa(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Da(n),null;case 13:if(Ue(qe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));Li()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Di(),null;case 10:return Ta(n.type._context),null;case 22:case 23:return vu(),null;case 24:return null;default:return null}}var Gs=!1,kt=!1,Ry=typeof WeakSet=="function"?WeakSet:Set,ye=null;function Fi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Je(e,n,l)}else i.current=null}function su(e,n,i){try{i()}catch(l){Je(e,n,l)}}var _f=!1;function Ty(e,n){if(va=hs,e=Zc(),ca(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,g=l.focusNode;l=l.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var S=0,T=-1,O=-1,ee=0,le=0,ue=e,se=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=S+f),ue!==g||l!==0&&ue.nodeType!==3||(O=S+l),ue.nodeType===3&&(S+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)se=ue,ue=ge;for(;;){if(ue===e)break t;if(se===i&&++ee===f&&(T=S),se===g&&++le===l&&(O=S),(ge=ue.nextSibling)!==null)break;ue=se,se=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(xa={focusedElem:e,selectionRange:i},hs=!1,ye=n;ye!==null;)if(n=ye,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ye=e;else for(;ye!==null;){n=ye;try{var xe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var we=xe.memoizedProps,et=xe.memoizedState,q=n.stateNode,F=q.getSnapshotBeforeUpdate(n.elementType===n.type?we:fn(n.type,we),et);q.__reactInternalSnapshotBeforeUpdate=F}break;case 3:var K=n.stateNode.containerInfo;K.nodeType===1?K.textContent="":K.nodeType===9&&K.documentElement&&K.removeChild(K.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(ce){Je(n,n.return,ce)}if(e=n.sibling,e!==null){e.return=n.return,ye=e;break}ye=n.return}return xe=_f,_f=!1,xe}function $o(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&e)===e){var g=f.destroy;f.destroy=void 0,g!==void 0&&su(n,i,g)}f=f.next}while(f!==l)}}function Xs(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function lu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function Sf(e){var n=e.alternate;n!==null&&(e.alternate=null,Sf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[Ln],delete n[jo],delete n[ka],delete n[gy],delete n[my])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function kf(e){return e.tag===5||e.tag===3||e.tag===4}function Nf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||kf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function au(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=js));else if(l!==4&&(e=e.child,e!==null))for(au(e,n,i),e=e.sibling;e!==null;)au(e,n,i),e=e.sibling}function uu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(uu(e,n,i),e=e.sibling;e!==null;)uu(e,n,i),e=e.sibling}var ft=null,hn=!1;function xr(e,n,i){for(i=i.child;i!==null;)jf(e,n,i),i=i.sibling}function jf(e,n,i){if(vt&&typeof vt.onCommitFiberUnmount=="function")try{vt.onCommitFiberUnmount(Mn,i)}catch{}switch(i.tag){case 5:kt||Fi(i,n);case 6:var l=ft,f=hn;ft=null,xr(e,n,i),ft=l,hn=f,ft!==null&&(hn?(e=ft,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):ft.removeChild(i.stateNode));break;case 18:ft!==null&&(hn?(e=ft,i=i.stateNode,e.nodeType===8?Sa(e.parentNode,i):e.nodeType===1&&Sa(e,i),po(e)):Sa(ft,i.stateNode));break;case 4:l=ft,f=hn,ft=i.stateNode.containerInfo,hn=!0,xr(e,n,i),ft=l,hn=f;break;case 0:case 11:case 14:case 15:if(!kt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var g=f,S=g.destroy;g=g.tag,S!==void 0&&((g&2)!==0||(g&4)!==0)&&su(i,n,S),f=f.next}while(f!==l)}xr(e,n,i);break;case 1:if(!kt&&(Fi(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Je(i,n,T)}xr(e,n,i);break;case 21:xr(e,n,i);break;case 22:i.mode&1?(kt=(l=kt)||i.memoizedState!==null,xr(e,n,i),kt=l):xr(e,n,i);break;default:xr(e,n,i)}}function bf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Ry),n.forEach(function(l){var f=By.bind(null,e,l);i.has(l)||(i.add(l),l.then(f,f))})}}function pn(e,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=S),l&=~g}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Ay(l/1960))-l,10e?16:e,_r===null)var l=!1;else{if(e=_r,_r=null,Js=0,($e&6)!==0)throw Error(o(331));var f=$e;for($e|=4,ye=e.current;ye!==null;){var g=ye,S=g.child;if((ye.flags&16)!==0){var T=g.deletions;if(T!==null){for(var O=0;OVe()-fu?Kr(e,0):du|=i),zt(e,n)}function Of(e,n){n===0&&((e.mode&1)===0?n=1:(n=Pn,Pn<<=1,(Pn&130023424)===0&&(Pn=4194304)));var i=Ct();e=Kn(e,n),e!==null&&(Rn(e,n,i),zt(e,i))}function Hy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Of(e,i)}function By(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Of(e,i)}var Ff;Ff=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Tt.current)At=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return At=!1,My(e,n,i);At=(e.flags&131072)!==0}else At=!1,Ge&&(n.flags&1048576)!==0&&vd(n,Is,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Ys(e,n),e=n.pendingProps;var f=Ii(n,wt.current);zi(n,i),f=Va(null,n,l,e,f,i);var g=Wa();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Lt(l)?(g=!0,Cs(n)):g=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,$a(n),f.updater=Ws,n.stateNode=f,f._reactInternals=n,Ka(n,l,e,i),n=eu(null,n,l,!0,g,i)):(n.tag=0,Ge&&g&&ba(n),Et(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Ys(e,n),e=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=Wy(l),e=fn(l,e),f){case 0:n=Ja(null,n,l,e,i);break e;case 1:n=ff(null,n,l,e,i);break e;case 11:n=lf(null,n,l,e,i);break e;case 14:n=af(null,n,l,fn(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:fn(l,f),Ja(e,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:fn(l,f),ff(e,n,l,f,i);case 3:e:{if(hf(n),e===null)throw Error(o(387));l=n.pendingProps,g=n.memoizedState,f=g.element,Ed(e,n),zs(n,l,null,i);var S=n.memoizedState;if(l=S.element,g.isDehydrated)if(g={element:l,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){f=Oi(Error(o(423)),n),n=pf(e,n,l,i,f);break e}else if(l!==f){f=Oi(Error(o(424)),n),n=pf(e,n,l,i,f);break e}else for(Ut=hr(n.stateNode.containerInfo.firstChild),Wt=n,Ge=!0,dn=null,i=jd(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Li(),l===f){n=Zn(e,n,i);break e}Et(e,n,l,i)}n=n.child}return n;case 5:return Pd(n),e===null&&Ma(n),l=n.type,f=n.pendingProps,g=e!==null?e.memoizedProps:null,S=f.children,wa(l,f)?S=null:g!==null&&wa(l,g)&&(n.flags|=32),df(e,n),Et(e,n,S,i),n.child;case 6:return e===null&&Ma(n),null;case 13:return gf(e,n,i);case 4:return za(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=Ai(n,null,l,i):Et(e,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:fn(l,f),lf(e,n,l,f,i);case 7:return Et(e,n,n.pendingProps,i),n.child;case 8:return Et(e,n,n.pendingProps.children,i),n.child;case 12:return Et(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,g=n.memoizedProps,S=f.value,Be(Ls,l._currentValue),l._currentValue=S,g!==null)if(cn(g.value,S)){if(g.children===f.children&&!Tt.current){n=Zn(e,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var T=g.dependencies;if(T!==null){S=g.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(g.tag===1){O=Qn(-1,i&-i),O.tag=2;var ee=g.updateQueue;if(ee!==null){ee=ee.shared;var le=ee.pending;le===null?O.next=O:(O.next=le.next,le.next=O),ee.pending=O}}g.lanes|=i,O=g.alternate,O!==null&&(O.lanes|=i),La(g.return,i,n),T.lanes|=i;break}O=O.next}}else if(g.tag===10)S=g.type===n.type?null:g.child;else if(g.tag===18){if(S=g.return,S===null)throw Error(o(341));S.lanes|=i,T=S.alternate,T!==null&&(T.lanes|=i),La(S,i,n),S=g.sibling}else S=g.child;if(S!==null)S.return=g;else for(S=g;S!==null;){if(S===n){S=null;break}if(g=S.sibling,g!==null){g.return=S.return,S=g;break}S=S.return}g=S}Et(e,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,zi(n,i),f=en(f),l=l(f),n.flags|=1,Et(e,n,l,i),n.child;case 14:return l=n.type,f=fn(l,n.pendingProps),f=fn(l.type,f),af(e,n,l,f,i);case 15:return uf(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:fn(l,f),Ys(e,n),n.tag=1,Lt(l)?(e=!0,Cs(n)):e=!1,zi(n,i),Jd(n,l,f),Ka(n,l,f,i),eu(null,n,l,!0,e,i);case 19:return yf(e,n,i);case 22:return cf(e,n,i)}throw Error(o(156,n.tag))};function Hf(e,n){return pi(e,n)}function Vy(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function rn(e,n,i,l){return new Vy(e,n,i,l)}function wu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Wy(e){if(typeof e=="function")return wu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===re)return 11;if(e===W)return 14}return 2}function Nr(e,n){var i=e.alternate;return i===null?(i=rn(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function rl(e,n,i,l,f,g){var S=2;if(l=e,typeof e=="function")wu(e)&&(S=1);else if(typeof e=="string")S=5;else e:switch(e){case V:return Zr(i.children,f,g,n);case X:S=8,f|=8;break;case G:return e=rn(12,i,n,f|2),e.elementType=G,e.lanes=g,e;case te:return e=rn(13,i,n,f),e.elementType=te,e.lanes=g,e;case I:return e=rn(19,i,n,f),e.elementType=I,e.lanes=g,e;case U:return il(i,f,g,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case J:S=10;break e;case Z:S=9;break e;case re:S=11;break e;case W:S=14;break e;case H:S=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=rn(S,i,n,f),n.elementType=e,n.type=l,n.lanes=g,n}function Zr(e,n,i,l){return e=rn(7,e,l,n),e.lanes=i,e}function il(e,n,i,l){return e=rn(22,e,l,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function _u(e,n,i){return e=rn(6,e,null,n),e.lanes=i,e}function Su(e,n,i){return n=rn(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Uy(e,n,i,l,f){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=In(0),this.expirationTimes=In(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=In(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function ku(e,n,i,l,f,g,S,T,O){return e=new Uy(e,n,i,T,O),n===1?(n=1,g===!0&&(n|=8)):n=0,g=rn(3,null,null,n),e.current=g,g.stateNode=e,g.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},$a(g),e}function Yy(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),Mu.exports=i0(),Mu.exports}var th;function o0(){if(th)return dl;th=1;var t=_p();return dl.createRoot=t.createRoot,dl.hydrateRoot=t.hydrateRoot,dl}var s0=o0();function Sp(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Te(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(Sp(s,o.statusText||"Request failed"))}return o.json()}const l0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Pe={health:()=>Te("/api/health"),settings:()=>Te("/api/settings"),saveSettings:t=>{const r={...t};for(const o of l0)r[o]===""&&delete r[o];return Te("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Te("/api/repos"),browse:t=>Te(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Te(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Te("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Te(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Te(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:t=>Te(`/api/architecture?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Te("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Te("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Te("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Te("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Te("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Te(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open",s)=>Te("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o,repo_path:s||null})}),scmRepos:t=>Te(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Te("/api/oauth/status"),githubOAuthStart:()=>Te("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Te("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Te("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Te("/api/oauth/gitlab/start"),oauthDisconnect:t=>Te("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Te("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})}),reviews:t=>Te(`/api/reviews?repo_path=${encodeURIComponent(t)}`),getReview:(t,r)=>Te(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(t)}`),reviewDiff:(t,r,o)=>Te(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(t)}&other=${encodeURIComponent(o)}`),config:t=>Te(`/api/config?repo_path=${encodeURIComponent(t)}`),saveConfig:(t,r)=>Te("/api/config",{method:"PUT",body:JSON.stringify({repo_path:t,...r})}),addWaiver:(t,r,o,s)=>Te("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:t,rule:r,node:o||null,reason:s||""})}),marks:(t,r)=>Te(`/api/marks?repo_path=${encodeURIComponent(t)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:t=>Te(`/api/architecture/health?repo_path=${encodeURIComponent(t)}`),workspaceStatus:t=>Te(`/api/workspace/status?repo_path=${encodeURIComponent(t)}`),openEditor:(t,r,o,s)=>Te("/api/open",{method:"POST",body:JSON.stringify({repo_path:t,path:r,line:o||null,editor:s||null})}),exportHtml:t=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:t})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(Sp(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(t,r,o,s)=>Te("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:t,edges:r,source_id:o,target_id:s||null})})};function a0(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):t}function u0({open:t,actions:r,onClose:o}){const[s,a]=L.useState(""),[u,c]=L.useState(0),h=L.useRef(null),p=L.useMemo(()=>a0(r,s),[r,s]);if(L.useEffect(()=>{if(!t)return;a(""),c(0);const m=window.setTimeout(()=>{var y;return(y=h.current)==null?void 0:y.focus()},0);return()=>window.clearTimeout(m)},[t]),L.useEffect(()=>{c(0)},[s]),!t)return null;const x=p[u],v=m=>{m&&(o(),m.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:m=>{m.target===m.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:m=>a(m.target.value),onKeyDown:m=>{m.key==="Escape"?(m.preventDefault(),o()):m.key==="ArrowDown"?(m.preventDefault(),c(y=>Math.min(p.length-1,y+1))):m.key==="ArrowUp"?(m.preventDefault(),c(y=>Math.max(0,y-1))):m.key==="Enter"&&(m.preventDefault(),v(x))}}),d.jsxs("ul",{children:[p.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,p.slice(0,40).map((m,y)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:y===u?"active":"",onMouseEnter:()=>c(y),onClick:()=>v(m),children:[d.jsx("span",{children:m.label}),m.hint?d.jsx("span",{className:"muted",children:m.hint}):null]})},m.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function c0({config:t,busy:r,onSave:o,onWaiver:s}){const[a,u]=L.useState(t),[c,h]=L.useState(t.available_rules[0]||""),[p,x]=L.useState(""),[v,m]=L.useState("");L.useEffect(()=>{u(t)},[t]);const y=Object.entries(a.contexts||{}),_=(M,k,b)=>{const A=a.contexts[M];if(!A)return;const $=V=>V.split(",").map(X=>X.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[M]:{...A,[k]:k==="name"?b:$(b)}}})},N=(M,k)=>{const b=k.trim();if(!b||b===M)return;const{[M]:A,...$}=a.contexts;A&&u({...a,contexts:{...$,[b]:{...A,name:b}}})},j=()=>{let M=1;for(;a.contexts[`context-${M}`];)M+=1;const k=`context-${M}`;u({...a,contexts:{...a.contexts,[k]:{name:k,django_apps:[],react:[],public_api:[],owners:[]}}})},E=M=>{const{[M]:k,...b}=a.contexts;u({...a,contexts:b})},w=M=>{const k=a.rules.includes(M);u({...a,rules:k?a.rules.filter(b=>b!==M):[...a.rules,M]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),y.map(([M,k])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:M})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:M,"data-testid":`config-context-name-${M}`,onBlur:b=>N(M,b.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(k.django_apps||[]).join(", "),onChange:b=>_(M,"django_apps",b.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(k.react||[]).join(", "),onChange:b=>_(M,"react",b.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(k.public_api||[]).join(", "),onChange:b=>_(M,"public_api",b.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(k.owners||[]).join(", "),onChange:b=>_(M,"owners",b.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>E(M),children:"Remove context"})]},M)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:j,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(M=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(M),onChange:()=>w(M)}),M]},M))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((M,k)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.rule}),M.node?` · ${M.node}`:"",M.reason?` — ${M.reason}`:""]},`${M.rule}:${M.node}:${k}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:M=>h(M.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(M=>d.jsx("option",{value:M,children:M},M))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:M=>x(M.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:v,onChange:M=>m(M.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,v),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function Xo(t){return t.replaceAll("_"," ")}function d0(t){return t.replaceAll("_"," ")}function to(t){return t.split(".").pop()||t}function Xu(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function f0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Mr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function ai({className:t,children:r}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function h0({className:t}){return d.jsxs(ai,{className:t,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function p0({className:t}){return d.jsxs(ai,{className:t,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function g0({className:t}){return d.jsxs(ai,{className:t,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function m0({className:t}){return d.jsxs(ai,{className:t,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function y0({className:t}){return d.jsxs(ai,{className:t,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function kp({className:t}){return d.jsx(ai,{className:t,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function v0({className:t}){return d.jsx(ai,{className:t,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const x0="modulepreload",w0=function(t,r){return new URL(t,r).href},nh={},_0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(v){return Promise.all(v.map(m=>Promise.resolve(m).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),x=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(v=>{if(v=w0(v,s),v in nh)return;nh[v]=!0;const m=v.endsWith(".css"),y=m?'[rel="stylesheet"]':"";if(!!s)for(let j=h.length-1;j>=0;j--){const E=h[j];if(E.href===v&&(!m||E.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${v}"]${y}`))return;const N=document.createElement("link");if(N.rel=m?"stylesheet":x0,m||(N.as="script"),N.crossOrigin="",N.href=v,x&&N.setAttribute("nonce",x),document.head.appendChild(N),m)return new Promise((j,E)=>{N.addEventListener("load",j),N.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${v}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function rt(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Ol(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}kl.prototype=Ol.prototype={constructor:kl,on:function(t,r){var o=this._,s=k0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),ih.hasOwnProperty(r)?{space:ih[r],local:t}:t}function j0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===qu&&r.documentElement.namespaceURI===qu?r.createElement(t):r.createElementNS(o,t)}}function b0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Np(t){var r=Fl(t);return(r.local?b0:j0)(r)}function E0(){}function dc(t){return t==null?E0:function(){return this.querySelector(t)}}function C0(t){typeof t!="function"&&(t=dc(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=k&&(k=M+1);!(A=E[k])&&++k=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function J0(t){t||(t=ev);function r(m,y){return m&&y?t(m.__data__,y.__data__):!m-!y}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function tv(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function nv(){return Array.from(this)}function rv(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?pv:typeof r=="function"?mv:gv)(t,r,o??"")):Xi(this.node(),t)}function Xi(t,r){return t.style.getPropertyValue(r)||Mp(t).getComputedStyle(t,null).getPropertyValue(r)}function vv(t){return function(){delete this[t]}}function xv(t,r){return function(){this[t]=r}}function wv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function _v(t,r){return arguments.length>1?this.each((r==null?vv:typeof r=="function"?wv:xv)(t,r)):this.node()[t]}function Pp(t){return t.trim().split(/^|\s+/)}function fc(t){return t.classList||new Ip(t)}function Ip(t){this._node=t,this._names=Pp(t.getAttribute("class")||"")}Ip.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Rp(t,r){for(var o=fc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function qv(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function Ku(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:x,dispatch:v}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:x,enumerable:!0,configurable:!0},_:{value:v}})}Ku.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function ox(t){return!t.ctrlKey&&!t.button}function sx(){return this.parentNode}function lx(t,r){return r??{x:t.x,y:t.y}}function ax(){return navigator.maxTouchPoints||"ontouchstart"in this}function Dp(){var t=ox,r=sx,o=lx,s=ax,a={},u=Ol("start","drag","end"),c=0,h,p,x,v,m=0;function y(b){b.on("mousedown.drag",_).filter(s).on("touchstart.drag",E).on("touchmove.drag",w,ix).on("touchend.drag touchcancel.drag",M).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(b,A){if(!(v||!t.call(this,b,A))){var $=k(this,r.call(this,b,A),b,A,"mouse");$&&(Gt(b.view).on("mousemove.drag",N,qo).on("mouseup.drag",j,qo),$p(b.view),Ru(b),x=!1,h=b.clientX,p=b.clientY,$("start",b))}}function N(b){if(Yi(b),!x){var A=b.clientX-h,$=b.clientY-p;x=A*A+$*$>m}a.mouse("drag",b)}function j(b){Gt(b.view).on("mousemove.drag mouseup.drag",null),zp(b.view,x),Yi(b),a.mouse("end",b)}function E(b,A){if(t.call(this,b,A)){var $=b.changedTouches,V=r.call(this,b,A),X=$.length,G,J;for(G=0;G>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?hl(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?hl(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=cx.exec(t))?new Ot(r[1],r[2],r[3],1):(r=dx.exec(t))?new Ot(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=fx.exec(t))?hl(r[1],r[2],r[3],r[4]):(r=hx.exec(t))?hl(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=px.exec(t))?dh(r[1],r[2]/100,r[3]/100,1):(r=gx.exec(t))?dh(r[1],r[2]/100,r[3]/100,r[4]):oh.hasOwnProperty(t)?ah(oh[t]):t==="transparent"?new Ot(NaN,NaN,NaN,0):null}function ah(t){return new Ot(t>>16&255,t>>8&255,t&255,1)}function hl(t,r,o,s){return s<=0&&(t=r=o=NaN),new Ot(t,r,o,s)}function vx(t){return t instanceof ls||(t=ri(t)),t?(t=t.rgb(),new Ot(t.r,t.g,t.b,t.opacity)):new Ot}function Qu(t,r,o,s){return arguments.length===1?vx(t):new Ot(t,r,o,s??1)}function Ot(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}hc(Ot,Qu,Op(ls,{brighter(t){return t=t==null?Ml:Math.pow(Ml,t),new Ot(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Ko:Math.pow(Ko,t),new Ot(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Ot(ti(this.r),ti(this.g),ti(this.b),Pl(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:uh,formatHex:uh,formatHex8:xx,formatRgb:ch,toString:ch}));function uh(){return`#${ei(this.r)}${ei(this.g)}${ei(this.b)}`}function xx(){return`#${ei(this.r)}${ei(this.g)}${ei(this.b)}${ei((isNaN(this.opacity)?1:this.opacity)*255)}`}function ch(){const t=Pl(this.opacity);return`${t===1?"rgb(":"rgba("}${ti(this.r)}, ${ti(this.g)}, ${ti(this.b)}${t===1?")":`, ${t})`}`}function Pl(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ti(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ei(t){return t=ti(t),(t<16?"0":"")+t.toString(16)}function dh(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new yn(t,r,o,s)}function Fp(t){if(t instanceof yn)return new yn(t.h,t.s,t.l,t.opacity);if(t instanceof ls||(t=ri(t)),!t)return new yn;if(t instanceof yn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new yn(c,h,p,t.opacity)}function wx(t,r,o,s){return arguments.length===1?Fp(t):new yn(t,r,o,s??1)}function yn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}hc(yn,wx,Op(ls,{brighter(t){return t=t==null?Ml:Math.pow(Ml,t),new yn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Ko:Math.pow(Ko,t),new yn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Ot(Tu(t>=240?t-240:t+120,a,s),Tu(t,a,s),Tu(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new yn(fh(this.h),pl(this.s),pl(this.l),Pl(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 t=Pl(this.opacity);return`${t===1?"hsl(":"hsla("}${fh(this.h)}, ${pl(this.s)*100}%, ${pl(this.l)*100}%${t===1?")":`, ${t})`}`}}));function fh(t){return t=(t||0)%360,t<0?t+360:t}function pl(t){return Math.max(0,Math.min(1,t||0))}function Tu(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const pc=t=>()=>t;function _x(t,r){return function(o){return t+o*r}}function Sx(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function kx(t){return(t=+t)==1?Hp:function(r,o){return o-r?Sx(r,o,t):pc(isNaN(r)?o:r)}}function Hp(t,r){var o=r-t;return o?_x(t,o):pc(isNaN(t)?r:t)}const Il=(function t(r){var o=kx(r);function s(a,u){var c=o((a=Qu(a)).r,(u=Qu(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),x=Hp(a.opacity,u.opacity);return function(v){return a.r=c(v),a.g=h(v),a.b=p(v),a.opacity=x(v),a+""}}return s.gamma=t,s})(1);function Nx(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:Dn(s,a)})),o=Lu.lastIndex;return o180?v+=360:v-x>180&&(x+=360),y.push({i:m.push(a(m)+"rotate(",null,s)-2,x:Dn(x,v)})):v&&m.push(a(m)+"rotate("+v+s)}function h(x,v,m,y){x!==v?y.push({i:m.push(a(m)+"skewX(",null,s)-2,x:Dn(x,v)}):v&&m.push(a(m)+"skewX("+v+s)}function p(x,v,m,y,_,N){if(x!==m||v!==y){var j=_.push(a(_)+"scale(",null,",",null,")");N.push({i:j-4,x:Dn(x,m)},{i:j-2,x:Dn(v,y)})}else(m!==1||y!==1)&&_.push(a(_)+"scale("+m+","+y+")")}return function(x,v){var m=[],y=[];return x=t(x),v=t(v),u(x.translateX,x.translateY,v.translateX,v.translateY,m,y),c(x.rotate,v.rotate,m,y),h(x.skewX,v.skewX,m,y),p(x.scaleX,x.scaleY,v.scaleX,v.scaleY,m,y),x=v=null,function(_){for(var N=-1,j=y.length,E;++N=0&&t._call.call(void 0,r),t=t._next;--qi}function gh(){ii=(Tl=Zo.now())+Hl,qi=Wo=0;try{Ox()}finally{qi=0,Hx(),ii=0}}function Fx(){var t=Zo.now(),r=t-Tl;r>Up&&(Hl-=r,Tl=t)}function Hx(){for(var t,r=Rl,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:Rl=o);Uo=t,ec(s)}function ec(t){if(!qi){Wo&&(Wo=clearTimeout(Wo));var r=t-ii;r>24?(t<1/0&&(Wo=setTimeout(gh,t-Zo.now()-Hl)),Bo&&(Bo=clearInterval(Bo))):(Bo||(Tl=Zo.now(),Bo=setInterval(Fx,Up)),qi=1,Yp(gh))}}function mh(t,r,o){var s=new Ll;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Bx=Ol("start","end","cancel","interrupt"),Vx=[],Xp=0,yh=1,tc=2,jl=3,vh=4,nc=5,bl=6;function Bl(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;Wx(t,o,{name:r,index:s,group:a,on:Bx,tween:Vx,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Xp})}function mc(t,r){var o=_n(t,r);if(o.state>Xp)throw new Error("too late; already scheduled");return o}function Fn(t,r){var o=_n(t,r);if(o.state>jl)throw new Error("too late; already running");return o}function _n(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Wx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=Gp(u,0,o.time);function u(x){o.state=yh,o.timer.restart(c,o.delay,o.time),o.delay<=x&&c(x-o.delay)}function c(x){var v,m,y,_;if(o.state!==yh)return p();for(v in s)if(_=s[v],_.name===o.name){if(_.state===jl)return mh(c);_.state===vh?(_.state=bl,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete s[v]):+vtc&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function ww(t,r,o){var s,a,u=xw(r)?mc:Fn;return function(){var c=u(this,t),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function _w(t,r){var o=this._id;return arguments.length<2?_n(this.node(),o).on.on(t):this.each(ww(o,t,r))}function Sw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function kw(){return this.on("end.remove",Sw(this._id))}function Nw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=dc(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function qw(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function tr(t,r,o){this.k=t,this.x=r,this.y=o}tr.prototype={constructor:tr,scale:function(t){return t===1?this:new tr(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new tr(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Vl=new tr(1,0,0);Zp.prototype=tr.prototype;function Zp(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Vl;return t.__zoom}function Au(t){t.stopImmediatePropagation()}function Vo(t){t.preventDefault(),t.stopImmediatePropagation()}function Kw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Qw(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function xh(){return this.__zoom||Vl}function Zw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Jw(){return navigator.maxTouchPoints||"ontouchstart"in this}function e1(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function Jp(){var t=Kw,r=Qw,o=e1,s=Zw,a=Jw,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=Nl,x=Ol("start","zoom","end"),v,m,y,_=500,N=150,j=0,E=10;function w(I){I.property("__zoom",xh).on("wheel.zoom",X,{passive:!1}).on("mousedown.zoom",G).on("dblclick.zoom",J).filter(a).on("touchstart.zoom",Z).on("touchmove.zoom",re).on("touchend.zoom touchcancel.zoom",te).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}w.transform=function(I,W,H,U){var C=I.selection?I.selection():I;C.property("__zoom",xh),I!==C?A(I,W,H,U):C.interrupt().each(function(){$(this,arguments).event(U).start().zoom(null,typeof W=="function"?W.apply(this,arguments):W).end()})},w.scaleBy=function(I,W,H,U){w.scaleTo(I,function(){var C=this.__zoom.k,D=typeof W=="function"?W.apply(this,arguments):W;return C*D},H,U)},w.scaleTo=function(I,W,H,U){w.transform(I,function(){var C=r.apply(this,arguments),D=this.__zoom,B=H==null?b(C):typeof H=="function"?H.apply(this,arguments):H,P=D.invert(B),z=typeof W=="function"?W.apply(this,arguments):W;return o(k(M(D,z),B,P),C,c)},H,U)},w.translateBy=function(I,W,H,U){w.transform(I,function(){return o(this.__zoom.translate(typeof W=="function"?W.apply(this,arguments):W,typeof H=="function"?H.apply(this,arguments):H),r.apply(this,arguments),c)},null,U)},w.translateTo=function(I,W,H,U,C){w.transform(I,function(){var D=r.apply(this,arguments),B=this.__zoom,P=U==null?b(D):typeof U=="function"?U.apply(this,arguments):U;return o(Vl.translate(P[0],P[1]).scale(B.k).translate(typeof W=="function"?-W.apply(this,arguments):-W,typeof H=="function"?-H.apply(this,arguments):-H),D,c)},U,C)};function M(I,W){return W=Math.max(u[0],Math.min(u[1],W)),W===I.k?I:new tr(W,I.x,I.y)}function k(I,W,H){var U=W[0]-H[0]*I.k,C=W[1]-H[1]*I.k;return U===I.x&&C===I.y?I:new tr(I.k,U,C)}function b(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function A(I,W,H,U){I.on("start.zoom",function(){$(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(U).end()}).tween("zoom",function(){var C=this,D=arguments,B=$(C,D).event(U),P=r.apply(C,D),z=H==null?b(P):typeof H=="function"?H.apply(C,D):H,ie=Math.max(P[1][0]-P[0][0],P[1][1]-P[0][1]),oe=C.__zoom,de=typeof W=="function"?W.apply(C,D):W,pe=p(oe.invert(z).concat(ie/oe.k),de.invert(z).concat(ie/de.k));return function(he){if(he===1)he=de;else{var Q=pe(he),ae=ie/Q[2];he=new tr(ae,z[0]-Q[0]*ae,z[1]-Q[1]*ae)}B.zoom(null,he)}})}function $(I,W,H){return!H&&I.__zooming||new V(I,W)}function V(I,W){this.that=I,this.args=W,this.active=0,this.sourceEvent=null,this.extent=r.apply(I,W),this.taps=0}V.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,W){return this.mouse&&I!=="mouse"&&(this.mouse[1]=W.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=W.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=W.invert(this.touch1[0])),this.that.__zoom=W,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var W=Gt(this.that).datum();x.call(I,this.that,new qw(I,{sourceEvent:this.sourceEvent,target:w,transform:this.that.__zoom,dispatch:x}),W)}};function X(I,...W){if(!t.apply(this,arguments))return;var H=$(this,W).event(I),U=this.__zoom,C=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,s.apply(this,arguments)))),D=mn(I);if(H.wheel)(H.mouse[0][0]!==D[0]||H.mouse[0][1]!==D[1])&&(H.mouse[1]=U.invert(H.mouse[0]=D)),clearTimeout(H.wheel);else{if(U.k===C)return;H.mouse=[D,U.invert(D)],El(this),H.start()}Vo(I),H.wheel=setTimeout(B,N),H.zoom("mouse",o(k(M(U,C),H.mouse[0],H.mouse[1]),H.extent,c));function B(){H.wheel=null,H.end()}}function G(I,...W){if(y||!t.apply(this,arguments))return;var H=I.currentTarget,U=$(this,W,!0).event(I),C=Gt(I.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",ie,!0),D=mn(I,H),B=I.clientX,P=I.clientY;$p(I.view),Au(I),U.mouse=[D,this.__zoom.invert(D)],El(this),U.start();function z(oe){if(Vo(oe),!U.moved){var de=oe.clientX-B,pe=oe.clientY-P;U.moved=de*de+pe*pe>j}U.event(oe).zoom("mouse",o(k(U.that.__zoom,U.mouse[0]=mn(oe,H),U.mouse[1]),U.extent,c))}function ie(oe){C.on("mousemove.zoom mouseup.zoom",null),zp(oe.view,U.moved),Vo(oe),U.event(oe).end()}}function J(I,...W){if(t.apply(this,arguments)){var H=this.__zoom,U=mn(I.changedTouches?I.changedTouches[0]:I,this),C=H.invert(U),D=H.k*(I.shiftKey?.5:2),B=o(k(M(H,D),U,C),r.apply(this,W),c);Vo(I),h>0?Gt(this).transition().duration(h).call(A,B,U,I):Gt(this).call(w.transform,B,U,I)}}function Z(I,...W){if(t.apply(this,arguments)){var H=I.touches,U=H.length,C=$(this,W,I.changedTouches.length===U).event(I),D,B,P,z;for(Au(I),B=0;B`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},Jo=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],eg=["Enter"," ","Escape"],tg={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Ki;(function(t){t.Strict="strict",t.Loose="loose"})(Ki||(Ki={}));var ni;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(ni||(ni={}));var es;(function(t){t.Partial="partial",t.Full="full"})(es||(es={}));const ng={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Pr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Pr||(Pr={}));var ts;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(ts||(ts={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const wh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function rg(t){return t===null?null:t?"valid":"invalid"}const ig=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,t1=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),vc=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),as=(t,r=[0,0])=>{const{width:o,height:s}=Sn(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},n1=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):vc(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,Wl(a,Al(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?Ul(s):{x:0,y:0,width:0,height:0}},us=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=Wl(o,Al(a)),s=!0)}),s?Ul(o):{x:0,y:0,width:0,height:0}},xc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,x=r.width/a,v=r.height/a,m=[];for(const y of t.values()){const{measured:_,selectable:N=!0,hidden:j=!1}=y;if(c&&!N||j)continue;const E=_.width??y.width??y.initialWidth??0,w=_.height??y.height??y.initialHeight??0,{x:M,y:k}=y.internals.positionAbsolute,b=ag(h,p,x,v,M,k,E,w),A=E*w,$=u&&b>0;(!y.internals.handleBounds||$||b>=A||y.dragging)&&m.push(y)}return m},r1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function i1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=Sn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function o1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const h=i1(t,c),p=us(h),x=_c(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(x,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function og({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),h=c.parentId?o.get(c.parentId):void 0,{x:p,y:x}=h?h.internals.positionAbsolute:{x:0,y:0},v=c.origin??s;let m=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",wn.error005());else{const{width:_,height:N}=Sn(h);_&&N&&(m=[[p,x],[p+_,x+N]])}else h&&si(c.extent)&&(m=[[c.extent[0][0]+p,c.extent[0][1]+x],[c.extent[1][0]+p,c.extent[1][1]+x]]);const y=si(m)?oi(r,m,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",wn.error015())),{position:{x:y.x-p+(c.measured.width??0)*v[0],y:y.y-x+(c.measured.height??0)*v[1]},positionAbsolute:y}}async function s1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(y=>y.id)),c=[];for(const y of o){if(y.deletable===!1)continue;const _=u.has(y.id),N=!_&&y.parentId&&c.find(j=>j.id===y.parentId);(_||N)&&c.push(y)}const h=new Set(r.map(y=>y.id)),p=s.filter(y=>y.deletable!==!1),v=r1(c,p);for(const y of p)h.has(y.id)&&!v.find(N=>N.id===y.id)&&v.push(y);if(!a)return{edges:v,nodes:c};const m=await a({nodes:c,edges:v});return typeof m=="boolean"?m?{edges:v,nodes:c}:{edges:[],nodes:[]}:m}const Qi=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),oi=(t={x:0,y:0},r,o)=>({x:Qi(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:Qi(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function sg(t,r,o){const{width:s,height:a}=Sn(o),{x:u,y:c}=o.internals.positionAbsolute;return oi(t,[[u,c],[u+s,c+a]],r)}const _h=(t,r,o)=>to?-Qi(Math.abs(t-o),1,r)/r:0,wc=(t,r,o=15,s=40)=>{const a=_h(t.x,s,r.width-s)*o,u=_h(t.y,s,r.height-s)*o;return[a,u]},Wl=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),rc=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),Ul=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),ns=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=vc(t)?t.internals.positionAbsolute:as(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},Al=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=vc(t)?t.internals.positionAbsolute:as(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},lg=(t,r)=>Ul(Wl(rc(t),rc(r))),ag=(t,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),x=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*x)},$l=(t,r)=>ag(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),Sh=t=>vn(t.width)&&vn(t.height)&&vn(t.x)&&vn(t.y),vn=t=>!isNaN(t)&&isFinite(t),ug=(t,r)=>(o,s)=>{},cs=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),ds=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(t-o)/a,y:(r-s)/a};return u?cs(h,c):h},Zi=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Wi(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function l1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Wi(t,o),a=Wi(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Wi(t.top??t.y??0,o),a=Wi(t.bottom??t.y??0,o),u=Wi(t.left??t.x??0,r),c=Wi(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function a1(t,r,o,s,a,u){const{x:c,y:h}=Zi(t,[r,o,s]),{x:p,y:x}=Zi({x:t.x+t.width,y:t.y+t.height},[r,o,s]),v=a-p,m=u-x;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(v),bottom:Math.floor(m)}}const _c=(t,r,o,s,a,u)=>{const c=l1(u,r,o),h=(r-c.x)/t.width,p=(o-c.y)/t.height,x=Math.min(h,p),v=Qi(x,s,a),m=t.x+t.width/2,y=t.y+t.height/2,_=r/2-m*v,N=o/2-y*v,j=a1(t,_,N,v,r,o),E={left:Math.min(j.left-c.left,0),top:Math.min(j.top-c.top,0),right:Math.min(j.right-c.right,0),bottom:Math.min(j.bottom-c.bottom,0)};return{x:_-E.left+E.right,y:N-E.top+E.bottom,zoom:v}},rs=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function si(t){return t!=null&&t!=="parent"}function Sn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function cg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function dg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function kh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function u1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function c1(t){return{...tg,...t||{}}}function Go(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=xn(t),h=ds({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y:x}=o?cs(h,r):h;return{xSnapped:p,ySnapped:x,...h}}const Sc=t=>({width:t.offsetWidth,height:t.offsetHeight}),fg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},d1=["INPUT","SELECT","TEXTAREA"];function hg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:d1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const pg=t=>"clientX"in t,xn=(t,r)=>{var u,c;const o=pg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},Nh=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...Sc(c)}})};function gg({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=t*.125+a*.375+c*.375+o*.125,x=r*.125+u*.375+h*.375+s*.125,v=Math.abs(p-t),m=Math.abs(x-r);return[p,x,v,m]}function yl(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function jh({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case Se.Left:return[r-yl(r-s,u),o];case Se.Right:return[r+yl(s-r,u),o];case Se.Top:return[r,o-yl(o-a,u)];case Se.Bottom:return[r,o+yl(a-o,u)]}}function mg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top,curvature:c=.25}){const[h,p]=jh({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[x,v]=jh({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[m,y,_,N]=gg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:x,targetControlY:v});return[`M${t},${r} C${h},${p} ${x},${v} ${s},${a}`,m,y,_,N]}function yg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const p1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,g1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),m1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",wn.error006()),r;const s=o.getEdgeId||p1;let a;return ig(t)?a={...t}:a={...t,id:s(t)},g1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function vg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=yg({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,h]}const bh={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},y1=({source:t,sourcePosition:r=Se.Bottom,target:o})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function v1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:s=Se.Top,center:a,offset:u,stepPosition:c}){const h=bh[r],p=bh[s],x={x:t.x+h.x*u,y:t.y+h.y*u},v={x:o.x+p.x*u,y:o.y+p.y*u},m=y1({source:x,sourcePosition:r,target:v}),y=m.x!==0?"x":"y",_=m[y];let N=[],j,E;const w={x:0,y:0},M={x:0,y:0},[,,k,b]=yg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[y]*p[y]===-1){y==="x"?(j=a.x??x.x+(v.x-x.x)*c,E=a.y??(x.y+v.y)/2):(j=a.x??(x.x+v.x)/2,E=a.y??x.y+(v.y-x.y)*c);const X=[{x:j,y:x.y},{x:j,y:v.y}],G=[{x:x.x,y:E},{x:v.x,y:E}];h[y]===_?N=y==="x"?X:G:N=y==="x"?G:X}else{const X=[{x:x.x,y:v.y}],G=[{x:v.x,y:x.y}];if(y==="x"?N=h.x===_?G:X:N=h.y===_?X:G,r===s){const I=Math.abs(t[y]-o[y]);if(I<=u){const W=Math.min(u-1,u-I);h[y]===_?w[y]=(x[y]>t[y]?-1:1)*W:M[y]=(v[y]>o[y]?-1:1)*W}}if(r!==s){const I=y==="x"?"y":"x",W=h[y]===p[I],H=x[I]>v[I],U=x[I]=te?(j=(J.x+Z.x)/2,E=N[0].y):(j=N[0].x,E=(J.y+Z.y)/2)}const A={x:x.x+w.x,y:x.y+w.y},$={x:v.x+M.x,y:v.y+M.y};return[[t,...A.x!==N[0].x||A.y!==N[0].y?[A]:[],...N,...$.x!==N[N.length-1].x||$.y!==N[N.length-1].y?[$]:[],o],j,E,k,b]}function x1(t,r,o,s){const a=Math.min(Eh(t,r)/2,Eh(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const x=t.xo.id===r):t[0])||null}function oc(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function _1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const x=oc(p,r);u.has(x)||(c.push({id:x,color:p.color||o,...p}),u.add(x))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const xg=1e3,S1=10,kc={nodeOrigin:[0,0],nodeExtent:Jo,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},k1={...kc,checkEquality:!0};function Nc(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function N1(t,r,o){const s=Nc(kc,o);for(const a of t.values())if(a.parentId)bc(a,t,r,s);else{const u=as(a,s.nodeOrigin),c=si(a.extent)?a.extent:s.nodeExtent,h=oi(u,c,Sn(a));a.internals.positionAbsolute=h}}function j1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function jc(t){return t==="manual"}function sc(t,r,o,s={}){var v,m;const a=Nc(k1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!jc(a.zIndexMode)?xg:0;let p=t.length>0,x=!1;r.clear(),o.clear();for(const y of t){let _=c.get(y.id);if(a.checkEquality&&y===(_==null?void 0:_.internals.userNode))r.set(y.id,_);else{const N=as(y,a.nodeOrigin),j=si(y.extent)?y.extent:a.nodeExtent,E=oi(N,j,Sn(y));_={...a.defaults,...y,measured:{width:(v=y.measured)==null?void 0:v.width,height:(m=y.measured)==null?void 0:m.height},internals:{positionAbsolute:E,handleBounds:j1(y,_),z:wg(y,h,a.zIndexMode),userNode:y}},r.set(y.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),y.parentId&&bc(_,r,o,s,u),x||(x=y.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:x}}function b1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function bc(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=Nc(kc,s),x=t.parentId,v=r.get(x);if(!v){console.warn(`Parent node ${x} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}b1(t,o),a&&!v.parentId&&v.internals.rootParentIndex===void 0&&p==="auto"&&(v.internals.rootParentIndex=++a.i,v.internals.z=v.internals.z+a.i*S1),a&&v.internals.rootParentIndex!==void 0&&(a.i=v.internals.rootParentIndex);const m=u&&!jc(p)?xg:0,{x:y,y:_,z:N}=E1(t,v,c,h,m,p),{positionAbsolute:j}=t.internals,E=y!==j.x||_!==j.y;(E||N!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:E?{x:y,y:_}:j,z:N}})}function wg(t,r,o){const s=vn(t.zIndex)?t.zIndex:0;return jc(o)?s:s+(t.selected?r:0)}function E1(t,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=Sn(t),x=as(t,o),v=si(t.extent)?oi(x,t.extent,p):x;let m=oi({x:c+v.x,y:h+v.y},s,p);t.extent==="parent"&&(m=sg(m,p,r));const y=wg(t,a,u),_=r.internals.z??0;return{x:m.x,y:m.y,z:_>=y?_+1:y}}function Ec(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const x=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??ns(p),v=lg(x,h.rect);u.set(h.parentId,{expandedRect:v,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},x)=>{var k;const v=p.internals.positionAbsolute,m=Sn(p),y=p.origin??s,_=h.x0||N>0||w||M)&&(a.push({id:x,type:"position",position:{x:p.position.x-_+w,y:p.position.y-N+M}}),(k=o.get(x))==null||k.forEach(b=>{t.some(A=>A.id===b.id)||a.push({id:b.id,type:"position",position:{x:b.position.x+_,y:b.position.y+N}})})),(m.width0){const _=Ec(y,r,o,a);x.push(..._)}return{changes:x,updatedInternals:p}}async function M1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Ih(t,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${t}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${t}-${u}`;const x=s.get(c)||new Map;s.set(c,x.set(o,r))}}function _g(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},x=`${a}-${c}--${u}-${h}`,v=`${u}-${h}--${a}-${c}`;Ih("source",p,v,t,a,c),Ih("target",p,x,t,u,h),r.set(s.id,s)}}function Sg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:Sg(o,r):!1}function Rh(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function P1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!Sg(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function $u({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[x,v]of r){const m=(c=o.get(x))==null?void 0:c.internals.userNode;m&&a.push({...m,position:v.position,dragging:s})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function I1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=cs(u,r);return{x:c.x-u.x,y:c.y-u.y}}function R1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,x={x:0,y:0},v=null,m=!1,y=null,_=!1,N=!1,j=null;function E({noDragClassName:M,handleSelector:k,domNode:b,isSelectable:A,nodeId:$,nodeClickDistance:V=0}){y=Gt(b);function X({x:re,y:te}){const{nodeLookup:I,nodeExtent:W,snapGrid:H,snapToGrid:U,nodeOrigin:C,onNodeDrag:D,onSelectionDrag:B,onError:P,updateNodePositions:z}=r();u={x:re,y:te};let ie=!1;const oe=h.size>1,de=oe&&W?rc(us(h)):null,pe=oe&&U?I1({dragItems:h,snapGrid:H,x:re,y:te}):null;for(const[he,Q]of h){if(!I.has(he))continue;let ae={x:re-Q.distance.x,y:te-Q.distance.y};U&&(ae=pe?{x:Math.round(ae.x+pe.x),y:Math.round(ae.y+pe.y)}:cs(ae,H));let me=null;if(oe&&W&&!Q.extent&&de){const{positionAbsolute:ne}=Q.internals,Ne=ne.x-de.x+W[0][0],Me=ne.x+Q.measured.width-de.x2+W[1][0],Re=ne.y-de.y+W[0][1],Le=ne.y+Q.measured.height-de.y2+W[1][1];me=[[Ne,Re],[Me,Le]]}const{position:ke,positionAbsolute:ve}=og({nodeId:he,nextPosition:ae,nodeLookup:I,nodeExtent:me||W,nodeOrigin:C,onError:P});ie=ie||Q.position.x!==ke.x||Q.position.y!==ke.y,Q.position=ke,Q.internals.positionAbsolute=ve}if(N=N||ie,!!ie&&(z(h,!0),j&&(s||D||!$&&B))){const[he,Q]=$u({nodeId:$,dragItems:h,nodeLookup:I});s==null||s(j,h,he,Q),D==null||D(j,he,Q),$||B==null||B(j,Q)}}async function G(){if(!v)return;const{transform:re,panBy:te,autoPanSpeed:I,autoPanOnNodeDrag:W}=r();if(!W){p=!1,cancelAnimationFrame(c);return}const[H,U]=wc(x,v,I);(H!==0||U!==0)&&(u.x=(u.x??0)-H/re[2],u.y=(u.y??0)-U/re[2],await te({x:H,y:U})&&X(u)),c=requestAnimationFrame(G)}function J(re){var oe;const{nodeLookup:te,multiSelectionActive:I,nodesDraggable:W,transform:H,snapGrid:U,snapToGrid:C,selectNodesOnDrag:D,onNodeDragStart:B,onSelectionDragStart:P,unselectNodesAndEdges:z}=r();m=!0,(!D||!A)&&!I&&$&&((oe=te.get($))!=null&&oe.selected||z()),A&&D&&$&&(t==null||t($));const ie=Go(re.sourceEvent,{transform:H,snapGrid:U,snapToGrid:C,containerBounds:v});if(u=ie,h=P1(te,W,ie,$),h.size>0&&(o||B||!$&&P)){const[de,pe]=$u({nodeId:$,dragItems:h,nodeLookup:te});o==null||o(re.sourceEvent,h,de,pe),B==null||B(re.sourceEvent,de,pe),$||P==null||P(re.sourceEvent,pe)}}const Z=Dp().clickDistance(V).on("start",re=>{const{domNode:te,nodeDragThreshold:I,transform:W,snapGrid:H,snapToGrid:U}=r();v=(te==null?void 0:te.getBoundingClientRect())||null,_=!1,N=!1,j=re.sourceEvent,I===0&&J(re),u=Go(re.sourceEvent,{transform:W,snapGrid:H,snapToGrid:U,containerBounds:v}),x=xn(re.sourceEvent,v)}).on("drag",re=>{const{autoPanOnNodeDrag:te,transform:I,snapGrid:W,snapToGrid:H,nodeDragThreshold:U,nodeLookup:C}=r(),D=Go(re.sourceEvent,{transform:I,snapGrid:W,snapToGrid:H,containerBounds:v});if(j=re.sourceEvent,(re.sourceEvent.type==="touchmove"&&re.sourceEvent.touches.length>1||$&&!C.has($))&&(_=!0),!_){if(!p&&te&&m&&(p=!0,G()),!m){const B=xn(re.sourceEvent,v),P=B.x-x.x,z=B.y-x.y;Math.sqrt(P*P+z*z)>U&&J(re)}(u.x!==D.xSnapped||u.y!==D.ySnapped)&&h&&m&&(x=xn(re.sourceEvent,v),X(D))}}).on("end",re=>{if(!m||_){_&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,m=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:te,updateNodePositions:I,onNodeDragStop:W,onSelectionDragStop:H}=r();if(N&&(I(h,!1),N=!1),a||W||!$&&H){const[U,C]=$u({nodeId:$,dragItems:h,nodeLookup:te,dragging:!1});a==null||a(re.sourceEvent,h,U,C),W==null||W(re.sourceEvent,U,C),$||H==null||H(re.sourceEvent,C)}}}).filter(re=>{const te=re.target;return!re.button&&(!M||!Rh(te,`.${M}`,b))&&(!k||Rh(te,k,b))});y.call(Z)}function w(){y==null||y.on(".drag",null)}return{update:E,destroy:w}}function T1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())$l(a,ns(u))>0&&s.push(u);return s}const L1=250;function A1(t,r,o,s){var h,p;let a=[],u=1/0;const c=T1(t,o,r+L1);for(const x of c){const v=[...((h=x.internals.handleBounds)==null?void 0:h.source)??[],...((p=x.internals.handleBounds)==null?void 0:p.target)??[]];for(const m of v){if(s.nodeId===m.nodeId&&s.type===m.type&&s.id===m.id)continue;const{x:y,y:_}=li(x,m,m.position,!0),N=Math.sqrt(Math.pow(y-t.x,2)+Math.pow(_-t.y,2));N>r||(N1){const x=s.type==="source"?"target":"source";return a.find(v=>v.type===x)??a[0]}return a[0]}function kg(t,r,o,s,a,u=!1){var x,v,m;const c=s.get(t);if(!c)return null;const h=a==="strict"?(x=c.internals.handleBounds)==null?void 0:x[r]:[...((v=c.internals.handleBounds)==null?void 0:v.source)??[],...((m=c.internals.handleBounds)==null?void 0:m.target)??[]],p=(o?h==null?void 0:h.find(y=>y.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...li(c,p,p.position,!0)}:p}function Ng(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function $1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const jg=()=>!0;function z1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:x,autoPanOnConnect:v,flowId:m,panBy:y,cancelConnection:_,onConnectStart:N,onConnect:j,onConnectEnd:E,isValidConnection:w=jg,onReconnectEnd:M,updateConnection:k,getTransform:b,getFromHandle:A,autoPanSpeed:$,dragThreshold:V=1,handleDomNode:X}){const G=fg(t.target);let J=0,Z;const{x:re,y:te}=xn(t),I=Ng(u,X),W=h==null?void 0:h.getBoundingClientRect();let H=!1;if(!W||!I)return;const U=kg(a,I,s,p,r);if(!U)return;let C=xn(t,W),D=!1,B=null,P=!1,z=null;function ie(){if(!v||!W)return;const[ke,ve]=wc(C,W,$);y({x:ke,y:ve}),J=requestAnimationFrame(ie)}const oe={...U,nodeId:a,type:I,position:U.position},de=p.get(a);let he={inProgress:!0,isValid:null,from:li(de,oe,Se.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:de,to:C,toHandle:null,toPosition:wh[oe.position],toNode:null,pointer:C};function Q(){H=!0,k(he),N==null||N(t,{nodeId:a,handleId:s,handleType:I})}V===0&&Q();function ae(ke){if(!H){const{x:Le,y:Ze}=xn(ke),pt=Le-re,Xe=Ze-te;if(!(pt*pt+Xe*Xe>V*V))return;Q()}if(!A()||!oe){me(ke);return}const ve=b();C=xn(ke,W),Z=A1(ds(C,ve,!1,[1,1]),o,p,oe),D||(ie(),D=!0);const ne=bg(ke,{handle:Z,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:w,doc:G,lib:x,flowId:m,nodeLookup:p});z=ne.handleDomNode,B=ne.connection,P=$1(!!Z,ne.isValid);const Ne=p.get(a),Me=Ne?li(Ne,oe,Se.Left,!0):he.from,Re={...he,from:Me,isValid:P,to:ne.toHandle&&P?Zi({x:ne.toHandle.x,y:ne.toHandle.y},ve):C,toHandle:ne.toHandle,toPosition:P&&ne.toHandle?ne.toHandle.position:wh[oe.position],toNode:ne.toHandle?p.get(ne.toHandle.nodeId):null,pointer:C};k(Re),he=Re}function me(ke){if(!("touches"in ke&&ke.touches.length>0)){if(H){(Z||z)&&B&&P&&(j==null||j(B));const{inProgress:ve,...ne}=he,Ne={...ne,toPosition:he.toHandle?he.toPosition:null};E==null||E(ke,Ne),u&&(M==null||M(ke,Ne))}_(),cancelAnimationFrame(J),D=!1,P=!1,B=null,z=null,G.removeEventListener("mousemove",ae),G.removeEventListener("mouseup",me),G.removeEventListener("touchmove",ae),G.removeEventListener("touchend",me)}}G.addEventListener("mousemove",ae),G.addEventListener("mouseup",me),G.addEventListener("touchmove",ae),G.addEventListener("touchend",me)}function bg(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:x=jg,nodeLookup:v}){const m=u==="target",y=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:N}=xn(t),j=c.elementFromPoint(_,N),E=j!=null&&j.classList.contains(`${h}-flow__handle`)?j:y,w={handleDomNode:E,isValid:!1,connection:null,toHandle:null};if(E){const M=Ng(void 0,E),k=E.getAttribute("data-nodeid"),b=E.getAttribute("data-handleid"),A=E.classList.contains("connectable"),$=E.classList.contains("connectableend");if(!k||!M)return w;const V={source:m?k:s,sourceHandle:m?b:a,target:m?s:k,targetHandle:m?a:b};w.connection=V;const G=A&&$&&(o===Ki.Strict?m&&M==="source"||!m&&M==="target":k!==s||b!==a);w.isValid=G&&x(V),w.toHandle=kg(k,M,b,v,o,!0)}return w}const lc={onPointerDown:z1,isValid:bg};function D1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Gt(t);function u({translateExtent:h,width:p,height:x,zoomStep:v=1,pannable:m=!0,zoomable:y=!0,inversePan:_=!1}){const N=k=>{if(k.sourceEvent.type!=="wheel"||!r)return;const b=o(),A=k.sourceEvent.ctrlKey&&rs()?10:1,$=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*v,V=b[2]*Math.pow(2,$*A);r.scaleTo(V)};let j=[0,0];const E=k=>{(k.sourceEvent.type==="mousedown"||k.sourceEvent.type==="touchstart")&&(j=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY])},w=k=>{const b=o();if(k.sourceEvent.type!=="mousemove"&&k.sourceEvent.type!=="touchmove"||!r)return;const A=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY],$=[A[0]-j[0],A[1]-j[1]];j=A;const V=s()*Math.max(b[2],Math.log(b[2]))*(_?-1:1),X={x:b[0]-$[0]*V,y:b[1]-$[1]*V},G=[[0,0],[p,x]];r.setViewportConstrained({x:X.x,y:X.y,zoom:b[2]},G,h)},M=Jp().on("start",E).on("zoom",m?w:null).on("zoom.wheel",y?N:null);a.call(M,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:mn}}const Yl=t=>({x:t.x,y:t.y,zoom:t.k}),zu=({x:t,y:r,zoom:o})=>Vl.translate(t,r).scale(o),Cr=(t,r)=>t.target.closest(`.${r}`),Eg=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),O1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Du=(t,r=0,o=O1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Cg=t=>{const r=t.ctrlKey&&rs()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function F1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:x}){return v=>{if(Cr(v,r))return v.ctrlKey&&v.preventDefault(),!1;v.preventDefault(),v.stopImmediatePropagation();const m=o.property("__zoom").k||1;if(v.ctrlKey&&c){const E=mn(v),w=Cg(v),M=m*Math.pow(2,w);s.scaleTo(o,M,E,v);return}const y=v.deltaMode===1?20:1;let _=a===ni.Vertical?0:v.deltaX*y,N=a===ni.Horizontal?0:v.deltaY*y;!rs()&&v.shiftKey&&a!==ni.Vertical&&(_=v.deltaY*y,N=0),s.translateBy(o,-(_/m)*u,-(N/m)*u,{internal:!0});const j=Yl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(v,j):(t.isPanScrolling=!0,h==null||h(v,j)),t.panScrollTimeout=setTimeout(()=>{x==null||x(v,j),t.isPanScrolling=!1},150)}}function H1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=Cr(s,t);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function B1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=Yl(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function V1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;t.usedRightMouseButton=!!(o&&Eg(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,Yl(u.transform)))}}function W1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&Eg(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const p=Yl(c.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function U1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:x,lib:v,connectionInProgress:m}){return y=>{var w;const _=r||o,N=s&&y.ctrlKey,j=y.type==="wheel";if(y.button===1&&y.type==="mousedown"&&(Cr(y,`${v}-flow__node`)||Cr(y,`${v}-flow__edge`)||Cr(y,`${v}-flow__selection`)||Cr(y,`${v}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!c&&!s||h||m&&!j||Cr(y,p)&&j||Cr(y,x)&&(!j||u&&j&&!r)||!s&&y.ctrlKey&&j)return!1;if(!s&&y.type==="touchstart"&&((w=y.touches)==null?void 0:w.length)>1)return y.preventDefault(),!1;if(!_&&!u&&!N&&j||!a&&(y.type==="mousedown"||y.type==="touchstart")||Array.isArray(a)&&!a.includes(y.button)&&y.type==="mousedown")return!1;const E=Array.isArray(a)&&a.includes(y.button)||!y.button||y.button<=1;return(!y.ctrlKey||j||t)&&E}}function Y1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const x={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},v=t.getBoundingClientRect();let m=[[0,0],[v.width,v.height]];const y=typeof ResizeObserver<"u"?new ResizeObserver(te=>{const I=te[0];I&&(m=[[0,0],[I.contentRect.width,I.contentRect.height]])}):null;y==null||y.observe(t);const _=Jp().extent(()=>m).scaleExtent([r,o]).translateExtent(s),N=Gt(t).call(_);b({x:a.x,y:a.y,zoom:Qi(a.zoom,r,o)},[[0,0],[v.width,v.height]],s);const j=N.on("wheel.zoom"),E=N.on("dblclick.zoom");_.wheelDelta(Cg);async function w(te,I){return N?new Promise(W=>{_==null||_.interpolate((I==null?void 0:I.interpolate)==="linear"?Yo:Nl).transform(Du(N,I==null?void 0:I.duration,I==null?void 0:I.ease,()=>W(!0)),te)}):!1}function M({noWheelClassName:te,noPanClassName:I,onPaneContextMenu:W,userSelectionActive:H,panOnScroll:U,panOnDrag:C,panOnScrollMode:D,panOnScrollSpeed:B,preventScrolling:P,zoomOnPinch:z,zoomOnScroll:ie,zoomOnDoubleClick:oe,panActivationKeyPressed:de=!1,zoomActivationKeyPressed:pe,lib:he,onTransformChange:Q,connectionInProgress:ae,paneClickDistance:me,selectionOnDrag:ke}){H&&!x.isZoomingOrPanning&&k();const ve=U&&!pe&&!H;_.clickDistance(ke?1/0:!vn(me)||me<0?0:me);const ne=ve?F1({zoomPanValues:x,noWheelClassName:te,d3Selection:N,d3Zoom:_,panOnScrollMode:D,panOnScrollSpeed:B,zoomOnPinch:z,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):H1({noWheelClassName:te,preventScrolling:P,d3ZoomHandler:j});N.on("wheel.zoom",ne,{passive:!1});const Ne=B1({zoomPanValues:x,onDraggingChange:p,onPanZoomStart:c});_.on("start",Ne);const Me=V1({zoomPanValues:x,panOnDrag:C,onPaneContextMenu:!!W,onPanZoom:u,onTransformChange:Q});_.on("zoom",Me);const Re=W1({zoomPanValues:x,panOnDrag:C,panOnScroll:U,onPaneContextMenu:W,onPanZoomEnd:h,onDraggingChange:p});_.on("end",Re);const Le=U1({panActivationKeyPressed:de,zoomActivationKeyPressed:pe,panOnDrag:C,zoomOnScroll:ie,panOnScroll:U,zoomOnDoubleClick:oe,zoomOnPinch:z,userSelectionActive:H,noPanClassName:I,noWheelClassName:te,lib:he,connectionInProgress:ae});_.filter(Le),oe?N.on("dblclick.zoom",E):N.on("dblclick.zoom",null)}function k(){_.on("zoom",null)}async function b(te,I,W){const H=zu(te),U=_==null?void 0:_.constrain()(H,I,W);return U&&await w(U),U}async function A(te,I){const W=zu(te);return await w(W,I),W}function $(te){if(N){const I=zu(te),W=N.property("__zoom");(W.k!==te.zoom||W.x!==te.x||W.y!==te.y)&&(_==null||_.transform(N,I,null,{sync:!0}))}}function V(){const te=N?Zp(N.node()):{x:0,y:0,k:1};return{x:te.x,y:te.y,zoom:te.k}}async function X(te,I){return N?new Promise(W=>{_==null||_.interpolate((I==null?void 0:I.interpolate)==="linear"?Yo:Nl).scaleTo(Du(N,I==null?void 0:I.duration,I==null?void 0:I.ease,()=>W(!0)),te)}):!1}async function G(te,I){return N?new Promise(W=>{_==null||_.interpolate((I==null?void 0:I.interpolate)==="linear"?Yo:Nl).scaleBy(Du(N,I==null?void 0:I.duration,I==null?void 0:I.ease,()=>W(!0)),te)}):!1}function J(te){_==null||_.scaleExtent(te)}function Z(te){_==null||_.translateExtent(te)}function re(te){const I=!vn(te)||te<0?0:te;_==null||_.clickDistance(I)}return{update:M,destroy:k,setViewport:A,setViewportConstrained:b,getViewport:V,scaleTo:X,scaleBy:G,setScaleExtent:J,setTranslateExtent:Z,syncViewport:$,setClickDistance:re}}var Ji;(function(t){t.Line="line",t.Handle="handle"})(Ji||(Ji={}));function G1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function Th(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function br(t,r){return Math.max(0,r-t)}function Er(t,r){return Math.max(0,t-r)}function vl(t,r,o){return Math.max(0,r-t,t-o)}function Lh(t,r){return t?!r:r}function X1(t,r,o,s,a,u,c,h){let{affectsX:p,affectsY:x}=r;const{isHorizontal:v,isVertical:m}=r,y=v&&m,{xSnapped:_,ySnapped:N}=o,{minWidth:j,maxWidth:E,minHeight:w,maxHeight:M}=s,{x:k,y:b,width:A,height:$,aspectRatio:V}=t;let X=Math.floor(v?_-t.pointerX:0),G=Math.floor(m?N-t.pointerY:0);const J=A+(p?-X:X),Z=$+(x?-G:G),re=-u[0]*A,te=-u[1]*$;let I=vl(J,j,E),W=vl(Z,w,M);if(c){let C=0,D=0;p&&X<0?C=br(k+X+re,c[0][0]):!p&&X>0&&(C=Er(k+J+re,c[1][0])),x&&G<0?D=br(b+G+te,c[0][1]):!x&&G>0&&(D=Er(b+Z+te,c[1][1])),I=Math.max(I,C),W=Math.max(W,D)}if(h){let C=0,D=0;p&&X>0?C=Er(k+X,h[0][0]):!p&&X<0&&(C=br(k+J,h[1][0])),x&&G>0?D=Er(b+G,h[0][1]):!x&&G<0&&(D=br(b+Z,h[1][1])),I=Math.max(I,C),W=Math.max(W,D)}if(a){if(v){const C=vl(J/V,w,M)*V;if(I=Math.max(I,C),c){let D=0;!p&&!x||p&&!x&&y?D=Er(b+te+J/V,c[1][1])*V:D=br(b+te+(p?X:-X)/V,c[0][1])*V,I=Math.max(I,D)}if(h){let D=0;!p&&!x||p&&!x&&y?D=br(b+J/V,h[1][1])*V:D=Er(b+(p?X:-X)/V,h[0][1])*V,I=Math.max(I,D)}}if(m){const C=vl(Z*V,j,E)/V;if(W=Math.max(W,C),c){let D=0;!p&&!x||x&&!p&&y?D=Er(k+Z*V+re,c[1][0])/V:D=br(k+(x?G:-G)*V+re,c[0][0])/V,W=Math.max(W,D)}if(h){let D=0;!p&&!x||x&&!p&&y?D=br(k+Z*V,h[1][0])/V:D=Er(k+(x?G:-G)*V,h[0][0])/V,W=Math.max(W,D)}}}G=G+(G<0?W:-W),X=X+(X<0?I:-I),a&&(y?J>Z*V?G=(Lh(p,x)?-X:X)/V:X=(Lh(p,x)?-G:G)*V:v?(G=X/V,x=p):(X=G*V,p=x));const H=p?k+X:k,U=x?b+G:b;return{width:A+(p?-X:X),height:$+(x?-G:G),x:u[0]*X*(p?-1:1)+H,y:u[1]*G*(x?-1:1)+U}}const Mg={width:0,height:0,x:0,y:0},q1={...Mg,pointerX:0,pointerY:0,aspectRatio:1};function K1(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function Q1({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Gt(t);let c={controlDirection:Th("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:x,boundaries:v,keepAspectRatio:m,resizeDirection:y,onResizeStart:_,onResize:N,onResizeEnd:j,shouldResize:E}){let w={...Mg},M={...q1};c={boundaries:v,resizeDirection:y,keepAspectRatio:m,controlDirection:Th(x)};let k,b=null,A=[],$,V,X,G=!1;const J=Dp().on("start",Z=>{const{nodeLookup:re,transform:te,snapGrid:I,snapToGrid:W,nodeOrigin:H,paneDomNode:U}=o();if(k=re.get(r),!k)return;b=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:C,ySnapped:D}=Go(Z.sourceEvent,{transform:te,snapGrid:I,snapToGrid:W,containerBounds:b});w={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},M={...w,pointerX:C,pointerY:D,aspectRatio:w.width/w.height},$=void 0,V=si(k.extent)?k.extent:void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&($=re.get(k.parentId)),$&&k.extent==="parent"&&(V=[[0,0],[$.measured.width,$.measured.height]]),A=[],X=void 0;for(const[B,P]of re)if(P.parentId===r&&(A.push({id:B,position:{...P.position},extent:P.extent}),P.extent==="parent"||P.expandParent)){const z=K1(P,k,P.origin??H);X?X=[[Math.min(z[0][0],X[0][0]),Math.min(z[0][1],X[0][1])],[Math.max(z[1][0],X[1][0]),Math.max(z[1][1],X[1][1])]]:X=z}_==null||_(Z,{...w})}).on("drag",Z=>{const{transform:re,snapGrid:te,snapToGrid:I,nodeOrigin:W}=o(),H=Go(Z.sourceEvent,{transform:re,snapGrid:te,snapToGrid:I,containerBounds:b}),U=[];if(!k)return;const{x:C,y:D,width:B,height:P}=w,z={},ie=k.origin??W,{width:oe,height:de,x:pe,y:he}=X1(M,c.controlDirection,H,c.boundaries,c.keepAspectRatio,ie,V,X),Q=oe!==B,ae=de!==P,me=pe!==C&&Q,ke=he!==D&&ae;if(!me&&!ke&&!Q&&!ae)return;if((me||ke||ie[0]===1||ie[1]===1)&&(z.x=me?pe:w.x,z.y=ke?he:w.y,w.x=z.x,w.y=z.y,A.length>0)){const Me=pe-C,Re=he-D;for(const Le of A)Le.position={x:Le.position.x-Me+ie[0]*(oe-B),y:Le.position.y-Re+ie[1]*(de-P)},U.push(Le)}if((Q||ae)&&(z.width=Q&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:w.width,z.height=ae&&(!c.resizeDirection||c.resizeDirection==="vertical")?de:w.height,w.width=z.width,w.height=z.height),$&&k.expandParent){const Me=ie[0]*(z.width??0);z.x&&z.x{G&&(j==null||j(Z,{...w}),a==null||a({...w}),G=!1)});u.call(J)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Ou={exports:{}},Fu={},Hu={exports:{}},Bu={};/** + * @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 Ah;function Z1(){if(Ah)return Bu;Ah=1;var t=os();function r(m,y){return m===y&&(m!==0||1/m===1/y)||m!==m&&y!==y}var o=typeof Object.is=="function"?Object.is:r,s=t.useState,a=t.useEffect,u=t.useLayoutEffect,c=t.useDebugValue;function h(m,y){var _=y(),N=s({inst:{value:_,getSnapshot:y}}),j=N[0].inst,E=N[1];return u(function(){j.value=_,j.getSnapshot=y,p(j)&&E({inst:j})},[m,_,y]),a(function(){return p(j)&&E({inst:j}),m(function(){p(j)&&E({inst:j})})},[m]),c(_),_}function p(m){var y=m.getSnapshot;m=m.value;try{var _=y();return!o(m,_)}catch{return!0}}function x(m,y){return y()}var v=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?x:h;return Bu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:v,Bu}var $h;function J1(){return $h||($h=1,Hu.exports=Z1()),Hu.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 zh;function e_(){if(zh)return Fu;zh=1;var t=os(),r=J1();function o(x,v){return x===v&&(x!==0||1/x===1/v)||x!==x&&v!==v}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Fu.useSyncExternalStoreWithSelector=function(x,v,m,y,_){var N=u(null);if(N.current===null){var j={hasValue:!1,value:null};N.current=j}else j=N.current;N=h(function(){function w($){if(!M){if(M=!0,k=$,$=y($),_!==void 0&&j.hasValue){var V=j.value;if(_(V,$))return b=V}return b=$}if(V=b,s(k,$))return V;var X=y($);return _!==void 0&&_(V,X)?(k=$,V):(k=$,b=X)}var M=!1,k,b,A=m===void 0?null:m;return[function(){return w(v())},A===null?void 0:function(){return w(A())}]},[v,m,y,_]);var E=a(x,N[0],N[1]);return c(function(){j.hasValue=!0,j.value=E},[E]),p(E),E},Fu}var Dh;function t_(){return Dh||(Dh=1,Ou.exports=e_()),Ou.exports}var n_=t_();const r_=wp(n_),i_={},Oh=t=>{let r;const o=new Set,s=(v,m)=>{const y=typeof v=="function"?v(r):v;if(!Object.is(y,r)){const _=r;r=m??(typeof y!="object"||y===null)?y:Object.assign({},r,y),o.forEach(N=>N(r,_))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>x,subscribe:v=>(o.add(v),()=>o.delete(v)),destroy:()=>{(i_?"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."),o.clear()}},x=r=t(s,a,p);return p},o_=t=>t?Oh(t):Oh,{useDebugValue:s_}=t0,{useSyncExternalStoreWithSelector:l_}=r_,a_=t=>t;function Pg(t,r=a_,o){const s=l_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return s_(s),s}const Fh=(t,r)=>{const o=o_(t),s=(a,u=r)=>Pg(o,a,u);return Object.assign(s,o),s},u_=(t,r)=>t?Fh(t,r):Fh;function Qe(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}_p();const Gl=L.createContext(null),c_=Gl.Provider,Ig=wn.error001("react");function ze(t,r){const o=L.useContext(Gl);if(o===null)throw new Error(Ig);return Pg(o,t,r)}function Ye(){const t=L.useContext(Gl);if(t===null)throw new Error(Ig);return L.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Hh={display:"none"},d_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Rg="react-flow__node-desc",Tg="react-flow__edge-desc",f_="react-flow__aria-live",h_=t=>t.ariaLiveMessage,p_=t=>t.ariaLabelConfig;function g_({rfId:t}){const r=ze(h_);return d.jsx("div",{id:`${f_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:d_,children:r})}function m_({rfId:t,disableKeyboardA11y:r}){const o=ze(p_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${Rg}-${t}`,style:Hh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${Tg}-${t}`,style:Hh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(g_,{rfId:t})]})}const Xl=L.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return d.jsx("div",{className:rt(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});Xl.displayName="Panel";const Bh="https://reactflow.dev?utm_source=attribution";function y_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:d.jsx(Xl,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Bh}`,children:d.jsx("a",{href:Bh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const v_=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},xl=t=>t.id;function x_(t,r){return Qe(t.selectedNodes.map(xl),r.selectedNodes.map(xl))&&Qe(t.selectedEdges.map(xl),r.selectedEdges.map(xl))}function w_({onSelectionChange:t}){const r=Ye(),{selectedNodes:o,selectedEdges:s}=ze(v_,x_);return L.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const __=t=>!!t.onSelectionChangeHandlers;function S_({onSelectionChange:t}){const r=ze(__);return t||r?d.jsx(w_,{onSelectionChange:t}):null}const Lg=[0,0],k_={x:0,y:0,zoom:1},N_=["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"],Vh=[...N_,"rfId"],j_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Wh={translateExtent:Jo,nodeOrigin:Lg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function b_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=ze(j_,Qe),x=Ye();L.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{v.current=Wh,h()}),[]);const v=L.useRef(Wh);return L.useEffect(()=>{for(const m of Vh){const y=t[m],_=v.current[m];y!==_&&(typeof t[m]>"u"||(m==="nodes"?r(y):m==="edges"?o(y):m==="minZoom"?s(y):m==="maxZoom"?a(y):m==="translateExtent"?u(y):m==="nodeExtent"?c(y):m==="ariaLabelConfig"?x.setState({ariaLabelConfig:c1(y)}):m==="fitView"?x.setState({fitViewQueued:y}):m==="fitViewOptions"?x.setState({fitViewOptions:y}):x.setState({[m]:y})))}v.current=t},Vh.map(m=>t[m])),null}function Uh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function E_(t){var s;const[r,o]=L.useState(t==="system"?null:t);return L.useEffect(()=>{if(t!=="system"){o(t);return}const a=Uh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=Uh())!=null&&s.matches?"dark":"light"}const Yh=typeof document<"u"?document:null;function is(t=null,r={target:Yh,actInsideInputWithModifier:!0}){const[o,s]=L.useState(!1),a=L.useRef(!1),u=L.useRef(new Set([])),[c,h]=L.useMemo(()=>{if(t!==null){const x=(Array.isArray(t)?t:[t]).filter(m=>typeof m=="string").map(m=>m.replace(/\+/g,` +`).replace(` + +`,` ++`).split(` +`)),v=x.reduce((m,y)=>m.concat(...y),[]);return[x,v]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Yh,x=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const v=_=>{var E,w;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!x)&&hg(_))return!1;const j=Xh(_.code,h);if(u.current.add(_[j]),Gh(c,u.current,!1)){const M=((w=(E=_.composedPath)==null?void 0:E.call(_))==null?void 0:w[0])||_.target,k=(M==null?void 0:M.nodeName)==="BUTTON"||(M==null?void 0:M.nodeName)==="A";r.preventDefault!==!1&&(a.current||!k)&&_.preventDefault(),s(!0)}},m=_=>{const N=Xh(_.code,h);Gh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[N]),_.key==="Meta"&&u.current.clear(),a.current=!1},y=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",v),p==null||p.addEventListener("keyup",m),window.addEventListener("blur",y),window.addEventListener("contextmenu",y),()=>{p==null||p.removeEventListener("keydown",v),p==null||p.removeEventListener("keyup",m),window.removeEventListener("blur",y),window.removeEventListener("contextmenu",y)}}},[t,s]),o}function Gh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Xh(t,r){return r.includes(t)?"code":"key"}const C_=()=>{const t=Ye();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=_c(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),x={x:r.x-h,y:r.y-p},v=o.snapGrid??a,m=o.snapToGrid??u;return ds(x,s,m,v)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=Zi(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function Ag(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)M_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function M_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function P_(t,r){return Ag(t,r)}function I_(t,r){return Ag(t,r)}function Jr(t,r){return{id:t,type:"select",selected:r}}function Ui(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(Jr(u.id,c)))}return s}function qh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Kh(t){return{id:t.id,type:"remove"}}const R_=ug();function T_(t,r,o={}){return m1(t,r,{...o,onError:o.onError??R_})}const Qh=t=>t1(t),L_=t=>ig(t);function $g(t){return L.forwardRef(t)}const zg=typeof window<"u"?L.useLayoutEffect:L.useEffect;function Zh(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>A_(()=>o(a=>a+BigInt(1))));return zg(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function A_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Dg=L.createContext(null);function $_({children:t}){const r=Ye(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:x,hasDefaultNodes:v,onNodesChange:m,nodeLookup:y,fitViewQueued:_,onNodesChangeMiddlewareMap:N}=r.getState();let j=p;for(const w of h)j=typeof w=="function"?w(j):w;let E=qh({items:j,lookup:y});for(const w of N.values())E=w(E);v&&x(j),E.length>0?m==null||m(E):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:w,nodes:M,setNodes:k}=r.getState();w&&k(M)})},[]),s=Zh(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:x,hasDefaultEdges:v,onEdgesChange:m,edgeLookup:y}=r.getState();let _=p;for(const N of h)_=typeof N=="function"?N(_):N;v?x(_):m&&m(qh({items:_,lookup:y}))},[]),u=Zh(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Dg.Provider,{value:c,children:t})}function z_(){const t=L.useContext(Dg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const D_=t=>!!t.panZoom;function ql(){const t=C_(),r=Ye(),o=z_(),s=ze(D_),a=L.useMemo(()=>{const u=m=>r.getState().nodeLookup.get(m),c=m=>{o.nodeQueue.push(m)},h=m=>{o.edgeQueue.push(m)},p=m=>{var w,M;const{nodeLookup:y,nodeOrigin:_}=r.getState(),N=Qh(m)?m:y.get(m.id),j=N.parentId?dg(N.position,N.measured,N.parentId,y,_):N.position,E={...N,position:j,width:((w=N.measured)==null?void 0:w.width)??N.width,height:((M=N.measured)==null?void 0:M.height)??N.height};return ns(E)},x=(m,y,_={replace:!1})=>{c(N=>N.map(j=>{if(j.id===m){const E=typeof y=="function"?y(j):y;return _.replace&&Qh(E)?E:{...j,...E}}return j}))},v=(m,y,_={replace:!1})=>{h(N=>N.map(j=>{if(j.id===m){const E=typeof y=="function"?y(j):y;return _.replace&&L_(E)?E:{...j,...E}}return j}))};return{getNodes:()=>r.getState().nodes.map(m=>({...m})),getNode:m=>{var y;return(y=u(m))==null?void 0:y.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:m=[]}=r.getState();return m.map(y=>({...y}))},getEdge:m=>r.getState().edgeLookup.get(m),setNodes:c,setEdges:h,addNodes:m=>{const y=Array.isArray(m)?m:[m];o.nodeQueue.push(_=>[..._,...y])},addEdges:m=>{const y=Array.isArray(m)?m:[m];o.edgeQueue.push(_=>[..._,...y])},toObject:()=>{const{nodes:m=[],edges:y=[],transform:_}=r.getState(),[N,j,E]=_;return{nodes:m.map(w=>({...w})),edges:y.map(w=>({...w})),viewport:{x:N,y:j,zoom:E}}},deleteElements:async({nodes:m=[],edges:y=[]})=>{const{nodes:_,edges:N,onNodesDelete:j,onEdgesDelete:E,triggerNodeChanges:w,triggerEdgeChanges:M,onDelete:k,onBeforeDelete:b}=r.getState(),{nodes:A,edges:$}=await s1({nodesToRemove:m,edgesToRemove:y,nodes:_,edges:N,onBeforeDelete:b}),V=$.length>0,X=A.length>0;if(V){const G=$.map(Kh);E==null||E($),M(G)}if(X){const G=A.map(Kh);j==null||j(A),w(G)}return(X||V)&&(k==null||k({nodes:A,edges:$})),{deletedNodes:A,deletedEdges:$}},getIntersectingNodes:(m,y=!0,_)=>{const N=Sh(m),j=N?m:p(m),E=_!==void 0;return j?(_||r.getState().nodes).filter(w=>{const M=r.getState().nodeLookup.get(w.id);if(M&&!N&&(w.id===m.id||!M.internals.positionAbsolute))return!1;const k=ns(E?w:M),b=$l(k,j);return y&&b>0||b>=k.width*k.height||b>=j.width*j.height}):[]},isNodeIntersecting:(m,y,_=!0)=>{const j=Sh(m)?m:p(m);if(!j)return!1;const E=$l(j,y);return _&&E>0||E>=y.width*y.height||E>=j.width*j.height},updateNode:x,updateNodeData:(m,y,_={replace:!1})=>{x(m,N=>{const j=typeof y=="function"?y(N):y;return _.replace?{...N,data:j}:{...N,data:{...N.data,...j}}},_)},updateEdge:v,updateEdgeData:(m,y,_={replace:!1})=>{v(m,N=>{const j=typeof y=="function"?y(N):y;return _.replace?{...N,data:j}:{...N,data:{...N.data,...j}}},_)},getNodesBounds:m=>{const{nodeLookup:y,nodeOrigin:_}=r.getState();return n1(m,{nodeLookup:y,nodeOrigin:_})},getHandleConnections:({type:m,id:y,nodeId:_})=>{var N;return Array.from(((N=r.getState().connectionLookup.get(`${_}-${m}${y?`-${y}`:""}`))==null?void 0:N.values())??[])},getNodeConnections:({type:m,handleId:y,nodeId:_})=>{var N;return Array.from(((N=r.getState().connectionLookup.get(`${_}${m?y?`-${m}-${y}`:`-${m}`:""}`))==null?void 0:N.values())??[])},fitView:async m=>{const y=r.getState().fitViewResolver??u1();return r.setState({fitViewQueued:!0,fitViewOptions:m,fitViewResolver:y}),o.nodeQueue.push(_=>[..._]),y.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const Jh=t=>t.selected,O_=typeof window<"u"?window:void 0;function F_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ye(),{deleteElements:s}=ql(),a=is(t,{actInsideInputWithModifier:!1}),u=is(r,{target:O_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(Jh),edges:c.filter(Jh)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function H_(t){const r=Ye();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=Sc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",wn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const Kl={position:"absolute",width:"100%",height:"100%",top:0,left:0},B_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function V_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=ni.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:x,translateExtent:v,minZoom:m,maxZoom:y,zoomActivationKeyCode:_,preventScrolling:N=!0,children:j,noWheelClassName:E,noPanClassName:w,onViewportChange:M,isControlledViewport:k,paneClickDistance:b,selectionOnDrag:A}){const $=Ye(),V=L.useRef(null),{userSelectionActive:X,lib:G,connectionInProgress:J}=ze(B_,Qe),Z=is(_),re=L.useRef();H_(V);const te=L.useCallback(I=>{M==null||M({x:I[0],y:I[1],zoom:I[2]}),k||$.setState({transform:I})},[M,k]);return L.useEffect(()=>{if(V.current){re.current=Y1({domNode:V.current,minZoom:m,maxZoom:y,translateExtent:v,viewport:x,onDraggingChange:U=>$.setState(C=>C.paneDragging===U?C:{paneDragging:U}),onPanZoomStart:(U,C)=>{const{onViewportChangeStart:D,onMoveStart:B}=$.getState();B==null||B(U,C),D==null||D(C)},onPanZoom:(U,C)=>{const{onViewportChange:D,onMove:B}=$.getState();B==null||B(U,C),D==null||D(C)},onPanZoomEnd:(U,C)=>{const{onViewportChangeEnd:D,onMoveEnd:B}=$.getState();B==null||B(U,C),D==null||D(C)}});const{x:I,y:W,zoom:H}=re.current.getViewport();return $.setState({panZoom:re.current,transform:[I,W,H],domNode:V.current.closest(".react-flow")}),()=>{var U;(U=re.current)==null||U.destroy()}}},[]),L.useEffect(()=>{var I;(I=re.current)==null||I.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:Z,preventScrolling:N,noPanClassName:w,userSelectionActive:X,noWheelClassName:E,lib:G,onTransformChange:te,connectionInProgress:J,selectionOnDrag:A,paneClickDistance:b})},[t,r,o,s,a,u,c,h,p,Z,N,w,X,E,G,te,J,A,b]),d.jsx("div",{className:"react-flow__renderer",ref:V,style:Kl,children:j})}const W_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function U_(){const{userSelectionActive:t,userSelectionRect:r}=ze(W_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const Vu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},Y_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function G_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=es.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:x,onPaneContextMenu:v,onPaneScroll:m,onPaneMouseEnter:y,onPaneMouseMove:_,onPaneMouseLeave:N,children:j}){const E=L.useRef(0),w=Ye(),{userSelectionActive:M,elementsSelectable:k,dragging:b,panBy:A,autoPanSpeed:$}=ze(Y_,Qe),V=k&&(t||M),X=L.useRef(null),G=L.useRef(),J=L.useRef(new Set),Z=L.useRef(new Set),re=L.useRef(!1),te=L.useRef(!1),I=L.useRef({x:0,y:0}),W=L.useRef(!1),H=Q=>{if(te.current||re.current||w.getState().connection.inProgress){te.current=!1,re.current=!1;return}x==null||x(Q),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},U=Q=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Q.preventDefault();return}v==null||v(Q)},C=m?Q=>m(Q):void 0,D=Q=>{te.current&&(Q.stopPropagation(),te.current=!1)},B=Q=>{var Le,Ze;if(Q.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:ae,transform:me}=w.getState();if(G.current=ae==null?void 0:ae.getBoundingClientRect(),!G.current)return;const ke=Q.target===X.current;if(!ke&&!!Q.target.closest(".nokey")||!t||!(c&&ke||r)||Q.button!==0||!Q.isPrimary)return;(Ze=(Le=Q.target)==null?void 0:Le.setPointerCapture)==null||Ze.call(Le,Q.pointerId),te.current=!1;const{x:Ne,y:Me}=xn(Q.nativeEvent,G.current),Re=ds({x:Ne,y:Me},me);w.setState({userSelectionRect:{width:0,height:0,startX:Re.x,startY:Re.y,x:Ne,y:Me}}),ke||(Q.stopPropagation(),Q.preventDefault())};function P(Q,ae){const{userSelectionRect:me}=w.getState();if(!me)return;const{transform:ke,nodeLookup:ve,edgeLookup:ne,connectionLookup:Ne,triggerNodeChanges:Me,triggerEdgeChanges:Re,defaultEdgeOptions:Le}=w.getState(),Ze={x:me.startX,y:me.startY},{x:pt,y:Xe}=Zi(Ze,ke),it={startX:Ze.x,startY:Ze.y,x:Qdt.id)),Z.current=new Set;const ot=(Le==null?void 0:Le.selectable)??!0;for(const dt of J.current){const gt=Ne.get(dt);if(gt)for(const{edgeId:mt}of gt.values()){const Pt=ne.get(mt);Pt&&(Pt.selectable??ot)&&Z.current.add(mt)}}if(!kh(on,J.current)){const dt=Ui(ve,J.current,!0);Me(dt)}if(!kh(Mt,Z.current)){const dt=Ui(ne,Z.current);Re(dt)}w.setState({userSelectionRect:it,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!a||!G.current)return;const[Q,ae]=wc(I.current,G.current,$);A({x:Q,y:ae}).then(me=>{if(!te.current||!me){E.current=requestAnimationFrame(z);return}const{x:ke,y:ve}=I.current;P(ke,ve),E.current=requestAnimationFrame(z)})}const ie=()=>{cancelAnimationFrame(E.current),E.current=0,W.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=Q=>{const{userSelectionRect:ae,transform:me,resetSelectedElements:ke}=w.getState();if(!G.current||!ae)return;const{x:ve,y:ne}=xn(Q.nativeEvent,G.current);I.current={x:ve,y:ne};const Ne=Zi({x:ae.startX,y:ae.startY},me);if(!te.current){const Me=r?0:u;if(Math.hypot(ve-Ne.x,ne-Ne.y)<=Me)return;ke(),h==null||h(Q)}te.current=!0,W.current||(z(),W.current=!0),P(ve,ne)},de=Q=>{var ae,me;if(!V){Q.target===X.current&&w.getState().connection.inProgress&&(re.current=!0);return}Q.button===0&&((me=(ae=Q.target)==null?void 0:ae.releasePointerCapture)==null||me.call(ae,Q.pointerId),!M&&Q.target===X.current&&w.getState().userSelectionRect&&(H==null||H(Q)),w.setState({userSelectionActive:!1,userSelectionRect:null}),te.current&&(p==null||p(Q),w.setState({nodesSelectionActive:J.current.size>0})),ie())},pe=Q=>{var ae,me;(me=(ae=Q.target)==null?void 0:ae.releasePointerCapture)==null||me.call(ae,Q.pointerId),ie()},he=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:rt(["react-flow__pane",{draggable:he,dragging:b,selection:t}]),onClick:V?void 0:Vu(H,X),onContextMenu:Vu(U,X),onWheel:Vu(C,X),onPointerEnter:V?void 0:y,onPointerMove:V?oe:_,onPointerUp:de,onPointerCancel:V?pe:void 0,onPointerDownCapture:V?B:void 0,onClickCapture:V?D:void 0,onPointerLeave:N,ref:X,style:Kl,children:[j,d.jsx(U_,{})]})}function ac({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),x=h.get(t);if(!x){p==null||p("012",wn.error012(t));return}r.setState({nodesSelectionActive:!1}),x.selected?(o||x.selected&&c)&&(u({nodes:[x],edges:[]}),requestAnimationFrame(()=>{var v;return(v=s==null?void 0:s.current)==null?void 0:v.blur()})):a([t])}function Og({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ye(),[p,x]=L.useState(!1),v=L.useRef();return L.useEffect(()=>{if(!r)return v.current=R1({getStoreItems:()=>h.getState(),onNodeMouseDown:m=>{ac({id:m,store:h,nodeRef:t})},onDragStart:()=>{x(!0)},onDragStop:()=>{x(!1)}}),()=>{var m;(m=v.current)==null||m.destroy(),v.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!v.current||v.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const X_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Fg(){const t=Ye();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:x,nodeOrigin:v}=t.getState(),m=new Map,y=X_(c),_=a?u[0]:5,N=a?u[1]:5,j=o.direction.x*_*o.factor,E=o.direction.y*N*o.factor;for(const[,w]of x){if(!y(w))continue;let M={x:w.internals.positionAbsolute.x+j,y:w.internals.positionAbsolute.y+E};a&&(M=cs(M,u));const{position:k,positionAbsolute:b}=og({nodeId:w.id,nextPosition:M,nodeLookup:x,nodeExtent:s,nodeOrigin:v,onError:h});w.position=k,w.internals.positionAbsolute=b,m.set(w.id,w)}p(m)},[])}const Cc=L.createContext(null),q_=Cc.Provider;Cc.Consumer;const Hg=()=>L.useContext(Cc),K_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Bg=L.createContext(null);function Q_({children:t}){const r=ze(K_,Qe);return d.jsx(Bg.Provider,{value:r,children:t})}function Z_(){const t=L.useContext(Bg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const J_={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},eS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:x}=c;if(!h&&!a)return J_;const v=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:v,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Ki.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:v&&x}};function tS({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:x,onMouseDown:v,onTouchStart:m,...y},_){var W,H;const N=c||null,j=t==="target",E=Ye(),w=Hg(),{connectOnClick:M,noPanClassName:k,rfId:b}=Z_(),{connectingFrom:A,connectingTo:$,clickConnecting:V,isPossibleEndHandle:X,connectionInProcess:G,clickConnectionInProcess:J,valid:Z}=ze(eS(w,N,t),Qe);w||(H=(W=E.getState()).onError)==null||H.call(W,"010",wn.error010());const re=U=>{const{defaultEdgeOptions:C,onConnect:D,hasDefaultEdges:B}=E.getState(),P={...C,...U};if(B){const{edges:z,setEdges:ie,onError:oe}=E.getState();ie(T_(P,z,{onError:oe}))}D==null||D(P),h==null||h(P)},te=U=>{if(!w)return;const C=pg(U.nativeEvent);if(a&&(C&&U.button===0||!C)){const D=E.getState();lc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:j,handleId:N,nodeId:w,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...B)=>{var P,z;return(z=(P=E.getState()).onConnectEnd)==null?void 0:z.call(P,...B)},updateConnection:D.updateConnection,onConnect:re,isValidConnection:o||((...B)=>{var P,z;return((z=(P=E.getState()).isValidConnection)==null?void 0:z.call(P,...B))??!0}),getTransform:()=>E.getState().transform,getFromHandle:()=>E.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}C?v==null||v(U):m==null||m(U)},I=U=>{const{onClickConnectStart:C,onClickConnectEnd:D,connectionClickStartHandle:B,connectionMode:P,isValidConnection:z,lib:ie,rfId:oe,nodeLookup:de,connection:pe}=E.getState();if(!w||!B&&!a)return;if(!B){C==null||C(U.nativeEvent,{nodeId:w,handleId:N,handleType:t}),E.setState({connectionClickStartHandle:{nodeId:w,type:t,id:N}});return}const he=fg(U.target),Q=o||z,{connection:ae,isValid:me}=lc.isValid(U.nativeEvent,{handle:{nodeId:w,id:N,type:t},connectionMode:P,fromNodeId:B.nodeId,fromHandleId:B.id||null,fromType:B.type,isValidConnection:Q,flowId:oe,doc:he,lib:ie,nodeLookup:de});me&&ae&&re(ae);const ke=structuredClone(pe);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,D==null||D(U,ke),E.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":N,"data-nodeid":w,"data-handlepos":r,"data-id":`${b}-${w}-${N}-${t}`,className:rt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",k,x,{source:!j,target:j,connectable:s,connectablestart:a,connectableend:u,clickconnecting:V,connectingfrom:A,connectingto:$,valid:Z,connectionindicator:s&&(!G||X)&&(G||J?u:a)}]),onMouseDown:te,onTouchStart:te,onClick:M?I:void 0,ref:_,...y,children:p})}const eo=L.memo($g(tS));function nS({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(eo,{type:"source",position:o,isConnectable:r})]})}function rS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:s=Se.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(eo,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(eo,{type:"source",position:s,isConnectable:r})]})}function iS(){return null}function oS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(eo,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const zl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},ep={input:nS,default:rS,output:oS,group:iS};function sS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const lS=t=>{const{width:r,height:o,x:s,y:a}=us(t.nodeLookup,{filter:u=>!!u.selected});return{width:vn(r)?r:null,height:vn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function aS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ye(),{width:a,height:u,transformString:c,userSelectionActive:h}=ze(lS,Qe),p=Fg(),x=L.useRef(null);L.useEffect(()=>{var _;o||(_=x.current)==null||_.focus({preventScroll:!0})},[o]);const v=!h&&a!==null&&u!==null;if(Og({nodeRef:x,disabled:!v}),!v)return null;const m=t?_=>{const N=s.getState().nodes.filter(j=>j.selected);t(_,N)}:void 0,y=_=>{Object.prototype.hasOwnProperty.call(zl,_.key)&&(_.preventDefault(),p({direction:zl[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:rt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:x,className:"react-flow__nodesselection-rect",onContextMenu:m,tabIndex:o?void 0:-1,onKeyDown:o?void 0:y,style:{width:a,height:u}})})}const tp=typeof window<"u"?window:void 0,uS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Vg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:x,selectionOnDrag:v,selectionMode:m,onSelectionStart:y,onSelectionEnd:_,multiSelectionKeyCode:N,panActivationKeyCode:j,zoomActivationKeyCode:E,elementsSelectable:w,zoomOnScroll:M,zoomOnPinch:k,panOnScroll:b,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:V,panOnDrag:X,autoPanOnSelection:G,defaultViewport:J,translateExtent:Z,minZoom:re,maxZoom:te,preventScrolling:I,onSelectionContextMenu:W,noWheelClassName:H,noPanClassName:U,disableKeyboardA11y:C,onViewportChange:D,isControlledViewport:B}){const{nodesSelectionActive:P,userSelectionActive:z}=ze(uS,Qe),ie=is(x,{target:tp}),oe=is(j,{target:tp}),de=oe||X,pe=oe||b,he=v&&de!==!0,Q=ie||z||he;return F_({deleteKeyCode:p,multiSelectionKeyCode:N}),d.jsx(V_,{onPaneContextMenu:u,elementsSelectable:w,zoomOnScroll:M,zoomOnPinch:k,panOnScroll:pe,panActivationKeyPressed:oe,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:V,panOnDrag:!ie&&de,defaultViewport:J,translateExtent:Z,minZoom:re,maxZoom:te,zoomActivationKeyCode:E,preventScrolling:I,noWheelClassName:H,noPanClassName:U,onViewportChange:D,isControlledViewport:B,paneClickDistance:h,selectionOnDrag:he,children:d.jsxs(G_,{onSelectionStart:y,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:de,autoPanOnSelection:G,isSelecting:!!Q,selectionMode:m,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:he,children:[t,P&&d.jsx(aS,{onSelectionContextMenu:W,noPanClassName:U,disableKeyboardA11y:C})]})})}Vg.displayName="FlowRenderer";const cS=L.memo(Vg),dS=t=>r=>t?xc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function fS(t){return ze(L.useCallback(dS(t),[t]),Qe)}const hS=t=>t.updateNodeInternals;function pS(){const t=ze(hS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function gS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ye(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),x=L.useRef(r),v=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!v||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[v,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const m=x.current!==r,y=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(m||y||_)&&(x.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function mS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:x,nodesFocusable:v,resizeObserver:m,noDragClassName:y,noPanClassName:_,disableKeyboardA11y:N,rfId:j,nodeTypes:E,nodeClickDistance:w,onError:M}){const{node:k,internals:b,isParent:A}=ze(Q=>{const ae=Q.nodeLookup.get(t),me=Q.parentLookup.has(t);return{node:ae,internals:ae.internals,isParent:me}},Qe);let $=k.type||"default",V=(E==null?void 0:E[$])||ep[$];V===void 0&&(M==null||M("003",wn.error003($)),$="default",V=(E==null?void 0:E.default)||ep.default);const X=!!(k.draggable||h&&typeof k.draggable>"u"),G=!!(k.selectable||p&&typeof k.selectable>"u"),J=!!(k.connectable||x&&typeof k.connectable>"u"),Z=!!(k.focusable||v&&typeof k.focusable>"u"),re=Ye(),te=cg(k),I=gS({node:k,nodeType:$,hasDimensions:te,resizeObserver:m}),W=Og({nodeRef:I,disabled:k.hidden||!X,noDragClassName:y,handleSelector:k.dragHandle,nodeId:t,isSelectable:G,nodeClickDistance:w}),H=Fg();if(k.hidden)return null;const U=Sn(k),C=sS(k),D=G||X||r||o||s||a,B=o?Q=>o(Q,{...b.userNode}):void 0,P=s?Q=>s(Q,{...b.userNode}):void 0,z=a?Q=>a(Q,{...b.userNode}):void 0,ie=u?Q=>u(Q,{...b.userNode}):void 0,oe=c?Q=>c(Q,{...b.userNode}):void 0,de=Q=>{const{selectNodesOnDrag:ae,nodeDragThreshold:me}=re.getState();G&&(!ae||!X||me>0)&&ac({id:t,store:re,nodeRef:I}),r&&r(Q,{...b.userNode})},pe=Q=>{if(!(hg(Q.nativeEvent)||N)){if(eg.includes(Q.key)&&G){const ae=Q.key==="Escape";ac({id:t,store:re,unselect:ae,nodeRef:I})}else if(X&&k.selected&&Object.prototype.hasOwnProperty.call(zl,Q.key)){Q.preventDefault();const{ariaLabelConfig:ae}=re.getState();re.setState({ariaLiveMessage:ae["node.a11yDescription.ariaLiveMessage"]({direction:Q.key.replace("Arrow","").toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),H({direction:zl[Q.key],factor:Q.shiftKey?4:1})}}},he=()=>{var Ne;if(N||!((Ne=I.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:Q,width:ae,height:me,autoPanOnNodeFocus:ke,setCenter:ve}=re.getState();if(!ke)return;xc(new Map([[t,k]]),{x:0,y:0,width:ae,height:me},Q,!0).length>0||ve(k.position.x+U.width/2,k.position.y+U.height/2,{zoom:Q[2]})};return d.jsx("div",{className:rt(["react-flow__node",`react-flow__node-${$}`,{[_]:X},k.className,{selected:k.selected,selectable:G,parent:A,draggable:X,dragging:W}]),ref:I,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:te?"visible":"hidden",...k.style,...C},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:B,onMouseMove:P,onMouseLeave:z,onContextMenu:ie,onClick:de,onDoubleClick:oe,onKeyDown:Z?pe:void 0,tabIndex:Z?0:void 0,onFocus:Z?he:void 0,role:k.ariaRole??(Z?"group":void 0),"aria-roledescription":"node","aria-describedby":N?void 0:`${Rg}-${j}`,"aria-label":k.ariaLabel,...k.domAttributes,children:d.jsx(q_,{value:t,children:d.jsx(V,{id:t,data:k.data,type:$,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:k.selected??!1,selectable:G,draggable:X,deletable:k.deletable??!0,isConnectable:J,sourcePosition:k.sourcePosition,targetPosition:k.targetPosition,dragging:W,dragHandle:k.dragHandle,zIndex:b.z,parentId:k.parentId,...U})})})}var yS=L.memo(mS);const vS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Wg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=ze(vS,Qe),u=fS(t.onlyRenderVisibleElements),c=pS();return d.jsx("div",{className:"react-flow__nodes",style:Kl,children:u.map(h=>d.jsx(yS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Wg.displayName="NodeRenderer";const xS=L.memo(Wg);function wS(t){return ze(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&h1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const _S=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},SS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},np={[ts.Arrow]:_S,[ts.ArrowClosed]:SS};function kS(t){const r=Ye();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(np,t)?np[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",wn.error009(t)),null)},[t])}const NS=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=kS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},Ug=({defaultColor:t,rfId:r})=>{const o=ze(u=>u.edges),s=ze(u=>u.defaultEdgeOptions),a=L.useMemo(()=>_1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(NS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Ug.displayName="MarkerDefinitions";var jS=L.memo(Ug);function Yg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:x,...v}){const[m,y]=L.useState({x:1,y:0,width:0,height:0}),_=rt(["react-flow__edge-textwrapper",x]),N=L.useRef(null);return L.useEffect(()=>{if(N.current){const j=N.current.getBBox();y({x:j.x,y:j.y,width:j.width,height:j.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-m.width/2} ${r-m.height/2})`,className:_,visibility:m.width?"visible":"hidden",...v,children:[a&&d.jsx("rect",{width:m.width+2*c[0],x:-c[0],y:-c[1],height:m.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:m.height/2,dy:"0.3em",ref:N,style:s,children:o}),p]}):null}Yg.displayName="EdgeText";const bS=L.memo(Yg);function Ql({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:x=20,...v}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...v,d:t,fill:"none",className:rt(["react-flow__edge-path",v.className])}),x?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:x,className:"react-flow__edge-interaction"}):null,s&&vn(r)&&vn(o)?d.jsx(bS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function rp({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function Gg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top}){const[c,h]=rp({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,x]=rp({pos:u,x1:s,y1:a,x2:t,y2:r}),[v,m,y,_]=gg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:x});return[`M${t},${r} C${c},${h} ${p},${x} ${s},${a}`,v,m,y,_]}function Xg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:x,labelShowBg:v,labelBgStyle:m,labelBgPadding:y,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,interactionWidth:w})=>{const[M,k,b]=Gg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),A=t.isInternal?void 0:r;return d.jsx(Ql,{id:A,path:M,labelX:k,labelY:b,label:p,labelStyle:x,labelShowBg:v,labelBgStyle:m,labelBgPadding:y,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,interactionWidth:w})})}const ES=Xg({isInternal:!1}),qg=Xg({isInternal:!0});ES.displayName="SimpleBezierEdge";qg.displayName="SimpleBezierEdgeInternal";function Kg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:m,style:y,sourcePosition:_=Se.Bottom,targetPosition:N=Se.Top,markerEnd:j,markerStart:E,pathOptions:w,interactionWidth:M})=>{const[k,b,A]=ic({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:N,borderRadius:w==null?void 0:w.borderRadius,offset:w==null?void 0:w.offset,stepPosition:w==null?void 0:w.stepPosition}),$=t.isInternal?void 0:r;return d.jsx(Ql,{id:$,path:k,labelX:b,labelY:A,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:m,style:y,markerEnd:j,markerStart:E,interactionWidth:M})})}const Qg=Kg({isInternal:!1}),Zg=Kg({isInternal:!0});Qg.displayName="SmoothStepEdge";Zg.displayName="SmoothStepEdgeInternal";function Jg(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(Qg,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const CS=Jg({isInternal:!1}),em=Jg({isInternal:!0});CS.displayName="StepEdge";em.displayName="StepEdgeInternal";function tm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:m,style:y,markerEnd:_,markerStart:N,interactionWidth:j})=>{const[E,w,M]=vg({sourceX:o,sourceY:s,targetX:a,targetY:u}),k=t.isInternal?void 0:r;return d.jsx(Ql,{id:k,path:E,labelX:w,labelY:M,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:m,style:y,markerEnd:_,markerStart:N,interactionWidth:j})})}const MS=tm({isInternal:!1}),nm=tm({isInternal:!0});MS.displayName="StraightEdge";nm.displayName="StraightEdgeInternal";function rm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:x,labelShowBg:v,labelBgStyle:m,labelBgPadding:y,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,pathOptions:w,interactionWidth:M})=>{const[k,b,A]=mg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:w==null?void 0:w.curvature}),$=t.isInternal?void 0:r;return d.jsx(Ql,{id:$,path:k,labelX:b,labelY:A,label:p,labelStyle:x,labelShowBg:v,labelBgStyle:m,labelBgPadding:y,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,interactionWidth:M})})}const PS=rm({isInternal:!1}),im=rm({isInternal:!0});PS.displayName="BezierEdge";im.displayName="BezierEdgeInternal";const ip={default:im,straight:nm,step:em,smoothstep:Zg,simplebezier:qg},op={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},IS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,RS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,sp="react-flow__edgeupdater";function lp({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:rt([sp,`${sp}-${h}`]),cx:IS(r,s,t),cy:RS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function TS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:x,onReconnectStart:v,onReconnectEnd:m,setReconnecting:y,setUpdateHover:_}){const N=Ye(),j=(b,A)=>{if(b.button!==0)return;const{autoPanOnConnect:$,domNode:V,connectionMode:X,connectionRadius:G,lib:J,onConnectStart:Z,cancelConnection:re,nodeLookup:te,rfId:I,panBy:W,updateConnection:H}=N.getState(),U=A.type==="target",C=(P,z)=>{y(!1),m==null||m(P,o,A.type,z)},D=P=>x==null?void 0:x(o,P),B=(P,z)=>{y(!0),v==null||v(b,o,A.type),Z==null||Z(P,z)};lc.onPointerDown(b.nativeEvent,{autoPanOnConnect:$,connectionMode:X,connectionRadius:G,domNode:V,handleId:A.id,nodeId:A.nodeId,nodeLookup:te,isTarget:U,edgeUpdaterType:A.type,lib:J,flowId:I,cancelConnection:re,panBy:W,isValidConnection:(...P)=>{var z,ie;return((ie=(z=N.getState()).isValidConnection)==null?void 0:ie.call(z,...P))??!0},onConnect:D,onConnectStart:B,onConnectEnd:(...P)=>{var z,ie;return(ie=(z=N.getState()).onConnectEnd)==null?void 0:ie.call(z,...P)},onReconnectEnd:C,updateConnection:H,getTransform:()=>N.getState().transform,getFromHandle:()=>N.getState().connection.fromHandle,dragThreshold:N.getState().connectionDragThreshold,handleDomNode:b.currentTarget})},E=b=>j(b,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),w=b=>j(b,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),M=()=>_(!0),k=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(lp,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:E,onMouseEnter:M,onMouseOut:k,type:"source"}),(t===!0||t==="target")&&d.jsx(lp,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:w,onMouseEnter:M,onMouseOut:k,type:"target"})]})}function LS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:x,reconnectRadius:v,onReconnect:m,onReconnectStart:y,onReconnectEnd:_,rfId:N,edgeTypes:j,noPanClassName:E,onError:w,disableKeyboardA11y:M}){let k=ze(ve=>ve.edgeLookup.get(t));const b=ze(ve=>ve.defaultEdgeOptions);k=b?{...b,...k}:k;let A=k.type||"default",$=(j==null?void 0:j[A])||ip[A];$===void 0&&(w==null||w("011",wn.error011(A)),A="default",$=(j==null?void 0:j.default)||ip.default);const V=!!(k.focusable||r&&typeof k.focusable>"u"),X=typeof m<"u"&&(k.reconnectable||o&&typeof k.reconnectable>"u"),G=!!(k.selectable||s&&typeof k.selectable>"u"),J=L.useRef(null),[Z,re]=L.useState(!1),[te,I]=L.useState(!1),W=Ye(),{zIndex:H=k.zIndex,sourceX:U,sourceY:C,targetX:D,targetY:B,sourcePosition:P,targetPosition:z}=ze(L.useCallback(ve=>{const ne=ve.nodeLookup.get(k.source),Ne=ve.nodeLookup.get(k.target);if(!ne||!Ne)return op;const Me=w1({id:t,sourceNode:ne,targetNode:Ne,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:ve.connectionMode,onError:w}),Re=f1({selected:k.selected,zIndex:k.zIndex,sourceNode:ne,targetNode:Ne,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||op,zIndex:Re}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex,w]),Qe),ie=L.useMemo(()=>k.markerStart?`url('#${oc(k.markerStart,N)}')`:void 0,[k.markerStart,N]),oe=L.useMemo(()=>k.markerEnd?`url('#${oc(k.markerEnd,N)}')`:void 0,[k.markerEnd,N]);if(k.hidden||U===null||C===null||D===null||B===null)return null;const de=ve=>{var Re;const{addSelectedEdges:ne,unselectNodesAndEdges:Ne,multiSelectionActive:Me}=W.getState();G&&(W.setState({nodesSelectionActive:!1}),k.selected&&Me?(Ne({nodes:[],edges:[k]}),(Re=J.current)==null||Re.blur()):ne([t])),a&&a(ve,k)},pe=u?ve=>{u(ve,{...k})}:void 0,he=c?ve=>{c(ve,{...k})}:void 0,Q=h?ve=>{h(ve,{...k})}:void 0,ae=p?ve=>{p(ve,{...k})}:void 0,me=x?ve=>{x(ve,{...k})}:void 0,ke=ve=>{var ne;if(!M&&eg.includes(ve.key)&&G){const{unselectNodesAndEdges:Ne,addSelectedEdges:Me}=W.getState();ve.key==="Escape"?((ne=J.current)==null||ne.blur(),Ne({edges:[k]})):Me([t])}};return d.jsx("svg",{style:{zIndex:H},children:d.jsxs("g",{className:rt(["react-flow__edge",`react-flow__edge-${A}`,k.className,E,{selected:k.selected,animated:k.animated,inactive:!G&&!a,updating:Z,selectable:G}]),onClick:de,onDoubleClick:pe,onContextMenu:he,onMouseEnter:Q,onMouseMove:ae,onMouseLeave:me,onKeyDown:V?ke:void 0,tabIndex:V?0:void 0,role:k.ariaRole??(V?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":k.ariaLabel===null?void 0:k.ariaLabel||`Edge from ${k.source} to ${k.target}`,"aria-describedby":V?`${Tg}-${N}`:void 0,ref:J,...k.domAttributes,children:[!te&&d.jsx($,{id:t,source:k.source,target:k.target,type:k.type,selected:k.selected,animated:k.animated,selectable:G,deletable:k.deletable??!0,label:k.label,labelStyle:k.labelStyle,labelShowBg:k.labelShowBg,labelBgStyle:k.labelBgStyle,labelBgPadding:k.labelBgPadding,labelBgBorderRadius:k.labelBgBorderRadius,sourceX:U,sourceY:C,targetX:D,targetY:B,sourcePosition:P,targetPosition:z,data:k.data,style:k.style,sourceHandleId:k.sourceHandle,targetHandleId:k.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in k?k.pathOptions:void 0,interactionWidth:k.interactionWidth}),X&&d.jsx(TS,{edge:k,isReconnectable:X,reconnectRadius:v,onReconnect:m,onReconnectStart:y,onReconnectEnd:_,sourceX:U,sourceY:C,targetX:D,targetY:B,sourcePosition:P,targetPosition:z,setUpdateHover:re,setReconnecting:I})]})})}var AS=L.memo(LS);const $S=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function om({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:x,onEdgeClick:v,reconnectRadius:m,onEdgeDoubleClick:y,onReconnectStart:_,onReconnectEnd:N,disableKeyboardA11y:j}){const{edgesFocusable:E,edgesReconnectable:w,elementsSelectable:M,onError:k}=ze($S,Qe),b=wS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(jS,{defaultColor:t,rfId:o}),b.map(A=>d.jsx(AS,{id:A,edgesFocusable:E,edgesReconnectable:w,elementsSelectable:M,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:x,onClick:v,reconnectRadius:m,onDoubleClick:y,onReconnectStart:_,onReconnectEnd:N,rfId:o,onError:k,edgeTypes:s,disableKeyboardA11y:j},A))]})}om.displayName="EdgeRenderer";const zS=L.memo(om),ap=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function DS({children:t}){const r=Ye(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return zg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=ap(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:ap(s)},children:t})}function OS(t){const r=ql(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const FS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function HS(t){const r=ze(FS),o=Ye();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function BS(t){return t.connection.inProgress?{...t.connection,to:ds(t.connection.to,t.transform)}:{...t.connection}}function VS(t){return BS}function WS(t){const r=VS();return ze(r,Qe)}const US=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function YS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=ze(US,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:rt(["react-flow__connection",rg(h)]),children:d.jsx(sm,{style:r,type:o,CustomComponent:s,isValid:h})})})}const sm=({style:t,type:r=Pr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:x,toNode:v,toHandle:m,toPosition:y,pointer:_}=WS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:x.x,toY:x.y,fromPosition:p,toPosition:y,connectionStatus:rg(s),toNode:v,toHandle:m,pointer:_});let N="";const j={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:x.x,targetY:x.y,targetPosition:y};switch(r){case Pr.Bezier:[N]=mg(j);break;case Pr.SimpleBezier:[N]=Gg(j);break;case Pr.Step:[N]=ic({...j,borderRadius:0});break;case Pr.SmoothStep:[N]=ic(j);break;default:[N]=vg(j)}return d.jsx("path",{d:N,fill:"none",className:"react-flow__connection-path",style:t})};sm.displayName="ConnectionLine";const GS={};function up(t=GS){L.useRef(t),Ye(),L.useEffect(()=>{},[t])}function XS(){Ye(),L.useRef(!1),L.useEffect(()=>{},[])}function lm({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:v,onSelectionContextMenu:m,onSelectionStart:y,onSelectionEnd:_,connectionLineType:N,connectionLineStyle:j,connectionLineComponent:E,connectionLineContainerStyle:w,selectionKeyCode:M,selectionOnDrag:k,selectionMode:b,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:V,deleteKeyCode:X,onlyRenderVisibleElements:G,elementsSelectable:J,defaultViewport:Z,translateExtent:re,minZoom:te,maxZoom:I,preventScrolling:W,defaultMarkerColor:H,zoomOnScroll:U,zoomOnPinch:C,panOnScroll:D,panOnScrollSpeed:B,panOnScrollMode:P,zoomOnDoubleClick:z,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:de,onPaneMouseEnter:pe,onPaneMouseMove:he,onPaneMouseLeave:Q,onPaneScroll:ae,onPaneContextMenu:me,paneClickDistance:ke,nodeClickDistance:ve,onEdgeContextMenu:ne,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Re,reconnectRadius:Le,onReconnect:Ze,onReconnectStart:pt,onReconnectEnd:Xe,noDragClassName:it,noWheelClassName:on,noPanClassName:Mt,disableKeyboardA11y:ot,nodeExtent:dt,rfId:gt,viewport:mt,onViewportChange:Pt,nodesDraggable:kn}){return up(t),up(r),XS(),OS(o),HS(mt),d.jsx(cS,{onPaneClick:de,onPaneMouseEnter:pe,onPaneMouseMove:he,onPaneMouseLeave:Q,onPaneContextMenu:me,onPaneScroll:ae,paneClickDistance:ke,deleteKeyCode:X,selectionKeyCode:M,selectionOnDrag:k,selectionMode:b,onSelectionStart:y,onSelectionEnd:_,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:V,elementsSelectable:J,zoomOnScroll:U,zoomOnPinch:C,zoomOnDoubleClick:z,panOnScroll:D,panOnScrollSpeed:B,panOnScrollMode:P,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:Z,translateExtent:re,minZoom:te,maxZoom:I,onSelectionContextMenu:m,preventScrolling:W,noDragClassName:it,noWheelClassName:on,noPanClassName:Mt,disableKeyboardA11y:ot,onViewportChange:Pt,isControlledViewport:!!mt,children:d.jsxs(DS,{children:[d.jsx(zS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:Ze,onReconnectStart:pt,onReconnectEnd:Xe,onlyRenderVisibleElements:G,onEdgeContextMenu:ne,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Re,reconnectRadius:Le,defaultMarkerColor:H,noPanClassName:Mt,disableKeyboardA11y:ot,rfId:gt}),d.jsx(YS,{style:j,type:N,component:E,containerStyle:w}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(xS,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:v,nodeClickDistance:ve,onlyRenderVisibleElements:G,noPanClassName:Mt,noDragClassName:it,disableKeyboardA11y:ot,nodeExtent:dt,rfId:gt,nodesDraggable:kn}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}lm.displayName="GraphView";const qS=L.memo(lm),KS=ug(),cp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:x=2,nodeOrigin:v,nodeExtent:m,zIndexMode:y="basic"}={})=>{const _=new Map,N=new Map,j=new Map,E=new Map,w=s??r??[],M=o??t??[],k=v??[0,0],b=m??Jo;_g(j,E,w);const{nodesInitialized:A}=sc(M,_,N,{nodeOrigin:k,nodeExtent:b,zIndexMode:y});let $=[0,0,1];if(c&&a&&u){const V=us(_,{filter:Z=>!!((Z.width||Z.initialWidth)&&(Z.height||Z.initialHeight))}),{x:X,y:G,zoom:J}=_c(V,a,u,p,x,(h==null?void 0:h.padding)??.1);$=[X,G,J]}return{rfId:"1",width:a??0,height:u??0,transform:$,nodes:M,nodesInitialized:A,nodeLookup:_,parentLookup:N,edges:w,edgeLookup:E,connectionLookup:j,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:x,translateExtent:Jo,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ki.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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...ng},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:KS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:tg,zIndexMode:y,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},QS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:x,nodeOrigin:v,nodeExtent:m,zIndexMode:y})=>u_((_,N)=>{async function j(){const{nodeLookup:E,panZoom:w,fitViewOptions:M,fitViewResolver:k,width:b,height:A,minZoom:$,maxZoom:V}=N();w&&(await o1({nodes:E,width:b,height:A,panZoom:w,minZoom:$,maxZoom:V},M),k==null||k.resolve(!0),_({fitViewResolver:null}))}return{...cp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:x,nodeOrigin:v,nodeExtent:m,defaultNodes:o,defaultEdges:s,zIndexMode:y}),setNodes:E=>{const{nodeLookup:w,parentLookup:M,nodeOrigin:k,nodeExtent:b,elevateNodesOnSelect:A,fitViewQueued:$,zIndexMode:V,nodesSelectionActive:X}=N(),{nodesInitialized:G,hasSelectedNodes:J}=sc(E,w,M,{nodeOrigin:k,nodeExtent:b,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:V}),Z=X&&J;$&&G?(j(),_({nodes:E,nodesInitialized:G,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:Z})):_({nodes:E,nodesInitialized:G,nodesSelectionActive:Z})},setEdges:E=>{const{connectionLookup:w,edgeLookup:M}=N();_g(w,M,E),_({edges:E})},setDefaultNodesAndEdges:(E,w)=>{if(E){const{setNodes:M}=N();M(E),_({hasDefaultNodes:!0})}if(w){const{setEdges:M}=N();M(w),_({hasDefaultEdges:!0})}},updateNodeInternals:E=>{const{triggerNodeChanges:w,nodeLookup:M,parentLookup:k,domNode:b,nodeOrigin:A,nodeExtent:$,debug:V,fitViewQueued:X,zIndexMode:G}=N(),{changes:J,updatedInternals:Z}=C1(E,M,k,b,A,$,G);Z&&(N1(M,k,{nodeOrigin:A,nodeExtent:$,zIndexMode:G}),X?(j(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(J==null?void 0:J.length)>0&&(V&&console.log("React Flow: trigger node changes",J),w==null||w(J)))},updateNodePositions:(E,w=!1)=>{const M=[];let k=[];const{nodeLookup:b,triggerNodeChanges:A,connection:$,updateConnection:V,onNodesChangeMiddlewareMap:X}=N();for(const[G,J]of E){const Z=b.get(G),re=!!(Z!=null&&Z.expandParent&&(Z!=null&&Z.parentId)&&(J!=null&&J.position)),te={id:G,type:"position",position:re?{x:Math.max(0,J.position.x),y:Math.max(0,J.position.y)}:J.position,dragging:w};if(Z&&$.inProgress&&$.fromNode.id===Z.id){const I=li(Z,$.fromHandle,Se.Left,!0);V({...$,from:I})}re&&Z.parentId&&M.push({id:G,parentId:Z.parentId,rect:{...J.internals.positionAbsolute,width:J.measured.width??0,height:J.measured.height??0}}),k.push(te)}if(M.length>0){const{parentLookup:G,nodeOrigin:J}=N(),Z=Ec(M,b,G,J);k.push(...Z)}for(const G of X.values())k=G(k);A(k)},triggerNodeChanges:E=>{const{onNodesChange:w,setNodes:M,nodes:k,hasDefaultNodes:b,debug:A}=N();if(E!=null&&E.length){if(b){const $=P_(E,k);M($)}A&&console.log("React Flow: trigger node changes",E),w==null||w(E)}},triggerEdgeChanges:E=>{const{onEdgesChange:w,setEdges:M,edges:k,hasDefaultEdges:b,debug:A}=N();if(E!=null&&E.length){if(b){const $=I_(E,k);M($)}A&&console.log("React Flow: trigger edge changes",E),w==null||w(E)}},addSelectedNodes:E=>{const{multiSelectionActive:w,edgeLookup:M,nodeLookup:k,triggerNodeChanges:b,triggerEdgeChanges:A}=N();if(w){const $=E.map(V=>Jr(V,!0));b($);return}b(Ui(k,new Set([...E]),!0)),A(Ui(M))},addSelectedEdges:E=>{const{multiSelectionActive:w,edgeLookup:M,nodeLookup:k,triggerNodeChanges:b,triggerEdgeChanges:A}=N();if(w){const $=E.map(V=>Jr(V,!0));A($);return}A(Ui(M,new Set([...E]))),b(Ui(k,new Set,!0))},unselectNodesAndEdges:({nodes:E,edges:w}={})=>{const{edges:M,nodes:k,nodeLookup:b,triggerNodeChanges:A,triggerEdgeChanges:$}=N(),V=E||k,X=w||M,G=[];for(const Z of V){if(!Z.selected)continue;const re=b.get(Z.id);re&&(re.selected=!1),G.push(Jr(Z.id,!1))}const J=[];for(const Z of X)Z.selected&&J.push(Jr(Z.id,!1));A(G),$(J)},setMinZoom:E=>{const{panZoom:w,maxZoom:M}=N();w==null||w.setScaleExtent([E,M]),_({minZoom:E})},setMaxZoom:E=>{const{panZoom:w,minZoom:M}=N();w==null||w.setScaleExtent([M,E]),_({maxZoom:E})},setTranslateExtent:E=>{var w;(w=N().panZoom)==null||w.setTranslateExtent(E),_({translateExtent:E})},resetSelectedElements:()=>{const{edges:E,nodes:w,triggerNodeChanges:M,triggerEdgeChanges:k,elementsSelectable:b}=N();if(!b)return;const A=w.reduce((V,X)=>X.selected?[...V,Jr(X.id,!1)]:V,[]),$=E.reduce((V,X)=>X.selected?[...V,Jr(X.id,!1)]:V,[]);M(A),k($)},setNodeExtent:E=>{const{nodes:w,nodeLookup:M,parentLookup:k,nodeOrigin:b,elevateNodesOnSelect:A,nodeExtent:$,zIndexMode:V}=N();E[0][0]===$[0][0]&&E[0][1]===$[0][1]&&E[1][0]===$[1][0]&&E[1][1]===$[1][1]||(sc(w,M,k,{nodeOrigin:b,nodeExtent:E,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:V}),_({nodeExtent:E}))},panBy:E=>{const{transform:w,width:M,height:k,panZoom:b,translateExtent:A}=N();return M1({delta:E,panZoom:b,transform:w,translateExtent:A,width:M,height:k})},setCenter:async(E,w,M)=>{const{width:k,height:b,maxZoom:A,panZoom:$}=N();if(!$)return!1;const V=typeof(M==null?void 0:M.zoom)<"u"?M.zoom:A;return await $.setViewport({x:k/2-E*V,y:b/2-w*V,zoom:V},{duration:M==null?void 0:M.duration,ease:M==null?void 0:M.ease,interpolate:M==null?void 0:M.interpolate}),!0},cancelConnection:()=>{_({connection:{...ng}})},updateConnection:E=>{_({connection:E})},reset:()=>_({...cp()})}},Object.is);function am({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:x,nodeOrigin:v,nodeExtent:m,zIndexMode:y,children:_}){const[N]=L.useState(()=>QS({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:x,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:v,nodeExtent:m,zIndexMode:y}));return d.jsx(c_,{value:N,children:d.jsx($_,{children:d.jsx(Q_,{children:_})})})}function ZS({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:x,maxZoom:v,nodeOrigin:m,nodeExtent:y,zIndexMode:_}){return L.useContext(Gl)?d.jsx(d.Fragment,{children:t}):d.jsx(am,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:x,initialMaxZoom:v,nodeOrigin:m,nodeExtent:y,zIndexMode:_,children:t})}const JS={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function ek({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:x,onMove:v,onMoveStart:m,onMoveEnd:y,onConnect:_,onConnectStart:N,onConnectEnd:j,onClickConnectStart:E,onClickConnectEnd:w,onNodeMouseEnter:M,onNodeMouseMove:k,onNodeMouseLeave:b,onNodeContextMenu:A,onNodeDoubleClick:$,onNodeDragStart:V,onNodeDrag:X,onNodeDragStop:G,onNodesDelete:J,onEdgesDelete:Z,onDelete:re,onSelectionChange:te,onSelectionDragStart:I,onSelectionDrag:W,onSelectionDragStop:H,onSelectionContextMenu:U,onSelectionStart:C,onSelectionEnd:D,onBeforeDelete:B,connectionMode:P,connectionLineType:z=Pr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:de,deleteKeyCode:pe="Backspace",selectionKeyCode:he="Shift",selectionOnDrag:Q=!1,selectionMode:ae=es.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:ke=rs()?"Meta":"Control",zoomActivationKeyCode:ve=rs()?"Meta":"Control",snapToGrid:ne,snapGrid:Ne,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Re,nodesDraggable:Le,autoPanOnNodeFocus:Ze,nodesConnectable:pt,nodesFocusable:Xe,nodeOrigin:it=Lg,edgesFocusable:on,edgesReconnectable:Mt,elementsSelectable:ot=!0,defaultViewport:dt=k_,minZoom:gt=.5,maxZoom:mt=2,translateExtent:Pt=Jo,preventScrolling:kn=!0,nodeExtent:sn,defaultMarkerColor:qt="#b1b1b7",zoomOnScroll:no=!0,zoomOnPinch:rr=!0,panOnScroll:ui=!1,panOnScrollSpeed:ci=.5,panOnScrollMode:ir=ni.Free,zoomOnDoubleClick:Nn=!0,panOnDrag:Nt=!0,onPaneClick:jn,onPaneMouseEnter:bn,onPaneMouseMove:It,onPaneMouseLeave:Ft,onPaneScroll:En,onPaneContextMenu:yt,paneClickDistance:Rr=1,nodeClickDistance:Ht=0,children:Tr,onReconnect:tt,onReconnectStart:He,onReconnectEnd:ln,onEdgeContextMenu:Hn,onEdgeDoubleClick:jt,onEdgeMouseEnter:Lr,onEdgeMouseMove:bt,onEdgeMouseLeave:Cn,reconnectRadius:Kt=10,onNodesChange:Bn,onEdgesChange:di,noDragClassName:ro="nodrag",noWheelClassName:Bt="nowheel",noPanClassName:Rt="nopan",fitView:or,fitViewOptions:an,connectOnClick:Ar,attributionPosition:fi,proOptions:hi,defaultEdgeOptions:pi,elevateNodesOnSelect:gi=!0,elevateEdgesOnSelect:io=!1,disableKeyboardA11y:mi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:$r,autoPanOnSelection:zr=!0,autoPanSpeed:sr,connectionRadius:lr,isValidConnection:oo,onError:ar,style:Mn,id:vt,nodeDragThreshold:yi,connectionDragThreshold:xt,viewport:Dr,onViewportChange:vi,width:xi,height:Vn,colorMode:Pn="light",debug:Wn,onScroll:Qt,ariaLabelConfig:so,zIndexMode:wi="basic",...Or},Fr){const In=vt||"1",Rn=E_(Pn),_i=L.useCallback(Un=>{Un.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Qt==null||Qt(Un)},[Qt]);return d.jsx("div",{"data-testid":"rf__wrapper",...Or,onScroll:_i,style:{...Mn,...JS},ref:Fr,className:rt(["react-flow",a,Rn]),id:vt,role:"application",children:d.jsxs(ZS,{nodes:t,edges:r,width:xi,height:Vn,fitView:or,fitViewOptions:an,minZoom:gt,maxZoom:mt,nodeOrigin:it,nodeExtent:sn,zIndexMode:wi,children:[d.jsx(b_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:N,onConnectEnd:j,onClickConnectStart:E,onClickConnectEnd:w,nodesDraggable:Le,autoPanOnNodeFocus:Ze,nodesConnectable:pt,nodesFocusable:Xe,edgesFocusable:on,edgesReconnectable:Mt,elementsSelectable:ot,elevateNodesOnSelect:gi,elevateEdgesOnSelect:io,minZoom:gt,maxZoom:mt,nodeExtent:sn,onNodesChange:Bn,onEdgesChange:di,snapToGrid:ne,snapGrid:Ne,connectionMode:P,translateExtent:Pt,connectOnClick:Ar,defaultEdgeOptions:pi,fitView:or,fitViewOptions:an,onNodesDelete:J,onEdgesDelete:Z,onDelete:re,onNodeDragStart:V,onNodeDrag:X,onNodeDragStop:G,onSelectionDrag:W,onSelectionDragStart:I,onSelectionDragStop:H,onMove:v,onMoveStart:m,onMoveEnd:y,noPanClassName:Rt,nodeOrigin:it,rfId:In,autoPanOnConnect:Ve,autoPanOnNodeDrag:$r,autoPanSpeed:sr,onError:ar,connectionRadius:lr,isValidConnection:oo,selectNodesOnDrag:Re,nodeDragThreshold:yi,connectionDragThreshold:xt,onBeforeDelete:B,debug:Wn,ariaLabelConfig:so,zIndexMode:wi}),d.jsx(qS,{onInit:x,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:M,onNodeMouseMove:k,onNodeMouseLeave:b,onNodeContextMenu:A,onNodeDoubleClick:$,nodeTypes:u,edgeTypes:c,connectionLineType:z,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:de,selectionKeyCode:he,selectionOnDrag:Q,selectionMode:ae,deleteKeyCode:pe,multiSelectionKeyCode:ke,panActivationKeyCode:me,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:dt,translateExtent:Pt,minZoom:gt,maxZoom:mt,preventScrolling:kn,zoomOnScroll:no,zoomOnPinch:rr,zoomOnDoubleClick:Nn,panOnScroll:ui,panOnScrollSpeed:ci,panOnScrollMode:ir,panOnDrag:Nt,autoPanOnSelection:zr,onPaneClick:jn,onPaneMouseEnter:bn,onPaneMouseMove:It,onPaneMouseLeave:Ft,onPaneScroll:En,onPaneContextMenu:yt,paneClickDistance:Rr,nodeClickDistance:Ht,onSelectionContextMenu:U,onSelectionStart:C,onSelectionEnd:D,onReconnect:tt,onReconnectStart:He,onReconnectEnd:ln,onEdgeContextMenu:Hn,onEdgeDoubleClick:jt,onEdgeMouseEnter:Lr,onEdgeMouseMove:bt,onEdgeMouseLeave:Cn,reconnectRadius:Kt,defaultMarkerColor:qt,noDragClassName:ro,noWheelClassName:Bt,noPanClassName:Rt,rfId:In,disableKeyboardA11y:mi,nodeExtent:sn,viewport:Dr,onViewportChange:vi,nodesDraggable:Le}),d.jsx(S_,{onSelectionChange:te}),Tr,d.jsx(y_,{proOptions:hi,position:fi}),d.jsx(m_,{rfId:In,disableKeyboardA11y:mi})]})})}var tk=$g(ek);function nk({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:rt(["react-flow__background-pattern",o,s])})}function rk({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:rt(["react-flow__background-pattern","dots",r])})}var Ir;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Ir||(Ir={}));const ik={[Ir.Dots]:1,[Ir.Lines]:1,[Ir.Cross]:6},ok=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function um({id:t,variant:r=Ir.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:x,patternClassName:v}){const m=L.useRef(null),{transform:y,patternId:_}=ze(ok,Qe),N=s||ik[r],j=r===Ir.Dots,E=r===Ir.Cross,w=Array.isArray(o)?o:[o,o],M=[w[0]*y[2]||1,w[1]*y[2]||1],k=N*y[2],b=Array.isArray(u)?u:[u,u],A=E?[k,k]:M,$=[b[0]*y[2]+A[0]/2,b[1]*y[2]+A[1]/2],V=`${_}${t||""}`;return d.jsxs("svg",{className:rt(["react-flow__background",x]),style:{...p,...Kl,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:m,"data-testid":"rf__background",children:[d.jsx("pattern",{id:V,x:y[0]%M[0],y:y[1]%M[1],width:M[0],height:M[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:j?d.jsx(rk,{radius:k/2,className:v}):d.jsx(nk,{dimensions:A,lineWidth:a,variant:r,className:v})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${V})`})]})}um.displayName="Background";const sk=L.memo(um);function lk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ak(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function uk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 ck(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 wl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:rt(["react-flow__controls-button",r]),...o,children:t})}const fk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function cm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:x,children:v,position:m="bottom-left",orientation:y="vertical","aria-label":_}){const N=Ye(),{isInteractive:j,minZoomReached:E,maxZoomReached:w,ariaLabelConfig:M}=ze(fk,Qe),{zoomIn:k,zoomOut:b,fitView:A}=ql(),$=()=>{k(),u==null||u()},V=()=>{b(),c==null||c()},X=()=>{A(a),h==null||h()},G=()=>{N.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),p==null||p(!j)},J=y==="horizontal"?"horizontal":"vertical";return d.jsxs(Xl,{className:rt(["react-flow__controls",J,x]),position:m,style:t,"data-testid":"rf__controls","aria-label":_??M["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(wl,{onClick:$,className:"react-flow__controls-zoomin",title:M["controls.zoomIn.ariaLabel"],"aria-label":M["controls.zoomIn.ariaLabel"],disabled:w,children:d.jsx(lk,{})}),d.jsx(wl,{onClick:V,className:"react-flow__controls-zoomout",title:M["controls.zoomOut.ariaLabel"],"aria-label":M["controls.zoomOut.ariaLabel"],disabled:E,children:d.jsx(ak,{})})]}),o&&d.jsx(wl,{className:"react-flow__controls-fitview",onClick:X,title:M["controls.fitView.ariaLabel"],"aria-label":M["controls.fitView.ariaLabel"],children:d.jsx(uk,{})}),s&&d.jsx(wl,{className:"react-flow__controls-interactive",onClick:G,title:M["controls.interactive.ariaLabel"],"aria-label":M["controls.interactive.ariaLabel"],children:j?d.jsx(dk,{}):d.jsx(ck,{})}),v]})}cm.displayName="Controls";const hk=L.memo(cm);function pk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:x,borderRadius:v,shapeRendering:m,selected:y,onClick:_}){const{background:N,backgroundColor:j}=u||{},E=c||N||j;return d.jsx("rect",{className:rt(["react-flow__minimap-node",{selected:y},x]),x:r,y:o,rx:v,ry:v,width:s,height:a,style:{fill:E,stroke:h,strokeWidth:p},shapeRendering:m,onClick:_?w=>_(w,t):void 0})}const gk=L.memo(pk),mk=t=>t.nodes.map(r=>r.id),Wu=t=>t instanceof Function?t:()=>t;function yk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=gk,onClick:c}){const h=ze(mk,Qe),p=Wu(r),x=Wu(t),v=Wu(o),m=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(y=>d.jsx(xk,{id:y,nodeColorFunc:p,nodeStrokeColorFunc:x,nodeClassNameFunc:v,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:m},y))})}function vk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:x,x:v,y:m,width:y,height:_}=ze(N=>{const j=N.nodeLookup.get(t);if(!j)return{node:void 0,x:0,y:0,width:0,height:0};const E=j.internals.userNode,{x:w,y:M}=j.internals.positionAbsolute,{width:k,height:b}=Sn(E);return{node:E,x:w,y:M,width:k,height:b}},Qe);return!x||x.hidden||!cg(x)?null:d.jsx(h,{x:v,y:m,width:y,height:_,style:x.style,selected:!!x.selected,className:s(x),color:r(x),borderRadius:a,strokeColor:o(x),strokeWidth:u,shapeRendering:c,onClick:p,id:x.id})}const xk=L.memo(vk);var wk=L.memo(yk);const _k=200,Sk=150,kk=t=>!t.hidden,Nk=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?lg(us(t.nodeLookup,{filter:kk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},dp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,jk=(t,r)=>dp(t.viewBB,r.viewBB)&&dp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,bk="react-flow__minimap-desc";function dm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:x,maskStrokeColor:v,maskStrokeWidth:m,position:y="bottom-right",onClick:_,onNodeClick:N,pannable:j=!1,zoomable:E=!1,ariaLabel:w,inversePan:M,zoomStep:k=1,offsetScale:b=5}){const A=Ye(),$=L.useRef(null),{boundingRect:V,viewBB:X,rfId:G,panZoom:J,translateExtent:Z,flowWidth:re,flowHeight:te,ariaLabelConfig:I}=ze(Nk,jk),W=(t==null?void 0:t.width)??_k,H=(t==null?void 0:t.height)??Sk,U=V.width/W,C=V.height/H,D=Math.max(U,C),B=D*W,P=D*H,z=b*D,ie=V.x-(B-V.width)/2-z,oe=V.y-(P-V.height)/2-z,de=B+z*2,pe=P+z*2,he=`${bk}-${G}`,Q=L.useRef(0),ae=L.useRef();Q.current=D,L.useEffect(()=>{if($.current&&J)return ae.current=D1({domNode:$.current,panZoom:J,getTransform:()=>A.getState().transform,getViewScale:()=>Q.current}),()=>{var ne;(ne=ae.current)==null||ne.destroy()}},[J]),L.useEffect(()=>{var ne;(ne=ae.current)==null||ne.update({translateExtent:Z,width:re,height:te,inversePan:M,pannable:j,zoomStep:k,zoomable:E})},[j,E,M,k,Z,re,te]);const me=_?ne=>{var Re;const[Ne,Me]=((Re=ae.current)==null?void 0:Re.pointer(ne))||[0,0];_(ne,{x:Ne,y:Me})}:void 0,ke=N?L.useCallback((ne,Ne)=>{const Me=A.getState().nodeLookup.get(Ne).internals.userNode;N(ne,Me)},[]):void 0,ve=w??I["minimap.ariaLabel"];return d.jsx(Xl,{position:y,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-color-props":typeof v=="string"?v:void 0,"--xy-minimap-mask-stroke-width-props":typeof m=="number"?m*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:rt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:W,height:H,viewBox:`${ie} ${oe} ${de} ${pe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":he,ref:$,onClick:me,children:[ve&&d.jsx("title",{id:he,children:ve}),d.jsx(wk,{onClick:ke,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-z},${oe-z}h${de+z*2}v${pe+z*2}h${-de-z*2}z + M${X.x},${X.y}h${X.width}v${X.height}h${-X.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}dm.displayName="MiniMap";const Ek=L.memo(dm),Ck=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Mk={[Ji.Line]:"right",[Ji.Handle]:"bottom-right"};function Pk({nodeId:t,position:r,variant:o=Ji.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:x=Number.MAX_VALUE,maxHeight:v=Number.MAX_VALUE,keepAspectRatio:m=!1,resizeDirection:y,autoScale:_=!0,shouldResize:N,onResizeStart:j,onResize:E,onResizeEnd:w}){const M=Hg(),k=typeof t=="string"?t:M,b=Ye(),A=L.useRef(null),$=o===Ji.Handle,V=ze(L.useCallback(Ck($&&_),[$,_]),Qe),X=L.useRef(null),G=r??Mk[o];L.useEffect(()=>{if(!(!A.current||!k))return X.current||(X.current=Q1({domNode:A.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:Z,transform:re,snapGrid:te,snapToGrid:I,nodeOrigin:W,domNode:H}=b.getState();return{nodeLookup:Z,transform:re,snapGrid:te,snapToGrid:I,nodeOrigin:W,paneDomNode:H}},onChange:(Z,re)=>{const{triggerNodeChanges:te,nodeLookup:I,parentLookup:W,nodeOrigin:H}=b.getState(),U=[],C={x:Z.x,y:Z.y},D=I.get(k);if(D&&D.expandParent&&D.parentId){const B=D.origin??H,P=Z.width??D.measured.width??0,z=Z.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:P,height:z,...dg({x:Z.x??D.position.x,y:Z.y??D.position.y},{width:P,height:z},D.parentId,I,B)}},oe=Ec([ie],I,W,H);U.push(...oe),C.x=Z.x?Math.max(B[0]*P,Z.x):void 0,C.y=Z.y?Math.max(B[1]*z,Z.y):void 0}if(C.x!==void 0&&C.y!==void 0){const B={id:k,type:"position",position:{...C}};U.push(B)}if(Z.width!==void 0&&Z.height!==void 0){const P={id:k,type:"dimensions",resizing:!0,setAttributes:y?y==="horizontal"?"width":"height":!0,dimensions:{width:Z.width,height:Z.height}};U.push(P)}for(const B of re){const P={...B,type:"position"};U.push(P)}te(U)},onEnd:({width:Z,height:re})=>{const te={id:k,type:"dimensions",resizing:!1,dimensions:{width:Z,height:re}};b.getState().triggerNodeChanges([te])}})),X.current.update({controlPosition:G,boundaries:{minWidth:h,minHeight:p,maxWidth:x,maxHeight:v},keepAspectRatio:m,resizeDirection:y,onResizeStart:j,onResize:E,onResizeEnd:w,shouldResize:N}),()=>{var Z;(Z=X.current)==null||Z.destroy()}},[G,h,p,x,v,m,j,E,w,N]);const J=G.split("-");return d.jsx("div",{className:rt(["react-flow__resize-control","nodrag",...J,o,s]),ref:A,style:{...a,scale:V,...c&&{[$?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Pk);const Ik={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function Zl(t){return Ik[t]??8}const uc=208,cc=64,Rk=88,Tk=28,Lk=8;function Ak(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function $k(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const w of t){const M=Zl(w.type),k=s.get(M)??[];k.push(w),s.set(M,k)}const u=[...s.keys()].sort((w,M)=>w-M).map(w=>[...s.get(w)??[]].sort((M,k)=>M.name.localeCompare(k.name)||M.id.localeCompare(k.id))),c=new Set(t.map(w=>w.id)),h=new Map,p=new Map;for(const w of t)h.set(w.id,[]),p.set(w.id,[]);for(const w of r)!c.has(w.src)||!c.has(w.dst)||w.src===w.dst||(p.get(w.src).push(w.dst),h.get(w.dst).push(w.src));const x=new Map;u.forEach((w,M)=>{for(const k of w)x.set(k.id,M)});const v=new Map,m=()=>{for(const w of u)w.forEach((M,k)=>v.set(M.id,k))};m();const y=(w,M)=>{const k=w.map((b,A)=>{const $=M(b.id).map(X=>v.get(X)).filter(X=>X!==void 0),V=Ak($);return{n:b,bary:Number.isNaN(V)?A:V,name:b.name,id:b.id}});return k.sort((b,A)=>b.bary-A.bary||b.name.localeCompare(A.name)||b.id.localeCompare(A.id)),k.map(b=>b.n)},_=w=>M=>x.get(M)===w;for(let w=0;w(h.get(k)??[]).filter(_(M-1))),m();for(let M=u.length-2;M>=0;M--)u[M]=y(u[M],k=>(p.get(k)??[]).filter(_(M+1))),m()}const N=uc+Rk,j=cc+Tk,E=Math.max(...u.map(w=>w.length),1);return u.forEach((w,M)=>{const k=(E-w.length)*j/2;w.forEach((b,A)=>{o.set(b.id,{x:M*N,y:k+A*j})})}),o}const zk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),fm=90,Dk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),fp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Ok=Math.PI*(3-Math.sqrt(5)),hm=220,Fk=26,Hk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function pm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function PN(t){return fp[t]?fp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Bk(t){return t>=fm?"3d":"2d"}function Vk(t){return t>=fm?"overview":"full"}function Wk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(pm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Dk.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Wk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Yk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function Gk(t,r,o,s){const a=new Set(t.map(j=>j.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const j of r){if(!a.has(j.src)||!a.has(j.dst))continue;const E=u.get(j.src)??[];E.push({dst:j.dst,id:j.id}),u.set(j.src,E);const w=c.get(j.dst)??[];w.push({src:j.src,id:j.id}),c.set(j.dst,w)}const h=new Set(t.filter(j=>zk.has(j.type)).map(j=>j.id)),p=h.size?h:a,x=new Set,v=[o];for(;v.length;){const j=v.pop();if(!x.has(j)){x.add(j);for(const E of u.get(j)??[])x.has(E.dst)||v.push(E.dst)}}const m=new Set([o]),y=[...p].filter(j=>x.has(j)),_=new Set(y);for(;y.length;){const j=y.pop();m.add(j);for(const E of c.get(j)??[])x.has(E.src)&&!_.has(E.src)&&(_.add(E.src),y.push(E.src))}const N=new Set;for(const j of r)m.has(j.src)&&m.has(j.dst)&&N.add(j.id);return{nodeIds:m,edgeIds:N}}function IN(t){const r=new Map;for(const s of t){const a=Zl(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*hm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Fk*Math.sqrt(h+1),x=h*Ok;o.set(c.id,{x:u,y:p*Math.cos(x),z:p*Math.sin(x)})})}return o}function RN(t){const r=new Map;for(const o of t){const s=Zl(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*hm,count:s}))}const _l=16,Xk=12,qk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Kk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),hp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Qk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},pp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],gp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Zk=new Set(["looks_idempotent_on_pk","null","blank"]),Jk=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function eN(t){return hp[t]?hp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function tN(t,r,o){const s=new Map(r.map(y=>[y.id,y])),a=[];qk.has(t.type)&&a.push("sink"),Kk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(y=>y.dst===t.id),h=o.filter(y=>y.src===t.id),p=c.slice(0,_l).map(y=>Sl(y,s,y.src)),x=h.slice(0,_l).map(y=>Sl(y,s,y.dst)),v=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,m={type:t.type,typeLabel:Xo(to(t.type)),layer:Hk[Zl(t.type)]??"other",purpose:eN(t.type),name:t.name,qualifiedName:t.qualified_name,file:v,context:t.context,roles:a,facts:rN(u).filter(y=>!(y.key==="app"&&y.value===t.context)),inputs:p,outputs:x,extraInputs:Math.max(0,c.length-_l),extraOutputs:Math.max(0,h.length-_l),degreeIn:c.length,degreeOut:h.length,inputKinds:mp(c.map(y=>Sl(y,s,y.src))),outputKinds:mp(h.map(y=>Sl(y,s,y.dst))),pathSummary:""};return m.pathSummary=nN(m),m}function mp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function nN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function Sl(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Xo(to(s.type)):"",edgeType:t.type,edgeLabel:Xo(t.type),inferred:t.confidence<.8}}function rN(t){const r=[...pp.filter(a=>a in t),...Object.keys(t).filter(a=>!pp.includes(a)&&!gp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||gp.has(a)||Jk.has(a))continue;s.add(a);const u=iN(a,t[a]);u!=null&&o.push({key:a,label:Qk[a]??Xo(a),value:u})}return o}function iN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Zk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return oN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Xk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function oN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const sN=new Set,lN=L.lazy(()=>_0(()=>import("./LayeredGraph3D-B-dkkPpV.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),aN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function uN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(eo,{type:"target",position:Se.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:to(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Mr(t.name)}),d.jsx(eo,{type:"source",position:Se.Right,isConnectable:!1})]})}const cN={load:uN},dN=new Set(["django","react","stitch","arch"]);function fN({topologyKey:t}){const{fitView:r}=ql();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function hN(t,r,o=null,s={}){const a=new Map(t.map(p=>[p.id,p])),u=$k(t,r),c=t.map(p=>{var m;const x=((m=s.roles)==null?void 0:m[p.id])||[],v=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:p.id,type:"load",position:u.get(p.id)??{x:0,y:0},data:{name:p.name,type:p.type,file:p.file_path,roles:x,dim:v},selected:o===p.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:uc,height:cc,style:{width:uc,height:cc}}}),h=r.filter(p=>a.has(p.src)&&a.has(p.dst)).map(p=>{const x=aN[p.weight]||"var(--edge-cheap)",v=!!(o&&(p.src===o||p.dst===o));return{id:p.id,source:p.src,target:p.dst,type:"smoothstep",animated:p.weight==="critical",style:{stroke:x,strokeWidth:p.weight==="critical"?2.4:1.2,strokeDasharray:p.confidence<.8?"6 4":void 0},markerEnd:{type:ts.ArrowClosed,width:14,height:14,color:x},label:v?p.type.replaceAll("_"," "):void 0,labelStyle:v?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:v?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:v?[3,5]:void 0,labelBgBorderRadius:v?4:void 0}});return{rfNodes:c,rfEdges:h}}function pN({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:x}){const v=tN(t,r,o);return L.useEffect(()=>{const m=y=>{y.key==="Escape"&&s()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:v.typeLabel}),d.jsx("div",{className:"inspector-roles",children:v.roles.map(m=>d.jsx("span",{className:"inspector-chip",children:m},m))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Mr(v.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:v.purpose}),v.context?d.jsx("div",{className:"muted",children:Mr(v.context)}):null,v.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Mr(v.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Mr(v.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",v.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[v.degreeIn," in · ",v.degreeOut," out"]}),v.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:v.pathSummary}):null,v.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:v.facts.map(m=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:m.label}),d.jsx("dd",{children:Mr(m.value)})]},m.key))}):null,d.jsx(yp,{title:"Inputs",testId:"graph-inspector-inputs",links:v.inputs,extra:v.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(yp,{title:"Outputs",testId:"graph-inspector-outputs",links:v.outputs,extra:v.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",onClick:()=>a(t.id),children:"What if this changes"}):null,x?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",onClick:()=>x(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function yp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Mr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Mr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Uu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:x,repoPath:v,onOpenFile:m,pinnedId:y,onPin:_}){const[N,j]=L.useState(null),E=a!==void 0?a:N,w=ne=>{a===void 0&&j(ne),u==null||u(ne)},[M,k]=L.useState(null),[b,A]=L.useState(null),[$,V]=L.useState(new Set(dN)),[X,G]=L.useState(!1),[J,Z]=L.useState(""),[re,te]=L.useState(!1),I=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,W=M??Bk(t.length),H=b??Vk(t.length),U=X?E:null,C=L.useMemo(()=>p?Gk(t,r,p):null,[t,r,p]),D=C?t.filter(ne=>C.nodeIds.has(ne.id)):t,B=C?r.filter(ne=>C.edgeIds.has(ne.id)):r,P=L.useMemo(()=>Uk(D,B,{detail:H,families:$,focusId:U,neighborhoodOnly:!!U}),[D,B,H,$,U]),z=L.useMemo(()=>`${P.nodes.map(ne=>ne.id).join("\0")}|${P.edges.map(ne=>ne.id).join("\0")}`,[P.nodes,P.edges]),ie=E?t.find(ne=>ne.id===E)??null:null,{rfNodes:oe,rfEdges:de}=L.useMemo(()=>{const ne=hN(P.nodes,P.edges,E,{roles:c,testOverlay:h});return I&&(ne.rfEdges=ne.rfEdges.map(Ne=>({...Ne,animated:!1}))),ne},[P.nodes,P.edges,E,I,c,h]);L.useEffect(()=>{if(!s)return;const ne=t.find(Ne=>Ne.file_path===s);ne&&w(ne.id)},[s,t]);const pe=L.useMemo(()=>Yk(t,J),[t,J]),he=(ne,Ne)=>{w(Ne.id)},Q=()=>{w(null),G(!1)},ae=ie?d.jsx(pN,{node:ie,nodes:t,edges:r,onClose:Q,onWhatIf:o,onSelect:w,onOpenFile:m,pinned:y===ie.id,onPin:_,onIsolate:x?ne=>{x(p===ne?null:ne)}:void 0}):null,me=ne=>{V(Ne=>{const Me=new Set(Ne);if(Me.has(ne)){if(Me.size===1)return Ne;Me.delete(ne)}else Me.add(ne);return Me})},ke=L.useMemo(()=>{const ne=new Set;for(const Ne of t)ne.add(pm(Ne.type));return ne},[t]),ve=t.length-P.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:W==="2d"?"active":"","aria-pressed":W==="2d",onClick:()=>k("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:W==="3d"?"active":"","aria-pressed":W==="3d",onClick:()=>k("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:H==="overview"?"active":"","aria-pressed":H==="overview",onClick:()=>A("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:H==="full"?"active":"","aria-pressed":H==="full",onClick:()=>A("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(ne=>ke.has(ne)).map(ne=>d.jsx("button",{type:"button","data-testid":`graph-family-${ne}`,className:$.has(ne)?"active":"","aria-pressed":$.has(ne),onClick:()=>me(ne),children:ne},ne))}),d.jsx("button",{type:"button",className:X?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!E,onClick:()=>G(ne=>!ne),children:X?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>x==null?void 0:x(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:J,onChange:ne=>{Z(ne.target.value),te(!0)},onFocus:()=>te(!0),onBlur:()=>window.setTimeout(()=>te(!1),150)}),re&&J.trim()&&pe.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:pe.map(ne=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:Ne=>Ne.preventDefault(),onClick:()=>{w(ne.id),Z(""),te(!1)},children:[ne.name,d.jsx("span",{className:"muted",children:to(ne.type)})]})},ne.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[P.nodes.length," nodes · ",P.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:W==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(lN,{nodes:P.nodes,edges:P.edges,selectedId:E,neighborIds:U?P.neighborIds:sN,onSelect:ne=>{w(ne),ne||G(!1)}})}),ae]}):d.jsxs(am,{children:[d.jsxs(tk,{nodes:oe,edges:de,nodeTypes:cN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:he,onPaneClick:Q,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(fN,{topologyKey:z}),d.jsx(sk,{}),d.jsx(Ek,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(hk,{})]}),ae]})})]})}function gm(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function gN(t){localStorage.setItem("loadpath.editor",t)}async function mN(t,r,o,s=gm()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const vp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],yN=["preset","branch","tag","commit"];function vN(t){var a;if(!(t!=null&&t.git))return[...vp];const r=((a=t.presets)!=null&&a.length?t.presets:vp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function xN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function wN(t){return yN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function _N(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function xp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[x,v]=L.useState(!1),[m,y]=L.useState(null),[_,N]=L.useState(0),j=L.useMemo(()=>{const b=vN(u);return m===null?b:xN(b,m)},[u,m]),E=L.useMemo(()=>wN(j),[j]);L.useEffect(()=>{x&&c()},[x,c]),L.useEffect(()=>{N(0)},[m,x]);const w=()=>{v(!1),y(null)},M=b=>{r(b.value),w()},k=b=>{if(b.key==="ArrowDown"){if(b.preventDefault(),!x){v(!0);return}N(A=>Math.min(A+1,Math.max(j.length-1,0)))}else if(b.key==="ArrowUp"){if(b.preventDefault(),!x)return;N(A=>Math.max(A-1,0))}else if(b.key==="Enter"&&x){b.preventDefault();const A=j[_];A&&M(A)}else b.key==="Escape"&&x&&(b.preventDefault(),w())};return d.jsxs("div",{className:"combo",ref:p,onBlur:b=>{b.currentTarget.contains(b.relatedTarget)||w()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":x,"aria-controls":h,"aria-autocomplete":"list",onChange:b=>{r(b.target.value),x&&y(b.target.value)},onKeyDown:k}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":x,onMouseDown:b=>b.preventDefault(),onClick:()=>x?w():v(!0),children:d.jsx(v0,{})})]}),x?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:E.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):E.map(b=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:_N(b.group)}),b.items.map(A=>{const $=j.indexOf(A);return d.jsxs("button",{type:"button",role:"option","aria-selected":$===_,className:$===_?"combo-option active":"combo-option","data-testid":`ref-option-${A.group}`,onMouseDown:V=>V.preventDefault(),onMouseEnter:()=>N($),onClick:()=>M(A),children:[d.jsx("span",{className:"combo-label",children:A.label}),A.detail?d.jsx("span",{className:"combo-detail",children:A.detail}):null]},`${A.group}:${A.value}`)})]},b.group))}):null]})}function SN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[x,v]=L.useState(""),[m,y]=L.useState(!1),_=L.useRef(null),N=L.useRef(0),j=async k=>{const b=N.current+1;N.current=b,y(!0);try{const A=await Pe.browse(k);if(N.current!==b)return;a(A),c(A.path),p(A.is_git?A.path:null),v("")}catch(A){if(N.current!==b)return;v(A instanceof Error?A.message:String(A))}finally{N.current===b&&y(!1)}};L.useEffect(()=>{var k,b;j(t),(k=_.current)==null||k.focus(),(b=_.current)==null||b.select()},[t]);const E=h||(s==null?void 0:s.path)||u,w=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",M=k=>{k.key==="Escape"&&(k.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:M,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:k=>k.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:k=>{k.preventDefault(),j(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:k=>c(k.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),x?d.jsx("div",{className:"error",role:"alert",children:x}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":m,children:s!=null&&s.entries.length?s.entries.map(k=>{const b=h===k.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":b,className:b?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":k.path,onClick:()=>p(k.path),onDoubleClick:()=>void j(k.path),children:[d.jsx(kp,{}),d.jsx("span",{className:"explorer-name",children:k.name}),k.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},k.path)}):d.jsx("div",{className:"muted explorer-empty",children:m?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:E,children:E}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!E,onClick:()=>E&&r(E),children:["Use ",w]})]})]})})}const Dl=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],kN="obsidian",mm="loadpath.theme";function NN(t){return Dl.some(r=>r.id===t)}function ym(){try{const t=localStorage.getItem(mm)||"";if(NN(t))return t}catch{}return kN}function jN(t){var r;return((r=Dl.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function vm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=jN(t);try{localStorage.setItem(mm,t)}catch{}}const Yu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:h0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:p0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:g0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:m0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:y0}];function bN(t){const r=t.total||0;return r<=0?null:Math.min(100,Math.round(100*(t.done||0)/r))}function Gu(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function EN(){var Fr,In,Rn,_i,Un,De,lo,ao;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,x]=L.useState(null),[v,m]=L.useState(null),[y,_]=L.useState([]),[N,j]=L.useState("review"),[E,w]=L.useState(""),[M,k]=L.useState(""),[b,A]=L.useState(null),[$,V]=L.useState(!1),[X,G]=L.useState(""),[J,Z]=L.useState({}),[re,te]=L.useState([]),[I,W]=L.useState([]),[H,U]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[C,D]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[B,P]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[z,ie]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[oe,de]=L.useState(0),[pe,he]=L.useState(""),[Q,ae]=L.useState(ym),[me,ke]=L.useState(!1),[ve,ne]=L.useState(!1),[Ne,Me]=L.useState(!1),[Re,Le]=L.useState(null),[Ze,pt]=L.useState(null),[Xe,it]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[on,Mt]=L.useState(null),[ot,dt]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[gt,mt]=L.useState([]),[Pt,kn]=L.useState(null),[sn,qt]=L.useState(null),[no,rr]=L.useState(null),[ui,ci]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[ir,Nn]=L.useState(null),[Nt,jn]=L.useState(null),[bn,It]=L.useState(!1),[Ft,En]=L.useState(!1),yt=L.useRef(o);yt.current=o;const Rr=L.useRef(!1);Rr.current=ve;const Ht=L.useRef(""),Tr=R=>{ae(R),vm(R)},tt=L.useRef(""),He=R=>{tt.current=R,k(R)},ln=R=>{const Y=()=>{Pe.indexProgress(R).then(Ee=>{tt.current&&(Ee.phase&&Ee.phase!=="idle"&&Ee.message&&He(Ee.message),A(Ee.phase&&Ee.phase!=="idle"?bN(Ee):null))}).catch(()=>{})};Y();const fe=window.setInterval(Y,250);return()=>{window.clearInterval(fe),A(null)}};L.useEffect(()=>{Pe.settings().then(Z).catch(()=>{}).finally(()=>ke(!0)),Pe.repos().then(R=>_(R.repos)).catch(()=>{})},[]);const Hn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const R=o;let Y=!1;return Pe.architecture(R).then(fe=>{!Y&&yt.current===R&&m(fe)}).catch(()=>{}),Pe.config(R).then(fe=>{!Y&&yt.current===R&&qt(fe)}).catch(()=>{}),Pe.architectureHealth(R).then(fe=>{!Y&&yt.current===R&&rr(fe)}).catch(()=>{}),()=>{Y=!0}},[t,o]);const jt=R=>{yt.current=R,s(R),localStorage.setItem("loadpath.repo",R),R.trim()!==Ht.current&&(Ht.current="",Nn(null))},Lr=L.useCallback(R=>{const Y=(R??yt.current).trim();return!Y||Ht.current===Y?Promise.resolve():(Ht.current=Y,Pe.gitRefs(Y).then(fe=>{yt.current.trim()===Y&&Nn(fe)}).catch(()=>{Ht.current===Y&&(Ht.current="",Nn(null))}))},[]),bt=(R,Y)=>{u(R),h(Y),localStorage.setItem("loadpath.base",R),localStorage.setItem("loadpath.head",Y)},Cn=(R,Y,fe)=>{D(R),U(Y),localStorage.setItem("loadpath.provider",R),localStorage.setItem("loadpath.scmRepo",Y),fe!==void 0&&(P(fe),localStorage.setItem("loadpath.prNumber",fe))},Kt=R=>{x(R),de(0),Le(Ze&&R.nodes.some(Y=>Y.id===Ze)?Ze:null),Mt(null),kn(null),R.id&&!R.what_if&&localStorage.setItem("loadpath.lastReviewId",R.id)},Bn=async R=>{try{const Y=await Pe.reviews(R);mt(Y.reviews)}catch{mt([])}},di=async R=>{try{rr(await Pe.architectureHealth(R))}catch{rr(null)}},ro=R=>R==="github"?!!J.github_token_set:R==="gitlab"?!!J.gitlab_token_set:!!J.bitbucket_token_set,Bt=L.useCallback(async(R=C)=>{var Y;try{const fe=await Pe.scmRepos(R);W(fe.repos),(Y=fe.user)!=null&&Y.login&&Z(Ee=>({...Ee,...R==="github"?{github_user:fe.user.login}:R==="gitlab"?{gitlab_user:fe.user.login}:{bitbucket_user:fe.user.login}}))}catch{W([])}},[C]);L.useEffect(()=>{if(t!=="prs")return;let R=!1;return Bt(C).catch(()=>{R||W([])}),()=>{R=!0}},[t,C,Bt]),L.useEffect(()=>{if(!Nt)return;let R=!1,Y=0;const fe=async()=>{try{const Ee=await Pe.githubOAuthPoll(Nt.flow_id);if(R)return;if(Ee.status==="complete"){jn(null);const Ae=await Pe.settings();Z(Ae),G(Ee.user?`Signed in to GitHub as ${Ee.user}`:"Signed in to GitHub"),Bt("github");return}if(Ee.status==="pending"||Ee.status==="slow_down"){Y=window.setTimeout(fe,Math.max(Ee.interval||Nt.interval,5)*1e3);return}jn(null),w(Ee.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(Ee){if(R)return;jn(null),w(Ee instanceof Error?Ee.message:String(Ee))}};return Y=window.setTimeout(fe,Math.max(Nt.interval,5)*1e3),()=>{R=!0,window.clearTimeout(Y)}},[Nt,Bt]),L.useEffect(()=>{if(!bn)return;let R=!1,Y=0;const fe=Date.now(),Ee=async()=>{try{const Ae=await Pe.oauthStatus();if(R)return;if(Ae.bitbucket.connected){It(!1);const Fe=await Pe.settings();Z(Fe),G(Ae.bitbucket.user?`Signed in to Bitbucket as ${Ae.bitbucket.user}`:"Signed in to Bitbucket"),Bt("bitbucket");return}if(Date.now()-fe>18e4){It(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(Ee,1500)}catch(Ae){if(R)return;It(!1),w(Ae instanceof Error?Ae.message:String(Ae))}};return Y=window.setTimeout(Ee,1500),()=>{R=!0,window.clearTimeout(Y)}},[bn,Bt]),L.useEffect(()=>{if(!Ft)return;let R=!1,Y=0;const fe=Date.now(),Ee=async()=>{try{const Ae=await Pe.oauthStatus();if(R)return;if(Ae.gitlab.connected){En(!1);const Fe=await Pe.settings();Z(Fe),G(Ae.gitlab.user?`Signed in to GitLab as ${Ae.gitlab.user}`:"Signed in to GitLab"),Bt("gitlab");return}if(Date.now()-fe>18e4){En(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(Ee,1500)}catch(Ae){if(R)return;En(!1),w(Ae instanceof Error?Ae.message:String(Ae))}};return Y=window.setTimeout(Ee,1500),()=>{R=!0,window.clearTimeout(Y)}},[Ft,Bt]);const Rt=async(R=o)=>{if(!R.trim())return null;const Y=await Pe.architecture(R);return yt.current===R&&m(Y),Y},or=async R=>{const Y=R.trim();if(!(!Y||Y===yt.current)){if(tt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),G(""),x(null),m(null),j("architecture"),jt(Y),V(!0),He(`Loading ${f0(Y)}…`);try{await Promise.all([Rt(Y),Lr(Y)])}catch(fe){yt.current===Y&&w(fe instanceof Error?fe.message:String(fe))}finally{yt.current===Y&&(He(""),V(!1))}}},an=async()=>{if(tt.current||!Hn())return;w(""),G(""),He("Tracing load path…"),jt(o),bt(a,c);const R=ln(o);try{const Y=await Pe.review(o,a,c,!0,z);Kt(Y),j("review"),r("review"),await Pe.repos().then(fe=>_(fe.repos)).catch(()=>{}),await Promise.all([Rt(o),Bn(o),di(o)])}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{R(),He("")}},Ar=async(R=!0)=>{if(tt.current||!Hn())return;w(""),G(""),He(R?"Indexing…":"Full reindex…"),jt(o);const Y=ln(o);try{await Pe.index(o,R);const fe=await Rt(o);await Pe.repos().then(Ee=>_(Ee.repos)).catch(()=>{}),fe!=null&&fe.indexed&&(j("architecture"),r("architecture"))}catch(fe){w(fe instanceof Error?fe.message:String(fe))}finally{Y(),He("")}},fi=async()=>{if(!tt.current&&Hn()){w(""),G(""),He("Detecting layout…"),jt(o);try{const R=await Pe.init(o);G(R.message),await Pe.repos().then(Y=>_(Y.repos)).catch(()=>{})}catch(R){w(R instanceof Error?R.message:String(R))}finally{He("")}}},hi=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),G("Copied markdown brief")}catch(R){w(R instanceof Error?R.message:String(R))}},pi=async()=>{if(!tt.current){if(!(p!=null&&p.markdown)||!H||!B){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const R=await Pe.postComment(C,H,Number(B),p.markdown);G(R.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(R){w(R instanceof Error?R.message:String(R))}finally{He("")}}},gi=async()=>{if(!tt.current){w(""),He("Fetching pull requests…");try{const R=await Pe.prs(C,H,"open",o.trim()||void 0);te(R.pull_requests);const Y=I.find(fe=>fe.slug.toLowerCase()===H.trim().toLowerCase());Y!=null&&Y.local_path&&jt(Y.local_path)}catch(R){w(R instanceof Error?R.message:String(R))}finally{He("")}}},io=async()=>{w("");try{const R=await Pe.githubOAuthStart();jn(R),Gu(R.verification_uri_complete,"github.com","/login/device")}catch(R){w(R instanceof Error?R.message:String(R))}},mi=async()=>{w("");try{const R=await Pe.bitbucketOAuthStart();It(!0),Gu(R.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(R){It(!1),w(R instanceof Error?R.message:String(R))}},Ve=async()=>{w("");try{const R=await Pe.gitlabOAuthStart();En(!0),Gu(R.authorize_url,new URL(R.authorize_url).hostname,"/oauth/authorize")}catch(R){En(!1),w(R instanceof Error?R.message:String(R))}},$r=async R=>{if(!(tt.current||!o.trim())){w(""),He("Walking what-if path…");try{const Y=await Pe.whatIf(o,R);G(`${Y.title} — ${Y.confidence.level} · ${(Y.sinks||[]).length} sinks`),Kt({...Y,markdown:Y.markdown||"",index:Y.index||(p==null?void 0:p.index),workspace:Y.workspace||(p==null?void 0:p.workspace)}),j("review"),r("review")}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},zr=async R=>{var Ae;if(tt.current)return;Cn(R.provider,R.repo,String(R.number));const Y=I.find(Fe=>Fe.slug.toLowerCase()===R.repo.toLowerCase());Y!=null&&Y.local_path&&jt(Y.local_path),w(""),He(`Fetching ${R.provider} #${R.number}…`);const fe=(Y==null?void 0:Y.local_path)||o,Ee=fe?ln(fe):()=>{};try{const Fe=await Pe.reviewPr(R.provider,R.repo,R.number,(Y==null?void 0:Y.local_path)||o||void 0);Kt(Fe),Fe.pull_request&&typeof Fe.pull_request.repo_path=="string"&&jt(Fe.pull_request.repo_path),bt(String(Fe.base||R.target_branch),String(Fe.head||R.source_branch)),j("review"),r("review"),typeof((Ae=Fe.pull_request)==null?void 0:Ae.repo_path)=="string"&&Bn(Fe.pull_request.repo_path)}catch(Fe){bt(R.base_sha||R.target_branch,R.head_sha||R.source_branch),r("review"),w(Fe instanceof Error?Fe.message:String(Fe))}finally{Ee(),He("")}},sr=async R=>{w("");try{Z(await Pe.oauthDisconnect(R)),C===R&&W([]),G(`Disconnected ${R}`)}catch(Y){w(Y instanceof Error?Y.message:String(Y))}},lr=async R=>{R.preventDefault();const Y=new FormData(R.currentTarget),fe={github_token:String(Y.get("github_token")||""),github_oauth_client_id:String(Y.get("github_oauth_client_id")||""),github_host:String(Y.get("github_host")||""),gitlab_token:String(Y.get("gitlab_token")||""),gitlab_host:String(Y.get("gitlab_host")||""),gitlab_oauth_client_id:String(Y.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(Y.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(Y.get("bitbucket_token")||""),bitbucket_username:String(Y.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(Y.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(Y.get("bitbucket_oauth_client_secret")||""),ai_provider:String(Y.get("ai_provider")||"none"),ai_api_key:String(Y.get("ai_api_key")||""),ai_model:String(Y.get("ai_model")||""),ai_base_url:String(Y.get("ai_base_url")||"")},Ee=y.length?{...fe,workspaces:y.map(Ae=>({path:Ae.path,name:Ae.name}))}:fe;try{Z(await Pe.saveSettings(Ee)),G("Settings saved on this machine")}catch(Ae){w(Ae instanceof Error?Ae.message:String(Ae))}},oo=async()=>{if(!(!p||tt.current)){He("Residual analysis…");try{const R=await Pe.residual(p);he(R.note)}catch(R){w(R instanceof Error?R.message:String(R))}finally{He("")}}},ar=L.useRef(an);ar.current=an;const Mn=L.useRef(t);Mn.current=t;const vt=L.useRef(!1);vt.current=Ne;const yi=L.useRef(p);yi.current=p;const xt=L.useRef(oe);xt.current=oe,L.useEffect(()=>{const R=localStorage.getItem("loadpath.lastReviewId"),Y=(localStorage.getItem("loadpath.repo")||"").trim();if(!R||!Y){ci(!1);return}let fe=!1;return Pe.getReview(Y,R).then(Ee=>{fe||(Kt(Ee),bt(Ee.base||localStorage.getItem("loadpath.base")||"HEAD~1",Ee.head||localStorage.getItem("loadpath.head")||"HEAD"),Bn(Y),di(Y))}).catch(()=>{}).finally(()=>{fe||ci(!1)}),()=>{fe=!0}},[]);const Dr=L.useRef("");L.useEffect(()=>{if(!ot||!o.trim())return;let R=!1;const Y=async()=>{try{const Ee=await Pe.workspaceStatus(o);if(R)return;Dr.current&&Ee.fingerprint!==Dr.current&&!tt.current&&(ie(!0),localStorage.setItem("loadpath.dirty","1"),ar.current()),Dr.current=Ee.fingerprint}catch{}};Y();const fe=window.setInterval(Y,2e3);return()=>{R=!0,window.clearInterval(fe)}},[ot,o]),L.useEffect(()=>{const R=Y=>{var Ae;if((Y.metaKey||Y.ctrlKey)&&Y.key.toLowerCase()==="k"){Y.preventDefault(),Me(Fe=>!Fe);return}if(vt.current){Y.key==="Escape"&&(Y.preventDefault(),Me(!1));return}if(Rr.current){Y.key==="Escape"&&(Y.preventDefault(),ne(!1));return}const fe=Y.target;if(fe&&(fe.tagName==="INPUT"||fe.tagName==="TEXTAREA"||fe.tagName==="SELECT"||fe.isContentEditable)){Y.key==="Escape"&&fe.blur();return}if(Y.key==="Escape"){w(""),G(""),Le(Ze),Mt(null);return}if(Y.key==="j"||Y.key==="k"){const Fe=((Ae=yi.current)==null?void 0:Ae.read_order)||[];if(!Fe.length)return;Y.preventDefault();const un=xt.current,Tn=Y.key==="j"?Math.min(Fe.length-1,un+1):Math.max(0,un-1);de(Tn);return}const Ee=Yu.find(Fe=>Fe.shortcut===Y.key);if(Ee&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey&&r(Ee.id),(Y.metaKey||Y.ctrlKey)&&Y.key==="Enter"){if(Mn.current==="settings"||Mn.current==="prs"||tt.current)return;Y.preventDefault(),ar.current()}};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[Ze]);const vi=async(R,Y)=>{if(!o.trim())return;const fe=await mN(o,R,Y);fe.ok?G(fe.message):w(fe.message)},xi=async()=>{if(p)try{const R=await Pe.exportHtml(p),Y=URL.createObjectURL(R),fe=document.createElement("a");fe.href=Y,fe.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,fe.click(),URL.revokeObjectURL(Y),G("Saved HTML brief")}catch(R){w(R instanceof Error?R.message:String(R))}},Vn=async R=>{if(o.trim()){He("Loading stored review…");try{const Y=await Pe.getReview(o,R);Kt(Y),bt(Y.base||a,Y.head||c),j("review"),r("review");const fe=gt.find(Ee=>Ee.id!==R);if(fe)try{kn(await Pe.reviewDiff(o,R,fe.id))}catch{kn(null)}}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},Pn={selectedId:Re,onSelect:Le,nodeRoles:p==null?void 0:p.node_roles,testOverlay:Xe,isolateSource:on,onIsolate:Mt,repoPath:o,onOpenFile:vi,pinnedId:Ze,onPin:pt},Wn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void an()},{id:"index",group:"Run",label:"Index repository",run:()=>void Ar(!0)},{id:"watch",group:"Run",label:ot?"Stop watching working tree":"Watch working tree",run:()=>{const R=!ot;dt(R),localStorage.setItem("loadpath.watch",R?"1":"0")}},{id:"tests",group:"Graph",label:Xe?"Hide test overlay":"Show test overlay",run:()=>{const R=!Xe;it(R),localStorage.setItem("loadpath.testOverlay",R?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void xi()},...Yu.map(R=>({id:`tab-${R.id}`,group:"Tabs",label:`Go to ${R.label}`,hint:R.shortcut,run:()=>r(R.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(R=>({id:`node-${R.id}`,group:"Nodes",label:R.name,hint:to(R.type),run:()=>{Le(R.id),r("graph")}})),...gt.slice(0,12).map(R=>({id:`hist-${R.id}`,group:"History",label:R.title||R.id,hint:`${R.level||""} ${R.created_at||""}`.trim(),run:()=>void Vn(R.id)}))],Qt=L.useMemo(()=>N==="architecture"?(v==null?void 0:v.nodes)??[]:(p==null?void 0:p.nodes)??[],[N,v,p]),so=L.useMemo(()=>N==="architecture"?(v==null?void 0:v.edges)??[]:(p==null?void 0:p.edges)??[],[N,v,p]),wi=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:v!=null&&v.indexed?`${v.counts.nodes} nodes · ${v.counts.edges} edges`:"Not indexed",Or=((p==null?void 0:p.findings)||[]).filter(R=>!R.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Yu.map(R=>{const Y=R.icon,fe=t===R.id;return d.jsxs("button",{type:"button","data-testid":R.testId,className:fe?"nav-item active":"nav-item","aria-current":fe?"page":void 0,"aria-label":R.label,onClick:()=>r(R.id),children:[d.jsx(Y,{}),d.jsx("span",{children:R.label})]},R.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:Q,onChange:R=>Tr(R.target.value),children:["dark","light"].map(R=>d.jsx("optgroup",{label:R==="dark"?"Dark":"Light",children:Dl.filter(Y=>Y.group===R).map(Y=>d.jsx("option",{value:Y.id,children:Y.label},Y.id))},R))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:M||wi}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[M?d.jsxs("div",{className:b!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","data-testid":"progress",children:[d.jsx("i",{style:b!=null?{width:`${b}%`}:void 0}),d.jsx("span",{className:"sr-only",children:M})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[y.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:y.some(R=>R.path===o)?o:"",disabled:!!M,"aria-busy":$,onChange:R=>{R.target.value&&or(R.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),y.map(R=>d.jsxs("option",{value:R.path,children:[R.name,R.indexed?` (${R.counts.nodes})`:""]},R.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:R=>{const Y=R.target.value;s(Y),Y.trim()!==Ht.current&&(Ht.current="",Nn(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>ne(!0),children:d.jsx(kp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(xp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:R=>bt(R,c),placeholder:"base",refs:ir,onNeedRefs:Lr})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(xp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:R=>bt(a,R),placeholder:"head",refs:ir,onNeedRefs:Lr})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:z?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":z,onClick:()=>{const R=!z;ie(R),localStorage.setItem("loadpath.dirty",R?"1":"0")},children:z?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:ot?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":ot,onClick:()=>{const R=!ot;dt(R),localStorage.setItem("loadpath.watch",R?"1":"0")},children:ot?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!M,onClick:fi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!M,onClick:()=>Ar(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!M,onClick:an,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[E?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:E}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,X?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:X}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>G(""),"aria-label":"Dismiss",children:"×"})]}):null,((Fr=p==null?void 0:p.index)!=null&&Fr.stale||v!=null&&v.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((In=p==null?void 0:p.index)==null?void 0:In.django_boot)==="failed"||(v==null?void 0:v.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Rn=p==null?void 0:p.index)==null?void 0:Rn.django_boot_detail)||(v==null?void 0:v.django_boot_detail)||"django.setup() failed"}):null,(_i=p==null?void 0:p.workspace)!=null&&_i.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null]}),d.jsxs("div",{className:"stage","aria-busy":$,children:[$?d.jsxs("div",{className:"empty workspace-loading","data-testid":"workspace-loading",children:[d.jsx("h2",{children:M}),d.jsx("p",{children:"Fetching the indexed graph for this repository."})]}):null,!$&&t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(CN,{review:p,findings:Or,aiNote:pe,busy:!!M,tourIndex:oe,onTour:de,onAskAi:oo,onCopy:hi,onPost:pi,onSelect:Le,onOpenFile:vi,onExport:xi,history:gt,diff:Pt,onReopen:Vn,onWaiver:(R,Y)=>{o.trim()&&Pe.addWaiver(o,R,Y||void 0,"from review").then(fe=>{qt(fe),G(`Waived ${R} in loadpath.yml`)})}}):ui?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Uu,{nodes:p.nodes,edges:p.edges,onWhatIf:$r,focusPath:(Un=p.read_order[oe])==null?void 0:Un.path,...Pn}):null})]}),!$&&t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:v!=null&&v.indexed?d.jsx(MN,{architecture:v,busy:!!M,onReindex:()=>Ar(!1),onReview:an,onSelect:Le,config:sn,health:no,onSaveConfig:R=>{Pe.saveConfig(o,R).then(Y=>{qt(Y),G("Wrote loadpath.yml")})},onWaiver:(R,Y,fe)=>{Pe.addWaiver(o,R,Y,fe).then(Ee=>{qt(Ee),G(`Waived ${R}`)})}}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:v!=null&&v.indexed?d.jsx(Uu,{nodes:v.nodes,edges:v.edges,onWhatIf:$r,...Pn}):null})]}),!$&&t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":N==="review","data-testid":"graph-mode-review",className:N==="review"?"active":"",onClick:()=>j("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":N==="architecture","data-testid":"graph-mode-architecture",className:N==="architecture"?"active":"",onClick:()=>j("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:Xe?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":Xe,onClick:()=>{const R=!Xe;it(R),localStorage.setItem("loadpath.testOverlay",R?"1":"0")},children:"Tests"})]}),Qt.length?d.jsx(Uu,{nodes:Qt,edges:so,onWhatIf:$r,...Pn}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),!$&&t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:C,onChange:R=>Cn(R.target.value,H,B),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:I.length?"Search your repos":"owner/repo",value:H,onChange:R=>Cn(C,R.target.value,B),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:I.map(R=>d.jsxs("option",{value:R.slug,children:[R.private?"private":"public",R.local_path?" · local":""]},R.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!M||!ro(C),onClick:()=>{Bt(C)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!M,onClick:gi,children:"List PRs"})]}),I.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[I.length," ",C," repositor",I.length===1?"y":"ies",C==="github"&&J.github_user?` · @${String(J.github_user)}`:"",C==="gitlab"&&J.gitlab_user?` · @${String(J.gitlab_user)}`:"",C==="bitbucket"&&J.bitbucket_user?` · ${String(J.bitbucket_user)}`:""]}):null,re.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):re.map(R=>{var Y;return d.jsxs("article",{className:"pr","data-testid":`pr-${R.number}`,children:[d.jsxs("h3",{children:["#",R.number," ",R.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${R.draft?"":"open"}`,children:R.draft?"draft":R.state}),d.jsx("span",{children:R.author}),d.jsxs("span",{children:[R.source_branch," → ",R.target_branch]}),R.loadpath?d.jsxs("span",{className:`chip ${R.loadpath.level||""}`,"data-testid":`pr-loadpath-${R.number}`,children:[((Y=R.loadpath.level)==null?void 0:Y.toUpperCase())||"REVIEWED",R.loadpath.contract_break&&R.loadpath.contract_break!=="none"?` · ${R.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:R.url,target:"_blank",rel:"noreferrer",children:["Open on ",R.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${R.number}`,onClick:()=>void zr(R),children:"Review this PR"})]})]},`${R.provider}-${R.number}`)})]}),!$&&t==="settings"&&me&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:lr,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Dl.map(R=>d.jsxs("button",{type:"button","data-theme":R.id,className:Q===R.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${R.id}`,onClick:()=>Tr(R.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:R.label}),d.jsx("div",{className:"group",children:R.group})]},R.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:gm(),onChange:R=>gN(R.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:J.github_token_set?J.github_user?`Signed in as @${String(J.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:J.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void sr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!Nt||!J.github_oauth_ready,onClick:()=>void io(),children:Nt?"Waiting for GitHub…":"Sign in with GitHub"})})]}),Nt?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:Nt.user_code})," at GitHub if the browser did not fill it in."]}):null,J.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(J.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(J.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:J.gitlab_token_set?J.gitlab_user?`Signed in as @${String(J.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:J.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void sr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Ft||!J.gitlab_oauth_ready,onClick:()=>void Ve(),children:Ft?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(J.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(J.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:J.bitbucket_token_set?J.bitbucket_user?`Signed in as ${String(J.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:J.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void sr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:bn||!J.bitbucket_oauth_ready,onClick:()=>void mi(),children:bn?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),J.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(J.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(J.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((De=J.ai)==null?void 0:De.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((lo=J.ai)==null?void 0:lo.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((ao=J.ai)==null?void 0:ao.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(u0,{open:Ne,actions:Wn,onClose:()=>Me(!1)}),ve?d.jsx(SN,{initialPath:o,onClose:()=>ne(!1),onSelect:R=>{if(tt.current){w("Wait for the current job to finish before switching workspace.");return}ne(!1),or(R)}}):null]})}function CN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:x,onOpenFile:v,onExport:m,history:y,diff:_,onReopen:N,onWaiver:j}){var w,M,k,b,A,$,V,X,G,J,Z,re,te,I,W,H,U;const E=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),E.length?d.jsx("ul",{className:"reasons",children:E.map(C=>d.jsx("li",{children:C},C))}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(C=>d.jsx("span",{className:"chip",children:Xo(C)},C)),(w=t.contract_break)!=null&&w.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(C=>C.status==="todo").length})]}),(t.checklist||[]).map(C=>d.jsxs("div",{className:`check-item ${C.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>C.node_id&&x(C.node_id),children:[d.jsx("span",{className:`chip ${C.status}`,children:C.status}),C.title]}),C.detail?d.jsx("div",{className:"why",children:C.detail}):null,C.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(C.body||"")},children:"Copy test"}):null,C.kind==="finding"&&C.status==="todo"&&C.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>j(C.rule,C.node_id),children:"Waive in loadpath.yml"}):null]},C.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(M=t.workspace)!=null&&M.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((C,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",C.path]}),d.jsx("div",{className:"why",children:C.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>v(C.path),children:"Open"})]},C.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(C=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:C.title})," — ",C.files.join(", ")]},C.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(C=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>C.node_id&&x(C.node_id),children:[d.jsx("span",{className:`chip ${C.severity}`,children:C.severity}),C.message]})},C.rule+C.message))]}),d.jsx(xm,{cards:t.deepening}),(b=(k=t.contract_break)==null?void 0:k.reasons)!=null&&b.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(C=>d.jsx("div",{className:"muted",children:C},C)),($=(A=t.contract_break.sides)==null?void 0:A.rows)!=null&&$.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(C=>d.jsxs("tr",{className:C.status,children:[d.jsx("td",{children:C.field}),d.jsx("td",{children:C.serializer?"yes":"—"}),d.jsx("td",{children:C.zod?"yes":"—"}),d.jsx("td",{children:C.graphql?"yes":"—"})]},C.field))})]}):null]}):null,(V=t.auth)!=null&&V.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(C=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),C.name]},C.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(X=t.suggested_tests)==null?void 0:X.length})]}),(t.suggested_tests||[]).map(C=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:C.title}),d.jsx("pre",{className:"headline",children:C.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(C.body)},children:"Copy sketch"})]},C.title))]}):null,(G=t.trend)!=null&&G.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(C=>d.jsxs("div",{className:"muted",children:[C.level," · ",Xu(C.created_at),C.sinks!=null?` · ${C.sinks} sinks`:""]},C.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(C=>d.jsx("div",{className:"residual muted",children:C},C))]}),y.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:y.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,y.slice(0,12).map(C=>d.jsxs("button",{type:"button",className:C.id===t.id?"history-item current":"history-item",onClick:()=>N(C.id),children:[d.jsx("span",{className:`chip ${C.level||""}`,children:C.level||"walk"}),C.title||C.id.slice(0,8),d.jsx("span",{className:"muted",children:C.created_at?Xu(C.created_at):""})]},C.id))]}):null,(Z=(J=t.evolution)==null?void 0:J.notes)!=null&&Z.length||(te=(re=t.evolution)==null?void 0:re.hotspots)!=null&&te.some(C=>C.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((I=t.evolution)==null?void 0:I.notes)||[]).map(C=>d.jsx("div",{className:"muted",children:C},C)),(((W=t.evolution)==null?void 0:W.hotspots)||[]).filter(C=>C.commits).slice(0,6).map(C=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:C.path})," — ",C.commits," commits, bus factor ",C.bus_factor]},C.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:m,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(H=t.codeowners_reviewers)!=null&&H.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function MN({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var v;const x=t.findings.filter(m=>!m.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${Xu(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(m=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:m.name})," — ",(m.django_apps||[]).join(", ")||"no apps"," ·"," ",(m.owners||[]).join(", ")||"unowned"]},m.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(m=>d.jsx("div",{className:"muted",children:m},m))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:x.length})]}),x.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):x.map(m=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>m.node_id&&a(m.node_id),children:[d.jsx("span",{className:`chip ${m.severity}`,children:m.severity}),m.message]})},m.rule+m.message))]}),d.jsx(xm,{cards:t.deepening}),(v=c==null?void 0:c.points)!=null&&v.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(m=>d.jsx("i",{className:m.level||"",title:`${m.level} · ${m.findings} findings`,style:{height:`${8+Math.min(24,(m.findings||0)*4)}px`}},m.id||m.created_at))}),Object.entries(c.contexts).map(([m,y])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:m})," — last ",((_=y[y.length-1])==null?void 0:_.findings)??0," findings"]},m)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(c0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((m,y)=>y[1]-m[1]).slice(0,12).map(([m,y])=>d.jsxs("tr",{children:[d.jsx("td",{children:to(m)}),d.jsx("td",{children:y})]},m))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function xm({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:d0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}vm(ym());s0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(EN,{})}));export{Hk as L,RN as a,PN as c,d as j,IN as l,L as r,to as t}; diff --git a/src/loadpath/static/assets/index-PXVMaQl_.js b/src/loadpath/static/assets/index-PXVMaQl_.js deleted file mode 100644 index 51281a4..0000000 --- a/src/loadpath/static/assets/index-PXVMaQl_.js +++ /dev/null @@ -1,62 +0,0 @@ -(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function wp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Su={exports:{}},wo={},ku={exports:{}},Te={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Uf;function Qy(){if(Uf)return Te;Uf=1;var t=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),c=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),x=Symbol.iterator;function m(M){return M===null||typeof M!="object"?null:(M=x&&M[x]||M["@@iterator"],typeof M=="function"?M:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,j={};function b(M,R,re){this.props=M,this.context=R,this.refs=j,this.updater=re||S}b.prototype.isReactComponent={},b.prototype.setState=function(M,R){if(typeof M!="object"&&typeof M!="function"&&M!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,M,R,"setState")},b.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function _(){}_.prototype=b.prototype;function P(M,R,re){this.props=M,this.context=R,this.refs=j,this.updater=re||S}var N=P.prototype=new _;N.constructor=P,k(N,b.prototype),N.isPureReactComponent=!0;var E=Array.isArray,L=Object.prototype.hasOwnProperty,A={current:null},V={key:!0,ref:!0,__self:!0,__source:!0};function z(M,R,re){var ie,ce={},fe=null,de=null;if(R!=null)for(ie in R.ref!==void 0&&(de=R.ref),R.key!==void 0&&(fe=""+R.key),R)L.call(R,ie)&&!V.hasOwnProperty(ie)&&(ce[ie]=R[ie]);var Q=arguments.length-2;if(Q===1)ce.children=re;else if(1>>1,R=T[M];if(0>>1;Ma(ce,B))fea(de,ce)?(T[M]=de,T[fe]=B,M=fe):(T[M]=ce,T[ie]=B,M=ie);else if(fea(de,B))T[M]=de,T[fe]=B,M=fe;else break e}}return F}function a(T,F){var B=T.sortIndex-F.sortIndex;return B!==0?B:T.id-F.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,f=c.now();t.unstable_now=function(){return c.now()-f}}var g=[],y=[],v=1,x=null,m=3,S=!1,k=!1,j=!1,b=typeof setTimeout=="function"?setTimeout:null,_=typeof clearTimeout=="function"?clearTimeout:null,P=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function N(T){for(var F=o(y);F!==null;){if(F.callback===null)s(y);else if(F.startTime<=T)s(y),F.sortIndex=F.expirationTime,r(g,F);else break;F=o(y)}}function E(T){if(j=!1,N(T),!k)if(o(g)!==null)k=!0,U(L);else{var F=o(y);F!==null&&Y(E,F.startTime-T)}}function L(T,F){k=!1,j&&(j=!1,_(z),z=-1),S=!0;var B=m;try{for(N(F),x=o(g);x!==null&&(!(x.expirationTime>F)||T&&!J());){var M=x.callback;if(typeof M=="function"){x.callback=null,m=x.priorityLevel;var R=M(x.expirationTime<=F);F=t.unstable_now(),typeof R=="function"?x.callback=R:x===o(g)&&s(g),N(F)}else s(g);x=o(g)}if(x!==null)var re=!0;else{var ie=o(y);ie!==null&&Y(E,ie.startTime-F),re=!1}return re}finally{x=null,m=B,S=!1}}var A=!1,V=null,z=-1,G=5,ee=-1;function J(){return!(t.unstable_now()-eeT||125M?(T.sortIndex=B,r(y,T),o(g)===null&&T===o(y)&&(j?(_(z),z=-1):j=!0,Y(E,B-M))):(T.sortIndex=R,r(g,T),k||S||(k=!0,U(L))),T},t.unstable_shouldYield=J,t.unstable_wrapCallback=function(T){var F=m;return function(){var B=m;m=F;try{return T.apply(this,arguments)}finally{m=B}}}})(ju)),ju}var Kf;function n0(){return Kf||(Kf=1,Eu.exports=t0()),Eu.exports}/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Qf;function r0(){if(Qf)return Ct;Qf=1;var t=$o(),r=n0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),g=Object.prototype.hasOwnProperty,y=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},x={};function m(e){return g.call(x,e)?!0:g.call(v,e)?!1:y.test(e)?x[e]=!0:(v[e]=!0,!1)}function S(e,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function k(e,n,i,l){if(n===null||typeof n>"u"||S(e,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function j(e,n,i,l,d,p,w){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=d,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=p,this.removeEmptyString=w}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){b[e]=new j(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];b[n]=new j(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){b[e]=new j(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){b[e]=new j(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){b[e]=new j(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){b[e]=new j(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){b[e]=new j(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){b[e]=new j(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){b[e]=new j(e,5,!1,e.toLowerCase(),null,!1,!1)});var _=/[\-:]([a-z])/g;function P(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(_,P);b[n]=new j(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(_,P);b[n]=new j(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(_,P);b[n]=new j(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){b[e]=new j(e,1,!1,e.toLowerCase(),null,!1,!1)}),b.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){b[e]=new j(e,1,!1,e.toLowerCase(),null,!0,!0)});function N(e,n,i,l){var d=b.hasOwnProperty(n)?b[n]:null;(d!==null?d.type!==0:l||!(2I||d[w]!==p[I]){var $=` -`+d[w].replace(" at new "," at ");return e.displayName&&$.includes("")&&($=$.replace("",e.displayName)),$}while(1<=w&&0<=I);break}}}finally{re=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?R(e):""}function ce(e){switch(e.tag){case 5:return R(e.type);case 16:return R("Lazy");case 13:return R("Suspense");case 19:return R("SuspenseList");case 0:case 2:case 15:return e=ie(e.type,!1),e;case 11:return e=ie(e.type.render,!1),e;case 1:return e=ie(e.type,!0),e;default:return""}}function fe(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case V:return"Fragment";case A:return"Portal";case G:return"Profiler";case z:return"StrictMode";case q:return"Suspense";case C:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case J:return(e.displayName||"Context")+".Consumer";case ee:return(e._context.displayName||"Context")+".Provider";case ne:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case W:return n=e.displayName||null,n!==null?n:fe(e.type)||"Memo";case U:n=e._payload,e=e._init;try{return fe(e(n))}catch{}}return null}function de(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return fe(n);case 8:return n===z?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Q(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function le(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=le(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var d=i.get,p=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return d.call(this)},set:function(w){l=""+w,p.call(this,w)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(w){l=""+w},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function ke(e){e._valueTracker||(e._valueTracker=me(e))}function xe(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=le(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function pe(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function be(e,n){var i=n.checked;return B({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Pe(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Q(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Ce(e,n){n=n.checked,n!=null&&N(e,"checked",n,!1)}function Re(e,n){Ce(e,n);var i=Q(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?nt(e,n.type,i):n.hasOwnProperty("defaultValue")&&nt(e,n.type,Q(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function tt(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function nt(e,n,i){(n!=="number"||pe(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var Je=Array.isArray;function Qe(e,n,i,l){if(e=e.options,n){n={};for(var d=0;d"+n.valueOf().toString()+"",n=mt.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function ht(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var Gt={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},_n=["Webkit","ms","Moz","O"];Object.keys(Gt).forEach(function(e){_n.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),Gt[n]=Gt[e]})});function zn(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||Gt.hasOwnProperty(e)&&Gt[e]?(""+n).trim():n+"px"}function Gr(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,d=zn(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,d):e[i]=d}}var It=B({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Sn(e,n){if(n){if(It[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function Dn(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var un=null;function $n(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var gr=null,cn=null,dn=null;function Xr(e){if(e=io(e)){if(typeof gr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=cs(n),gr(e.stateNode,e.type,n))}}function qr(e){cn?dn?dn.push(e):dn=[e]:cn=e}function Kr(){if(cn){var e=cn,n=dn;if(dn=cn=null,Xr(e),n)for(e=0;e>>=0,e===0?32:31-(Hl(e)/Bl|0)|0}var ii=64,oi=4194304;function _r(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Nn(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,d=e.suspendedLanes,p=e.pingedLanes,w=i&268435455;if(w!==0){var I=w&~d;I!==0?l=_r(I):(p&=w,p!==0&&(l=_r(p)))}else w=i&~d,w!==0?l=_r(w):p!==0&&(l=_r(p));if(l===0)return 0;if(n!==0&&n!==l&&(n&d)===0&&(d=l&-l,p=n&-n,d>=p||d===16&&(p&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function kr(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Lt(n),e[n]=i}function Ul(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=qi),Dc=" ",$c=!1;function Oc(e,n){switch(e){case"keyup":return Ym.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Fc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ui=!1;function Xm(e,n){switch(e){case"compositionend":return Fc(n);case"keypress":return n.which!==32?null:($c=!0,Dc);case"textInput":return e=n.data,e===Dc&&$c?null:e;default:return null}}function qm(e,n){if(ui)return e==="compositionend"||!na&&Oc(e,n)?(e=Ic(),Jo=Kl=qn=null,ui=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Gc(i)}}function qc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?qc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Kc(){for(var e=window,n=pe();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=pe(e.document)}return n}function oa(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function iy(e){var n=Kc(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&qc(i.ownerDocument.documentElement,i)){if(l!==null&&oa(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var d=i.textContent.length,p=Math.min(l.start,d);l=l.end===void 0?p:Math.min(l.end,d),!e.extend&&p>l&&(d=l,l=p,p=d),d=Xc(i,p);var w=Xc(i,l);d&&w&&(e.rangeCount!==1||e.anchorNode!==d.node||e.anchorOffset!==d.offset||e.focusNode!==w.node||e.focusOffset!==w.offset)&&(n=n.createRange(),n.setStart(d.node,d.offset),e.removeAllRanges(),p>l?(e.addRange(n),e.extend(w.node,w.offset)):(n.setEnd(w.node,w.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,ci=null,sa=null,Ji=null,la=!1;function Qc(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;la||ci==null||ci!==pe(l)||(l=ci,"selectionStart"in l&&oa(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),Ji&&Zi(Ji,l)||(Ji=l,l=ls(sa,"onSelect"),0gi||(e.current=xa[gi],xa[gi]=null,gi--)}function Be(e,n){gi++,xa[gi]=e.current,e.current=n}var Jn={},yt=Zn(Jn),kt=Zn(!1),Er=Jn;function mi(e,n){var i=e.type.contextTypes;if(!i)return Jn;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var d={},p;for(p in i)d[p]=n[p];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=d),d}function Nt(e){return e=e.childContextTypes,e!=null}function ds(){We(kt),We(yt)}function fd(e,n,i){if(yt.current!==Jn)throw Error(o(168));Be(yt,n),Be(kt,i)}function hd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var d in l)if(!(d in n))throw Error(o(108,de(e)||"Unknown",d));return B({},i,l)}function fs(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Jn,Er=yt.current,Be(yt,e),Be(kt,kt.current),!0}function pd(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=hd(e,n,Er),l.__reactInternalMemoizedMergedChildContext=e,We(kt),We(yt),Be(yt,e)):We(kt),Be(kt,i)}var jn=null,hs=!1,wa=!1;function gd(e){jn===null?jn=[e]:jn.push(e)}function my(e){hs=!0,gd(e)}function er(){if(!wa&&jn!==null){wa=!0;var e=0,n=Oe;try{var i=jn;for(Oe=1;e>=w,d-=w,bn=1<<32-Lt(n)+d|i<je?(dt=Ee,Ee=null):dt=Ee.sibling;var De=oe(X,Ee,K[je],ue);if(De===null){Ee===null&&(Ee=dt);break}e&&Ee&&De.alternate===null&&n(X,Ee),H=p(De,H,je),Ne===null?we=De:Ne.sibling=De,Ne=De,Ee=dt}if(je===K.length)return i(X,Ee),Ge&&br(X,je),we;if(Ee===null){for(;jeje?(dt=Ee,Ee=null):dt=Ee.sibling;var ur=oe(X,Ee,De.value,ue);if(ur===null){Ee===null&&(Ee=dt);break}e&&Ee&&ur.alternate===null&&n(X,Ee),H=p(ur,H,je),Ne===null?we=ur:Ne.sibling=ur,Ne=ur,Ee=dt}if(De.done)return i(X,Ee),Ge&&br(X,je),we;if(Ee===null){for(;!De.done;je++,De=K.next())De=ae(X,De.value,ue),De!==null&&(H=p(De,H,je),Ne===null?we=De:Ne.sibling=De,Ne=De);return Ge&&br(X,je),we}for(Ee=l(X,Ee);!De.done;je++,De=K.next())De=he(Ee,X,je,De.value,ue),De!==null&&(e&&De.alternate!==null&&Ee.delete(De.key===null?je:De.key),H=p(De,H,je),Ne===null?we=De:Ne.sibling=De,Ne=De);return e&&Ee.forEach(function(Ky){return n(X,Ky)}),Ge&&br(X,je),we}function et(X,H,K,ue){if(typeof K=="object"&&K!==null&&K.type===V&&K.key===null&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case L:e:{for(var we=K.key,Ne=H;Ne!==null;){if(Ne.key===we){if(we=K.type,we===V){if(Ne.tag===7){i(X,Ne.sibling),H=d(Ne,K.props.children),H.return=X,X=H;break e}}else if(Ne.elementType===we||typeof we=="object"&&we!==null&&we.$$typeof===U&&_d(we)===Ne.type){i(X,Ne.sibling),H=d(Ne,K.props),H.ref=oo(X,Ne,K),H.return=X,X=H;break e}i(X,Ne);break}else n(X,Ne);Ne=Ne.sibling}K.type===V?(H=Ar(K.props.children,X.mode,ue,K.key),H.return=X,X=H):(ue=Hs(K.type,K.key,K.props,null,X.mode,ue),ue.ref=oo(X,H,K),ue.return=X,X=ue)}return w(X);case A:e:{for(Ne=K.key;H!==null;){if(H.key===Ne)if(H.tag===4&&H.stateNode.containerInfo===K.containerInfo&&H.stateNode.implementation===K.implementation){i(X,H.sibling),H=d(H,K.children||[]),H.return=X,X=H;break e}else{i(X,H);break}else n(X,H);H=H.sibling}H=yu(K,X.mode,ue),H.return=X,X=H}return w(X);case U:return Ne=K._init,et(X,H,Ne(K._payload),ue)}if(Je(K))return ye(X,H,K,ue);if(F(K))return ve(X,H,K,ue);ys(X,K)}return typeof K=="string"&&K!==""||typeof K=="number"?(K=""+K,H!==null&&H.tag===6?(i(X,H.sibling),H=d(H,K),H.return=X,X=H):(i(X,H),H=mu(K,X.mode,ue),H.return=X,X=H),w(X)):i(X,H)}return et}var wi=Sd(!0),kd=Sd(!1),vs=Zn(null),xs=null,_i=null,ja=null;function ba(){ja=_i=xs=null}function Ca(e){var n=vs.current;We(vs),e._currentValue=n}function Ma(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function Si(e,n){xs=e,ja=_i=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Et=!0),e.firstContext=null)}function Vt(e){var n=e._currentValue;if(ja!==e)if(e={context:e,memoizedValue:n,next:null},_i===null){if(xs===null)throw Error(o(308));_i=e,xs.dependencies={lanes:0,firstContext:e}}else _i=_i.next=e;return n}var Cr=null;function Pa(e){Cr===null?Cr=[e]:Cr.push(e)}function Nd(e,n,i,l){var d=n.interleaved;return d===null?(i.next=i,Pa(n)):(i.next=d.next,d.next=i),n.interleaved=i,Mn(e,l)}function Mn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var tr=!1;function Ia(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ed(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Pn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function nr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(Ae&2)!==0){var d=l.pending;return d===null?n.next=n:(n.next=d.next,d.next=n),l.pending=n,Mn(e,i)}return d=l.interleaved,d===null?(n.next=n,Pa(l)):(n.next=d.next,d.next=n),l.interleaved=n,Mn(e,i)}function ws(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,si(e,i)}}function jd(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var d=null,p=null;if(i=i.firstBaseUpdate,i!==null){do{var w={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};p===null?d=p=w:p=p.next=w,i=i.next}while(i!==null);p===null?d=p=n:p=p.next=n}else d=p=n;i={baseState:l.baseState,firstBaseUpdate:d,lastBaseUpdate:p,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function _s(e,n,i,l){var d=e.updateQueue;tr=!1;var p=d.firstBaseUpdate,w=d.lastBaseUpdate,I=d.shared.pending;if(I!==null){d.shared.pending=null;var $=I,Z=$.next;$.next=null,w===null?p=Z:w.next=Z,w=$;var se=e.alternate;se!==null&&(se=se.updateQueue,I=se.lastBaseUpdate,I!==w&&(I===null?se.firstBaseUpdate=Z:I.next=Z,se.lastBaseUpdate=$))}if(p!==null){var ae=d.baseState;w=0,se=Z=$=null,I=p;do{var oe=I.lane,he=I.eventTime;if((l&oe)===oe){se!==null&&(se=se.next={eventTime:he,lane:0,tag:I.tag,payload:I.payload,callback:I.callback,next:null});e:{var ye=e,ve=I;switch(oe=n,he=i,ve.tag){case 1:if(ye=ve.payload,typeof ye=="function"){ae=ye.call(he,ae,oe);break e}ae=ye;break e;case 3:ye.flags=ye.flags&-65537|128;case 0:if(ye=ve.payload,oe=typeof ye=="function"?ye.call(he,ae,oe):ye,oe==null)break e;ae=B({},ae,oe);break e;case 2:tr=!0}}I.callback!==null&&I.lane!==0&&(e.flags|=64,oe=d.effects,oe===null?d.effects=[I]:oe.push(I))}else he={eventTime:he,lane:oe,tag:I.tag,payload:I.payload,callback:I.callback,next:null},se===null?(Z=se=he,$=ae):se=se.next=he,w|=oe;if(I=I.next,I===null){if(I=d.shared.pending,I===null)break;oe=I,I=oe.next,oe.next=null,d.lastBaseUpdate=oe,d.shared.pending=null}}while(!0);if(se===null&&($=ae),d.baseState=$,d.firstBaseUpdate=Z,d.lastBaseUpdate=se,n=d.shared.interleaved,n!==null){d=n;do w|=d.lane,d=d.next;while(d!==n)}else p===null&&(d.shared.lanes=0);Ir|=w,e.lanes=w,e.memoizedState=ae}}function bd(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=za.transition;za.transition={};try{e(!1),n()}finally{Oe=i,za.transition=l}}function Yd(){return Wt().memoizedState}function wy(e,n,i){var l=sr(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},Gd(e))Xd(n,i);else if(i=Nd(e,n,i,l),i!==null){var d=St();Jt(i,e,l,d),qd(i,n,l)}}function _y(e,n,i){var l=sr(e),d={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(Gd(e))Xd(n,d);else{var p=e.alternate;if(e.lanes===0&&(p===null||p.lanes===0)&&(p=n.lastRenderedReducer,p!==null))try{var w=n.lastRenderedState,I=p(w,i);if(d.hasEagerState=!0,d.eagerState=I,Xt(I,w)){var $=n.interleaved;$===null?(d.next=d,Pa(n)):(d.next=$.next,$.next=d),n.interleaved=d;return}}catch{}finally{}i=Nd(e,n,d,l),i!==null&&(d=St(),Jt(i,e,l,d),qd(i,n,l))}}function Gd(e){var n=e.alternate;return e===qe||n!==null&&n===qe}function Xd(e,n){uo=Ns=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function qd(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,si(e,i)}}var bs={readContext:Vt,useCallback:vt,useContext:vt,useEffect:vt,useImperativeHandle:vt,useInsertionEffect:vt,useLayoutEffect:vt,useMemo:vt,useReducer:vt,useRef:vt,useState:vt,useDebugValue:vt,useDeferredValue:vt,useTransition:vt,useMutableSource:vt,useSyncExternalStore:vt,useId:vt,unstable_isNewReconciler:!1},Sy={readContext:Vt,useCallback:function(e,n){return mn().memoizedState=[e,n===void 0?null:n],e},useContext:Vt,useEffect:$d,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Es(4194308,4,Hd.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Es(4194308,4,e,n)},useInsertionEffect:function(e,n){return Es(4,2,e,n)},useMemo:function(e,n){var i=mn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=mn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=wy.bind(null,qe,e),[l.memoizedState,e]},useRef:function(e){var n=mn();return e={current:e},n.memoizedState=e},useState:zd,useDebugValue:Va,useDeferredValue:function(e){return mn().memoizedState=e},useTransition:function(){var e=zd(!1),n=e[0];return e=xy.bind(null,e[1]),mn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=qe,d=mn();if(Ge){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ct===null)throw Error(o(349));(Pr&30)!==0||Id(l,n,i)}d.memoizedState=i;var p={value:i,getSnapshot:n};return d.queue=p,$d(Rd.bind(null,l,p,e),[e]),l.flags|=2048,ho(9,Td.bind(null,l,p,i,n),void 0,null),i},useId:function(){var e=mn(),n=ct.identifierPrefix;if(Ge){var i=Cn,l=bn;i=(l&~(1<<32-Lt(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=co++,0<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=w.createElement(i,{is:l.is}):(e=w.createElement(i),i==="select"&&(w=e,l.multiple?w.multiple=!0:l.size&&(w.size=l.size))):e=w.createElementNS(e,i),e[pn]=n,e[ro]=l,mf(e,n,!1,!1),n.stateNode=e;e:{switch(w=Dn(i,l),i){case"dialog":Ve("cancel",e),Ve("close",e),d=l;break;case"iframe":case"object":case"embed":Ve("load",e),d=l;break;case"video":case"audio":for(d=0;dbi&&(n.flags|=128,l=!0,po(p,!1),n.lanes=4194304)}else{if(!l)if(e=Ss(w),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),po(p,!0),p.tail===null&&p.tailMode==="hidden"&&!w.alternate&&!Ge)return xt(n),null}else 2*Fe()-p.renderingStartTime>bi&&i!==1073741824&&(n.flags|=128,l=!0,po(p,!1),n.lanes=4194304);p.isBackwards?(w.sibling=n.child,n.child=w):(i=p.last,i!==null?i.sibling=w:n.child=w,p.last=w)}return p.tail!==null?(n=p.tail,p.rendering=n,p.tail=n.sibling,p.renderingStartTime=Fe(),n.sibling=null,i=Xe.current,Be(Xe,l?i&1|2:i&1),n):(xt(n),null);case 22:case 23:return hu(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?($t&1073741824)!==0&&(xt(n),n.subtreeFlags&6&&(n.flags|=8192)):xt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function Py(e,n){switch(Sa(n),n.tag){case 1:return Nt(n.type)&&ds(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return ki(),We(kt),We(yt),Aa(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Ra(n),null;case 13:if(We(Xe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));xi()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return We(Xe),null;case 4:return ki(),null;case 10:return Ca(n.type._context),null;case 22:case 23:return hu(),null;case 24:return null;default:return null}}var Is=!1,wt=!1,Iy=typeof WeakSet=="function"?WeakSet:Set,ge=null;function Ei(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Ze(e,n,l)}else i.current=null}function tu(e,n,i){try{i()}catch(l){Ze(e,n,l)}}var xf=!1;function Ty(e,n){if(ha=Qo,e=Kc(),oa(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var d=l.anchorOffset,p=l.focusNode;l=l.focusOffset;try{i.nodeType,p.nodeType}catch{i=null;break e}var w=0,I=-1,$=-1,Z=0,se=0,ae=e,oe=null;t:for(;;){for(var he;ae!==i||d!==0&&ae.nodeType!==3||(I=w+d),ae!==p||l!==0&&ae.nodeType!==3||($=w+l),ae.nodeType===3&&(w+=ae.nodeValue.length),(he=ae.firstChild)!==null;)oe=ae,ae=he;for(;;){if(ae===e)break t;if(oe===i&&++Z===d&&(I=w),oe===p&&++se===l&&($=w),(he=ae.nextSibling)!==null)break;ae=oe,oe=ae.parentNode}ae=he}i=I===-1||$===-1?null:{start:I,end:$}}else i=null}i=i||{start:0,end:0}}else i=null;for(pa={focusedElem:e,selectionRange:i},Qo=!1,ge=n;ge!==null;)if(n=ge,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ge=e;else for(;ge!==null;){n=ge;try{var ye=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(ye!==null){var ve=ye.memoizedProps,et=ye.memoizedState,X=n.stateNode,H=X.getSnapshotBeforeUpdate(n.elementType===n.type?ve:Kt(n.type,ve),et);X.__reactInternalSnapshotBeforeUpdate=H}break;case 3:var K=n.stateNode.containerInfo;K.nodeType===1?K.textContent="":K.nodeType===9&&K.documentElement&&K.removeChild(K.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(ue){Ze(n,n.return,ue)}if(e=n.sibling,e!==null){e.return=n.return,ge=e;break}ge=n.return}return ye=xf,xf=!1,ye}function go(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var d=l=l.next;do{if((d.tag&e)===e){var p=d.destroy;d.destroy=void 0,p!==void 0&&tu(n,i,p)}d=d.next}while(d!==l)}}function Ts(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function nu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function wf(e){var n=e.alternate;n!==null&&(e.alternate=null,wf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[pn],delete n[ro],delete n[va],delete n[py],delete n[gy])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function _f(e){return e.tag===5||e.tag===3||e.tag===4}function Sf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||_f(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function ru(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=us));else if(l!==4&&(e=e.child,e!==null))for(ru(e,n,i),e=e.sibling;e!==null;)ru(e,n,i),e=e.sibling}function iu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(iu(e,n,i),e=e.sibling;e!==null;)iu(e,n,i),e=e.sibling}var pt=null,Qt=!1;function rr(e,n,i){for(i=i.child;i!==null;)kf(e,n,i),i=i.sibling}function kf(e,n,i){if(Rt&&typeof Rt.onCommitFiberUnmount=="function")try{Rt.onCommitFiberUnmount(ri,i)}catch{}switch(i.tag){case 5:wt||Ei(i,n);case 6:var l=pt,d=Qt;pt=null,rr(e,n,i),pt=l,Qt=d,pt!==null&&(Qt?(e=pt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):pt.removeChild(i.stateNode));break;case 18:pt!==null&&(Qt?(e=pt,i=i.stateNode,e.nodeType===8?ya(e.parentNode,i):e.nodeType===1&&ya(e,i),Yi(e)):ya(pt,i.stateNode));break;case 4:l=pt,d=Qt,pt=i.stateNode.containerInfo,Qt=!0,rr(e,n,i),pt=l,Qt=d;break;case 0:case 11:case 14:case 15:if(!wt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){d=l=l.next;do{var p=d,w=p.destroy;p=p.tag,w!==void 0&&((p&2)!==0||(p&4)!==0)&&tu(i,n,w),d=d.next}while(d!==l)}rr(e,n,i);break;case 1:if(!wt&&(Ei(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(I){Ze(i,n,I)}rr(e,n,i);break;case 21:rr(e,n,i);break;case 22:i.mode&1?(wt=(l=wt)||i.memoizedState!==null,rr(e,n,i),wt=l):rr(e,n,i);break;default:rr(e,n,i)}}function Nf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Iy),n.forEach(function(l){var d=Hy.bind(null,e,l);i.has(l)||(i.add(l),l.then(d,d))})}}function Zt(e,n){var i=n.deletions;if(i!==null)for(var l=0;ld&&(d=w),l&=~p}if(l=d,l=Fe()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Ly(l/1960))-l,10e?16:e,or===null)var l=!1;else{if(e=or,or=null,Ds=0,(Ae&6)!==0)throw Error(o(331));var d=Ae;for(Ae|=4,ge=e.current;ge!==null;){var p=ge,w=p.child;if((ge.flags&16)!==0){var I=p.deletions;if(I!==null){for(var $=0;$Fe()-lu?Rr(e,0):su|=i),bt(e,n)}function Df(e,n){n===0&&((e.mode&1)===0?n=1:(n=oi,oi<<=1,(oi&130023424)===0&&(oi=4194304)));var i=St();e=Mn(e,n),e!==null&&(kr(e,n,i),bt(e,i))}function Fy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Df(e,i)}function Hy(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,d=e.memoizedState;d!==null&&(i=d.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Df(e,i)}var $f;$f=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||kt.current)Et=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Et=!1,Cy(e,n,i);Et=(e.flags&131072)!==0}else Et=!1,Ge&&(n.flags&1048576)!==0&&md(n,gs,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Ps(e,n),e=n.pendingProps;var d=mi(n,yt.current);Si(n,i),d=$a(null,n,l,e,d,i);var p=Oa();return n.flags|=1,typeof d=="object"&&d!==null&&typeof d.render=="function"&&d.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Nt(l)?(p=!0,fs(n)):p=!1,n.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,Ia(n),d.updater=Cs,n.stateNode=d,d._reactInternals=n,Ua(n,l,e,i),n=qa(null,n,l,!0,p,i)):(n.tag=0,Ge&&p&&_a(n),_t(null,n,d,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Ps(e,n),e=n.pendingProps,d=l._init,l=d(l._payload),n.type=l,d=n.tag=Vy(l),e=Kt(l,e),d){case 0:n=Xa(null,n,l,e,i);break e;case 1:n=cf(null,n,l,e,i);break e;case 11:n=of(null,n,l,e,i);break e;case 14:n=sf(null,n,l,Kt(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,d=n.pendingProps,d=n.elementType===l?d:Kt(l,d),Xa(e,n,l,d,i);case 1:return l=n.type,d=n.pendingProps,d=n.elementType===l?d:Kt(l,d),cf(e,n,l,d,i);case 3:e:{if(df(n),e===null)throw Error(o(387));l=n.pendingProps,p=n.memoizedState,d=p.element,Ed(e,n),_s(n,l,null,i);var w=n.memoizedState;if(l=w.element,p.isDehydrated)if(p={element:l,isDehydrated:!1,cache:w.cache,pendingSuspenseBoundaries:w.pendingSuspenseBoundaries,transitions:w.transitions},n.updateQueue.baseState=p,n.memoizedState=p,n.flags&256){d=Ni(Error(o(423)),n),n=ff(e,n,l,i,d);break e}else if(l!==d){d=Ni(Error(o(424)),n),n=ff(e,n,l,i,d);break e}else for(Dt=Qn(n.stateNode.containerInfo.firstChild),zt=n,Ge=!0,qt=null,i=kd(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(xi(),l===d){n=In(e,n,i);break e}_t(e,n,l,i)}n=n.child}return n;case 5:return Cd(n),e===null&&Na(n),l=n.type,d=n.pendingProps,p=e!==null?e.memoizedProps:null,w=d.children,ga(l,d)?w=null:p!==null&&ga(l,p)&&(n.flags|=32),uf(e,n),_t(e,n,w,i),n.child;case 6:return e===null&&Na(n),null;case 13:return hf(e,n,i);case 4:return Ta(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=wi(n,null,l,i):_t(e,n,l,i),n.child;case 11:return l=n.type,d=n.pendingProps,d=n.elementType===l?d:Kt(l,d),of(e,n,l,d,i);case 7:return _t(e,n,n.pendingProps,i),n.child;case 8:return _t(e,n,n.pendingProps.children,i),n.child;case 12:return _t(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,d=n.pendingProps,p=n.memoizedProps,w=d.value,Be(vs,l._currentValue),l._currentValue=w,p!==null)if(Xt(p.value,w)){if(p.children===d.children&&!kt.current){n=In(e,n,i);break e}}else for(p=n.child,p!==null&&(p.return=n);p!==null;){var I=p.dependencies;if(I!==null){w=p.child;for(var $=I.firstContext;$!==null;){if($.context===l){if(p.tag===1){$=Pn(-1,i&-i),$.tag=2;var Z=p.updateQueue;if(Z!==null){Z=Z.shared;var se=Z.pending;se===null?$.next=$:($.next=se.next,se.next=$),Z.pending=$}}p.lanes|=i,$=p.alternate,$!==null&&($.lanes|=i),Ma(p.return,i,n),I.lanes|=i;break}$=$.next}}else if(p.tag===10)w=p.type===n.type?null:p.child;else if(p.tag===18){if(w=p.return,w===null)throw Error(o(341));w.lanes|=i,I=w.alternate,I!==null&&(I.lanes|=i),Ma(w,i,n),w=p.sibling}else w=p.child;if(w!==null)w.return=p;else for(w=p;w!==null;){if(w===n){w=null;break}if(p=w.sibling,p!==null){p.return=w.return,w=p;break}w=w.return}p=w}_t(e,n,d.children,i),n=n.child}return n;case 9:return d=n.type,l=n.pendingProps.children,Si(n,i),d=Vt(d),l=l(d),n.flags|=1,_t(e,n,l,i),n.child;case 14:return l=n.type,d=Kt(l,n.pendingProps),d=Kt(l.type,d),sf(e,n,l,d,i);case 15:return lf(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,d=n.pendingProps,d=n.elementType===l?d:Kt(l,d),Ps(e,n),n.tag=1,Nt(l)?(e=!0,fs(n)):e=!1,Si(n,i),Qd(n,l,d),Ua(n,l,d,i),qa(null,n,l,!0,e,i);case 19:return gf(e,n,i);case 22:return af(e,n,i)}throw Error(o(156,n.tag))};function Of(e,n){return te(e,n)}function By(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Yt(e,n,i,l){return new By(e,n,i,l)}function gu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Vy(e){if(typeof e=="function")return gu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ne)return 11;if(e===W)return 14}return 2}function ar(e,n){var i=e.alternate;return i===null?(i=Yt(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function Hs(e,n,i,l,d,p){var w=2;if(l=e,typeof e=="function")gu(e)&&(w=1);else if(typeof e=="string")w=5;else e:switch(e){case V:return Ar(i.children,d,p,n);case z:w=8,d|=8;break;case G:return e=Yt(12,i,n,d|2),e.elementType=G,e.lanes=p,e;case q:return e=Yt(13,i,n,d),e.elementType=q,e.lanes=p,e;case C:return e=Yt(19,i,n,d),e.elementType=C,e.lanes=p,e;case Y:return Bs(i,d,p,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ee:w=10;break e;case J:w=9;break e;case ne:w=11;break e;case W:w=14;break e;case U:w=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=Yt(w,i,n,d),n.elementType=e,n.type=l,n.lanes=p,n}function Ar(e,n,i,l){return e=Yt(7,e,l,n),e.lanes=i,e}function Bs(e,n,i,l){return e=Yt(22,e,l,n),e.elementType=Y,e.lanes=i,e.stateNode={isHidden:!1},e}function mu(e,n,i){return e=Yt(6,e,null,n),e.lanes=i,e}function yu(e,n,i){return n=Yt(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Wy(e,n,i,l,d){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Sr(0),this.expirationTimes=Sr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Sr(0),this.identifierPrefix=l,this.onRecoverableError=d,this.mutableSourceEagerHydrationData=null}function vu(e,n,i,l,d,p,w,I,$){return e=new Wy(e,n,i,I,$),n===1?(n=1,p===!0&&(n|=8)):n=0,p=Yt(3,null,null,n),e.current=p,p.stateNode=e,p.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ia(p),e}function Uy(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),Nu.exports=r0(),Nu.exports}var Jf;function i0(){if(Jf)return qs;Jf=1;var t=_p();return qs.createRoot=t.createRoot,qs.hydrateRoot=t.hydrateRoot,qs}var o0=i0();function s0(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Ue(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(s0(s,o.statusText||"Request failed"))}return o.json()}const l0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],$e={health:()=>Ue("/api/health"),settings:()=>Ue("/api/settings"),saveSettings:t=>{const r={...t};for(const o of l0)r[o]===""&&delete r[o];return Ue("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ue("/api/repos"),browse:t=>Ue(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ue(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ue("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ue(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Ue(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:t=>Ue(`/api/architecture?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Ue("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Ue("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Ue("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Ue("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Ue("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Ue(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open")=>Ue("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o})}),scmRepos:t=>Ue(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ue("/api/oauth/status"),githubOAuthStart:()=>Ue("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ue("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ue("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Ue("/api/oauth/gitlab/start"),oauthDisconnect:t=>Ue("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ue("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})})};function bo(t){return t.replaceAll("_"," ")}function a0(t){return t.replaceAll("_"," ")}function kl(t){return t.split(".").pop()||t}function Sp(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function u0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Dr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function Yr({className:t,children:r}){return h.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function c0({className:t}){return h.jsxs(Yr,{className:t,children:[h.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),h.jsx("path",{d:"M9.5 3.5V7H13"}),h.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function d0({className:t}){return h.jsxs(Yr,{className:t,children:[h.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),h.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),h.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),h.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function f0({className:t}){return h.jsxs(Yr,{className:t,children:[h.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),h.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),h.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),h.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function h0({className:t}){return h.jsxs(Yr,{className:t,children:[h.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),h.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),h.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),h.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function p0({className:t}){return h.jsxs(Yr,{className:t,children:[h.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),h.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function kp({className:t}){return h.jsx(Yr,{className:t,children:h.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function g0({className:t}){return h.jsx(Yr,{className:t,children:h.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const m0="modulepreload",y0=function(t,r){return new URL(t,r).href},eh={},v0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(v){return Promise.all(v.map(x=>Promise.resolve(x).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};const f=document.getElementsByTagName("link"),g=document.querySelector("meta[property=csp-nonce]"),y=(g==null?void 0:g.nonce)||(g==null?void 0:g.getAttribute("nonce"));a=c(o.map(v=>{if(v=y0(v,s),v in eh)return;eh[v]=!0;const x=v.endsWith(".css"),m=x?'[rel="stylesheet"]':"";if(!!s)for(let j=f.length-1;j>=0;j--){const b=f[j];if(b.href===v&&(!x||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${v}"]${m}`))return;const k=document.createElement("link");if(k.rel=x?"stylesheet":m0,x||(k.as="script"),k.crossOrigin="",k.href=v,y&&k.setAttribute("nonce",y),document.head.appendChild(k),x)return new Promise((j,b)=>{k.addEventListener("load",j),k.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${v}`)))})}))}function u(c){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=c,window.dispatchEvent(f),!f.defaultPrevented)throw c}return a.then(c=>{for(const f of c||[])f.status==="rejected"&&u(f.reason);return r().catch(u)})};function it(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Nl(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}ll.prototype=Nl.prototype={constructor:ll,on:function(t,r){var o=this._,s=w0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),nh.hasOwnProperty(r)?{space:nh[r],local:t}:t}function S0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===Bu&&r.documentElement.namespaceURI===Bu?r.createElement(t):r.createElementNS(o,t)}}function k0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Np(t){var r=El(t);return(r.local?k0:S0)(r)}function N0(){}function ic(t){return t==null?N0:function(){return this.querySelector(t)}}function E0(t){typeof t!="function"&&(t=ic(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=N&&(N=P+1);!(L=b[N])&&++N=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function K0(t){t||(t=Q0);function r(x,m){return x&&m?t(x.__data__,m.__data__):!x-!m}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function Z0(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function J0(){return Array.from(this)}function ev(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?dv:typeof r=="function"?hv:fv)(t,r,o??"")):Ri(this.node(),t)}function Ri(t,r){return t.style.getPropertyValue(r)||Mp(t).getComputedStyle(t,null).getPropertyValue(r)}function gv(t){return function(){delete this[t]}}function mv(t,r){return function(){this[t]=r}}function yv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function vv(t,r){return arguments.length>1?this.each((r==null?gv:typeof r=="function"?yv:mv)(t,r)):this.node()[t]}function Pp(t){return t.trim().split(/^|\s+/)}function oc(t){return t.classList||new Ip(t)}function Ip(t){this._node=t,this._names=Pp(t.getAttribute("class")||"")}Ip.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Tp(t,r){for(var o=oc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function Yv(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function Vu(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:f,dx:g,dy:y,dispatch:v}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:f,enumerable:!0,configurable:!0},dx:{value:g,enumerable:!0,configurable:!0},dy:{value:y,enumerable:!0,configurable:!0},_:{value:v}})}Vu.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function nx(t){return!t.ctrlKey&&!t.button}function rx(){return this.parentNode}function ix(t,r){return r??{x:t.x,y:t.y}}function ox(){return navigator.maxTouchPoints||"ontouchstart"in this}function $p(){var t=nx,r=rx,o=ix,s=ox,a={},u=Nl("start","drag","end"),c=0,f,g,y,v,x=0;function m(E){E.on("mousedown.drag",S).filter(s).on("touchstart.drag",b).on("touchmove.drag",_,tx).on("touchend.drag touchcancel.drag",P).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function S(E,L){if(!(v||!t.call(this,E,L))){var A=N(this,r.call(this,E,L),E,L,"mouse");A&&(Ot(E.view).on("mousemove.drag",k,Co).on("mouseup.drag",j,Co),zp(E.view),bu(E),y=!1,f=E.clientX,g=E.clientY,A("start",E))}}function k(E){if(Ii(E),!y){var L=E.clientX-f,A=E.clientY-g;y=L*L+A*A>x}a.mouse("drag",E)}function j(E){Ot(E.view).on("mousemove.drag mouseup.drag",null),Dp(E.view,y),Ii(E),a.mouse("end",E)}function b(E,L){if(t.call(this,E,L)){var A=E.changedTouches,V=r.call(this,E,L),z=A.length,G,ee;for(G=0;G>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?Qs(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?Qs(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=lx.exec(t))?new Mt(r[1],r[2],r[3],1):(r=ax.exec(t))?new Mt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=ux.exec(t))?Qs(r[1],r[2],r[3],r[4]):(r=cx.exec(t))?Qs(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=dx.exec(t))?uh(r[1],r[2]/100,r[3]/100,1):(r=fx.exec(t))?uh(r[1],r[2]/100,r[3]/100,r[4]):rh.hasOwnProperty(t)?sh(rh[t]):t==="transparent"?new Mt(NaN,NaN,NaN,0):null}function sh(t){return new Mt(t>>16&255,t>>8&255,t&255,1)}function Qs(t,r,o,s){return s<=0&&(t=r=o=NaN),new Mt(t,r,o,s)}function gx(t){return t instanceof Fo||(t=Hr(t)),t?(t=t.rgb(),new Mt(t.r,t.g,t.b,t.opacity)):new Mt}function Wu(t,r,o,s){return arguments.length===1?gx(t):new Mt(t,r,o,s??1)}function Mt(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}sc(Mt,Wu,Op(Fo,{brighter(t){return t=t==null?hl:Math.pow(hl,t),new Mt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Mo:Math.pow(Mo,t),new Mt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Mt(Or(this.r),Or(this.g),Or(this.b),pl(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:lh,formatHex:lh,formatHex8:mx,formatRgb:ah,toString:ah}));function lh(){return`#${$r(this.r)}${$r(this.g)}${$r(this.b)}`}function mx(){return`#${$r(this.r)}${$r(this.g)}${$r(this.b)}${$r((isNaN(this.opacity)?1:this.opacity)*255)}`}function ah(){const t=pl(this.opacity);return`${t===1?"rgb(":"rgba("}${Or(this.r)}, ${Or(this.g)}, ${Or(this.b)}${t===1?")":`, ${t})`}`}function pl(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Or(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function $r(t){return t=Or(t),(t<16?"0":"")+t.toString(16)}function uh(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new tn(t,r,o,s)}function Fp(t){if(t instanceof tn)return new tn(t.h,t.s,t.l,t.opacity);if(t instanceof Fo||(t=Hr(t)),!t)return new tn;if(t instanceof tn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,f=u-a,g=(u+a)/2;return f?(r===u?c=(o-s)/f+(o0&&g<1?0:c,new tn(c,f,g,t.opacity)}function yx(t,r,o,s){return arguments.length===1?Fp(t):new tn(t,r,o,s??1)}function tn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}sc(tn,yx,Op(Fo,{brighter(t){return t=t==null?hl:Math.pow(hl,t),new tn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Mo:Math.pow(Mo,t),new tn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Mt(Cu(t>=240?t-240:t+120,a,s),Cu(t,a,s),Cu(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new tn(ch(this.h),Zs(this.s),Zs(this.l),pl(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 t=pl(this.opacity);return`${t===1?"hsl(":"hsla("}${ch(this.h)}, ${Zs(this.s)*100}%, ${Zs(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ch(t){return t=(t||0)%360,t<0?t+360:t}function Zs(t){return Math.max(0,Math.min(1,t||0))}function Cu(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const lc=t=>()=>t;function vx(t,r){return function(o){return t+o*r}}function xx(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function wx(t){return(t=+t)==1?Hp:function(r,o){return o-r?xx(r,o,t):lc(isNaN(r)?o:r)}}function Hp(t,r){var o=r-t;return o?vx(t,o):lc(isNaN(t)?r:t)}const gl=(function t(r){var o=wx(r);function s(a,u){var c=o((a=Wu(a)).r,(u=Wu(u)).r),f=o(a.g,u.g),g=o(a.b,u.b),y=Hp(a.opacity,u.opacity);return function(v){return a.r=c(v),a.g=f(v),a.b=g(v),a.opacity=y(v),a+""}}return s.gamma=t,s})(1);function _x(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),f[c]?f[c]+=u:f[++c]=u),(s=s[0])===(a=a[0])?f[c]?f[c]+=a:f[++c]=a:(f[++c]=null,g.push({i:c,x:vn(s,a)})),o=Mu.lastIndex;return o180?v+=360:v-y>180&&(y+=360),m.push({i:x.push(a(x)+"rotate(",null,s)-2,x:vn(y,v)})):v&&x.push(a(x)+"rotate("+v+s)}function f(y,v,x,m){y!==v?m.push({i:x.push(a(x)+"skewX(",null,s)-2,x:vn(y,v)}):v&&x.push(a(x)+"skewX("+v+s)}function g(y,v,x,m,S,k){if(y!==x||v!==m){var j=S.push(a(S)+"scale(",null,",",null,")");k.push({i:j-4,x:vn(y,x)},{i:j-2,x:vn(v,m)})}else(x!==1||m!==1)&&S.push(a(S)+"scale("+x+","+m+")")}return function(y,v){var x=[],m=[];return y=t(y),v=t(v),u(y.translateX,y.translateY,v.translateX,v.translateY,x,m),c(y.rotate,v.rotate,x,m),f(y.skewX,v.skewX,x,m),g(y.scaleX,y.scaleY,v.scaleX,v.scaleY,x,m),y=v=null,function(S){for(var k=-1,j=m.length,b;++k=0&&t._call.call(void 0,r),t=t._next;--Li}function hh(){Br=(yl=Io.now())+jl,Li=ko=0;try{zx()}finally{Li=0,$x(),Br=0}}function Dx(){var t=Io.now(),r=t-yl;r>Up&&(jl-=r,yl=t)}function $x(){for(var t,r=ml,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:ml=o);No=t,Gu(s)}function Gu(t){if(!Li){ko&&(ko=clearTimeout(ko));var r=t-Br;r>24?(t<1/0&&(ko=setTimeout(hh,t-Io.now()-jl)),_o&&(_o=clearInterval(_o))):(_o||(yl=Io.now(),_o=setInterval(Dx,Up)),Li=1,Yp(hh))}}function ph(t,r,o){var s=new vl;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Ox=Nl("start","end","cancel","interrupt"),Fx=[],Xp=0,gh=1,Xu=2,ul=3,mh=4,qu=5,cl=6;function bl(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;Hx(t,o,{name:r,index:s,group:a,on:Ox,tween:Fx,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Xp})}function uc(t,r){var o=sn(t,r);if(o.state>Xp)throw new Error("too late; already scheduled");return o}function wn(t,r){var o=sn(t,r);if(o.state>ul)throw new Error("too late; already running");return o}function sn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Hx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=Gp(u,0,o.time);function u(y){o.state=gh,o.timer.restart(c,o.delay,o.time),o.delay<=y&&c(y-o.delay)}function c(y){var v,x,m,S;if(o.state!==gh)return g();for(v in s)if(S=s[v],S.name===o.name){if(S.state===ul)return ph(c);S.state===mh?(S.state=cl,S.timer.stop(),S.on.call("interrupt",t,t.__data__,S.index,S.group),delete s[v]):+vXu&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function yw(t,r,o){var s,a,u=mw(r)?uc:wn;return function(){var c=u(this,t),f=c.on;f!==s&&(a=(s=f).copy()).on(r,o),c.on=a}}function vw(t,r){var o=this._id;return arguments.length<2?sn(this.node(),o).on.on(t):this.each(yw(o,t,r))}function xw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function ww(){return this.on("end.remove",xw(this._id))}function _w(t){var r=this._name,o=this._id;typeof t!="function"&&(t=ic(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function Yw(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function Ln(t,r,o){this.k=t,this.x=r,this.y=o}Ln.prototype={constructor:Ln,scale:function(t){return t===1?this:new Ln(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new Ln(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Cl=new Ln(1,0,0);Zp.prototype=Ln.prototype;function Zp(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Cl;return t.__zoom}function Pu(t){t.stopImmediatePropagation()}function So(t){t.preventDefault(),t.stopImmediatePropagation()}function Gw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Xw(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function yh(){return this.__zoom||Cl}function qw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Kw(){return navigator.maxTouchPoints||"ontouchstart"in this}function Qw(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function Jp(){var t=Gw,r=Xw,o=Qw,s=qw,a=Kw,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],f=250,g=al,y=Nl("start","zoom","end"),v,x,m,S=500,k=150,j=0,b=10;function _(C){C.property("__zoom",yh).on("wheel.zoom",z,{passive:!1}).on("mousedown.zoom",G).on("dblclick.zoom",ee).filter(a).on("touchstart.zoom",J).on("touchmove.zoom",ne).on("touchend.zoom touchcancel.zoom",q).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(C,W,U,Y){var T=C.selection?C.selection():C;T.property("__zoom",yh),C!==T?L(C,W,U,Y):T.interrupt().each(function(){A(this,arguments).event(Y).start().zoom(null,typeof W=="function"?W.apply(this,arguments):W).end()})},_.scaleBy=function(C,W,U,Y){_.scaleTo(C,function(){var T=this.__zoom.k,F=typeof W=="function"?W.apply(this,arguments):W;return T*F},U,Y)},_.scaleTo=function(C,W,U,Y){_.transform(C,function(){var T=r.apply(this,arguments),F=this.__zoom,B=U==null?E(T):typeof U=="function"?U.apply(this,arguments):U,M=F.invert(B),R=typeof W=="function"?W.apply(this,arguments):W;return o(N(P(F,R),B,M),T,c)},U,Y)},_.translateBy=function(C,W,U,Y){_.transform(C,function(){return o(this.__zoom.translate(typeof W=="function"?W.apply(this,arguments):W,typeof U=="function"?U.apply(this,arguments):U),r.apply(this,arguments),c)},null,Y)},_.translateTo=function(C,W,U,Y,T){_.transform(C,function(){var F=r.apply(this,arguments),B=this.__zoom,M=Y==null?E(F):typeof Y=="function"?Y.apply(this,arguments):Y;return o(Cl.translate(M[0],M[1]).scale(B.k).translate(typeof W=="function"?-W.apply(this,arguments):-W,typeof U=="function"?-U.apply(this,arguments):-U),F,c)},Y,T)};function P(C,W){return W=Math.max(u[0],Math.min(u[1],W)),W===C.k?C:new Ln(W,C.x,C.y)}function N(C,W,U){var Y=W[0]-U[0]*C.k,T=W[1]-U[1]*C.k;return Y===C.x&&T===C.y?C:new Ln(C.k,Y,T)}function E(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function L(C,W,U,Y){C.on("start.zoom",function(){A(this,arguments).event(Y).start()}).on("interrupt.zoom end.zoom",function(){A(this,arguments).event(Y).end()}).tween("zoom",function(){var T=this,F=arguments,B=A(T,F).event(Y),M=r.apply(T,F),R=U==null?E(M):typeof U=="function"?U.apply(T,F):U,re=Math.max(M[1][0]-M[0][0],M[1][1]-M[0][1]),ie=T.__zoom,ce=typeof W=="function"?W.apply(T,F):W,fe=g(ie.invert(R).concat(re/ie.k),ce.invert(R).concat(re/ce.k));return function(de){if(de===1)de=ce;else{var Q=fe(de),le=re/Q[2];de=new Ln(le,R[0]-Q[0]*le,R[1]-Q[1]*le)}B.zoom(null,de)}})}function A(C,W,U){return!U&&C.__zooming||new V(C,W)}function V(C,W){this.that=C,this.args=W,this.active=0,this.sourceEvent=null,this.extent=r.apply(C,W),this.taps=0}V.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,W){return this.mouse&&C!=="mouse"&&(this.mouse[1]=W.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=W.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=W.invert(this.touch1[0])),this.that.__zoom=W,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var W=Ot(this.that).datum();y.call(C,this.that,new Yw(C,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:y}),W)}};function z(C,...W){if(!t.apply(this,arguments))return;var U=A(this,W).event(C),Y=this.__zoom,T=Math.max(u[0],Math.min(u[1],Y.k*Math.pow(2,s.apply(this,arguments)))),F=en(C);if(U.wheel)(U.mouse[0][0]!==F[0]||U.mouse[0][1]!==F[1])&&(U.mouse[1]=Y.invert(U.mouse[0]=F)),clearTimeout(U.wheel);else{if(Y.k===T)return;U.mouse=[F,Y.invert(F)],dl(this),U.start()}So(C),U.wheel=setTimeout(B,k),U.zoom("mouse",o(N(P(Y,T),U.mouse[0],U.mouse[1]),U.extent,c));function B(){U.wheel=null,U.end()}}function G(C,...W){if(m||!t.apply(this,arguments))return;var U=C.currentTarget,Y=A(this,W,!0).event(C),T=Ot(C.view).on("mousemove.zoom",R,!0).on("mouseup.zoom",re,!0),F=en(C,U),B=C.clientX,M=C.clientY;zp(C.view),Pu(C),Y.mouse=[F,this.__zoom.invert(F)],dl(this),Y.start();function R(ie){if(So(ie),!Y.moved){var ce=ie.clientX-B,fe=ie.clientY-M;Y.moved=ce*ce+fe*fe>j}Y.event(ie).zoom("mouse",o(N(Y.that.__zoom,Y.mouse[0]=en(ie,U),Y.mouse[1]),Y.extent,c))}function re(ie){T.on("mousemove.zoom mouseup.zoom",null),Dp(ie.view,Y.moved),So(ie),Y.event(ie).end()}}function ee(C,...W){if(t.apply(this,arguments)){var U=this.__zoom,Y=en(C.changedTouches?C.changedTouches[0]:C,this),T=U.invert(Y),F=U.k*(C.shiftKey?.5:2),B=o(N(P(U,F),Y,T),r.apply(this,W),c);So(C),f>0?Ot(this).transition().duration(f).call(L,B,Y,C):Ot(this).call(_.transform,B,Y,C)}}function J(C,...W){if(t.apply(this,arguments)){var U=C.touches,Y=U.length,T=A(this,W,C.changedTouches.length===Y).event(C),F,B,M,R;for(Pu(C),B=0;B`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},To=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],eg=["Enter"," ","Escape"],tg={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Ai;(function(t){t.Strict="strict",t.Loose="loose"})(Ai||(Ai={}));var Fr;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(Fr||(Fr={}));var Ro;(function(t){t.Partial="partial",t.Full="full"})(Ro||(Ro={}));const ng={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var hr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(hr||(hr={}));var Lo;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(Lo||(Lo={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const vh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function rg(t){return t===null?null:t?"valid":"invalid"}const ig=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,Zw=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),dc=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),Ho=(t,r=[0,0])=>{const{width:o,height:s}=ln(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},Jw=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let f=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(f=c?r.nodeLookup.get(u):dc(u)?u:r.nodeLookup.get(u.id)),f?(o=!0,Ml(a,xl(f,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?Pl(s):{x:0,y:0,width:0,height:0}},Bo=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=Ml(o,xl(a)),s=!0)}),s?Pl(o):{x:0,y:0,width:0,height:0}},fc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const f=(r.x-o)/a,g=(r.y-s)/a,y=r.width/a,v=r.height/a,x=[];for(const m of t.values()){const{measured:S,selectable:k=!0,hidden:j=!1}=m;if(c&&!k||j)continue;const b=S.width??m.width??m.initialWidth??0,_=S.height??m.height??m.initialHeight??0,{x:P,y:N}=m.internals.positionAbsolute,E=ag(f,g,y,v,P,N,b,_),L=b*_,A=u&&E>0;(!m.internals.handleBounds||A||E>=L||m.dragging)&&x.push(m)}return x},e1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function t1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:f}=ln(a);u=c>0&&f>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function n1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const f=t1(t,c),g=Bo(f),y=pc(g,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(y,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function og({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),f=c.parentId?o.get(c.parentId):void 0,{x:g,y}=f?f.internals.positionAbsolute:{x:0,y:0},v=c.origin??s;let x=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!f)u==null||u("005",on.error005());else{const{width:S,height:k}=ln(f);S&&k&&(x=[[g,y],[g+S,y+k]])}else f&&Wr(c.extent)&&(x=[[c.extent[0][0]+g,c.extent[0][1]+y],[c.extent[1][0]+g,c.extent[1][1]+y]]);const m=Wr(x)?Vr(r,x,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",on.error015())),{position:{x:m.x-g+(c.measured.width??0)*v[0],y:m.y-y+(c.measured.height??0)*v[1]},positionAbsolute:m}}async function r1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(m=>m.id)),c=[];for(const m of o){if(m.deletable===!1)continue;const S=u.has(m.id),k=!S&&m.parentId&&c.find(j=>j.id===m.parentId);(S||k)&&c.push(m)}const f=new Set(r.map(m=>m.id)),g=s.filter(m=>m.deletable!==!1),v=e1(c,g);for(const m of g)f.has(m.id)&&!v.find(k=>k.id===m.id)&&v.push(m);if(!a)return{edges:v,nodes:c};const x=await a({nodes:c,edges:v});return typeof x=="boolean"?x?{edges:v,nodes:c}:{edges:[],nodes:[]}:x}const zi=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),Vr=(t={x:0,y:0},r,o)=>({x:zi(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:zi(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function sg(t,r,o){const{width:s,height:a}=ln(o),{x:u,y:c}=o.internals.positionAbsolute;return Vr(t,[[u,c],[u+s,c+a]],r)}const xh=(t,r,o)=>to?-zi(Math.abs(t-o),1,r)/r:0,hc=(t,r,o=15,s=40)=>{const a=xh(t.x,s,r.width-s)*o,u=xh(t.y,s,r.height-s)*o;return[a,u]},Ml=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),Ku=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),Pl=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),Ao=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=dc(t)?t.internals.positionAbsolute:Ho(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},xl=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=dc(t)?t.internals.positionAbsolute:Ho(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},lg=(t,r)=>Pl(Ml(Ku(t),Ku(r))),ag=(t,r,o,s,a,u,c,f)=>{const g=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),y=Math.max(0,Math.min(r+s,u+f)-Math.max(r,u));return Math.ceil(g*y)},wl=(t,r)=>ag(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),wh=t=>nn(t.width)&&nn(t.height)&&nn(t.x)&&nn(t.y),nn=t=>!isNaN(t)&&isFinite(t),ug=(t,r)=>(o,s)=>{},Vo=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),Wo=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const f={x:(t-o)/a,y:(r-s)/a};return u?Vo(f,c):f},Di=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Mi(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function i1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Mi(t,o),a=Mi(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Mi(t.top??t.y??0,o),a=Mi(t.bottom??t.y??0,o),u=Mi(t.left??t.x??0,r),c=Mi(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function o1(t,r,o,s,a,u){const{x:c,y:f}=Di(t,[r,o,s]),{x:g,y}=Di({x:t.x+t.width,y:t.y+t.height},[r,o,s]),v=a-g,x=u-y;return{left:Math.floor(c),top:Math.floor(f),right:Math.floor(v),bottom:Math.floor(x)}}const pc=(t,r,o,s,a,u)=>{const c=i1(u,r,o),f=(r-c.x)/t.width,g=(o-c.y)/t.height,y=Math.min(f,g),v=zi(y,s,a),x=t.x+t.width/2,m=t.y+t.height/2,S=r/2-x*v,k=o/2-m*v,j=o1(t,S,k,v,r,o),b={left:Math.min(j.left-c.left,0),top:Math.min(j.top-c.top,0),right:Math.min(j.right-c.right,0),bottom:Math.min(j.bottom-c.bottom,0)};return{x:S-b.left+b.right,y:k-b.top+b.bottom,zoom:v}},zo=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function Wr(t){return t!=null&&t!=="parent"}function ln(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function cg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function dg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const f=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*f[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*f[1]}return u}function _h(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function s1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function l1(t){return{...tg,...t||{}}}function jo(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=rn(t),f=Wo({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:g,y}=o?Vo(f,r):f;return{xSnapped:g,ySnapped:y,...f}}const gc=t=>({width:t.offsetWidth,height:t.offsetHeight}),fg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},a1=["INPUT","SELECT","TEXTAREA"];function hg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:a1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const pg=t=>"clientX"in t,rn=(t,r)=>{var u,c;const o=pg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},Sh=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const f=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(f.left-o.left)/s,y:(f.top-o.top)/s,...gc(c)}})};function gg({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:f}){const g=t*.125+a*.375+c*.375+o*.125,y=r*.125+u*.375+f*.375+s*.125,v=Math.abs(g-t),x=Math.abs(y-r);return[g,y,v,x]}function tl(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function kh({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case Se.Left:return[r-tl(r-s,u),o];case Se.Right:return[r+tl(s-r,u),o];case Se.Top:return[r,o-tl(o-a,u)];case Se.Bottom:return[r,o+tl(a-o,u)]}}function mg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top,curvature:c=.25}){const[f,g]=kh({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[y,v]=kh({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[x,m,S,k]=gg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:f,sourceControlY:g,targetControlX:y,targetControlY:v});return[`M${t},${r} C${f},${g} ${y},${v} ${s},${a}`,x,m,S,k]}function yg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const d1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,f1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),h1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",on.error006()),r;const s=o.getEdgeId||d1;let a;return ig(t)?a={...t}:a={...t,id:s(t)},f1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function vg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,f]=yg({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,f]}const Nh={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},p1=({source:t,sourcePosition:r=Se.Bottom,target:o})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function g1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:s=Se.Top,center:a,offset:u,stepPosition:c}){const f=Nh[r],g=Nh[s],y={x:t.x+f.x*u,y:t.y+f.y*u},v={x:o.x+g.x*u,y:o.y+g.y*u},x=p1({source:y,sourcePosition:r,target:v}),m=x.x!==0?"x":"y",S=x[m];let k=[],j,b;const _={x:0,y:0},P={x:0,y:0},[,,N,E]=yg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(f[m]*g[m]===-1){m==="x"?(j=a.x??y.x+(v.x-y.x)*c,b=a.y??(y.y+v.y)/2):(j=a.x??(y.x+v.x)/2,b=a.y??y.y+(v.y-y.y)*c);const z=[{x:j,y:y.y},{x:j,y:v.y}],G=[{x:y.x,y:b},{x:v.x,y:b}];f[m]===S?k=m==="x"?z:G:k=m==="x"?G:z}else{const z=[{x:y.x,y:v.y}],G=[{x:v.x,y:y.y}];if(m==="x"?k=f.x===S?G:z:k=f.y===S?z:G,r===s){const C=Math.abs(t[m]-o[m]);if(C<=u){const W=Math.min(u-1,u-C);f[m]===S?_[m]=(y[m]>t[m]?-1:1)*W:P[m]=(v[m]>o[m]?-1:1)*W}}if(r!==s){const C=m==="x"?"y":"x",W=f[m]===g[C],U=y[C]>v[C],Y=y[C]=q?(j=(ee.x+J.x)/2,b=k[0].y):(j=k[0].x,b=(ee.y+J.y)/2)}const L={x:y.x+_.x,y:y.y+_.y},A={x:v.x+P.x,y:v.y+P.y};return[[t,...L.x!==k[0].x||L.y!==k[0].y?[L]:[],...k,...A.x!==k[k.length-1].x||A.y!==k[k.length-1].y?[A]:[],o],j,b,N,E]}function m1(t,r,o,s){const a=Math.min(Eh(t,r)/2,Eh(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const y=t.xo.id===r):t[0])||null}function Zu(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function v1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,f)=>([f.markerStart||s,f.markerEnd||a].forEach(g=>{if(g&&typeof g=="object"){const y=Zu(g,r);u.has(y)||(c.push({id:y,color:g.color||o,...g}),u.add(y))}}),c),[]).sort((c,f)=>c.id.localeCompare(f.id))}const xg=1e3,x1=10,mc={nodeOrigin:[0,0],nodeExtent:To,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},w1={...mc,checkEquality:!0};function yc(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function _1(t,r,o){const s=yc(mc,o);for(const a of t.values())if(a.parentId)xc(a,t,r,s);else{const u=Ho(a,s.nodeOrigin),c=Wr(a.extent)?a.extent:s.nodeExtent,f=Vr(u,c,ln(a));a.internals.positionAbsolute=f}}function S1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function vc(t){return t==="manual"}function Ju(t,r,o,s={}){var v,x;const a=yc(w1,s),u={i:0},c=new Map(r),f=a!=null&&a.elevateNodesOnSelect&&!vc(a.zIndexMode)?xg:0;let g=t.length>0,y=!1;r.clear(),o.clear();for(const m of t){let S=c.get(m.id);if(a.checkEquality&&m===(S==null?void 0:S.internals.userNode))r.set(m.id,S);else{const k=Ho(m,a.nodeOrigin),j=Wr(m.extent)?m.extent:a.nodeExtent,b=Vr(k,j,ln(m));S={...a.defaults,...m,measured:{width:(v=m.measured)==null?void 0:v.width,height:(x=m.measured)==null?void 0:x.height},internals:{positionAbsolute:b,handleBounds:S1(m,S),z:wg(m,f,a.zIndexMode),userNode:m}},r.set(m.id,S)}(S.measured===void 0||S.measured.width===void 0||S.measured.height===void 0)&&!S.hidden&&(g=!1),m.parentId&&xc(S,r,o,s,u),y||(y=m.selected??!1)}return{nodesInitialized:g,hasSelectedNodes:y}}function k1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function xc(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:f,zIndexMode:g}=yc(mc,s),y=t.parentId,v=r.get(y);if(!v){console.warn(`Parent node ${y} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}k1(t,o),a&&!v.parentId&&v.internals.rootParentIndex===void 0&&g==="auto"&&(v.internals.rootParentIndex=++a.i,v.internals.z=v.internals.z+a.i*x1),a&&v.internals.rootParentIndex!==void 0&&(a.i=v.internals.rootParentIndex);const x=u&&!vc(g)?xg:0,{x:m,y:S,z:k}=N1(t,v,c,f,x,g),{positionAbsolute:j}=t.internals,b=m!==j.x||S!==j.y;(b||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:b?{x:m,y:S}:j,z:k}})}function wg(t,r,o){const s=nn(t.zIndex)?t.zIndex:0;return vc(o)?s:s+(t.selected?r:0)}function N1(t,r,o,s,a,u){const{x:c,y:f}=r.internals.positionAbsolute,g=ln(t),y=Ho(t,o),v=Wr(t.extent)?Vr(y,t.extent,g):y;let x=Vr({x:c+v.x,y:f+v.y},s,g);t.extent==="parent"&&(x=sg(x,g,r));const m=wg(t,a,u),S=r.internals.z??0;return{x:x.x,y:x.y,z:S>=m?S+1:m}}function wc(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const f of t){const g=r.get(f.parentId);if(!g)continue;const y=((c=u.get(f.parentId))==null?void 0:c.expandedRect)??Ao(g),v=lg(y,f.rect);u.set(f.parentId,{expandedRect:v,parent:g})}return u.size>0&&u.forEach(({expandedRect:f,parent:g},y)=>{var N;const v=g.internals.positionAbsolute,x=ln(g),m=g.origin??s,S=f.x0||k>0||_||P)&&(a.push({id:y,type:"position",position:{x:g.position.x-S+_,y:g.position.y-k+P}}),(N=o.get(y))==null||N.forEach(E=>{t.some(L=>L.id===E.id)||a.push({id:E.id,type:"position",position:{x:E.position.x+S,y:E.position.y+k}})})),(x.width0){const S=wc(m,r,o,a);y.push(...S)}return{changes:y,updatedInternals:g}}async function j1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Mh(t,r,o,s,a,u){let c=a;const f=s.get(c)||new Map;s.set(c,f.set(o,r)),c=`${a}-${t}`;const g=s.get(c)||new Map;if(s.set(c,g.set(o,r)),u){c=`${a}-${t}-${u}`;const y=s.get(c)||new Map;s.set(c,y.set(o,r))}}function _g(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:f=null}=s,g={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:f},y=`${a}-${c}--${u}-${f}`,v=`${u}-${f}--${a}-${c}`;Mh("source",g,v,t,a,c),Mh("target",g,y,t,u,f),r.set(s.id,s)}}function Sg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:Sg(o,r):!1}function Ph(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function b1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!Sg(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const f=t.get(u);f&&a.set(u,{id:u,position:f.position||{x:0,y:0},distance:{x:o.x-f.internals.positionAbsolute.x,y:o.y-f.internals.positionAbsolute.y},extent:f.extent,parentId:f.parentId,origin:f.origin,expandParent:f.expandParent,internals:{positionAbsolute:f.internals.positionAbsolute||{x:0,y:0}},measured:{width:f.measured.width??0,height:f.measured.height??0}})}return a}function Iu({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,f,g;const a=[];for(const[y,v]of r){const x=(c=o.get(y))==null?void 0:c.internals.userNode;x&&a.push({...x,position:v.position,dragging:s})}if(!t)return[a[0],a];const u=(f=o.get(t))==null?void 0:f.internals.userNode;return[u?{...u,position:((g=r.get(t))==null?void 0:g.position)||u.position,dragging:s}:a[0],a]}function C1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=Vo(u,r);return{x:c.x-u.x,y:c.y-u.y}}function M1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,f=new Map,g=!1,y={x:0,y:0},v=null,x=!1,m=null,S=!1,k=!1,j=null;function b({noDragClassName:P,handleSelector:N,domNode:E,isSelectable:L,nodeId:A,nodeClickDistance:V=0}){m=Ot(E);function z({x:ne,y:q}){const{nodeLookup:C,nodeExtent:W,snapGrid:U,snapToGrid:Y,nodeOrigin:T,onNodeDrag:F,onSelectionDrag:B,onError:M,updateNodePositions:R}=r();u={x:ne,y:q};let re=!1;const ie=f.size>1,ce=ie&&W?Ku(Bo(f)):null,fe=ie&&Y?C1({dragItems:f,snapGrid:U,x:ne,y:q}):null;for(const[de,Q]of f){if(!C.has(de))continue;let le={x:ne-Q.distance.x,y:q-Q.distance.y};Y&&(le=fe?{x:Math.round(le.x+fe.x),y:Math.round(le.y+fe.y)}:Vo(le,U));let me=null;if(ie&&W&&!Q.extent&&ce){const{positionAbsolute:pe}=Q.internals,be=pe.x-ce.x+W[0][0],Pe=pe.x+Q.measured.width-ce.x2+W[1][0],Ce=pe.y-ce.y+W[0][1],Re=pe.y+Q.measured.height-ce.y2+W[1][1];me=[[be,Ce],[Pe,Re]]}const{position:ke,positionAbsolute:xe}=og({nodeId:de,nextPosition:le,nodeLookup:C,nodeExtent:me||W,nodeOrigin:T,onError:M});re=re||Q.position.x!==ke.x||Q.position.y!==ke.y,Q.position=ke,Q.internals.positionAbsolute=xe}if(k=k||re,!!re&&(R(f,!0),j&&(s||F||!A&&B))){const[de,Q]=Iu({nodeId:A,dragItems:f,nodeLookup:C});s==null||s(j,f,de,Q),F==null||F(j,de,Q),A||B==null||B(j,Q)}}async function G(){if(!v)return;const{transform:ne,panBy:q,autoPanSpeed:C,autoPanOnNodeDrag:W}=r();if(!W){g=!1,cancelAnimationFrame(c);return}const[U,Y]=hc(y,v,C);(U!==0||Y!==0)&&(u.x=(u.x??0)-U/ne[2],u.y=(u.y??0)-Y/ne[2],await q({x:U,y:Y})&&z(u)),c=requestAnimationFrame(G)}function ee(ne){var ie;const{nodeLookup:q,multiSelectionActive:C,nodesDraggable:W,transform:U,snapGrid:Y,snapToGrid:T,selectNodesOnDrag:F,onNodeDragStart:B,onSelectionDragStart:M,unselectNodesAndEdges:R}=r();x=!0,(!F||!L)&&!C&&A&&((ie=q.get(A))!=null&&ie.selected||R()),L&&F&&A&&(t==null||t(A));const re=jo(ne.sourceEvent,{transform:U,snapGrid:Y,snapToGrid:T,containerBounds:v});if(u=re,f=b1(q,W,re,A),f.size>0&&(o||B||!A&&M)){const[ce,fe]=Iu({nodeId:A,dragItems:f,nodeLookup:q});o==null||o(ne.sourceEvent,f,ce,fe),B==null||B(ne.sourceEvent,ce,fe),A||M==null||M(ne.sourceEvent,fe)}}const J=$p().clickDistance(V).on("start",ne=>{const{domNode:q,nodeDragThreshold:C,transform:W,snapGrid:U,snapToGrid:Y}=r();v=(q==null?void 0:q.getBoundingClientRect())||null,S=!1,k=!1,j=ne.sourceEvent,C===0&&ee(ne),u=jo(ne.sourceEvent,{transform:W,snapGrid:U,snapToGrid:Y,containerBounds:v}),y=rn(ne.sourceEvent,v)}).on("drag",ne=>{const{autoPanOnNodeDrag:q,transform:C,snapGrid:W,snapToGrid:U,nodeDragThreshold:Y,nodeLookup:T}=r(),F=jo(ne.sourceEvent,{transform:C,snapGrid:W,snapToGrid:U,containerBounds:v});if(j=ne.sourceEvent,(ne.sourceEvent.type==="touchmove"&&ne.sourceEvent.touches.length>1||A&&!T.has(A))&&(S=!0),!S){if(!g&&q&&x&&(g=!0,G()),!x){const B=rn(ne.sourceEvent,v),M=B.x-y.x,R=B.y-y.y;Math.sqrt(M*M+R*R)>Y&&ee(ne)}(u.x!==F.xSnapped||u.y!==F.ySnapped)&&f&&x&&(y=rn(ne.sourceEvent,v),z(F))}}).on("end",ne=>{if(!x||S){S&&f.size>0&&r().updateNodePositions(f,!1);return}if(g=!1,x=!1,cancelAnimationFrame(c),f.size>0){const{nodeLookup:q,updateNodePositions:C,onNodeDragStop:W,onSelectionDragStop:U}=r();if(k&&(C(f,!1),k=!1),a||W||!A&&U){const[Y,T]=Iu({nodeId:A,dragItems:f,nodeLookup:q,dragging:!1});a==null||a(ne.sourceEvent,f,Y,T),W==null||W(ne.sourceEvent,Y,T),A||U==null||U(ne.sourceEvent,T)}}}).filter(ne=>{const q=ne.target;return!ne.button&&(!P||!Ph(q,`.${P}`,E))&&(!N||Ph(q,N,E))});m.call(J)}function _(){m==null||m.on(".drag",null)}return{update:b,destroy:_}}function P1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())wl(a,Ao(u))>0&&s.push(u);return s}const I1=250;function T1(t,r,o,s){var f,g;let a=[],u=1/0;const c=P1(t,o,r+I1);for(const y of c){const v=[...((f=y.internals.handleBounds)==null?void 0:f.source)??[],...((g=y.internals.handleBounds)==null?void 0:g.target)??[]];for(const x of v){if(s.nodeId===x.nodeId&&s.type===x.type&&s.id===x.id)continue;const{x:m,y:S}=Ur(y,x,x.position,!0),k=Math.sqrt(Math.pow(m-t.x,2)+Math.pow(S-t.y,2));k>r||(k1){const y=s.type==="source"?"target":"source";return a.find(v=>v.type===y)??a[0]}return a[0]}function kg(t,r,o,s,a,u=!1){var y,v,x;const c=s.get(t);if(!c)return null;const f=a==="strict"?(y=c.internals.handleBounds)==null?void 0:y[r]:[...((v=c.internals.handleBounds)==null?void 0:v.source)??[],...((x=c.internals.handleBounds)==null?void 0:x.target)??[]],g=(o?f==null?void 0:f.find(m=>m.id===o):f==null?void 0:f[0])??null;return g&&u?{...g,...Ur(c,g,g.position,!0)}:g}function Ng(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function R1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const Eg=()=>!0;function L1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:f,nodeLookup:g,lib:y,autoPanOnConnect:v,flowId:x,panBy:m,cancelConnection:S,onConnectStart:k,onConnect:j,onConnectEnd:b,isValidConnection:_=Eg,onReconnectEnd:P,updateConnection:N,getTransform:E,getFromHandle:L,autoPanSpeed:A,dragThreshold:V=1,handleDomNode:z}){const G=fg(t.target);let ee=0,J;const{x:ne,y:q}=rn(t),C=Ng(u,z),W=f==null?void 0:f.getBoundingClientRect();let U=!1;if(!W||!C)return;const Y=kg(a,C,s,g,r);if(!Y)return;let T=rn(t,W),F=!1,B=null,M=!1,R=null;function re(){if(!v||!W)return;const[ke,xe]=hc(T,W,A);m({x:ke,y:xe}),ee=requestAnimationFrame(re)}const ie={...Y,nodeId:a,type:C,position:Y.position},ce=g.get(a);let de={inProgress:!0,isValid:null,from:Ur(ce,ie,Se.Left,!0),fromHandle:ie,fromPosition:ie.position,fromNode:ce,to:T,toHandle:null,toPosition:vh[ie.position],toNode:null,pointer:T};function Q(){U=!0,N(de),k==null||k(t,{nodeId:a,handleId:s,handleType:C})}V===0&&Q();function le(ke){if(!U){const{x:Re,y:tt}=rn(ke),nt=Re-ne,Je=tt-q;if(!(nt*nt+Je*Je>V*V))return;Q()}if(!L()||!ie){me(ke);return}const xe=E();T=rn(ke,W),J=T1(Wo(T,xe,!1,[1,1]),o,g,ie),F||(re(),F=!0);const pe=jg(ke,{handle:J,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:_,doc:G,lib:y,flowId:x,nodeLookup:g});R=pe.handleDomNode,B=pe.connection,M=R1(!!J,pe.isValid);const be=g.get(a),Pe=be?Ur(be,ie,Se.Left,!0):de.from,Ce={...de,from:Pe,isValid:M,to:pe.toHandle&&M?Di({x:pe.toHandle.x,y:pe.toHandle.y},xe):T,toHandle:pe.toHandle,toPosition:M&&pe.toHandle?pe.toHandle.position:vh[ie.position],toNode:pe.toHandle?g.get(pe.toHandle.nodeId):null,pointer:T};N(Ce),de=Ce}function me(ke){if(!("touches"in ke&&ke.touches.length>0)){if(U){(J||R)&&B&&M&&(j==null||j(B));const{inProgress:xe,...pe}=de,be={...pe,toPosition:de.toHandle?de.toPosition:null};b==null||b(ke,be),u&&(P==null||P(ke,be))}S(),cancelAnimationFrame(ee),F=!1,M=!1,B=null,R=null,G.removeEventListener("mousemove",le),G.removeEventListener("mouseup",me),G.removeEventListener("touchmove",le),G.removeEventListener("touchend",me)}}G.addEventListener("mousemove",le),G.addEventListener("mouseup",me),G.addEventListener("touchmove",le),G.addEventListener("touchend",me)}function jg(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:f,flowId:g,isValidConnection:y=Eg,nodeLookup:v}){const x=u==="target",m=r?c.querySelector(`.${f}-flow__handle[data-id="${g}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:S,y:k}=rn(t),j=c.elementFromPoint(S,k),b=j!=null&&j.classList.contains(`${f}-flow__handle`)?j:m,_={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const P=Ng(void 0,b),N=b.getAttribute("data-nodeid"),E=b.getAttribute("data-handleid"),L=b.classList.contains("connectable"),A=b.classList.contains("connectableend");if(!N||!P)return _;const V={source:x?N:s,sourceHandle:x?E:a,target:x?s:N,targetHandle:x?a:E};_.connection=V;const G=L&&A&&(o===Ai.Strict?x&&P==="source"||!x&&P==="target":N!==s||E!==a);_.isValid=G&&y(V),_.toHandle=kg(N,P,E,v,o,!0)}return _}const ec={onPointerDown:L1,isValid:jg};function A1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Ot(t);function u({translateExtent:f,width:g,height:y,zoomStep:v=1,pannable:x=!0,zoomable:m=!0,inversePan:S=!1}){const k=N=>{if(N.sourceEvent.type!=="wheel"||!r)return;const E=o(),L=N.sourceEvent.ctrlKey&&zo()?10:1,A=-N.sourceEvent.deltaY*(N.sourceEvent.deltaMode===1?.05:N.sourceEvent.deltaMode?1:.002)*v,V=E[2]*Math.pow(2,A*L);r.scaleTo(V)};let j=[0,0];const b=N=>{(N.sourceEvent.type==="mousedown"||N.sourceEvent.type==="touchstart")&&(j=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY])},_=N=>{const E=o();if(N.sourceEvent.type!=="mousemove"&&N.sourceEvent.type!=="touchmove"||!r)return;const L=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY],A=[L[0]-j[0],L[1]-j[1]];j=L;const V=s()*Math.max(E[2],Math.log(E[2]))*(S?-1:1),z={x:E[0]-A[0]*V,y:E[1]-A[1]*V},G=[[0,0],[g,y]];r.setViewportConstrained({x:z.x,y:z.y,zoom:E[2]},G,f)},P=Jp().on("start",b).on("zoom",x?_:null).on("zoom.wheel",m?k:null);a.call(P,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:en}}const Il=t=>({x:t.x,y:t.y,zoom:t.k}),Tu=({x:t,y:r,zoom:o})=>Cl.translate(t,r).scale(o),fr=(t,r)=>t.target.closest(`.${r}`),bg=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),z1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Ru=(t,r=0,o=z1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Cg=t=>{const r=t.ctrlKey&&zo()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function D1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:f,onPanZoom:g,onPanZoomEnd:y}){return v=>{if(fr(v,r))return v.ctrlKey&&v.preventDefault(),!1;v.preventDefault(),v.stopImmediatePropagation();const x=o.property("__zoom").k||1;if(v.ctrlKey&&c){const b=en(v),_=Cg(v),P=x*Math.pow(2,_);s.scaleTo(o,P,b,v);return}const m=v.deltaMode===1?20:1;let S=a===Fr.Vertical?0:v.deltaX*m,k=a===Fr.Horizontal?0:v.deltaY*m;!zo()&&v.shiftKey&&a!==Fr.Vertical&&(S=v.deltaY*m,k=0),s.translateBy(o,-(S/x)*u,-(k/x)*u,{internal:!0});const j=Il(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?g==null||g(v,j):(t.isPanScrolling=!0,f==null||f(v,j)),t.panScrollTimeout=setTimeout(()=>{y==null||y(v,j),t.isPanScrolling=!1},150)}}function $1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,f=fr(s,t);if(s.ctrlKey&&u&&f&&s.preventDefault(),c||f)return null;s.preventDefault(),o.call(this,s,a)}}function O1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,f;if((u=s.sourceEvent)!=null&&u.internal)return;const a=Il(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((f=s.sourceEvent)==null?void 0:f.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function F1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,f;t.usedRightMouseButton=!!(o&&bg(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((f=u.sourceEvent)!=null&&f.internal)&&(a==null||a(u.sourceEvent,Il(u.transform)))}}function H1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var f;if(!((f=c.sourceEvent)!=null&&f.internal)&&(t.isZoomingOrPanning=!1,u&&bg(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const g=Il(c.transform);t.prevViewport=g,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,g)},o?150:0)}}}function B1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:f,noWheelClassName:g,noPanClassName:y,lib:v,connectionInProgress:x}){return m=>{var _;const S=r||o,k=s&&m.ctrlKey,j=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(fr(m,`${v}-flow__node`)||fr(m,`${v}-flow__edge`)||fr(m,`${v}-flow__selection`)||fr(m,`${v}-flow__nodesselection`)))return!0;if(!a&&!S&&!u&&!c&&!s||f||x&&!j||fr(m,g)&&j||fr(m,y)&&(!j||u&&j&&!r)||!s&&m.ctrlKey&&j)return!1;if(!s&&m.type==="touchstart"&&((_=m.touches)==null?void 0:_.length)>1)return m.preventDefault(),!1;if(!S&&!u&&!k&&j||!a&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(a)&&!a.includes(m.button)&&m.type==="mousedown")return!1;const b=Array.isArray(a)&&a.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||j||t)&&b}}function V1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:f,onDraggingChange:g}){const y={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},v=t.getBoundingClientRect();let x=[[0,0],[v.width,v.height]];const m=typeof ResizeObserver<"u"?new ResizeObserver(q=>{const C=q[0];C&&(x=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;m==null||m.observe(t);const S=Jp().extent(()=>x).scaleExtent([r,o]).translateExtent(s),k=Ot(t).call(S);E({x:a.x,y:a.y,zoom:zi(a.zoom,r,o)},[[0,0],[v.width,v.height]],s);const j=k.on("wheel.zoom"),b=k.on("dblclick.zoom");S.wheelDelta(Cg);async function _(q,C){return k?new Promise(W=>{S==null||S.interpolate((C==null?void 0:C.interpolate)==="linear"?Eo:al).transform(Ru(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>W(!0)),q)}):!1}function P({noWheelClassName:q,noPanClassName:C,onPaneContextMenu:W,userSelectionActive:U,panOnScroll:Y,panOnDrag:T,panOnScrollMode:F,panOnScrollSpeed:B,preventScrolling:M,zoomOnPinch:R,zoomOnScroll:re,zoomOnDoubleClick:ie,panActivationKeyPressed:ce=!1,zoomActivationKeyPressed:fe,lib:de,onTransformChange:Q,connectionInProgress:le,paneClickDistance:me,selectionOnDrag:ke}){U&&!y.isZoomingOrPanning&&N();const xe=Y&&!fe&&!U;S.clickDistance(ke?1/0:!nn(me)||me<0?0:me);const pe=xe?D1({zoomPanValues:y,noWheelClassName:q,d3Selection:k,d3Zoom:S,panOnScrollMode:F,panOnScrollSpeed:B,zoomOnPinch:R,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:f}):$1({noWheelClassName:q,preventScrolling:M,d3ZoomHandler:j});k.on("wheel.zoom",pe,{passive:!1});const be=O1({zoomPanValues:y,onDraggingChange:g,onPanZoomStart:c});S.on("start",be);const Pe=F1({zoomPanValues:y,panOnDrag:T,onPaneContextMenu:!!W,onPanZoom:u,onTransformChange:Q});S.on("zoom",Pe);const Ce=H1({zoomPanValues:y,panOnDrag:T,panOnScroll:Y,onPaneContextMenu:W,onPanZoomEnd:f,onDraggingChange:g});S.on("end",Ce);const Re=B1({panActivationKeyPressed:ce,zoomActivationKeyPressed:fe,panOnDrag:T,zoomOnScroll:re,panOnScroll:Y,zoomOnDoubleClick:ie,zoomOnPinch:R,userSelectionActive:U,noPanClassName:C,noWheelClassName:q,lib:de,connectionInProgress:le});S.filter(Re),ie?k.on("dblclick.zoom",b):k.on("dblclick.zoom",null)}function N(){S.on("zoom",null)}async function E(q,C,W){const U=Tu(q),Y=S==null?void 0:S.constrain()(U,C,W);return Y&&await _(Y),Y}async function L(q,C){const W=Tu(q);return await _(W,C),W}function A(q){if(k){const C=Tu(q),W=k.property("__zoom");(W.k!==q.zoom||W.x!==q.x||W.y!==q.y)&&(S==null||S.transform(k,C,null,{sync:!0}))}}function V(){const q=k?Zp(k.node()):{x:0,y:0,k:1};return{x:q.x,y:q.y,zoom:q.k}}async function z(q,C){return k?new Promise(W=>{S==null||S.interpolate((C==null?void 0:C.interpolate)==="linear"?Eo:al).scaleTo(Ru(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>W(!0)),q)}):!1}async function G(q,C){return k?new Promise(W=>{S==null||S.interpolate((C==null?void 0:C.interpolate)==="linear"?Eo:al).scaleBy(Ru(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>W(!0)),q)}):!1}function ee(q){S==null||S.scaleExtent(q)}function J(q){S==null||S.translateExtent(q)}function ne(q){const C=!nn(q)||q<0?0:q;S==null||S.clickDistance(C)}return{update:P,destroy:N,setViewport:L,setViewportConstrained:E,getViewport:V,scaleTo:z,scaleBy:G,setScaleExtent:ee,setTranslateExtent:J,syncViewport:A,setClickDistance:ne}}var $i;(function(t){t.Line="line",t.Handle="handle"})($i||($i={}));function W1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,f=o-s,g=[c>0?1:c<0?-1:0,f>0?1:f<0?-1:0];return c&&a&&(g[0]=g[0]*-1),f&&u&&(g[1]=g[1]*-1),g}function Ih(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function cr(t,r){return Math.max(0,r-t)}function dr(t,r){return Math.max(0,t-r)}function nl(t,r,o){return Math.max(0,r-t,t-o)}function Th(t,r){return t?!r:r}function U1(t,r,o,s,a,u,c,f){let{affectsX:g,affectsY:y}=r;const{isHorizontal:v,isVertical:x}=r,m=v&&x,{xSnapped:S,ySnapped:k}=o,{minWidth:j,maxWidth:b,minHeight:_,maxHeight:P}=s,{x:N,y:E,width:L,height:A,aspectRatio:V}=t;let z=Math.floor(v?S-t.pointerX:0),G=Math.floor(x?k-t.pointerY:0);const ee=L+(g?-z:z),J=A+(y?-G:G),ne=-u[0]*L,q=-u[1]*A;let C=nl(ee,j,b),W=nl(J,_,P);if(c){let T=0,F=0;g&&z<0?T=cr(N+z+ne,c[0][0]):!g&&z>0&&(T=dr(N+ee+ne,c[1][0])),y&&G<0?F=cr(E+G+q,c[0][1]):!y&&G>0&&(F=dr(E+J+q,c[1][1])),C=Math.max(C,T),W=Math.max(W,F)}if(f){let T=0,F=0;g&&z>0?T=dr(N+z,f[0][0]):!g&&z<0&&(T=cr(N+ee,f[1][0])),y&&G>0?F=dr(E+G,f[0][1]):!y&&G<0&&(F=cr(E+J,f[1][1])),C=Math.max(C,T),W=Math.max(W,F)}if(a){if(v){const T=nl(ee/V,_,P)*V;if(C=Math.max(C,T),c){let F=0;!g&&!y||g&&!y&&m?F=dr(E+q+ee/V,c[1][1])*V:F=cr(E+q+(g?z:-z)/V,c[0][1])*V,C=Math.max(C,F)}if(f){let F=0;!g&&!y||g&&!y&&m?F=cr(E+ee/V,f[1][1])*V:F=dr(E+(g?z:-z)/V,f[0][1])*V,C=Math.max(C,F)}}if(x){const T=nl(J*V,j,b)/V;if(W=Math.max(W,T),c){let F=0;!g&&!y||y&&!g&&m?F=dr(N+J*V+ne,c[1][0])/V:F=cr(N+(y?G:-G)*V+ne,c[0][0])/V,W=Math.max(W,F)}if(f){let F=0;!g&&!y||y&&!g&&m?F=cr(N+J*V,f[1][0])/V:F=dr(N+(y?G:-G)*V,f[0][0])/V,W=Math.max(W,F)}}}G=G+(G<0?W:-W),z=z+(z<0?C:-C),a&&(m?ee>J*V?G=(Th(g,y)?-z:z)/V:z=(Th(g,y)?-G:G)*V:v?(G=z/V,y=g):(z=G*V,g=y));const U=g?N+z:N,Y=y?E+G:E;return{width:L+(g?-z:z),height:A+(y?-G:G),x:u[0]*z*(g?-1:1)+U,y:u[1]*G*(y?-1:1)+Y}}const Mg={width:0,height:0,x:0,y:0},Y1={...Mg,pointerX:0,pointerY:0,aspectRatio:1};function G1(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,f=o[0]*u,g=o[1]*c;return[[s-f,a-g],[s+u-f,a+c-g]]}function X1({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Ot(t);let c={controlDirection:Ih("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function f({controlPosition:y,boundaries:v,keepAspectRatio:x,resizeDirection:m,onResizeStart:S,onResize:k,onResizeEnd:j,shouldResize:b}){let _={...Mg},P={...Y1};c={boundaries:v,resizeDirection:m,keepAspectRatio:x,controlDirection:Ih(y)};let N,E=null,L=[],A,V,z,G=!1;const ee=$p().on("start",J=>{const{nodeLookup:ne,transform:q,snapGrid:C,snapToGrid:W,nodeOrigin:U,paneDomNode:Y}=o();if(N=ne.get(r),!N)return;E=(Y==null?void 0:Y.getBoundingClientRect())??null;const{xSnapped:T,ySnapped:F}=jo(J.sourceEvent,{transform:q,snapGrid:C,snapToGrid:W,containerBounds:E});_={width:N.measured.width??0,height:N.measured.height??0,x:N.position.x??0,y:N.position.y??0},P={..._,pointerX:T,pointerY:F,aspectRatio:_.width/_.height},A=void 0,V=Wr(N.extent)?N.extent:void 0,N.parentId&&(N.extent==="parent"||N.expandParent)&&(A=ne.get(N.parentId)),A&&N.extent==="parent"&&(V=[[0,0],[A.measured.width,A.measured.height]]),L=[],z=void 0;for(const[B,M]of ne)if(M.parentId===r&&(L.push({id:B,position:{...M.position},extent:M.extent}),M.extent==="parent"||M.expandParent)){const R=G1(M,N,M.origin??U);z?z=[[Math.min(R[0][0],z[0][0]),Math.min(R[0][1],z[0][1])],[Math.max(R[1][0],z[1][0]),Math.max(R[1][1],z[1][1])]]:z=R}S==null||S(J,{..._})}).on("drag",J=>{const{transform:ne,snapGrid:q,snapToGrid:C,nodeOrigin:W}=o(),U=jo(J.sourceEvent,{transform:ne,snapGrid:q,snapToGrid:C,containerBounds:E}),Y=[];if(!N)return;const{x:T,y:F,width:B,height:M}=_,R={},re=N.origin??W,{width:ie,height:ce,x:fe,y:de}=U1(P,c.controlDirection,U,c.boundaries,c.keepAspectRatio,re,V,z),Q=ie!==B,le=ce!==M,me=fe!==T&&Q,ke=de!==F&≤if(!me&&!ke&&!Q&&!le)return;if((me||ke||re[0]===1||re[1]===1)&&(R.x=me?fe:_.x,R.y=ke?de:_.y,_.x=R.x,_.y=R.y,L.length>0)){const Pe=fe-T,Ce=de-F;for(const Re of L)Re.position={x:Re.position.x-Pe+re[0]*(ie-B),y:Re.position.y-Ce+re[1]*(ce-M)},Y.push(Re)}if((Q||le)&&(R.width=Q&&(!c.resizeDirection||c.resizeDirection==="horizontal")?ie:_.width,R.height=le&&(!c.resizeDirection||c.resizeDirection==="vertical")?ce:_.height,_.width=R.width,_.height=R.height),A&&N.expandParent){const Pe=re[0]*(R.width??0);R.x&&R.x{G&&(j==null||j(J,{..._}),a==null||a({..._}),G=!1)});u.call(ee)}function g(){u.on(".drag",null)}return{update:f,destroy:g}}var Lu={exports:{}},Au={},zu={exports:{}},Du={};/** - * @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 Rh;function q1(){if(Rh)return Du;Rh=1;var t=$o();function r(x,m){return x===m&&(x!==0||1/x===1/m)||x!==x&&m!==m}var o=typeof Object.is=="function"?Object.is:r,s=t.useState,a=t.useEffect,u=t.useLayoutEffect,c=t.useDebugValue;function f(x,m){var S=m(),k=s({inst:{value:S,getSnapshot:m}}),j=k[0].inst,b=k[1];return u(function(){j.value=S,j.getSnapshot=m,g(j)&&b({inst:j})},[x,S,m]),a(function(){return g(j)&&b({inst:j}),x(function(){g(j)&&b({inst:j})})},[x]),c(S),S}function g(x){var m=x.getSnapshot;x=x.value;try{var S=m();return!o(x,S)}catch{return!0}}function y(x,m){return m()}var v=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:f;return Du.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:v,Du}var Lh;function K1(){return Lh||(Lh=1,zu.exports=q1()),zu.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 Ah;function Q1(){if(Ah)return Au;Ah=1;var t=$o(),r=K1();function o(y,v){return y===v&&(y!==0||1/y===1/v)||y!==y&&v!==v}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,f=t.useMemo,g=t.useDebugValue;return Au.useSyncExternalStoreWithSelector=function(y,v,x,m,S){var k=u(null);if(k.current===null){var j={hasValue:!1,value:null};k.current=j}else j=k.current;k=f(function(){function _(A){if(!P){if(P=!0,N=A,A=m(A),S!==void 0&&j.hasValue){var V=j.value;if(S(V,A))return E=V}return E=A}if(V=E,s(N,A))return V;var z=m(A);return S!==void 0&&S(V,z)?(N=A,V):(N=A,E=z)}var P=!1,N,E,L=x===void 0?null:x;return[function(){return _(v())},L===null?void 0:function(){return _(L())}]},[v,x,m,S]);var b=a(y,k[0],k[1]);return c(function(){j.hasValue=!0,j.value=b},[b]),g(b),b},Au}var zh;function Z1(){return zh||(zh=1,Lu.exports=Q1()),Lu.exports}var J1=Z1();const e_=wp(J1),t_={},Dh=t=>{let r;const o=new Set,s=(v,x)=>{const m=typeof v=="function"?v(r):v;if(!Object.is(m,r)){const S=r;r=x??(typeof m!="object"||m===null)?m:Object.assign({},r,m),o.forEach(k=>k(r,S))}},a=()=>r,g={setState:s,getState:a,getInitialState:()=>y,subscribe:v=>(o.add(v),()=>o.delete(v)),destroy:()=>{(t_?"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."),o.clear()}},y=r=t(s,a,g);return g},n_=t=>t?Dh(t):Dh,{useDebugValue:r_}=e0,{useSyncExternalStoreWithSelector:i_}=e_,o_=t=>t;function Pg(t,r=o_,o){const s=i_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return r_(s),s}const $h=(t,r)=>{const o=n_(t),s=(a,u=r)=>Pg(o,a,u);return Object.assign(s,o),s},s_=(t,r)=>t?$h(t,r):$h;function Ke(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}_p();const Tl=O.createContext(null),l_=Tl.Provider,Ig=on.error001("react");function ze(t,r){const o=O.useContext(Tl);if(o===null)throw new Error(Ig);return Pg(o,t,r)}function Ye(){const t=O.useContext(Tl);if(t===null)throw new Error(Ig);return O.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Oh={display:"none"},a_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Tg="react-flow__node-desc",Rg="react-flow__edge-desc",u_="react-flow__aria-live",c_=t=>t.ariaLiveMessage,d_=t=>t.ariaLabelConfig;function f_({rfId:t}){const r=ze(c_);return h.jsx("div",{id:`${u_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:a_,children:r})}function h_({rfId:t,disableKeyboardA11y:r}){const o=ze(d_);return h.jsxs(h.Fragment,{children:[h.jsx("div",{id:`${Tg}-${t}`,style:Oh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),h.jsx("div",{id:`${Rg}-${t}`,style:Oh,children:o["edge.a11yDescription.default"]}),!r&&h.jsx(f_,{rfId:t})]})}const Rl=O.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return h.jsx("div",{className:it(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});Rl.displayName="Panel";const Fh="https://reactflow.dev?utm_source=attribution";function p_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:h.jsx(Rl,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Fh}`,children:h.jsx("a",{href:Fh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const g_=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},rl=t=>t.id;function m_(t,r){return Ke(t.selectedNodes.map(rl),r.selectedNodes.map(rl))&&Ke(t.selectedEdges.map(rl),r.selectedEdges.map(rl))}function y_({onSelectionChange:t}){const r=Ye(),{selectedNodes:o,selectedEdges:s}=ze(g_,m_);return O.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const v_=t=>!!t.onSelectionChangeHandlers;function x_({onSelectionChange:t}){const r=ze(v_);return t||r?h.jsx(y_,{onSelectionChange:t}):null}const Lg=[0,0],w_={x:0,y:0,zoom:1},__=["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"],Hh=[...__,"rfId"],S_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Bh={translateExtent:To,nodeOrigin:Lg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function k_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:f,setDefaultNodesAndEdges:g}=ze(S_,Ke),y=Ye();O.useEffect(()=>(g(t.defaultNodes,t.defaultEdges),()=>{v.current=Bh,f()}),[]);const v=O.useRef(Bh);return O.useEffect(()=>{for(const x of Hh){const m=t[x],S=v.current[x];m!==S&&(typeof t[x]>"u"||(x==="nodes"?r(m):x==="edges"?o(m):x==="minZoom"?s(m):x==="maxZoom"?a(m):x==="translateExtent"?u(m):x==="nodeExtent"?c(m):x==="ariaLabelConfig"?y.setState({ariaLabelConfig:l1(m)}):x==="fitView"?y.setState({fitViewQueued:m}):x==="fitViewOptions"?y.setState({fitViewOptions:m}):y.setState({[x]:m})))}v.current=t},Hh.map(x=>t[x])),null}function Vh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function N_(t){var s;const[r,o]=O.useState(t==="system"?null:t);return O.useEffect(()=>{if(t!=="system"){o(t);return}const a=Vh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=Vh())!=null&&s.matches?"dark":"light"}const Wh=typeof document<"u"?document:null;function Do(t=null,r={target:Wh,actInsideInputWithModifier:!0}){const[o,s]=O.useState(!1),a=O.useRef(!1),u=O.useRef(new Set([])),[c,f]=O.useMemo(()=>{if(t!==null){const y=(Array.isArray(t)?t:[t]).filter(x=>typeof x=="string").map(x=>x.replace(/\+/g,` -`).replace(` - -`,` -+`).split(` -`)),v=y.reduce((x,m)=>x.concat(...m),[]);return[y,v]}return[[],[]]},[t]);return O.useEffect(()=>{const g=(r==null?void 0:r.target)??Wh,y=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const v=S=>{var b,_;if(a.current=S.ctrlKey||S.metaKey||S.shiftKey||S.altKey,(!a.current||a.current&&!y)&&hg(S))return!1;const j=Yh(S.code,f);if(u.current.add(S[j]),Uh(c,u.current,!1)){const P=((_=(b=S.composedPath)==null?void 0:b.call(S))==null?void 0:_[0])||S.target,N=(P==null?void 0:P.nodeName)==="BUTTON"||(P==null?void 0:P.nodeName)==="A";r.preventDefault!==!1&&(a.current||!N)&&S.preventDefault(),s(!0)}},x=S=>{const k=Yh(S.code,f);Uh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(S[k]),S.key==="Meta"&&u.current.clear(),a.current=!1},m=()=>{u.current.clear(),s(!1)};return g==null||g.addEventListener("keydown",v),g==null||g.addEventListener("keyup",x),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{g==null||g.removeEventListener("keydown",v),g==null||g.removeEventListener("keyup",x),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,s]),o}function Uh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Yh(t,r){return r.includes(t)?"code":"key"}const E_=()=>{const t=Ye();return O.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:f}=t.getState(),g=pc(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return f?(await f.setViewport(g,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:f,y:g}=c.getBoundingClientRect(),y={x:r.x-f,y:r.y-g},v=o.snapGrid??a,x=o.snapToGrid??u;return Wo(y,s,x,v)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=Di(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function Ag(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const f={...u};for(const g of c)j_(g,f);o.push(f)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function j_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function b_(t,r){return Ag(t,r)}function C_(t,r){return Ag(t,r)}function zr(t,r){return{id:t,type:"select",selected:r}}function Pi(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(zr(u.id,c)))}return s}function Gh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const f=r.get(c.id),g=((a=f==null?void 0:f.internals)==null?void 0:a.userNode)??f;g!==void 0&&g!==c&&o.push({id:c.id,item:c,type:"replace"}),g===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Xh(t){return{id:t.id,type:"remove"}}const M_=ug();function P_(t,r,o={}){return h1(t,r,{...o,onError:o.onError??M_})}const qh=t=>Zw(t),I_=t=>ig(t);function zg(t){return O.forwardRef(t)}const Dg=typeof window<"u"?O.useLayoutEffect:O.useEffect;function Kh(t){const[r,o]=O.useState(BigInt(0)),[s]=O.useState(()=>T_(()=>o(a=>a+BigInt(1))));return Dg(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function T_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const $g=O.createContext(null);function R_({children:t}){const r=Ye(),o=O.useCallback(f=>{const{nodes:g=[],setNodes:y,hasDefaultNodes:v,onNodesChange:x,nodeLookup:m,fitViewQueued:S,onNodesChangeMiddlewareMap:k}=r.getState();let j=g;for(const _ of f)j=typeof _=="function"?_(j):_;let b=Gh({items:j,lookup:m});for(const _ of k.values())b=_(b);v&&y(j),b.length>0?x==null||x(b):S&&window.requestAnimationFrame(()=>{const{fitViewQueued:_,nodes:P,setNodes:N}=r.getState();_&&N(P)})},[]),s=Kh(o),a=O.useCallback(f=>{const{edges:g=[],setEdges:y,hasDefaultEdges:v,onEdgesChange:x,edgeLookup:m}=r.getState();let S=g;for(const k of f)S=typeof k=="function"?k(S):k;v?y(S):x&&x(Gh({items:S,lookup:m}))},[]),u=Kh(a),c=O.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return h.jsx($g.Provider,{value:c,children:t})}function L_(){const t=O.useContext($g);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const A_=t=>!!t.panZoom;function Ll(){const t=E_(),r=Ye(),o=L_(),s=ze(A_),a=O.useMemo(()=>{const u=x=>r.getState().nodeLookup.get(x),c=x=>{o.nodeQueue.push(x)},f=x=>{o.edgeQueue.push(x)},g=x=>{var _,P;const{nodeLookup:m,nodeOrigin:S}=r.getState(),k=qh(x)?x:m.get(x.id),j=k.parentId?dg(k.position,k.measured,k.parentId,m,S):k.position,b={...k,position:j,width:((_=k.measured)==null?void 0:_.width)??k.width,height:((P=k.measured)==null?void 0:P.height)??k.height};return Ao(b)},y=(x,m,S={replace:!1})=>{c(k=>k.map(j=>{if(j.id===x){const b=typeof m=="function"?m(j):m;return S.replace&&qh(b)?b:{...j,...b}}return j}))},v=(x,m,S={replace:!1})=>{f(k=>k.map(j=>{if(j.id===x){const b=typeof m=="function"?m(j):m;return S.replace&&I_(b)?b:{...j,...b}}return j}))};return{getNodes:()=>r.getState().nodes.map(x=>({...x})),getNode:x=>{var m;return(m=u(x))==null?void 0:m.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:x=[]}=r.getState();return x.map(m=>({...m}))},getEdge:x=>r.getState().edgeLookup.get(x),setNodes:c,setEdges:f,addNodes:x=>{const m=Array.isArray(x)?x:[x];o.nodeQueue.push(S=>[...S,...m])},addEdges:x=>{const m=Array.isArray(x)?x:[x];o.edgeQueue.push(S=>[...S,...m])},toObject:()=>{const{nodes:x=[],edges:m=[],transform:S}=r.getState(),[k,j,b]=S;return{nodes:x.map(_=>({..._})),edges:m.map(_=>({..._})),viewport:{x:k,y:j,zoom:b}}},deleteElements:async({nodes:x=[],edges:m=[]})=>{const{nodes:S,edges:k,onNodesDelete:j,onEdgesDelete:b,triggerNodeChanges:_,triggerEdgeChanges:P,onDelete:N,onBeforeDelete:E}=r.getState(),{nodes:L,edges:A}=await r1({nodesToRemove:x,edgesToRemove:m,nodes:S,edges:k,onBeforeDelete:E}),V=A.length>0,z=L.length>0;if(V){const G=A.map(Xh);b==null||b(A),P(G)}if(z){const G=L.map(Xh);j==null||j(L),_(G)}return(z||V)&&(N==null||N({nodes:L,edges:A})),{deletedNodes:L,deletedEdges:A}},getIntersectingNodes:(x,m=!0,S)=>{const k=wh(x),j=k?x:g(x),b=S!==void 0;return j?(S||r.getState().nodes).filter(_=>{const P=r.getState().nodeLookup.get(_.id);if(P&&!k&&(_.id===x.id||!P.internals.positionAbsolute))return!1;const N=Ao(b?_:P),E=wl(N,j);return m&&E>0||E>=N.width*N.height||E>=j.width*j.height}):[]},isNodeIntersecting:(x,m,S=!0)=>{const j=wh(x)?x:g(x);if(!j)return!1;const b=wl(j,m);return S&&b>0||b>=m.width*m.height||b>=j.width*j.height},updateNode:y,updateNodeData:(x,m,S={replace:!1})=>{y(x,k=>{const j=typeof m=="function"?m(k):m;return S.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},S)},updateEdge:v,updateEdgeData:(x,m,S={replace:!1})=>{v(x,k=>{const j=typeof m=="function"?m(k):m;return S.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},S)},getNodesBounds:x=>{const{nodeLookup:m,nodeOrigin:S}=r.getState();return Jw(x,{nodeLookup:m,nodeOrigin:S})},getHandleConnections:({type:x,id:m,nodeId:S})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${S}-${x}${m?`-${m}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:x,handleId:m,nodeId:S})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${S}${x?m?`-${x}-${m}`:`-${x}`:""}`))==null?void 0:k.values())??[])},fitView:async x=>{const m=r.getState().fitViewResolver??s1();return r.setState({fitViewQueued:!0,fitViewOptions:x,fitViewResolver:m}),o.nodeQueue.push(S=>[...S]),m.promise}}},[]);return O.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const Qh=t=>t.selected,z_=typeof window<"u"?window:void 0;function D_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ye(),{deleteElements:s}=Ll(),a=Do(t,{actInsideInputWithModifier:!1}),u=Do(r,{target:z_});O.useEffect(()=>{if(a){const{edges:c,nodes:f}=o.getState();s({nodes:f.filter(Qh),edges:c.filter(Qh)}),o.setState({nodesSelectionActive:!1})}},[a]),O.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function $_(t){const r=Ye();O.useEffect(()=>{const o=()=>{var a,u,c,f;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=gc(t.current);(s.height===0||s.width===0)&&((f=(c=r.getState()).onError)==null||f.call(c,"004",on.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const Al={position:"absolute",width:"100%",height:"100%",top:0,left:0},O_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function F_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=Fr.Free,zoomOnDoubleClick:f=!0,panOnDrag:g=!0,defaultViewport:y,translateExtent:v,minZoom:x,maxZoom:m,zoomActivationKeyCode:S,preventScrolling:k=!0,children:j,noWheelClassName:b,noPanClassName:_,onViewportChange:P,isControlledViewport:N,paneClickDistance:E,selectionOnDrag:L}){const A=Ye(),V=O.useRef(null),{userSelectionActive:z,lib:G,connectionInProgress:ee}=ze(O_,Ke),J=Do(S),ne=O.useRef();$_(V);const q=O.useCallback(C=>{P==null||P({x:C[0],y:C[1],zoom:C[2]}),N||A.setState({transform:C})},[P,N]);return O.useEffect(()=>{if(V.current){ne.current=V1({domNode:V.current,minZoom:x,maxZoom:m,translateExtent:v,viewport:y,onDraggingChange:Y=>A.setState(T=>T.paneDragging===Y?T:{paneDragging:Y}),onPanZoomStart:(Y,T)=>{const{onViewportChangeStart:F,onMoveStart:B}=A.getState();B==null||B(Y,T),F==null||F(T)},onPanZoom:(Y,T)=>{const{onViewportChange:F,onMove:B}=A.getState();B==null||B(Y,T),F==null||F(T)},onPanZoomEnd:(Y,T)=>{const{onViewportChangeEnd:F,onMoveEnd:B}=A.getState();B==null||B(Y,T),F==null||F(T)}});const{x:C,y:W,zoom:U}=ne.current.getViewport();return A.setState({panZoom:ne.current,transform:[C,W,U],domNode:V.current.closest(".react-flow")}),()=>{var Y;(Y=ne.current)==null||Y.destroy()}}},[]),O.useEffect(()=>{var C;(C=ne.current)==null||C.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:f,panOnDrag:g,zoomActivationKeyPressed:J,preventScrolling:k,noPanClassName:_,userSelectionActive:z,noWheelClassName:b,lib:G,onTransformChange:q,connectionInProgress:ee,selectionOnDrag:L,paneClickDistance:E})},[t,r,o,s,a,u,c,f,g,J,k,_,z,b,G,q,ee,L,E]),h.jsx("div",{className:"react-flow__renderer",ref:V,style:Al,children:j})}const H_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function B_(){const{userSelectionActive:t,userSelectionRect:r}=ze(H_,Ke);return t&&r?h.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const $u=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},V_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function W_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=Ro.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:f,onSelectionEnd:g,onPaneClick:y,onPaneContextMenu:v,onPaneScroll:x,onPaneMouseEnter:m,onPaneMouseMove:S,onPaneMouseLeave:k,children:j}){const b=O.useRef(0),_=Ye(),{userSelectionActive:P,elementsSelectable:N,dragging:E,panBy:L,autoPanSpeed:A}=ze(V_,Ke),V=N&&(t||P),z=O.useRef(null),G=O.useRef(),ee=O.useRef(new Set),J=O.useRef(new Set),ne=O.useRef(!1),q=O.useRef(!1),C=O.useRef({x:0,y:0}),W=O.useRef(!1),U=Q=>{if(q.current||ne.current||_.getState().connection.inProgress){q.current=!1,ne.current=!1;return}y==null||y(Q),_.getState().resetSelectedElements(),_.setState({nodesSelectionActive:!1})},Y=Q=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Q.preventDefault();return}v==null||v(Q)},T=x?Q=>x(Q):void 0,F=Q=>{q.current&&(Q.stopPropagation(),q.current=!1)},B=Q=>{var Re,tt;if(Q.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:le,transform:me}=_.getState();if(G.current=le==null?void 0:le.getBoundingClientRect(),!G.current)return;const ke=Q.target===z.current;if(!ke&&!!Q.target.closest(".nokey")||!t||!(c&&ke||r)||Q.button!==0||!Q.isPrimary)return;(tt=(Re=Q.target)==null?void 0:Re.setPointerCapture)==null||tt.call(Re,Q.pointerId),q.current=!1;const{x:be,y:Pe}=rn(Q.nativeEvent,G.current),Ce=Wo({x:be,y:Pe},me);_.setState({userSelectionRect:{width:0,height:0,startX:Ce.x,startY:Ce.y,x:be,y:Pe}}),ke||(Q.stopPropagation(),Q.preventDefault())};function M(Q,le){const{userSelectionRect:me}=_.getState();if(!me)return;const{transform:ke,nodeLookup:xe,edgeLookup:pe,connectionLookup:be,triggerNodeChanges:Pe,triggerEdgeChanges:Ce,defaultEdgeOptions:Re}=_.getState(),tt={x:me.startX,y:me.startY},{x:nt,y:Je}=Di(tt,ke),Qe={startX:tt.x,startY:tt.y,x:Qft.id)),J.current=new Set;const st=(Re==null?void 0:Re.selectable)??!0;for(const ft of ee.current){const He=be.get(ft);if(He)for(const{edgeId:Le}of He.values()){const mt=pe.get(Le);mt&&(mt.selectable??st)&&J.current.add(Le)}}if(!_h(ot,ee.current)){const ft=Pi(xe,ee.current,!0);Pe(ft)}if(!_h(Pt,J.current)){const ft=Pi(pe,J.current);Ce(ft)}_.setState({userSelectionRect:Qe,userSelectionActive:!0,nodesSelectionActive:!1})}function R(){if(!a||!G.current)return;const[Q,le]=hc(C.current,G.current,A);L({x:Q,y:le}).then(me=>{if(!q.current||!me){b.current=requestAnimationFrame(R);return}const{x:ke,y:xe}=C.current;M(ke,xe),b.current=requestAnimationFrame(R)})}const re=()=>{cancelAnimationFrame(b.current),b.current=0,W.current=!1};O.useEffect(()=>()=>re(),[]);const ie=Q=>{const{userSelectionRect:le,transform:me,resetSelectedElements:ke}=_.getState();if(!G.current||!le)return;const{x:xe,y:pe}=rn(Q.nativeEvent,G.current);C.current={x:xe,y:pe};const be=Di({x:le.startX,y:le.startY},me);if(!q.current){const Pe=r?0:u;if(Math.hypot(xe-be.x,pe-be.y)<=Pe)return;ke(),f==null||f(Q)}q.current=!0,W.current||(R(),W.current=!0),M(xe,pe)},ce=Q=>{var le,me;if(!V){Q.target===z.current&&_.getState().connection.inProgress&&(ne.current=!0);return}Q.button===0&&((me=(le=Q.target)==null?void 0:le.releasePointerCapture)==null||me.call(le,Q.pointerId),!P&&Q.target===z.current&&_.getState().userSelectionRect&&(U==null||U(Q)),_.setState({userSelectionActive:!1,userSelectionRect:null}),q.current&&(g==null||g(Q),_.setState({nodesSelectionActive:ee.current.size>0})),re())},fe=Q=>{var le,me;(me=(le=Q.target)==null?void 0:le.releasePointerCapture)==null||me.call(le,Q.pointerId),re()},de=s===!0||Array.isArray(s)&&s.includes(0);return h.jsxs("div",{className:it(["react-flow__pane",{draggable:de,dragging:E,selection:t}]),onClick:V?void 0:$u(U,z),onContextMenu:$u(Y,z),onWheel:$u(T,z),onPointerEnter:V?void 0:m,onPointerMove:V?ie:S,onPointerUp:ce,onPointerCancel:V?fe:void 0,onPointerDownCapture:V?B:void 0,onClickCapture:V?F:void 0,onPointerLeave:k,ref:z,style:Al,children:[j,h.jsx(B_,{})]})}function tc({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:f,onError:g}=r.getState(),y=f.get(t);if(!y){g==null||g("012",on.error012(t));return}r.setState({nodesSelectionActive:!1}),y.selected?(o||y.selected&&c)&&(u({nodes:[y],edges:[]}),requestAnimationFrame(()=>{var v;return(v=s==null?void 0:s.current)==null?void 0:v.blur()})):a([t])}function Og({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const f=Ye(),[g,y]=O.useState(!1),v=O.useRef();return O.useEffect(()=>{if(!r)return v.current=M1({getStoreItems:()=>f.getState(),onNodeMouseDown:x=>{tc({id:x,store:f,nodeRef:t})},onDragStart:()=>{y(!0)},onDragStop:()=>{y(!1)}}),()=>{var x;(x=v.current)==null||x.destroy(),v.current=void 0}},[r,f,t]),O.useEffect(()=>{r||!t.current||!v.current||v.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),g}const U_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Fg(){const t=Ye();return O.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:f,updateNodePositions:g,nodeLookup:y,nodeOrigin:v}=t.getState(),x=new Map,m=U_(c),S=a?u[0]:5,k=a?u[1]:5,j=o.direction.x*S*o.factor,b=o.direction.y*k*o.factor;for(const[,_]of y){if(!m(_))continue;let P={x:_.internals.positionAbsolute.x+j,y:_.internals.positionAbsolute.y+b};a&&(P=Vo(P,u));const{position:N,positionAbsolute:E}=og({nodeId:_.id,nextPosition:P,nodeLookup:y,nodeExtent:s,nodeOrigin:v,onError:f});_.position=N,_.internals.positionAbsolute=E,x.set(_.id,_)}g(x)},[])}const _c=O.createContext(null),Y_=_c.Provider;_c.Consumer;const Hg=()=>O.useContext(_c),G_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Bg=O.createContext(null);function X_({children:t}){const r=ze(G_,Ke);return h.jsx(Bg.Provider,{value:r,children:t})}function q_(){const t=O.useContext(Bg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const K_={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Q_=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:f,toHandle:g,isValid:y}=c;if(!f&&!a)return K_;const v=(g==null?void 0:g.nodeId)===t&&(g==null?void 0:g.id)===r&&(g==null?void 0:g.type)===o;return{connectingFrom:(f==null?void 0:f.nodeId)===t&&(f==null?void 0:f.id)===r&&(f==null?void 0:f.type)===o,connectingTo:v,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Ai.Strict?(f==null?void 0:f.type)!==o:t!==(f==null?void 0:f.nodeId)||r!==(f==null?void 0:f.id),connectionInProcess:!!f,clickConnectionInProcess:!!a,valid:v&&y}};function Z_({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:f,children:g,className:y,onMouseDown:v,onTouchStart:x,...m},S){var W,U;const k=c||null,j=t==="target",b=Ye(),_=Hg(),{connectOnClick:P,noPanClassName:N,rfId:E}=q_(),{connectingFrom:L,connectingTo:A,clickConnecting:V,isPossibleEndHandle:z,connectionInProcess:G,clickConnectionInProcess:ee,valid:J}=ze(Q_(_,k,t),Ke);_||(U=(W=b.getState()).onError)==null||U.call(W,"010",on.error010());const ne=Y=>{const{defaultEdgeOptions:T,onConnect:F,hasDefaultEdges:B}=b.getState(),M={...T,...Y};if(B){const{edges:R,setEdges:re,onError:ie}=b.getState();re(P_(M,R,{onError:ie}))}F==null||F(M),f==null||f(M)},q=Y=>{if(!_)return;const T=pg(Y.nativeEvent);if(a&&(T&&Y.button===0||!T)){const F=b.getState();ec.onPointerDown(Y.nativeEvent,{handleDomNode:Y.currentTarget,autoPanOnConnect:F.autoPanOnConnect,connectionMode:F.connectionMode,connectionRadius:F.connectionRadius,domNode:F.domNode,nodeLookup:F.nodeLookup,lib:F.lib,isTarget:j,handleId:k,nodeId:_,flowId:F.rfId,panBy:F.panBy,cancelConnection:F.cancelConnection,onConnectStart:F.onConnectStart,onConnectEnd:(...B)=>{var M,R;return(R=(M=b.getState()).onConnectEnd)==null?void 0:R.call(M,...B)},updateConnection:F.updateConnection,onConnect:ne,isValidConnection:o||((...B)=>{var M,R;return((R=(M=b.getState()).isValidConnection)==null?void 0:R.call(M,...B))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:F.autoPanSpeed,dragThreshold:F.connectionDragThreshold})}T?v==null||v(Y):x==null||x(Y)},C=Y=>{const{onClickConnectStart:T,onClickConnectEnd:F,connectionClickStartHandle:B,connectionMode:M,isValidConnection:R,lib:re,rfId:ie,nodeLookup:ce,connection:fe}=b.getState();if(!_||!B&&!a)return;if(!B){T==null||T(Y.nativeEvent,{nodeId:_,handleId:k,handleType:t}),b.setState({connectionClickStartHandle:{nodeId:_,type:t,id:k}});return}const de=fg(Y.target),Q=o||R,{connection:le,isValid:me}=ec.isValid(Y.nativeEvent,{handle:{nodeId:_,id:k,type:t},connectionMode:M,fromNodeId:B.nodeId,fromHandleId:B.id||null,fromType:B.type,isValidConnection:Q,flowId:ie,doc:de,lib:re,nodeLookup:ce});me&&le&&ne(le);const ke=structuredClone(fe);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,F==null||F(Y,ke),b.setState({connectionClickStartHandle:null})};return h.jsx("div",{"data-handleid":k,"data-nodeid":_,"data-handlepos":r,"data-id":`${E}-${_}-${k}-${t}`,className:it(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",N,y,{source:!j,target:j,connectable:s,connectablestart:a,connectableend:u,clickconnecting:V,connectingfrom:L,connectingto:A,valid:J,connectionindicator:s&&(!G||z)&&(G||ee?u:a)}]),onMouseDown:q,onTouchStart:q,onClick:P?C:void 0,ref:S,...m,children:g})}const Oi=O.memo(zg(Z_));function J_({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return h.jsxs(h.Fragment,{children:[t==null?void 0:t.label,h.jsx(Oi,{type:"source",position:o,isConnectable:r})]})}function eS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:s=Se.Bottom}){return h.jsxs(h.Fragment,{children:[h.jsx(Oi,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,h.jsx(Oi,{type:"source",position:s,isConnectable:r})]})}function tS(){return null}function nS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return h.jsxs(h.Fragment,{children:[h.jsx(Oi,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const _l={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Zh={input:J_,default:eS,output:nS,group:tS};function rS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const iS=t=>{const{width:r,height:o,x:s,y:a}=Bo(t.nodeLookup,{filter:u=>!!u.selected});return{width:nn(r)?r:null,height:nn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function oS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ye(),{width:a,height:u,transformString:c,userSelectionActive:f}=ze(iS,Ke),g=Fg(),y=O.useRef(null);O.useEffect(()=>{var S;o||(S=y.current)==null||S.focus({preventScroll:!0})},[o]);const v=!f&&a!==null&&u!==null;if(Og({nodeRef:y,disabled:!v}),!v)return null;const x=t?S=>{const k=s.getState().nodes.filter(j=>j.selected);t(S,k)}:void 0,m=S=>{Object.prototype.hasOwnProperty.call(_l,S.key)&&(S.preventDefault(),g({direction:_l[S.key],factor:S.shiftKey?4:1}))};return h.jsx("div",{className:it(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:h.jsx("div",{ref:y,className:"react-flow__nodesselection-rect",onContextMenu:x,tabIndex:o?void 0:-1,onKeyDown:o?void 0:m,style:{width:a,height:u}})})}const Jh=typeof window<"u"?window:void 0,sS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Vg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:f,deleteKeyCode:g,selectionKeyCode:y,selectionOnDrag:v,selectionMode:x,onSelectionStart:m,onSelectionEnd:S,multiSelectionKeyCode:k,panActivationKeyCode:j,zoomActivationKeyCode:b,elementsSelectable:_,zoomOnScroll:P,zoomOnPinch:N,panOnScroll:E,panOnScrollSpeed:L,panOnScrollMode:A,zoomOnDoubleClick:V,panOnDrag:z,autoPanOnSelection:G,defaultViewport:ee,translateExtent:J,minZoom:ne,maxZoom:q,preventScrolling:C,onSelectionContextMenu:W,noWheelClassName:U,noPanClassName:Y,disableKeyboardA11y:T,onViewportChange:F,isControlledViewport:B}){const{nodesSelectionActive:M,userSelectionActive:R}=ze(sS,Ke),re=Do(y,{target:Jh}),ie=Do(j,{target:Jh}),ce=ie||z,fe=ie||E,de=v&&ce!==!0,Q=re||R||de;return D_({deleteKeyCode:g,multiSelectionKeyCode:k}),h.jsx(F_,{onPaneContextMenu:u,elementsSelectable:_,zoomOnScroll:P,zoomOnPinch:N,panOnScroll:fe,panActivationKeyPressed:ie,panOnScrollSpeed:L,panOnScrollMode:A,zoomOnDoubleClick:V,panOnDrag:!re&&ce,defaultViewport:ee,translateExtent:J,minZoom:ne,maxZoom:q,zoomActivationKeyCode:b,preventScrolling:C,noWheelClassName:U,noPanClassName:Y,onViewportChange:F,isControlledViewport:B,paneClickDistance:f,selectionOnDrag:de,children:h.jsxs(W_,{onSelectionStart:m,onSelectionEnd:S,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:ce,autoPanOnSelection:G,isSelecting:!!Q,selectionMode:x,selectionKeyPressed:re,paneClickDistance:f,selectionOnDrag:de,children:[t,M&&h.jsx(oS,{onSelectionContextMenu:W,noPanClassName:Y,disableKeyboardA11y:T})]})})}Vg.displayName="FlowRenderer";const lS=O.memo(Vg),aS=t=>r=>t?fc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function uS(t){return ze(O.useCallback(aS(t),[t]),Ke)}const cS=t=>t.updateNodeInternals;function dS(){const t=ze(cS),[r]=O.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return O.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function fS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ye(),u=O.useRef(null),c=O.useRef(null),f=O.useRef(t.sourcePosition),g=O.useRef(t.targetPosition),y=O.useRef(r),v=o&&!!t.internals.handleBounds;return O.useEffect(()=>{u.current&&!t.hidden&&(!v||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[v,t.hidden]),O.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),O.useEffect(()=>{if(u.current){const x=y.current!==r,m=f.current!==t.sourcePosition,S=g.current!==t.targetPosition;(x||m||S)&&(y.current=r,f.current=t.sourcePosition,g.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function hS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:f,elementsSelectable:g,nodesConnectable:y,nodesFocusable:v,resizeObserver:x,noDragClassName:m,noPanClassName:S,disableKeyboardA11y:k,rfId:j,nodeTypes:b,nodeClickDistance:_,onError:P}){const{node:N,internals:E,isParent:L}=ze(Q=>{const le=Q.nodeLookup.get(t),me=Q.parentLookup.has(t);return{node:le,internals:le.internals,isParent:me}},Ke);let A=N.type||"default",V=(b==null?void 0:b[A])||Zh[A];V===void 0&&(P==null||P("003",on.error003(A)),A="default",V=(b==null?void 0:b.default)||Zh.default);const z=!!(N.draggable||f&&typeof N.draggable>"u"),G=!!(N.selectable||g&&typeof N.selectable>"u"),ee=!!(N.connectable||y&&typeof N.connectable>"u"),J=!!(N.focusable||v&&typeof N.focusable>"u"),ne=Ye(),q=cg(N),C=fS({node:N,nodeType:A,hasDimensions:q,resizeObserver:x}),W=Og({nodeRef:C,disabled:N.hidden||!z,noDragClassName:m,handleSelector:N.dragHandle,nodeId:t,isSelectable:G,nodeClickDistance:_}),U=Fg();if(N.hidden)return null;const Y=ln(N),T=rS(N),F=G||z||r||o||s||a,B=o?Q=>o(Q,{...E.userNode}):void 0,M=s?Q=>s(Q,{...E.userNode}):void 0,R=a?Q=>a(Q,{...E.userNode}):void 0,re=u?Q=>u(Q,{...E.userNode}):void 0,ie=c?Q=>c(Q,{...E.userNode}):void 0,ce=Q=>{const{selectNodesOnDrag:le,nodeDragThreshold:me}=ne.getState();G&&(!le||!z||me>0)&&tc({id:t,store:ne,nodeRef:C}),r&&r(Q,{...E.userNode})},fe=Q=>{if(!(hg(Q.nativeEvent)||k)){if(eg.includes(Q.key)&&G){const le=Q.key==="Escape";tc({id:t,store:ne,unselect:le,nodeRef:C})}else if(z&&N.selected&&Object.prototype.hasOwnProperty.call(_l,Q.key)){Q.preventDefault();const{ariaLabelConfig:le}=ne.getState();ne.setState({ariaLiveMessage:le["node.a11yDescription.ariaLiveMessage"]({direction:Q.key.replace("Arrow","").toLowerCase(),x:~~E.positionAbsolute.x,y:~~E.positionAbsolute.y})}),U({direction:_l[Q.key],factor:Q.shiftKey?4:1})}}},de=()=>{var be;if(k||!((be=C.current)!=null&&be.matches(":focus-visible")))return;const{transform:Q,width:le,height:me,autoPanOnNodeFocus:ke,setCenter:xe}=ne.getState();if(!ke)return;fc(new Map([[t,N]]),{x:0,y:0,width:le,height:me},Q,!0).length>0||xe(N.position.x+Y.width/2,N.position.y+Y.height/2,{zoom:Q[2]})};return h.jsx("div",{className:it(["react-flow__node",`react-flow__node-${A}`,{[S]:z},N.className,{selected:N.selected,selectable:G,parent:L,draggable:z,dragging:W}]),ref:C,style:{zIndex:E.z,transform:`translate(${E.positionAbsolute.x}px,${E.positionAbsolute.y}px)`,pointerEvents:F?"all":"none",visibility:q?"visible":"hidden",...N.style,...T},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:B,onMouseMove:M,onMouseLeave:R,onContextMenu:re,onClick:ce,onDoubleClick:ie,onKeyDown:J?fe:void 0,tabIndex:J?0:void 0,onFocus:J?de:void 0,role:N.ariaRole??(J?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${Tg}-${j}`,"aria-label":N.ariaLabel,...N.domAttributes,children:h.jsx(Y_,{value:t,children:h.jsx(V,{id:t,data:N.data,type:A,positionAbsoluteX:E.positionAbsolute.x,positionAbsoluteY:E.positionAbsolute.y,selected:N.selected??!1,selectable:G,draggable:z,deletable:N.deletable??!0,isConnectable:ee,sourcePosition:N.sourcePosition,targetPosition:N.targetPosition,dragging:W,dragHandle:N.dragHandle,zIndex:E.z,parentId:N.parentId,...Y})})})}var pS=O.memo(hS);const gS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Wg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=ze(gS,Ke),u=uS(t.onlyRenderVisibleElements),c=dS();return h.jsx("div",{className:"react-flow__nodes",style:Al,children:u.map(f=>h.jsx(pS,{id:f,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},f))})}Wg.displayName="NodeRenderer";const mS=O.memo(Wg);function yS(t){return ze(O.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&c1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Ke)}const vS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return h.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},xS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return h.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ep={[Lo.Arrow]:vS,[Lo.ArrowClosed]:xS};function wS(t){const r=Ye();return O.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(ep,t)?ep[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",on.error009(t)),null)},[t])}const _S=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:f="auto-start-reverse"})=>{const g=wS(r);return g?h.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:f,refX:"0",refY:"0",children:h.jsx(g,{color:o,strokeWidth:c})}):null},Ug=({defaultColor:t,rfId:r})=>{const o=ze(u=>u.edges),s=ze(u=>u.defaultEdgeOptions),a=O.useMemo(()=>v1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?h.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:h.jsx("defs",{children:a.map(u=>h.jsx(_S,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Ug.displayName="MarkerDefinitions";var SS=O.memo(Ug);function Yg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:f=2,children:g,className:y,...v}){const[x,m]=O.useState({x:1,y:0,width:0,height:0}),S=it(["react-flow__edge-textwrapper",y]),k=O.useRef(null);return O.useEffect(()=>{if(k.current){const j=k.current.getBBox();m({x:j.x,y:j.y,width:j.width,height:j.height})}},[o]),o?h.jsxs("g",{transform:`translate(${t-x.width/2} ${r-x.height/2})`,className:S,visibility:x.width?"visible":"hidden",...v,children:[a&&h.jsx("rect",{width:x.width+2*c[0],x:-c[0],y:-c[1],height:x.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:f,ry:f}),h.jsx("text",{className:"react-flow__edge-text",y:x.height/2,dy:"0.3em",ref:k,style:s,children:o}),g]}):null}Yg.displayName="EdgeText";const kS=O.memo(Yg);function zl({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:g,interactionWidth:y=20,...v}){return h.jsxs(h.Fragment,{children:[h.jsx("path",{...v,d:t,fill:"none",className:it(["react-flow__edge-path",v.className])}),y?h.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:y,className:"react-flow__edge-interaction"}):null,s&&nn(r)&&nn(o)?h.jsx(kS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:g}):null]})}function tp({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function Gg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top}){const[c,f]=tp({pos:o,x1:t,y1:r,x2:s,y2:a}),[g,y]=tp({pos:u,x1:s,y1:a,x2:t,y2:r}),[v,x,m,S]=gg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:f,targetControlX:g,targetControlY:y});return[`M${t},${r} C${c},${f} ${g},${y} ${s},${a}`,v,x,m,S]}function Xg(t){return O.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:f,label:g,labelStyle:y,labelShowBg:v,labelBgStyle:x,labelBgPadding:m,labelBgBorderRadius:S,style:k,markerEnd:j,markerStart:b,interactionWidth:_})=>{const[P,N,E]=Gg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:f}),L=t.isInternal?void 0:r;return h.jsx(zl,{id:L,path:P,labelX:N,labelY:E,label:g,labelStyle:y,labelShowBg:v,labelBgStyle:x,labelBgPadding:m,labelBgBorderRadius:S,style:k,markerEnd:j,markerStart:b,interactionWidth:_})})}const NS=Xg({isInternal:!1}),qg=Xg({isInternal:!0});NS.displayName="SimpleBezierEdge";qg.displayName="SimpleBezierEdgeInternal";function Kg(t){return O.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:v,labelBgBorderRadius:x,style:m,sourcePosition:S=Se.Bottom,targetPosition:k=Se.Top,markerEnd:j,markerStart:b,pathOptions:_,interactionWidth:P})=>{const[N,E,L]=Qu({sourceX:o,sourceY:s,sourcePosition:S,targetX:a,targetY:u,targetPosition:k,borderRadius:_==null?void 0:_.borderRadius,offset:_==null?void 0:_.offset,stepPosition:_==null?void 0:_.stepPosition}),A=t.isInternal?void 0:r;return h.jsx(zl,{id:A,path:N,labelX:E,labelY:L,label:c,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:v,labelBgBorderRadius:x,style:m,markerEnd:j,markerStart:b,interactionWidth:P})})}const Qg=Kg({isInternal:!1}),Zg=Kg({isInternal:!0});Qg.displayName="SmoothStepEdge";Zg.displayName="SmoothStepEdgeInternal";function Jg(t){return O.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return h.jsx(Qg,{...o,id:s,pathOptions:O.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const ES=Jg({isInternal:!1}),em=Jg({isInternal:!0});ES.displayName="StepEdge";em.displayName="StepEdgeInternal";function tm(t){return O.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:v,labelBgBorderRadius:x,style:m,markerEnd:S,markerStart:k,interactionWidth:j})=>{const[b,_,P]=vg({sourceX:o,sourceY:s,targetX:a,targetY:u}),N=t.isInternal?void 0:r;return h.jsx(zl,{id:N,path:b,labelX:_,labelY:P,label:c,labelStyle:f,labelShowBg:g,labelBgStyle:y,labelBgPadding:v,labelBgBorderRadius:x,style:m,markerEnd:S,markerStart:k,interactionWidth:j})})}const jS=tm({isInternal:!1}),nm=tm({isInternal:!0});jS.displayName="StraightEdge";nm.displayName="StraightEdgeInternal";function rm(t){return O.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=Se.Bottom,targetPosition:f=Se.Top,label:g,labelStyle:y,labelShowBg:v,labelBgStyle:x,labelBgPadding:m,labelBgBorderRadius:S,style:k,markerEnd:j,markerStart:b,pathOptions:_,interactionWidth:P})=>{const[N,E,L]=mg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:f,curvature:_==null?void 0:_.curvature}),A=t.isInternal?void 0:r;return h.jsx(zl,{id:A,path:N,labelX:E,labelY:L,label:g,labelStyle:y,labelShowBg:v,labelBgStyle:x,labelBgPadding:m,labelBgBorderRadius:S,style:k,markerEnd:j,markerStart:b,interactionWidth:P})})}const bS=rm({isInternal:!1}),im=rm({isInternal:!0});bS.displayName="BezierEdge";im.displayName="BezierEdgeInternal";const np={default:im,straight:nm,step:em,smoothstep:Zg,simplebezier:qg},rp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},CS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,MS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,ip="react-flow__edgeupdater";function op({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:f}){return h.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:it([ip,`${ip}-${f}`]),cx:CS(r,s,t),cy:MS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function PS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:f,targetPosition:g,onReconnect:y,onReconnectStart:v,onReconnectEnd:x,setReconnecting:m,setUpdateHover:S}){const k=Ye(),j=(E,L)=>{if(E.button!==0)return;const{autoPanOnConnect:A,domNode:V,connectionMode:z,connectionRadius:G,lib:ee,onConnectStart:J,cancelConnection:ne,nodeLookup:q,rfId:C,panBy:W,updateConnection:U}=k.getState(),Y=L.type==="target",T=(M,R)=>{m(!1),x==null||x(M,o,L.type,R)},F=M=>y==null?void 0:y(o,M),B=(M,R)=>{m(!0),v==null||v(E,o,L.type),J==null||J(M,R)};ec.onPointerDown(E.nativeEvent,{autoPanOnConnect:A,connectionMode:z,connectionRadius:G,domNode:V,handleId:L.id,nodeId:L.nodeId,nodeLookup:q,isTarget:Y,edgeUpdaterType:L.type,lib:ee,flowId:C,cancelConnection:ne,panBy:W,isValidConnection:(...M)=>{var R,re;return((re=(R=k.getState()).isValidConnection)==null?void 0:re.call(R,...M))??!0},onConnect:F,onConnectStart:B,onConnectEnd:(...M)=>{var R,re;return(re=(R=k.getState()).onConnectEnd)==null?void 0:re.call(R,...M)},onReconnectEnd:T,updateConnection:U,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:E.currentTarget})},b=E=>j(E,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),_=E=>j(E,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),P=()=>S(!0),N=()=>S(!1);return h.jsxs(h.Fragment,{children:[(t===!0||t==="source")&&h.jsx(op,{position:f,centerX:s,centerY:a,radius:r,onMouseDown:b,onMouseEnter:P,onMouseOut:N,type:"source"}),(t===!0||t==="target")&&h.jsx(op,{position:g,centerX:u,centerY:c,radius:r,onMouseDown:_,onMouseEnter:P,onMouseOut:N,type:"target"})]})}function IS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:f,onMouseMove:g,onMouseLeave:y,reconnectRadius:v,onReconnect:x,onReconnectStart:m,onReconnectEnd:S,rfId:k,edgeTypes:j,noPanClassName:b,onError:_,disableKeyboardA11y:P}){let N=ze(xe=>xe.edgeLookup.get(t));const E=ze(xe=>xe.defaultEdgeOptions);N=E?{...E,...N}:N;let L=N.type||"default",A=(j==null?void 0:j[L])||np[L];A===void 0&&(_==null||_("011",on.error011(L)),L="default",A=(j==null?void 0:j.default)||np.default);const V=!!(N.focusable||r&&typeof N.focusable>"u"),z=typeof x<"u"&&(N.reconnectable||o&&typeof N.reconnectable>"u"),G=!!(N.selectable||s&&typeof N.selectable>"u"),ee=O.useRef(null),[J,ne]=O.useState(!1),[q,C]=O.useState(!1),W=Ye(),{zIndex:U=N.zIndex,sourceX:Y,sourceY:T,targetX:F,targetY:B,sourcePosition:M,targetPosition:R}=ze(O.useCallback(xe=>{const pe=xe.nodeLookup.get(N.source),be=xe.nodeLookup.get(N.target);if(!pe||!be)return rp;const Pe=y1({id:t,sourceNode:pe,targetNode:be,sourceHandle:N.sourceHandle||null,targetHandle:N.targetHandle||null,connectionMode:xe.connectionMode,onError:_}),Ce=u1({selected:N.selected,zIndex:N.zIndex,sourceNode:pe,targetNode:be,elevateOnSelect:xe.elevateEdgesOnSelect,zIndexMode:xe.zIndexMode});return{...Pe||rp,zIndex:Ce}},[N.source,N.target,N.sourceHandle,N.targetHandle,N.selected,N.zIndex,_]),Ke),re=O.useMemo(()=>N.markerStart?`url('#${Zu(N.markerStart,k)}')`:void 0,[N.markerStart,k]),ie=O.useMemo(()=>N.markerEnd?`url('#${Zu(N.markerEnd,k)}')`:void 0,[N.markerEnd,k]);if(N.hidden||Y===null||T===null||F===null||B===null)return null;const ce=xe=>{var Ce;const{addSelectedEdges:pe,unselectNodesAndEdges:be,multiSelectionActive:Pe}=W.getState();G&&(W.setState({nodesSelectionActive:!1}),N.selected&&Pe?(be({nodes:[],edges:[N]}),(Ce=ee.current)==null||Ce.blur()):pe([t])),a&&a(xe,N)},fe=u?xe=>{u(xe,{...N})}:void 0,de=c?xe=>{c(xe,{...N})}:void 0,Q=f?xe=>{f(xe,{...N})}:void 0,le=g?xe=>{g(xe,{...N})}:void 0,me=y?xe=>{y(xe,{...N})}:void 0,ke=xe=>{var pe;if(!P&&eg.includes(xe.key)&&G){const{unselectNodesAndEdges:be,addSelectedEdges:Pe}=W.getState();xe.key==="Escape"?((pe=ee.current)==null||pe.blur(),be({edges:[N]})):Pe([t])}};return h.jsx("svg",{style:{zIndex:U},children:h.jsxs("g",{className:it(["react-flow__edge",`react-flow__edge-${L}`,N.className,b,{selected:N.selected,animated:N.animated,inactive:!G&&!a,updating:J,selectable:G}]),onClick:ce,onDoubleClick:fe,onContextMenu:de,onMouseEnter:Q,onMouseMove:le,onMouseLeave:me,onKeyDown:V?ke:void 0,tabIndex:V?0:void 0,role:N.ariaRole??(V?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":N.ariaLabel===null?void 0:N.ariaLabel||`Edge from ${N.source} to ${N.target}`,"aria-describedby":V?`${Rg}-${k}`:void 0,ref:ee,...N.domAttributes,children:[!q&&h.jsx(A,{id:t,source:N.source,target:N.target,type:N.type,selected:N.selected,animated:N.animated,selectable:G,deletable:N.deletable??!0,label:N.label,labelStyle:N.labelStyle,labelShowBg:N.labelShowBg,labelBgStyle:N.labelBgStyle,labelBgPadding:N.labelBgPadding,labelBgBorderRadius:N.labelBgBorderRadius,sourceX:Y,sourceY:T,targetX:F,targetY:B,sourcePosition:M,targetPosition:R,data:N.data,style:N.style,sourceHandleId:N.sourceHandle,targetHandleId:N.targetHandle,markerStart:re,markerEnd:ie,pathOptions:"pathOptions"in N?N.pathOptions:void 0,interactionWidth:N.interactionWidth}),z&&h.jsx(PS,{edge:N,isReconnectable:z,reconnectRadius:v,onReconnect:x,onReconnectStart:m,onReconnectEnd:S,sourceX:Y,sourceY:T,targetX:F,targetY:B,sourcePosition:M,targetPosition:R,setUpdateHover:ne,setReconnecting:C})]})})}var TS=O.memo(IS);const RS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function om({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:f,onEdgeMouseMove:g,onEdgeMouseLeave:y,onEdgeClick:v,reconnectRadius:x,onEdgeDoubleClick:m,onReconnectStart:S,onReconnectEnd:k,disableKeyboardA11y:j}){const{edgesFocusable:b,edgesReconnectable:_,elementsSelectable:P,onError:N}=ze(RS,Ke),E=yS(r);return h.jsxs("div",{className:"react-flow__edges",children:[h.jsx(SS,{defaultColor:t,rfId:o}),E.map(L=>h.jsx(TS,{id:L,edgesFocusable:b,edgesReconnectable:_,elementsSelectable:P,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:f,onMouseMove:g,onMouseLeave:y,onClick:v,reconnectRadius:x,onDoubleClick:m,onReconnectStart:S,onReconnectEnd:k,rfId:o,onError:N,edgeTypes:s,disableKeyboardA11y:j},L))]})}om.displayName="EdgeRenderer";const LS=O.memo(om),sp=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function AS({children:t}){const r=Ye(),o=O.useRef(null),[s]=O.useState(()=>r.getState().transform);return Dg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=sp(c)))};return u(),r.subscribe(u)},[r]),h.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:sp(s)},children:t})}function zS(t){const r=Ll(),o=O.useRef(!1);O.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const DS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function $S(t){const r=ze(DS),o=Ye();return O.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function OS(t){return t.connection.inProgress?{...t.connection,to:Wo(t.connection.to,t.transform)}:{...t.connection}}function FS(t){return OS}function HS(t){const r=FS();return ze(r,Ke)}const BS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function VS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:f,inProgress:g}=ze(BS,Ke);return!(u&&a&&g)?null:h.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:h.jsx("g",{className:it(["react-flow__connection",rg(f)]),children:h.jsx(sm,{style:r,type:o,CustomComponent:s,isValid:f})})})}const sm=({style:t,type:r=hr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:f,fromPosition:g,to:y,toNode:v,toHandle:x,toPosition:m,pointer:S}=HS();if(!a)return;if(o)return h.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:f,fromX:u.x,fromY:u.y,toX:y.x,toY:y.y,fromPosition:g,toPosition:m,connectionStatus:rg(s),toNode:v,toHandle:x,pointer:S});let k="";const j={sourceX:u.x,sourceY:u.y,sourcePosition:g,targetX:y.x,targetY:y.y,targetPosition:m};switch(r){case hr.Bezier:[k]=mg(j);break;case hr.SimpleBezier:[k]=Gg(j);break;case hr.Step:[k]=Qu({...j,borderRadius:0});break;case hr.SmoothStep:[k]=Qu(j);break;default:[k]=vg(j)}return h.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};sm.displayName="ConnectionLine";const WS={};function lp(t=WS){O.useRef(t),Ye(),O.useEffect(()=>{},[t])}function US(){Ye(),O.useRef(!1),O.useEffect(()=>{},[])}function lm({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:f,onNodeMouseMove:g,onNodeMouseLeave:y,onNodeContextMenu:v,onSelectionContextMenu:x,onSelectionStart:m,onSelectionEnd:S,connectionLineType:k,connectionLineStyle:j,connectionLineComponent:b,connectionLineContainerStyle:_,selectionKeyCode:P,selectionOnDrag:N,selectionMode:E,multiSelectionKeyCode:L,panActivationKeyCode:A,zoomActivationKeyCode:V,deleteKeyCode:z,onlyRenderVisibleElements:G,elementsSelectable:ee,defaultViewport:J,translateExtent:ne,minZoom:q,maxZoom:C,preventScrolling:W,defaultMarkerColor:U,zoomOnScroll:Y,zoomOnPinch:T,panOnScroll:F,panOnScrollSpeed:B,panOnScrollMode:M,zoomOnDoubleClick:R,panOnDrag:re,autoPanOnSelection:ie,onPaneClick:ce,onPaneMouseEnter:fe,onPaneMouseMove:de,onPaneMouseLeave:Q,onPaneScroll:le,onPaneContextMenu:me,paneClickDistance:ke,nodeClickDistance:xe,onEdgeContextMenu:pe,onEdgeMouseEnter:be,onEdgeMouseMove:Pe,onEdgeMouseLeave:Ce,reconnectRadius:Re,onReconnect:tt,onReconnectStart:nt,onReconnectEnd:Je,noDragClassName:Qe,noWheelClassName:ot,noPanClassName:Pt,disableKeyboardA11y:st,nodeExtent:ft,rfId:He,viewport:Le,onViewportChange:mt,nodesDraggable:an}){return lp(t),lp(r),US(),zS(o),$S(Le),h.jsx(lS,{onPaneClick:ce,onPaneMouseEnter:fe,onPaneMouseMove:de,onPaneMouseLeave:Q,onPaneContextMenu:me,onPaneScroll:le,paneClickDistance:ke,deleteKeyCode:z,selectionKeyCode:P,selectionOnDrag:N,selectionMode:E,onSelectionStart:m,onSelectionEnd:S,multiSelectionKeyCode:L,panActivationKeyCode:A,zoomActivationKeyCode:V,elementsSelectable:ee,zoomOnScroll:Y,zoomOnPinch:T,zoomOnDoubleClick:R,panOnScroll:F,panOnScrollSpeed:B,panOnScrollMode:M,panOnDrag:re,autoPanOnSelection:ie,defaultViewport:J,translateExtent:ne,minZoom:q,maxZoom:C,onSelectionContextMenu:x,preventScrolling:W,noDragClassName:Qe,noWheelClassName:ot,noPanClassName:Pt,disableKeyboardA11y:st,onViewportChange:mt,isControlledViewport:!!Le,children:h.jsxs(AS,{children:[h.jsx(LS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:tt,onReconnectStart:nt,onReconnectEnd:Je,onlyRenderVisibleElements:G,onEdgeContextMenu:pe,onEdgeMouseEnter:be,onEdgeMouseMove:Pe,onEdgeMouseLeave:Ce,reconnectRadius:Re,defaultMarkerColor:U,noPanClassName:Pt,disableKeyboardA11y:st,rfId:He}),h.jsx(VS,{style:j,type:k,component:b,containerStyle:_}),h.jsx("div",{className:"react-flow__edgelabel-renderer"}),h.jsx(mS,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:f,onNodeMouseMove:g,onNodeMouseLeave:y,onNodeContextMenu:v,nodeClickDistance:xe,onlyRenderVisibleElements:G,noPanClassName:Pt,noDragClassName:Qe,disableKeyboardA11y:st,nodeExtent:ft,rfId:He,nodesDraggable:an}),h.jsx("div",{className:"react-flow__viewport-portal"})]})})}lm.displayName="GraphView";const YS=O.memo(lm),GS=ug(),ap=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:f,minZoom:g=.5,maxZoom:y=2,nodeOrigin:v,nodeExtent:x,zIndexMode:m="basic"}={})=>{const S=new Map,k=new Map,j=new Map,b=new Map,_=s??r??[],P=o??t??[],N=v??[0,0],E=x??To;_g(j,b,_);const{nodesInitialized:L}=Ju(P,S,k,{nodeOrigin:N,nodeExtent:E,zIndexMode:m});let A=[0,0,1];if(c&&a&&u){const V=Bo(S,{filter:J=>!!((J.width||J.initialWidth)&&(J.height||J.initialHeight))}),{x:z,y:G,zoom:ee}=pc(V,a,u,g,y,(f==null?void 0:f.padding)??.1);A=[z,G,ee]}return{rfId:"1",width:a??0,height:u??0,transform:A,nodes:P,nodesInitialized:L,nodeLookup:S,parentLookup:k,edges:_,edgeLookup:b,connectionLookup:j,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:g,maxZoom:y,translateExtent:To,nodeExtent:E,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ai.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:N,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:c??!1,fitViewOptions:f,fitViewResolver:null,connection:{...ng},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:GS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:tg,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},XS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:f,minZoom:g,maxZoom:y,nodeOrigin:v,nodeExtent:x,zIndexMode:m})=>s_((S,k)=>{async function j(){const{nodeLookup:b,panZoom:_,fitViewOptions:P,fitViewResolver:N,width:E,height:L,minZoom:A,maxZoom:V}=k();_&&(await n1({nodes:b,width:E,height:L,panZoom:_,minZoom:A,maxZoom:V},P),N==null||N.resolve(!0),S({fitViewResolver:null}))}return{...ap({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:f,minZoom:g,maxZoom:y,nodeOrigin:v,nodeExtent:x,defaultNodes:o,defaultEdges:s,zIndexMode:m}),setNodes:b=>{const{nodeLookup:_,parentLookup:P,nodeOrigin:N,nodeExtent:E,elevateNodesOnSelect:L,fitViewQueued:A,zIndexMode:V,nodesSelectionActive:z}=k(),{nodesInitialized:G,hasSelectedNodes:ee}=Ju(b,_,P,{nodeOrigin:N,nodeExtent:E,elevateNodesOnSelect:L,checkEquality:!0,zIndexMode:V}),J=z&ⅇA&&G?(j(),S({nodes:b,nodesInitialized:G,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:J})):S({nodes:b,nodesInitialized:G,nodesSelectionActive:J})},setEdges:b=>{const{connectionLookup:_,edgeLookup:P}=k();_g(_,P,b),S({edges:b})},setDefaultNodesAndEdges:(b,_)=>{if(b){const{setNodes:P}=k();P(b),S({hasDefaultNodes:!0})}if(_){const{setEdges:P}=k();P(_),S({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:_,nodeLookup:P,parentLookup:N,domNode:E,nodeOrigin:L,nodeExtent:A,debug:V,fitViewQueued:z,zIndexMode:G}=k(),{changes:ee,updatedInternals:J}=E1(b,P,N,E,L,A,G);J&&(_1(P,N,{nodeOrigin:L,nodeExtent:A,zIndexMode:G}),z?(j(),S({fitViewQueued:!1,fitViewOptions:void 0})):S({}),(ee==null?void 0:ee.length)>0&&(V&&console.log("React Flow: trigger node changes",ee),_==null||_(ee)))},updateNodePositions:(b,_=!1)=>{const P=[];let N=[];const{nodeLookup:E,triggerNodeChanges:L,connection:A,updateConnection:V,onNodesChangeMiddlewareMap:z}=k();for(const[G,ee]of b){const J=E.get(G),ne=!!(J!=null&&J.expandParent&&(J!=null&&J.parentId)&&(ee!=null&&ee.position)),q={id:G,type:"position",position:ne?{x:Math.max(0,ee.position.x),y:Math.max(0,ee.position.y)}:ee.position,dragging:_};if(J&&A.inProgress&&A.fromNode.id===J.id){const C=Ur(J,A.fromHandle,Se.Left,!0);V({...A,from:C})}ne&&J.parentId&&P.push({id:G,parentId:J.parentId,rect:{...ee.internals.positionAbsolute,width:ee.measured.width??0,height:ee.measured.height??0}}),N.push(q)}if(P.length>0){const{parentLookup:G,nodeOrigin:ee}=k(),J=wc(P,E,G,ee);N.push(...J)}for(const G of z.values())N=G(N);L(N)},triggerNodeChanges:b=>{const{onNodesChange:_,setNodes:P,nodes:N,hasDefaultNodes:E,debug:L}=k();if(b!=null&&b.length){if(E){const A=b_(b,N);P(A)}L&&console.log("React Flow: trigger node changes",b),_==null||_(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:_,setEdges:P,edges:N,hasDefaultEdges:E,debug:L}=k();if(b!=null&&b.length){if(E){const A=C_(b,N);P(A)}L&&console.log("React Flow: trigger edge changes",b),_==null||_(b)}},addSelectedNodes:b=>{const{multiSelectionActive:_,edgeLookup:P,nodeLookup:N,triggerNodeChanges:E,triggerEdgeChanges:L}=k();if(_){const A=b.map(V=>zr(V,!0));E(A);return}E(Pi(N,new Set([...b]),!0)),L(Pi(P))},addSelectedEdges:b=>{const{multiSelectionActive:_,edgeLookup:P,nodeLookup:N,triggerNodeChanges:E,triggerEdgeChanges:L}=k();if(_){const A=b.map(V=>zr(V,!0));L(A);return}L(Pi(P,new Set([...b]))),E(Pi(N,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:_}={})=>{const{edges:P,nodes:N,nodeLookup:E,triggerNodeChanges:L,triggerEdgeChanges:A}=k(),V=b||N,z=_||P,G=[];for(const J of V){if(!J.selected)continue;const ne=E.get(J.id);ne&&(ne.selected=!1),G.push(zr(J.id,!1))}const ee=[];for(const J of z)J.selected&&ee.push(zr(J.id,!1));L(G),A(ee)},setMinZoom:b=>{const{panZoom:_,maxZoom:P}=k();_==null||_.setScaleExtent([b,P]),S({minZoom:b})},setMaxZoom:b=>{const{panZoom:_,minZoom:P}=k();_==null||_.setScaleExtent([P,b]),S({maxZoom:b})},setTranslateExtent:b=>{var _;(_=k().panZoom)==null||_.setTranslateExtent(b),S({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:_,triggerNodeChanges:P,triggerEdgeChanges:N,elementsSelectable:E}=k();if(!E)return;const L=_.reduce((V,z)=>z.selected?[...V,zr(z.id,!1)]:V,[]),A=b.reduce((V,z)=>z.selected?[...V,zr(z.id,!1)]:V,[]);P(L),N(A)},setNodeExtent:b=>{const{nodes:_,nodeLookup:P,parentLookup:N,nodeOrigin:E,elevateNodesOnSelect:L,nodeExtent:A,zIndexMode:V}=k();b[0][0]===A[0][0]&&b[0][1]===A[0][1]&&b[1][0]===A[1][0]&&b[1][1]===A[1][1]||(Ju(_,P,N,{nodeOrigin:E,nodeExtent:b,elevateNodesOnSelect:L,checkEquality:!1,zIndexMode:V}),S({nodeExtent:b}))},panBy:b=>{const{transform:_,width:P,height:N,panZoom:E,translateExtent:L}=k();return j1({delta:b,panZoom:E,transform:_,translateExtent:L,width:P,height:N})},setCenter:async(b,_,P)=>{const{width:N,height:E,maxZoom:L,panZoom:A}=k();if(!A)return!1;const V=typeof(P==null?void 0:P.zoom)<"u"?P.zoom:L;return await A.setViewport({x:N/2-b*V,y:E/2-_*V,zoom:V},{duration:P==null?void 0:P.duration,ease:P==null?void 0:P.ease,interpolate:P==null?void 0:P.interpolate}),!0},cancelConnection:()=>{S({connection:{...ng}})},updateConnection:b=>{S({connection:b})},reset:()=>S({...ap()})}},Object.is);function am({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:f,initialFitViewOptions:g,fitView:y,nodeOrigin:v,nodeExtent:x,zIndexMode:m,children:S}){const[k]=O.useState(()=>XS({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:y,minZoom:c,maxZoom:f,fitViewOptions:g,nodeOrigin:v,nodeExtent:x,zIndexMode:m}));return h.jsx(l_,{value:k,children:h.jsx(R_,{children:h.jsx(X_,{children:S})})})}function qS({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:f,fitViewOptions:g,minZoom:y,maxZoom:v,nodeOrigin:x,nodeExtent:m,zIndexMode:S}){return O.useContext(Tl)?h.jsx(h.Fragment,{children:t}):h.jsx(am,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:f,initialFitViewOptions:g,initialMinZoom:y,initialMaxZoom:v,nodeOrigin:x,nodeExtent:m,zIndexMode:S,children:t})}const KS={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function QS({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:f,onEdgeClick:g,onInit:y,onMove:v,onMoveStart:x,onMoveEnd:m,onConnect:S,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:_,onNodeMouseEnter:P,onNodeMouseMove:N,onNodeMouseLeave:E,onNodeContextMenu:L,onNodeDoubleClick:A,onNodeDragStart:V,onNodeDrag:z,onNodeDragStop:G,onNodesDelete:ee,onEdgesDelete:J,onDelete:ne,onSelectionChange:q,onSelectionDragStart:C,onSelectionDrag:W,onSelectionDragStop:U,onSelectionContextMenu:Y,onSelectionStart:T,onSelectionEnd:F,onBeforeDelete:B,connectionMode:M,connectionLineType:R=hr.Bezier,connectionLineStyle:re,connectionLineComponent:ie,connectionLineContainerStyle:ce,deleteKeyCode:fe="Backspace",selectionKeyCode:de="Shift",selectionOnDrag:Q=!1,selectionMode:le=Ro.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:ke=zo()?"Meta":"Control",zoomActivationKeyCode:xe=zo()?"Meta":"Control",snapToGrid:pe,snapGrid:be,onlyRenderVisibleElements:Pe=!1,selectNodesOnDrag:Ce,nodesDraggable:Re,autoPanOnNodeFocus:tt,nodesConnectable:nt,nodesFocusable:Je,nodeOrigin:Qe=Lg,edgesFocusable:ot,edgesReconnectable:Pt,elementsSelectable:st=!0,defaultViewport:ft=w_,minZoom:He=.5,maxZoom:Le=2,translateExtent:mt=To,preventScrolling:an=!0,nodeExtent:ht,defaultMarkerColor:Gt="#b1b1b7",zoomOnScroll:_n=!0,zoomOnPinch:zn=!0,panOnScroll:Gr=!1,panOnScrollSpeed:It=.5,panOnScrollMode:Sn=Fr.Free,zoomOnDoubleClick:Dn=!0,panOnDrag:un=!0,onPaneClick:$n,onPaneMouseEnter:gr,onPaneMouseMove:cn,onPaneMouseLeave:dn,onPaneScroll:Xr,onPaneContextMenu:qr,paneClickDistance:Kr=1,nodeClickDistance:Qr=0,children:On,onReconnect:mr,onReconnectStart:Fn,onReconnectEnd:kn,onEdgeContextMenu:yr,onEdgeDoubleClick:fn,onEdgeMouseEnter:vr,onEdgeMouseMove:hn,onEdgeMouseLeave:Hn,reconnectRadius:Bn=10,onNodesChange:xr,onEdgesChange:Zr,noDragClassName:Jr="nodrag",noWheelClassName:ei="nowheel",noPanClassName:Tt="nopan",fitView:Vn,fitViewOptions:Wn,connectOnClick:ti,attributionPosition:wr,proOptions:D,defaultEdgeOptions:te,elevateNodesOnSelect:_e=!0,elevateEdgesOnSelect:Ie=!1,disableKeyboardA11y:Me=!1,autoPanOnConnect:Fe,autoPanOnNodeDrag:$l,autoPanOnSelection:Fi=!0,autoPanSpeed:Uo,connectionRadius:ni,isValidConnection:Ol,onError:Yo,style:ri,id:Rt,nodeDragThreshold:Fl,connectionDragThreshold:Lt,viewport:Hl,onViewportChange:Bl,width:Vl,height:ii,colorMode:oi="light",debug:_r,onScroll:Nn,ariaLabelConfig:Wl,zIndexMode:Go="basic",...Hi},Xo){const Sr=Rt||"1",kr=N_(oi),Ul=O.useCallback(si=>{si.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Nn==null||Nn(si)},[Nn]);return h.jsx("div",{"data-testid":"rf__wrapper",...Hi,onScroll:Ul,style:{...ri,...KS},ref:Xo,className:it(["react-flow",a,kr]),id:Rt,role:"application",children:h.jsxs(qS,{nodes:t,edges:r,width:Vl,height:ii,fitView:Vn,fitViewOptions:Wn,minZoom:He,maxZoom:Le,nodeOrigin:Qe,nodeExtent:ht,zIndexMode:Go,children:[h.jsx(k_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:S,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:_,nodesDraggable:Re,autoPanOnNodeFocus:tt,nodesConnectable:nt,nodesFocusable:Je,edgesFocusable:ot,edgesReconnectable:Pt,elementsSelectable:st,elevateNodesOnSelect:_e,elevateEdgesOnSelect:Ie,minZoom:He,maxZoom:Le,nodeExtent:ht,onNodesChange:xr,onEdgesChange:Zr,snapToGrid:pe,snapGrid:be,connectionMode:M,translateExtent:mt,connectOnClick:ti,defaultEdgeOptions:te,fitView:Vn,fitViewOptions:Wn,onNodesDelete:ee,onEdgesDelete:J,onDelete:ne,onNodeDragStart:V,onNodeDrag:z,onNodeDragStop:G,onSelectionDrag:W,onSelectionDragStart:C,onSelectionDragStop:U,onMove:v,onMoveStart:x,onMoveEnd:m,noPanClassName:Tt,nodeOrigin:Qe,rfId:Sr,autoPanOnConnect:Fe,autoPanOnNodeDrag:$l,autoPanSpeed:Uo,onError:Yo,connectionRadius:ni,isValidConnection:Ol,selectNodesOnDrag:Ce,nodeDragThreshold:Fl,connectionDragThreshold:Lt,onBeforeDelete:B,debug:_r,ariaLabelConfig:Wl,zIndexMode:Go}),h.jsx(YS,{onInit:y,onNodeClick:f,onEdgeClick:g,onNodeMouseEnter:P,onNodeMouseMove:N,onNodeMouseLeave:E,onNodeContextMenu:L,onNodeDoubleClick:A,nodeTypes:u,edgeTypes:c,connectionLineType:R,connectionLineStyle:re,connectionLineComponent:ie,connectionLineContainerStyle:ce,selectionKeyCode:de,selectionOnDrag:Q,selectionMode:le,deleteKeyCode:fe,multiSelectionKeyCode:ke,panActivationKeyCode:me,zoomActivationKeyCode:xe,onlyRenderVisibleElements:Pe,defaultViewport:ft,translateExtent:mt,minZoom:He,maxZoom:Le,preventScrolling:an,zoomOnScroll:_n,zoomOnPinch:zn,zoomOnDoubleClick:Dn,panOnScroll:Gr,panOnScrollSpeed:It,panOnScrollMode:Sn,panOnDrag:un,autoPanOnSelection:Fi,onPaneClick:$n,onPaneMouseEnter:gr,onPaneMouseMove:cn,onPaneMouseLeave:dn,onPaneScroll:Xr,onPaneContextMenu:qr,paneClickDistance:Kr,nodeClickDistance:Qr,onSelectionContextMenu:Y,onSelectionStart:T,onSelectionEnd:F,onReconnect:mr,onReconnectStart:Fn,onReconnectEnd:kn,onEdgeContextMenu:yr,onEdgeDoubleClick:fn,onEdgeMouseEnter:vr,onEdgeMouseMove:hn,onEdgeMouseLeave:Hn,reconnectRadius:Bn,defaultMarkerColor:Gt,noDragClassName:Jr,noWheelClassName:ei,noPanClassName:Tt,rfId:Sr,disableKeyboardA11y:Me,nodeExtent:ht,viewport:Hl,onViewportChange:Bl,nodesDraggable:Re}),h.jsx(x_,{onSelectionChange:q}),On,h.jsx(p_,{proOptions:D,position:wr}),h.jsx(h_,{rfId:Sr,disableKeyboardA11y:Me})]})})}var ZS=zg(QS);function JS({dimensions:t,lineWidth:r,variant:o,className:s}){return h.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:it(["react-flow__background-pattern",o,s])})}function ek({radius:t,className:r}){return h.jsx("circle",{cx:t,cy:t,r:t,className:it(["react-flow__background-pattern","dots",r])})}var pr;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(pr||(pr={}));const tk={[pr.Dots]:1,[pr.Lines]:1,[pr.Cross]:6},nk=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function um({id:t,variant:r=pr.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:f,style:g,className:y,patternClassName:v}){const x=O.useRef(null),{transform:m,patternId:S}=ze(nk,Ke),k=s||tk[r],j=r===pr.Dots,b=r===pr.Cross,_=Array.isArray(o)?o:[o,o],P=[_[0]*m[2]||1,_[1]*m[2]||1],N=k*m[2],E=Array.isArray(u)?u:[u,u],L=b?[N,N]:P,A=[E[0]*m[2]+L[0]/2,E[1]*m[2]+L[1]/2],V=`${S}${t||""}`;return h.jsxs("svg",{className:it(["react-flow__background",y]),style:{...g,...Al,"--xy-background-color-props":f,"--xy-background-pattern-color-props":c},ref:x,"data-testid":"rf__background",children:[h.jsx("pattern",{id:V,x:m[0]%P[0],y:m[1]%P[1],width:P[0],height:P[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${A[0]},-${A[1]})`,children:j?h.jsx(ek,{radius:N/2,className:v}):h.jsx(JS,{dimensions:L,lineWidth:a,variant:r,className:v})}),h.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${V})`})]})}um.displayName="Background";const rk=O.memo(um);function ik(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:h.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ok(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:h.jsx("path",{d:"M0 0h32v4.2H0z"})})}function sk(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:h.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 lk(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:h.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 ak(){return h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:h.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 il({children:t,className:r,...o}){return h.jsx("button",{type:"button",className:it(["react-flow__controls-button",r]),...o,children:t})}const uk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function cm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:f,onInteractiveChange:g,className:y,children:v,position:x="bottom-left",orientation:m="vertical","aria-label":S}){const k=Ye(),{isInteractive:j,minZoomReached:b,maxZoomReached:_,ariaLabelConfig:P}=ze(uk,Ke),{zoomIn:N,zoomOut:E,fitView:L}=Ll(),A=()=>{N(),u==null||u()},V=()=>{E(),c==null||c()},z=()=>{L(a),f==null||f()},G=()=>{k.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),g==null||g(!j)},ee=m==="horizontal"?"horizontal":"vertical";return h.jsxs(Rl,{className:it(["react-flow__controls",ee,y]),position:x,style:t,"data-testid":"rf__controls","aria-label":S??P["controls.ariaLabel"],children:[r&&h.jsxs(h.Fragment,{children:[h.jsx(il,{onClick:A,className:"react-flow__controls-zoomin",title:P["controls.zoomIn.ariaLabel"],"aria-label":P["controls.zoomIn.ariaLabel"],disabled:_,children:h.jsx(ik,{})}),h.jsx(il,{onClick:V,className:"react-flow__controls-zoomout",title:P["controls.zoomOut.ariaLabel"],"aria-label":P["controls.zoomOut.ariaLabel"],disabled:b,children:h.jsx(ok,{})})]}),o&&h.jsx(il,{className:"react-flow__controls-fitview",onClick:z,title:P["controls.fitView.ariaLabel"],"aria-label":P["controls.fitView.ariaLabel"],children:h.jsx(sk,{})}),s&&h.jsx(il,{className:"react-flow__controls-interactive",onClick:G,title:P["controls.interactive.ariaLabel"],"aria-label":P["controls.interactive.ariaLabel"],children:j?h.jsx(ak,{}):h.jsx(lk,{})}),v]})}cm.displayName="Controls";const ck=O.memo(cm);function dk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:f,strokeWidth:g,className:y,borderRadius:v,shapeRendering:x,selected:m,onClick:S}){const{background:k,backgroundColor:j}=u||{},b=c||k||j;return h.jsx("rect",{className:it(["react-flow__minimap-node",{selected:m},y]),x:r,y:o,rx:v,ry:v,width:s,height:a,style:{fill:b,stroke:f,strokeWidth:g},shapeRendering:x,onClick:S?_=>S(_,t):void 0})}const fk=O.memo(dk),hk=t=>t.nodes.map(r=>r.id),Ou=t=>t instanceof Function?t:()=>t;function pk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=fk,onClick:c}){const f=ze(hk,Ke),g=Ou(r),y=Ou(t),v=Ou(o),x=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return h.jsx(h.Fragment,{children:f.map(m=>h.jsx(mk,{id:m,nodeColorFunc:g,nodeStrokeColorFunc:y,nodeClassNameFunc:v,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:x},m))})}function gk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:f,onClick:g}){const{node:y,x:v,y:x,width:m,height:S}=ze(k=>{const j=k.nodeLookup.get(t);if(!j)return{node:void 0,x:0,y:0,width:0,height:0};const b=j.internals.userNode,{x:_,y:P}=j.internals.positionAbsolute,{width:N,height:E}=ln(b);return{node:b,x:_,y:P,width:N,height:E}},Ke);return!y||y.hidden||!cg(y)?null:h.jsx(f,{x:v,y:x,width:m,height:S,style:y.style,selected:!!y.selected,className:s(y),color:r(y),borderRadius:a,strokeColor:o(y),strokeWidth:u,shapeRendering:c,onClick:g,id:y.id})}const mk=O.memo(gk);var yk=O.memo(pk);const vk=200,xk=150,wk=t=>!t.hidden,_k=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?lg(Bo(t.nodeLookup,{filter:wk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},up=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,Sk=(t,r)=>up(t.viewBB,r.viewBB)&&up(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,kk="react-flow__minimap-desc";function dm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:f,bgColor:g,maskColor:y,maskStrokeColor:v,maskStrokeWidth:x,position:m="bottom-right",onClick:S,onNodeClick:k,pannable:j=!1,zoomable:b=!1,ariaLabel:_,inversePan:P,zoomStep:N=1,offsetScale:E=5}){const L=Ye(),A=O.useRef(null),{boundingRect:V,viewBB:z,rfId:G,panZoom:ee,translateExtent:J,flowWidth:ne,flowHeight:q,ariaLabelConfig:C}=ze(_k,Sk),W=(t==null?void 0:t.width)??vk,U=(t==null?void 0:t.height)??xk,Y=V.width/W,T=V.height/U,F=Math.max(Y,T),B=F*W,M=F*U,R=E*F,re=V.x-(B-V.width)/2-R,ie=V.y-(M-V.height)/2-R,ce=B+R*2,fe=M+R*2,de=`${kk}-${G}`,Q=O.useRef(0),le=O.useRef();Q.current=F,O.useEffect(()=>{if(A.current&&ee)return le.current=A1({domNode:A.current,panZoom:ee,getTransform:()=>L.getState().transform,getViewScale:()=>Q.current}),()=>{var pe;(pe=le.current)==null||pe.destroy()}},[ee]),O.useEffect(()=>{var pe;(pe=le.current)==null||pe.update({translateExtent:J,width:ne,height:q,inversePan:P,pannable:j,zoomStep:N,zoomable:b})},[j,b,P,N,J,ne,q]);const me=S?pe=>{var Ce;const[be,Pe]=((Ce=le.current)==null?void 0:Ce.pointer(pe))||[0,0];S(pe,{x:be,y:Pe})}:void 0,ke=k?O.useCallback((pe,be)=>{const Pe=L.getState().nodeLookup.get(be).internals.userNode;k(pe,Pe)},[]):void 0,xe=_??C["minimap.ariaLabel"];return h.jsx(Rl,{position:m,style:{...t,"--xy-minimap-background-color-props":typeof g=="string"?g:void 0,"--xy-minimap-mask-background-color-props":typeof y=="string"?y:void 0,"--xy-minimap-mask-stroke-color-props":typeof v=="string"?v:void 0,"--xy-minimap-mask-stroke-width-props":typeof x=="number"?x*F:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:it(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:h.jsxs("svg",{width:W,height:U,viewBox:`${re} ${ie} ${ce} ${fe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":de,ref:A,onClick:me,children:[xe&&h.jsx("title",{id:de,children:xe}),h.jsx(yk,{onClick:ke,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:f}),h.jsx("path",{className:"react-flow__minimap-mask",d:`M${re-R},${ie-R}h${ce+R*2}v${fe+R*2}h${-ce-R*2}z - M${z.x},${z.y}h${z.width}v${z.height}h${-z.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}dm.displayName="MiniMap";const Nk=O.memo(dm),Ek=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,jk={[$i.Line]:"right",[$i.Handle]:"bottom-right"};function bk({nodeId:t,position:r,variant:o=$i.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:f=10,minHeight:g=10,maxWidth:y=Number.MAX_VALUE,maxHeight:v=Number.MAX_VALUE,keepAspectRatio:x=!1,resizeDirection:m,autoScale:S=!0,shouldResize:k,onResizeStart:j,onResize:b,onResizeEnd:_}){const P=Hg(),N=typeof t=="string"?t:P,E=Ye(),L=O.useRef(null),A=o===$i.Handle,V=ze(O.useCallback(Ek(A&&S),[A,S]),Ke),z=O.useRef(null),G=r??jk[o];O.useEffect(()=>{if(!(!L.current||!N))return z.current||(z.current=X1({domNode:L.current,nodeId:N,getStoreItems:()=>{const{nodeLookup:J,transform:ne,snapGrid:q,snapToGrid:C,nodeOrigin:W,domNode:U}=E.getState();return{nodeLookup:J,transform:ne,snapGrid:q,snapToGrid:C,nodeOrigin:W,paneDomNode:U}},onChange:(J,ne)=>{const{triggerNodeChanges:q,nodeLookup:C,parentLookup:W,nodeOrigin:U}=E.getState(),Y=[],T={x:J.x,y:J.y},F=C.get(N);if(F&&F.expandParent&&F.parentId){const B=F.origin??U,M=J.width??F.measured.width??0,R=J.height??F.measured.height??0,re={id:F.id,parentId:F.parentId,rect:{width:M,height:R,...dg({x:J.x??F.position.x,y:J.y??F.position.y},{width:M,height:R},F.parentId,C,B)}},ie=wc([re],C,W,U);Y.push(...ie),T.x=J.x?Math.max(B[0]*M,J.x):void 0,T.y=J.y?Math.max(B[1]*R,J.y):void 0}if(T.x!==void 0&&T.y!==void 0){const B={id:N,type:"position",position:{...T}};Y.push(B)}if(J.width!==void 0&&J.height!==void 0){const M={id:N,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:J.width,height:J.height}};Y.push(M)}for(const B of ne){const M={...B,type:"position"};Y.push(M)}q(Y)},onEnd:({width:J,height:ne})=>{const q={id:N,type:"dimensions",resizing:!1,dimensions:{width:J,height:ne}};E.getState().triggerNodeChanges([q])}})),z.current.update({controlPosition:G,boundaries:{minWidth:f,minHeight:g,maxWidth:y,maxHeight:v},keepAspectRatio:x,resizeDirection:m,onResizeStart:j,onResize:b,onResizeEnd:_,shouldResize:k}),()=>{var J;(J=z.current)==null||J.destroy()}},[G,f,g,y,v,x,j,b,_,k]);const ee=G.split("-");return h.jsx("div",{className:it(["react-flow__resize-control","nodrag",...ee,o,s]),ref:L,style:{...a,scale:V,...c&&{[A?"backgroundColor":"borderColor"]:c}},children:u})}O.memo(bk);const Ck={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function Dl(t){return Ck[t]??8}const nc=208,rc=64,Mk=88,Pk=28,Ik=8;function Tk(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function Rk(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const _ of t){const P=Dl(_.type),N=s.get(P)??[];N.push(_),s.set(P,N)}const u=[...s.keys()].sort((_,P)=>_-P).map(_=>[...s.get(_)??[]].sort((P,N)=>P.name.localeCompare(N.name)||P.id.localeCompare(N.id))),c=new Set(t.map(_=>_.id)),f=new Map,g=new Map;for(const _ of t)f.set(_.id,[]),g.set(_.id,[]);for(const _ of r)!c.has(_.src)||!c.has(_.dst)||_.src===_.dst||(g.get(_.src).push(_.dst),f.get(_.dst).push(_.src));const y=new Map;u.forEach((_,P)=>{for(const N of _)y.set(N.id,P)});const v=new Map,x=()=>{for(const _ of u)_.forEach((P,N)=>v.set(P.id,N))};x();const m=(_,P)=>{const N=_.map((E,L)=>{const A=P(E.id).map(z=>v.get(z)).filter(z=>z!==void 0),V=Tk(A);return{n:E,bary:Number.isNaN(V)?L:V,name:E.name,id:E.id}});return N.sort((E,L)=>E.bary-L.bary||E.name.localeCompare(L.name)||E.id.localeCompare(L.id)),N.map(E=>E.n)},S=_=>P=>y.get(P)===_;for(let _=0;_(f.get(N)??[]).filter(S(P-1))),x();for(let P=u.length-2;P>=0;P--)u[P]=m(u[P],N=>(g.get(N)??[]).filter(S(P+1))),x()}const k=nc+Mk,j=rc+Pk,b=Math.max(...u.map(_=>_.length),1);return u.forEach((_,P)=>{const N=(b-_.length)*j/2;_.forEach((E,L)=>{o.set(E.id,{x:P*k,y:N+L*j})})}),o}const fm=90,Lk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),cp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Ak=Math.PI*(3-Math.sqrt(5)),hm=220,zk=26,Dk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function pm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function _N(t){return cp[t]?cp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function $k(t){return t>=fm?"3d":"2d"}function Ok(t){return t>=fm?"overview":"full"}function Fk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(pm(f.type)));o.detail==="overview"&&(s=s.filter(f=>!Lk.has(f.type)));const a=new Set(s.map(f=>f.id)),u=r.filter(f=>a.has(f.src)&&a.has(f.dst)),c=o.focusId?Fk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(g=>c.has(g.id));const f=new Set(s.map(g=>g.id));return{nodes:s,edges:u.filter(g=>f.has(g.src)&&f.has(g.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function SN(t){const r=new Map;for(const s of t){const a=Dl(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,f)=>c.name.localeCompare(f.name));const u=s*hm;a.forEach((c,f)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const g=zk*Math.sqrt(f+1),y=f*Ak;o.set(c.id,{x:u,y:g*Math.cos(y),z:g*Math.sin(y)})})}return o}function kN(t){const r=new Map;for(const o of t){const s=Dl(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*hm,count:s}))}const ol=16,Bk=12,Vk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Wk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),dp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Uk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},fp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],hp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Yk=new Set(["looks_idempotent_on_pk","null","blank"]),Gk=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function Xk(t){return dp[t]?dp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function qk(t,r,o){const s=new Map(r.map(m=>[m.id,m])),a=[];Vk.has(t.type)&&a.push("sink"),Wk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(m=>m.dst===t.id),f=o.filter(m=>m.src===t.id),g=c.slice(0,ol).map(m=>sl(m,s,m.src)),y=f.slice(0,ol).map(m=>sl(m,s,m.dst)),v=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,x={type:t.type,typeLabel:bo(kl(t.type)),layer:Dk[Dl(t.type)]??"other",purpose:Xk(t.type),name:t.name,qualifiedName:t.qualified_name,file:v,context:t.context,roles:a,facts:Qk(u).filter(m=>!(m.key==="app"&&m.value===t.context)),inputs:g,outputs:y,extraInputs:Math.max(0,c.length-ol),extraOutputs:Math.max(0,f.length-ol),degreeIn:c.length,degreeOut:f.length,inputKinds:pp(c.map(m=>sl(m,s,m.src))),outputKinds:pp(f.map(m=>sl(m,s,m.dst))),pathSummary:""};return x.pathSummary=Kk(x),x}function pp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function Kk(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function sl(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?bo(kl(s.type)):"",edgeType:t.type,edgeLabel:bo(t.type),inferred:t.confidence<.8}}function Qk(t){const r=[...fp.filter(a=>a in t),...Object.keys(t).filter(a=>!fp.includes(a)&&!hp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||hp.has(a)||Gk.has(a))continue;s.add(a);const u=Zk(a,t[a]);u!=null&&o.push({key:a,label:Uk[a]??bo(a),value:u})}return o}function Zk(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Yk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return Jk(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Bk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function Jk(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),f=Array.isArray(a.accessed)?a.accessed.join("."):"",g=a.line?` L${a.line}`:"";return f?`${c} → ${f}${g}`:`${c}${g}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",f=String(a.kind||"filter");return c?`${f} ${c}`:f}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,f])=>`${c}=${f}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const eN=new Set,tN=O.lazy(()=>v0(()=>import("./LayeredGraph3D-DBrjUozl.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),nN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function rN({data:t,selected:r}){return h.jsxs("div",{className:r?"lp-node selected":"lp-node",children:[h.jsx(Oi,{type:"target",position:Se.Left,isConnectable:!1}),h.jsx("div",{className:"t",children:kl(t.type)}),h.jsx("div",{className:"n",title:t.name,children:Dr(t.name)}),h.jsx(Oi,{type:"source",position:Se.Right,isConnectable:!1})]})}const iN={load:rN},oN=new Set(["django","react","stitch","arch"]);function sN({topologyKey:t}){const{fitView:r}=Ll();return O.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function lN(t,r,o=null){const s=new Map(t.map(f=>[f.id,f])),a=Rk(t,r),u=t.map(f=>({id:f.id,type:"load",position:a.get(f.id)??{x:0,y:0},data:{name:f.name,type:f.type,file:f.file_path},selected:o===f.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:nc,height:rc,style:{width:nc,height:rc}})),c=r.filter(f=>s.has(f.src)&&s.has(f.dst)).map(f=>{const g=nN[f.weight]||"var(--edge-cheap)",y=!!(o&&(f.src===o||f.dst===o));return{id:f.id,source:f.src,target:f.dst,type:"smoothstep",animated:f.weight==="critical",style:{stroke:g,strokeWidth:f.weight==="critical"?2.4:1.2,strokeDasharray:f.confidence<.8?"6 4":void 0},markerEnd:{type:Lo.ArrowClosed,width:14,height:14,color:g},label:y?f.type.replaceAll("_"," "):void 0,labelStyle:y?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:y?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:y?[3,5]:void 0,labelBgBorderRadius:y?4:void 0}});return{rfNodes:u,rfEdges:c}}function gp({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a}){const u=qk(t,r,o);return O.useEffect(()=>{const c=f=>{f.key==="Escape"&&s()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[s]),h.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[h.jsxs("div",{className:"inspector-head",children:[h.jsx("div",{className:"t",children:u.typeLabel}),h.jsx("div",{className:"inspector-roles",children:u.roles.map(c=>h.jsx("span",{className:"inspector-chip",children:c},c))}),h.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),h.jsx("div",{className:"n",children:Dr(u.name)}),h.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:u.purpose}),u.context?h.jsx("div",{className:"muted",children:Dr(u.context)}):null,u.file?h.jsx("div",{className:"file",children:Dr(u.file)}):null,h.jsx("div",{className:"muted",children:Dr(u.qualifiedName)}),h.jsxs("div",{className:"muted inspector-layer",children:["layer · ",u.layer]}),h.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[u.degreeIn," in · ",u.degreeOut," out"]}),u.pathSummary?h.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:u.pathSummary}):null,u.facts.length?h.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:u.facts.map(c=>h.jsxs("div",{className:"inspector-fact",children:[h.jsx("dt",{children:c.label}),h.jsx("dd",{children:Dr(c.value)})]},c.key))}):null,h.jsx(mp,{title:"Inputs",testId:"graph-inspector-inputs",links:u.inputs,extra:u.extraInputs,empty:"Nothing in this graph points here."}),h.jsx(mp,{title:"Outputs",testId:"graph-inspector-outputs",links:u.outputs,extra:u.extraOutputs,empty:"This node does not point at anything in this graph."}),a?h.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",onClick:()=>a(t.id),children:"What if this changes"}):null]})}function mp({title:t,testId:r,links:o,extra:s,empty:a}){return h.jsxs("section",{className:"inspector-section","data-testid":r,children:[h.jsxs("h3",{children:[t,h.jsx("span",{className:"count",children:o.length+s})]}),o.length?h.jsx("ul",{children:o.map((u,c)=>h.jsxs("li",{children:[h.jsx("span",{className:"inspector-link-name",title:u.name,children:Dr(u.name)}),h.jsxs("span",{className:"inspector-link-meta",children:[u.typeLabel?`${u.typeLabel} · `:"",u.edgeLabel,u.inferred?" · inferred":""]})]},`${u.edgeType}:${u.id}:${c}`))}):h.jsx("p",{className:"muted",children:a}),s?h.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Fu({nodes:t,edges:r,onWhatIf:o,focusPath:s}){const[a,u]=O.useState(null),[c,f]=O.useState(null),[g,y]=O.useState(null),[v,x]=O.useState(new Set(oN)),[m,S]=O.useState(!1),k=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,j=c??$k(t.length),b=g??Ok(t.length),_=m&&j==="3d"?a:null,P=O.useMemo(()=>Hk(t,r,{detail:b,families:v,focusId:_,neighborhoodOnly:!!_}),[t,r,b,v,_]),N=O.useMemo(()=>`${P.nodes.map(q=>q.id).join("\0")}|${P.edges.map(q=>q.id).join("\0")}`,[P.nodes,P.edges]),E=O.useMemo(()=>new Map(P.nodes.map(q=>[q.id,q])),[P.nodes]),L=a?E.get(a)??null:null,{rfNodes:A,rfEdges:V}=O.useMemo(()=>{const q=lN(P.nodes,P.edges,a);return k&&(q.rfEdges=q.rfEdges.map(C=>({...C,animated:!1}))),q},[P.nodes,P.edges,a,k]);O.useEffect(()=>{a&&!E.has(a)&&u(null)},[E,a]),O.useEffect(()=>{if(!s)return;const q=t.find(C=>C.file_path===s);q&&u(q.id)},[s,t]);const z=(q,C)=>{u(C.id)},G=()=>{u(null),S(!1)},ee=q=>{x(C=>{const W=new Set(C);if(W.has(q)){if(W.size===1)return C;W.delete(q)}else W.add(q);return W})},J=O.useMemo(()=>{const q=new Set;for(const C of t)q.add(pm(C.type));return q},[t]),ne=t.length-P.nodes.length;return h.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[h.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[h.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[h.jsx("button",{type:"button","data-testid":"graph-view-2d",className:j==="2d"?"active":"","aria-pressed":j==="2d",onClick:()=>f("2d"),children:"2D map"}),h.jsx("button",{type:"button","data-testid":"graph-view-3d",className:j==="3d"?"active":"","aria-pressed":j==="3d",onClick:()=>f("3d"),children:"3D layers"})]}),h.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[h.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:b==="overview"?"active":"","aria-pressed":b==="overview",onClick:()=>y("overview"),children:"Overview"}),h.jsx("button",{type:"button","data-testid":"graph-detail-full",className:b==="full"?"active":"","aria-pressed":b==="full",onClick:()=>y("full"),children:"Full"})]}),h.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(q=>J.has(q)).map(q=>h.jsx("button",{type:"button","data-testid":`graph-family-${q}`,className:v.has(q)?"active":"","aria-pressed":v.has(q),onClick:()=>ee(q),children:q},q))}),j==="3d"?h.jsx("button",{type:"button",className:m?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!a,onClick:()=>S(q=>!q),children:m?"Neighborhood":"Focus neighbors"}):null,h.jsxs("span",{className:"muted graph-count",children:[P.nodes.length," nodes · ",P.edges.length," edges",ne?` · ${ne} hidden`:""]})]}),h.jsx("div",{className:"graph-stage",children:j==="3d"?h.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[h.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),h.jsx(O.Suspense,{fallback:h.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:h.jsx(tN,{nodes:P.nodes,edges:P.edges,selectedId:a,neighborIds:_?P.neighborIds:eN,onSelect:q=>{u(q),q||S(!1)}})}),L?h.jsx(gp,{node:L,nodes:t,edges:r,onClose:G,onWhatIf:o}):null]}):h.jsxs(am,{children:[h.jsxs(ZS,{nodes:A,edges:V,nodeTypes:iN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:z,onPaneClick:G,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[h.jsx(sN,{topologyKey:N}),h.jsx(rk,{}),h.jsx(Nk,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),h.jsx(ck,{})]}),L?h.jsx(gp,{node:L,nodes:t,edges:r,onClose:G,onWhatIf:o}):null]})})]})}const yp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],aN=["preset","branch","tag","commit"];function uN(t){var a;if(!(t!=null&&t.git))return[...yp];const r=((a=t.presets)!=null&&a.length?t.presets:yp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function cN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function dN(t){return aN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function fN(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function vp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const f=O.useId(),g=O.useRef(null),[y,v]=O.useState(!1),[x,m]=O.useState(null),[S,k]=O.useState(0),j=O.useMemo(()=>{const E=uN(u);return x===null?E:cN(E,x)},[u,x]),b=O.useMemo(()=>dN(j),[j]);O.useEffect(()=>{y&&c()},[y,c]),O.useEffect(()=>{k(0)},[x,y]);const _=()=>{v(!1),m(null)},P=E=>{r(E.value),_()},N=E=>{if(E.key==="ArrowDown"){if(E.preventDefault(),!y){v(!0);return}k(L=>Math.min(L+1,Math.max(j.length-1,0)))}else if(E.key==="ArrowUp"){if(E.preventDefault(),!y)return;k(L=>Math.max(L-1,0))}else if(E.key==="Enter"&&y){E.preventDefault();const L=j[S];L&&P(L)}else E.key==="Escape"&&y&&(E.preventDefault(),_())};return h.jsxs("div",{className:"combo",ref:g,onBlur:E=>{E.currentTarget.contains(E.relatedTarget)||_()},children:[h.jsxs("div",{className:"combo-row",children:[h.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":y,"aria-controls":f,"aria-autocomplete":"list",onChange:E=>{r(E.target.value),y&&m(E.target.value)},onKeyDown:N}),h.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":y,onMouseDown:E=>E.preventDefault(),onClick:()=>y?_():v(!0),children:h.jsx(g0,{})})]}),y?h.jsx("div",{className:"combo-menu",id:f,role:"listbox","data-testid":a,children:b.length===0?h.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):b.map(E=>h.jsxs("div",{className:"combo-group",children:[h.jsx("div",{className:"combo-heading",children:fN(E.group)}),E.items.map(L=>{const A=j.indexOf(L);return h.jsxs("button",{type:"button",role:"option","aria-selected":A===S,className:A===S?"combo-option active":"combo-option","data-testid":`ref-option-${L.group}`,onMouseDown:V=>V.preventDefault(),onMouseEnter:()=>k(A),onClick:()=>P(L),children:[h.jsx("span",{className:"combo-label",children:L.label}),L.detail?h.jsx("span",{className:"combo-detail",children:L.detail}):null]},`${L.group}:${L.value}`)})]},E.group))}):null]})}function hN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=O.useState(null),[u,c]=O.useState(t),[f,g]=O.useState(null),[y,v]=O.useState(""),[x,m]=O.useState(!1),S=O.useRef(null),k=O.useRef(0),j=async N=>{const E=k.current+1;k.current=E,m(!0);try{const L=await $e.browse(N);if(k.current!==E)return;a(L),c(L.path),g(L.is_git?L.path:null),v("")}catch(L){if(k.current!==E)return;v(L instanceof Error?L.message:String(L))}finally{k.current===E&&m(!1)}};O.useEffect(()=>{var N,E;j(t),(N=S.current)==null||N.focus(),(E=S.current)==null||E.select()},[t]);const b=f||(s==null?void 0:s.path)||u,_=f&&f!==(s==null?void 0:s.path)?f.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",P=N=>{N.key==="Escape"&&(N.preventDefault(),o())};return h.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:P,children:h.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:N=>N.stopPropagation(),children:[h.jsxs("div",{className:"modal-head",children:[h.jsxs("div",{children:[h.jsx("h2",{id:"explorer-title",children:"Select repository"}),h.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),h.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),h.jsxs("form",{className:"explorer-path",onSubmit:N=>{N.preventDefault(),j(u)},children:[h.jsx("input",{ref:S,"data-testid":"explorer-path",value:u,onChange:N=>c(N.target.value),spellCheck:!1,"aria-label":"Directory path"}),h.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),h.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),h.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),y?h.jsx("div",{className:"error",role:"alert",children:y}):null,h.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":x,children:s!=null&&s.entries.length?s.entries.map(N=>{const E=f===N.path;return h.jsxs("button",{type:"button",role:"option","aria-selected":E,className:E?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":N.path,onClick:()=>g(N.path),onDoubleClick:()=>void j(N.path),children:[h.jsx(kp,{}),h.jsx("span",{className:"explorer-name",children:N.name}),N.is_git?h.jsx("span",{className:"chip git-badge",children:"git"}):null]},N.path)}):h.jsx("div",{className:"muted explorer-empty",children:x?"Loading…":"No folders here"})}),h.jsxs("div",{className:"modal-foot",children:[h.jsx("span",{className:"muted explorer-current",title:b,children:b}),h.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!b,onClick:()=>b&&r(b),children:["Use ",_]})]})]})})}const Sl=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],pN="obsidian",gm="loadpath.theme";function gN(t){return Sl.some(r=>r.id===t)}function mm(){try{const t=localStorage.getItem(gm)||"";if(gN(t))return t}catch{}return pN}function mN(t){var r;return((r=Sl.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function ym(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=mN(t);try{localStorage.setItem(gm,t)}catch{}}const xp=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:c0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:d0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:f0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:h0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:p0}];function yN(t){const r=t.total||0;return r<=0?null:Math.min(100,Math.round(100*(t.done||0)/r))}function Hu(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function vN(){var Zr,Jr,ei,Tt,Vn,Wn,ti,wr;const[t,r]=O.useState("review"),[o,s]=O.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=O.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,f]=O.useState(localStorage.getItem("loadpath.head")||"HEAD"),[g,y]=O.useState(null),[v,x]=O.useState(null),[m,S]=O.useState([]),[k,j]=O.useState("review"),[b,_]=O.useState(""),[P,N]=O.useState(""),[E,L]=O.useState(null),[A,V]=O.useState(!1),[z,G]=O.useState(""),[ee,J]=O.useState({}),[ne,q]=O.useState([]),[C,W]=O.useState([]),[U,Y]=O.useState(localStorage.getItem("loadpath.scmRepo")||""),[T,F]=O.useState(localStorage.getItem("loadpath.provider")||"github"),[B,M]=O.useState(localStorage.getItem("loadpath.prNumber")||""),[R,re]=O.useState(localStorage.getItem("loadpath.dirty")==="1"),[ie,ce]=O.useState(0),[fe,de]=O.useState(""),[Q,le]=O.useState(mm),[me,ke]=O.useState(!1),[xe,pe]=O.useState(!1),[be,Pe]=O.useState(null),[Ce,Re]=O.useState(null),[tt,nt]=O.useState(!1),[Je,Qe]=O.useState(!1),ot=O.useRef(o);ot.current=o;const Pt=O.useRef(!1);Pt.current=xe;const st=O.useRef(""),ft=D=>{le(D),ym(D)},He=O.useRef(""),Le=D=>{He.current=D,N(D)},mt=D=>{const te=()=>{$e.indexProgress(D).then(Ie=>{He.current&&(Ie.phase&&Ie.phase!=="idle"&&Ie.message&&Le(Ie.message),L(Ie.phase&&Ie.phase!=="idle"?yN(Ie):null))}).catch(()=>{})};te();const _e=window.setInterval(te,250);return()=>{window.clearInterval(_e),L(null)}};O.useEffect(()=>{$e.settings().then(J).catch(()=>{}).finally(()=>ke(!0)),$e.repos().then(D=>S(D.repos)).catch(()=>{})},[]);const an=()=>o.trim()?!0:(_("Point at a local repository path first."),!1);O.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const D=o;let te=!1;return $e.architecture(D).then(_e=>{!te&&ot.current===D&&x(_e)}).catch(()=>{}),()=>{te=!0}},[t,o]);const ht=D=>{ot.current=D,s(D),localStorage.setItem("loadpath.repo",D),D.trim()!==st.current&&(st.current="",Pe(null))},Gt=O.useCallback(D=>{const te=(D??ot.current).trim();return!te||st.current===te?Promise.resolve():(st.current=te,$e.gitRefs(te).then(_e=>{ot.current.trim()===te&&Pe(_e)}).catch(()=>{st.current===te&&(st.current="",Pe(null))}))},[]),_n=(D,te)=>{u(D),f(te),localStorage.setItem("loadpath.base",D),localStorage.setItem("loadpath.head",te)},zn=(D,te,_e)=>{F(D),Y(te),localStorage.setItem("loadpath.provider",D),localStorage.setItem("loadpath.scmRepo",te),_e!==void 0&&(M(_e),localStorage.setItem("loadpath.prNumber",_e))},Gr=D=>D==="github"?!!ee.github_token_set:D==="gitlab"?!!ee.gitlab_token_set:!!ee.bitbucket_token_set,It=O.useCallback(async(D=T)=>{var te;try{const _e=await $e.scmRepos(D);W(_e.repos),(te=_e.user)!=null&&te.login&&J(Ie=>({...Ie,...D==="github"?{github_user:_e.user.login}:D==="gitlab"?{gitlab_user:_e.user.login}:{bitbucket_user:_e.user.login}}))}catch{W([])}},[T]);O.useEffect(()=>{if(t!=="prs")return;let D=!1;return It(T).catch(()=>{D||W([])}),()=>{D=!0}},[t,T,It]),O.useEffect(()=>{if(!Ce)return;let D=!1,te=0;const _e=async()=>{try{const Ie=await $e.githubOAuthPoll(Ce.flow_id);if(D)return;if(Ie.status==="complete"){Re(null);const Me=await $e.settings();J(Me),G(Ie.user?`Signed in to GitHub as ${Ie.user}`:"Signed in to GitHub"),It("github");return}if(Ie.status==="pending"||Ie.status==="slow_down"){te=window.setTimeout(_e,Math.max(Ie.interval||Ce.interval,5)*1e3);return}Re(null),_(Ie.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(Ie){if(D)return;Re(null),_(Ie instanceof Error?Ie.message:String(Ie))}};return te=window.setTimeout(_e,Math.max(Ce.interval,5)*1e3),()=>{D=!0,window.clearTimeout(te)}},[Ce,It]),O.useEffect(()=>{if(!tt)return;let D=!1,te=0;const _e=Date.now(),Ie=async()=>{try{const Me=await $e.oauthStatus();if(D)return;if(Me.bitbucket.connected){nt(!1);const Fe=await $e.settings();J(Fe),G(Me.bitbucket.user?`Signed in to Bitbucket as ${Me.bitbucket.user}`:"Signed in to Bitbucket"),It("bitbucket");return}if(Date.now()-_e>18e4){nt(!1),_("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}te=window.setTimeout(Ie,1500)}catch(Me){if(D)return;nt(!1),_(Me instanceof Error?Me.message:String(Me))}};return te=window.setTimeout(Ie,1500),()=>{D=!0,window.clearTimeout(te)}},[tt,It]),O.useEffect(()=>{if(!Je)return;let D=!1,te=0;const _e=Date.now(),Ie=async()=>{try{const Me=await $e.oauthStatus();if(D)return;if(Me.gitlab.connected){Qe(!1);const Fe=await $e.settings();J(Fe),G(Me.gitlab.user?`Signed in to GitLab as ${Me.gitlab.user}`:"Signed in to GitLab"),It("gitlab");return}if(Date.now()-_e>18e4){Qe(!1),_("GitLab sign-in timed out. Finish in the browser, or try again.");return}te=window.setTimeout(Ie,1500)}catch(Me){if(D)return;Qe(!1),_(Me instanceof Error?Me.message:String(Me))}};return te=window.setTimeout(Ie,1500),()=>{D=!0,window.clearTimeout(te)}},[Je,It]);const Sn=async(D=o)=>{if(!D.trim())return null;const te=await $e.architecture(D);return ot.current===D&&x(te),te},Dn=async D=>{const te=D.trim();if(!(!te||te===ot.current)){if(He.current){_("Wait for the current job to finish before switching workspace.");return}_(""),G(""),y(null),x(null),j("architecture"),ht(te),V(!0),Le(`Loading ${u0(te)}…`);try{await Promise.all([Sn(te),Gt(te)])}catch(_e){ot.current===te&&_(_e instanceof Error?_e.message:String(_e))}finally{ot.current===te&&(Le(""),V(!1))}}},un=async()=>{if(He.current||!an())return;_(""),G(""),Le("Tracing load path…"),ht(o),_n(a,c);const D=mt(o);try{const te=await $e.review(o,a,c,!0,R);y(te),ce(0),j("review"),r("review"),await $e.repos().then(_e=>S(_e.repos)).catch(()=>{}),await Sn(o)}catch(te){_(te instanceof Error?te.message:String(te))}finally{D(),Le("")}},$n=async(D=!0)=>{if(He.current||!an())return;_(""),G(""),Le(D?"Indexing…":"Full reindex…"),ht(o);const te=mt(o);try{await $e.index(o,D);const _e=await Sn(o);await $e.repos().then(Ie=>S(Ie.repos)).catch(()=>{}),_e!=null&&_e.indexed&&(j("architecture"),r("architecture"))}catch(_e){_(_e instanceof Error?_e.message:String(_e))}finally{te(),Le("")}},gr=async()=>{if(!He.current&&an()){_(""),G(""),Le("Detecting layout…"),ht(o);try{const D=await $e.init(o);G(D.message),await $e.repos().then(te=>S(te.repos)).catch(()=>{})}catch(D){_(D instanceof Error?D.message:String(D))}finally{Le("")}}},cn=async()=>{if(g!=null&&g.markdown)try{await navigator.clipboard.writeText(g.markdown),G("Copied markdown brief")}catch(D){_(D instanceof Error?D.message:String(D))}},dn=async()=>{if(!He.current){if(!(g!=null&&g.markdown)||!U||!B){_("Pick a pull request first (Pull requests tab), then post the brief.");return}Le("Posting Loadpath brief…");try{const D=await $e.postComment(T,U,Number(B),g.markdown);G(D.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(D){_(D instanceof Error?D.message:String(D))}finally{Le("")}}},Xr=async()=>{if(!He.current){_(""),Le("Fetching pull requests…");try{const D=await $e.prs(T,U);q(D.pull_requests);const te=C.find(_e=>_e.slug.toLowerCase()===U.trim().toLowerCase());te!=null&&te.local_path&&ht(te.local_path)}catch(D){_(D instanceof Error?D.message:String(D))}finally{Le("")}}},qr=async()=>{_("");try{const D=await $e.githubOAuthStart();Re(D),Hu(D.verification_uri_complete,"github.com","/login/device")}catch(D){_(D instanceof Error?D.message:String(D))}},Kr=async()=>{_("");try{const D=await $e.bitbucketOAuthStart();nt(!0),Hu(D.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(D){nt(!1),_(D instanceof Error?D.message:String(D))}},Qr=async()=>{_("");try{const D=await $e.gitlabOAuthStart();Qe(!0),Hu(D.authorize_url,new URL(D.authorize_url).hostname,"/oauth/authorize")}catch(D){Qe(!1),_(D instanceof Error?D.message:String(D))}},On=async D=>{if(!(He.current||!o.trim())){_(""),Le("Walking what-if path…");try{const te=await $e.whatIf(o,D);G(`${te.title} — ${te.confidence.level} · ${(te.sinks||[]).length} sinks`),y({...te,markdown:te.markdown||"",index:te.index||(g==null?void 0:g.index),workspace:te.workspace||(g==null?void 0:g.workspace)}),ce(0),j("review"),r("review")}catch(te){_(te instanceof Error?te.message:String(te))}finally{Le("")}}},mr=async D=>{if(He.current)return;zn(D.provider,D.repo,String(D.number));const te=C.find(Me=>Me.slug.toLowerCase()===D.repo.toLowerCase());te!=null&&te.local_path&&ht(te.local_path),_(""),Le(`Fetching ${D.provider} #${D.number}…`);const _e=(te==null?void 0:te.local_path)||o,Ie=_e?mt(_e):()=>{};try{const Me=await $e.reviewPr(D.provider,D.repo,D.number,(te==null?void 0:te.local_path)||o||void 0);y(Me),ce(0),Me.pull_request&&typeof Me.pull_request.repo_path=="string"&&ht(Me.pull_request.repo_path),_n(String(Me.base||D.target_branch),String(Me.head||D.source_branch)),j("review"),r("review")}catch(Me){_n(D.base_sha||D.target_branch,D.head_sha||D.source_branch),r("review"),_(Me instanceof Error?Me.message:String(Me))}finally{Ie(),Le("")}},Fn=async D=>{_("");try{J(await $e.oauthDisconnect(D)),T===D&&W([]),G(`Disconnected ${D}`)}catch(te){_(te instanceof Error?te.message:String(te))}},kn=async D=>{D.preventDefault();const te=new FormData(D.currentTarget),_e={github_token:String(te.get("github_token")||""),github_oauth_client_id:String(te.get("github_oauth_client_id")||""),github_host:String(te.get("github_host")||""),gitlab_token:String(te.get("gitlab_token")||""),gitlab_host:String(te.get("gitlab_host")||""),gitlab_oauth_client_id:String(te.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(te.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(te.get("bitbucket_token")||""),bitbucket_username:String(te.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(te.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(te.get("bitbucket_oauth_client_secret")||""),ai_provider:String(te.get("ai_provider")||"none"),ai_api_key:String(te.get("ai_api_key")||""),ai_model:String(te.get("ai_model")||""),ai_base_url:String(te.get("ai_base_url")||"")},Ie=m.length?{..._e,workspaces:m.map(Me=>({path:Me.path,name:Me.name}))}:_e;try{J(await $e.saveSettings(Ie)),G("Settings saved on this machine")}catch(Me){_(Me instanceof Error?Me.message:String(Me))}},yr=async()=>{if(!(!g||He.current)){Le("Residual analysis…");try{const D=await $e.residual(g);de(D.note)}catch(D){_(D instanceof Error?D.message:String(D))}finally{Le("")}}},fn=O.useRef(un);fn.current=un;const vr=O.useRef(t);vr.current=t,O.useEffect(()=>{const D=te=>{if(Pt.current){te.key==="Escape"&&(te.preventDefault(),pe(!1));return}const _e=te.target;if(_e&&(_e.tagName==="INPUT"||_e.tagName==="TEXTAREA"||_e.tagName==="SELECT"||_e.isContentEditable)){te.key==="Escape"&&_e.blur();return}if(te.key==="Escape"){_(""),G("");return}const Ie=xp.find(Me=>Me.shortcut===te.key);if(Ie&&!te.metaKey&&!te.ctrlKey&&!te.altKey&&r(Ie.id),(te.metaKey||te.ctrlKey)&&te.key==="Enter"){if(vr.current==="settings"||vr.current==="prs"||He.current)return;te.preventDefault(),fn.current()}};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[]);const hn=O.useMemo(()=>k==="architecture"?(v==null?void 0:v.nodes)??[]:(g==null?void 0:g.nodes)??[],[k,v,g]),Hn=O.useMemo(()=>k==="architecture"?(v==null?void 0:v.edges)??[]:(g==null?void 0:g.edges)??[],[k,v,g]),Bn=g!=null&&g.index?`${g.index.counts.nodes} nodes · ${g.index.counts.edges} edges`:v!=null&&v.indexed?`${v.counts.nodes} nodes · ${v.counts.edges} edges`:"Not indexed",xr=((g==null?void 0:g.findings)||[]).filter(D=>!D.waived);return h.jsxs("div",{className:"app",children:[h.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),h.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[h.jsxs("div",{className:"brand",children:[h.jsx("div",{className:"brand-mark",children:"Loadpath"}),h.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),xp.map(D=>{const te=D.icon,_e=t===D.id;return h.jsxs("button",{type:"button","data-testid":D.testId,className:_e?"nav-item active":"nav-item","aria-current":_e?"page":void 0,"aria-label":D.label,onClick:()=>r(D.id),children:[h.jsx(te,{}),h.jsx("span",{children:D.label})]},D.id)}),h.jsxs("div",{className:"theme-pick",children:[h.jsx("label",{htmlFor:"theme-select",children:"Theme"}),h.jsx("select",{id:"theme-select","data-testid":"theme-select",value:Q,onChange:D=>ft(D.target.value),children:["dark","light"].map(D=>h.jsx("optgroup",{label:D==="dark"?"Dark":"Light",children:Sl.filter(te=>te.group===D).map(te=>h.jsx("option",{value:te.id,children:te.label},te.id))},D))})]}),h.jsxs("div",{className:"rail-foot",children:[h.jsx("div",{className:"muted",role:"status",children:P||Bn}),h.jsxs("div",{className:"kbd-hint",children:[h.jsx("kbd",{children:"1"}),"–",h.jsx("kbd",{children:"5"})," tabs · ",h.jsx("kbd",{children:"Ctrl"}),"+",h.jsx("kbd",{children:"Enter"})," review"]})]})]}),h.jsxs("div",{className:"main",id:"main",children:[P?h.jsxs("div",{className:E!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","data-testid":"progress",children:[h.jsx("i",{style:E!=null?{width:`${E}%`}:void 0}),h.jsx("span",{className:"sr-only",children:P})]}):null,h.jsxs("header",{className:"topbar","data-testid":"topbar",children:[m.length>0?h.jsxs("label",{className:"field workspace",children:[h.jsx("span",{children:"Workspace"}),h.jsxs("select",{"data-testid":"workspace-select",value:m.some(D=>D.path===o)?o:"",disabled:!!P,"aria-busy":A,onChange:D=>{D.target.value&&Dn(D.target.value)},children:[h.jsx("option",{value:"",children:"Indexed repos…"}),m.map(D=>h.jsxs("option",{value:D.path,children:[D.name,D.indexed?` (${D.counts.nodes})`:""]},D.path))]})]}):null,h.jsxs("label",{className:"field path",children:[h.jsx("span",{children:"Repository"}),h.jsxs("div",{className:"path-row",children:[h.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:D=>{const te=D.target.value;s(te),te.trim()!==st.current&&(st.current="",Pe(null))},spellCheck:!1}),h.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>pe(!0),children:h.jsx(kp,{})})]})]}),h.jsxs("label",{className:"field ref",children:[h.jsx("span",{children:"Base"}),h.jsx(vp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:D=>_n(D,c),placeholder:"base",refs:be,onNeedRefs:Gt})]}),h.jsxs("label",{className:"field ref",children:[h.jsx("span",{children:"Head"}),h.jsx(vp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:D=>_n(a,D),placeholder:"head",refs:be,onNeedRefs:Gt})]}),h.jsxs("label",{className:"field dirty",children:[h.jsx("span",{children:"Working tree"}),h.jsx("button",{type:"button",className:R?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":R,onClick:()=>{const D=!R;re(D),localStorage.setItem("loadpath.dirty",D?"1":"0")},children:R?"Include uncommitted":"Committed range"})]}),h.jsxs("div",{className:"topbar-actions",children:[h.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!P,onClick:gr,children:"Draft config"}),h.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!P,onClick:()=>$n(!0),children:"Index"}),h.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!P,onClick:un,children:"Review"})]})]}),h.jsxs("div",{className:"alerts",children:[b?h.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[h.jsx("span",{children:b}),h.jsx("button",{type:"button",className:"dismiss",onClick:()=>_(""),"aria-label":"Dismiss error",children:"×"})]}):null,z?h.jsxs("div",{className:"banner","data-testid":"status-note",children:[h.jsx("span",{children:z}),h.jsx("button",{type:"button",className:"dismiss",onClick:()=>G(""),"aria-label":"Dismiss",children:"×"})]}):null,((Zr=g==null?void 0:g.index)!=null&&Zr.stale||v!=null&&v.stale)&&(t==="review"||t==="architecture")?h.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((Jr=g==null?void 0:g.index)==null?void 0:Jr.django_boot)==="failed"||(v==null?void 0:v.django_boot)==="failed"?h.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((ei=g==null?void 0:g.index)==null?void 0:ei.django_boot_detail)||(v==null?void 0:v.django_boot_detail)||"django.setup() failed"}):null,(Tt=g==null?void 0:g.workspace)!=null&&Tt.dirty_overlaps_review&&t==="review"?h.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(g.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null]}),h.jsxs("div",{className:"stage","aria-busy":A,children:[A?h.jsxs("div",{className:"empty workspace-loading","data-testid":"workspace-loading",children:[h.jsx("h2",{children:P}),h.jsx("p",{children:"Fetching the indexed graph for this repository."})]}):null,!A&&t==="review"&&h.jsxs("div",{className:"content","data-testid":"review-layout",children:[h.jsx("aside",{className:"brief","data-testid":"brief",children:g?h.jsx(xN,{review:g,findings:xr,aiNote:fe,busy:!!P,tourIndex:ie,onTour:ce,onAskAi:yr,onCopy:cn,onPost:dn}):h.jsxs("div",{className:"empty","data-testid":"review-empty",children:[h.jsx("h2",{children:"Trace the force of this diff"}),h.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),h.jsxs("ol",{children:[h.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),h.jsxs("li",{children:["Index it. Missing ",h.jsx("code",{children:"loadpath.yml"})," is drafted from ",h.jsx("code",{children:"manage.py"})," and"," ",h.jsx("code",{children:"src/features"}),"."]}),h.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),h.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:g?h.jsx(Fu,{nodes:g.nodes,edges:g.edges,onWhatIf:On,focusPath:(Vn=g.read_order[ie])==null?void 0:Vn.path}):null})]}),!A&&t==="architecture"&&h.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[h.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:v!=null&&v.indexed?h.jsx(wN,{architecture:v,busy:!!P,onReindex:()=>$n(!1),onReview:un}):h.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),h.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:v!=null&&v.indexed?h.jsx(Fu,{nodes:v.nodes,edges:v.edges,onWhatIf:On}):null})]}),!A&&t==="graph"&&h.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[h.jsxs("div",{className:"graph-modes",children:[h.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[h.jsx("button",{type:"button","aria-pressed":k==="review","data-testid":"graph-mode-review",className:k==="review"?"active":"",onClick:()=>j("review"),children:"This review"}),h.jsx("button",{type:"button","aria-pressed":k==="architecture","data-testid":"graph-mode-architecture",className:k==="architecture"?"active":"",onClick:()=>j("architecture"),children:"Indexed architecture"})]}),h.jsxs("div",{className:"legend","aria-hidden":"true",children:[h.jsxs("span",{children:[h.jsx("i",{})," cheap"]}),h.jsxs("span",{children:[h.jsx("i",{className:"exp"})," expensive"]}),h.jsxs("span",{children:[h.jsx("i",{className:"crit"})," critical"]}),h.jsxs("span",{children:[h.jsx("i",{className:"dash"})," inferred"]})]})]}),hn.length?h.jsx(Fu,{nodes:hn,edges:Hn,onWhatIf:On}):h.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),!A&&t==="prs"&&h.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[h.jsxs("div",{className:"pr-toolbar",children:[h.jsxs("label",{className:"field provider",children:[h.jsx("span",{children:"Provider"}),h.jsxs("select",{"data-testid":"pr-provider",value:T,onChange:D=>zn(D.target.value,U,B),children:[h.jsx("option",{value:"github",children:"GitHub"}),h.jsx("option",{value:"gitlab",children:"GitLab"}),h.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),h.jsxs("label",{className:"field",children:[h.jsx("span",{children:"Repository"}),h.jsx("input",{"data-testid":"pr-repo",placeholder:C.length?"Search your repos":"owner/repo",value:U,onChange:D=>zn(T,D.target.value,B),list:"scm-repos",spellCheck:!1}),h.jsx("datalist",{id:"scm-repos",children:C.map(D=>h.jsxs("option",{value:D.slug,children:[D.private?"private":"public",D.local_path?" · local":""]},D.slug))})]}),h.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!P||!Gr(T),onClick:()=>{It(T)},children:"My repos"}),h.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!P,onClick:Xr,children:"List PRs"})]}),C.length>0?h.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[C.length," ",T," repositor",C.length===1?"y":"ies",T==="github"&&ee.github_user?` · @${String(ee.github_user)}`:"",T==="gitlab"&&ee.gitlab_user?` · @${String(ee.gitlab_user)}`:"",T==="bitbucket"&&ee.bitbucket_user?` · ${String(ee.bitbucket_user)}`:""]}):null,ne.length===0?h.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[h.jsx("h2",{children:"No pull requests loaded"}),h.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):ne.map(D=>h.jsxs("article",{className:"pr","data-testid":`pr-${D.number}`,children:[h.jsxs("h3",{children:["#",D.number," ",D.title]}),h.jsxs("div",{className:"pr-meta muted",children:[h.jsx("span",{className:`chip ${D.draft?"":"open"}`,children:D.draft?"draft":D.state}),h.jsx("span",{children:D.author}),h.jsxs("span",{children:[D.source_branch," → ",D.target_branch]})]}),h.jsxs("div",{className:"pr-actions",children:[h.jsxs("a",{href:D.url,target:"_blank",rel:"noreferrer",children:["Open on ",D.provider]}),h.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${D.number}`,onClick:()=>void mr(D),children:"Review this PR"})]})]},`${D.provider}-${D.number}`))]}),!A&&t==="settings"&&me&&h.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:kn,children:[h.jsxs("div",{children:[h.jsx("h1",{children:"Settings"}),h.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),h.jsxs("section",{className:"settings-card",children:[h.jsx("h2",{children:"Appearance"}),h.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),h.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Sl.map(D=>h.jsxs("button",{type:"button","data-theme":D.id,className:Q===D.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${D.id}`,onClick:()=>ft(D.id),children:[h.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),h.jsx("div",{className:"name",children:D.label}),h.jsx("div",{className:"group",children:D.group})]},D.id))})]}),h.jsxs("section",{className:"settings-card",children:[h.jsx("h2",{children:"Source control"}),h.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),h.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[h.jsxs("div",{children:[h.jsx("strong",{children:"GitHub"}),h.jsx("p",{className:"muted",children:ee.github_token_set?ee.github_user?`Signed in as @${String(ee.github_user)}`:"Token saved on this machine":"Not connected"})]}),h.jsx("div",{className:"btn-row",children:ee.github_token_set?h.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void Fn("github"),children:"Disconnect"}):h.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!Ce||!ee.github_oauth_ready,onClick:()=>void qr(),children:Ce?"Waiting for GitHub…":"Sign in with GitHub"})})]}),Ce?h.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",h.jsx("code",{children:Ce.user_code})," at GitHub if the browser did not fill it in."]}):null,ee.github_oauth_ready?null:h.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),h.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),h.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(ee.github_oauth_client_id||""),autoComplete:"off"}),h.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),h.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),h.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),h.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(ee.github_host||""),autoComplete:"off"}),h.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[h.jsxs("div",{children:[h.jsx("strong",{children:"GitLab"}),h.jsx("p",{className:"muted",children:ee.gitlab_token_set?ee.gitlab_user?`Signed in as @${String(ee.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),h.jsx("div",{className:"btn-row",children:ee.gitlab_token_set?h.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void Fn("gitlab"),children:"Disconnect"}):h.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Je||!ee.gitlab_oauth_ready,onClick:()=>void Qr(),children:Je?"Waiting for GitLab…":"Sign in with GitLab"})})]}),h.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),h.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(ee.gitlab_host||""),autoComplete:"off"}),h.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),h.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(ee.gitlab_oauth_client_id||""),autoComplete:"off"}),h.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),h.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),h.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),h.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),h.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[h.jsxs("div",{children:[h.jsx("strong",{children:"Bitbucket"}),h.jsx("p",{className:"muted",children:ee.bitbucket_token_set?ee.bitbucket_user?`Signed in as ${String(ee.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),h.jsx("div",{className:"btn-row",children:ee.bitbucket_token_set?h.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void Fn("bitbucket"),children:"Disconnect"}):h.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:tt||!ee.bitbucket_oauth_ready,onClick:()=>void Kr(),children:tt?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),ee.bitbucket_oauth_ready?null:h.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",h.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),h.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),h.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(ee.bitbucket_oauth_client_id||""),autoComplete:"off"}),h.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),h.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),h.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),h.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),h.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),h.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(ee.bitbucket_username||"")})]}),h.jsxs("section",{className:"settings-card",children:[h.jsx("h2",{children:"Residual AI"}),h.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),h.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((Wn=ee.ai)==null?void 0:Wn.provider)||"none"),children:[h.jsx("option",{value:"none",children:"none (graph only)"}),h.jsx("option",{value:"anthropic",children:"Anthropic"}),h.jsx("option",{value:"openai",children:"OpenAI"}),h.jsx("option",{value:"grok",children:"Grok / xAI"}),h.jsx("option",{value:"deepseek",children:"DeepSeek"}),h.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),h.jsx("option",{value:"ollama",children:"Ollama local"})]}),h.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),h.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),h.jsx("label",{htmlFor:"ai_model",children:"Model"}),h.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((ti=ee.ai)==null?void 0:ti.model)||"")}),h.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),h.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((wr=ee.ai)==null?void 0:wr.base_url)||"")}),h.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),xe?h.jsx(hN,{initialPath:o,onClose:()=>pe(!1),onSelect:D=>{if(He.current){_("Wait for the current job to finish before switching workspace.");return}pe(!1),Dn(D)}}):null]})}function xN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:f,onPost:g}){var v,x,m,S,k,j,b,_,P,N,E,L,A,V;const y=[...new Set(t.confidence.reasons||[])];return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[h.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),y.length?h.jsx("ul",{className:"reasons",children:y.map(z=>h.jsx("li",{children:z},z))}):null,t.low_risk?h.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(z=>h.jsx("span",{className:"chip",children:bo(z)},z)),(v=t.contract_break)!=null&&v.kind&&t.contract_break.kind!=="none"?h.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),h.jsxs("div",{className:"metrics",children:[h.jsxs("div",{className:"metric",children:[h.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),h.jsx("div",{className:"l",children:"Sinks tested"})]}),h.jsxs("div",{className:"metric",children:[h.jsx("div",{className:"n",children:r.length}),h.jsx("div",{className:"l",children:"Findings"})]}),h.jsxs("div",{className:"metric",children:[h.jsx("div",{className:"n",children:t.residuals.length}),h.jsx("div",{className:"l",children:"Residuals"})]})]}),h.jsx("pre",{className:"headline",children:t.headline}),t.index?h.jsxs("details",{className:"section",open:!0,children:[h.jsxs("summary",{children:["Index ",h.jsx("span",{className:"count",children:t.index.counts.nodes})]}),h.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(x=t.workspace)!=null&&x.three_dot?" · three-dot range":""]})]}):null,h.jsxs("details",{className:"section",open:!0,children:[h.jsxs("summary",{children:["Read this ",h.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((z,G)=>h.jsxs("div",{className:G===a?"read-item tour-current":"read-item",children:[h.jsxs("span",{className:"file",children:[G+1,". ",z.path]}),h.jsx("div",{className:"why",children:z.why})]},z.path)),t.read_order.length>0?h.jsxs("div",{className:"btn-row tour-row",children:[h.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),h.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),h.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),h.jsxs("details",{className:"section",children:[h.jsxs("summary",{children:["Clusters ",h.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(z=>h.jsxs("div",{className:"muted",children:[h.jsx("strong",{children:z.title})," — ",z.files.join(", ")]},z.id))]}),h.jsxs("details",{className:"section",open:!0,children:[h.jsxs("summary",{children:["Architecture ",h.jsx("span",{className:"count",children:r.length})]}),r.length===0?h.jsx("div",{className:"muted",children:t.architecture_note}):r.map(z=>h.jsxs("div",{className:"finding",children:[h.jsx("span",{className:`chip ${z.severity}`,children:z.severity}),z.message]},z.rule+z.message))]}),h.jsx(vm,{cards:t.deepening}),(S=(m=t.contract_break)==null?void 0:m.reasons)!=null&&S.length?h.jsxs("details",{className:"section",open:!0,children:[h.jsxs("summary",{children:["Contract ",h.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(z=>h.jsx("div",{className:"muted",children:z},z))]}):null,(k=t.auth)!=null&&k.note?h.jsxs("details",{className:"section",open:!0,children:[h.jsx("summary",{children:"Auth"}),h.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(z=>h.jsxs("div",{className:"finding",children:[h.jsx("span",{className:"chip warning",children:"missing"}),z.name]},z.id))]}):null,(t.suggested_tests||[]).length?h.jsxs("details",{className:"section",open:!0,children:[h.jsxs("summary",{children:["Suggested tests ",h.jsx("span",{className:"count",children:(j=t.suggested_tests)==null?void 0:j.length})]}),(t.suggested_tests||[]).map(z=>h.jsxs("div",{className:"residual",children:[h.jsx("strong",{children:z.title}),h.jsx("pre",{className:"headline",children:z.body})]},z.title))]}):null,(b=t.trend)!=null&&b.note?h.jsxs("details",{className:"section",children:[h.jsx("summary",{children:"Confidence trend"}),h.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(z=>h.jsxs("div",{className:"muted",children:[z.level," · ",Sp(z.created_at),z.sinks!=null?` · ${z.sinks} sinks`:""]},z.id))]}):null,h.jsxs("details",{className:"section",open:!0,children:[h.jsxs("summary",{children:["Residual ",h.jsx("span",{className:"count",children:t.residuals.length})]}),h.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(z=>h.jsx("div",{className:"residual muted",children:z},z))]}),(P=(_=t.evolution)==null?void 0:_.notes)!=null&&P.length||(E=(N=t.evolution)==null?void 0:N.hotspots)!=null&&E.some(z=>z.commits)?h.jsxs("details",{className:"section",children:[h.jsx("summary",{children:"Churn & coupling"}),(((L=t.evolution)==null?void 0:L.notes)||[]).map(z=>h.jsx("div",{className:"muted",children:z},z)),(((A=t.evolution)==null?void 0:A.hotspots)||[]).filter(z=>z.commits).slice(0,6).map(z=>h.jsxs("div",{className:"muted",children:[h.jsx("span",{className:"file",children:z.path})," — ",z.commits," commits, bus factor ",z.bus_factor]},z.path))]}):null,h.jsxs("div",{className:"btn-row",children:[h.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),h.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:f,children:"Copy markdown"}),h.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",onClick:g,children:"Post to PR"})]}),o?h.jsx("pre",{className:"headline",children:o}):null,h.jsx("div",{className:"kicker",children:"Reviewers"}),h.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(V=t.knowledge_owners)!=null&&V.length?h.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function wN({architecture:t,busy:r,onReindex:o,onReview:s}){const a=t.findings.filter(u=>!u.waived);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"merge-box high",children:[h.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),h.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${Sp(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),h.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?h.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),h.jsxs("details",{className:"section",open:!0,children:[h.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(u=>h.jsxs("div",{className:"muted",children:[h.jsx("strong",{children:u.name})," — ",(u.django_apps||[]).join(", ")||"no apps"," ·"," ",(u.owners||[]).join(", ")||"unowned"]},u.name))]}),h.jsxs("details",{className:"section",children:[h.jsxs("summary",{children:["Rules ",h.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(u=>h.jsx("div",{className:"muted",children:u},u))]}),h.jsxs("details",{className:"section",open:!0,children:[h.jsxs("summary",{children:["Findings ",h.jsx("span",{className:"count",children:a.length})]}),a.length===0?h.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):a.map(u=>h.jsxs("div",{className:"finding",children:[h.jsx("span",{className:`chip ${u.severity}`,children:u.severity}),u.message]},u.rule+u.message))]}),h.jsx(vm,{cards:t.deepening}),h.jsxs("details",{className:"section",open:!0,children:[h.jsx("summary",{children:"Types"}),h.jsx("table",{className:"type-table",children:h.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((u,c)=>c[1]-u[1]).slice(0,12).map(([u,c])=>h.jsxs("tr",{children:[h.jsx("td",{children:kl(u)}),h.jsx("td",{children:c})]},u))})})]}),h.jsxs("div",{className:"btn-row",children:[h.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),h.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function vm({cards:t}){const r=t||[];return r.length?h.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[h.jsxs("summary",{children:["Depth ",h.jsx("span",{className:"count",children:r.length})]}),h.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>h.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[h.jsx("span",{className:`chip ${o.strength}`,children:a0(o.strength)}),o.top?h.jsx("span",{className:"chip",children:"top"}):null,h.jsx("strong",{children:o.title}),h.jsx("div",{className:"why",children:o.message}),o.deletion_test?h.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?h.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}ym(mm());o0.createRoot(document.getElementById("root")).render(h.jsx(O.StrictMode,{children:h.jsx(vN,{})}));export{Dk as L,kN as a,_N as c,h as j,SN as l,O as r,kl as t}; diff --git a/src/loadpath/static/index.html b/src/loadpath/static/index.html index 4b5036a..c75530b 100644 --- a/src/loadpath/static/index.html +++ b/src/loadpath/static/index.html @@ -17,8 +17,8 @@ - - + +
diff --git a/src/loadpath/workspace.py b/src/loadpath/workspace.py index fbfe74f..2c2d0ef 100644 --- a/src/loadpath/workspace.py +++ b/src/loadpath/workspace.py @@ -2,6 +2,7 @@ from __future__ import annotations +import hashlib import subprocess from pathlib import Path from typing import Any @@ -214,6 +215,27 @@ def git_dirty_paths(repo_root: Path) -> list[str]: return paths +def workspace_status(repo_root: Path) -> dict[str, Any]: + """Dirty paths plus a fingerprint so the UI can watch the working tree.""" + repo_root = repo_root.resolve() + dirty = git_dirty_paths(repo_root) + parts: list[str] = [] + for rel in dirty[:80]: + full = repo_root / rel + try: + st = full.stat() + parts.append(f"{rel}:{st.st_mtime_ns}:{st.st_size}") + except OSError: + parts.append(f"{rel}:missing") + digest = hashlib.sha256("\n".join(parts).encode("utf-8")).hexdigest()[:16] + return { + "repo_path": str(repo_root), + "dirty": dirty[:80], + "dirty_count": len(dirty), + "fingerprint": digest if dirty else "clean", + } + + def git_merge_base(repo_root: Path, a: str, b: str) -> str | None: repo_root = repo_root.resolve() try: diff --git a/tests/e2e/test_api_flow.py b/tests/e2e/test_api_flow.py index 416dbf7..7d760ee 100644 --- a/tests/e2e/test_api_flow.py +++ b/tests/e2e/test_api_flow.py @@ -61,6 +61,37 @@ def test_api_health_index_review_graph_settings(tmp_path, monkeypatch): assert body["index"]["reindexed"] is False assert "workspace" in body assert body["index"]["django_boot"] == "off" + assert body["checklist"] + assert body["seed_ids"] + assert body["marks"] + assert "node_roles" in body + + listed = client.get("/api/reviews", params={"repo_path": str(repo)}) + assert listed.status_code == 200 + assert listed.json()["reviews"] + review_id = listed.json()["reviews"][0]["id"] + stored = client.get(f"/api/reviews/{review_id}", params={"repo_path": str(repo)}) + assert stored.status_code == 200 + assert stored.json()["markdown"] + marks = client.get("/api/marks", params={"repo_path": str(repo)}) + assert marks.json()["files"] + health = client.get("/api/architecture/health", params={"repo_path": str(repo)}) + assert health.json()["points"] + status = client.get("/api/workspace/status", params={"repo_path": str(repo)}) + assert status.json()["fingerprint"] + html = client.get(f"/api/reviews/{review_id}/html", params={"repo_path": str(repo)}) + assert html.status_code == 200 + assert "text/html" in html.headers["content-type"] + + cfg = client.get("/api/config", params={"repo_path": str(repo)}) + assert "billing" in cfg.json()["contexts"] + assert "waivers" in cfg.json() + waived = client.post( + "/api/config/waiver", + json={"repo_path": str(repo), "rule": "leaked_seam", "reason": "e2e"}, + ) + assert waived.status_code == 200 + assert any(w["rule"] == "leaked_seam" for w in waived.json()["waivers"]) init = client.post("/api/init", json={"repo_path": str(repo)}) assert init.status_code == 200 diff --git a/tests/e2e/test_ui_flows.py b/tests/e2e/test_ui_flows.py index 557422d..2abdb35 100644 --- a/tests/e2e/test_ui_flows.py +++ b/tests/e2e/test_ui_flows.py @@ -152,6 +152,8 @@ def test_ui_index_review_graph_copy_and_workspace(live_app, browser_page): wait_visible_graph(page) page.get_by_test_id("tab-review").click() + page.get_by_test_id("merge-box").wait_for() + page.get_by_test_id("merge-checklist").wait_for() page.context.grant_permissions(["clipboard-read", "clipboard-write"], origin=base_url) page.get_by_test_id("btn-copy-markdown").click() page.get_by_test_id("status-note").wait_for(timeout=10_000) @@ -159,6 +161,22 @@ def test_ui_index_review_graph_copy_and_workspace(live_app, browser_page): clip = page.evaluate("navigator.clipboard.readText()") assert "Loadpath" in clip or "Invoice" in clip or clip.strip() + page.locator(".brand").click() + page.keyboard.press("Control+K") + page.get_by_test_id("command-palette").wait_for() + page.get_by_test_id("command-palette-input").fill("Impact graph") + page.keyboard.press("Enter") + page.get_by_test_id("graph-full").wait_for() + page.get_by_test_id("graph-search").fill("Invoice") + page.get_by_test_id("graph-search-hits").wait_for() + page.get_by_test_id("graph-neighborhood").wait_for() + page.get_by_test_id("graph-test-overlay").click() + assert page.get_by_test_id("graph-test-overlay").get_attribute("aria-pressed") == "true" + + page.get_by_test_id("tab-review").click() + page.get_by_test_id("btn-export-html").click() + page.get_by_test_id("status-note").wait_for(timeout=10_000) + page.get_by_test_id("btn-post-comment").click() post_err = _assert_readable_error(page) assert "pull request" in post_err.lower() diff --git a/tests/unit/test_experience.py b/tests/unit/test_experience.py new file mode 100644 index 0000000..e4cf3b3 --- /dev/null +++ b/tests/unit/test_experience.py @@ -0,0 +1,281 @@ +from __future__ import annotations + +from loadpath.config import add_waiver, config_document, load_config, write_config +from loadpath.review.codeowners import owners_for_path, parse_codeowners, review_codeowners +from loadpath.review.editor import editor_urls +from loadpath.review.experience import ( + architecture_health, + attach_experience, + checklist, + contract_sides, + diff_reviews, + file_marks, + isolate_paths, + match_reviews_to_prs, + node_roles, + summarize_stored_review, +) +from loadpath.workspace import workspace_status + +from tests.conftest import prepare_review_repo + + +def test_codeowners_last_match_wins(): + rules = parse_codeowners( + "* @everyone\n" + "/backend/ @backend-team\n" + "/backend/billing/ @billing-team @alice\n" + "*.md @docs\n" + ) + assert owners_for_path("frontend/src/App.tsx", rules) == ["@everyone"] + assert owners_for_path("backend/accounts/models.py", rules) == ["@backend-team"] + assert owners_for_path("backend/billing/serializers.py", rules) == ["@billing-team", "@alice"] + assert owners_for_path("README.md", rules) == ["@docs"] + + +def test_review_codeowners_from_github_file(tmp_path): + repo = tmp_path / "repo" + github = repo / ".github" + github.mkdir(parents=True) + (github / "CODEOWNERS").write_text("/backend/billing/ @billing-team\n", encoding="utf-8") + result = review_codeowners(repo, ["backend/billing/serializers.py", "frontend/src/App.tsx"]) + assert result["owners"] == ["@billing-team"] + assert result["files"][0]["path"] == "backend/billing/serializers.py" + + +def test_node_roles_seed_downstream_tested(): + nodes = [ + {"id": "ser", "type": "django.serializer", "name": "InvoiceSerializer"}, + {"id": "page", "type": "react.page", "name": "InvoicePage"}, + {"id": "test", "type": "django.test", "name": "test_invoice"}, + ] + edges = [ + {"id": "e1", "src": "ser", "dst": "page", "type": "consumed_by_client", "confidence": 1}, + {"id": "e2", "src": "ser", "dst": "test", "type": "tested_by", "confidence": 1}, + ] + roles = node_roles(nodes, edges, {"ser"}) + assert "seed" in roles["ser"] + assert "contract" in roles["ser"] + assert "tested" in roles["ser"] + assert "downstream" in roles["page"] + assert "sink" in roles["page"] + assert "untested" in roles["page"] + + +def test_contract_sides_flags_missing_zod_field(): + nodes = [ + {"id": "f1", "type": "django.serializer_field", "name": "total"}, + {"id": "f2", "type": "django.serializer_field", "name": "status"}, + {"id": "z", "type": "react.form_schema", "name": "InvoiceSchema", "extra": {"fields": ["status"]}}, + ] + sides = contract_sides(nodes, ["total"]) + by_name = {row["field"]: row for row in sides["rows"]} + assert by_name["total"]["serializer"] is True + assert by_name["total"]["zod"] is False + assert by_name["total"]["status"] == "missing_client" + assert by_name["status"]["status"] == "aligned" + + +def test_checklist_ready_when_high_and_clean(): + items = checklist( + { + "confidence": {"level": "high", "untested_sinks": []}, + "findings": [], + "residuals": [], + "low_risk": True, + "contract_break": {"kind": "none"}, + } + ) + assert items[0]["kind"] == "ready" + assert items[0]["status"] == "done" + + +def test_checklist_todos_for_blocker_and_untested(): + items = checklist( + { + "confidence": { + "level": "low", + "untested_sinks": [{"id": "page", "name": "InvoicePage", "type": "react.page"}], + }, + "findings": [ + { + "rule": "views_cannot_import_other_context_models", + "severity": "blocker", + "message": "billing view imports accounts", + "node_id": "view", + "waived": False, + } + ], + "suggested_tests": [ + {"sink": "InvoicePage", "title": "Render InvoicePage", "body": "it('renders') {}"} + ], + "contract_break": {"kind": "breaking", "reasons": ["Required total"]}, + } + ) + kinds = {i["kind"] for i in items} + assert "finding" in kinds + assert "test" in kinds + assert "contract" in kinds + blocker = next(i for i in items if i["kind"] == "finding") + assert blocker["rule"] == "views_cannot_import_other_context_models" + test_item = next(i for i in items if i["kind"] == "test") + assert "it('renders')" in (test_item.get("body") or "") + + +def test_isolate_paths_keeps_only_source_to_sink(): + nodes = [ + {"id": "a", "type": "django.field", "name": "total"}, + {"id": "b", "type": "django.serializer", "name": "Ser"}, + {"id": "c", "type": "django.route", "name": "/api"}, + {"id": "noise", "type": "react.page", "name": "MePage"}, + ] + edges = [ + {"id": "ab", "src": "a", "dst": "b", "type": "has_field"}, + {"id": "bc", "src": "b", "dst": "c", "type": "publishes_route"}, + {"id": "bn", "src": "b", "dst": "noise", "type": "consumed_by_client"}, + ] + isolated = isolate_paths(nodes, edges, "a", "c") + assert set(isolated["node_ids"]) == {"a", "b", "c"} + assert "bn" not in isolated["edge_ids"] + assert "ab" in isolated["edge_ids"] + + +def test_diff_reviews_new_sinks_and_dropped_confidence(): + current = { + "confidence": {"level": "low"}, + "sinks": [{"name": "InvoicePage"}, {"name": "send_invoice_email"}], + "findings": [], + "contract_break": {"kind": "breaking"}, + } + previous = { + "confidence": {"level": "medium"}, + "sinks": [{"name": "InvoicePage"}], + "findings": [], + "contract_break": {"kind": "additive"}, + } + diff = diff_reviews(current, previous) + assert diff["direction"] == "dropped" + assert "send_invoice_email" in diff["added_sinks"] + assert "breaking" in diff["note"] + + +def test_summarize_and_match_pr(): + item = { + "id": "abc", + "created_at": "2026-01-01T00:00:00+00:00", + "base_ref": "main", + "head_ref": "feature/total", + "payload": { + "title": "Invoice.total", + "confidence": {"level": "medium", "sinks": 3, "covered_sinks": 1}, + "contract_break": {"kind": "breaking"}, + "findings": [{"waived": False}], + }, + } + summary = summarize_stored_review(item) + assert summary["level"] == "medium" + assert summary["contract_break"] == "breaking" + matched = match_reviews_to_prs( + [summary], + [{"number": 12, "source_branch": "feature/total", "target_branch": "main", "title": "x"}], + ) + assert matched[0]["loadpath"]["id"] == "abc" + + +def test_architecture_health_points(): + health = architecture_health( + [ + { + "id": "1", + "created_at": "2026-01-01T00:00:00Z", + "payload": { + "confidence": {"level": "high", "sinks": 1}, + "findings": [], + "edges": [{"confidence": 1}], + "nodes": [], + }, + }, + { + "id": "2", + "created_at": "2026-01-02T00:00:00Z", + "payload": { + "confidence": {"level": "low", "sinks": 4}, + "findings": [{"node_id": "n1", "waived": False}], + "edges": [{"confidence": 0.4}, {"confidence": 1}], + "nodes": [{"id": "n1", "context": "billing"}], + }, + }, + ] + ) + assert len(health["points"]) == 2 + assert health["points"][-1]["findings"] == 1 + assert health["contexts"]["billing"][-1]["findings"] == 1 + + +def test_file_marks_badge_prefers_seed(tmp_path): + review = { + "seed_ids": ["ser"], + "nodes": [ + { + "id": "ser", + "type": "django.serializer", + "name": "InvoiceSerializer", + "file_path": "backend/billing/serializers.py", + "start_line": 4, + } + ], + "edges": [], + } + attach_experience(review, seed_ids={"ser"}) + marks = file_marks(review) + assert marks[0]["badge"] == "S" + assert "seed" in marks[0]["roles"] + + +def test_write_config_and_waiver(tmp_path): + repo = tmp_path / "repo" + repo.mkdir() + (repo / "loadpath.yml").write_text( + "contexts:\n billing:\n django_apps: [billing]\n owners: [billing-team]\nrules:\n - leaked_seam\n", + encoding="utf-8", + ) + write_config( + repo, + { + "contexts": { + "billing": { + "django_apps": ["billing"], + "react": ["frontend/src/features/billing"], + "public_api": ["GET /api/invoices"], + "owners": ["billing-team"], + } + }, + "rules": ["leaked_seam", "tests_bypass_interface"], + }, + ) + doc = config_document(load_config(repo)) + assert doc["contexts"]["billing"]["react"] == ["frontend/src/features/billing"] + waived = add_waiver(repo, "leaked_seam", "django.view:billing.InvoiceViewSet", "legacy") + assert waived["waivers"][0]["rule"] == "leaked_seam" + assert "legacy" in (repo / "loadpath.yml").read_text() + + +def test_workspace_status_fingerprint_changes(tmp_path): + repo = prepare_review_repo(tmp_path) + clean = workspace_status(repo) + assert clean["fingerprint"] == "clean" + (repo / "backend/billing/serializers.py").write_text("changed\n", encoding="utf-8") + dirty = workspace_status(repo) + assert dirty["dirty_count"] >= 1 + assert dirty["fingerprint"] != "clean" + (repo / "backend/billing/serializers.py").write_text("changed again\n", encoding="utf-8") + later = workspace_status(repo) + assert later["fingerprint"] != dirty["fingerprint"] + + +def test_editor_urls_include_line(): + from pathlib import Path + + urls = editor_urls(Path("/tmp/acme/backend/a.py"), 12) + assert urls["cursor"].endswith("a.py:12") + assert urls["vscode"].startswith("vscode://file/") diff --git a/ui/src/App.tsx b/ui/src/App.tsx index ce613c4..c96f0a6 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -1,12 +1,28 @@ import { useCallback, useEffect, useMemo, useRef, useState, type FormEvent } from "react"; import { api } from "./api"; +import { CommandPalette, type PaletteAction } from "./CommandPalette"; +import { ConfigEditor } from "./ConfigEditor"; import { formatWhen, kindLabel, repoName, strengthLabel, typeLabel } from "./format"; import { IconArchitecture, IconFolder, IconGraph, IconPrs, IconReview, IconSettings } from "./icons"; import { ImpactGraph } from "./ImpactGraph"; +import { openInEditor, persistEditorPreference, editorPreference } from "./openEditor"; import { RefCombobox } from "./RefCombobox"; import { RepoExplorer } from "./RepoExplorer"; import { THEMES, applyTheme, readTheme, type ThemeId } from "./themes"; -import type { ArchitectureReport, DeepeningCandidate, GitRefs, IndexedRepo, IndexProgress, PullRequest, RemoteRepo, Review } from "./types"; +import type { + ArchitectureHealth, + ArchitectureReport, + DeepeningCandidate, + GitRefs, + IndexedRepo, + IndexProgress, + LoadpathConfigDoc, + PullRequest, + RemoteRepo, + Review, + ReviewDiff, + ReviewSummary, +} from "./types"; type Tab = "review" | "architecture" | "graph" | "prs" | "settings"; type GraphMode = "review" | "architecture"; @@ -65,6 +81,23 @@ export function App() { const [theme, setTheme] = useState(readTheme); const [settingsReady, setSettingsReady] = useState(false); const [explorerOpen, setExplorerOpen] = useState(false); + const [paletteOpen, setPaletteOpen] = useState(false); + const [selectedId, setSelectedId] = useState(null); + const [pinnedId, setPinnedId] = useState(null); + const [testOverlay, setTestOverlay] = useState(localStorage.getItem("loadpath.testOverlay") === "1"); + const [isolateSource, setIsolateSource] = useState(null); + const [watchEnabled, setWatchEnabled] = useState(localStorage.getItem("loadpath.watch") === "1"); + const [reviewHistory, setReviewHistory] = useState([]); + const [reviewDiff, setReviewDiff] = useState(null); + const [configDoc, setConfigDoc] = useState(null); + const [health, setHealth] = useState(null); + const [restoring, setRestoring] = useState(() => { + try { + return Boolean(localStorage.getItem("loadpath.lastReviewId") && (localStorage.getItem("loadpath.repo") || "").trim()); + } catch { + return false; + } + }); const [gitRefs, setGitRefs] = useState(null); const [githubFlow, setGithubFlow] = useState<{ flow_id: string; @@ -136,6 +169,18 @@ export function App() { if (!cancelled && repoRef.current === requested) setArchitecture(report); }) .catch(() => undefined); + api + .config(requested) + .then((doc) => { + if (!cancelled && repoRef.current === requested) setConfigDoc(doc); + }) + .catch(() => undefined); + api + .architectureHealth(requested) + .then((next) => { + if (!cancelled && repoRef.current === requested) setHealth(next); + }) + .catch(() => undefined); return () => { cancelled = true; }; @@ -186,6 +231,42 @@ export function App() { } }; + const rememberReview = (next: Review) => { + setReview(next); + setTourIndex(0); + setSelectedId(pinnedId && next.nodes.some((n) => n.id === pinnedId) ? pinnedId : null); + setIsolateSource(null); + setReviewDiff(null); + if (next.id && !next.what_if) { + localStorage.setItem("loadpath.lastReviewId", next.id); + } + }; + + const loadHistory = async (path: string) => { + try { + const listed = await api.reviews(path); + setReviewHistory(listed.reviews); + } catch { + setReviewHistory([]); + } + }; + + const loadConfigDoc = async (path: string) => { + try { + setConfigDoc(await api.config(path)); + } catch { + setConfigDoc(null); + } + }; + + const loadHealth = async (path: string) => { + try { + setHealth(await api.architectureHealth(path)); + } catch { + setHealth(null); + } + }; + const tokenSetFor = (name: string) => name === "github" ? Boolean(settings.github_token_set) @@ -377,12 +458,11 @@ export function App() { const stopWatch = watchIndex(repo); try { const r = await api.review(repo, base, head, true, dirty); - setReview(r); - setTourIndex(0); + rememberReview(r); setGraphMode("review"); setTab("review"); await api.repos().then((x) => setRepos(x.repos)).catch(() => undefined); - await loadArchitecture(repo); + await Promise.all([loadArchitecture(repo), loadHistory(repo), loadHealth(repo)]); } catch (e) { setError(e instanceof Error ? e.message : String(e)); } finally { @@ -465,7 +545,7 @@ export function App() { setError(""); markBusy("Fetching pull requests…"); try { - const r = await api.prs(provider, scmRepo); + const r = await api.prs(provider, scmRepo, "open", repo.trim() || undefined); setPrs(r.pull_requests); const match = remoteRepos.find((item) => item.slug.toLowerCase() === scmRepo.trim().toLowerCase()); if (match?.local_path) persistRepo(match.local_path); @@ -518,13 +598,12 @@ export function App() { try { const result = await api.whatIf(repo, nodeId); setCopied(`${result.title} — ${result.confidence.level} · ${(result.sinks || []).length} sinks`); - setReview({ + rememberReview({ ...result, markdown: result.markdown || "", index: result.index || review?.index, workspace: result.workspace || review?.workspace, }); - setTourIndex(0); setGraphMode("review"); setTab("review"); } catch (e) { @@ -545,12 +624,14 @@ export function App() { const stopWatch = watchPath ? watchIndex(watchPath) : () => undefined; try { const r = await api.reviewPr(item.provider, item.repo, item.number, match?.local_path || repo || undefined); - setReview(r); - setTourIndex(0); + rememberReview(r); if (r.pull_request && typeof r.pull_request.repo_path === "string") persistRepo(r.pull_request.repo_path); persistRefs(String(r.base || item.target_branch), String(r.head || item.source_branch)); setGraphMode("review"); setTab("review"); + if (typeof (r.pull_request as { repo_path?: string } | undefined)?.repo_path === "string") { + void loadHistory((r.pull_request as { repo_path: string }).repo_path); + } } catch (e) { persistRefs(item.base_sha || item.target_branch, item.head_sha || item.source_branch); setTab("review"); @@ -620,9 +701,85 @@ export function App() { runReviewRef.current = runReview; const tabRef = useRef(tab); tabRef.current = tab; + const paletteOpenRef = useRef(false); + paletteOpenRef.current = paletteOpen; + const reviewRef = useRef(review); + reviewRef.current = review; + const tourIndexRef = useRef(tourIndex); + tourIndexRef.current = tourIndex; + + useEffect(() => { + const lastId = localStorage.getItem("loadpath.lastReviewId"); + const path = (localStorage.getItem("loadpath.repo") || "").trim(); + if (!lastId || !path) { + setRestoring(false); + return; + } + let cancelled = false; + api + .getReview(path, lastId) + .then((r) => { + if (cancelled) return; + rememberReview(r); + persistRefs(r.base || localStorage.getItem("loadpath.base") || "HEAD~1", r.head || localStorage.getItem("loadpath.head") || "HEAD"); + void loadHistory(path); + void loadHealth(path); + }) + .catch(() => undefined) + .finally(() => { + if (!cancelled) setRestoring(false); + }); + return () => { + cancelled = true; + }; + // Restore once on launch from the last stored review id. + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + const fingerprintRef = useRef(""); + useEffect(() => { + if (!watchEnabled || !repo.trim()) return; + let cancelled = false; + const tick = async () => { + try { + const status = await api.workspaceStatus(repo); + if (cancelled) return; + if ( + fingerprintRef.current && + status.fingerprint !== fingerprintRef.current && + !busyRef.current + ) { + setDirty(true); + localStorage.setItem("loadpath.dirty", "1"); + void runReviewRef.current(); + } + fingerprintRef.current = status.fingerprint; + } catch { + /* ignore poll errors */ + } + }; + void tick(); + const id = window.setInterval(tick, 2000); + return () => { + cancelled = true; + window.clearInterval(id); + }; + }, [watchEnabled, repo]); useEffect(() => { const onKey = (event: KeyboardEvent) => { + if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") { + event.preventDefault(); + setPaletteOpen((open) => !open); + return; + } + if (paletteOpenRef.current) { + if (event.key === "Escape") { + event.preventDefault(); + setPaletteOpen(false); + } + return; + } if (explorerOpenRef.current) { if (event.key === "Escape") { event.preventDefault(); @@ -638,6 +795,17 @@ export function App() { if (event.key === "Escape") { setError(""); setCopied(""); + setSelectedId(pinnedId); + setIsolateSource(null); + return; + } + if (event.key === "j" || event.key === "k") { + const order = reviewRef.current?.read_order || []; + if (!order.length) return; + event.preventDefault(); + const current = tourIndexRef.current; + const next = event.key === "j" ? Math.min(order.length - 1, current + 1) : Math.max(0, current - 1); + setTourIndex(next); return; } const hit = TABS.find((item) => item.shortcut === event.key); @@ -651,7 +819,107 @@ export function App() { }; window.addEventListener("keydown", onKey); return () => window.removeEventListener("keydown", onKey); - }, []); + }, [pinnedId]); + + const openFile = async (path: string, line?: number | null) => { + if (!repo.trim()) return; + const result = await openInEditor(repo, path, line); + if (result.ok) setCopied(result.message); + else setError(result.message); + }; + + const exportHtml = async () => { + if (!review) return; + try { + const blob = await api.exportHtml(review); + const url = URL.createObjectURL(blob); + const a = document.createElement("a"); + a.href = url; + a.download = `loadpath-${(review.id || "review").slice(0, 8)}.html`; + a.click(); + URL.revokeObjectURL(url); + setCopied("Saved HTML brief"); + } catch (e) { + setError(e instanceof Error ? e.message : String(e)); + } + }; + + const reopenReview = async (id: string) => { + if (!repo.trim()) return; + markBusy("Loading stored review…"); + try { + const next = await api.getReview(repo, id); + rememberReview(next); + persistRefs(next.base || base, next.head || head); + setGraphMode("review"); + setTab("review"); + const previous = reviewHistory.find((item) => item.id !== id); + if (previous) { + try { + setReviewDiff(await api.reviewDiff(repo, id, previous.id)); + } catch { + setReviewDiff(null); + } + } + } catch (e) { + setError(e instanceof Error ? e.message : String(e)); + } finally { + markBusy(""); + } + }; + + const graphBind = { + selectedId, + onSelect: setSelectedId, + nodeRoles: review?.node_roles, + testOverlay, + isolateSource, + onIsolate: setIsolateSource, + repoPath: repo, + onOpenFile: openFile, + pinnedId, + onPin: setPinnedId, + }; + + const paletteActions: PaletteAction[] = [ + { id: "review", group: "Run", label: "Review this range", hint: "⌘/Ctrl+Enter", run: () => void runReview() }, + { id: "index", group: "Run", label: "Index repository", run: () => void runIndex(true) }, + { id: "watch", group: "Run", label: watchEnabled ? "Stop watching working tree" : "Watch working tree", run: () => { + const next = !watchEnabled; + setWatchEnabled(next); + localStorage.setItem("loadpath.watch", next ? "1" : "0"); + } }, + { id: "tests", group: "Graph", label: testOverlay ? "Hide test overlay" : "Show test overlay", run: () => { + const next = !testOverlay; + setTestOverlay(next); + localStorage.setItem("loadpath.testOverlay", next ? "1" : "0"); + } }, + { id: "export", group: "Review", label: "Export HTML brief", run: () => void exportHtml() }, + ...TABS.map((item) => ({ + id: `tab-${item.id}`, + group: "Tabs", + label: `Go to ${item.label}`, + hint: item.shortcut, + run: () => setTab(item.id), + })), + ...(review?.nodes || []).slice(0, 30).map((n) => ({ + id: `node-${n.id}`, + group: "Nodes", + label: n.name, + hint: typeLabel(n.type), + run: () => { + setSelectedId(n.id); + setTab("graph"); + }, + })), + ...reviewHistory.slice(0, 12).map((item) => ({ + id: `hist-${item.id}`, + group: "History", + label: item.title || item.id, + hint: `${item.level || ""} ${item.created_at || ""}`.trim(), + run: () => void reopenReview(item.id), + })), + ]; const graphNodes = useMemo(() => { if (graphMode === "architecture") return architecture?.nodes ?? []; @@ -722,7 +990,7 @@ export function App() { {busy || indexLine}
- 1–5 tabs · Ctrl+Enter review + 1–5 tabs · ⌘K palette · j/k read order
@@ -830,6 +1098,32 @@ export function App() { {dirty ? "Include uncommitted" : "Committed range"} + + {review ? ( +
+
+ {review.confidence.level.toUpperCase()} +
+
+ {review.confidence.covered_sinks}/{review.confidence.sinks} sinks +
+
+ ) : null}
+ {graphNodes.length ? ( - + ) : (

Index the repo or run a review first. Click a node to inspect it. @@ -1077,6 +1429,16 @@ export function App() { {p.source_branch} → {p.target_branch} + {p.loadpath ? ( + + {p.loadpath.level?.toUpperCase() || "REVIEWED"} + {p.loadpath.contract_break && p.loadpath.contract_break !== "none" + ? ` · ${p.loadpath.contract_break}` + : ""} + + ) : ( + no Loadpath walk yet + )}

+
+

Editor

+

Open files from the inspector and read-order in Cursor, VS Code, or the system handler.

+ + +

Source control

@@ -1348,6 +1726,7 @@ export function App() { )} + setPaletteOpen(false)} /> {explorerOpen ? ( void; onCopy: () => void; onPost: () => void; + onSelect: (id: string | null) => void; + onOpenFile: (path: string, line?: number | null) => void; + onExport: () => void; + history: ReviewSummary[]; + diff: ReviewDiff | null; + onReopen: (id: string) => void; + onWaiver: (rule: string, node?: string | null) => void; }) { const uniqueReasons = [...new Set(review.confidence.reasons || [])]; return ( @@ -1430,6 +1823,43 @@ function ReviewBrief({

{review.headline}
+ {(review.checklist || []).length ? ( +
+ + Merge checklist{" "} + {(review.checklist || []).filter((i) => i.status === "todo").length} + + {(review.checklist || []).map((item) => ( +
+ + {item.detail ?
{item.detail}
: null} + {item.body ? ( + + ) : null} + {item.kind === "finding" && item.status === "todo" && item.rule ? ( + + ) : null} +
+ ))} +
+ ) : null} {review.index ? (
@@ -1455,10 +1885,13 @@ function ReviewBrief({ {review.read_order.map((f, i) => (
- +
{f.why}
+
))} {review.read_order.length > 0 ? ( @@ -1506,8 +1939,10 @@ function ReviewBrief({ ) : ( findings.map((f) => (
- {f.severity} - {f.message} +
)) )} @@ -1523,6 +1958,28 @@ function ReviewBrief({ {reason} ))} + {review.contract_break.sides?.rows?.length ? ( + + + + + + + + + + + {review.contract_break.sides.rows.map((row) => ( + + + + + + + ))} + +
FieldSerializerZodGraphQL
{row.field}{row.serializer ? "yes" : "—"}{row.zod ? "yes" : "—"}{row.graphql ? "yes" : "—"}
+ ) : null}
) : null} {review.auth?.note ? ( @@ -1546,6 +2003,15 @@ function ReviewBrief({
{sketch.title}
{sketch.body}
+
))} @@ -1573,6 +2039,26 @@ function ReviewBrief({ ))} + {history.length ? ( +
+ + History {history.length} + + {diff ?
{diff.note}
: null} + {history.slice(0, 12).map((item) => ( + + ))} +
+ ) : null} {(review.evolution?.notes?.length || review.evolution?.hotspots?.some((h) => h.commits)) ? (
Churn & coupling @@ -1598,6 +2084,9 @@ function ReviewBrief({ + @@ -1605,6 +2094,9 @@ function ReviewBrief({ {aiNote ?
{aiNote}
: null}
Reviewers
{review.suggested_reviewers.join(", ") || "—"}
+ {review.codeowners_reviewers?.length ? ( +
CODEOWNERS: {review.codeowners_reviewers.join(", ")}
+ ) : null} {review.knowledge_owners?.length ? (
Knowledge: {review.knowledge_owners.join(", ")}
) : null} @@ -1617,11 +2109,21 @@ function ArchitectureBrief({ busy, onReindex, onReview, + onSelect, + config, + health, + onSaveConfig, + onWaiver, }: { architecture: ArchitectureReport; busy: boolean; onReindex: () => void; onReview: () => void; + onSelect: (id: string | null) => void; + config: LoadpathConfigDoc | null; + health: ArchitectureHealth | null; + onSaveConfig: (doc: LoadpathConfigDoc) => void; + onWaiver: (rule: string, node: string, reason: string) => void; }) { const hits = architecture.findings.filter((f) => !f.waived); return ( @@ -1667,13 +2169,43 @@ function ArchitectureBrief({ ) : ( hits.map((f) => (
- {f.severity} - {f.message} +
)) )}
+ {health?.points?.length ? ( +
+ + Health over time {health.points.length} + + + {Object.entries(health.contexts).map(([name, series]) => ( +
+ {name} — last {series[series.length - 1]?.findings ?? 0} findings +
+ ))} +
+ ) : null} + {config ? ( +
+ loadpath.yml + +
+ ) : null}
Types diff --git a/ui/src/CommandPalette.tsx b/ui/src/CommandPalette.tsx new file mode 100644 index 0000000..f98d23c --- /dev/null +++ b/ui/src/CommandPalette.tsx @@ -0,0 +1,111 @@ +import { useEffect, useMemo, useRef, useState } from "react"; + +export type PaletteAction = { + id: string; + label: string; + hint?: string; + group?: string; + run: () => void; +}; + +export function filterActions(actions: PaletteAction[], query: string): PaletteAction[] { + const q = query.trim().toLowerCase(); + if (!q) return actions; + return actions.filter( + (a) => + a.label.toLowerCase().includes(q) || + (a.hint || "").toLowerCase().includes(q) || + (a.group || "").toLowerCase().includes(q), + ); +} + +export function CommandPalette({ + open, + actions, + onClose, +}: { + open: boolean; + actions: PaletteAction[]; + onClose: () => void; +}) { + const [query, setQuery] = useState(""); + const [index, setIndex] = useState(0); + const inputRef = useRef(null); + const hits = useMemo(() => filterActions(actions, query), [actions, query]); + + useEffect(() => { + if (!open) return; + setQuery(""); + setIndex(0); + const t = window.setTimeout(() => inputRef.current?.focus(), 0); + return () => window.clearTimeout(t); + }, [open]); + + useEffect(() => { + setIndex(0); + }, [query]); + + if (!open) return null; + const current = hits[index]; + + const run = (action?: PaletteAction) => { + if (!action) return; + onClose(); + action.run(); + }; + + return ( +
{ + if (e.target === e.currentTarget) onClose(); + }} + > +
+ setQuery(e.target.value)} + onKeyDown={(e) => { + if (e.key === "Escape") { + e.preventDefault(); + onClose(); + } else if (e.key === "ArrowDown") { + e.preventDefault(); + setIndex((i) => Math.min(hits.length - 1, i + 1)); + } else if (e.key === "ArrowUp") { + e.preventDefault(); + setIndex((i) => Math.max(0, i - 1)); + } else if (e.key === "Enter") { + e.preventDefault(); + run(current); + } + }} + /> +
    + {hits.length === 0 ?
  • No matches
  • : null} + {hits.slice(0, 40).map((action, i) => ( +
  • + +
  • + ))} +
+
+ ↑ + ↓ move · Enter run · Esc close +
+
+
+ ); +} diff --git a/ui/src/ConfigEditor.tsx b/ui/src/ConfigEditor.tsx new file mode 100644 index 0000000..b1acce8 --- /dev/null +++ b/ui/src/ConfigEditor.tsx @@ -0,0 +1,199 @@ +import { useEffect, useState } from "react"; +import type { LoadpathConfigDoc } from "./types"; + +export function ConfigEditor({ + config, + busy, + onSave, + onWaiver, +}: { + config: LoadpathConfigDoc; + busy: boolean; + onSave: (next: LoadpathConfigDoc) => void; + onWaiver?: (rule: string, node: string, reason: string) => void; +}) { + const [draft, setDraft] = useState(config); + const [waiverRule, setWaiverRule] = useState(config.available_rules[0] || ""); + const [waiverNode, setWaiverNode] = useState(""); + const [waiverReason, setWaiverReason] = useState(""); + + useEffect(() => { + setDraft(config); + }, [config]); + + const contexts = Object.entries(draft.contexts || {}); + + const updateContext = (name: string, field: string, value: string) => { + const ctx = draft.contexts[name]; + if (!ctx) return; + const split = (raw: string) => + raw + .split(",") + .map((s) => s.trim()) + .filter(Boolean); + setDraft({ + ...draft, + contexts: { + ...draft.contexts, + [name]: { + ...ctx, + [field]: field === "name" ? value : split(value), + }, + }, + }); + }; + + const renameContext = (from: string, to: string) => { + const nextName = to.trim(); + if (!nextName || nextName === from) return; + const { [from]: current, ...rest } = draft.contexts; + if (!current) return; + setDraft({ + ...draft, + contexts: { ...rest, [nextName]: { ...current, name: nextName } }, + }); + }; + + const addContext = () => { + let n = 1; + while (draft.contexts[`context-${n}`]) n += 1; + const name = `context-${n}`; + setDraft({ + ...draft, + contexts: { + ...draft.contexts, + [name]: { name, django_apps: [], react: [], public_api: [], owners: [] }, + }, + }); + }; + + const removeContext = (name: string) => { + const { [name]: _drop, ...rest } = draft.contexts; + setDraft({ ...draft, contexts: rest }); + }; + + const toggleRule = (rule: string) => { + const on = draft.rules.includes(rule); + setDraft({ + ...draft, + rules: on ? draft.rules.filter((r) => r !== rule) : [...draft.rules, rule], + }); + }; + + return ( +
+

+ {draft.exists ? draft.path : "No loadpath.yml yet — saving writes one at the repo root."} +

+ {contexts.map(([name, ctx]) => ( +
+ + Context {name} + + + + + + + +
+ ))} +
+ +
+
+ + Rules {draft.rules.length} + + {(draft.available_rules.length ? draft.available_rules : draft.rules).map((rule) => ( + + ))} +
+
+ + Waivers {(draft.waivers || []).length} + + {(draft.waivers || []).map((w, i) => ( +
+ {w.rule} + {w.node ? ` · ${w.node}` : ""} + {w.reason ? ` — ${w.reason}` : ""} +
+ ))} + + + + +
+
+ +
+
+ ); +} diff --git a/ui/src/ImpactGraph.tsx b/ui/src/ImpactGraph.tsx index 35d0b17..1190039 100644 --- a/ui/src/ImpactGraph.tsx +++ b/ui/src/ImpactGraph.tsx @@ -19,6 +19,8 @@ import { defaultDetail, defaultProjection, familyFor, + isolatePathIds, + searchNodes, visibleGraph, type GraphDetail, type GraphFamily, @@ -45,9 +47,16 @@ const WEIGHT_COLOR: Record = { critical: "var(--edge-critical)", }; -function LoadNode({ data, selected }: { data: { name: string; type: string }; selected?: boolean }) { +function LoadNode({ + data, + selected, +}: { + data: { name: string; type: string; roles?: string[]; dim?: boolean }; + selected?: boolean; +}) { + const roles = (data.roles || []).map((role) => `role-${role}`).join(" "); return ( -
+
{typeLabel(data.type)}
@@ -82,21 +91,31 @@ export function toReactFlowElements( nodes: GraphNode[], edges: GraphEdge[], selectedId: string | null = null, + opts: { roles?: Record; testOverlay?: boolean } = {}, ): { rfNodes: Node[]; rfEdges: Edge[] } { const byId = new Map(nodes.map((n) => [n.id, n])); const pos = layoutNodes(nodes, edges); - const rfNodes: Node[] = nodes.map((n) => ({ - id: n.id, - type: "load", - position: pos.get(n.id) ?? { x: 0, y: 0 }, - data: { name: n.name, type: n.type, file: n.file_path }, - selected: selectedId === n.id, - sourcePosition: Position.Right, - targetPosition: Position.Left, - width: GRAPH_NODE_WIDTH, - height: GRAPH_NODE_HEIGHT, - style: { width: GRAPH_NODE_WIDTH, height: GRAPH_NODE_HEIGHT }, - })); + const rfNodes: Node[] = nodes.map((n) => { + const roles = opts.roles?.[n.id] || []; + const dim = + Boolean(opts.testOverlay) && + !roles.includes("tested") && + !roles.includes("untested") && + !roles.includes("test") && + !roles.includes("seed"); + return { + id: n.id, + type: "load", + position: pos.get(n.id) ?? { x: 0, y: 0 }, + data: { name: n.name, type: n.type, file: n.file_path, roles, dim }, + selected: selectedId === n.id, + sourcePosition: Position.Right, + targetPosition: Position.Left, + width: GRAPH_NODE_WIDTH, + height: GRAPH_NODE_HEIGHT, + style: { width: GRAPH_NODE_WIDTH, height: GRAPH_NODE_HEIGHT }, + }; + }); const rfEdges: Edge[] = edges .filter((e) => byId.has(e.src) && byId.has(e.dst)) .map((e) => { @@ -135,12 +154,22 @@ function GraphInspector({ edges, onClose, onWhatIf, + onSelect, + onOpenFile, + pinned, + onPin, + onIsolate, }: { node: GraphNode; nodes: GraphNode[]; edges: GraphEdge[]; onClose: () => void; onWhatIf?: (id: string) => void; + onSelect?: (id: string) => void; + onOpenFile?: (path: string, line?: number | null) => void; + pinned?: boolean; + onPin?: (id: string | null) => void; + onIsolate?: (id: string) => void; }) { const info = inspectNode(node, nodes, edges); useEffect(() => { @@ -176,7 +205,21 @@ function GraphInspector({ {info.purpose}

{info.context ?
{wrapHint(info.context)}
: null} - {info.file ?
{wrapHint(info.file)}
: null} + {info.file ? ( +
+
{wrapHint(info.file)}
+ {onOpenFile && node.file_path ? ( + + ) : null} +
+ ) : null}
{wrapHint(info.qualifiedName)}
layer · {info.layer}
@@ -203,6 +246,7 @@ function GraphInspector({ links={info.inputs} extra={info.extraInputs} empty="Nothing in this graph points here." + onSelect={onSelect} /> - {onWhatIf ? ( - - ) : null} +
+ {onWhatIf ? ( + + ) : null} + {onIsolate ? ( + + ) : null} + {onPin ? ( + + ) : null} +
); } @@ -226,12 +288,14 @@ function InspectorLinks({ links, extra, empty, + onSelect, }: { title: string; testId: string; links: InspectorLink[]; extra: number; empty: string; + onSelect?: (id: string) => void; }) { return (
@@ -243,14 +307,29 @@ function InspectorLinks({
    {links.map((link, i) => (
  • - - {wrapHint(link.name)} - - - {link.typeLabel ? `${link.typeLabel} · ` : ""} - {link.edgeLabel} - {link.inferred ? " · inferred" : ""} - + {onSelect ? ( + + ) : ( + <> + + {wrapHint(link.name)} + + + {link.typeLabel ? `${link.typeLabel} · ` : ""} + {link.edgeLabel} + {link.inferred ? " · inferred" : ""} + + + )}
  • ))}
@@ -267,50 +346,81 @@ export function ImpactGraph({ edges, onWhatIf, focusPath, + selectedId: selectedIdProp, + onSelect, + nodeRoles, + testOverlay = false, + isolateSource, + onIsolate, + repoPath: _repoPath, + onOpenFile, + pinnedId, + onPin, }: { nodes: GraphNode[]; edges: GraphEdge[]; onWhatIf?: (id: string) => void; focusPath?: string; + selectedId?: string | null; + onSelect?: (id: string | null) => void; + nodeRoles?: Record; + testOverlay?: boolean; + isolateSource?: string | null; + onIsolate?: (id: string | null) => void; + repoPath?: string; + onOpenFile?: (path: string, line?: number | null) => void; + pinnedId?: string | null; + onPin?: (id: string | null) => void; }) { - const [selectedId, setSelectedId] = useState(null); + const [localSelected, setLocalSelected] = useState(null); + const selectedId = selectedIdProp !== undefined ? selectedIdProp : localSelected; + const setSelectedId = (id: string | null) => { + if (selectedIdProp === undefined) setLocalSelected(id); + onSelect?.(id); + }; const [projection, setProjection] = useState(null); const [detail, setDetail] = useState(null); const [families, setFamilies] = useState>(new Set(ALL_FAMILIES)); const [neighborhoodOnly, setNeighborhoodOnly] = useState(false); + const [query, setQuery] = useState(""); + const [hitsOpen, setHitsOpen] = useState(false); const reduceMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches; const view = projection ?? defaultProjection(nodes.length); const level = detail ?? defaultDetail(nodes.length); - const neighborhoodFocus = neighborhoodOnly && view === "3d" ? selectedId : null; + const neighborhoodFocus = neighborhoodOnly ? selectedId : null; + const isolated = useMemo( + () => (isolateSource ? isolatePathIds(nodes, edges, isolateSource) : null), + [nodes, edges, isolateSource], + ); + const scopedNodes = isolated ? nodes.filter((n) => isolated.nodeIds.has(n.id)) : nodes; + const scopedEdges = isolated ? edges.filter((e) => isolated.edgeIds.has(e.id)) : edges; const visible = useMemo( () => - visibleGraph(nodes, edges, { + visibleGraph(scopedNodes, scopedEdges, { detail: level, families, focusId: neighborhoodFocus, neighborhoodOnly: Boolean(neighborhoodFocus), }), - [nodes, edges, level, families, neighborhoodFocus], + [scopedNodes, scopedEdges, level, families, neighborhoodFocus], ); const topologyKey = useMemo( () => `${visible.nodes.map((n) => n.id).join("\0")}|${visible.edges.map((e) => e.id).join("\0")}`, [visible.nodes, visible.edges], ); - const byId = useMemo(() => new Map(visible.nodes.map((n) => [n.id, n])), [visible.nodes]); - const selected = selectedId ? byId.get(selectedId) ?? null : null; + const selected = selectedId ? nodes.find((n) => n.id === selectedId) ?? null : null; const { rfNodes, rfEdges } = useMemo(() => { - const elements = toReactFlowElements(visible.nodes, visible.edges, selectedId); + const elements = toReactFlowElements(visible.nodes, visible.edges, selectedId, { + roles: nodeRoles, + testOverlay, + }); if (reduceMotion) { elements.rfEdges = elements.rfEdges.map((edge) => ({ ...edge, animated: false })); } return elements; - }, [visible.nodes, visible.edges, selectedId, reduceMotion]); - - useEffect(() => { - if (selectedId && !byId.has(selectedId)) setSelectedId(null); - }, [byId, selectedId]); + }, [visible.nodes, visible.edges, selectedId, reduceMotion, nodeRoles, testOverlay]); useEffect(() => { if (!focusPath) return; @@ -318,6 +428,8 @@ export function ImpactGraph({ if (match) setSelectedId(match.id); }, [focusPath, nodes]); + const hits = useMemo(() => searchNodes(nodes, query), [nodes, query]); + const onNodeClick: NodeMouseHandler = (_evt, node) => { setSelectedId(node.id); }; @@ -327,6 +439,27 @@ export function ImpactGraph({ setNeighborhoodOnly(false); }; + const inspector = selected ? ( + { + onIsolate(isolateSource === id ? null : id); + } + : undefined + } + /> + ) : null; + const toggleFamily = (family: GraphFamily) => { setFamilies((current) => { const next = new Set(current); @@ -407,17 +540,59 @@ export function ImpactGraph({ ))}
- {view === "3d" ? ( + + {isolateSource ? ( ) : null} + {visible.nodes.length} nodes · {visible.edges.length} edges {hidden ? ` · ${hidden} hidden` : ""} @@ -442,9 +617,7 @@ export function ImpactGraph({ }} /> - {selected ? ( - - ) : null} + {inspector}
) : ( @@ -480,9 +653,7 @@ export function ImpactGraph({ /> - {selected ? ( - - ) : null} + {inspector} )}
diff --git a/ui/src/api.ts b/ui/src/api.ts index eb7fd88..1b5eaa1 100644 --- a/ui/src/api.ts +++ b/ui/src/api.ts @@ -1,4 +1,20 @@ -import type { ArchitectureReport, FsListing, GitRefs, GraphNode, IndexedRepo, IndexProgress, PullRequest, RemoteRepo, Review } from "./types"; +import type { + ArchitectureHealth, + ArchitectureReport, + FsListing, + GitRefs, + GraphEdge, + GraphNode, + IndexedRepo, + IndexProgress, + LoadpathConfigDoc, + PullRequest, + RemoteRepo, + Review, + ReviewDiff, + ReviewSummary, + WorkspaceStatus, +} from "./types"; export function formatApiError(text: string, fallback = "Request failed"): string { const trimmed = (text || "").trim(); @@ -114,10 +130,10 @@ export const api = { req<{ nodes: unknown[]; edges: unknown[]; counts: { nodes: number; edges: number } }>( `/api/graph?repo_path=${encodeURIComponent(repo_path)}&scope=${scope}`, ), - prs: (provider: string, repo: string, state = "open") => + prs: (provider: string, repo: string, state = "open", repo_path?: string) => req<{ pull_requests: PullRequest[] }>("/api/prs", { method: "POST", - body: JSON.stringify({ provider, repo, state }), + body: JSON.stringify({ provider, repo, state, repo_path: repo_path || null }), }), scmRepos: (provider: string) => req<{ provider: string; user: { login: string; name: string; url: string }; repos: RemoteRepo[] }>( @@ -157,4 +173,62 @@ export const api = { method: "POST", body: JSON.stringify({ review }), }), + reviews: (repo_path: string) => + req<{ reviews: ReviewSummary[] }>(`/api/reviews?repo_path=${encodeURIComponent(repo_path)}`), + getReview: (repo_path: string, review_id: string) => + req(`/api/reviews/${encodeURIComponent(review_id)}?repo_path=${encodeURIComponent(repo_path)}`), + reviewDiff: (repo_path: string, review_id: string, other: string) => + req( + `/api/reviews/${encodeURIComponent(review_id)}/diff?repo_path=${encodeURIComponent(repo_path)}&other=${encodeURIComponent(other)}`, + ), + config: (repo_path: string) => + req(`/api/config?repo_path=${encodeURIComponent(repo_path)}`), + saveConfig: (repo_path: string, body: Partial) => + req("/api/config", { + method: "PUT", + body: JSON.stringify({ repo_path, ...body }), + }), + addWaiver: (repo_path: string, rule: string, node?: string, reason?: string) => + req("/api/config/waiver", { + method: "POST", + body: JSON.stringify({ repo_path, rule, node: node || null, reason: reason || "" }), + }), + marks: (repo_path: string, review_id?: string) => + req<{ review_id: string | null; files: { path: string; badge: string; tooltip: string; roles: string[] }[] }>( + `/api/marks?repo_path=${encodeURIComponent(repo_path)}${review_id ? `&review_id=${encodeURIComponent(review_id)}` : ""}`, + ), + architectureHealth: (repo_path: string) => + req(`/api/architecture/health?repo_path=${encodeURIComponent(repo_path)}`), + workspaceStatus: (repo_path: string) => + req(`/api/workspace/status?repo_path=${encodeURIComponent(repo_path)}`), + openEditor: (repo_path: string, path: string, line?: number, editor?: string) => + req<{ + ok: boolean; + path: string; + abs_path: string; + line?: number | null; + opened_with?: string | null; + urls?: Record; + error?: string; + }>("/api/open", { + method: "POST", + body: JSON.stringify({ repo_path, path, line: line || null, editor: editor || null }), + }), + exportHtml: (review: Review) => + fetch("/api/export/html", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ review }), + }).then(async (res) => { + if (!res.ok) { + const text = await res.text(); + throw new Error(formatApiError(text, res.statusText || "Request failed")); + } + return res.blob(); + }), + isolate: (nodes: GraphNode[], edges: GraphEdge[], source_id: string, target_id?: string) => + req<{ node_ids: string[]; edge_ids: string[]; targets: string[] }>("/api/graph/isolate", { + method: "POST", + body: JSON.stringify({ nodes, edges, source_id, target_id: target_id || null }), + }), }; diff --git a/ui/src/experience.test.ts b/ui/src/experience.test.ts new file mode 100644 index 0000000..fe679e0 --- /dev/null +++ b/ui/src/experience.test.ts @@ -0,0 +1,24 @@ +import { describe, expect, it } from "vitest"; +import { filterActions } from "./CommandPalette"; +import { vscodeFileUrl } from "./openEditor"; + +describe("filterActions", () => { + const actions = [ + { id: "a", label: "Review this range", hint: "⌘Enter", group: "Run", run: () => undefined }, + { id: "b", label: "InvoiceSerializer", hint: "serializer", group: "Nodes", run: () => undefined }, + ]; + + it("filters by label, hint, and group", () => { + expect(filterActions(actions, "review").map((a) => a.id)).toEqual(["a"]); + expect(filterActions(actions, "serializer").map((a) => a.id)).toEqual(["b"]); + expect(filterActions(actions, "nodes").map((a) => a.id)).toEqual(["b"]); + expect(filterActions(actions, "")).toHaveLength(2); + }); +}); + +describe("vscodeFileUrl", () => { + it("builds a cursor/vscode file URI with a line", () => { + expect(vscodeFileUrl("/tmp/acme/a.py", 12, "cursor")).toBe("cursor://file/tmp/acme/a.py:12"); + expect(vscodeFileUrl("C:\\repo\\a.py", 1, "vscode")).toContain("vscode://file/"); + }); +}); diff --git a/ui/src/graphView.test.ts b/ui/src/graphView.test.ts index 613cac2..3112366 100644 --- a/ui/src/graphView.test.ts +++ b/ui/src/graphView.test.ts @@ -6,8 +6,10 @@ import { defaultDetail, defaultProjection, familyFor, + isolatePathIds, layoutNodes3d, neighborIds, + searchNodes, visibleGraph, } from "./graphView"; import type { GraphEdge, GraphNode } from "./types"; @@ -82,6 +84,32 @@ describe("neighborIds", () => { }); }); +describe("isolatePathIds", () => { + it("keeps only nodes on the path from source to a sink", () => { + const pathNodes: GraphNode[] = [ + node("field", "django.field", "total"), + node("ser", "django.serializer", "InvoiceSerializer"), + node("route", "django.route", "/api/invoices"), + node("me", "react.page", "MePage"), + ]; + const pathEdges: GraphEdge[] = [ + edge("field", "ser"), + edge("ser", "route"), + edge("ser", "me"), + ]; + const isolated = isolatePathIds(pathNodes, pathEdges, "field", "route"); + expect([...isolated.nodeIds].sort()).toEqual(["field", "route", "ser"]); + expect(isolated.edgeIds.has("ser->me")).toBe(false); + }); +}); + +describe("searchNodes", () => { + it("matches name and type", () => { + expect(searchNodes(nodes, "invoice").map((n) => n.id)).toEqual([]); + expect(searchNodes(nodes, "component").map((n) => n.id)).toEqual(["c"]); + }); +}); + describe("defaults", () => { it("uses 3d overview once the graph is large", () => { expect(defaultProjection(LARGE_GRAPH - 1)).toBe("2d"); diff --git a/ui/src/graphView.ts b/ui/src/graphView.ts index d638fb2..2bffebd 100644 --- a/ui/src/graphView.ts +++ b/ui/src/graphView.ts @@ -4,6 +4,21 @@ export type GraphFamily = "django" | "react" | "stitch" | "arch"; export type GraphDetail = "overview" | "full"; export type GraphProjection = "2d" | "3d"; +export const PATH_SINK_TYPES = new Set([ + "django.route", + "react.route", + "react.page", + "django.task", + "django.migration_op", + "django.permission", + "openapi.path", + "django.consumer", + "django.websocket_route", + "django.template", + "graphql.operation", + "fastapi.route", +]); + export const LARGE_GRAPH = 90; /** Leaf noise that turns a load-path into an unreadable field cloud. */ @@ -155,6 +170,69 @@ export function visibleGraph( return { nodes: kept, edges: linked, neighborIds: neighbors }; } +export function searchNodes(nodes: GraphNode[], query: string): GraphNode[] { + const q = query.trim().toLowerCase(); + if (!q) return []; + return nodes + .filter((n) => { + const hay = `${n.name} ${n.qualified_name} ${n.type} ${n.file_path || ""} ${n.context || ""}`.toLowerCase(); + return hay.includes(q); + }) + .slice(0, 24); +} + +export function isolatePathIds( + nodes: GraphNode[], + edges: GraphEdge[], + sourceId: string, + targetId?: string | null, +): { nodeIds: Set; edgeIds: Set } { + const ids = new Set(nodes.map((n) => n.id)); + if (!ids.has(sourceId)) return { nodeIds: new Set(), edgeIds: new Set() }; + const succ = new Map(); + const pred = new Map(); + for (const e of edges) { + if (!ids.has(e.src) || !ids.has(e.dst)) continue; + const s = succ.get(e.src) ?? []; + s.push({ dst: e.dst, id: e.id }); + succ.set(e.src, s); + const p = pred.get(e.dst) ?? []; + p.push({ src: e.src, id: e.id }); + pred.set(e.dst, p); + } + const sinks = new Set(nodes.filter((n) => PATH_SINK_TYPES.has(n.type)).map((n) => n.id)); + const targets = targetId && ids.has(targetId) ? new Set([targetId]) : sinks.size ? sinks : ids; + + const reachable = new Set(); + const stack = [sourceId]; + while (stack.length) { + const cur = stack.pop()!; + if (reachable.has(cur)) continue; + reachable.add(cur); + for (const nxt of succ.get(cur) ?? []) { + if (!reachable.has(nxt.dst)) stack.push(nxt.dst); + } + } + const keep = new Set([sourceId]); + const back = [...targets].filter((t) => reachable.has(t)); + const seen = new Set(back); + while (back.length) { + const cur = back.pop()!; + keep.add(cur); + for (const prev of pred.get(cur) ?? []) { + if (reachable.has(prev.src) && !seen.has(prev.src)) { + seen.add(prev.src); + back.push(prev.src); + } + } + } + const edgeIds = new Set(); + for (const e of edges) { + if (keep.has(e.src) && keep.has(e.dst)) edgeIds.add(e.id); + } + return { nodeIds: keep, edgeIds }; +} + export function layoutNodes3d(nodes: GraphNode[]): Map { const columns = new Map(); for (const n of nodes) { diff --git a/ui/src/openEditor.ts b/ui/src/openEditor.ts new file mode 100644 index 0000000..e2d1330 --- /dev/null +++ b/ui/src/openEditor.ts @@ -0,0 +1,44 @@ +import { api } from "./api"; + +export type EditorKind = "auto" | "cursor" | "vscode" | "system"; + +export function editorPreference(): EditorKind { + const raw = localStorage.getItem("loadpath.editor") || "auto"; + if (raw === "cursor" || raw === "vscode" || raw === "system") return raw; + return "auto"; +} + +export function persistEditorPreference(kind: EditorKind) { + localStorage.setItem("loadpath.editor", kind); +} + +export function vscodeFileUrl(absPath: string, line?: number | null, scheme = "vscode"): string { + const normalized = absPath.replaceAll("\\", "/"); + const withSlash = normalized.startsWith("/") ? normalized : `/${normalized}`; + const loc = line && line > 0 ? `${withSlash}:${line}` : withSlash; + return `${scheme}://file${loc}`; +} + +export async function openInEditor( + repoPath: string, + relPath: string, + line?: number | null, + editor: EditorKind = editorPreference(), +): Promise<{ ok: boolean; message: string }> { + try { + const result = await api.openEditor(repoPath, relPath, line ?? undefined, editor); + if (result.ok) { + return { ok: true, message: `Opened ${relPath} in ${result.opened_with || "editor"}` }; + } + const urls = result.urls || {}; + const preferred = + editor === "vscode" ? urls.vscode : editor === "cursor" ? urls.cursor : urls.cursor || urls.vscode; + if (preferred) { + window.open(preferred, "_blank", "noopener,noreferrer"); + return { ok: true, message: `Opening ${relPath} via editor URL` }; + } + return { ok: false, message: result.error || "Could not open editor" }; + } catch (err) { + return { ok: false, message: err instanceof Error ? err.message : String(err) }; + } +} diff --git a/ui/src/styles.css b/ui/src/styles.css index 9487392..7f57159 100644 --- a/ui/src/styles.css +++ b/ui/src/styles.css @@ -1531,6 +1531,19 @@ h2 { font-size: 13px; margin: 0; font-weight: 600; } .legend i.exp { background: var(--edge-expensive); } .legend i.crit { background: var(--edge-critical); height: 3px; } .legend i.dash { border-top: 2px dashed var(--muted); background: none; height: 0; } +.legend i.seed { + height: 10px; + width: 10px; + border-radius: 2px; + background: color-mix(in srgb, var(--medium) 70%, var(--node-bg)); +} +.legend i.down { + height: 10px; + width: 10px; + border-radius: 2px; + border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--node-line)); + background: var(--node-bg); +} .inspector { position: absolute; top: 12px; @@ -1700,6 +1713,164 @@ h2 { font-size: 13px; margin: 0; font-weight: 600; } overflow-wrap: anywhere; } .lp-node.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); } +.lp-node.role-seed { + border-color: var(--medium); + background: color-mix(in srgb, var(--medium) 14%, var(--node-bg)); +} +.lp-node.role-downstream { + border-color: color-mix(in srgb, var(--accent) 45%, var(--node-line)); +} +.lp-node.role-untested { box-shadow: inset 3px 0 0 var(--low); } +.lp-node.role-tested { box-shadow: inset 3px 0 0 var(--high); } +.lp-node.role-contract { outline: 1px dashed color-mix(in srgb, var(--accent) 50%, transparent); } +.lp-node.dim { opacity: 0.38; } +.merge-box.compact { + padding: 6px 10px; + min-width: 92px; + margin: 0; +} +.merge-box.compact .level { font-size: 12px; } +.palette-scrim { + position: fixed; + inset: 0; + background: color-mix(in srgb, var(--bg) 55%, transparent); + z-index: 40; + display: grid; + place-items: start center; + padding-top: 12vh; +} +.palette { + width: min(640px, calc(100vw - 32px)); + background: var(--surface); + border: 1px solid var(--line); + border-radius: 12px; + box-shadow: 0 18px 60px var(--shadow); + overflow: hidden; +} +.palette input { + width: 100%; + border: 0; + border-bottom: 1px solid var(--line); + background: transparent; + color: var(--ink); + padding: 14px 16px; + font: inherit; +} +.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 360px; overflow: auto; } +.palette li button { + width: 100%; + display: flex; + justify-content: space-between; + gap: 12px; + text-align: left; + background: transparent; + border: 0; + color: var(--ink); + padding: 8px 10px; + border-radius: 8px; + cursor: pointer; +} +.palette li button.active, .palette li button:hover { background: var(--rail-active); } +.palette-foot { padding: 8px 12px 10px; } +.graph-search { position: relative; min-width: 140px; } +.graph-search input { + width: 100%; + background: var(--bg-2); + border: 1px solid var(--line); + color: var(--ink); + border-radius: 8px; + padding: 6px 8px; + font: inherit; +} +.graph-search-hits { + position: absolute; + z-index: 5; + left: 0; + right: 0; + top: calc(100% + 4px); + background: var(--surface); + border: 1px solid var(--line); + border-radius: 8px; + list-style: none; + margin: 0; + padding: 4px; + max-height: 240px; + overflow: auto; +} +.graph-search-hits button { + width: 100%; + display: flex; + justify-content: space-between; + gap: 8px; + background: transparent; + border: 0; + color: var(--ink); + text-align: left; + padding: 6px 8px; + cursor: pointer; +} +.graph-search-hits button:hover { background: var(--rail-active); } +.inspector-link { + display: flex; + flex-direction: column; + width: 100%; + background: transparent; + border: 0; + color: inherit; + text-align: left; + cursor: pointer; + padding: 0; +} +.file-row { display: flex; flex-direction: column; gap: 6px; } +.linkish { + background: none; + border: 0; + color: inherit; + font: inherit; + text-align: left; + cursor: pointer; + padding: 0; +} +.history-item, .check-item { + display: flex; + flex-wrap: wrap; + gap: 8px; + align-items: baseline; + width: 100%; + background: transparent; + border: 0; + color: inherit; + font: inherit; + text-align: left; + padding: 6px 0; + cursor: pointer; +} +.history-item.current { color: var(--accent); } +.check-row { display: flex; gap: 8px; align-items: center; margin: 4px 0; } +.sparkline { + display: flex; + align-items: flex-end; + gap: 3px; + height: 36px; + margin: 8px 0; +} +.sparkline i { + flex: 1; + background: var(--muted); + border-radius: 2px 2px 0 0; + min-width: 4px; +} +.sparkline i.high { background: var(--high); } +.sparkline i.medium { background: var(--medium); } +.sparkline i.low { background: var(--low); } +.config-editor .field { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; } +.config-editor input, .config-editor select { + background: var(--bg-2); + border: 1px solid var(--line); + color: var(--ink); + border-radius: 8px; + padding: 6px 8px; +} .react-flow__node-load .react-flow__handle { width: 8px; height: 8px; diff --git a/ui/src/types.ts b/ui/src/types.ts index 843f59e..705156e 100644 --- a/ui/src/types.ts +++ b/ui/src/types.ts @@ -44,6 +44,37 @@ export type DeepeningCandidate = { top?: boolean; }; +export type ChecklistItem = { + id: string; + kind: string; + status: "todo" | "done" | "info" | string; + title: string; + detail?: string; + node_id?: string | null; + file_path?: string | null; + rule?: string | null; + body?: string; + action?: string; +}; + +export type ContractSideRow = { + field: string; + serializer: boolean; + zod: boolean; + openapi: boolean; + graphql: boolean; + status: string; +}; + +export type FileMark = { + path: string; + line?: number | null; + roles: string[]; + node_id?: string; + badge: string; + tooltip: string; +}; + export type Review = { id: string; title: string; @@ -72,7 +103,18 @@ export type Review = { architecture_note: string; depth_note?: string; deepening?: DeepeningCandidate[]; - contract_break?: { kind: string; reasons: string[]; fields: string[] }; + contract_break?: { + kind: string; + reasons: string[]; + fields: string[]; + sides?: { + serializer: string[]; + zod: string[]; + openapi: string[]; + graphql: string[]; + rows: ContractSideRow[]; + }; + }; auth?: { note: string; sinks: { id: string; name: string; permissions: string[] }[]; @@ -86,9 +128,20 @@ export type Review = { change_coupling: { a: string; b: string; together: number; cross_context?: boolean }[]; notes: string[]; }; + seed_ids?: string[]; + node_roles?: Record; + checklist?: ChecklistItem[]; + marks?: FileMark[]; + codeowners?: { + path?: string | null; + owners: string[]; + files: { path: string; owners: string[] }[]; + }; + codeowners_reviewers?: string[]; nodes: GraphNode[]; edges: GraphEdge[]; markdown?: string; + pull_request?: Record; index?: { db: string; counts: { nodes: number; edges: number }; @@ -157,6 +210,75 @@ export type ArchitectureReport = { boot_residuals?: string[]; }; +export type ReviewSummary = { + id: string; + created_at?: string; + base_ref?: string | null; + head_ref?: string | null; + title?: string; + level?: string; + sinks?: number; + covered_sinks?: number; + contract_break?: string; + findings?: number; + low_risk?: boolean; + labels?: string[]; + what_if?: boolean; + contexts?: string[]; +}; + +export type ReviewDiff = { + direction: string; + added_sinks: string[]; + removed_sinks: string[]; + added_findings: number; + removed_findings: number; + from_level?: string; + to_level?: string; + from_contract?: string; + to_contract?: string; + note: string; +}; + +export type ArchitectureHealth = { + points: { + id?: string; + created_at?: string; + level?: string; + sinks?: number; + findings?: number; + inferred_ratio?: number; + contexts?: Record; + title?: string; + }[]; + contexts: Record; +}; + +export type LoadpathConfigDoc = { + repo_root: string; + path: string; + exists: boolean; + contexts: Record< + string, + { name: string; django_apps: string[]; react: string[]; public_api: string[]; owners: string[] } + >; + rules: string[]; + available_rules: string[]; + waivers: { rule: string; node?: string | null; reason?: string }[]; + django_root: string; + react_root: string; + openapi_paths: string[]; + boot_django: boolean; + layers: { django: string[]; react: string[] }; +}; + +export type WorkspaceStatus = { + repo_path: string; + dirty: string[]; + dirty_count: number; + fingerprint: string; +}; + export type IndexedRepo = { path: string; name: string; @@ -185,6 +307,7 @@ export type PullRequest = { draft: boolean; head_sha?: string; base_sha?: string; + loadpath?: ReviewSummary; }; export type RemoteRepo = { From 494c7ba404fb96d923dcf90c4191ba12ba7f1f9c Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 15 Aug 2026 23:23:04 +0000 Subject: [PATCH 02/16] Scope screenshot wait to the review brief confidence level. The top-bar merge box also uses .level, so a page-wide locator is no longer unique. Co-authored-by: zord.lack.net --- tests/e2e/test_ui_screenshots.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/e2e/test_ui_screenshots.py b/tests/e2e/test_ui_screenshots.py index e84c962..dc89107 100644 --- a/tests/e2e/test_ui_screenshots.py +++ b/tests/e2e/test_ui_screenshots.py @@ -113,7 +113,8 @@ def test_ui_review_graph_prs_settings(live_app, tmp_path: Path, browser_page): error = page.locator(".error") if error.count() and error.inner_text().strip(): pytest.fail(error.inner_text()) - page.locator(".level").wait_for(timeout=15_000) + page.get_by_test_id("merge-box").wait_for(timeout=15_000) + page.get_by_test_id("brief").locator(".level").wait_for(timeout=15_000) brief = page.get_by_test_id("brief").inner_text() assert "MEDIUM" in brief or "LOW" in brief or "HIGH" in brief _wait_graph(page) From 41a34b28d7c74227b55a4984f9bfac54dcca8bfc Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 15 Aug 2026 23:29:37 +0000 Subject: [PATCH 03/16] Keep review path isolate off the architecture graph. Isolating a walk to sinks is a review-graph action; the indexed architecture view should stay the full map when the user switches tabs. Co-authored-by: zord.lack.net --- ...redGraph3D-B-dkkPpV.js => LayeredGraph3D-DIo4wwkt.js} | 2 +- .../assets/{index-Dg2mxCJ9.js => index-Cksrgi4F.js} | 2 +- src/loadpath/static/index.html | 2 +- ui/src/App.tsx | 9 ++++++++- 4 files changed, 11 insertions(+), 4 deletions(-) rename src/loadpath/static/assets/{LayeredGraph3D-B-dkkPpV.js => LayeredGraph3D-DIo4wwkt.js} (99%) rename src/loadpath/static/assets/{index-Dg2mxCJ9.js => index-Cksrgi4F.js} (93%) diff --git a/src/loadpath/static/assets/LayeredGraph3D-B-dkkPpV.js b/src/loadpath/static/assets/LayeredGraph3D-DIo4wwkt.js similarity index 99% rename from src/loadpath/static/assets/LayeredGraph3D-B-dkkPpV.js rename to src/loadpath/static/assets/LayeredGraph3D-DIo4wwkt.js index 2b386f8..753c7a2 100644 --- a/src/loadpath/static/assets/LayeredGraph3D-B-dkkPpV.js +++ b/src/loadpath/static/assets/LayeredGraph3D-DIo4wwkt.js @@ -1,4 +1,4 @@ -import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-Dg2mxCJ9.js";/** +import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-Cksrgi4F.js";/** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT diff --git a/src/loadpath/static/assets/index-Dg2mxCJ9.js b/src/loadpath/static/assets/index-Cksrgi4F.js similarity index 93% rename from src/loadpath/static/assets/index-Dg2mxCJ9.js rename to src/loadpath/static/assets/index-Cksrgi4F.js index 23e1c1d..16cfb7e 100644 --- a/src/loadpath/static/assets/index-Dg2mxCJ9.js +++ b/src/loadpath/static/assets/index-Cksrgi4F.js @@ -59,4 +59,4 @@ Error generating stack: `+g.message+` `,` +`).split(` `)),v=x.reduce((m,y)=>m.concat(...y),[]);return[x,v]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Yh,x=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const v=_=>{var E,w;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!x)&&hg(_))return!1;const j=Xh(_.code,h);if(u.current.add(_[j]),Gh(c,u.current,!1)){const M=((w=(E=_.composedPath)==null?void 0:E.call(_))==null?void 0:w[0])||_.target,k=(M==null?void 0:M.nodeName)==="BUTTON"||(M==null?void 0:M.nodeName)==="A";r.preventDefault!==!1&&(a.current||!k)&&_.preventDefault(),s(!0)}},m=_=>{const N=Xh(_.code,h);Gh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[N]),_.key==="Meta"&&u.current.clear(),a.current=!1},y=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",v),p==null||p.addEventListener("keyup",m),window.addEventListener("blur",y),window.addEventListener("contextmenu",y),()=>{p==null||p.removeEventListener("keydown",v),p==null||p.removeEventListener("keyup",m),window.removeEventListener("blur",y),window.removeEventListener("contextmenu",y)}}},[t,s]),o}function Gh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Xh(t,r){return r.includes(t)?"code":"key"}const C_=()=>{const t=Ye();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=_c(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),x={x:r.x-h,y:r.y-p},v=o.snapGrid??a,m=o.snapToGrid??u;return ds(x,s,m,v)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=Zi(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function Ag(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)M_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function M_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function P_(t,r){return Ag(t,r)}function I_(t,r){return Ag(t,r)}function Jr(t,r){return{id:t,type:"select",selected:r}}function Ui(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(Jr(u.id,c)))}return s}function qh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Kh(t){return{id:t.id,type:"remove"}}const R_=ug();function T_(t,r,o={}){return m1(t,r,{...o,onError:o.onError??R_})}const Qh=t=>t1(t),L_=t=>ig(t);function $g(t){return L.forwardRef(t)}const zg=typeof window<"u"?L.useLayoutEffect:L.useEffect;function Zh(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>A_(()=>o(a=>a+BigInt(1))));return zg(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function A_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Dg=L.createContext(null);function $_({children:t}){const r=Ye(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:x,hasDefaultNodes:v,onNodesChange:m,nodeLookup:y,fitViewQueued:_,onNodesChangeMiddlewareMap:N}=r.getState();let j=p;for(const w of h)j=typeof w=="function"?w(j):w;let E=qh({items:j,lookup:y});for(const w of N.values())E=w(E);v&&x(j),E.length>0?m==null||m(E):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:w,nodes:M,setNodes:k}=r.getState();w&&k(M)})},[]),s=Zh(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:x,hasDefaultEdges:v,onEdgesChange:m,edgeLookup:y}=r.getState();let _=p;for(const N of h)_=typeof N=="function"?N(_):N;v?x(_):m&&m(qh({items:_,lookup:y}))},[]),u=Zh(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Dg.Provider,{value:c,children:t})}function z_(){const t=L.useContext(Dg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const D_=t=>!!t.panZoom;function ql(){const t=C_(),r=Ye(),o=z_(),s=ze(D_),a=L.useMemo(()=>{const u=m=>r.getState().nodeLookup.get(m),c=m=>{o.nodeQueue.push(m)},h=m=>{o.edgeQueue.push(m)},p=m=>{var w,M;const{nodeLookup:y,nodeOrigin:_}=r.getState(),N=Qh(m)?m:y.get(m.id),j=N.parentId?dg(N.position,N.measured,N.parentId,y,_):N.position,E={...N,position:j,width:((w=N.measured)==null?void 0:w.width)??N.width,height:((M=N.measured)==null?void 0:M.height)??N.height};return ns(E)},x=(m,y,_={replace:!1})=>{c(N=>N.map(j=>{if(j.id===m){const E=typeof y=="function"?y(j):y;return _.replace&&Qh(E)?E:{...j,...E}}return j}))},v=(m,y,_={replace:!1})=>{h(N=>N.map(j=>{if(j.id===m){const E=typeof y=="function"?y(j):y;return _.replace&&L_(E)?E:{...j,...E}}return j}))};return{getNodes:()=>r.getState().nodes.map(m=>({...m})),getNode:m=>{var y;return(y=u(m))==null?void 0:y.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:m=[]}=r.getState();return m.map(y=>({...y}))},getEdge:m=>r.getState().edgeLookup.get(m),setNodes:c,setEdges:h,addNodes:m=>{const y=Array.isArray(m)?m:[m];o.nodeQueue.push(_=>[..._,...y])},addEdges:m=>{const y=Array.isArray(m)?m:[m];o.edgeQueue.push(_=>[..._,...y])},toObject:()=>{const{nodes:m=[],edges:y=[],transform:_}=r.getState(),[N,j,E]=_;return{nodes:m.map(w=>({...w})),edges:y.map(w=>({...w})),viewport:{x:N,y:j,zoom:E}}},deleteElements:async({nodes:m=[],edges:y=[]})=>{const{nodes:_,edges:N,onNodesDelete:j,onEdgesDelete:E,triggerNodeChanges:w,triggerEdgeChanges:M,onDelete:k,onBeforeDelete:b}=r.getState(),{nodes:A,edges:$}=await s1({nodesToRemove:m,edgesToRemove:y,nodes:_,edges:N,onBeforeDelete:b}),V=$.length>0,X=A.length>0;if(V){const G=$.map(Kh);E==null||E($),M(G)}if(X){const G=A.map(Kh);j==null||j(A),w(G)}return(X||V)&&(k==null||k({nodes:A,edges:$})),{deletedNodes:A,deletedEdges:$}},getIntersectingNodes:(m,y=!0,_)=>{const N=Sh(m),j=N?m:p(m),E=_!==void 0;return j?(_||r.getState().nodes).filter(w=>{const M=r.getState().nodeLookup.get(w.id);if(M&&!N&&(w.id===m.id||!M.internals.positionAbsolute))return!1;const k=ns(E?w:M),b=$l(k,j);return y&&b>0||b>=k.width*k.height||b>=j.width*j.height}):[]},isNodeIntersecting:(m,y,_=!0)=>{const j=Sh(m)?m:p(m);if(!j)return!1;const E=$l(j,y);return _&&E>0||E>=y.width*y.height||E>=j.width*j.height},updateNode:x,updateNodeData:(m,y,_={replace:!1})=>{x(m,N=>{const j=typeof y=="function"?y(N):y;return _.replace?{...N,data:j}:{...N,data:{...N.data,...j}}},_)},updateEdge:v,updateEdgeData:(m,y,_={replace:!1})=>{v(m,N=>{const j=typeof y=="function"?y(N):y;return _.replace?{...N,data:j}:{...N,data:{...N.data,...j}}},_)},getNodesBounds:m=>{const{nodeLookup:y,nodeOrigin:_}=r.getState();return n1(m,{nodeLookup:y,nodeOrigin:_})},getHandleConnections:({type:m,id:y,nodeId:_})=>{var N;return Array.from(((N=r.getState().connectionLookup.get(`${_}-${m}${y?`-${y}`:""}`))==null?void 0:N.values())??[])},getNodeConnections:({type:m,handleId:y,nodeId:_})=>{var N;return Array.from(((N=r.getState().connectionLookup.get(`${_}${m?y?`-${m}-${y}`:`-${m}`:""}`))==null?void 0:N.values())??[])},fitView:async m=>{const y=r.getState().fitViewResolver??u1();return r.setState({fitViewQueued:!0,fitViewOptions:m,fitViewResolver:y}),o.nodeQueue.push(_=>[..._]),y.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const Jh=t=>t.selected,O_=typeof window<"u"?window:void 0;function F_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ye(),{deleteElements:s}=ql(),a=is(t,{actInsideInputWithModifier:!1}),u=is(r,{target:O_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(Jh),edges:c.filter(Jh)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function H_(t){const r=Ye();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=Sc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",wn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const Kl={position:"absolute",width:"100%",height:"100%",top:0,left:0},B_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function V_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=ni.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:x,translateExtent:v,minZoom:m,maxZoom:y,zoomActivationKeyCode:_,preventScrolling:N=!0,children:j,noWheelClassName:E,noPanClassName:w,onViewportChange:M,isControlledViewport:k,paneClickDistance:b,selectionOnDrag:A}){const $=Ye(),V=L.useRef(null),{userSelectionActive:X,lib:G,connectionInProgress:J}=ze(B_,Qe),Z=is(_),re=L.useRef();H_(V);const te=L.useCallback(I=>{M==null||M({x:I[0],y:I[1],zoom:I[2]}),k||$.setState({transform:I})},[M,k]);return L.useEffect(()=>{if(V.current){re.current=Y1({domNode:V.current,minZoom:m,maxZoom:y,translateExtent:v,viewport:x,onDraggingChange:U=>$.setState(C=>C.paneDragging===U?C:{paneDragging:U}),onPanZoomStart:(U,C)=>{const{onViewportChangeStart:D,onMoveStart:B}=$.getState();B==null||B(U,C),D==null||D(C)},onPanZoom:(U,C)=>{const{onViewportChange:D,onMove:B}=$.getState();B==null||B(U,C),D==null||D(C)},onPanZoomEnd:(U,C)=>{const{onViewportChangeEnd:D,onMoveEnd:B}=$.getState();B==null||B(U,C),D==null||D(C)}});const{x:I,y:W,zoom:H}=re.current.getViewport();return $.setState({panZoom:re.current,transform:[I,W,H],domNode:V.current.closest(".react-flow")}),()=>{var U;(U=re.current)==null||U.destroy()}}},[]),L.useEffect(()=>{var I;(I=re.current)==null||I.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:Z,preventScrolling:N,noPanClassName:w,userSelectionActive:X,noWheelClassName:E,lib:G,onTransformChange:te,connectionInProgress:J,selectionOnDrag:A,paneClickDistance:b})},[t,r,o,s,a,u,c,h,p,Z,N,w,X,E,G,te,J,A,b]),d.jsx("div",{className:"react-flow__renderer",ref:V,style:Kl,children:j})}const W_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function U_(){const{userSelectionActive:t,userSelectionRect:r}=ze(W_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const Vu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},Y_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function G_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=es.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:x,onPaneContextMenu:v,onPaneScroll:m,onPaneMouseEnter:y,onPaneMouseMove:_,onPaneMouseLeave:N,children:j}){const E=L.useRef(0),w=Ye(),{userSelectionActive:M,elementsSelectable:k,dragging:b,panBy:A,autoPanSpeed:$}=ze(Y_,Qe),V=k&&(t||M),X=L.useRef(null),G=L.useRef(),J=L.useRef(new Set),Z=L.useRef(new Set),re=L.useRef(!1),te=L.useRef(!1),I=L.useRef({x:0,y:0}),W=L.useRef(!1),H=Q=>{if(te.current||re.current||w.getState().connection.inProgress){te.current=!1,re.current=!1;return}x==null||x(Q),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},U=Q=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Q.preventDefault();return}v==null||v(Q)},C=m?Q=>m(Q):void 0,D=Q=>{te.current&&(Q.stopPropagation(),te.current=!1)},B=Q=>{var Le,Ze;if(Q.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:ae,transform:me}=w.getState();if(G.current=ae==null?void 0:ae.getBoundingClientRect(),!G.current)return;const ke=Q.target===X.current;if(!ke&&!!Q.target.closest(".nokey")||!t||!(c&&ke||r)||Q.button!==0||!Q.isPrimary)return;(Ze=(Le=Q.target)==null?void 0:Le.setPointerCapture)==null||Ze.call(Le,Q.pointerId),te.current=!1;const{x:Ne,y:Me}=xn(Q.nativeEvent,G.current),Re=ds({x:Ne,y:Me},me);w.setState({userSelectionRect:{width:0,height:0,startX:Re.x,startY:Re.y,x:Ne,y:Me}}),ke||(Q.stopPropagation(),Q.preventDefault())};function P(Q,ae){const{userSelectionRect:me}=w.getState();if(!me)return;const{transform:ke,nodeLookup:ve,edgeLookup:ne,connectionLookup:Ne,triggerNodeChanges:Me,triggerEdgeChanges:Re,defaultEdgeOptions:Le}=w.getState(),Ze={x:me.startX,y:me.startY},{x:pt,y:Xe}=Zi(Ze,ke),it={startX:Ze.x,startY:Ze.y,x:Qdt.id)),Z.current=new Set;const ot=(Le==null?void 0:Le.selectable)??!0;for(const dt of J.current){const gt=Ne.get(dt);if(gt)for(const{edgeId:mt}of gt.values()){const Pt=ne.get(mt);Pt&&(Pt.selectable??ot)&&Z.current.add(mt)}}if(!kh(on,J.current)){const dt=Ui(ve,J.current,!0);Me(dt)}if(!kh(Mt,Z.current)){const dt=Ui(ne,Z.current);Re(dt)}w.setState({userSelectionRect:it,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!a||!G.current)return;const[Q,ae]=wc(I.current,G.current,$);A({x:Q,y:ae}).then(me=>{if(!te.current||!me){E.current=requestAnimationFrame(z);return}const{x:ke,y:ve}=I.current;P(ke,ve),E.current=requestAnimationFrame(z)})}const ie=()=>{cancelAnimationFrame(E.current),E.current=0,W.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=Q=>{const{userSelectionRect:ae,transform:me,resetSelectedElements:ke}=w.getState();if(!G.current||!ae)return;const{x:ve,y:ne}=xn(Q.nativeEvent,G.current);I.current={x:ve,y:ne};const Ne=Zi({x:ae.startX,y:ae.startY},me);if(!te.current){const Me=r?0:u;if(Math.hypot(ve-Ne.x,ne-Ne.y)<=Me)return;ke(),h==null||h(Q)}te.current=!0,W.current||(z(),W.current=!0),P(ve,ne)},de=Q=>{var ae,me;if(!V){Q.target===X.current&&w.getState().connection.inProgress&&(re.current=!0);return}Q.button===0&&((me=(ae=Q.target)==null?void 0:ae.releasePointerCapture)==null||me.call(ae,Q.pointerId),!M&&Q.target===X.current&&w.getState().userSelectionRect&&(H==null||H(Q)),w.setState({userSelectionActive:!1,userSelectionRect:null}),te.current&&(p==null||p(Q),w.setState({nodesSelectionActive:J.current.size>0})),ie())},pe=Q=>{var ae,me;(me=(ae=Q.target)==null?void 0:ae.releasePointerCapture)==null||me.call(ae,Q.pointerId),ie()},he=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:rt(["react-flow__pane",{draggable:he,dragging:b,selection:t}]),onClick:V?void 0:Vu(H,X),onContextMenu:Vu(U,X),onWheel:Vu(C,X),onPointerEnter:V?void 0:y,onPointerMove:V?oe:_,onPointerUp:de,onPointerCancel:V?pe:void 0,onPointerDownCapture:V?B:void 0,onClickCapture:V?D:void 0,onPointerLeave:N,ref:X,style:Kl,children:[j,d.jsx(U_,{})]})}function ac({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),x=h.get(t);if(!x){p==null||p("012",wn.error012(t));return}r.setState({nodesSelectionActive:!1}),x.selected?(o||x.selected&&c)&&(u({nodes:[x],edges:[]}),requestAnimationFrame(()=>{var v;return(v=s==null?void 0:s.current)==null?void 0:v.blur()})):a([t])}function Og({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ye(),[p,x]=L.useState(!1),v=L.useRef();return L.useEffect(()=>{if(!r)return v.current=R1({getStoreItems:()=>h.getState(),onNodeMouseDown:m=>{ac({id:m,store:h,nodeRef:t})},onDragStart:()=>{x(!0)},onDragStop:()=>{x(!1)}}),()=>{var m;(m=v.current)==null||m.destroy(),v.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!v.current||v.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const X_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Fg(){const t=Ye();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:x,nodeOrigin:v}=t.getState(),m=new Map,y=X_(c),_=a?u[0]:5,N=a?u[1]:5,j=o.direction.x*_*o.factor,E=o.direction.y*N*o.factor;for(const[,w]of x){if(!y(w))continue;let M={x:w.internals.positionAbsolute.x+j,y:w.internals.positionAbsolute.y+E};a&&(M=cs(M,u));const{position:k,positionAbsolute:b}=og({nodeId:w.id,nextPosition:M,nodeLookup:x,nodeExtent:s,nodeOrigin:v,onError:h});w.position=k,w.internals.positionAbsolute=b,m.set(w.id,w)}p(m)},[])}const Cc=L.createContext(null),q_=Cc.Provider;Cc.Consumer;const Hg=()=>L.useContext(Cc),K_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Bg=L.createContext(null);function Q_({children:t}){const r=ze(K_,Qe);return d.jsx(Bg.Provider,{value:r,children:t})}function Z_(){const t=L.useContext(Bg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const J_={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},eS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:x}=c;if(!h&&!a)return J_;const v=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:v,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Ki.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:v&&x}};function tS({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:x,onMouseDown:v,onTouchStart:m,...y},_){var W,H;const N=c||null,j=t==="target",E=Ye(),w=Hg(),{connectOnClick:M,noPanClassName:k,rfId:b}=Z_(),{connectingFrom:A,connectingTo:$,clickConnecting:V,isPossibleEndHandle:X,connectionInProcess:G,clickConnectionInProcess:J,valid:Z}=ze(eS(w,N,t),Qe);w||(H=(W=E.getState()).onError)==null||H.call(W,"010",wn.error010());const re=U=>{const{defaultEdgeOptions:C,onConnect:D,hasDefaultEdges:B}=E.getState(),P={...C,...U};if(B){const{edges:z,setEdges:ie,onError:oe}=E.getState();ie(T_(P,z,{onError:oe}))}D==null||D(P),h==null||h(P)},te=U=>{if(!w)return;const C=pg(U.nativeEvent);if(a&&(C&&U.button===0||!C)){const D=E.getState();lc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:j,handleId:N,nodeId:w,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...B)=>{var P,z;return(z=(P=E.getState()).onConnectEnd)==null?void 0:z.call(P,...B)},updateConnection:D.updateConnection,onConnect:re,isValidConnection:o||((...B)=>{var P,z;return((z=(P=E.getState()).isValidConnection)==null?void 0:z.call(P,...B))??!0}),getTransform:()=>E.getState().transform,getFromHandle:()=>E.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}C?v==null||v(U):m==null||m(U)},I=U=>{const{onClickConnectStart:C,onClickConnectEnd:D,connectionClickStartHandle:B,connectionMode:P,isValidConnection:z,lib:ie,rfId:oe,nodeLookup:de,connection:pe}=E.getState();if(!w||!B&&!a)return;if(!B){C==null||C(U.nativeEvent,{nodeId:w,handleId:N,handleType:t}),E.setState({connectionClickStartHandle:{nodeId:w,type:t,id:N}});return}const he=fg(U.target),Q=o||z,{connection:ae,isValid:me}=lc.isValid(U.nativeEvent,{handle:{nodeId:w,id:N,type:t},connectionMode:P,fromNodeId:B.nodeId,fromHandleId:B.id||null,fromType:B.type,isValidConnection:Q,flowId:oe,doc:he,lib:ie,nodeLookup:de});me&&ae&&re(ae);const ke=structuredClone(pe);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,D==null||D(U,ke),E.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":N,"data-nodeid":w,"data-handlepos":r,"data-id":`${b}-${w}-${N}-${t}`,className:rt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",k,x,{source:!j,target:j,connectable:s,connectablestart:a,connectableend:u,clickconnecting:V,connectingfrom:A,connectingto:$,valid:Z,connectionindicator:s&&(!G||X)&&(G||J?u:a)}]),onMouseDown:te,onTouchStart:te,onClick:M?I:void 0,ref:_,...y,children:p})}const eo=L.memo($g(tS));function nS({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(eo,{type:"source",position:o,isConnectable:r})]})}function rS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:s=Se.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(eo,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(eo,{type:"source",position:s,isConnectable:r})]})}function iS(){return null}function oS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(eo,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const zl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},ep={input:nS,default:rS,output:oS,group:iS};function sS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const lS=t=>{const{width:r,height:o,x:s,y:a}=us(t.nodeLookup,{filter:u=>!!u.selected});return{width:vn(r)?r:null,height:vn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function aS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ye(),{width:a,height:u,transformString:c,userSelectionActive:h}=ze(lS,Qe),p=Fg(),x=L.useRef(null);L.useEffect(()=>{var _;o||(_=x.current)==null||_.focus({preventScroll:!0})},[o]);const v=!h&&a!==null&&u!==null;if(Og({nodeRef:x,disabled:!v}),!v)return null;const m=t?_=>{const N=s.getState().nodes.filter(j=>j.selected);t(_,N)}:void 0,y=_=>{Object.prototype.hasOwnProperty.call(zl,_.key)&&(_.preventDefault(),p({direction:zl[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:rt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:x,className:"react-flow__nodesselection-rect",onContextMenu:m,tabIndex:o?void 0:-1,onKeyDown:o?void 0:y,style:{width:a,height:u}})})}const tp=typeof window<"u"?window:void 0,uS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Vg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:x,selectionOnDrag:v,selectionMode:m,onSelectionStart:y,onSelectionEnd:_,multiSelectionKeyCode:N,panActivationKeyCode:j,zoomActivationKeyCode:E,elementsSelectable:w,zoomOnScroll:M,zoomOnPinch:k,panOnScroll:b,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:V,panOnDrag:X,autoPanOnSelection:G,defaultViewport:J,translateExtent:Z,minZoom:re,maxZoom:te,preventScrolling:I,onSelectionContextMenu:W,noWheelClassName:H,noPanClassName:U,disableKeyboardA11y:C,onViewportChange:D,isControlledViewport:B}){const{nodesSelectionActive:P,userSelectionActive:z}=ze(uS,Qe),ie=is(x,{target:tp}),oe=is(j,{target:tp}),de=oe||X,pe=oe||b,he=v&&de!==!0,Q=ie||z||he;return F_({deleteKeyCode:p,multiSelectionKeyCode:N}),d.jsx(V_,{onPaneContextMenu:u,elementsSelectable:w,zoomOnScroll:M,zoomOnPinch:k,panOnScroll:pe,panActivationKeyPressed:oe,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:V,panOnDrag:!ie&&de,defaultViewport:J,translateExtent:Z,minZoom:re,maxZoom:te,zoomActivationKeyCode:E,preventScrolling:I,noWheelClassName:H,noPanClassName:U,onViewportChange:D,isControlledViewport:B,paneClickDistance:h,selectionOnDrag:he,children:d.jsxs(G_,{onSelectionStart:y,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:de,autoPanOnSelection:G,isSelecting:!!Q,selectionMode:m,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:he,children:[t,P&&d.jsx(aS,{onSelectionContextMenu:W,noPanClassName:U,disableKeyboardA11y:C})]})})}Vg.displayName="FlowRenderer";const cS=L.memo(Vg),dS=t=>r=>t?xc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function fS(t){return ze(L.useCallback(dS(t),[t]),Qe)}const hS=t=>t.updateNodeInternals;function pS(){const t=ze(hS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function gS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ye(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),x=L.useRef(r),v=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!v||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[v,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const m=x.current!==r,y=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(m||y||_)&&(x.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function mS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:x,nodesFocusable:v,resizeObserver:m,noDragClassName:y,noPanClassName:_,disableKeyboardA11y:N,rfId:j,nodeTypes:E,nodeClickDistance:w,onError:M}){const{node:k,internals:b,isParent:A}=ze(Q=>{const ae=Q.nodeLookup.get(t),me=Q.parentLookup.has(t);return{node:ae,internals:ae.internals,isParent:me}},Qe);let $=k.type||"default",V=(E==null?void 0:E[$])||ep[$];V===void 0&&(M==null||M("003",wn.error003($)),$="default",V=(E==null?void 0:E.default)||ep.default);const X=!!(k.draggable||h&&typeof k.draggable>"u"),G=!!(k.selectable||p&&typeof k.selectable>"u"),J=!!(k.connectable||x&&typeof k.connectable>"u"),Z=!!(k.focusable||v&&typeof k.focusable>"u"),re=Ye(),te=cg(k),I=gS({node:k,nodeType:$,hasDimensions:te,resizeObserver:m}),W=Og({nodeRef:I,disabled:k.hidden||!X,noDragClassName:y,handleSelector:k.dragHandle,nodeId:t,isSelectable:G,nodeClickDistance:w}),H=Fg();if(k.hidden)return null;const U=Sn(k),C=sS(k),D=G||X||r||o||s||a,B=o?Q=>o(Q,{...b.userNode}):void 0,P=s?Q=>s(Q,{...b.userNode}):void 0,z=a?Q=>a(Q,{...b.userNode}):void 0,ie=u?Q=>u(Q,{...b.userNode}):void 0,oe=c?Q=>c(Q,{...b.userNode}):void 0,de=Q=>{const{selectNodesOnDrag:ae,nodeDragThreshold:me}=re.getState();G&&(!ae||!X||me>0)&&ac({id:t,store:re,nodeRef:I}),r&&r(Q,{...b.userNode})},pe=Q=>{if(!(hg(Q.nativeEvent)||N)){if(eg.includes(Q.key)&&G){const ae=Q.key==="Escape";ac({id:t,store:re,unselect:ae,nodeRef:I})}else if(X&&k.selected&&Object.prototype.hasOwnProperty.call(zl,Q.key)){Q.preventDefault();const{ariaLabelConfig:ae}=re.getState();re.setState({ariaLiveMessage:ae["node.a11yDescription.ariaLiveMessage"]({direction:Q.key.replace("Arrow","").toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),H({direction:zl[Q.key],factor:Q.shiftKey?4:1})}}},he=()=>{var Ne;if(N||!((Ne=I.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:Q,width:ae,height:me,autoPanOnNodeFocus:ke,setCenter:ve}=re.getState();if(!ke)return;xc(new Map([[t,k]]),{x:0,y:0,width:ae,height:me},Q,!0).length>0||ve(k.position.x+U.width/2,k.position.y+U.height/2,{zoom:Q[2]})};return d.jsx("div",{className:rt(["react-flow__node",`react-flow__node-${$}`,{[_]:X},k.className,{selected:k.selected,selectable:G,parent:A,draggable:X,dragging:W}]),ref:I,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:te?"visible":"hidden",...k.style,...C},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:B,onMouseMove:P,onMouseLeave:z,onContextMenu:ie,onClick:de,onDoubleClick:oe,onKeyDown:Z?pe:void 0,tabIndex:Z?0:void 0,onFocus:Z?he:void 0,role:k.ariaRole??(Z?"group":void 0),"aria-roledescription":"node","aria-describedby":N?void 0:`${Rg}-${j}`,"aria-label":k.ariaLabel,...k.domAttributes,children:d.jsx(q_,{value:t,children:d.jsx(V,{id:t,data:k.data,type:$,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:k.selected??!1,selectable:G,draggable:X,deletable:k.deletable??!0,isConnectable:J,sourcePosition:k.sourcePosition,targetPosition:k.targetPosition,dragging:W,dragHandle:k.dragHandle,zIndex:b.z,parentId:k.parentId,...U})})})}var yS=L.memo(mS);const vS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Wg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=ze(vS,Qe),u=fS(t.onlyRenderVisibleElements),c=pS();return d.jsx("div",{className:"react-flow__nodes",style:Kl,children:u.map(h=>d.jsx(yS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Wg.displayName="NodeRenderer";const xS=L.memo(Wg);function wS(t){return ze(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&h1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const _S=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},SS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},np={[ts.Arrow]:_S,[ts.ArrowClosed]:SS};function kS(t){const r=Ye();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(np,t)?np[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",wn.error009(t)),null)},[t])}const NS=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=kS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},Ug=({defaultColor:t,rfId:r})=>{const o=ze(u=>u.edges),s=ze(u=>u.defaultEdgeOptions),a=L.useMemo(()=>_1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(NS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Ug.displayName="MarkerDefinitions";var jS=L.memo(Ug);function Yg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:x,...v}){const[m,y]=L.useState({x:1,y:0,width:0,height:0}),_=rt(["react-flow__edge-textwrapper",x]),N=L.useRef(null);return L.useEffect(()=>{if(N.current){const j=N.current.getBBox();y({x:j.x,y:j.y,width:j.width,height:j.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-m.width/2} ${r-m.height/2})`,className:_,visibility:m.width?"visible":"hidden",...v,children:[a&&d.jsx("rect",{width:m.width+2*c[0],x:-c[0],y:-c[1],height:m.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:m.height/2,dy:"0.3em",ref:N,style:s,children:o}),p]}):null}Yg.displayName="EdgeText";const bS=L.memo(Yg);function Ql({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:x=20,...v}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...v,d:t,fill:"none",className:rt(["react-flow__edge-path",v.className])}),x?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:x,className:"react-flow__edge-interaction"}):null,s&&vn(r)&&vn(o)?d.jsx(bS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function rp({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function Gg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top}){const[c,h]=rp({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,x]=rp({pos:u,x1:s,y1:a,x2:t,y2:r}),[v,m,y,_]=gg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:x});return[`M${t},${r} C${c},${h} ${p},${x} ${s},${a}`,v,m,y,_]}function Xg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:x,labelShowBg:v,labelBgStyle:m,labelBgPadding:y,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,interactionWidth:w})=>{const[M,k,b]=Gg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),A=t.isInternal?void 0:r;return d.jsx(Ql,{id:A,path:M,labelX:k,labelY:b,label:p,labelStyle:x,labelShowBg:v,labelBgStyle:m,labelBgPadding:y,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,interactionWidth:w})})}const ES=Xg({isInternal:!1}),qg=Xg({isInternal:!0});ES.displayName="SimpleBezierEdge";qg.displayName="SimpleBezierEdgeInternal";function Kg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:m,style:y,sourcePosition:_=Se.Bottom,targetPosition:N=Se.Top,markerEnd:j,markerStart:E,pathOptions:w,interactionWidth:M})=>{const[k,b,A]=ic({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:N,borderRadius:w==null?void 0:w.borderRadius,offset:w==null?void 0:w.offset,stepPosition:w==null?void 0:w.stepPosition}),$=t.isInternal?void 0:r;return d.jsx(Ql,{id:$,path:k,labelX:b,labelY:A,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:m,style:y,markerEnd:j,markerStart:E,interactionWidth:M})})}const Qg=Kg({isInternal:!1}),Zg=Kg({isInternal:!0});Qg.displayName="SmoothStepEdge";Zg.displayName="SmoothStepEdgeInternal";function Jg(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(Qg,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const CS=Jg({isInternal:!1}),em=Jg({isInternal:!0});CS.displayName="StepEdge";em.displayName="StepEdgeInternal";function tm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:m,style:y,markerEnd:_,markerStart:N,interactionWidth:j})=>{const[E,w,M]=vg({sourceX:o,sourceY:s,targetX:a,targetY:u}),k=t.isInternal?void 0:r;return d.jsx(Ql,{id:k,path:E,labelX:w,labelY:M,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:m,style:y,markerEnd:_,markerStart:N,interactionWidth:j})})}const MS=tm({isInternal:!1}),nm=tm({isInternal:!0});MS.displayName="StraightEdge";nm.displayName="StraightEdgeInternal";function rm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:x,labelShowBg:v,labelBgStyle:m,labelBgPadding:y,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,pathOptions:w,interactionWidth:M})=>{const[k,b,A]=mg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:w==null?void 0:w.curvature}),$=t.isInternal?void 0:r;return d.jsx(Ql,{id:$,path:k,labelX:b,labelY:A,label:p,labelStyle:x,labelShowBg:v,labelBgStyle:m,labelBgPadding:y,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,interactionWidth:M})})}const PS=rm({isInternal:!1}),im=rm({isInternal:!0});PS.displayName="BezierEdge";im.displayName="BezierEdgeInternal";const ip={default:im,straight:nm,step:em,smoothstep:Zg,simplebezier:qg},op={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},IS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,RS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,sp="react-flow__edgeupdater";function lp({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:rt([sp,`${sp}-${h}`]),cx:IS(r,s,t),cy:RS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function TS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:x,onReconnectStart:v,onReconnectEnd:m,setReconnecting:y,setUpdateHover:_}){const N=Ye(),j=(b,A)=>{if(b.button!==0)return;const{autoPanOnConnect:$,domNode:V,connectionMode:X,connectionRadius:G,lib:J,onConnectStart:Z,cancelConnection:re,nodeLookup:te,rfId:I,panBy:W,updateConnection:H}=N.getState(),U=A.type==="target",C=(P,z)=>{y(!1),m==null||m(P,o,A.type,z)},D=P=>x==null?void 0:x(o,P),B=(P,z)=>{y(!0),v==null||v(b,o,A.type),Z==null||Z(P,z)};lc.onPointerDown(b.nativeEvent,{autoPanOnConnect:$,connectionMode:X,connectionRadius:G,domNode:V,handleId:A.id,nodeId:A.nodeId,nodeLookup:te,isTarget:U,edgeUpdaterType:A.type,lib:J,flowId:I,cancelConnection:re,panBy:W,isValidConnection:(...P)=>{var z,ie;return((ie=(z=N.getState()).isValidConnection)==null?void 0:ie.call(z,...P))??!0},onConnect:D,onConnectStart:B,onConnectEnd:(...P)=>{var z,ie;return(ie=(z=N.getState()).onConnectEnd)==null?void 0:ie.call(z,...P)},onReconnectEnd:C,updateConnection:H,getTransform:()=>N.getState().transform,getFromHandle:()=>N.getState().connection.fromHandle,dragThreshold:N.getState().connectionDragThreshold,handleDomNode:b.currentTarget})},E=b=>j(b,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),w=b=>j(b,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),M=()=>_(!0),k=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(lp,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:E,onMouseEnter:M,onMouseOut:k,type:"source"}),(t===!0||t==="target")&&d.jsx(lp,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:w,onMouseEnter:M,onMouseOut:k,type:"target"})]})}function LS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:x,reconnectRadius:v,onReconnect:m,onReconnectStart:y,onReconnectEnd:_,rfId:N,edgeTypes:j,noPanClassName:E,onError:w,disableKeyboardA11y:M}){let k=ze(ve=>ve.edgeLookup.get(t));const b=ze(ve=>ve.defaultEdgeOptions);k=b?{...b,...k}:k;let A=k.type||"default",$=(j==null?void 0:j[A])||ip[A];$===void 0&&(w==null||w("011",wn.error011(A)),A="default",$=(j==null?void 0:j.default)||ip.default);const V=!!(k.focusable||r&&typeof k.focusable>"u"),X=typeof m<"u"&&(k.reconnectable||o&&typeof k.reconnectable>"u"),G=!!(k.selectable||s&&typeof k.selectable>"u"),J=L.useRef(null),[Z,re]=L.useState(!1),[te,I]=L.useState(!1),W=Ye(),{zIndex:H=k.zIndex,sourceX:U,sourceY:C,targetX:D,targetY:B,sourcePosition:P,targetPosition:z}=ze(L.useCallback(ve=>{const ne=ve.nodeLookup.get(k.source),Ne=ve.nodeLookup.get(k.target);if(!ne||!Ne)return op;const Me=w1({id:t,sourceNode:ne,targetNode:Ne,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:ve.connectionMode,onError:w}),Re=f1({selected:k.selected,zIndex:k.zIndex,sourceNode:ne,targetNode:Ne,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||op,zIndex:Re}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex,w]),Qe),ie=L.useMemo(()=>k.markerStart?`url('#${oc(k.markerStart,N)}')`:void 0,[k.markerStart,N]),oe=L.useMemo(()=>k.markerEnd?`url('#${oc(k.markerEnd,N)}')`:void 0,[k.markerEnd,N]);if(k.hidden||U===null||C===null||D===null||B===null)return null;const de=ve=>{var Re;const{addSelectedEdges:ne,unselectNodesAndEdges:Ne,multiSelectionActive:Me}=W.getState();G&&(W.setState({nodesSelectionActive:!1}),k.selected&&Me?(Ne({nodes:[],edges:[k]}),(Re=J.current)==null||Re.blur()):ne([t])),a&&a(ve,k)},pe=u?ve=>{u(ve,{...k})}:void 0,he=c?ve=>{c(ve,{...k})}:void 0,Q=h?ve=>{h(ve,{...k})}:void 0,ae=p?ve=>{p(ve,{...k})}:void 0,me=x?ve=>{x(ve,{...k})}:void 0,ke=ve=>{var ne;if(!M&&eg.includes(ve.key)&&G){const{unselectNodesAndEdges:Ne,addSelectedEdges:Me}=W.getState();ve.key==="Escape"?((ne=J.current)==null||ne.blur(),Ne({edges:[k]})):Me([t])}};return d.jsx("svg",{style:{zIndex:H},children:d.jsxs("g",{className:rt(["react-flow__edge",`react-flow__edge-${A}`,k.className,E,{selected:k.selected,animated:k.animated,inactive:!G&&!a,updating:Z,selectable:G}]),onClick:de,onDoubleClick:pe,onContextMenu:he,onMouseEnter:Q,onMouseMove:ae,onMouseLeave:me,onKeyDown:V?ke:void 0,tabIndex:V?0:void 0,role:k.ariaRole??(V?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":k.ariaLabel===null?void 0:k.ariaLabel||`Edge from ${k.source} to ${k.target}`,"aria-describedby":V?`${Tg}-${N}`:void 0,ref:J,...k.domAttributes,children:[!te&&d.jsx($,{id:t,source:k.source,target:k.target,type:k.type,selected:k.selected,animated:k.animated,selectable:G,deletable:k.deletable??!0,label:k.label,labelStyle:k.labelStyle,labelShowBg:k.labelShowBg,labelBgStyle:k.labelBgStyle,labelBgPadding:k.labelBgPadding,labelBgBorderRadius:k.labelBgBorderRadius,sourceX:U,sourceY:C,targetX:D,targetY:B,sourcePosition:P,targetPosition:z,data:k.data,style:k.style,sourceHandleId:k.sourceHandle,targetHandleId:k.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in k?k.pathOptions:void 0,interactionWidth:k.interactionWidth}),X&&d.jsx(TS,{edge:k,isReconnectable:X,reconnectRadius:v,onReconnect:m,onReconnectStart:y,onReconnectEnd:_,sourceX:U,sourceY:C,targetX:D,targetY:B,sourcePosition:P,targetPosition:z,setUpdateHover:re,setReconnecting:I})]})})}var AS=L.memo(LS);const $S=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function om({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:x,onEdgeClick:v,reconnectRadius:m,onEdgeDoubleClick:y,onReconnectStart:_,onReconnectEnd:N,disableKeyboardA11y:j}){const{edgesFocusable:E,edgesReconnectable:w,elementsSelectable:M,onError:k}=ze($S,Qe),b=wS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(jS,{defaultColor:t,rfId:o}),b.map(A=>d.jsx(AS,{id:A,edgesFocusable:E,edgesReconnectable:w,elementsSelectable:M,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:x,onClick:v,reconnectRadius:m,onDoubleClick:y,onReconnectStart:_,onReconnectEnd:N,rfId:o,onError:k,edgeTypes:s,disableKeyboardA11y:j},A))]})}om.displayName="EdgeRenderer";const zS=L.memo(om),ap=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function DS({children:t}){const r=Ye(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return zg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=ap(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:ap(s)},children:t})}function OS(t){const r=ql(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const FS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function HS(t){const r=ze(FS),o=Ye();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function BS(t){return t.connection.inProgress?{...t.connection,to:ds(t.connection.to,t.transform)}:{...t.connection}}function VS(t){return BS}function WS(t){const r=VS();return ze(r,Qe)}const US=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function YS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=ze(US,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:rt(["react-flow__connection",rg(h)]),children:d.jsx(sm,{style:r,type:o,CustomComponent:s,isValid:h})})})}const sm=({style:t,type:r=Pr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:x,toNode:v,toHandle:m,toPosition:y,pointer:_}=WS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:x.x,toY:x.y,fromPosition:p,toPosition:y,connectionStatus:rg(s),toNode:v,toHandle:m,pointer:_});let N="";const j={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:x.x,targetY:x.y,targetPosition:y};switch(r){case Pr.Bezier:[N]=mg(j);break;case Pr.SimpleBezier:[N]=Gg(j);break;case Pr.Step:[N]=ic({...j,borderRadius:0});break;case Pr.SmoothStep:[N]=ic(j);break;default:[N]=vg(j)}return d.jsx("path",{d:N,fill:"none",className:"react-flow__connection-path",style:t})};sm.displayName="ConnectionLine";const GS={};function up(t=GS){L.useRef(t),Ye(),L.useEffect(()=>{},[t])}function XS(){Ye(),L.useRef(!1),L.useEffect(()=>{},[])}function lm({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:v,onSelectionContextMenu:m,onSelectionStart:y,onSelectionEnd:_,connectionLineType:N,connectionLineStyle:j,connectionLineComponent:E,connectionLineContainerStyle:w,selectionKeyCode:M,selectionOnDrag:k,selectionMode:b,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:V,deleteKeyCode:X,onlyRenderVisibleElements:G,elementsSelectable:J,defaultViewport:Z,translateExtent:re,minZoom:te,maxZoom:I,preventScrolling:W,defaultMarkerColor:H,zoomOnScroll:U,zoomOnPinch:C,panOnScroll:D,panOnScrollSpeed:B,panOnScrollMode:P,zoomOnDoubleClick:z,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:de,onPaneMouseEnter:pe,onPaneMouseMove:he,onPaneMouseLeave:Q,onPaneScroll:ae,onPaneContextMenu:me,paneClickDistance:ke,nodeClickDistance:ve,onEdgeContextMenu:ne,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Re,reconnectRadius:Le,onReconnect:Ze,onReconnectStart:pt,onReconnectEnd:Xe,noDragClassName:it,noWheelClassName:on,noPanClassName:Mt,disableKeyboardA11y:ot,nodeExtent:dt,rfId:gt,viewport:mt,onViewportChange:Pt,nodesDraggable:kn}){return up(t),up(r),XS(),OS(o),HS(mt),d.jsx(cS,{onPaneClick:de,onPaneMouseEnter:pe,onPaneMouseMove:he,onPaneMouseLeave:Q,onPaneContextMenu:me,onPaneScroll:ae,paneClickDistance:ke,deleteKeyCode:X,selectionKeyCode:M,selectionOnDrag:k,selectionMode:b,onSelectionStart:y,onSelectionEnd:_,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:V,elementsSelectable:J,zoomOnScroll:U,zoomOnPinch:C,zoomOnDoubleClick:z,panOnScroll:D,panOnScrollSpeed:B,panOnScrollMode:P,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:Z,translateExtent:re,minZoom:te,maxZoom:I,onSelectionContextMenu:m,preventScrolling:W,noDragClassName:it,noWheelClassName:on,noPanClassName:Mt,disableKeyboardA11y:ot,onViewportChange:Pt,isControlledViewport:!!mt,children:d.jsxs(DS,{children:[d.jsx(zS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:Ze,onReconnectStart:pt,onReconnectEnd:Xe,onlyRenderVisibleElements:G,onEdgeContextMenu:ne,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Re,reconnectRadius:Le,defaultMarkerColor:H,noPanClassName:Mt,disableKeyboardA11y:ot,rfId:gt}),d.jsx(YS,{style:j,type:N,component:E,containerStyle:w}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(xS,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:v,nodeClickDistance:ve,onlyRenderVisibleElements:G,noPanClassName:Mt,noDragClassName:it,disableKeyboardA11y:ot,nodeExtent:dt,rfId:gt,nodesDraggable:kn}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}lm.displayName="GraphView";const qS=L.memo(lm),KS=ug(),cp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:x=2,nodeOrigin:v,nodeExtent:m,zIndexMode:y="basic"}={})=>{const _=new Map,N=new Map,j=new Map,E=new Map,w=s??r??[],M=o??t??[],k=v??[0,0],b=m??Jo;_g(j,E,w);const{nodesInitialized:A}=sc(M,_,N,{nodeOrigin:k,nodeExtent:b,zIndexMode:y});let $=[0,0,1];if(c&&a&&u){const V=us(_,{filter:Z=>!!((Z.width||Z.initialWidth)&&(Z.height||Z.initialHeight))}),{x:X,y:G,zoom:J}=_c(V,a,u,p,x,(h==null?void 0:h.padding)??.1);$=[X,G,J]}return{rfId:"1",width:a??0,height:u??0,transform:$,nodes:M,nodesInitialized:A,nodeLookup:_,parentLookup:N,edges:w,edgeLookup:E,connectionLookup:j,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:x,translateExtent:Jo,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ki.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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...ng},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:KS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:tg,zIndexMode:y,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},QS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:x,nodeOrigin:v,nodeExtent:m,zIndexMode:y})=>u_((_,N)=>{async function j(){const{nodeLookup:E,panZoom:w,fitViewOptions:M,fitViewResolver:k,width:b,height:A,minZoom:$,maxZoom:V}=N();w&&(await o1({nodes:E,width:b,height:A,panZoom:w,minZoom:$,maxZoom:V},M),k==null||k.resolve(!0),_({fitViewResolver:null}))}return{...cp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:x,nodeOrigin:v,nodeExtent:m,defaultNodes:o,defaultEdges:s,zIndexMode:y}),setNodes:E=>{const{nodeLookup:w,parentLookup:M,nodeOrigin:k,nodeExtent:b,elevateNodesOnSelect:A,fitViewQueued:$,zIndexMode:V,nodesSelectionActive:X}=N(),{nodesInitialized:G,hasSelectedNodes:J}=sc(E,w,M,{nodeOrigin:k,nodeExtent:b,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:V}),Z=X&&J;$&&G?(j(),_({nodes:E,nodesInitialized:G,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:Z})):_({nodes:E,nodesInitialized:G,nodesSelectionActive:Z})},setEdges:E=>{const{connectionLookup:w,edgeLookup:M}=N();_g(w,M,E),_({edges:E})},setDefaultNodesAndEdges:(E,w)=>{if(E){const{setNodes:M}=N();M(E),_({hasDefaultNodes:!0})}if(w){const{setEdges:M}=N();M(w),_({hasDefaultEdges:!0})}},updateNodeInternals:E=>{const{triggerNodeChanges:w,nodeLookup:M,parentLookup:k,domNode:b,nodeOrigin:A,nodeExtent:$,debug:V,fitViewQueued:X,zIndexMode:G}=N(),{changes:J,updatedInternals:Z}=C1(E,M,k,b,A,$,G);Z&&(N1(M,k,{nodeOrigin:A,nodeExtent:$,zIndexMode:G}),X?(j(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(J==null?void 0:J.length)>0&&(V&&console.log("React Flow: trigger node changes",J),w==null||w(J)))},updateNodePositions:(E,w=!1)=>{const M=[];let k=[];const{nodeLookup:b,triggerNodeChanges:A,connection:$,updateConnection:V,onNodesChangeMiddlewareMap:X}=N();for(const[G,J]of E){const Z=b.get(G),re=!!(Z!=null&&Z.expandParent&&(Z!=null&&Z.parentId)&&(J!=null&&J.position)),te={id:G,type:"position",position:re?{x:Math.max(0,J.position.x),y:Math.max(0,J.position.y)}:J.position,dragging:w};if(Z&&$.inProgress&&$.fromNode.id===Z.id){const I=li(Z,$.fromHandle,Se.Left,!0);V({...$,from:I})}re&&Z.parentId&&M.push({id:G,parentId:Z.parentId,rect:{...J.internals.positionAbsolute,width:J.measured.width??0,height:J.measured.height??0}}),k.push(te)}if(M.length>0){const{parentLookup:G,nodeOrigin:J}=N(),Z=Ec(M,b,G,J);k.push(...Z)}for(const G of X.values())k=G(k);A(k)},triggerNodeChanges:E=>{const{onNodesChange:w,setNodes:M,nodes:k,hasDefaultNodes:b,debug:A}=N();if(E!=null&&E.length){if(b){const $=P_(E,k);M($)}A&&console.log("React Flow: trigger node changes",E),w==null||w(E)}},triggerEdgeChanges:E=>{const{onEdgesChange:w,setEdges:M,edges:k,hasDefaultEdges:b,debug:A}=N();if(E!=null&&E.length){if(b){const $=I_(E,k);M($)}A&&console.log("React Flow: trigger edge changes",E),w==null||w(E)}},addSelectedNodes:E=>{const{multiSelectionActive:w,edgeLookup:M,nodeLookup:k,triggerNodeChanges:b,triggerEdgeChanges:A}=N();if(w){const $=E.map(V=>Jr(V,!0));b($);return}b(Ui(k,new Set([...E]),!0)),A(Ui(M))},addSelectedEdges:E=>{const{multiSelectionActive:w,edgeLookup:M,nodeLookup:k,triggerNodeChanges:b,triggerEdgeChanges:A}=N();if(w){const $=E.map(V=>Jr(V,!0));A($);return}A(Ui(M,new Set([...E]))),b(Ui(k,new Set,!0))},unselectNodesAndEdges:({nodes:E,edges:w}={})=>{const{edges:M,nodes:k,nodeLookup:b,triggerNodeChanges:A,triggerEdgeChanges:$}=N(),V=E||k,X=w||M,G=[];for(const Z of V){if(!Z.selected)continue;const re=b.get(Z.id);re&&(re.selected=!1),G.push(Jr(Z.id,!1))}const J=[];for(const Z of X)Z.selected&&J.push(Jr(Z.id,!1));A(G),$(J)},setMinZoom:E=>{const{panZoom:w,maxZoom:M}=N();w==null||w.setScaleExtent([E,M]),_({minZoom:E})},setMaxZoom:E=>{const{panZoom:w,minZoom:M}=N();w==null||w.setScaleExtent([M,E]),_({maxZoom:E})},setTranslateExtent:E=>{var w;(w=N().panZoom)==null||w.setTranslateExtent(E),_({translateExtent:E})},resetSelectedElements:()=>{const{edges:E,nodes:w,triggerNodeChanges:M,triggerEdgeChanges:k,elementsSelectable:b}=N();if(!b)return;const A=w.reduce((V,X)=>X.selected?[...V,Jr(X.id,!1)]:V,[]),$=E.reduce((V,X)=>X.selected?[...V,Jr(X.id,!1)]:V,[]);M(A),k($)},setNodeExtent:E=>{const{nodes:w,nodeLookup:M,parentLookup:k,nodeOrigin:b,elevateNodesOnSelect:A,nodeExtent:$,zIndexMode:V}=N();E[0][0]===$[0][0]&&E[0][1]===$[0][1]&&E[1][0]===$[1][0]&&E[1][1]===$[1][1]||(sc(w,M,k,{nodeOrigin:b,nodeExtent:E,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:V}),_({nodeExtent:E}))},panBy:E=>{const{transform:w,width:M,height:k,panZoom:b,translateExtent:A}=N();return M1({delta:E,panZoom:b,transform:w,translateExtent:A,width:M,height:k})},setCenter:async(E,w,M)=>{const{width:k,height:b,maxZoom:A,panZoom:$}=N();if(!$)return!1;const V=typeof(M==null?void 0:M.zoom)<"u"?M.zoom:A;return await $.setViewport({x:k/2-E*V,y:b/2-w*V,zoom:V},{duration:M==null?void 0:M.duration,ease:M==null?void 0:M.ease,interpolate:M==null?void 0:M.interpolate}),!0},cancelConnection:()=>{_({connection:{...ng}})},updateConnection:E=>{_({connection:E})},reset:()=>_({...cp()})}},Object.is);function am({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:x,nodeOrigin:v,nodeExtent:m,zIndexMode:y,children:_}){const[N]=L.useState(()=>QS({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:x,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:v,nodeExtent:m,zIndexMode:y}));return d.jsx(c_,{value:N,children:d.jsx($_,{children:d.jsx(Q_,{children:_})})})}function ZS({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:x,maxZoom:v,nodeOrigin:m,nodeExtent:y,zIndexMode:_}){return L.useContext(Gl)?d.jsx(d.Fragment,{children:t}):d.jsx(am,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:x,initialMaxZoom:v,nodeOrigin:m,nodeExtent:y,zIndexMode:_,children:t})}const JS={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function ek({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:x,onMove:v,onMoveStart:m,onMoveEnd:y,onConnect:_,onConnectStart:N,onConnectEnd:j,onClickConnectStart:E,onClickConnectEnd:w,onNodeMouseEnter:M,onNodeMouseMove:k,onNodeMouseLeave:b,onNodeContextMenu:A,onNodeDoubleClick:$,onNodeDragStart:V,onNodeDrag:X,onNodeDragStop:G,onNodesDelete:J,onEdgesDelete:Z,onDelete:re,onSelectionChange:te,onSelectionDragStart:I,onSelectionDrag:W,onSelectionDragStop:H,onSelectionContextMenu:U,onSelectionStart:C,onSelectionEnd:D,onBeforeDelete:B,connectionMode:P,connectionLineType:z=Pr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:de,deleteKeyCode:pe="Backspace",selectionKeyCode:he="Shift",selectionOnDrag:Q=!1,selectionMode:ae=es.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:ke=rs()?"Meta":"Control",zoomActivationKeyCode:ve=rs()?"Meta":"Control",snapToGrid:ne,snapGrid:Ne,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Re,nodesDraggable:Le,autoPanOnNodeFocus:Ze,nodesConnectable:pt,nodesFocusable:Xe,nodeOrigin:it=Lg,edgesFocusable:on,edgesReconnectable:Mt,elementsSelectable:ot=!0,defaultViewport:dt=k_,minZoom:gt=.5,maxZoom:mt=2,translateExtent:Pt=Jo,preventScrolling:kn=!0,nodeExtent:sn,defaultMarkerColor:qt="#b1b1b7",zoomOnScroll:no=!0,zoomOnPinch:rr=!0,panOnScroll:ui=!1,panOnScrollSpeed:ci=.5,panOnScrollMode:ir=ni.Free,zoomOnDoubleClick:Nn=!0,panOnDrag:Nt=!0,onPaneClick:jn,onPaneMouseEnter:bn,onPaneMouseMove:It,onPaneMouseLeave:Ft,onPaneScroll:En,onPaneContextMenu:yt,paneClickDistance:Rr=1,nodeClickDistance:Ht=0,children:Tr,onReconnect:tt,onReconnectStart:He,onReconnectEnd:ln,onEdgeContextMenu:Hn,onEdgeDoubleClick:jt,onEdgeMouseEnter:Lr,onEdgeMouseMove:bt,onEdgeMouseLeave:Cn,reconnectRadius:Kt=10,onNodesChange:Bn,onEdgesChange:di,noDragClassName:ro="nodrag",noWheelClassName:Bt="nowheel",noPanClassName:Rt="nopan",fitView:or,fitViewOptions:an,connectOnClick:Ar,attributionPosition:fi,proOptions:hi,defaultEdgeOptions:pi,elevateNodesOnSelect:gi=!0,elevateEdgesOnSelect:io=!1,disableKeyboardA11y:mi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:$r,autoPanOnSelection:zr=!0,autoPanSpeed:sr,connectionRadius:lr,isValidConnection:oo,onError:ar,style:Mn,id:vt,nodeDragThreshold:yi,connectionDragThreshold:xt,viewport:Dr,onViewportChange:vi,width:xi,height:Vn,colorMode:Pn="light",debug:Wn,onScroll:Qt,ariaLabelConfig:so,zIndexMode:wi="basic",...Or},Fr){const In=vt||"1",Rn=E_(Pn),_i=L.useCallback(Un=>{Un.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Qt==null||Qt(Un)},[Qt]);return d.jsx("div",{"data-testid":"rf__wrapper",...Or,onScroll:_i,style:{...Mn,...JS},ref:Fr,className:rt(["react-flow",a,Rn]),id:vt,role:"application",children:d.jsxs(ZS,{nodes:t,edges:r,width:xi,height:Vn,fitView:or,fitViewOptions:an,minZoom:gt,maxZoom:mt,nodeOrigin:it,nodeExtent:sn,zIndexMode:wi,children:[d.jsx(b_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:N,onConnectEnd:j,onClickConnectStart:E,onClickConnectEnd:w,nodesDraggable:Le,autoPanOnNodeFocus:Ze,nodesConnectable:pt,nodesFocusable:Xe,edgesFocusable:on,edgesReconnectable:Mt,elementsSelectable:ot,elevateNodesOnSelect:gi,elevateEdgesOnSelect:io,minZoom:gt,maxZoom:mt,nodeExtent:sn,onNodesChange:Bn,onEdgesChange:di,snapToGrid:ne,snapGrid:Ne,connectionMode:P,translateExtent:Pt,connectOnClick:Ar,defaultEdgeOptions:pi,fitView:or,fitViewOptions:an,onNodesDelete:J,onEdgesDelete:Z,onDelete:re,onNodeDragStart:V,onNodeDrag:X,onNodeDragStop:G,onSelectionDrag:W,onSelectionDragStart:I,onSelectionDragStop:H,onMove:v,onMoveStart:m,onMoveEnd:y,noPanClassName:Rt,nodeOrigin:it,rfId:In,autoPanOnConnect:Ve,autoPanOnNodeDrag:$r,autoPanSpeed:sr,onError:ar,connectionRadius:lr,isValidConnection:oo,selectNodesOnDrag:Re,nodeDragThreshold:yi,connectionDragThreshold:xt,onBeforeDelete:B,debug:Wn,ariaLabelConfig:so,zIndexMode:wi}),d.jsx(qS,{onInit:x,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:M,onNodeMouseMove:k,onNodeMouseLeave:b,onNodeContextMenu:A,onNodeDoubleClick:$,nodeTypes:u,edgeTypes:c,connectionLineType:z,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:de,selectionKeyCode:he,selectionOnDrag:Q,selectionMode:ae,deleteKeyCode:pe,multiSelectionKeyCode:ke,panActivationKeyCode:me,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:dt,translateExtent:Pt,minZoom:gt,maxZoom:mt,preventScrolling:kn,zoomOnScroll:no,zoomOnPinch:rr,zoomOnDoubleClick:Nn,panOnScroll:ui,panOnScrollSpeed:ci,panOnScrollMode:ir,panOnDrag:Nt,autoPanOnSelection:zr,onPaneClick:jn,onPaneMouseEnter:bn,onPaneMouseMove:It,onPaneMouseLeave:Ft,onPaneScroll:En,onPaneContextMenu:yt,paneClickDistance:Rr,nodeClickDistance:Ht,onSelectionContextMenu:U,onSelectionStart:C,onSelectionEnd:D,onReconnect:tt,onReconnectStart:He,onReconnectEnd:ln,onEdgeContextMenu:Hn,onEdgeDoubleClick:jt,onEdgeMouseEnter:Lr,onEdgeMouseMove:bt,onEdgeMouseLeave:Cn,reconnectRadius:Kt,defaultMarkerColor:qt,noDragClassName:ro,noWheelClassName:Bt,noPanClassName:Rt,rfId:In,disableKeyboardA11y:mi,nodeExtent:sn,viewport:Dr,onViewportChange:vi,nodesDraggable:Le}),d.jsx(S_,{onSelectionChange:te}),Tr,d.jsx(y_,{proOptions:hi,position:fi}),d.jsx(m_,{rfId:In,disableKeyboardA11y:mi})]})})}var tk=$g(ek);function nk({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:rt(["react-flow__background-pattern",o,s])})}function rk({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:rt(["react-flow__background-pattern","dots",r])})}var Ir;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Ir||(Ir={}));const ik={[Ir.Dots]:1,[Ir.Lines]:1,[Ir.Cross]:6},ok=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function um({id:t,variant:r=Ir.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:x,patternClassName:v}){const m=L.useRef(null),{transform:y,patternId:_}=ze(ok,Qe),N=s||ik[r],j=r===Ir.Dots,E=r===Ir.Cross,w=Array.isArray(o)?o:[o,o],M=[w[0]*y[2]||1,w[1]*y[2]||1],k=N*y[2],b=Array.isArray(u)?u:[u,u],A=E?[k,k]:M,$=[b[0]*y[2]+A[0]/2,b[1]*y[2]+A[1]/2],V=`${_}${t||""}`;return d.jsxs("svg",{className:rt(["react-flow__background",x]),style:{...p,...Kl,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:m,"data-testid":"rf__background",children:[d.jsx("pattern",{id:V,x:y[0]%M[0],y:y[1]%M[1],width:M[0],height:M[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:j?d.jsx(rk,{radius:k/2,className:v}):d.jsx(nk,{dimensions:A,lineWidth:a,variant:r,className:v})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${V})`})]})}um.displayName="Background";const sk=L.memo(um);function lk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ak(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function uk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 ck(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 wl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:rt(["react-flow__controls-button",r]),...o,children:t})}const fk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function cm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:x,children:v,position:m="bottom-left",orientation:y="vertical","aria-label":_}){const N=Ye(),{isInteractive:j,minZoomReached:E,maxZoomReached:w,ariaLabelConfig:M}=ze(fk,Qe),{zoomIn:k,zoomOut:b,fitView:A}=ql(),$=()=>{k(),u==null||u()},V=()=>{b(),c==null||c()},X=()=>{A(a),h==null||h()},G=()=>{N.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),p==null||p(!j)},J=y==="horizontal"?"horizontal":"vertical";return d.jsxs(Xl,{className:rt(["react-flow__controls",J,x]),position:m,style:t,"data-testid":"rf__controls","aria-label":_??M["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(wl,{onClick:$,className:"react-flow__controls-zoomin",title:M["controls.zoomIn.ariaLabel"],"aria-label":M["controls.zoomIn.ariaLabel"],disabled:w,children:d.jsx(lk,{})}),d.jsx(wl,{onClick:V,className:"react-flow__controls-zoomout",title:M["controls.zoomOut.ariaLabel"],"aria-label":M["controls.zoomOut.ariaLabel"],disabled:E,children:d.jsx(ak,{})})]}),o&&d.jsx(wl,{className:"react-flow__controls-fitview",onClick:X,title:M["controls.fitView.ariaLabel"],"aria-label":M["controls.fitView.ariaLabel"],children:d.jsx(uk,{})}),s&&d.jsx(wl,{className:"react-flow__controls-interactive",onClick:G,title:M["controls.interactive.ariaLabel"],"aria-label":M["controls.interactive.ariaLabel"],children:j?d.jsx(dk,{}):d.jsx(ck,{})}),v]})}cm.displayName="Controls";const hk=L.memo(cm);function pk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:x,borderRadius:v,shapeRendering:m,selected:y,onClick:_}){const{background:N,backgroundColor:j}=u||{},E=c||N||j;return d.jsx("rect",{className:rt(["react-flow__minimap-node",{selected:y},x]),x:r,y:o,rx:v,ry:v,width:s,height:a,style:{fill:E,stroke:h,strokeWidth:p},shapeRendering:m,onClick:_?w=>_(w,t):void 0})}const gk=L.memo(pk),mk=t=>t.nodes.map(r=>r.id),Wu=t=>t instanceof Function?t:()=>t;function yk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=gk,onClick:c}){const h=ze(mk,Qe),p=Wu(r),x=Wu(t),v=Wu(o),m=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(y=>d.jsx(xk,{id:y,nodeColorFunc:p,nodeStrokeColorFunc:x,nodeClassNameFunc:v,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:m},y))})}function vk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:x,x:v,y:m,width:y,height:_}=ze(N=>{const j=N.nodeLookup.get(t);if(!j)return{node:void 0,x:0,y:0,width:0,height:0};const E=j.internals.userNode,{x:w,y:M}=j.internals.positionAbsolute,{width:k,height:b}=Sn(E);return{node:E,x:w,y:M,width:k,height:b}},Qe);return!x||x.hidden||!cg(x)?null:d.jsx(h,{x:v,y:m,width:y,height:_,style:x.style,selected:!!x.selected,className:s(x),color:r(x),borderRadius:a,strokeColor:o(x),strokeWidth:u,shapeRendering:c,onClick:p,id:x.id})}const xk=L.memo(vk);var wk=L.memo(yk);const _k=200,Sk=150,kk=t=>!t.hidden,Nk=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?lg(us(t.nodeLookup,{filter:kk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},dp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,jk=(t,r)=>dp(t.viewBB,r.viewBB)&&dp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,bk="react-flow__minimap-desc";function dm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:x,maskStrokeColor:v,maskStrokeWidth:m,position:y="bottom-right",onClick:_,onNodeClick:N,pannable:j=!1,zoomable:E=!1,ariaLabel:w,inversePan:M,zoomStep:k=1,offsetScale:b=5}){const A=Ye(),$=L.useRef(null),{boundingRect:V,viewBB:X,rfId:G,panZoom:J,translateExtent:Z,flowWidth:re,flowHeight:te,ariaLabelConfig:I}=ze(Nk,jk),W=(t==null?void 0:t.width)??_k,H=(t==null?void 0:t.height)??Sk,U=V.width/W,C=V.height/H,D=Math.max(U,C),B=D*W,P=D*H,z=b*D,ie=V.x-(B-V.width)/2-z,oe=V.y-(P-V.height)/2-z,de=B+z*2,pe=P+z*2,he=`${bk}-${G}`,Q=L.useRef(0),ae=L.useRef();Q.current=D,L.useEffect(()=>{if($.current&&J)return ae.current=D1({domNode:$.current,panZoom:J,getTransform:()=>A.getState().transform,getViewScale:()=>Q.current}),()=>{var ne;(ne=ae.current)==null||ne.destroy()}},[J]),L.useEffect(()=>{var ne;(ne=ae.current)==null||ne.update({translateExtent:Z,width:re,height:te,inversePan:M,pannable:j,zoomStep:k,zoomable:E})},[j,E,M,k,Z,re,te]);const me=_?ne=>{var Re;const[Ne,Me]=((Re=ae.current)==null?void 0:Re.pointer(ne))||[0,0];_(ne,{x:Ne,y:Me})}:void 0,ke=N?L.useCallback((ne,Ne)=>{const Me=A.getState().nodeLookup.get(Ne).internals.userNode;N(ne,Me)},[]):void 0,ve=w??I["minimap.ariaLabel"];return d.jsx(Xl,{position:y,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-color-props":typeof v=="string"?v:void 0,"--xy-minimap-mask-stroke-width-props":typeof m=="number"?m*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:rt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:W,height:H,viewBox:`${ie} ${oe} ${de} ${pe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":he,ref:$,onClick:me,children:[ve&&d.jsx("title",{id:he,children:ve}),d.jsx(wk,{onClick:ke,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-z},${oe-z}h${de+z*2}v${pe+z*2}h${-de-z*2}z - M${X.x},${X.y}h${X.width}v${X.height}h${-X.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}dm.displayName="MiniMap";const Ek=L.memo(dm),Ck=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Mk={[Ji.Line]:"right",[Ji.Handle]:"bottom-right"};function Pk({nodeId:t,position:r,variant:o=Ji.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:x=Number.MAX_VALUE,maxHeight:v=Number.MAX_VALUE,keepAspectRatio:m=!1,resizeDirection:y,autoScale:_=!0,shouldResize:N,onResizeStart:j,onResize:E,onResizeEnd:w}){const M=Hg(),k=typeof t=="string"?t:M,b=Ye(),A=L.useRef(null),$=o===Ji.Handle,V=ze(L.useCallback(Ck($&&_),[$,_]),Qe),X=L.useRef(null),G=r??Mk[o];L.useEffect(()=>{if(!(!A.current||!k))return X.current||(X.current=Q1({domNode:A.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:Z,transform:re,snapGrid:te,snapToGrid:I,nodeOrigin:W,domNode:H}=b.getState();return{nodeLookup:Z,transform:re,snapGrid:te,snapToGrid:I,nodeOrigin:W,paneDomNode:H}},onChange:(Z,re)=>{const{triggerNodeChanges:te,nodeLookup:I,parentLookup:W,nodeOrigin:H}=b.getState(),U=[],C={x:Z.x,y:Z.y},D=I.get(k);if(D&&D.expandParent&&D.parentId){const B=D.origin??H,P=Z.width??D.measured.width??0,z=Z.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:P,height:z,...dg({x:Z.x??D.position.x,y:Z.y??D.position.y},{width:P,height:z},D.parentId,I,B)}},oe=Ec([ie],I,W,H);U.push(...oe),C.x=Z.x?Math.max(B[0]*P,Z.x):void 0,C.y=Z.y?Math.max(B[1]*z,Z.y):void 0}if(C.x!==void 0&&C.y!==void 0){const B={id:k,type:"position",position:{...C}};U.push(B)}if(Z.width!==void 0&&Z.height!==void 0){const P={id:k,type:"dimensions",resizing:!0,setAttributes:y?y==="horizontal"?"width":"height":!0,dimensions:{width:Z.width,height:Z.height}};U.push(P)}for(const B of re){const P={...B,type:"position"};U.push(P)}te(U)},onEnd:({width:Z,height:re})=>{const te={id:k,type:"dimensions",resizing:!1,dimensions:{width:Z,height:re}};b.getState().triggerNodeChanges([te])}})),X.current.update({controlPosition:G,boundaries:{minWidth:h,minHeight:p,maxWidth:x,maxHeight:v},keepAspectRatio:m,resizeDirection:y,onResizeStart:j,onResize:E,onResizeEnd:w,shouldResize:N}),()=>{var Z;(Z=X.current)==null||Z.destroy()}},[G,h,p,x,v,m,j,E,w,N]);const J=G.split("-");return d.jsx("div",{className:rt(["react-flow__resize-control","nodrag",...J,o,s]),ref:A,style:{...a,scale:V,...c&&{[$?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Pk);const Ik={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function Zl(t){return Ik[t]??8}const uc=208,cc=64,Rk=88,Tk=28,Lk=8;function Ak(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function $k(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const w of t){const M=Zl(w.type),k=s.get(M)??[];k.push(w),s.set(M,k)}const u=[...s.keys()].sort((w,M)=>w-M).map(w=>[...s.get(w)??[]].sort((M,k)=>M.name.localeCompare(k.name)||M.id.localeCompare(k.id))),c=new Set(t.map(w=>w.id)),h=new Map,p=new Map;for(const w of t)h.set(w.id,[]),p.set(w.id,[]);for(const w of r)!c.has(w.src)||!c.has(w.dst)||w.src===w.dst||(p.get(w.src).push(w.dst),h.get(w.dst).push(w.src));const x=new Map;u.forEach((w,M)=>{for(const k of w)x.set(k.id,M)});const v=new Map,m=()=>{for(const w of u)w.forEach((M,k)=>v.set(M.id,k))};m();const y=(w,M)=>{const k=w.map((b,A)=>{const $=M(b.id).map(X=>v.get(X)).filter(X=>X!==void 0),V=Ak($);return{n:b,bary:Number.isNaN(V)?A:V,name:b.name,id:b.id}});return k.sort((b,A)=>b.bary-A.bary||b.name.localeCompare(A.name)||b.id.localeCompare(A.id)),k.map(b=>b.n)},_=w=>M=>x.get(M)===w;for(let w=0;w(h.get(k)??[]).filter(_(M-1))),m();for(let M=u.length-2;M>=0;M--)u[M]=y(u[M],k=>(p.get(k)??[]).filter(_(M+1))),m()}const N=uc+Rk,j=cc+Tk,E=Math.max(...u.map(w=>w.length),1);return u.forEach((w,M)=>{const k=(E-w.length)*j/2;w.forEach((b,A)=>{o.set(b.id,{x:M*N,y:k+A*j})})}),o}const zk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),fm=90,Dk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),fp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Ok=Math.PI*(3-Math.sqrt(5)),hm=220,Fk=26,Hk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function pm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function PN(t){return fp[t]?fp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Bk(t){return t>=fm?"3d":"2d"}function Vk(t){return t>=fm?"overview":"full"}function Wk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(pm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Dk.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Wk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Yk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function Gk(t,r,o,s){const a=new Set(t.map(j=>j.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const j of r){if(!a.has(j.src)||!a.has(j.dst))continue;const E=u.get(j.src)??[];E.push({dst:j.dst,id:j.id}),u.set(j.src,E);const w=c.get(j.dst)??[];w.push({src:j.src,id:j.id}),c.set(j.dst,w)}const h=new Set(t.filter(j=>zk.has(j.type)).map(j=>j.id)),p=h.size?h:a,x=new Set,v=[o];for(;v.length;){const j=v.pop();if(!x.has(j)){x.add(j);for(const E of u.get(j)??[])x.has(E.dst)||v.push(E.dst)}}const m=new Set([o]),y=[...p].filter(j=>x.has(j)),_=new Set(y);for(;y.length;){const j=y.pop();m.add(j);for(const E of c.get(j)??[])x.has(E.src)&&!_.has(E.src)&&(_.add(E.src),y.push(E.src))}const N=new Set;for(const j of r)m.has(j.src)&&m.has(j.dst)&&N.add(j.id);return{nodeIds:m,edgeIds:N}}function IN(t){const r=new Map;for(const s of t){const a=Zl(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*hm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Fk*Math.sqrt(h+1),x=h*Ok;o.set(c.id,{x:u,y:p*Math.cos(x),z:p*Math.sin(x)})})}return o}function RN(t){const r=new Map;for(const o of t){const s=Zl(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*hm,count:s}))}const _l=16,Xk=12,qk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Kk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),hp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Qk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},pp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],gp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Zk=new Set(["looks_idempotent_on_pk","null","blank"]),Jk=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function eN(t){return hp[t]?hp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function tN(t,r,o){const s=new Map(r.map(y=>[y.id,y])),a=[];qk.has(t.type)&&a.push("sink"),Kk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(y=>y.dst===t.id),h=o.filter(y=>y.src===t.id),p=c.slice(0,_l).map(y=>Sl(y,s,y.src)),x=h.slice(0,_l).map(y=>Sl(y,s,y.dst)),v=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,m={type:t.type,typeLabel:Xo(to(t.type)),layer:Hk[Zl(t.type)]??"other",purpose:eN(t.type),name:t.name,qualifiedName:t.qualified_name,file:v,context:t.context,roles:a,facts:rN(u).filter(y=>!(y.key==="app"&&y.value===t.context)),inputs:p,outputs:x,extraInputs:Math.max(0,c.length-_l),extraOutputs:Math.max(0,h.length-_l),degreeIn:c.length,degreeOut:h.length,inputKinds:mp(c.map(y=>Sl(y,s,y.src))),outputKinds:mp(h.map(y=>Sl(y,s,y.dst))),pathSummary:""};return m.pathSummary=nN(m),m}function mp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function nN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function Sl(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Xo(to(s.type)):"",edgeType:t.type,edgeLabel:Xo(t.type),inferred:t.confidence<.8}}function rN(t){const r=[...pp.filter(a=>a in t),...Object.keys(t).filter(a=>!pp.includes(a)&&!gp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||gp.has(a)||Jk.has(a))continue;s.add(a);const u=iN(a,t[a]);u!=null&&o.push({key:a,label:Qk[a]??Xo(a),value:u})}return o}function iN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Zk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return oN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Xk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function oN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const sN=new Set,lN=L.lazy(()=>_0(()=>import("./LayeredGraph3D-B-dkkPpV.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),aN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function uN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(eo,{type:"target",position:Se.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:to(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Mr(t.name)}),d.jsx(eo,{type:"source",position:Se.Right,isConnectable:!1})]})}const cN={load:uN},dN=new Set(["django","react","stitch","arch"]);function fN({topologyKey:t}){const{fitView:r}=ql();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function hN(t,r,o=null,s={}){const a=new Map(t.map(p=>[p.id,p])),u=$k(t,r),c=t.map(p=>{var m;const x=((m=s.roles)==null?void 0:m[p.id])||[],v=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:p.id,type:"load",position:u.get(p.id)??{x:0,y:0},data:{name:p.name,type:p.type,file:p.file_path,roles:x,dim:v},selected:o===p.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:uc,height:cc,style:{width:uc,height:cc}}}),h=r.filter(p=>a.has(p.src)&&a.has(p.dst)).map(p=>{const x=aN[p.weight]||"var(--edge-cheap)",v=!!(o&&(p.src===o||p.dst===o));return{id:p.id,source:p.src,target:p.dst,type:"smoothstep",animated:p.weight==="critical",style:{stroke:x,strokeWidth:p.weight==="critical"?2.4:1.2,strokeDasharray:p.confidence<.8?"6 4":void 0},markerEnd:{type:ts.ArrowClosed,width:14,height:14,color:x},label:v?p.type.replaceAll("_"," "):void 0,labelStyle:v?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:v?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:v?[3,5]:void 0,labelBgBorderRadius:v?4:void 0}});return{rfNodes:c,rfEdges:h}}function pN({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:x}){const v=tN(t,r,o);return L.useEffect(()=>{const m=y=>{y.key==="Escape"&&s()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:v.typeLabel}),d.jsx("div",{className:"inspector-roles",children:v.roles.map(m=>d.jsx("span",{className:"inspector-chip",children:m},m))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Mr(v.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:v.purpose}),v.context?d.jsx("div",{className:"muted",children:Mr(v.context)}):null,v.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Mr(v.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Mr(v.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",v.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[v.degreeIn," in · ",v.degreeOut," out"]}),v.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:v.pathSummary}):null,v.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:v.facts.map(m=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:m.label}),d.jsx("dd",{children:Mr(m.value)})]},m.key))}):null,d.jsx(yp,{title:"Inputs",testId:"graph-inspector-inputs",links:v.inputs,extra:v.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(yp,{title:"Outputs",testId:"graph-inspector-outputs",links:v.outputs,extra:v.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",onClick:()=>a(t.id),children:"What if this changes"}):null,x?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",onClick:()=>x(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function yp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Mr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Mr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Uu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:x,repoPath:v,onOpenFile:m,pinnedId:y,onPin:_}){const[N,j]=L.useState(null),E=a!==void 0?a:N,w=ne=>{a===void 0&&j(ne),u==null||u(ne)},[M,k]=L.useState(null),[b,A]=L.useState(null),[$,V]=L.useState(new Set(dN)),[X,G]=L.useState(!1),[J,Z]=L.useState(""),[re,te]=L.useState(!1),I=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,W=M??Bk(t.length),H=b??Vk(t.length),U=X?E:null,C=L.useMemo(()=>p?Gk(t,r,p):null,[t,r,p]),D=C?t.filter(ne=>C.nodeIds.has(ne.id)):t,B=C?r.filter(ne=>C.edgeIds.has(ne.id)):r,P=L.useMemo(()=>Uk(D,B,{detail:H,families:$,focusId:U,neighborhoodOnly:!!U}),[D,B,H,$,U]),z=L.useMemo(()=>`${P.nodes.map(ne=>ne.id).join("\0")}|${P.edges.map(ne=>ne.id).join("\0")}`,[P.nodes,P.edges]),ie=E?t.find(ne=>ne.id===E)??null:null,{rfNodes:oe,rfEdges:de}=L.useMemo(()=>{const ne=hN(P.nodes,P.edges,E,{roles:c,testOverlay:h});return I&&(ne.rfEdges=ne.rfEdges.map(Ne=>({...Ne,animated:!1}))),ne},[P.nodes,P.edges,E,I,c,h]);L.useEffect(()=>{if(!s)return;const ne=t.find(Ne=>Ne.file_path===s);ne&&w(ne.id)},[s,t]);const pe=L.useMemo(()=>Yk(t,J),[t,J]),he=(ne,Ne)=>{w(Ne.id)},Q=()=>{w(null),G(!1)},ae=ie?d.jsx(pN,{node:ie,nodes:t,edges:r,onClose:Q,onWhatIf:o,onSelect:w,onOpenFile:m,pinned:y===ie.id,onPin:_,onIsolate:x?ne=>{x(p===ne?null:ne)}:void 0}):null,me=ne=>{V(Ne=>{const Me=new Set(Ne);if(Me.has(ne)){if(Me.size===1)return Ne;Me.delete(ne)}else Me.add(ne);return Me})},ke=L.useMemo(()=>{const ne=new Set;for(const Ne of t)ne.add(pm(Ne.type));return ne},[t]),ve=t.length-P.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:W==="2d"?"active":"","aria-pressed":W==="2d",onClick:()=>k("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:W==="3d"?"active":"","aria-pressed":W==="3d",onClick:()=>k("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:H==="overview"?"active":"","aria-pressed":H==="overview",onClick:()=>A("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:H==="full"?"active":"","aria-pressed":H==="full",onClick:()=>A("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(ne=>ke.has(ne)).map(ne=>d.jsx("button",{type:"button","data-testid":`graph-family-${ne}`,className:$.has(ne)?"active":"","aria-pressed":$.has(ne),onClick:()=>me(ne),children:ne},ne))}),d.jsx("button",{type:"button",className:X?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!E,onClick:()=>G(ne=>!ne),children:X?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>x==null?void 0:x(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:J,onChange:ne=>{Z(ne.target.value),te(!0)},onFocus:()=>te(!0),onBlur:()=>window.setTimeout(()=>te(!1),150)}),re&&J.trim()&&pe.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:pe.map(ne=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:Ne=>Ne.preventDefault(),onClick:()=>{w(ne.id),Z(""),te(!1)},children:[ne.name,d.jsx("span",{className:"muted",children:to(ne.type)})]})},ne.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[P.nodes.length," nodes · ",P.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:W==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(lN,{nodes:P.nodes,edges:P.edges,selectedId:E,neighborIds:U?P.neighborIds:sN,onSelect:ne=>{w(ne),ne||G(!1)}})}),ae]}):d.jsxs(am,{children:[d.jsxs(tk,{nodes:oe,edges:de,nodeTypes:cN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:he,onPaneClick:Q,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(fN,{topologyKey:z}),d.jsx(sk,{}),d.jsx(Ek,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(hk,{})]}),ae]})})]})}function gm(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function gN(t){localStorage.setItem("loadpath.editor",t)}async function mN(t,r,o,s=gm()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const vp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],yN=["preset","branch","tag","commit"];function vN(t){var a;if(!(t!=null&&t.git))return[...vp];const r=((a=t.presets)!=null&&a.length?t.presets:vp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function xN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function wN(t){return yN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function _N(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function xp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[x,v]=L.useState(!1),[m,y]=L.useState(null),[_,N]=L.useState(0),j=L.useMemo(()=>{const b=vN(u);return m===null?b:xN(b,m)},[u,m]),E=L.useMemo(()=>wN(j),[j]);L.useEffect(()=>{x&&c()},[x,c]),L.useEffect(()=>{N(0)},[m,x]);const w=()=>{v(!1),y(null)},M=b=>{r(b.value),w()},k=b=>{if(b.key==="ArrowDown"){if(b.preventDefault(),!x){v(!0);return}N(A=>Math.min(A+1,Math.max(j.length-1,0)))}else if(b.key==="ArrowUp"){if(b.preventDefault(),!x)return;N(A=>Math.max(A-1,0))}else if(b.key==="Enter"&&x){b.preventDefault();const A=j[_];A&&M(A)}else b.key==="Escape"&&x&&(b.preventDefault(),w())};return d.jsxs("div",{className:"combo",ref:p,onBlur:b=>{b.currentTarget.contains(b.relatedTarget)||w()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":x,"aria-controls":h,"aria-autocomplete":"list",onChange:b=>{r(b.target.value),x&&y(b.target.value)},onKeyDown:k}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":x,onMouseDown:b=>b.preventDefault(),onClick:()=>x?w():v(!0),children:d.jsx(v0,{})})]}),x?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:E.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):E.map(b=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:_N(b.group)}),b.items.map(A=>{const $=j.indexOf(A);return d.jsxs("button",{type:"button",role:"option","aria-selected":$===_,className:$===_?"combo-option active":"combo-option","data-testid":`ref-option-${A.group}`,onMouseDown:V=>V.preventDefault(),onMouseEnter:()=>N($),onClick:()=>M(A),children:[d.jsx("span",{className:"combo-label",children:A.label}),A.detail?d.jsx("span",{className:"combo-detail",children:A.detail}):null]},`${A.group}:${A.value}`)})]},b.group))}):null]})}function SN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[x,v]=L.useState(""),[m,y]=L.useState(!1),_=L.useRef(null),N=L.useRef(0),j=async k=>{const b=N.current+1;N.current=b,y(!0);try{const A=await Pe.browse(k);if(N.current!==b)return;a(A),c(A.path),p(A.is_git?A.path:null),v("")}catch(A){if(N.current!==b)return;v(A instanceof Error?A.message:String(A))}finally{N.current===b&&y(!1)}};L.useEffect(()=>{var k,b;j(t),(k=_.current)==null||k.focus(),(b=_.current)==null||b.select()},[t]);const E=h||(s==null?void 0:s.path)||u,w=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",M=k=>{k.key==="Escape"&&(k.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:M,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:k=>k.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:k=>{k.preventDefault(),j(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:k=>c(k.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),x?d.jsx("div",{className:"error",role:"alert",children:x}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":m,children:s!=null&&s.entries.length?s.entries.map(k=>{const b=h===k.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":b,className:b?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":k.path,onClick:()=>p(k.path),onDoubleClick:()=>void j(k.path),children:[d.jsx(kp,{}),d.jsx("span",{className:"explorer-name",children:k.name}),k.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},k.path)}):d.jsx("div",{className:"muted explorer-empty",children:m?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:E,children:E}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!E,onClick:()=>E&&r(E),children:["Use ",w]})]})]})})}const Dl=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],kN="obsidian",mm="loadpath.theme";function NN(t){return Dl.some(r=>r.id===t)}function ym(){try{const t=localStorage.getItem(mm)||"";if(NN(t))return t}catch{}return kN}function jN(t){var r;return((r=Dl.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function vm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=jN(t);try{localStorage.setItem(mm,t)}catch{}}const Yu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:h0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:p0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:g0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:m0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:y0}];function bN(t){const r=t.total||0;return r<=0?null:Math.min(100,Math.round(100*(t.done||0)/r))}function Gu(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function EN(){var Fr,In,Rn,_i,Un,De,lo,ao;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,x]=L.useState(null),[v,m]=L.useState(null),[y,_]=L.useState([]),[N,j]=L.useState("review"),[E,w]=L.useState(""),[M,k]=L.useState(""),[b,A]=L.useState(null),[$,V]=L.useState(!1),[X,G]=L.useState(""),[J,Z]=L.useState({}),[re,te]=L.useState([]),[I,W]=L.useState([]),[H,U]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[C,D]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[B,P]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[z,ie]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[oe,de]=L.useState(0),[pe,he]=L.useState(""),[Q,ae]=L.useState(ym),[me,ke]=L.useState(!1),[ve,ne]=L.useState(!1),[Ne,Me]=L.useState(!1),[Re,Le]=L.useState(null),[Ze,pt]=L.useState(null),[Xe,it]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[on,Mt]=L.useState(null),[ot,dt]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[gt,mt]=L.useState([]),[Pt,kn]=L.useState(null),[sn,qt]=L.useState(null),[no,rr]=L.useState(null),[ui,ci]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[ir,Nn]=L.useState(null),[Nt,jn]=L.useState(null),[bn,It]=L.useState(!1),[Ft,En]=L.useState(!1),yt=L.useRef(o);yt.current=o;const Rr=L.useRef(!1);Rr.current=ve;const Ht=L.useRef(""),Tr=R=>{ae(R),vm(R)},tt=L.useRef(""),He=R=>{tt.current=R,k(R)},ln=R=>{const Y=()=>{Pe.indexProgress(R).then(Ee=>{tt.current&&(Ee.phase&&Ee.phase!=="idle"&&Ee.message&&He(Ee.message),A(Ee.phase&&Ee.phase!=="idle"?bN(Ee):null))}).catch(()=>{})};Y();const fe=window.setInterval(Y,250);return()=>{window.clearInterval(fe),A(null)}};L.useEffect(()=>{Pe.settings().then(Z).catch(()=>{}).finally(()=>ke(!0)),Pe.repos().then(R=>_(R.repos)).catch(()=>{})},[]);const Hn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const R=o;let Y=!1;return Pe.architecture(R).then(fe=>{!Y&&yt.current===R&&m(fe)}).catch(()=>{}),Pe.config(R).then(fe=>{!Y&&yt.current===R&&qt(fe)}).catch(()=>{}),Pe.architectureHealth(R).then(fe=>{!Y&&yt.current===R&&rr(fe)}).catch(()=>{}),()=>{Y=!0}},[t,o]);const jt=R=>{yt.current=R,s(R),localStorage.setItem("loadpath.repo",R),R.trim()!==Ht.current&&(Ht.current="",Nn(null))},Lr=L.useCallback(R=>{const Y=(R??yt.current).trim();return!Y||Ht.current===Y?Promise.resolve():(Ht.current=Y,Pe.gitRefs(Y).then(fe=>{yt.current.trim()===Y&&Nn(fe)}).catch(()=>{Ht.current===Y&&(Ht.current="",Nn(null))}))},[]),bt=(R,Y)=>{u(R),h(Y),localStorage.setItem("loadpath.base",R),localStorage.setItem("loadpath.head",Y)},Cn=(R,Y,fe)=>{D(R),U(Y),localStorage.setItem("loadpath.provider",R),localStorage.setItem("loadpath.scmRepo",Y),fe!==void 0&&(P(fe),localStorage.setItem("loadpath.prNumber",fe))},Kt=R=>{x(R),de(0),Le(Ze&&R.nodes.some(Y=>Y.id===Ze)?Ze:null),Mt(null),kn(null),R.id&&!R.what_if&&localStorage.setItem("loadpath.lastReviewId",R.id)},Bn=async R=>{try{const Y=await Pe.reviews(R);mt(Y.reviews)}catch{mt([])}},di=async R=>{try{rr(await Pe.architectureHealth(R))}catch{rr(null)}},ro=R=>R==="github"?!!J.github_token_set:R==="gitlab"?!!J.gitlab_token_set:!!J.bitbucket_token_set,Bt=L.useCallback(async(R=C)=>{var Y;try{const fe=await Pe.scmRepos(R);W(fe.repos),(Y=fe.user)!=null&&Y.login&&Z(Ee=>({...Ee,...R==="github"?{github_user:fe.user.login}:R==="gitlab"?{gitlab_user:fe.user.login}:{bitbucket_user:fe.user.login}}))}catch{W([])}},[C]);L.useEffect(()=>{if(t!=="prs")return;let R=!1;return Bt(C).catch(()=>{R||W([])}),()=>{R=!0}},[t,C,Bt]),L.useEffect(()=>{if(!Nt)return;let R=!1,Y=0;const fe=async()=>{try{const Ee=await Pe.githubOAuthPoll(Nt.flow_id);if(R)return;if(Ee.status==="complete"){jn(null);const Ae=await Pe.settings();Z(Ae),G(Ee.user?`Signed in to GitHub as ${Ee.user}`:"Signed in to GitHub"),Bt("github");return}if(Ee.status==="pending"||Ee.status==="slow_down"){Y=window.setTimeout(fe,Math.max(Ee.interval||Nt.interval,5)*1e3);return}jn(null),w(Ee.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(Ee){if(R)return;jn(null),w(Ee instanceof Error?Ee.message:String(Ee))}};return Y=window.setTimeout(fe,Math.max(Nt.interval,5)*1e3),()=>{R=!0,window.clearTimeout(Y)}},[Nt,Bt]),L.useEffect(()=>{if(!bn)return;let R=!1,Y=0;const fe=Date.now(),Ee=async()=>{try{const Ae=await Pe.oauthStatus();if(R)return;if(Ae.bitbucket.connected){It(!1);const Fe=await Pe.settings();Z(Fe),G(Ae.bitbucket.user?`Signed in to Bitbucket as ${Ae.bitbucket.user}`:"Signed in to Bitbucket"),Bt("bitbucket");return}if(Date.now()-fe>18e4){It(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(Ee,1500)}catch(Ae){if(R)return;It(!1),w(Ae instanceof Error?Ae.message:String(Ae))}};return Y=window.setTimeout(Ee,1500),()=>{R=!0,window.clearTimeout(Y)}},[bn,Bt]),L.useEffect(()=>{if(!Ft)return;let R=!1,Y=0;const fe=Date.now(),Ee=async()=>{try{const Ae=await Pe.oauthStatus();if(R)return;if(Ae.gitlab.connected){En(!1);const Fe=await Pe.settings();Z(Fe),G(Ae.gitlab.user?`Signed in to GitLab as ${Ae.gitlab.user}`:"Signed in to GitLab"),Bt("gitlab");return}if(Date.now()-fe>18e4){En(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(Ee,1500)}catch(Ae){if(R)return;En(!1),w(Ae instanceof Error?Ae.message:String(Ae))}};return Y=window.setTimeout(Ee,1500),()=>{R=!0,window.clearTimeout(Y)}},[Ft,Bt]);const Rt=async(R=o)=>{if(!R.trim())return null;const Y=await Pe.architecture(R);return yt.current===R&&m(Y),Y},or=async R=>{const Y=R.trim();if(!(!Y||Y===yt.current)){if(tt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),G(""),x(null),m(null),j("architecture"),jt(Y),V(!0),He(`Loading ${f0(Y)}…`);try{await Promise.all([Rt(Y),Lr(Y)])}catch(fe){yt.current===Y&&w(fe instanceof Error?fe.message:String(fe))}finally{yt.current===Y&&(He(""),V(!1))}}},an=async()=>{if(tt.current||!Hn())return;w(""),G(""),He("Tracing load path…"),jt(o),bt(a,c);const R=ln(o);try{const Y=await Pe.review(o,a,c,!0,z);Kt(Y),j("review"),r("review"),await Pe.repos().then(fe=>_(fe.repos)).catch(()=>{}),await Promise.all([Rt(o),Bn(o),di(o)])}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{R(),He("")}},Ar=async(R=!0)=>{if(tt.current||!Hn())return;w(""),G(""),He(R?"Indexing…":"Full reindex…"),jt(o);const Y=ln(o);try{await Pe.index(o,R);const fe=await Rt(o);await Pe.repos().then(Ee=>_(Ee.repos)).catch(()=>{}),fe!=null&&fe.indexed&&(j("architecture"),r("architecture"))}catch(fe){w(fe instanceof Error?fe.message:String(fe))}finally{Y(),He("")}},fi=async()=>{if(!tt.current&&Hn()){w(""),G(""),He("Detecting layout…"),jt(o);try{const R=await Pe.init(o);G(R.message),await Pe.repos().then(Y=>_(Y.repos)).catch(()=>{})}catch(R){w(R instanceof Error?R.message:String(R))}finally{He("")}}},hi=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),G("Copied markdown brief")}catch(R){w(R instanceof Error?R.message:String(R))}},pi=async()=>{if(!tt.current){if(!(p!=null&&p.markdown)||!H||!B){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const R=await Pe.postComment(C,H,Number(B),p.markdown);G(R.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(R){w(R instanceof Error?R.message:String(R))}finally{He("")}}},gi=async()=>{if(!tt.current){w(""),He("Fetching pull requests…");try{const R=await Pe.prs(C,H,"open",o.trim()||void 0);te(R.pull_requests);const Y=I.find(fe=>fe.slug.toLowerCase()===H.trim().toLowerCase());Y!=null&&Y.local_path&&jt(Y.local_path)}catch(R){w(R instanceof Error?R.message:String(R))}finally{He("")}}},io=async()=>{w("");try{const R=await Pe.githubOAuthStart();jn(R),Gu(R.verification_uri_complete,"github.com","/login/device")}catch(R){w(R instanceof Error?R.message:String(R))}},mi=async()=>{w("");try{const R=await Pe.bitbucketOAuthStart();It(!0),Gu(R.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(R){It(!1),w(R instanceof Error?R.message:String(R))}},Ve=async()=>{w("");try{const R=await Pe.gitlabOAuthStart();En(!0),Gu(R.authorize_url,new URL(R.authorize_url).hostname,"/oauth/authorize")}catch(R){En(!1),w(R instanceof Error?R.message:String(R))}},$r=async R=>{if(!(tt.current||!o.trim())){w(""),He("Walking what-if path…");try{const Y=await Pe.whatIf(o,R);G(`${Y.title} — ${Y.confidence.level} · ${(Y.sinks||[]).length} sinks`),Kt({...Y,markdown:Y.markdown||"",index:Y.index||(p==null?void 0:p.index),workspace:Y.workspace||(p==null?void 0:p.workspace)}),j("review"),r("review")}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},zr=async R=>{var Ae;if(tt.current)return;Cn(R.provider,R.repo,String(R.number));const Y=I.find(Fe=>Fe.slug.toLowerCase()===R.repo.toLowerCase());Y!=null&&Y.local_path&&jt(Y.local_path),w(""),He(`Fetching ${R.provider} #${R.number}…`);const fe=(Y==null?void 0:Y.local_path)||o,Ee=fe?ln(fe):()=>{};try{const Fe=await Pe.reviewPr(R.provider,R.repo,R.number,(Y==null?void 0:Y.local_path)||o||void 0);Kt(Fe),Fe.pull_request&&typeof Fe.pull_request.repo_path=="string"&&jt(Fe.pull_request.repo_path),bt(String(Fe.base||R.target_branch),String(Fe.head||R.source_branch)),j("review"),r("review"),typeof((Ae=Fe.pull_request)==null?void 0:Ae.repo_path)=="string"&&Bn(Fe.pull_request.repo_path)}catch(Fe){bt(R.base_sha||R.target_branch,R.head_sha||R.source_branch),r("review"),w(Fe instanceof Error?Fe.message:String(Fe))}finally{Ee(),He("")}},sr=async R=>{w("");try{Z(await Pe.oauthDisconnect(R)),C===R&&W([]),G(`Disconnected ${R}`)}catch(Y){w(Y instanceof Error?Y.message:String(Y))}},lr=async R=>{R.preventDefault();const Y=new FormData(R.currentTarget),fe={github_token:String(Y.get("github_token")||""),github_oauth_client_id:String(Y.get("github_oauth_client_id")||""),github_host:String(Y.get("github_host")||""),gitlab_token:String(Y.get("gitlab_token")||""),gitlab_host:String(Y.get("gitlab_host")||""),gitlab_oauth_client_id:String(Y.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(Y.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(Y.get("bitbucket_token")||""),bitbucket_username:String(Y.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(Y.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(Y.get("bitbucket_oauth_client_secret")||""),ai_provider:String(Y.get("ai_provider")||"none"),ai_api_key:String(Y.get("ai_api_key")||""),ai_model:String(Y.get("ai_model")||""),ai_base_url:String(Y.get("ai_base_url")||"")},Ee=y.length?{...fe,workspaces:y.map(Ae=>({path:Ae.path,name:Ae.name}))}:fe;try{Z(await Pe.saveSettings(Ee)),G("Settings saved on this machine")}catch(Ae){w(Ae instanceof Error?Ae.message:String(Ae))}},oo=async()=>{if(!(!p||tt.current)){He("Residual analysis…");try{const R=await Pe.residual(p);he(R.note)}catch(R){w(R instanceof Error?R.message:String(R))}finally{He("")}}},ar=L.useRef(an);ar.current=an;const Mn=L.useRef(t);Mn.current=t;const vt=L.useRef(!1);vt.current=Ne;const yi=L.useRef(p);yi.current=p;const xt=L.useRef(oe);xt.current=oe,L.useEffect(()=>{const R=localStorage.getItem("loadpath.lastReviewId"),Y=(localStorage.getItem("loadpath.repo")||"").trim();if(!R||!Y){ci(!1);return}let fe=!1;return Pe.getReview(Y,R).then(Ee=>{fe||(Kt(Ee),bt(Ee.base||localStorage.getItem("loadpath.base")||"HEAD~1",Ee.head||localStorage.getItem("loadpath.head")||"HEAD"),Bn(Y),di(Y))}).catch(()=>{}).finally(()=>{fe||ci(!1)}),()=>{fe=!0}},[]);const Dr=L.useRef("");L.useEffect(()=>{if(!ot||!o.trim())return;let R=!1;const Y=async()=>{try{const Ee=await Pe.workspaceStatus(o);if(R)return;Dr.current&&Ee.fingerprint!==Dr.current&&!tt.current&&(ie(!0),localStorage.setItem("loadpath.dirty","1"),ar.current()),Dr.current=Ee.fingerprint}catch{}};Y();const fe=window.setInterval(Y,2e3);return()=>{R=!0,window.clearInterval(fe)}},[ot,o]),L.useEffect(()=>{const R=Y=>{var Ae;if((Y.metaKey||Y.ctrlKey)&&Y.key.toLowerCase()==="k"){Y.preventDefault(),Me(Fe=>!Fe);return}if(vt.current){Y.key==="Escape"&&(Y.preventDefault(),Me(!1));return}if(Rr.current){Y.key==="Escape"&&(Y.preventDefault(),ne(!1));return}const fe=Y.target;if(fe&&(fe.tagName==="INPUT"||fe.tagName==="TEXTAREA"||fe.tagName==="SELECT"||fe.isContentEditable)){Y.key==="Escape"&&fe.blur();return}if(Y.key==="Escape"){w(""),G(""),Le(Ze),Mt(null);return}if(Y.key==="j"||Y.key==="k"){const Fe=((Ae=yi.current)==null?void 0:Ae.read_order)||[];if(!Fe.length)return;Y.preventDefault();const un=xt.current,Tn=Y.key==="j"?Math.min(Fe.length-1,un+1):Math.max(0,un-1);de(Tn);return}const Ee=Yu.find(Fe=>Fe.shortcut===Y.key);if(Ee&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey&&r(Ee.id),(Y.metaKey||Y.ctrlKey)&&Y.key==="Enter"){if(Mn.current==="settings"||Mn.current==="prs"||tt.current)return;Y.preventDefault(),ar.current()}};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[Ze]);const vi=async(R,Y)=>{if(!o.trim())return;const fe=await mN(o,R,Y);fe.ok?G(fe.message):w(fe.message)},xi=async()=>{if(p)try{const R=await Pe.exportHtml(p),Y=URL.createObjectURL(R),fe=document.createElement("a");fe.href=Y,fe.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,fe.click(),URL.revokeObjectURL(Y),G("Saved HTML brief")}catch(R){w(R instanceof Error?R.message:String(R))}},Vn=async R=>{if(o.trim()){He("Loading stored review…");try{const Y=await Pe.getReview(o,R);Kt(Y),bt(Y.base||a,Y.head||c),j("review"),r("review");const fe=gt.find(Ee=>Ee.id!==R);if(fe)try{kn(await Pe.reviewDiff(o,R,fe.id))}catch{kn(null)}}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},Pn={selectedId:Re,onSelect:Le,nodeRoles:p==null?void 0:p.node_roles,testOverlay:Xe,isolateSource:on,onIsolate:Mt,repoPath:o,onOpenFile:vi,pinnedId:Ze,onPin:pt},Wn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void an()},{id:"index",group:"Run",label:"Index repository",run:()=>void Ar(!0)},{id:"watch",group:"Run",label:ot?"Stop watching working tree":"Watch working tree",run:()=>{const R=!ot;dt(R),localStorage.setItem("loadpath.watch",R?"1":"0")}},{id:"tests",group:"Graph",label:Xe?"Hide test overlay":"Show test overlay",run:()=>{const R=!Xe;it(R),localStorage.setItem("loadpath.testOverlay",R?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void xi()},...Yu.map(R=>({id:`tab-${R.id}`,group:"Tabs",label:`Go to ${R.label}`,hint:R.shortcut,run:()=>r(R.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(R=>({id:`node-${R.id}`,group:"Nodes",label:R.name,hint:to(R.type),run:()=>{Le(R.id),r("graph")}})),...gt.slice(0,12).map(R=>({id:`hist-${R.id}`,group:"History",label:R.title||R.id,hint:`${R.level||""} ${R.created_at||""}`.trim(),run:()=>void Vn(R.id)}))],Qt=L.useMemo(()=>N==="architecture"?(v==null?void 0:v.nodes)??[]:(p==null?void 0:p.nodes)??[],[N,v,p]),so=L.useMemo(()=>N==="architecture"?(v==null?void 0:v.edges)??[]:(p==null?void 0:p.edges)??[],[N,v,p]),wi=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:v!=null&&v.indexed?`${v.counts.nodes} nodes · ${v.counts.edges} edges`:"Not indexed",Or=((p==null?void 0:p.findings)||[]).filter(R=>!R.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Yu.map(R=>{const Y=R.icon,fe=t===R.id;return d.jsxs("button",{type:"button","data-testid":R.testId,className:fe?"nav-item active":"nav-item","aria-current":fe?"page":void 0,"aria-label":R.label,onClick:()=>r(R.id),children:[d.jsx(Y,{}),d.jsx("span",{children:R.label})]},R.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:Q,onChange:R=>Tr(R.target.value),children:["dark","light"].map(R=>d.jsx("optgroup",{label:R==="dark"?"Dark":"Light",children:Dl.filter(Y=>Y.group===R).map(Y=>d.jsx("option",{value:Y.id,children:Y.label},Y.id))},R))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:M||wi}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[M?d.jsxs("div",{className:b!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","data-testid":"progress",children:[d.jsx("i",{style:b!=null?{width:`${b}%`}:void 0}),d.jsx("span",{className:"sr-only",children:M})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[y.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:y.some(R=>R.path===o)?o:"",disabled:!!M,"aria-busy":$,onChange:R=>{R.target.value&&or(R.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),y.map(R=>d.jsxs("option",{value:R.path,children:[R.name,R.indexed?` (${R.counts.nodes})`:""]},R.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:R=>{const Y=R.target.value;s(Y),Y.trim()!==Ht.current&&(Ht.current="",Nn(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>ne(!0),children:d.jsx(kp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(xp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:R=>bt(R,c),placeholder:"base",refs:ir,onNeedRefs:Lr})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(xp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:R=>bt(a,R),placeholder:"head",refs:ir,onNeedRefs:Lr})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:z?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":z,onClick:()=>{const R=!z;ie(R),localStorage.setItem("loadpath.dirty",R?"1":"0")},children:z?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:ot?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":ot,onClick:()=>{const R=!ot;dt(R),localStorage.setItem("loadpath.watch",R?"1":"0")},children:ot?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!M,onClick:fi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!M,onClick:()=>Ar(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!M,onClick:an,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[E?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:E}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,X?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:X}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>G(""),"aria-label":"Dismiss",children:"×"})]}):null,((Fr=p==null?void 0:p.index)!=null&&Fr.stale||v!=null&&v.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((In=p==null?void 0:p.index)==null?void 0:In.django_boot)==="failed"||(v==null?void 0:v.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Rn=p==null?void 0:p.index)==null?void 0:Rn.django_boot_detail)||(v==null?void 0:v.django_boot_detail)||"django.setup() failed"}):null,(_i=p==null?void 0:p.workspace)!=null&&_i.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null]}),d.jsxs("div",{className:"stage","aria-busy":$,children:[$?d.jsxs("div",{className:"empty workspace-loading","data-testid":"workspace-loading",children:[d.jsx("h2",{children:M}),d.jsx("p",{children:"Fetching the indexed graph for this repository."})]}):null,!$&&t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(CN,{review:p,findings:Or,aiNote:pe,busy:!!M,tourIndex:oe,onTour:de,onAskAi:oo,onCopy:hi,onPost:pi,onSelect:Le,onOpenFile:vi,onExport:xi,history:gt,diff:Pt,onReopen:Vn,onWaiver:(R,Y)=>{o.trim()&&Pe.addWaiver(o,R,Y||void 0,"from review").then(fe=>{qt(fe),G(`Waived ${R} in loadpath.yml`)})}}):ui?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Uu,{nodes:p.nodes,edges:p.edges,onWhatIf:$r,focusPath:(Un=p.read_order[oe])==null?void 0:Un.path,...Pn}):null})]}),!$&&t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:v!=null&&v.indexed?d.jsx(MN,{architecture:v,busy:!!M,onReindex:()=>Ar(!1),onReview:an,onSelect:Le,config:sn,health:no,onSaveConfig:R=>{Pe.saveConfig(o,R).then(Y=>{qt(Y),G("Wrote loadpath.yml")})},onWaiver:(R,Y,fe)=>{Pe.addWaiver(o,R,Y,fe).then(Ee=>{qt(Ee),G(`Waived ${R}`)})}}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:v!=null&&v.indexed?d.jsx(Uu,{nodes:v.nodes,edges:v.edges,onWhatIf:$r,...Pn}):null})]}),!$&&t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":N==="review","data-testid":"graph-mode-review",className:N==="review"?"active":"",onClick:()=>j("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":N==="architecture","data-testid":"graph-mode-architecture",className:N==="architecture"?"active":"",onClick:()=>j("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:Xe?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":Xe,onClick:()=>{const R=!Xe;it(R),localStorage.setItem("loadpath.testOverlay",R?"1":"0")},children:"Tests"})]}),Qt.length?d.jsx(Uu,{nodes:Qt,edges:so,onWhatIf:$r,...Pn}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),!$&&t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:C,onChange:R=>Cn(R.target.value,H,B),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:I.length?"Search your repos":"owner/repo",value:H,onChange:R=>Cn(C,R.target.value,B),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:I.map(R=>d.jsxs("option",{value:R.slug,children:[R.private?"private":"public",R.local_path?" · local":""]},R.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!M||!ro(C),onClick:()=>{Bt(C)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!M,onClick:gi,children:"List PRs"})]}),I.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[I.length," ",C," repositor",I.length===1?"y":"ies",C==="github"&&J.github_user?` · @${String(J.github_user)}`:"",C==="gitlab"&&J.gitlab_user?` · @${String(J.gitlab_user)}`:"",C==="bitbucket"&&J.bitbucket_user?` · ${String(J.bitbucket_user)}`:""]}):null,re.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):re.map(R=>{var Y;return d.jsxs("article",{className:"pr","data-testid":`pr-${R.number}`,children:[d.jsxs("h3",{children:["#",R.number," ",R.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${R.draft?"":"open"}`,children:R.draft?"draft":R.state}),d.jsx("span",{children:R.author}),d.jsxs("span",{children:[R.source_branch," → ",R.target_branch]}),R.loadpath?d.jsxs("span",{className:`chip ${R.loadpath.level||""}`,"data-testid":`pr-loadpath-${R.number}`,children:[((Y=R.loadpath.level)==null?void 0:Y.toUpperCase())||"REVIEWED",R.loadpath.contract_break&&R.loadpath.contract_break!=="none"?` · ${R.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:R.url,target:"_blank",rel:"noreferrer",children:["Open on ",R.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${R.number}`,onClick:()=>void zr(R),children:"Review this PR"})]})]},`${R.provider}-${R.number}`)})]}),!$&&t==="settings"&&me&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:lr,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Dl.map(R=>d.jsxs("button",{type:"button","data-theme":R.id,className:Q===R.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${R.id}`,onClick:()=>Tr(R.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:R.label}),d.jsx("div",{className:"group",children:R.group})]},R.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:gm(),onChange:R=>gN(R.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:J.github_token_set?J.github_user?`Signed in as @${String(J.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:J.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void sr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!Nt||!J.github_oauth_ready,onClick:()=>void io(),children:Nt?"Waiting for GitHub…":"Sign in with GitHub"})})]}),Nt?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:Nt.user_code})," at GitHub if the browser did not fill it in."]}):null,J.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(J.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(J.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:J.gitlab_token_set?J.gitlab_user?`Signed in as @${String(J.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:J.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void sr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Ft||!J.gitlab_oauth_ready,onClick:()=>void Ve(),children:Ft?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(J.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(J.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:J.bitbucket_token_set?J.bitbucket_user?`Signed in as ${String(J.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:J.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void sr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:bn||!J.bitbucket_oauth_ready,onClick:()=>void mi(),children:bn?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),J.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(J.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(J.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((De=J.ai)==null?void 0:De.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((lo=J.ai)==null?void 0:lo.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((ao=J.ai)==null?void 0:ao.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(u0,{open:Ne,actions:Wn,onClose:()=>Me(!1)}),ve?d.jsx(SN,{initialPath:o,onClose:()=>ne(!1),onSelect:R=>{if(tt.current){w("Wait for the current job to finish before switching workspace.");return}ne(!1),or(R)}}):null]})}function CN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:x,onOpenFile:v,onExport:m,history:y,diff:_,onReopen:N,onWaiver:j}){var w,M,k,b,A,$,V,X,G,J,Z,re,te,I,W,H,U;const E=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),E.length?d.jsx("ul",{className:"reasons",children:E.map(C=>d.jsx("li",{children:C},C))}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(C=>d.jsx("span",{className:"chip",children:Xo(C)},C)),(w=t.contract_break)!=null&&w.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(C=>C.status==="todo").length})]}),(t.checklist||[]).map(C=>d.jsxs("div",{className:`check-item ${C.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>C.node_id&&x(C.node_id),children:[d.jsx("span",{className:`chip ${C.status}`,children:C.status}),C.title]}),C.detail?d.jsx("div",{className:"why",children:C.detail}):null,C.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(C.body||"")},children:"Copy test"}):null,C.kind==="finding"&&C.status==="todo"&&C.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>j(C.rule,C.node_id),children:"Waive in loadpath.yml"}):null]},C.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(M=t.workspace)!=null&&M.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((C,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",C.path]}),d.jsx("div",{className:"why",children:C.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>v(C.path),children:"Open"})]},C.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(C=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:C.title})," — ",C.files.join(", ")]},C.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(C=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>C.node_id&&x(C.node_id),children:[d.jsx("span",{className:`chip ${C.severity}`,children:C.severity}),C.message]})},C.rule+C.message))]}),d.jsx(xm,{cards:t.deepening}),(b=(k=t.contract_break)==null?void 0:k.reasons)!=null&&b.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(C=>d.jsx("div",{className:"muted",children:C},C)),($=(A=t.contract_break.sides)==null?void 0:A.rows)!=null&&$.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(C=>d.jsxs("tr",{className:C.status,children:[d.jsx("td",{children:C.field}),d.jsx("td",{children:C.serializer?"yes":"—"}),d.jsx("td",{children:C.zod?"yes":"—"}),d.jsx("td",{children:C.graphql?"yes":"—"})]},C.field))})]}):null]}):null,(V=t.auth)!=null&&V.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(C=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),C.name]},C.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(X=t.suggested_tests)==null?void 0:X.length})]}),(t.suggested_tests||[]).map(C=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:C.title}),d.jsx("pre",{className:"headline",children:C.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(C.body)},children:"Copy sketch"})]},C.title))]}):null,(G=t.trend)!=null&&G.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(C=>d.jsxs("div",{className:"muted",children:[C.level," · ",Xu(C.created_at),C.sinks!=null?` · ${C.sinks} sinks`:""]},C.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(C=>d.jsx("div",{className:"residual muted",children:C},C))]}),y.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:y.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,y.slice(0,12).map(C=>d.jsxs("button",{type:"button",className:C.id===t.id?"history-item current":"history-item",onClick:()=>N(C.id),children:[d.jsx("span",{className:`chip ${C.level||""}`,children:C.level||"walk"}),C.title||C.id.slice(0,8),d.jsx("span",{className:"muted",children:C.created_at?Xu(C.created_at):""})]},C.id))]}):null,(Z=(J=t.evolution)==null?void 0:J.notes)!=null&&Z.length||(te=(re=t.evolution)==null?void 0:re.hotspots)!=null&&te.some(C=>C.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((I=t.evolution)==null?void 0:I.notes)||[]).map(C=>d.jsx("div",{className:"muted",children:C},C)),(((W=t.evolution)==null?void 0:W.hotspots)||[]).filter(C=>C.commits).slice(0,6).map(C=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:C.path})," — ",C.commits," commits, bus factor ",C.bus_factor]},C.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:m,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(H=t.codeowners_reviewers)!=null&&H.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function MN({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var v;const x=t.findings.filter(m=>!m.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${Xu(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(m=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:m.name})," — ",(m.django_apps||[]).join(", ")||"no apps"," ·"," ",(m.owners||[]).join(", ")||"unowned"]},m.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(m=>d.jsx("div",{className:"muted",children:m},m))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:x.length})]}),x.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):x.map(m=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>m.node_id&&a(m.node_id),children:[d.jsx("span",{className:`chip ${m.severity}`,children:m.severity}),m.message]})},m.rule+m.message))]}),d.jsx(xm,{cards:t.deepening}),(v=c==null?void 0:c.points)!=null&&v.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(m=>d.jsx("i",{className:m.level||"",title:`${m.level} · ${m.findings} findings`,style:{height:`${8+Math.min(24,(m.findings||0)*4)}px`}},m.id||m.created_at))}),Object.entries(c.contexts).map(([m,y])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:m})," — last ",((_=y[y.length-1])==null?void 0:_.findings)??0," findings"]},m)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(c0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((m,y)=>y[1]-m[1]).slice(0,12).map(([m,y])=>d.jsxs("tr",{children:[d.jsx("td",{children:to(m)}),d.jsx("td",{children:y})]},m))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function xm({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:d0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}vm(ym());s0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(EN,{})}));export{Hk as L,RN as a,PN as c,d as j,IN as l,L as r,to as t}; + M${X.x},${X.y}h${X.width}v${X.height}h${-X.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}dm.displayName="MiniMap";const Ek=L.memo(dm),Ck=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Mk={[Ji.Line]:"right",[Ji.Handle]:"bottom-right"};function Pk({nodeId:t,position:r,variant:o=Ji.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:x=Number.MAX_VALUE,maxHeight:v=Number.MAX_VALUE,keepAspectRatio:m=!1,resizeDirection:y,autoScale:_=!0,shouldResize:N,onResizeStart:j,onResize:E,onResizeEnd:w}){const M=Hg(),k=typeof t=="string"?t:M,b=Ye(),A=L.useRef(null),$=o===Ji.Handle,V=ze(L.useCallback(Ck($&&_),[$,_]),Qe),X=L.useRef(null),G=r??Mk[o];L.useEffect(()=>{if(!(!A.current||!k))return X.current||(X.current=Q1({domNode:A.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:Z,transform:re,snapGrid:te,snapToGrid:I,nodeOrigin:W,domNode:H}=b.getState();return{nodeLookup:Z,transform:re,snapGrid:te,snapToGrid:I,nodeOrigin:W,paneDomNode:H}},onChange:(Z,re)=>{const{triggerNodeChanges:te,nodeLookup:I,parentLookup:W,nodeOrigin:H}=b.getState(),U=[],C={x:Z.x,y:Z.y},D=I.get(k);if(D&&D.expandParent&&D.parentId){const B=D.origin??H,P=Z.width??D.measured.width??0,z=Z.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:P,height:z,...dg({x:Z.x??D.position.x,y:Z.y??D.position.y},{width:P,height:z},D.parentId,I,B)}},oe=Ec([ie],I,W,H);U.push(...oe),C.x=Z.x?Math.max(B[0]*P,Z.x):void 0,C.y=Z.y?Math.max(B[1]*z,Z.y):void 0}if(C.x!==void 0&&C.y!==void 0){const B={id:k,type:"position",position:{...C}};U.push(B)}if(Z.width!==void 0&&Z.height!==void 0){const P={id:k,type:"dimensions",resizing:!0,setAttributes:y?y==="horizontal"?"width":"height":!0,dimensions:{width:Z.width,height:Z.height}};U.push(P)}for(const B of re){const P={...B,type:"position"};U.push(P)}te(U)},onEnd:({width:Z,height:re})=>{const te={id:k,type:"dimensions",resizing:!1,dimensions:{width:Z,height:re}};b.getState().triggerNodeChanges([te])}})),X.current.update({controlPosition:G,boundaries:{minWidth:h,minHeight:p,maxWidth:x,maxHeight:v},keepAspectRatio:m,resizeDirection:y,onResizeStart:j,onResize:E,onResizeEnd:w,shouldResize:N}),()=>{var Z;(Z=X.current)==null||Z.destroy()}},[G,h,p,x,v,m,j,E,w,N]);const J=G.split("-");return d.jsx("div",{className:rt(["react-flow__resize-control","nodrag",...J,o,s]),ref:A,style:{...a,scale:V,...c&&{[$?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Pk);const Ik={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function Zl(t){return Ik[t]??8}const uc=208,cc=64,Rk=88,Tk=28,Lk=8;function Ak(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function $k(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const w of t){const M=Zl(w.type),k=s.get(M)??[];k.push(w),s.set(M,k)}const u=[...s.keys()].sort((w,M)=>w-M).map(w=>[...s.get(w)??[]].sort((M,k)=>M.name.localeCompare(k.name)||M.id.localeCompare(k.id))),c=new Set(t.map(w=>w.id)),h=new Map,p=new Map;for(const w of t)h.set(w.id,[]),p.set(w.id,[]);for(const w of r)!c.has(w.src)||!c.has(w.dst)||w.src===w.dst||(p.get(w.src).push(w.dst),h.get(w.dst).push(w.src));const x=new Map;u.forEach((w,M)=>{for(const k of w)x.set(k.id,M)});const v=new Map,m=()=>{for(const w of u)w.forEach((M,k)=>v.set(M.id,k))};m();const y=(w,M)=>{const k=w.map((b,A)=>{const $=M(b.id).map(X=>v.get(X)).filter(X=>X!==void 0),V=Ak($);return{n:b,bary:Number.isNaN(V)?A:V,name:b.name,id:b.id}});return k.sort((b,A)=>b.bary-A.bary||b.name.localeCompare(A.name)||b.id.localeCompare(A.id)),k.map(b=>b.n)},_=w=>M=>x.get(M)===w;for(let w=0;w(h.get(k)??[]).filter(_(M-1))),m();for(let M=u.length-2;M>=0;M--)u[M]=y(u[M],k=>(p.get(k)??[]).filter(_(M+1))),m()}const N=uc+Rk,j=cc+Tk,E=Math.max(...u.map(w=>w.length),1);return u.forEach((w,M)=>{const k=(E-w.length)*j/2;w.forEach((b,A)=>{o.set(b.id,{x:M*N,y:k+A*j})})}),o}const zk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),fm=90,Dk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),fp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Ok=Math.PI*(3-Math.sqrt(5)),hm=220,Fk=26,Hk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function pm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function PN(t){return fp[t]?fp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Bk(t){return t>=fm?"3d":"2d"}function Vk(t){return t>=fm?"overview":"full"}function Wk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(pm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Dk.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Wk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Yk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function Gk(t,r,o,s){const a=new Set(t.map(j=>j.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const j of r){if(!a.has(j.src)||!a.has(j.dst))continue;const E=u.get(j.src)??[];E.push({dst:j.dst,id:j.id}),u.set(j.src,E);const w=c.get(j.dst)??[];w.push({src:j.src,id:j.id}),c.set(j.dst,w)}const h=new Set(t.filter(j=>zk.has(j.type)).map(j=>j.id)),p=h.size?h:a,x=new Set,v=[o];for(;v.length;){const j=v.pop();if(!x.has(j)){x.add(j);for(const E of u.get(j)??[])x.has(E.dst)||v.push(E.dst)}}const m=new Set([o]),y=[...p].filter(j=>x.has(j)),_=new Set(y);for(;y.length;){const j=y.pop();m.add(j);for(const E of c.get(j)??[])x.has(E.src)&&!_.has(E.src)&&(_.add(E.src),y.push(E.src))}const N=new Set;for(const j of r)m.has(j.src)&&m.has(j.dst)&&N.add(j.id);return{nodeIds:m,edgeIds:N}}function IN(t){const r=new Map;for(const s of t){const a=Zl(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*hm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Fk*Math.sqrt(h+1),x=h*Ok;o.set(c.id,{x:u,y:p*Math.cos(x),z:p*Math.sin(x)})})}return o}function RN(t){const r=new Map;for(const o of t){const s=Zl(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*hm,count:s}))}const _l=16,Xk=12,qk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Kk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),hp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Qk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},pp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],gp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Zk=new Set(["looks_idempotent_on_pk","null","blank"]),Jk=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function eN(t){return hp[t]?hp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function tN(t,r,o){const s=new Map(r.map(y=>[y.id,y])),a=[];qk.has(t.type)&&a.push("sink"),Kk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(y=>y.dst===t.id),h=o.filter(y=>y.src===t.id),p=c.slice(0,_l).map(y=>Sl(y,s,y.src)),x=h.slice(0,_l).map(y=>Sl(y,s,y.dst)),v=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,m={type:t.type,typeLabel:Xo(to(t.type)),layer:Hk[Zl(t.type)]??"other",purpose:eN(t.type),name:t.name,qualifiedName:t.qualified_name,file:v,context:t.context,roles:a,facts:rN(u).filter(y=>!(y.key==="app"&&y.value===t.context)),inputs:p,outputs:x,extraInputs:Math.max(0,c.length-_l),extraOutputs:Math.max(0,h.length-_l),degreeIn:c.length,degreeOut:h.length,inputKinds:mp(c.map(y=>Sl(y,s,y.src))),outputKinds:mp(h.map(y=>Sl(y,s,y.dst))),pathSummary:""};return m.pathSummary=nN(m),m}function mp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function nN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function Sl(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Xo(to(s.type)):"",edgeType:t.type,edgeLabel:Xo(t.type),inferred:t.confidence<.8}}function rN(t){const r=[...pp.filter(a=>a in t),...Object.keys(t).filter(a=>!pp.includes(a)&&!gp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||gp.has(a)||Jk.has(a))continue;s.add(a);const u=iN(a,t[a]);u!=null&&o.push({key:a,label:Qk[a]??Xo(a),value:u})}return o}function iN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Zk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return oN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Xk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function oN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const sN=new Set,lN=L.lazy(()=>_0(()=>import("./LayeredGraph3D-DIo4wwkt.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),aN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function uN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(eo,{type:"target",position:Se.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:to(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Mr(t.name)}),d.jsx(eo,{type:"source",position:Se.Right,isConnectable:!1})]})}const cN={load:uN},dN=new Set(["django","react","stitch","arch"]);function fN({topologyKey:t}){const{fitView:r}=ql();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function hN(t,r,o=null,s={}){const a=new Map(t.map(p=>[p.id,p])),u=$k(t,r),c=t.map(p=>{var m;const x=((m=s.roles)==null?void 0:m[p.id])||[],v=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:p.id,type:"load",position:u.get(p.id)??{x:0,y:0},data:{name:p.name,type:p.type,file:p.file_path,roles:x,dim:v},selected:o===p.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:uc,height:cc,style:{width:uc,height:cc}}}),h=r.filter(p=>a.has(p.src)&&a.has(p.dst)).map(p=>{const x=aN[p.weight]||"var(--edge-cheap)",v=!!(o&&(p.src===o||p.dst===o));return{id:p.id,source:p.src,target:p.dst,type:"smoothstep",animated:p.weight==="critical",style:{stroke:x,strokeWidth:p.weight==="critical"?2.4:1.2,strokeDasharray:p.confidence<.8?"6 4":void 0},markerEnd:{type:ts.ArrowClosed,width:14,height:14,color:x},label:v?p.type.replaceAll("_"," "):void 0,labelStyle:v?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:v?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:v?[3,5]:void 0,labelBgBorderRadius:v?4:void 0}});return{rfNodes:c,rfEdges:h}}function pN({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:x}){const v=tN(t,r,o);return L.useEffect(()=>{const m=y=>{y.key==="Escape"&&s()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:v.typeLabel}),d.jsx("div",{className:"inspector-roles",children:v.roles.map(m=>d.jsx("span",{className:"inspector-chip",children:m},m))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Mr(v.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:v.purpose}),v.context?d.jsx("div",{className:"muted",children:Mr(v.context)}):null,v.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Mr(v.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Mr(v.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",v.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[v.degreeIn," in · ",v.degreeOut," out"]}),v.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:v.pathSummary}):null,v.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:v.facts.map(m=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:m.label}),d.jsx("dd",{children:Mr(m.value)})]},m.key))}):null,d.jsx(yp,{title:"Inputs",testId:"graph-inspector-inputs",links:v.inputs,extra:v.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(yp,{title:"Outputs",testId:"graph-inspector-outputs",links:v.outputs,extra:v.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",onClick:()=>a(t.id),children:"What if this changes"}):null,x?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",onClick:()=>x(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function yp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Mr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Mr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Uu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:x,repoPath:v,onOpenFile:m,pinnedId:y,onPin:_}){const[N,j]=L.useState(null),E=a!==void 0?a:N,w=ne=>{a===void 0&&j(ne),u==null||u(ne)},[M,k]=L.useState(null),[b,A]=L.useState(null),[$,V]=L.useState(new Set(dN)),[X,G]=L.useState(!1),[J,Z]=L.useState(""),[re,te]=L.useState(!1),I=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,W=M??Bk(t.length),H=b??Vk(t.length),U=X?E:null,C=L.useMemo(()=>p?Gk(t,r,p):null,[t,r,p]),D=C?t.filter(ne=>C.nodeIds.has(ne.id)):t,B=C?r.filter(ne=>C.edgeIds.has(ne.id)):r,P=L.useMemo(()=>Uk(D,B,{detail:H,families:$,focusId:U,neighborhoodOnly:!!U}),[D,B,H,$,U]),z=L.useMemo(()=>`${P.nodes.map(ne=>ne.id).join("\0")}|${P.edges.map(ne=>ne.id).join("\0")}`,[P.nodes,P.edges]),ie=E?t.find(ne=>ne.id===E)??null:null,{rfNodes:oe,rfEdges:de}=L.useMemo(()=>{const ne=hN(P.nodes,P.edges,E,{roles:c,testOverlay:h});return I&&(ne.rfEdges=ne.rfEdges.map(Ne=>({...Ne,animated:!1}))),ne},[P.nodes,P.edges,E,I,c,h]);L.useEffect(()=>{if(!s)return;const ne=t.find(Ne=>Ne.file_path===s);ne&&w(ne.id)},[s,t]);const pe=L.useMemo(()=>Yk(t,J),[t,J]),he=(ne,Ne)=>{w(Ne.id)},Q=()=>{w(null),G(!1)},ae=ie?d.jsx(pN,{node:ie,nodes:t,edges:r,onClose:Q,onWhatIf:o,onSelect:w,onOpenFile:m,pinned:y===ie.id,onPin:_,onIsolate:x?ne=>{x(p===ne?null:ne)}:void 0}):null,me=ne=>{V(Ne=>{const Me=new Set(Ne);if(Me.has(ne)){if(Me.size===1)return Ne;Me.delete(ne)}else Me.add(ne);return Me})},ke=L.useMemo(()=>{const ne=new Set;for(const Ne of t)ne.add(pm(Ne.type));return ne},[t]),ve=t.length-P.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:W==="2d"?"active":"","aria-pressed":W==="2d",onClick:()=>k("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:W==="3d"?"active":"","aria-pressed":W==="3d",onClick:()=>k("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:H==="overview"?"active":"","aria-pressed":H==="overview",onClick:()=>A("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:H==="full"?"active":"","aria-pressed":H==="full",onClick:()=>A("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(ne=>ke.has(ne)).map(ne=>d.jsx("button",{type:"button","data-testid":`graph-family-${ne}`,className:$.has(ne)?"active":"","aria-pressed":$.has(ne),onClick:()=>me(ne),children:ne},ne))}),d.jsx("button",{type:"button",className:X?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!E,onClick:()=>G(ne=>!ne),children:X?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>x==null?void 0:x(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:J,onChange:ne=>{Z(ne.target.value),te(!0)},onFocus:()=>te(!0),onBlur:()=>window.setTimeout(()=>te(!1),150)}),re&&J.trim()&&pe.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:pe.map(ne=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:Ne=>Ne.preventDefault(),onClick:()=>{w(ne.id),Z(""),te(!1)},children:[ne.name,d.jsx("span",{className:"muted",children:to(ne.type)})]})},ne.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[P.nodes.length," nodes · ",P.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:W==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(lN,{nodes:P.nodes,edges:P.edges,selectedId:E,neighborIds:U?P.neighborIds:sN,onSelect:ne=>{w(ne),ne||G(!1)}})}),ae]}):d.jsxs(am,{children:[d.jsxs(tk,{nodes:oe,edges:de,nodeTypes:cN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:he,onPaneClick:Q,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(fN,{topologyKey:z}),d.jsx(sk,{}),d.jsx(Ek,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(hk,{})]}),ae]})})]})}function gm(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function gN(t){localStorage.setItem("loadpath.editor",t)}async function mN(t,r,o,s=gm()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const vp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],yN=["preset","branch","tag","commit"];function vN(t){var a;if(!(t!=null&&t.git))return[...vp];const r=((a=t.presets)!=null&&a.length?t.presets:vp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function xN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function wN(t){return yN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function _N(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function xp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[x,v]=L.useState(!1),[m,y]=L.useState(null),[_,N]=L.useState(0),j=L.useMemo(()=>{const b=vN(u);return m===null?b:xN(b,m)},[u,m]),E=L.useMemo(()=>wN(j),[j]);L.useEffect(()=>{x&&c()},[x,c]),L.useEffect(()=>{N(0)},[m,x]);const w=()=>{v(!1),y(null)},M=b=>{r(b.value),w()},k=b=>{if(b.key==="ArrowDown"){if(b.preventDefault(),!x){v(!0);return}N(A=>Math.min(A+1,Math.max(j.length-1,0)))}else if(b.key==="ArrowUp"){if(b.preventDefault(),!x)return;N(A=>Math.max(A-1,0))}else if(b.key==="Enter"&&x){b.preventDefault();const A=j[_];A&&M(A)}else b.key==="Escape"&&x&&(b.preventDefault(),w())};return d.jsxs("div",{className:"combo",ref:p,onBlur:b=>{b.currentTarget.contains(b.relatedTarget)||w()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":x,"aria-controls":h,"aria-autocomplete":"list",onChange:b=>{r(b.target.value),x&&y(b.target.value)},onKeyDown:k}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":x,onMouseDown:b=>b.preventDefault(),onClick:()=>x?w():v(!0),children:d.jsx(v0,{})})]}),x?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:E.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):E.map(b=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:_N(b.group)}),b.items.map(A=>{const $=j.indexOf(A);return d.jsxs("button",{type:"button",role:"option","aria-selected":$===_,className:$===_?"combo-option active":"combo-option","data-testid":`ref-option-${A.group}`,onMouseDown:V=>V.preventDefault(),onMouseEnter:()=>N($),onClick:()=>M(A),children:[d.jsx("span",{className:"combo-label",children:A.label}),A.detail?d.jsx("span",{className:"combo-detail",children:A.detail}):null]},`${A.group}:${A.value}`)})]},b.group))}):null]})}function SN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[x,v]=L.useState(""),[m,y]=L.useState(!1),_=L.useRef(null),N=L.useRef(0),j=async k=>{const b=N.current+1;N.current=b,y(!0);try{const A=await Pe.browse(k);if(N.current!==b)return;a(A),c(A.path),p(A.is_git?A.path:null),v("")}catch(A){if(N.current!==b)return;v(A instanceof Error?A.message:String(A))}finally{N.current===b&&y(!1)}};L.useEffect(()=>{var k,b;j(t),(k=_.current)==null||k.focus(),(b=_.current)==null||b.select()},[t]);const E=h||(s==null?void 0:s.path)||u,w=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",M=k=>{k.key==="Escape"&&(k.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:M,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:k=>k.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:k=>{k.preventDefault(),j(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:k=>c(k.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),x?d.jsx("div",{className:"error",role:"alert",children:x}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":m,children:s!=null&&s.entries.length?s.entries.map(k=>{const b=h===k.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":b,className:b?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":k.path,onClick:()=>p(k.path),onDoubleClick:()=>void j(k.path),children:[d.jsx(kp,{}),d.jsx("span",{className:"explorer-name",children:k.name}),k.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},k.path)}):d.jsx("div",{className:"muted explorer-empty",children:m?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:E,children:E}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!E,onClick:()=>E&&r(E),children:["Use ",w]})]})]})})}const Dl=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],kN="obsidian",mm="loadpath.theme";function NN(t){return Dl.some(r=>r.id===t)}function ym(){try{const t=localStorage.getItem(mm)||"";if(NN(t))return t}catch{}return kN}function jN(t){var r;return((r=Dl.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function vm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=jN(t);try{localStorage.setItem(mm,t)}catch{}}const Yu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:h0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:p0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:g0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:m0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:y0}];function bN(t){const r=t.total||0;return r<=0?null:Math.min(100,Math.round(100*(t.done||0)/r))}function Gu(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function EN(){var Fr,In,Rn,_i,Un,De,lo,ao;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,x]=L.useState(null),[v,m]=L.useState(null),[y,_]=L.useState([]),[N,j]=L.useState("review"),[E,w]=L.useState(""),[M,k]=L.useState(""),[b,A]=L.useState(null),[$,V]=L.useState(!1),[X,G]=L.useState(""),[J,Z]=L.useState({}),[re,te]=L.useState([]),[I,W]=L.useState([]),[H,U]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[C,D]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[B,P]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[z,ie]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[oe,de]=L.useState(0),[pe,he]=L.useState(""),[Q,ae]=L.useState(ym),[me,ke]=L.useState(!1),[ve,ne]=L.useState(!1),[Ne,Me]=L.useState(!1),[Re,Le]=L.useState(null),[Ze,pt]=L.useState(null),[Xe,it]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[on,Mt]=L.useState(null),[ot,dt]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[gt,mt]=L.useState([]),[Pt,kn]=L.useState(null),[sn,qt]=L.useState(null),[no,rr]=L.useState(null),[ui,ci]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[ir,Nn]=L.useState(null),[Nt,jn]=L.useState(null),[bn,It]=L.useState(!1),[Ft,En]=L.useState(!1),yt=L.useRef(o);yt.current=o;const Rr=L.useRef(!1);Rr.current=ve;const Ht=L.useRef(""),Tr=R=>{ae(R),vm(R)},tt=L.useRef(""),He=R=>{tt.current=R,k(R)},ln=R=>{const Y=()=>{Pe.indexProgress(R).then(Ee=>{tt.current&&(Ee.phase&&Ee.phase!=="idle"&&Ee.message&&He(Ee.message),A(Ee.phase&&Ee.phase!=="idle"?bN(Ee):null))}).catch(()=>{})};Y();const fe=window.setInterval(Y,250);return()=>{window.clearInterval(fe),A(null)}};L.useEffect(()=>{Pe.settings().then(Z).catch(()=>{}).finally(()=>ke(!0)),Pe.repos().then(R=>_(R.repos)).catch(()=>{})},[]);const Hn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const R=o;let Y=!1;return Pe.architecture(R).then(fe=>{!Y&&yt.current===R&&m(fe)}).catch(()=>{}),Pe.config(R).then(fe=>{!Y&&yt.current===R&&qt(fe)}).catch(()=>{}),Pe.architectureHealth(R).then(fe=>{!Y&&yt.current===R&&rr(fe)}).catch(()=>{}),()=>{Y=!0}},[t,o]);const jt=R=>{yt.current=R,s(R),localStorage.setItem("loadpath.repo",R),R.trim()!==Ht.current&&(Ht.current="",Nn(null))},Lr=L.useCallback(R=>{const Y=(R??yt.current).trim();return!Y||Ht.current===Y?Promise.resolve():(Ht.current=Y,Pe.gitRefs(Y).then(fe=>{yt.current.trim()===Y&&Nn(fe)}).catch(()=>{Ht.current===Y&&(Ht.current="",Nn(null))}))},[]),bt=(R,Y)=>{u(R),h(Y),localStorage.setItem("loadpath.base",R),localStorage.setItem("loadpath.head",Y)},Cn=(R,Y,fe)=>{D(R),U(Y),localStorage.setItem("loadpath.provider",R),localStorage.setItem("loadpath.scmRepo",Y),fe!==void 0&&(P(fe),localStorage.setItem("loadpath.prNumber",fe))},Kt=R=>{x(R),de(0),Le(Ze&&R.nodes.some(Y=>Y.id===Ze)?Ze:null),Mt(null),kn(null),R.id&&!R.what_if&&localStorage.setItem("loadpath.lastReviewId",R.id)},Bn=async R=>{try{const Y=await Pe.reviews(R);mt(Y.reviews)}catch{mt([])}},di=async R=>{try{rr(await Pe.architectureHealth(R))}catch{rr(null)}},ro=R=>R==="github"?!!J.github_token_set:R==="gitlab"?!!J.gitlab_token_set:!!J.bitbucket_token_set,Bt=L.useCallback(async(R=C)=>{var Y;try{const fe=await Pe.scmRepos(R);W(fe.repos),(Y=fe.user)!=null&&Y.login&&Z(Ee=>({...Ee,...R==="github"?{github_user:fe.user.login}:R==="gitlab"?{gitlab_user:fe.user.login}:{bitbucket_user:fe.user.login}}))}catch{W([])}},[C]);L.useEffect(()=>{if(t!=="prs")return;let R=!1;return Bt(C).catch(()=>{R||W([])}),()=>{R=!0}},[t,C,Bt]),L.useEffect(()=>{if(!Nt)return;let R=!1,Y=0;const fe=async()=>{try{const Ee=await Pe.githubOAuthPoll(Nt.flow_id);if(R)return;if(Ee.status==="complete"){jn(null);const Ae=await Pe.settings();Z(Ae),G(Ee.user?`Signed in to GitHub as ${Ee.user}`:"Signed in to GitHub"),Bt("github");return}if(Ee.status==="pending"||Ee.status==="slow_down"){Y=window.setTimeout(fe,Math.max(Ee.interval||Nt.interval,5)*1e3);return}jn(null),w(Ee.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(Ee){if(R)return;jn(null),w(Ee instanceof Error?Ee.message:String(Ee))}};return Y=window.setTimeout(fe,Math.max(Nt.interval,5)*1e3),()=>{R=!0,window.clearTimeout(Y)}},[Nt,Bt]),L.useEffect(()=>{if(!bn)return;let R=!1,Y=0;const fe=Date.now(),Ee=async()=>{try{const Ae=await Pe.oauthStatus();if(R)return;if(Ae.bitbucket.connected){It(!1);const Fe=await Pe.settings();Z(Fe),G(Ae.bitbucket.user?`Signed in to Bitbucket as ${Ae.bitbucket.user}`:"Signed in to Bitbucket"),Bt("bitbucket");return}if(Date.now()-fe>18e4){It(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(Ee,1500)}catch(Ae){if(R)return;It(!1),w(Ae instanceof Error?Ae.message:String(Ae))}};return Y=window.setTimeout(Ee,1500),()=>{R=!0,window.clearTimeout(Y)}},[bn,Bt]),L.useEffect(()=>{if(!Ft)return;let R=!1,Y=0;const fe=Date.now(),Ee=async()=>{try{const Ae=await Pe.oauthStatus();if(R)return;if(Ae.gitlab.connected){En(!1);const Fe=await Pe.settings();Z(Fe),G(Ae.gitlab.user?`Signed in to GitLab as ${Ae.gitlab.user}`:"Signed in to GitLab"),Bt("gitlab");return}if(Date.now()-fe>18e4){En(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(Ee,1500)}catch(Ae){if(R)return;En(!1),w(Ae instanceof Error?Ae.message:String(Ae))}};return Y=window.setTimeout(Ee,1500),()=>{R=!0,window.clearTimeout(Y)}},[Ft,Bt]);const Rt=async(R=o)=>{if(!R.trim())return null;const Y=await Pe.architecture(R);return yt.current===R&&m(Y),Y},or=async R=>{const Y=R.trim();if(!(!Y||Y===yt.current)){if(tt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),G(""),x(null),m(null),j("architecture"),jt(Y),V(!0),He(`Loading ${f0(Y)}…`);try{await Promise.all([Rt(Y),Lr(Y)])}catch(fe){yt.current===Y&&w(fe instanceof Error?fe.message:String(fe))}finally{yt.current===Y&&(He(""),V(!1))}}},an=async()=>{if(tt.current||!Hn())return;w(""),G(""),He("Tracing load path…"),jt(o),bt(a,c);const R=ln(o);try{const Y=await Pe.review(o,a,c,!0,z);Kt(Y),j("review"),r("review"),await Pe.repos().then(fe=>_(fe.repos)).catch(()=>{}),await Promise.all([Rt(o),Bn(o),di(o)])}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{R(),He("")}},Ar=async(R=!0)=>{if(tt.current||!Hn())return;w(""),G(""),He(R?"Indexing…":"Full reindex…"),jt(o);const Y=ln(o);try{await Pe.index(o,R);const fe=await Rt(o);await Pe.repos().then(Ee=>_(Ee.repos)).catch(()=>{}),fe!=null&&fe.indexed&&(j("architecture"),r("architecture"))}catch(fe){w(fe instanceof Error?fe.message:String(fe))}finally{Y(),He("")}},fi=async()=>{if(!tt.current&&Hn()){w(""),G(""),He("Detecting layout…"),jt(o);try{const R=await Pe.init(o);G(R.message),await Pe.repos().then(Y=>_(Y.repos)).catch(()=>{})}catch(R){w(R instanceof Error?R.message:String(R))}finally{He("")}}},hi=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),G("Copied markdown brief")}catch(R){w(R instanceof Error?R.message:String(R))}},pi=async()=>{if(!tt.current){if(!(p!=null&&p.markdown)||!H||!B){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const R=await Pe.postComment(C,H,Number(B),p.markdown);G(R.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(R){w(R instanceof Error?R.message:String(R))}finally{He("")}}},gi=async()=>{if(!tt.current){w(""),He("Fetching pull requests…");try{const R=await Pe.prs(C,H,"open",o.trim()||void 0);te(R.pull_requests);const Y=I.find(fe=>fe.slug.toLowerCase()===H.trim().toLowerCase());Y!=null&&Y.local_path&&jt(Y.local_path)}catch(R){w(R instanceof Error?R.message:String(R))}finally{He("")}}},io=async()=>{w("");try{const R=await Pe.githubOAuthStart();jn(R),Gu(R.verification_uri_complete,"github.com","/login/device")}catch(R){w(R instanceof Error?R.message:String(R))}},mi=async()=>{w("");try{const R=await Pe.bitbucketOAuthStart();It(!0),Gu(R.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(R){It(!1),w(R instanceof Error?R.message:String(R))}},Ve=async()=>{w("");try{const R=await Pe.gitlabOAuthStart();En(!0),Gu(R.authorize_url,new URL(R.authorize_url).hostname,"/oauth/authorize")}catch(R){En(!1),w(R instanceof Error?R.message:String(R))}},$r=async R=>{if(!(tt.current||!o.trim())){w(""),He("Walking what-if path…");try{const Y=await Pe.whatIf(o,R);G(`${Y.title} — ${Y.confidence.level} · ${(Y.sinks||[]).length} sinks`),Kt({...Y,markdown:Y.markdown||"",index:Y.index||(p==null?void 0:p.index),workspace:Y.workspace||(p==null?void 0:p.workspace)}),j("review"),r("review")}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},zr=async R=>{var Ae;if(tt.current)return;Cn(R.provider,R.repo,String(R.number));const Y=I.find(Fe=>Fe.slug.toLowerCase()===R.repo.toLowerCase());Y!=null&&Y.local_path&&jt(Y.local_path),w(""),He(`Fetching ${R.provider} #${R.number}…`);const fe=(Y==null?void 0:Y.local_path)||o,Ee=fe?ln(fe):()=>{};try{const Fe=await Pe.reviewPr(R.provider,R.repo,R.number,(Y==null?void 0:Y.local_path)||o||void 0);Kt(Fe),Fe.pull_request&&typeof Fe.pull_request.repo_path=="string"&&jt(Fe.pull_request.repo_path),bt(String(Fe.base||R.target_branch),String(Fe.head||R.source_branch)),j("review"),r("review"),typeof((Ae=Fe.pull_request)==null?void 0:Ae.repo_path)=="string"&&Bn(Fe.pull_request.repo_path)}catch(Fe){bt(R.base_sha||R.target_branch,R.head_sha||R.source_branch),r("review"),w(Fe instanceof Error?Fe.message:String(Fe))}finally{Ee(),He("")}},sr=async R=>{w("");try{Z(await Pe.oauthDisconnect(R)),C===R&&W([]),G(`Disconnected ${R}`)}catch(Y){w(Y instanceof Error?Y.message:String(Y))}},lr=async R=>{R.preventDefault();const Y=new FormData(R.currentTarget),fe={github_token:String(Y.get("github_token")||""),github_oauth_client_id:String(Y.get("github_oauth_client_id")||""),github_host:String(Y.get("github_host")||""),gitlab_token:String(Y.get("gitlab_token")||""),gitlab_host:String(Y.get("gitlab_host")||""),gitlab_oauth_client_id:String(Y.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(Y.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(Y.get("bitbucket_token")||""),bitbucket_username:String(Y.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(Y.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(Y.get("bitbucket_oauth_client_secret")||""),ai_provider:String(Y.get("ai_provider")||"none"),ai_api_key:String(Y.get("ai_api_key")||""),ai_model:String(Y.get("ai_model")||""),ai_base_url:String(Y.get("ai_base_url")||"")},Ee=y.length?{...fe,workspaces:y.map(Ae=>({path:Ae.path,name:Ae.name}))}:fe;try{Z(await Pe.saveSettings(Ee)),G("Settings saved on this machine")}catch(Ae){w(Ae instanceof Error?Ae.message:String(Ae))}},oo=async()=>{if(!(!p||tt.current)){He("Residual analysis…");try{const R=await Pe.residual(p);he(R.note)}catch(R){w(R instanceof Error?R.message:String(R))}finally{He("")}}},ar=L.useRef(an);ar.current=an;const Mn=L.useRef(t);Mn.current=t;const vt=L.useRef(!1);vt.current=Ne;const yi=L.useRef(p);yi.current=p;const xt=L.useRef(oe);xt.current=oe,L.useEffect(()=>{const R=localStorage.getItem("loadpath.lastReviewId"),Y=(localStorage.getItem("loadpath.repo")||"").trim();if(!R||!Y){ci(!1);return}let fe=!1;return Pe.getReview(Y,R).then(Ee=>{fe||(Kt(Ee),bt(Ee.base||localStorage.getItem("loadpath.base")||"HEAD~1",Ee.head||localStorage.getItem("loadpath.head")||"HEAD"),Bn(Y),di(Y))}).catch(()=>{}).finally(()=>{fe||ci(!1)}),()=>{fe=!0}},[]);const Dr=L.useRef("");L.useEffect(()=>{if(!ot||!o.trim())return;let R=!1;const Y=async()=>{try{const Ee=await Pe.workspaceStatus(o);if(R)return;Dr.current&&Ee.fingerprint!==Dr.current&&!tt.current&&(ie(!0),localStorage.setItem("loadpath.dirty","1"),ar.current()),Dr.current=Ee.fingerprint}catch{}};Y();const fe=window.setInterval(Y,2e3);return()=>{R=!0,window.clearInterval(fe)}},[ot,o]),L.useEffect(()=>{const R=Y=>{var Ae;if((Y.metaKey||Y.ctrlKey)&&Y.key.toLowerCase()==="k"){Y.preventDefault(),Me(Fe=>!Fe);return}if(vt.current){Y.key==="Escape"&&(Y.preventDefault(),Me(!1));return}if(Rr.current){Y.key==="Escape"&&(Y.preventDefault(),ne(!1));return}const fe=Y.target;if(fe&&(fe.tagName==="INPUT"||fe.tagName==="TEXTAREA"||fe.tagName==="SELECT"||fe.isContentEditable)){Y.key==="Escape"&&fe.blur();return}if(Y.key==="Escape"){w(""),G(""),Le(Ze),Mt(null);return}if(Y.key==="j"||Y.key==="k"){const Fe=((Ae=yi.current)==null?void 0:Ae.read_order)||[];if(!Fe.length)return;Y.preventDefault();const un=xt.current,Tn=Y.key==="j"?Math.min(Fe.length-1,un+1):Math.max(0,un-1);de(Tn);return}const Ee=Yu.find(Fe=>Fe.shortcut===Y.key);if(Ee&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey&&r(Ee.id),(Y.metaKey||Y.ctrlKey)&&Y.key==="Enter"){if(Mn.current==="settings"||Mn.current==="prs"||tt.current)return;Y.preventDefault(),ar.current()}};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[Ze]);const vi=async(R,Y)=>{if(!o.trim())return;const fe=await mN(o,R,Y);fe.ok?G(fe.message):w(fe.message)},xi=async()=>{if(p)try{const R=await Pe.exportHtml(p),Y=URL.createObjectURL(R),fe=document.createElement("a");fe.href=Y,fe.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,fe.click(),URL.revokeObjectURL(Y),G("Saved HTML brief")}catch(R){w(R instanceof Error?R.message:String(R))}},Vn=async R=>{if(o.trim()){He("Loading stored review…");try{const Y=await Pe.getReview(o,R);Kt(Y),bt(Y.base||a,Y.head||c),j("review"),r("review");const fe=gt.find(Ee=>Ee.id!==R);if(fe)try{kn(await Pe.reviewDiff(o,R,fe.id))}catch{kn(null)}}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},Pn={selectedId:Re,onSelect:Le,nodeRoles:p==null?void 0:p.node_roles,testOverlay:Xe,isolateSource:on,onIsolate:Mt,repoPath:o,onOpenFile:vi,pinnedId:Ze,onPin:pt},Wn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void an()},{id:"index",group:"Run",label:"Index repository",run:()=>void Ar(!0)},{id:"watch",group:"Run",label:ot?"Stop watching working tree":"Watch working tree",run:()=>{const R=!ot;dt(R),localStorage.setItem("loadpath.watch",R?"1":"0")}},{id:"tests",group:"Graph",label:Xe?"Hide test overlay":"Show test overlay",run:()=>{const R=!Xe;it(R),localStorage.setItem("loadpath.testOverlay",R?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void xi()},...Yu.map(R=>({id:`tab-${R.id}`,group:"Tabs",label:`Go to ${R.label}`,hint:R.shortcut,run:()=>r(R.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(R=>({id:`node-${R.id}`,group:"Nodes",label:R.name,hint:to(R.type),run:()=>{Le(R.id),r("graph")}})),...gt.slice(0,12).map(R=>({id:`hist-${R.id}`,group:"History",label:R.title||R.id,hint:`${R.level||""} ${R.created_at||""}`.trim(),run:()=>void Vn(R.id)}))],Qt=L.useMemo(()=>N==="architecture"?(v==null?void 0:v.nodes)??[]:(p==null?void 0:p.nodes)??[],[N,v,p]),so=L.useMemo(()=>N==="architecture"?(v==null?void 0:v.edges)??[]:(p==null?void 0:p.edges)??[],[N,v,p]),wi=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:v!=null&&v.indexed?`${v.counts.nodes} nodes · ${v.counts.edges} edges`:"Not indexed",Or=((p==null?void 0:p.findings)||[]).filter(R=>!R.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Yu.map(R=>{const Y=R.icon,fe=t===R.id;return d.jsxs("button",{type:"button","data-testid":R.testId,className:fe?"nav-item active":"nav-item","aria-current":fe?"page":void 0,"aria-label":R.label,onClick:()=>r(R.id),children:[d.jsx(Y,{}),d.jsx("span",{children:R.label})]},R.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:Q,onChange:R=>Tr(R.target.value),children:["dark","light"].map(R=>d.jsx("optgroup",{label:R==="dark"?"Dark":"Light",children:Dl.filter(Y=>Y.group===R).map(Y=>d.jsx("option",{value:Y.id,children:Y.label},Y.id))},R))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:M||wi}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[M?d.jsxs("div",{className:b!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","data-testid":"progress",children:[d.jsx("i",{style:b!=null?{width:`${b}%`}:void 0}),d.jsx("span",{className:"sr-only",children:M})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[y.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:y.some(R=>R.path===o)?o:"",disabled:!!M,"aria-busy":$,onChange:R=>{R.target.value&&or(R.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),y.map(R=>d.jsxs("option",{value:R.path,children:[R.name,R.indexed?` (${R.counts.nodes})`:""]},R.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:R=>{const Y=R.target.value;s(Y),Y.trim()!==Ht.current&&(Ht.current="",Nn(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>ne(!0),children:d.jsx(kp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(xp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:R=>bt(R,c),placeholder:"base",refs:ir,onNeedRefs:Lr})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(xp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:R=>bt(a,R),placeholder:"head",refs:ir,onNeedRefs:Lr})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:z?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":z,onClick:()=>{const R=!z;ie(R),localStorage.setItem("loadpath.dirty",R?"1":"0")},children:z?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:ot?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":ot,onClick:()=>{const R=!ot;dt(R),localStorage.setItem("loadpath.watch",R?"1":"0")},children:ot?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!M,onClick:fi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!M,onClick:()=>Ar(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!M,onClick:an,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[E?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:E}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,X?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:X}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>G(""),"aria-label":"Dismiss",children:"×"})]}):null,((Fr=p==null?void 0:p.index)!=null&&Fr.stale||v!=null&&v.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((In=p==null?void 0:p.index)==null?void 0:In.django_boot)==="failed"||(v==null?void 0:v.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Rn=p==null?void 0:p.index)==null?void 0:Rn.django_boot_detail)||(v==null?void 0:v.django_boot_detail)||"django.setup() failed"}):null,(_i=p==null?void 0:p.workspace)!=null&&_i.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null]}),d.jsxs("div",{className:"stage","aria-busy":$,children:[$?d.jsxs("div",{className:"empty workspace-loading","data-testid":"workspace-loading",children:[d.jsx("h2",{children:M}),d.jsx("p",{children:"Fetching the indexed graph for this repository."})]}):null,!$&&t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(CN,{review:p,findings:Or,aiNote:pe,busy:!!M,tourIndex:oe,onTour:de,onAskAi:oo,onCopy:hi,onPost:pi,onSelect:Le,onOpenFile:vi,onExport:xi,history:gt,diff:Pt,onReopen:Vn,onWaiver:(R,Y)=>{o.trim()&&Pe.addWaiver(o,R,Y||void 0,"from review").then(fe=>{qt(fe),G(`Waived ${R} in loadpath.yml`)})}}):ui?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Uu,{nodes:p.nodes,edges:p.edges,onWhatIf:$r,focusPath:(Un=p.read_order[oe])==null?void 0:Un.path,...Pn}):null})]}),!$&&t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:v!=null&&v.indexed?d.jsx(MN,{architecture:v,busy:!!M,onReindex:()=>Ar(!1),onReview:an,onSelect:Le,config:sn,health:no,onSaveConfig:R=>{Pe.saveConfig(o,R).then(Y=>{qt(Y),G("Wrote loadpath.yml")})},onWaiver:(R,Y,fe)=>{Pe.addWaiver(o,R,Y,fe).then(Ee=>{qt(Ee),G(`Waived ${R}`)})}}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:v!=null&&v.indexed?d.jsx(Uu,{nodes:v.nodes,edges:v.edges,onWhatIf:$r,...Pn,isolateSource:null,onIsolate:void 0}):null})]}),!$&&t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":N==="review","data-testid":"graph-mode-review",className:N==="review"?"active":"",onClick:()=>j("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":N==="architecture","data-testid":"graph-mode-architecture",className:N==="architecture"?"active":"",onClick:()=>j("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:Xe?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":Xe,onClick:()=>{const R=!Xe;it(R),localStorage.setItem("loadpath.testOverlay",R?"1":"0")},children:"Tests"})]}),Qt.length?d.jsx(Uu,{nodes:Qt,edges:so,onWhatIf:$r,...Pn}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),!$&&t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:C,onChange:R=>Cn(R.target.value,H,B),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:I.length?"Search your repos":"owner/repo",value:H,onChange:R=>Cn(C,R.target.value,B),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:I.map(R=>d.jsxs("option",{value:R.slug,children:[R.private?"private":"public",R.local_path?" · local":""]},R.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!M||!ro(C),onClick:()=>{Bt(C)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!M,onClick:gi,children:"List PRs"})]}),I.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[I.length," ",C," repositor",I.length===1?"y":"ies",C==="github"&&J.github_user?` · @${String(J.github_user)}`:"",C==="gitlab"&&J.gitlab_user?` · @${String(J.gitlab_user)}`:"",C==="bitbucket"&&J.bitbucket_user?` · ${String(J.bitbucket_user)}`:""]}):null,re.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):re.map(R=>{var Y;return d.jsxs("article",{className:"pr","data-testid":`pr-${R.number}`,children:[d.jsxs("h3",{children:["#",R.number," ",R.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${R.draft?"":"open"}`,children:R.draft?"draft":R.state}),d.jsx("span",{children:R.author}),d.jsxs("span",{children:[R.source_branch," → ",R.target_branch]}),R.loadpath?d.jsxs("span",{className:`chip ${R.loadpath.level||""}`,"data-testid":`pr-loadpath-${R.number}`,children:[((Y=R.loadpath.level)==null?void 0:Y.toUpperCase())||"REVIEWED",R.loadpath.contract_break&&R.loadpath.contract_break!=="none"?` · ${R.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:R.url,target:"_blank",rel:"noreferrer",children:["Open on ",R.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${R.number}`,onClick:()=>void zr(R),children:"Review this PR"})]})]},`${R.provider}-${R.number}`)})]}),!$&&t==="settings"&&me&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:lr,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Dl.map(R=>d.jsxs("button",{type:"button","data-theme":R.id,className:Q===R.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${R.id}`,onClick:()=>Tr(R.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:R.label}),d.jsx("div",{className:"group",children:R.group})]},R.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:gm(),onChange:R=>gN(R.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:J.github_token_set?J.github_user?`Signed in as @${String(J.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:J.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void sr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!Nt||!J.github_oauth_ready,onClick:()=>void io(),children:Nt?"Waiting for GitHub…":"Sign in with GitHub"})})]}),Nt?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:Nt.user_code})," at GitHub if the browser did not fill it in."]}):null,J.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(J.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(J.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:J.gitlab_token_set?J.gitlab_user?`Signed in as @${String(J.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:J.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void sr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Ft||!J.gitlab_oauth_ready,onClick:()=>void Ve(),children:Ft?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(J.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(J.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:J.bitbucket_token_set?J.bitbucket_user?`Signed in as ${String(J.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:J.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void sr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:bn||!J.bitbucket_oauth_ready,onClick:()=>void mi(),children:bn?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),J.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(J.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(J.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((De=J.ai)==null?void 0:De.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((lo=J.ai)==null?void 0:lo.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((ao=J.ai)==null?void 0:ao.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(u0,{open:Ne,actions:Wn,onClose:()=>Me(!1)}),ve?d.jsx(SN,{initialPath:o,onClose:()=>ne(!1),onSelect:R=>{if(tt.current){w("Wait for the current job to finish before switching workspace.");return}ne(!1),or(R)}}):null]})}function CN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:x,onOpenFile:v,onExport:m,history:y,diff:_,onReopen:N,onWaiver:j}){var w,M,k,b,A,$,V,X,G,J,Z,re,te,I,W,H,U;const E=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),E.length?d.jsx("ul",{className:"reasons",children:E.map(C=>d.jsx("li",{children:C},C))}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(C=>d.jsx("span",{className:"chip",children:Xo(C)},C)),(w=t.contract_break)!=null&&w.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(C=>C.status==="todo").length})]}),(t.checklist||[]).map(C=>d.jsxs("div",{className:`check-item ${C.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>C.node_id&&x(C.node_id),children:[d.jsx("span",{className:`chip ${C.status}`,children:C.status}),C.title]}),C.detail?d.jsx("div",{className:"why",children:C.detail}):null,C.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(C.body||"")},children:"Copy test"}):null,C.kind==="finding"&&C.status==="todo"&&C.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>j(C.rule,C.node_id),children:"Waive in loadpath.yml"}):null]},C.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(M=t.workspace)!=null&&M.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((C,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",C.path]}),d.jsx("div",{className:"why",children:C.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>v(C.path),children:"Open"})]},C.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(C=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:C.title})," — ",C.files.join(", ")]},C.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(C=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>C.node_id&&x(C.node_id),children:[d.jsx("span",{className:`chip ${C.severity}`,children:C.severity}),C.message]})},C.rule+C.message))]}),d.jsx(xm,{cards:t.deepening}),(b=(k=t.contract_break)==null?void 0:k.reasons)!=null&&b.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(C=>d.jsx("div",{className:"muted",children:C},C)),($=(A=t.contract_break.sides)==null?void 0:A.rows)!=null&&$.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(C=>d.jsxs("tr",{className:C.status,children:[d.jsx("td",{children:C.field}),d.jsx("td",{children:C.serializer?"yes":"—"}),d.jsx("td",{children:C.zod?"yes":"—"}),d.jsx("td",{children:C.graphql?"yes":"—"})]},C.field))})]}):null]}):null,(V=t.auth)!=null&&V.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(C=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),C.name]},C.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(X=t.suggested_tests)==null?void 0:X.length})]}),(t.suggested_tests||[]).map(C=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:C.title}),d.jsx("pre",{className:"headline",children:C.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(C.body)},children:"Copy sketch"})]},C.title))]}):null,(G=t.trend)!=null&&G.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(C=>d.jsxs("div",{className:"muted",children:[C.level," · ",Xu(C.created_at),C.sinks!=null?` · ${C.sinks} sinks`:""]},C.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(C=>d.jsx("div",{className:"residual muted",children:C},C))]}),y.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:y.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,y.slice(0,12).map(C=>d.jsxs("button",{type:"button",className:C.id===t.id?"history-item current":"history-item",onClick:()=>N(C.id),children:[d.jsx("span",{className:`chip ${C.level||""}`,children:C.level||"walk"}),C.title||C.id.slice(0,8),d.jsx("span",{className:"muted",children:C.created_at?Xu(C.created_at):""})]},C.id))]}):null,(Z=(J=t.evolution)==null?void 0:J.notes)!=null&&Z.length||(te=(re=t.evolution)==null?void 0:re.hotspots)!=null&&te.some(C=>C.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((I=t.evolution)==null?void 0:I.notes)||[]).map(C=>d.jsx("div",{className:"muted",children:C},C)),(((W=t.evolution)==null?void 0:W.hotspots)||[]).filter(C=>C.commits).slice(0,6).map(C=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:C.path})," — ",C.commits," commits, bus factor ",C.bus_factor]},C.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:m,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(H=t.codeowners_reviewers)!=null&&H.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function MN({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var v;const x=t.findings.filter(m=>!m.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${Xu(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(m=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:m.name})," — ",(m.django_apps||[]).join(", ")||"no apps"," ·"," ",(m.owners||[]).join(", ")||"unowned"]},m.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(m=>d.jsx("div",{className:"muted",children:m},m))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:x.length})]}),x.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):x.map(m=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>m.node_id&&a(m.node_id),children:[d.jsx("span",{className:`chip ${m.severity}`,children:m.severity}),m.message]})},m.rule+m.message))]}),d.jsx(xm,{cards:t.deepening}),(v=c==null?void 0:c.points)!=null&&v.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(m=>d.jsx("i",{className:m.level||"",title:`${m.level} · ${m.findings} findings`,style:{height:`${8+Math.min(24,(m.findings||0)*4)}px`}},m.id||m.created_at))}),Object.entries(c.contexts).map(([m,y])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:m})," — last ",((_=y[y.length-1])==null?void 0:_.findings)??0," findings"]},m)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(c0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((m,y)=>y[1]-m[1]).slice(0,12).map(([m,y])=>d.jsxs("tr",{children:[d.jsx("td",{children:to(m)}),d.jsx("td",{children:y})]},m))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function xm({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:d0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}vm(ym());s0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(EN,{})}));export{Hk as L,RN as a,PN as c,d as j,IN as l,L as r,to as t}; diff --git a/src/loadpath/static/index.html b/src/loadpath/static/index.html index c75530b..ce9c3e8 100644 --- a/src/loadpath/static/index.html +++ b/src/loadpath/static/index.html @@ -17,7 +17,7 @@ - + diff --git a/ui/src/App.tsx b/ui/src/App.tsx index c96f0a6..49ebaf0 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -1279,7 +1279,14 @@ export function App() {
{architecture?.indexed ? ( - + ) : null}
From 950dc6bb1316e6019824e14557c36442b9c944af Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 15 Aug 2026 23:45:45 +0000 Subject: [PATCH 04/16] Load indexed workspaces without blocking on the full graph. GET /api/architecture can return the brief first (findings, counts) while GET /api/architecture/graph fills the map. Workspace listing no longer re-hashes the tree or evaluates rules. Drift on load uses mtimes; node and edge reads are cached and architecture edges are type-filtered in SQL. The UI paints the architecture brief as soon as the summary arrives. Co-authored-by: zord.lack.net --- src/loadpath/architecture/snapshot.py | 71 +++++++++++++--- src/loadpath/graph/store.py | 60 ++++++++++++-- src/loadpath/index.py | 40 +++++++-- src/loadpath/mcp/tools.py | 6 +- src/loadpath/server/app.py | 31 +++++-- ...DIo4wwkt.js => LayeredGraph3D-DtHNGq_6.js} | 2 +- src/loadpath/static/assets/index-Cksrgi4F.js | 62 -------------- src/loadpath/static/assets/index-Pc-bL4kN.js | 62 ++++++++++++++ src/loadpath/static/index.html | 2 +- tests/e2e/test_api_flow.py | 16 +++- tests/e2e/test_ui_flows.py | 23 ++++++ tests/unit/test_architecture_load.py | 82 +++++++++++++++++++ ui/src/App.tsx | 78 +++++++++++++----- ui/src/api.ts | 10 ++- ui/src/types.ts | 1 + 15 files changed, 420 insertions(+), 126 deletions(-) rename src/loadpath/static/assets/{LayeredGraph3D-DIo4wwkt.js => LayeredGraph3D-DtHNGq_6.js} (99%) delete mode 100644 src/loadpath/static/assets/index-Cksrgi4F.js create mode 100644 src/loadpath/static/assets/index-Pc-bL4kN.js create mode 100644 tests/unit/test_architecture_load.py diff --git a/src/loadpath/architecture/snapshot.py b/src/loadpath/architecture/snapshot.py index 7b3e8b5..0c6ac98 100644 --- a/src/loadpath/architecture/snapshot.py +++ b/src/loadpath/architecture/snapshot.py @@ -8,7 +8,7 @@ from loadpath.architecture.depth import deepening_candidates from loadpath.architecture.rules import evaluate from loadpath.config import LoadpathConfig, load_config -from loadpath.graph.store import GraphStore, linked_edges +from loadpath.graph.store import GraphStore from loadpath.index import default_db_path, index_drift from loadpath.types import NodeType @@ -43,7 +43,7 @@ } -def summarize_index(store: GraphStore, config: LoadpathConfig) -> dict[str, Any]: +def summarize_index(store: GraphStore, config: LoadpathConfig, *, hash_drift: bool = False) -> dict[str, Any]: raw_findings = evaluate(store, config) findings = [f.to_dict() for f in raw_findings] residuals = [line for line in (store.get_meta("residuals") or "").splitlines() if line] @@ -57,7 +57,7 @@ def summarize_index(store: GraphStore, config: LoadpathConfig) -> dict[str, Any] } for name, ctx in config.contexts.items() } - drift = index_drift(store, config.repo_root, config) + drift = index_drift(store, config.repo_root, config, hash_contents=hash_drift) boot_residuals = [line for line in residuals if "django.setup()" in line] return { "ok": True, @@ -87,11 +87,55 @@ def summarize_index(store: GraphStore, config: LoadpathConfig) -> dict[str, Any] def architecture_graph(store: GraphStore) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]: - nodes = [n for n in store.nodes() if n["type"] in ARCHITECTURE_NODE_TYPES] - return nodes, linked_edges(nodes, store.edges()) + types = sorted(ARCHITECTURE_NODE_TYPES) + nodes = store.nodes(types) + return nodes, store.edges_between_types(types) -def architecture_report(repo_root: Path, db_path: Path | None = None) -> dict[str, Any]: +def workspace_index_card(repo_root: Path, db_path: Path | None = None) -> dict[str, Any]: + """Counts and contexts only — used by GET /api/repos so listing workspaces is cheap.""" + repo_root = repo_root.resolve() + db = db_path or default_db_path(repo_root) + has_config = (repo_root / "loadpath.yml").is_file() + empty_contexts: dict[str, Any] = {} + if not db.is_file(): + return { + "indexed": False, + "counts": {"nodes": 0, "edges": 0}, + "has_config": has_config, + "contexts": empty_contexts, + } + store = GraphStore(db) + config = load_config(repo_root) + card = { + "indexed": True, + "counts": store.counts(), + "indexed_at": store.get_meta("indexed_at"), + "has_config": has_config, + "contexts": { + name: { + "name": name, + "django_apps": ctx.django_apps, + "react": ctx.react, + "public_api": ctx.public_api, + "owners": ctx.owners, + } + for name, ctx in config.contexts.items() + }, + "django_boot": store.get_meta("django_boot") or "off", + "stale": False, + } + store.close() + return card + + +def architecture_report( + repo_root: Path, + db_path: Path | None = None, + *, + include_graph: bool = True, + hash_drift: bool = False, +) -> dict[str, Any]: repo_root = repo_root.resolve() db = db_path or default_db_path(repo_root) if not db.is_file(): @@ -123,12 +167,19 @@ def architecture_report(repo_root: Path, db_path: Path | None = None) -> dict[st "residuals": [], "nodes": [], "edges": [], + "graph_pending": False, } store = GraphStore(db) config = load_config(repo_root) - summary = summarize_index(store, config) - nodes, edges = architecture_graph(store) - summary["nodes"] = nodes - summary["edges"] = edges + summary = summarize_index(store, config, hash_drift=hash_drift) + if include_graph: + nodes, edges = architecture_graph(store) + summary["nodes"] = nodes + summary["edges"] = edges + summary["graph_pending"] = False + else: + summary["nodes"] = [] + summary["edges"] = [] + summary["graph_pending"] = True store.close() return summary diff --git a/src/loadpath/graph/store.py b/src/loadpath/graph/store.py index 174585b..7a2e152 100644 --- a/src/loadpath/graph/store.py +++ b/src/loadpath/graph/store.py @@ -74,12 +74,23 @@ def __init__(self, db_path: Path) -> None: self.conn.execute("PRAGMA foreign_keys = ON") self.conn.execute("PRAGMA journal_mode = WAL") self.conn.execute("PRAGMA synchronous = NORMAL") + self.conn.execute("PRAGMA temp_store = MEMORY") + self.conn.execute("PRAGMA mmap_size = 268435456") + self.conn.execute("PRAGMA cache_size = -8000") self.conn.executescript(SCHEMA) self.conn.commit() + self._nodes_cache: list[dict[str, Any]] | None = None + self._edges_cache: list[dict[str, Any]] | None = None def close(self) -> None: + self._nodes_cache = None + self._edges_cache = None self.conn.close() + def _invalidate(self) -> None: + self._nodes_cache = None + self._edges_cache = None + def __enter__(self) -> GraphStore: return self @@ -115,6 +126,7 @@ def delete_file_nodes(self, path: str, *, drop_incoming: bool = True) -> None: ] if not ids: self.conn.execute("DELETE FROM files WHERE path=?", (path,)) + self._invalidate() return placeholders = ",".join("?" * len(ids)) if drop_incoming: @@ -127,11 +139,13 @@ def delete_file_nodes(self, path: str, *, drop_incoming: bool = True) -> None: self.conn.execute(f"DELETE FROM edges WHERE src IN ({placeholders})", ids) self.conn.execute("DELETE FROM nodes WHERE file_path=?", (path,)) self.conn.execute("DELETE FROM files WHERE path=?", (path,)) + self._invalidate() def prune_dangling_edges(self) -> None: self.conn.execute( "DELETE FROM edges WHERE src NOT IN (SELECT id FROM nodes) OR dst NOT IN (SELECT id FROM nodes)" ) + self._invalidate() def upsert_graph(self, graph: ExtractedGraph, *, commit: bool = True) -> None: for node in graph.nodes: @@ -140,6 +154,7 @@ def upsert_graph(self, graph: ExtractedGraph, *, commit: bool = True) -> None: self.upsert_edge(edge) if commit: self.conn.commit() + self._invalidate() def upsert_node(self, node: Node) -> None: existing = self.get_node(node.id) @@ -190,6 +205,7 @@ def upsert_node(self, node: Node) -> None: json.dumps(extra), ), ) + self._invalidate() def upsert_edge(self, edge: Edge) -> None: row = edge.to_row() @@ -212,24 +228,50 @@ def upsert_edge(self, edge: Edge) -> None: json.dumps(row["extra"]), ), ) + self._invalidate() def get_node(self, node_id: str) -> dict[str, Any] | None: row = self.conn.execute("SELECT * FROM nodes WHERE id=?", (node_id,)).fetchone() return self._node_from_row(row) if row else None - def nodes(self, types: Iterable[NodeType] | None = None) -> list[dict[str, Any]]: - if types: - values = [t.value for t in types] - placeholders = ",".join("?" * len(values)) + def nodes(self, types: Iterable[NodeType | str] | None = None) -> list[dict[str, Any]]: + want = {t.value if isinstance(t, NodeType) else str(t) for t in types} if types else None + if self._nodes_cache is not None: + if want is None: + return self._nodes_cache + return [n for n in self._nodes_cache if n["type"] in want] + if want: + placeholders = ",".join("?" * len(want)) rows = self.conn.execute( - f"SELECT * FROM nodes WHERE type IN ({placeholders})", values + f"SELECT * FROM nodes WHERE type IN ({placeholders})", tuple(want) ).fetchall() - else: - rows = self.conn.execute("SELECT * FROM nodes").fetchall() - return [self._node_from_row(r) for r in rows] + return [self._node_from_row(r) for r in rows] + self._nodes_cache = [self._node_from_row(r) for r in self.conn.execute("SELECT * FROM nodes")] + return self._nodes_cache def edges(self) -> list[dict[str, Any]]: - rows = self.conn.execute("SELECT * FROM edges").fetchall() + if self._edges_cache is None: + self._edges_cache = [self._edge_from_row(r) for r in self.conn.execute("SELECT * FROM edges")] + return self._edges_cache + + def edges_between_types(self, types: Iterable[str]) -> list[dict[str, Any]]: + """Edges whose endpoints both have a type in `types`. Avoids loading the full graph.""" + want = sorted({str(t) for t in types}) + if not want: + return [] + if self._edges_cache is not None and self._nodes_cache is not None: + ids = {n["id"] for n in self._nodes_cache if n["type"] in set(want)} + return [e for e in self._edges_cache if e["src"] in ids and e["dst"] in ids] + placeholders = ",".join("?" * len(want)) + rows = self.conn.execute( + f""" + SELECT e.id, e.src, e.dst, e.type, e.weight, e.confidence, e.extra + FROM edges e + WHERE e.src IN (SELECT id FROM nodes WHERE type IN ({placeholders})) + AND e.dst IN (SELECT id FROM nodes WHERE type IN ({placeholders})) + """, + (*want, *want), + ).fetchall() return [self._edge_from_row(r) for r in rows] def neighbors(self, node_id: str, direction: str = "both") -> list[dict[str, Any]]: diff --git a/src/loadpath/index.py b/src/loadpath/index.py index 44700ae..19c937b 100644 --- a/src/loadpath/index.py +++ b/src/loadpath/index.py @@ -210,22 +210,48 @@ def list_source_files( return [by_path[path] for path in paths] +def _indexed_timestamp(store: GraphStore) -> float: + raw = store.get_meta("indexed_at") or "" + try: + return datetime.fromisoformat(raw).timestamp() + except ValueError: + return 0.0 + + def index_drift( store: GraphStore, repo_root: Path, config: LoadpathConfig, files: list[SourceFile] | None = None, + *, + hash_contents: bool = True, ) -> dict: - files = files if files is not None else list_source_files(repo_root, config) - present = {src.rel for src in files} + """Compare the index to the working tree. + + `hash_contents=False` walks the tree and uses mtimes instead of SHA-256. + That is what GET /api/architecture should use: loading a workspace must not + re-hash the whole monorepo. + """ + config_changed = _sidecar_digest(repo_root, config) != (store.get_meta("sidecar_hash") or "") indexed = set(store.indexed_paths()) - changed: list[str] = [] - for src in files: - if store.file_hash(src.rel) != src.digest: - changed.append(src.rel) + if files is None and not hash_contents: + paths = iter_source_files(repo_root, config) + present = {path.relative_to(repo_root).as_posix() for path in paths} + indexed_ts = _indexed_timestamp(store) + changed: list[str] = [] + for path in paths: + rel = path.relative_to(repo_root).as_posix() + try: + if path.stat().st_mtime > indexed_ts: + changed.append(rel) + except OSError: + changed.append(rel) + else: + files = files if files is not None else list_source_files(repo_root, config) + present = {src.rel for src in files} + changed = [src.rel for src in files if store.file_hash(src.rel) != src.digest] added = sorted(present - indexed) deleted = sorted(indexed - present) - config_changed = _sidecar_digest(repo_root, config) != (store.get_meta("sidecar_hash") or "") return { "stale": bool(changed or added or deleted or config_changed) or store.file_count() == 0, "config_changed": config_changed, diff --git a/src/loadpath/mcp/tools.py b/src/loadpath/mcp/tools.py index 467434d..aaa96a1 100644 --- a/src/loadpath/mcp/tools.py +++ b/src/loadpath/mcp/tools.py @@ -5,7 +5,7 @@ import httpx -from loadpath.architecture.snapshot import architecture_report, summarize_index +from loadpath.architecture.snapshot import architecture_report, summarize_index, workspace_index_card from loadpath.config import load_config from loadpath.detect import detect_layout, write_draft_config from loadpath.index import index_repo @@ -78,7 +78,7 @@ def list_workspaces() -> dict[str, Any]: "counts": {"nodes": 0, "edges": 0}, } if path.is_dir(): - report = architecture_report(path) + report = workspace_index_card(path) item.update( { "indexed": report["indexed"], @@ -120,7 +120,7 @@ def architecture(repo_path: str) -> dict[str, Any]: root = _repo(repo_path) if isinstance(root, dict): return root - return compact_architecture(architecture_report(root)) + return compact_architecture(architecture_report(root, include_graph=False)) def review_range( diff --git a/src/loadpath/server/app.py b/src/loadpath/server/app.py index 295d3bb..bedc968 100644 --- a/src/loadpath/server/app.py +++ b/src/loadpath/server/app.py @@ -7,6 +7,7 @@ from fastapi import FastAPI, HTTPException, Query, Request from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import HTMLResponse, Response +from starlette.middleware.gzip import GZipMiddleware from fastapi.staticfiles import StaticFiles from pydantic import BaseModel, Field import httpx @@ -24,7 +25,12 @@ resource_url, ) from loadpath.ai.providers import client_for, residual_prompt -from loadpath.architecture.snapshot import architecture_graph, architecture_report, summarize_index +from loadpath.architecture.snapshot import ( + architecture_graph, + architecture_report, + summarize_index, + workspace_index_card, +) from loadpath.config import load_config, config_document, write_config, add_waiver from loadpath.detect import detect_layout, write_draft_config from loadpath.graph.store import GraphStore @@ -275,6 +281,7 @@ def create_app( app.state.mcp = mcp app.state.mcp_http = mcp_http add_mcp_auth_middleware(app, mcp) + app.add_middleware(GZipMiddleware, minimum_size=500) app.add_middleware( CORSMiddleware, allow_origins=["*"], @@ -392,9 +399,7 @@ def api_index_progress(repo_path: str) -> dict[str, Any]: @app.get("/api/index") def api_index_status(repo_path: str) -> dict[str, Any]: root = require_repo_path(repo_path) - report = architecture_report(root) - report.pop("nodes", None) - report.pop("edges", None) + report = architecture_report(root, include_graph=False) return report @app.get("/api/fs") @@ -420,7 +425,7 @@ def api_repos() -> dict[str, Any]: "counts": {"nodes": 0, "edges": 0}, } if path.is_dir(): - report = architecture_report(path) + report = workspace_index_card(path) item.update( { "indexed": report["indexed"], @@ -522,9 +527,21 @@ def api_graph(repo_path: str, scope: str = "full") -> dict[str, Any]: return payload @app.get("/api/architecture") - def api_architecture(repo_path: str) -> dict[str, Any]: + def api_architecture(repo_path: str, graph: bool = True) -> dict[str, Any]: + root = require_repo_path(repo_path) + return architecture_report(root, include_graph=graph) + + @app.get("/api/architecture/graph") + def api_architecture_graph(repo_path: str) -> dict[str, Any]: root = require_repo_path(repo_path) - return architecture_report(root) + db = default_db_path(root) + if not db.is_file(): + raise HTTPException(409, "Index the repo first") + store = GraphStore(db) + nodes, edges = architecture_graph(store) + payload = {"nodes": nodes, "edges": edges, "counts": store.counts()} + store.close() + return payload @app.get("/api/config") def api_config(repo_path: str) -> dict[str, Any]: diff --git a/src/loadpath/static/assets/LayeredGraph3D-DIo4wwkt.js b/src/loadpath/static/assets/LayeredGraph3D-DtHNGq_6.js similarity index 99% rename from src/loadpath/static/assets/LayeredGraph3D-DIo4wwkt.js rename to src/loadpath/static/assets/LayeredGraph3D-DtHNGq_6.js index 753c7a2..e3c7a9e 100644 --- a/src/loadpath/static/assets/LayeredGraph3D-DIo4wwkt.js +++ b/src/loadpath/static/assets/LayeredGraph3D-DtHNGq_6.js @@ -1,4 +1,4 @@ -import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-Cksrgi4F.js";/** +import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-Pc-bL4kN.js";/** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT diff --git a/src/loadpath/static/assets/index-Cksrgi4F.js b/src/loadpath/static/assets/index-Cksrgi4F.js deleted file mode 100644 index 16cfb7e..0000000 --- a/src/loadpath/static/assets/index-Cksrgi4F.js +++ /dev/null @@ -1,62 +0,0 @@ -(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function wp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Eu={exports:{}},Ho={},Cu={exports:{}},Ie={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Gf;function Zy(){if(Gf)return Ie;Gf=1;var t=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),x=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),m=Symbol.iterator;function y(P){return P===null||typeof P!="object"?null:(P=m&&P[m]||P["@@iterator"],typeof P=="function"?P:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,j={};function E(P,z,ie){this.props=P,this.context=z,this.refs=j,this.updater=ie||_}E.prototype.isReactComponent={},E.prototype.setState=function(P,z){if(typeof P!="object"&&typeof P!="function"&&P!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,P,z,"setState")},E.prototype.forceUpdate=function(P){this.updater.enqueueForceUpdate(this,P,"forceUpdate")};function w(){}w.prototype=E.prototype;function M(P,z,ie){this.props=P,this.context=z,this.refs=j,this.updater=ie||_}var k=M.prototype=new w;k.constructor=M,N(k,E.prototype),k.isPureReactComponent=!0;var b=Array.isArray,A=Object.prototype.hasOwnProperty,$={current:null},V={key:!0,ref:!0,__self:!0,__source:!0};function X(P,z,ie){var oe,de={},pe=null,he=null;if(z!=null)for(oe in z.ref!==void 0&&(he=z.ref),z.key!==void 0&&(pe=""+z.key),z)A.call(z,oe)&&!V.hasOwnProperty(oe)&&(de[oe]=z[oe]);var Q=arguments.length-2;if(Q===1)de.children=ie;else if(1>>1,z=C[P];if(0>>1;Pa(de,B))pea(he,de)?(C[P]=he,C[pe]=B,P=pe):(C[P]=de,C[oe]=B,P=oe);else if(pea(he,B))C[P]=he,C[pe]=B,P=pe;else break e}}return D}function a(C,D){var B=C.sortIndex-D.sortIndex;return B!==0?B:C.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,h=c.now();t.unstable_now=function(){return c.now()-h}}var p=[],x=[],v=1,m=null,y=3,_=!1,N=!1,j=!1,E=typeof setTimeout=="function"?setTimeout:null,w=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function k(C){for(var D=o(x);D!==null;){if(D.callback===null)s(x);else if(D.startTime<=C)s(x),D.sortIndex=D.expirationTime,r(p,D);else break;D=o(x)}}function b(C){if(j=!1,k(C),!N)if(o(p)!==null)N=!0,H(A);else{var D=o(x);D!==null&&U(b,D.startTime-C)}}function A(C,D){N=!1,j&&(j=!1,w(X),X=-1),_=!0;var B=y;try{for(k(D),m=o(p);m!==null&&(!(m.expirationTime>D)||C&&!Z());){var P=m.callback;if(typeof P=="function"){m.callback=null,y=m.priorityLevel;var z=P(m.expirationTime<=D);D=t.unstable_now(),typeof z=="function"?m.callback=z:m===o(p)&&s(p),k(D)}else s(p);m=o(p)}if(m!==null)var ie=!0;else{var oe=o(x);oe!==null&&U(b,oe.startTime-D),ie=!1}return ie}finally{m=null,y=B,_=!1}}var $=!1,V=null,X=-1,G=5,J=-1;function Z(){return!(t.unstable_now()-JC||125P?(C.sortIndex=B,r(x,C),o(p)===null&&C===o(x)&&(j?(w(X),X=-1):j=!0,U(b,B-P))):(C.sortIndex=z,r(p,C),N||_||(N=!0,H(A))),C},t.unstable_shouldYield=Z,t.unstable_wrapCallback=function(C){var D=y;return function(){var B=y;y=D;try{return C.apply(this,arguments)}finally{y=B}}}})(Iu)),Iu}var Zf;function r0(){return Zf||(Zf=1,Pu.exports=n0()),Pu.exports}/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Jf;function i0(){if(Jf)return Dt;Jf=1;var t=os(),r=r0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,x=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,v={},m={};function y(e){return p.call(m,e)?!0:p.call(v,e)?!1:x.test(e)?m[e]=!0:(v[e]=!0,!1)}function _(e,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function N(e,n,i,l){if(n===null||typeof n>"u"||_(e,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function j(e,n,i,l,f,g,S){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=f,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=g,this.removeEmptyString=S}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){E[e]=new j(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];E[n]=new j(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){E[e]=new j(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){E[e]=new j(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){E[e]=new j(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){E[e]=new j(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){E[e]=new j(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){E[e]=new j(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){E[e]=new j(e,5,!1,e.toLowerCase(),null,!1,!1)});var w=/[\-:]([a-z])/g;function M(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(w,M);E[n]=new j(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(w,M);E[n]=new j(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(w,M);E[n]=new j(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){E[e]=new j(e,1,!1,e.toLowerCase(),null,!1,!1)}),E.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){E[e]=new j(e,1,!1,e.toLowerCase(),null,!0,!0)});function k(e,n,i,l){var f=E.hasOwnProperty(n)?E[n]:null;(f!==null?f.type!==0:l||!(2T||f[S]!==g[T]){var O=` -`+f[S].replace(" at new "," at ");return e.displayName&&O.includes("")&&(O=O.replace("",e.displayName)),O}while(1<=S&&0<=T);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?z(e):""}function de(e){switch(e.tag){case 5:return z(e.type);case 16:return z("Lazy");case 13:return z("Suspense");case 19:return z("SuspenseList");case 0:case 2:case 15:return e=oe(e.type,!1),e;case 11:return e=oe(e.type.render,!1),e;case 1:return e=oe(e.type,!0),e;default:return""}}function pe(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case V:return"Fragment";case $:return"Portal";case G:return"Profiler";case X:return"StrictMode";case te:return"Suspense";case I:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Z:return(e.displayName||"Context")+".Consumer";case J:return(e._context.displayName||"Context")+".Provider";case re:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case W:return n=e.displayName||null,n!==null?n:pe(e.type)||"Memo";case H:n=e._payload,e=e._init;try{return pe(e(n))}catch{}}return null}function he(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return pe(n);case 8:return n===X?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Q(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ae(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=ae(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function ke(e){e._valueTracker||(e._valueTracker=me(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=ae(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function ne(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return B({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Q(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Re(e,n){n=n.checked,n!=null&&k(e,"checked",n,!1)}function Le(e,n){Re(e,n);var i=Q(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?pt(e,n.type,i):n.hasOwnProperty("defaultValue")&&pt(e,n.type,Q(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function Ze(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function pt(e,n,i){(n!=="number"||ne(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var Xe=Array.isArray;function it(e,n,i,l){if(e=e.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=Pt.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function sn(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var qt={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},no=["Webkit","ms","Moz","O"];Object.keys(qt).forEach(function(e){no.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),qt[n]=qt[e]})});function rr(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||qt.hasOwnProperty(e)&&qt[e]?(""+n).trim():n+"px"}function ui(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=rr(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,f):e[i]=f}}var ci=B({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ir(e,n){if(n){if(ci[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function Nn(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Nt=null;function jn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var bn=null,It=null,Ft=null;function En(e){if(e=bo(e)){if(typeof bn!="function")throw Error(o(280));var n=e.stateNode;n&&(n=bs(n),bn(e.stateNode,e.type,n))}}function yt(e){It?Ft?Ft.push(e):Ft=[e]:It=e}function Rr(){if(It){var e=It,n=Ft;if(Ft=It=null,En(e),n)for(e=0;e>>=0,e===0?32:31-(Dr(e)/vi|0)|0}var Vn=64,Pn=4194304;function Wn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Qt(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,f=e.suspendedLanes,g=e.pingedLanes,S=i&268435455;if(S!==0){var T=S&~f;T!==0?l=Wn(T):(g&=S,g!==0&&(l=Wn(g)))}else S=i&~f,S!==0?l=Wn(S):g!==0&&(l=Wn(g));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,g=n&-n,f>=g||f===16&&(g&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function Rn(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-xt(n),e[n]=i}function _i(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=yo),Oc=" ",Fc=!1;function Hc(e,n){switch(e){case"keyup":return Gm.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Bc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ni=!1;function qm(e,n){switch(e){case"compositionend":return Bc(n);case"keypress":return n.which!==32?null:(Fc=!0,Oc);case"textInput":return e=n.data,e===Oc&&Fc?null:e;default:return null}}function Km(e,n){if(Ni)return e==="compositionend"||!la&&Hc(e,n)?(e=Tc(),gs=ta=dr=null,Ni=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=qc(i)}}function Qc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Qc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Zc(){for(var e=window,n=ne();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=ne(e.document)}return n}function ca(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function oy(e){var n=Zc(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Qc(i.ownerDocument.documentElement,i)){if(l!==null&&ca(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var f=i.textContent.length,g=Math.min(l.start,f);l=l.end===void 0?g:Math.min(l.end,f),!e.extend&&g>l&&(f=l,l=g,g=f),f=Kc(i,g);var S=Kc(i,l);f&&S&&(e.rangeCount!==1||e.anchorNode!==f.node||e.anchorOffset!==f.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),e.removeAllRanges(),g>l?(e.addRange(n),e.extend(S.node,S.offset)):(n.setEnd(S.node,S.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,ji=null,da=null,_o=null,fa=!1;function Jc(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;fa||ji==null||ji!==ne(l)||(l=ji,"selectionStart"in l&&ca(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),_o&&wo(_o,l)||(_o=l,l=ks(da,"onSelect"),0Pi||(e.current=Na[Pi],Na[Pi]=null,Pi--)}function Be(e,n){Pi++,Na[Pi]=e.current,e.current=n}var gr={},wt=pr(gr),Tt=pr(!1),Br=gr;function Ii(e,n){var i=e.type.contextTypes;if(!i)return gr;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in i)f[g]=n[g];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=f),f}function Lt(e){return e=e.childContextTypes,e!=null}function Es(){Ue(Tt),Ue(wt)}function pd(e,n,i){if(wt.current!==gr)throw Error(o(168));Be(wt,n),Be(Tt,i)}function gd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,he(e)||"Unknown",f));return B({},i,l)}function Cs(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||gr,Br=wt.current,Be(wt,e),Be(Tt,Tt.current),!0}function md(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=gd(e,n,Br),l.__reactInternalMemoizedMergedChildContext=e,Ue(Tt),Ue(wt),Be(wt,e)):Ue(Tt),Be(Tt,i)}var Gn=null,Ms=!1,ja=!1;function yd(e){Gn===null?Gn=[e]:Gn.push(e)}function yy(e){Ms=!0,yd(e)}function mr(){if(!ja&&Gn!==null){ja=!0;var e=0,n=De;try{var i=Gn;for(De=1;e>=S,f-=S,Xn=1<<32-xt(n)+f|i<Ce?(ct=be,be=null):ct=be.sibling;var Oe=se(q,be,K[Ce],ce);if(Oe===null){be===null&&(be=ct);break}e&&be&&Oe.alternate===null&&n(q,be),F=g(Oe,F,Ce),je===null?_e=Oe:je.sibling=Oe,je=Oe,be=ct}if(Ce===K.length)return i(q,be),Ge&&Wr(q,Ce),_e;if(be===null){for(;CeCe?(ct=be,be=null):ct=be.sibling;var jr=se(q,be,Oe.value,ce);if(jr===null){be===null&&(be=ct);break}e&&be&&jr.alternate===null&&n(q,be),F=g(jr,F,Ce),je===null?_e=jr:je.sibling=jr,je=jr,be=ct}if(Oe.done)return i(q,be),Ge&&Wr(q,Ce),_e;if(be===null){for(;!Oe.done;Ce++,Oe=K.next())Oe=ue(q,Oe.value,ce),Oe!==null&&(F=g(Oe,F,Ce),je===null?_e=Oe:je.sibling=Oe,je=Oe);return Ge&&Wr(q,Ce),_e}for(be=l(q,be);!Oe.done;Ce++,Oe=K.next())Oe=ge(be,q,Ce,Oe.value,ce),Oe!==null&&(e&&Oe.alternate!==null&&be.delete(Oe.key===null?Ce:Oe.key),F=g(Oe,F,Ce),je===null?_e=Oe:je.sibling=Oe,je=Oe);return e&&be.forEach(function(Qy){return n(q,Qy)}),Ge&&Wr(q,Ce),_e}function et(q,F,K,ce){if(typeof K=="object"&&K!==null&&K.type===V&&K.key===null&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case A:e:{for(var _e=K.key,je=F;je!==null;){if(je.key===_e){if(_e=K.type,_e===V){if(je.tag===7){i(q,je.sibling),F=f(je,K.props.children),F.return=q,q=F;break e}}else if(je.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===H&&kd(_e)===je.type){i(q,je.sibling),F=f(je,K.props),F.ref=Eo(q,je,K),F.return=q,q=F;break e}i(q,je);break}else n(q,je);je=je.sibling}K.type===V?(F=Zr(K.props.children,q.mode,ce,K.key),F.return=q,q=F):(ce=rl(K.type,K.key,K.props,null,q.mode,ce),ce.ref=Eo(q,F,K),ce.return=q,q=ce)}return S(q);case $:e:{for(je=K.key;F!==null;){if(F.key===je)if(F.tag===4&&F.stateNode.containerInfo===K.containerInfo&&F.stateNode.implementation===K.implementation){i(q,F.sibling),F=f(F,K.children||[]),F.return=q,q=F;break e}else{i(q,F);break}else n(q,F);F=F.sibling}F=Su(K,q.mode,ce),F.return=q,q=F}return S(q);case H:return je=K._init,et(q,F,je(K._payload),ce)}if(Xe(K))return xe(q,F,K,ce);if(D(K))return we(q,F,K,ce);Ts(q,K)}return typeof K=="string"&&K!==""||typeof K=="number"?(K=""+K,F!==null&&F.tag===6?(i(q,F.sibling),F=f(F,K),F.return=q,q=F):(i(q,F),F=_u(K,q.mode,ce),F.return=q,q=F),S(q)):i(q,F)}return et}var Ai=Nd(!0),jd=Nd(!1),Ls=pr(null),As=null,$i=null,Ia=null;function Ra(){Ia=$i=As=null}function Ta(e){var n=Ls.current;Ue(Ls),e._currentValue=n}function La(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function zi(e,n){As=e,Ia=$i=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(At=!0),e.firstContext=null)}function en(e){var n=e._currentValue;if(Ia!==e)if(e={context:e,memoizedValue:n,next:null},$i===null){if(As===null)throw Error(o(308));$i=e,As.dependencies={lanes:0,firstContext:e}}else $i=$i.next=e;return n}var Ur=null;function Aa(e){Ur===null?Ur=[e]:Ur.push(e)}function bd(e,n,i,l){var f=n.interleaved;return f===null?(i.next=i,Aa(n)):(i.next=f.next,f.next=i),n.interleaved=i,Kn(e,l)}function Kn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var yr=!1;function $a(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ed(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Qn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function vr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,($e&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,Kn(e,i)}return f=l.interleaved,f===null?(n.next=n,Aa(l)):(n.next=f.next,f.next=n),l.interleaved=n,Kn(e,i)}function $s(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,Un(e,i)}}function Cd(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var S={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?f=g=S:g=g.next=S,i=i.next}while(i!==null);g===null?f=g=n:g=g.next=n}else f=g=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function zs(e,n,i,l){var f=e.updateQueue;yr=!1;var g=f.firstBaseUpdate,S=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,ee=O.next;O.next=null,S===null?g=ee:S.next=ee,S=O;var le=e.alternate;le!==null&&(le=le.updateQueue,T=le.lastBaseUpdate,T!==S&&(T===null?le.firstBaseUpdate=ee:T.next=ee,le.lastBaseUpdate=O))}if(g!==null){var ue=f.baseState;S=0,le=ee=O=null,T=g;do{var se=T.lane,ge=T.eventTime;if((l&se)===se){le!==null&&(le=le.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var xe=e,we=T;switch(se=n,ge=i,we.tag){case 1:if(xe=we.payload,typeof xe=="function"){ue=xe.call(ge,ue,se);break e}ue=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=we.payload,se=typeof xe=="function"?xe.call(ge,ue,se):xe,se==null)break e;ue=B({},ue,se);break e;case 2:yr=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,se=f.effects,se===null?f.effects=[T]:se.push(T))}else ge={eventTime:ge,lane:se,tag:T.tag,payload:T.payload,callback:T.callback,next:null},le===null?(ee=le=ge,O=ue):le=le.next=ge,S|=se;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;se=T,T=se.next,se.next=null,f.lastBaseUpdate=se,f.shared.pending=null}}while(!0);if(le===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=ee,f.lastBaseUpdate=le,n=f.shared.interleaved,n!==null){f=n;do S|=f.lane,f=f.next;while(f!==n)}else g===null&&(f.shared.lanes=0);Xr|=S,e.lanes=S,e.memoizedState=ue}}function Md(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=Ha.transition;Ha.transition={};try{e(!1),n()}finally{De=i,Ha.transition=l}}function Xd(){return tn().memoizedState}function _y(e,n,i){var l=Sr(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},qd(e))Kd(n,i);else if(i=bd(e,n,i,l),i!==null){var f=Ct();gn(i,e,l,f),Qd(i,n,l)}}function Sy(e,n,i){var l=Sr(e),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(qd(e))Kd(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,T=g(S,i);if(f.hasEagerState=!0,f.eagerState=T,cn(T,S)){var O=n.interleaved;O===null?(f.next=f,Aa(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=bd(e,n,f,l),i!==null&&(f=Ct(),gn(i,e,l,f),Qd(i,n,l))}}function qd(e){var n=e.alternate;return e===Ke||n!==null&&n===Ke}function Kd(e,n){Io=Fs=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Qd(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,Un(e,i)}}var Vs={readContext:en,useCallback:_t,useContext:_t,useEffect:_t,useImperativeHandle:_t,useInsertionEffect:_t,useLayoutEffect:_t,useMemo:_t,useReducer:_t,useRef:_t,useState:_t,useDebugValue:_t,useDeferredValue:_t,useTransition:_t,useMutableSource:_t,useSyncExternalStore:_t,useId:_t,unstable_isNewReconciler:!1},ky={readContext:en,useCallback:function(e,n){return $n().memoizedState=[e,n===void 0?null:n],e},useContext:en,useEffect:Fd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Hs(4194308,4,Vd.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Hs(4194308,4,e,n)},useInsertionEffect:function(e,n){return Hs(4,2,e,n)},useMemo:function(e,n){var i=$n();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=$n();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=_y.bind(null,Ke,e),[l.memoizedState,e]},useRef:function(e){var n=$n();return e={current:e},n.memoizedState=e},useState:Dd,useDebugValue:Xa,useDeferredValue:function(e){return $n().memoizedState=e},useTransition:function(){var e=Dd(!1),n=e[0];return e=wy.bind(null,e[1]),$n().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=Ke,f=$n();if(Ge){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ut===null)throw Error(o(349));(Gr&30)!==0||Td(l,n,i)}f.memoizedState=i;var g={value:i,getSnapshot:n};return f.queue=g,Fd(Ad.bind(null,l,g,e),[e]),l.flags|=2048,Lo(9,Ld.bind(null,l,g,i,n),void 0,null),i},useId:function(){var e=$n(),n=ut.identifierPrefix;if(Ge){var i=qn,l=Xn;i=(l&~(1<<32-xt(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=Ro++,0<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=S.createElement(i,{is:l.is}):(e=S.createElement(i),i==="select"&&(S=e,l.multiple?S.multiple=!0:l.size&&(S.size=l.size))):e=S.createElementNS(e,i),e[Ln]=n,e[jo]=l,vf(e,n,!1,!1),n.stateNode=e;e:{switch(S=Nn(i,l),i){case"dialog":We("cancel",e),We("close",e),f=l;break;case"iframe":case"object":case"embed":We("load",e),f=l;break;case"video":case"audio":for(f=0;fBi&&(n.flags|=128,l=!0,Ao(g,!1),n.lanes=4194304)}else{if(!l)if(e=Ds(S),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Ao(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Ge)return St(n),null}else 2*Ve()-g.renderingStartTime>Bi&&i!==1073741824&&(n.flags|=128,l=!0,Ao(g,!1),n.lanes=4194304);g.isBackwards?(S.sibling=n.child,n.child=S):(i=g.last,i!==null?i.sibling=S:n.child=S,g.last=S)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(St(n),null);case 22:case 23:return vu(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Yt&1073741824)!==0&&(St(n),n.subtreeFlags&6&&(n.flags|=8192)):St(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function Iy(e,n){switch(Ea(n),n.tag){case 1:return Lt(n.type)&&Es(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Di(),Ue(Tt),Ue(wt),Fa(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Da(n),null;case 13:if(Ue(qe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));Li()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Di(),null;case 10:return Ta(n.type._context),null;case 22:case 23:return vu(),null;case 24:return null;default:return null}}var Gs=!1,kt=!1,Ry=typeof WeakSet=="function"?WeakSet:Set,ye=null;function Fi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Je(e,n,l)}else i.current=null}function su(e,n,i){try{i()}catch(l){Je(e,n,l)}}var _f=!1;function Ty(e,n){if(va=hs,e=Zc(),ca(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,g=l.focusNode;l=l.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var S=0,T=-1,O=-1,ee=0,le=0,ue=e,se=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=S+f),ue!==g||l!==0&&ue.nodeType!==3||(O=S+l),ue.nodeType===3&&(S+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)se=ue,ue=ge;for(;;){if(ue===e)break t;if(se===i&&++ee===f&&(T=S),se===g&&++le===l&&(O=S),(ge=ue.nextSibling)!==null)break;ue=se,se=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(xa={focusedElem:e,selectionRange:i},hs=!1,ye=n;ye!==null;)if(n=ye,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ye=e;else for(;ye!==null;){n=ye;try{var xe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var we=xe.memoizedProps,et=xe.memoizedState,q=n.stateNode,F=q.getSnapshotBeforeUpdate(n.elementType===n.type?we:fn(n.type,we),et);q.__reactInternalSnapshotBeforeUpdate=F}break;case 3:var K=n.stateNode.containerInfo;K.nodeType===1?K.textContent="":K.nodeType===9&&K.documentElement&&K.removeChild(K.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(ce){Je(n,n.return,ce)}if(e=n.sibling,e!==null){e.return=n.return,ye=e;break}ye=n.return}return xe=_f,_f=!1,xe}function $o(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&e)===e){var g=f.destroy;f.destroy=void 0,g!==void 0&&su(n,i,g)}f=f.next}while(f!==l)}}function Xs(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function lu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function Sf(e){var n=e.alternate;n!==null&&(e.alternate=null,Sf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[Ln],delete n[jo],delete n[ka],delete n[gy],delete n[my])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function kf(e){return e.tag===5||e.tag===3||e.tag===4}function Nf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||kf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function au(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=js));else if(l!==4&&(e=e.child,e!==null))for(au(e,n,i),e=e.sibling;e!==null;)au(e,n,i),e=e.sibling}function uu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(uu(e,n,i),e=e.sibling;e!==null;)uu(e,n,i),e=e.sibling}var ft=null,hn=!1;function xr(e,n,i){for(i=i.child;i!==null;)jf(e,n,i),i=i.sibling}function jf(e,n,i){if(vt&&typeof vt.onCommitFiberUnmount=="function")try{vt.onCommitFiberUnmount(Mn,i)}catch{}switch(i.tag){case 5:kt||Fi(i,n);case 6:var l=ft,f=hn;ft=null,xr(e,n,i),ft=l,hn=f,ft!==null&&(hn?(e=ft,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):ft.removeChild(i.stateNode));break;case 18:ft!==null&&(hn?(e=ft,i=i.stateNode,e.nodeType===8?Sa(e.parentNode,i):e.nodeType===1&&Sa(e,i),po(e)):Sa(ft,i.stateNode));break;case 4:l=ft,f=hn,ft=i.stateNode.containerInfo,hn=!0,xr(e,n,i),ft=l,hn=f;break;case 0:case 11:case 14:case 15:if(!kt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var g=f,S=g.destroy;g=g.tag,S!==void 0&&((g&2)!==0||(g&4)!==0)&&su(i,n,S),f=f.next}while(f!==l)}xr(e,n,i);break;case 1:if(!kt&&(Fi(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Je(i,n,T)}xr(e,n,i);break;case 21:xr(e,n,i);break;case 22:i.mode&1?(kt=(l=kt)||i.memoizedState!==null,xr(e,n,i),kt=l):xr(e,n,i);break;default:xr(e,n,i)}}function bf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Ry),n.forEach(function(l){var f=By.bind(null,e,l);i.has(l)||(i.add(l),l.then(f,f))})}}function pn(e,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=S),l&=~g}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Ay(l/1960))-l,10e?16:e,_r===null)var l=!1;else{if(e=_r,_r=null,Js=0,($e&6)!==0)throw Error(o(331));var f=$e;for($e|=4,ye=e.current;ye!==null;){var g=ye,S=g.child;if((ye.flags&16)!==0){var T=g.deletions;if(T!==null){for(var O=0;OVe()-fu?Kr(e,0):du|=i),zt(e,n)}function Of(e,n){n===0&&((e.mode&1)===0?n=1:(n=Pn,Pn<<=1,(Pn&130023424)===0&&(Pn=4194304)));var i=Ct();e=Kn(e,n),e!==null&&(Rn(e,n,i),zt(e,i))}function Hy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Of(e,i)}function By(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Of(e,i)}var Ff;Ff=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Tt.current)At=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return At=!1,My(e,n,i);At=(e.flags&131072)!==0}else At=!1,Ge&&(n.flags&1048576)!==0&&vd(n,Is,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Ys(e,n),e=n.pendingProps;var f=Ii(n,wt.current);zi(n,i),f=Va(null,n,l,e,f,i);var g=Wa();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Lt(l)?(g=!0,Cs(n)):g=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,$a(n),f.updater=Ws,n.stateNode=f,f._reactInternals=n,Ka(n,l,e,i),n=eu(null,n,l,!0,g,i)):(n.tag=0,Ge&&g&&ba(n),Et(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Ys(e,n),e=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=Wy(l),e=fn(l,e),f){case 0:n=Ja(null,n,l,e,i);break e;case 1:n=ff(null,n,l,e,i);break e;case 11:n=lf(null,n,l,e,i);break e;case 14:n=af(null,n,l,fn(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:fn(l,f),Ja(e,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:fn(l,f),ff(e,n,l,f,i);case 3:e:{if(hf(n),e===null)throw Error(o(387));l=n.pendingProps,g=n.memoizedState,f=g.element,Ed(e,n),zs(n,l,null,i);var S=n.memoizedState;if(l=S.element,g.isDehydrated)if(g={element:l,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){f=Oi(Error(o(423)),n),n=pf(e,n,l,i,f);break e}else if(l!==f){f=Oi(Error(o(424)),n),n=pf(e,n,l,i,f);break e}else for(Ut=hr(n.stateNode.containerInfo.firstChild),Wt=n,Ge=!0,dn=null,i=jd(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Li(),l===f){n=Zn(e,n,i);break e}Et(e,n,l,i)}n=n.child}return n;case 5:return Pd(n),e===null&&Ma(n),l=n.type,f=n.pendingProps,g=e!==null?e.memoizedProps:null,S=f.children,wa(l,f)?S=null:g!==null&&wa(l,g)&&(n.flags|=32),df(e,n),Et(e,n,S,i),n.child;case 6:return e===null&&Ma(n),null;case 13:return gf(e,n,i);case 4:return za(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=Ai(n,null,l,i):Et(e,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:fn(l,f),lf(e,n,l,f,i);case 7:return Et(e,n,n.pendingProps,i),n.child;case 8:return Et(e,n,n.pendingProps.children,i),n.child;case 12:return Et(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,g=n.memoizedProps,S=f.value,Be(Ls,l._currentValue),l._currentValue=S,g!==null)if(cn(g.value,S)){if(g.children===f.children&&!Tt.current){n=Zn(e,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var T=g.dependencies;if(T!==null){S=g.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(g.tag===1){O=Qn(-1,i&-i),O.tag=2;var ee=g.updateQueue;if(ee!==null){ee=ee.shared;var le=ee.pending;le===null?O.next=O:(O.next=le.next,le.next=O),ee.pending=O}}g.lanes|=i,O=g.alternate,O!==null&&(O.lanes|=i),La(g.return,i,n),T.lanes|=i;break}O=O.next}}else if(g.tag===10)S=g.type===n.type?null:g.child;else if(g.tag===18){if(S=g.return,S===null)throw Error(o(341));S.lanes|=i,T=S.alternate,T!==null&&(T.lanes|=i),La(S,i,n),S=g.sibling}else S=g.child;if(S!==null)S.return=g;else for(S=g;S!==null;){if(S===n){S=null;break}if(g=S.sibling,g!==null){g.return=S.return,S=g;break}S=S.return}g=S}Et(e,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,zi(n,i),f=en(f),l=l(f),n.flags|=1,Et(e,n,l,i),n.child;case 14:return l=n.type,f=fn(l,n.pendingProps),f=fn(l.type,f),af(e,n,l,f,i);case 15:return uf(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:fn(l,f),Ys(e,n),n.tag=1,Lt(l)?(e=!0,Cs(n)):e=!1,zi(n,i),Jd(n,l,f),Ka(n,l,f,i),eu(null,n,l,!0,e,i);case 19:return yf(e,n,i);case 22:return cf(e,n,i)}throw Error(o(156,n.tag))};function Hf(e,n){return pi(e,n)}function Vy(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function rn(e,n,i,l){return new Vy(e,n,i,l)}function wu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Wy(e){if(typeof e=="function")return wu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===re)return 11;if(e===W)return 14}return 2}function Nr(e,n){var i=e.alternate;return i===null?(i=rn(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function rl(e,n,i,l,f,g){var S=2;if(l=e,typeof e=="function")wu(e)&&(S=1);else if(typeof e=="string")S=5;else e:switch(e){case V:return Zr(i.children,f,g,n);case X:S=8,f|=8;break;case G:return e=rn(12,i,n,f|2),e.elementType=G,e.lanes=g,e;case te:return e=rn(13,i,n,f),e.elementType=te,e.lanes=g,e;case I:return e=rn(19,i,n,f),e.elementType=I,e.lanes=g,e;case U:return il(i,f,g,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case J:S=10;break e;case Z:S=9;break e;case re:S=11;break e;case W:S=14;break e;case H:S=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=rn(S,i,n,f),n.elementType=e,n.type=l,n.lanes=g,n}function Zr(e,n,i,l){return e=rn(7,e,l,n),e.lanes=i,e}function il(e,n,i,l){return e=rn(22,e,l,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function _u(e,n,i){return e=rn(6,e,null,n),e.lanes=i,e}function Su(e,n,i){return n=rn(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Uy(e,n,i,l,f){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=In(0),this.expirationTimes=In(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=In(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function ku(e,n,i,l,f,g,S,T,O){return e=new Uy(e,n,i,T,O),n===1?(n=1,g===!0&&(n|=8)):n=0,g=rn(3,null,null,n),e.current=g,g.stateNode=e,g.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},$a(g),e}function Yy(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),Mu.exports=i0(),Mu.exports}var th;function o0(){if(th)return dl;th=1;var t=_p();return dl.createRoot=t.createRoot,dl.hydrateRoot=t.hydrateRoot,dl}var s0=o0();function Sp(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Te(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(Sp(s,o.statusText||"Request failed"))}return o.json()}const l0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Pe={health:()=>Te("/api/health"),settings:()=>Te("/api/settings"),saveSettings:t=>{const r={...t};for(const o of l0)r[o]===""&&delete r[o];return Te("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Te("/api/repos"),browse:t=>Te(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Te(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Te("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Te(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Te(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:t=>Te(`/api/architecture?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Te("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Te("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Te("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Te("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Te("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Te(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open",s)=>Te("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o,repo_path:s||null})}),scmRepos:t=>Te(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Te("/api/oauth/status"),githubOAuthStart:()=>Te("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Te("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Te("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Te("/api/oauth/gitlab/start"),oauthDisconnect:t=>Te("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Te("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})}),reviews:t=>Te(`/api/reviews?repo_path=${encodeURIComponent(t)}`),getReview:(t,r)=>Te(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(t)}`),reviewDiff:(t,r,o)=>Te(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(t)}&other=${encodeURIComponent(o)}`),config:t=>Te(`/api/config?repo_path=${encodeURIComponent(t)}`),saveConfig:(t,r)=>Te("/api/config",{method:"PUT",body:JSON.stringify({repo_path:t,...r})}),addWaiver:(t,r,o,s)=>Te("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:t,rule:r,node:o||null,reason:s||""})}),marks:(t,r)=>Te(`/api/marks?repo_path=${encodeURIComponent(t)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:t=>Te(`/api/architecture/health?repo_path=${encodeURIComponent(t)}`),workspaceStatus:t=>Te(`/api/workspace/status?repo_path=${encodeURIComponent(t)}`),openEditor:(t,r,o,s)=>Te("/api/open",{method:"POST",body:JSON.stringify({repo_path:t,path:r,line:o||null,editor:s||null})}),exportHtml:t=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:t})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(Sp(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(t,r,o,s)=>Te("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:t,edges:r,source_id:o,target_id:s||null})})};function a0(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):t}function u0({open:t,actions:r,onClose:o}){const[s,a]=L.useState(""),[u,c]=L.useState(0),h=L.useRef(null),p=L.useMemo(()=>a0(r,s),[r,s]);if(L.useEffect(()=>{if(!t)return;a(""),c(0);const m=window.setTimeout(()=>{var y;return(y=h.current)==null?void 0:y.focus()},0);return()=>window.clearTimeout(m)},[t]),L.useEffect(()=>{c(0)},[s]),!t)return null;const x=p[u],v=m=>{m&&(o(),m.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:m=>{m.target===m.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:m=>a(m.target.value),onKeyDown:m=>{m.key==="Escape"?(m.preventDefault(),o()):m.key==="ArrowDown"?(m.preventDefault(),c(y=>Math.min(p.length-1,y+1))):m.key==="ArrowUp"?(m.preventDefault(),c(y=>Math.max(0,y-1))):m.key==="Enter"&&(m.preventDefault(),v(x))}}),d.jsxs("ul",{children:[p.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,p.slice(0,40).map((m,y)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:y===u?"active":"",onMouseEnter:()=>c(y),onClick:()=>v(m),children:[d.jsx("span",{children:m.label}),m.hint?d.jsx("span",{className:"muted",children:m.hint}):null]})},m.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function c0({config:t,busy:r,onSave:o,onWaiver:s}){const[a,u]=L.useState(t),[c,h]=L.useState(t.available_rules[0]||""),[p,x]=L.useState(""),[v,m]=L.useState("");L.useEffect(()=>{u(t)},[t]);const y=Object.entries(a.contexts||{}),_=(M,k,b)=>{const A=a.contexts[M];if(!A)return;const $=V=>V.split(",").map(X=>X.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[M]:{...A,[k]:k==="name"?b:$(b)}}})},N=(M,k)=>{const b=k.trim();if(!b||b===M)return;const{[M]:A,...$}=a.contexts;A&&u({...a,contexts:{...$,[b]:{...A,name:b}}})},j=()=>{let M=1;for(;a.contexts[`context-${M}`];)M+=1;const k=`context-${M}`;u({...a,contexts:{...a.contexts,[k]:{name:k,django_apps:[],react:[],public_api:[],owners:[]}}})},E=M=>{const{[M]:k,...b}=a.contexts;u({...a,contexts:b})},w=M=>{const k=a.rules.includes(M);u({...a,rules:k?a.rules.filter(b=>b!==M):[...a.rules,M]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),y.map(([M,k])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:M})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:M,"data-testid":`config-context-name-${M}`,onBlur:b=>N(M,b.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(k.django_apps||[]).join(", "),onChange:b=>_(M,"django_apps",b.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(k.react||[]).join(", "),onChange:b=>_(M,"react",b.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(k.public_api||[]).join(", "),onChange:b=>_(M,"public_api",b.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(k.owners||[]).join(", "),onChange:b=>_(M,"owners",b.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>E(M),children:"Remove context"})]},M)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:j,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(M=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(M),onChange:()=>w(M)}),M]},M))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((M,k)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.rule}),M.node?` · ${M.node}`:"",M.reason?` — ${M.reason}`:""]},`${M.rule}:${M.node}:${k}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:M=>h(M.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(M=>d.jsx("option",{value:M,children:M},M))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:M=>x(M.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:v,onChange:M=>m(M.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,v),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function Xo(t){return t.replaceAll("_"," ")}function d0(t){return t.replaceAll("_"," ")}function to(t){return t.split(".").pop()||t}function Xu(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function f0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Mr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function ai({className:t,children:r}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function h0({className:t}){return d.jsxs(ai,{className:t,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function p0({className:t}){return d.jsxs(ai,{className:t,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function g0({className:t}){return d.jsxs(ai,{className:t,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function m0({className:t}){return d.jsxs(ai,{className:t,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function y0({className:t}){return d.jsxs(ai,{className:t,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function kp({className:t}){return d.jsx(ai,{className:t,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function v0({className:t}){return d.jsx(ai,{className:t,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const x0="modulepreload",w0=function(t,r){return new URL(t,r).href},nh={},_0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(v){return Promise.all(v.map(m=>Promise.resolve(m).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),x=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(v=>{if(v=w0(v,s),v in nh)return;nh[v]=!0;const m=v.endsWith(".css"),y=m?'[rel="stylesheet"]':"";if(!!s)for(let j=h.length-1;j>=0;j--){const E=h[j];if(E.href===v&&(!m||E.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${v}"]${y}`))return;const N=document.createElement("link");if(N.rel=m?"stylesheet":x0,m||(N.as="script"),N.crossOrigin="",N.href=v,x&&N.setAttribute("nonce",x),document.head.appendChild(N),m)return new Promise((j,E)=>{N.addEventListener("load",j),N.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${v}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function rt(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Ol(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}kl.prototype=Ol.prototype={constructor:kl,on:function(t,r){var o=this._,s=k0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),ih.hasOwnProperty(r)?{space:ih[r],local:t}:t}function j0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===qu&&r.documentElement.namespaceURI===qu?r.createElement(t):r.createElementNS(o,t)}}function b0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Np(t){var r=Fl(t);return(r.local?b0:j0)(r)}function E0(){}function dc(t){return t==null?E0:function(){return this.querySelector(t)}}function C0(t){typeof t!="function"&&(t=dc(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=k&&(k=M+1);!(A=E[k])&&++k=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function J0(t){t||(t=ev);function r(m,y){return m&&y?t(m.__data__,y.__data__):!m-!y}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function tv(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function nv(){return Array.from(this)}function rv(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?pv:typeof r=="function"?mv:gv)(t,r,o??"")):Xi(this.node(),t)}function Xi(t,r){return t.style.getPropertyValue(r)||Mp(t).getComputedStyle(t,null).getPropertyValue(r)}function vv(t){return function(){delete this[t]}}function xv(t,r){return function(){this[t]=r}}function wv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function _v(t,r){return arguments.length>1?this.each((r==null?vv:typeof r=="function"?wv:xv)(t,r)):this.node()[t]}function Pp(t){return t.trim().split(/^|\s+/)}function fc(t){return t.classList||new Ip(t)}function Ip(t){this._node=t,this._names=Pp(t.getAttribute("class")||"")}Ip.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Rp(t,r){for(var o=fc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function qv(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function Ku(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:x,dispatch:v}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:x,enumerable:!0,configurable:!0},_:{value:v}})}Ku.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function ox(t){return!t.ctrlKey&&!t.button}function sx(){return this.parentNode}function lx(t,r){return r??{x:t.x,y:t.y}}function ax(){return navigator.maxTouchPoints||"ontouchstart"in this}function Dp(){var t=ox,r=sx,o=lx,s=ax,a={},u=Ol("start","drag","end"),c=0,h,p,x,v,m=0;function y(b){b.on("mousedown.drag",_).filter(s).on("touchstart.drag",E).on("touchmove.drag",w,ix).on("touchend.drag touchcancel.drag",M).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(b,A){if(!(v||!t.call(this,b,A))){var $=k(this,r.call(this,b,A),b,A,"mouse");$&&(Gt(b.view).on("mousemove.drag",N,qo).on("mouseup.drag",j,qo),$p(b.view),Ru(b),x=!1,h=b.clientX,p=b.clientY,$("start",b))}}function N(b){if(Yi(b),!x){var A=b.clientX-h,$=b.clientY-p;x=A*A+$*$>m}a.mouse("drag",b)}function j(b){Gt(b.view).on("mousemove.drag mouseup.drag",null),zp(b.view,x),Yi(b),a.mouse("end",b)}function E(b,A){if(t.call(this,b,A)){var $=b.changedTouches,V=r.call(this,b,A),X=$.length,G,J;for(G=0;G>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?hl(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?hl(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=cx.exec(t))?new Ot(r[1],r[2],r[3],1):(r=dx.exec(t))?new Ot(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=fx.exec(t))?hl(r[1],r[2],r[3],r[4]):(r=hx.exec(t))?hl(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=px.exec(t))?dh(r[1],r[2]/100,r[3]/100,1):(r=gx.exec(t))?dh(r[1],r[2]/100,r[3]/100,r[4]):oh.hasOwnProperty(t)?ah(oh[t]):t==="transparent"?new Ot(NaN,NaN,NaN,0):null}function ah(t){return new Ot(t>>16&255,t>>8&255,t&255,1)}function hl(t,r,o,s){return s<=0&&(t=r=o=NaN),new Ot(t,r,o,s)}function vx(t){return t instanceof ls||(t=ri(t)),t?(t=t.rgb(),new Ot(t.r,t.g,t.b,t.opacity)):new Ot}function Qu(t,r,o,s){return arguments.length===1?vx(t):new Ot(t,r,o,s??1)}function Ot(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}hc(Ot,Qu,Op(ls,{brighter(t){return t=t==null?Ml:Math.pow(Ml,t),new Ot(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Ko:Math.pow(Ko,t),new Ot(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Ot(ti(this.r),ti(this.g),ti(this.b),Pl(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:uh,formatHex:uh,formatHex8:xx,formatRgb:ch,toString:ch}));function uh(){return`#${ei(this.r)}${ei(this.g)}${ei(this.b)}`}function xx(){return`#${ei(this.r)}${ei(this.g)}${ei(this.b)}${ei((isNaN(this.opacity)?1:this.opacity)*255)}`}function ch(){const t=Pl(this.opacity);return`${t===1?"rgb(":"rgba("}${ti(this.r)}, ${ti(this.g)}, ${ti(this.b)}${t===1?")":`, ${t})`}`}function Pl(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ti(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ei(t){return t=ti(t),(t<16?"0":"")+t.toString(16)}function dh(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new yn(t,r,o,s)}function Fp(t){if(t instanceof yn)return new yn(t.h,t.s,t.l,t.opacity);if(t instanceof ls||(t=ri(t)),!t)return new yn;if(t instanceof yn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new yn(c,h,p,t.opacity)}function wx(t,r,o,s){return arguments.length===1?Fp(t):new yn(t,r,o,s??1)}function yn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}hc(yn,wx,Op(ls,{brighter(t){return t=t==null?Ml:Math.pow(Ml,t),new yn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Ko:Math.pow(Ko,t),new yn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Ot(Tu(t>=240?t-240:t+120,a,s),Tu(t,a,s),Tu(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new yn(fh(this.h),pl(this.s),pl(this.l),Pl(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 t=Pl(this.opacity);return`${t===1?"hsl(":"hsla("}${fh(this.h)}, ${pl(this.s)*100}%, ${pl(this.l)*100}%${t===1?")":`, ${t})`}`}}));function fh(t){return t=(t||0)%360,t<0?t+360:t}function pl(t){return Math.max(0,Math.min(1,t||0))}function Tu(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const pc=t=>()=>t;function _x(t,r){return function(o){return t+o*r}}function Sx(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function kx(t){return(t=+t)==1?Hp:function(r,o){return o-r?Sx(r,o,t):pc(isNaN(r)?o:r)}}function Hp(t,r){var o=r-t;return o?_x(t,o):pc(isNaN(t)?r:t)}const Il=(function t(r){var o=kx(r);function s(a,u){var c=o((a=Qu(a)).r,(u=Qu(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),x=Hp(a.opacity,u.opacity);return function(v){return a.r=c(v),a.g=h(v),a.b=p(v),a.opacity=x(v),a+""}}return s.gamma=t,s})(1);function Nx(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:Dn(s,a)})),o=Lu.lastIndex;return o180?v+=360:v-x>180&&(x+=360),y.push({i:m.push(a(m)+"rotate(",null,s)-2,x:Dn(x,v)})):v&&m.push(a(m)+"rotate("+v+s)}function h(x,v,m,y){x!==v?y.push({i:m.push(a(m)+"skewX(",null,s)-2,x:Dn(x,v)}):v&&m.push(a(m)+"skewX("+v+s)}function p(x,v,m,y,_,N){if(x!==m||v!==y){var j=_.push(a(_)+"scale(",null,",",null,")");N.push({i:j-4,x:Dn(x,m)},{i:j-2,x:Dn(v,y)})}else(m!==1||y!==1)&&_.push(a(_)+"scale("+m+","+y+")")}return function(x,v){var m=[],y=[];return x=t(x),v=t(v),u(x.translateX,x.translateY,v.translateX,v.translateY,m,y),c(x.rotate,v.rotate,m,y),h(x.skewX,v.skewX,m,y),p(x.scaleX,x.scaleY,v.scaleX,v.scaleY,m,y),x=v=null,function(_){for(var N=-1,j=y.length,E;++N=0&&t._call.call(void 0,r),t=t._next;--qi}function gh(){ii=(Tl=Zo.now())+Hl,qi=Wo=0;try{Ox()}finally{qi=0,Hx(),ii=0}}function Fx(){var t=Zo.now(),r=t-Tl;r>Up&&(Hl-=r,Tl=t)}function Hx(){for(var t,r=Rl,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:Rl=o);Uo=t,ec(s)}function ec(t){if(!qi){Wo&&(Wo=clearTimeout(Wo));var r=t-ii;r>24?(t<1/0&&(Wo=setTimeout(gh,t-Zo.now()-Hl)),Bo&&(Bo=clearInterval(Bo))):(Bo||(Tl=Zo.now(),Bo=setInterval(Fx,Up)),qi=1,Yp(gh))}}function mh(t,r,o){var s=new Ll;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Bx=Ol("start","end","cancel","interrupt"),Vx=[],Xp=0,yh=1,tc=2,jl=3,vh=4,nc=5,bl=6;function Bl(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;Wx(t,o,{name:r,index:s,group:a,on:Bx,tween:Vx,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Xp})}function mc(t,r){var o=_n(t,r);if(o.state>Xp)throw new Error("too late; already scheduled");return o}function Fn(t,r){var o=_n(t,r);if(o.state>jl)throw new Error("too late; already running");return o}function _n(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Wx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=Gp(u,0,o.time);function u(x){o.state=yh,o.timer.restart(c,o.delay,o.time),o.delay<=x&&c(x-o.delay)}function c(x){var v,m,y,_;if(o.state!==yh)return p();for(v in s)if(_=s[v],_.name===o.name){if(_.state===jl)return mh(c);_.state===vh?(_.state=bl,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete s[v]):+vtc&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function ww(t,r,o){var s,a,u=xw(r)?mc:Fn;return function(){var c=u(this,t),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function _w(t,r){var o=this._id;return arguments.length<2?_n(this.node(),o).on.on(t):this.each(ww(o,t,r))}function Sw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function kw(){return this.on("end.remove",Sw(this._id))}function Nw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=dc(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function qw(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function tr(t,r,o){this.k=t,this.x=r,this.y=o}tr.prototype={constructor:tr,scale:function(t){return t===1?this:new tr(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new tr(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Vl=new tr(1,0,0);Zp.prototype=tr.prototype;function Zp(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Vl;return t.__zoom}function Au(t){t.stopImmediatePropagation()}function Vo(t){t.preventDefault(),t.stopImmediatePropagation()}function Kw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Qw(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function xh(){return this.__zoom||Vl}function Zw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Jw(){return navigator.maxTouchPoints||"ontouchstart"in this}function e1(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function Jp(){var t=Kw,r=Qw,o=e1,s=Zw,a=Jw,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=Nl,x=Ol("start","zoom","end"),v,m,y,_=500,N=150,j=0,E=10;function w(I){I.property("__zoom",xh).on("wheel.zoom",X,{passive:!1}).on("mousedown.zoom",G).on("dblclick.zoom",J).filter(a).on("touchstart.zoom",Z).on("touchmove.zoom",re).on("touchend.zoom touchcancel.zoom",te).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}w.transform=function(I,W,H,U){var C=I.selection?I.selection():I;C.property("__zoom",xh),I!==C?A(I,W,H,U):C.interrupt().each(function(){$(this,arguments).event(U).start().zoom(null,typeof W=="function"?W.apply(this,arguments):W).end()})},w.scaleBy=function(I,W,H,U){w.scaleTo(I,function(){var C=this.__zoom.k,D=typeof W=="function"?W.apply(this,arguments):W;return C*D},H,U)},w.scaleTo=function(I,W,H,U){w.transform(I,function(){var C=r.apply(this,arguments),D=this.__zoom,B=H==null?b(C):typeof H=="function"?H.apply(this,arguments):H,P=D.invert(B),z=typeof W=="function"?W.apply(this,arguments):W;return o(k(M(D,z),B,P),C,c)},H,U)},w.translateBy=function(I,W,H,U){w.transform(I,function(){return o(this.__zoom.translate(typeof W=="function"?W.apply(this,arguments):W,typeof H=="function"?H.apply(this,arguments):H),r.apply(this,arguments),c)},null,U)},w.translateTo=function(I,W,H,U,C){w.transform(I,function(){var D=r.apply(this,arguments),B=this.__zoom,P=U==null?b(D):typeof U=="function"?U.apply(this,arguments):U;return o(Vl.translate(P[0],P[1]).scale(B.k).translate(typeof W=="function"?-W.apply(this,arguments):-W,typeof H=="function"?-H.apply(this,arguments):-H),D,c)},U,C)};function M(I,W){return W=Math.max(u[0],Math.min(u[1],W)),W===I.k?I:new tr(W,I.x,I.y)}function k(I,W,H){var U=W[0]-H[0]*I.k,C=W[1]-H[1]*I.k;return U===I.x&&C===I.y?I:new tr(I.k,U,C)}function b(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function A(I,W,H,U){I.on("start.zoom",function(){$(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(U).end()}).tween("zoom",function(){var C=this,D=arguments,B=$(C,D).event(U),P=r.apply(C,D),z=H==null?b(P):typeof H=="function"?H.apply(C,D):H,ie=Math.max(P[1][0]-P[0][0],P[1][1]-P[0][1]),oe=C.__zoom,de=typeof W=="function"?W.apply(C,D):W,pe=p(oe.invert(z).concat(ie/oe.k),de.invert(z).concat(ie/de.k));return function(he){if(he===1)he=de;else{var Q=pe(he),ae=ie/Q[2];he=new tr(ae,z[0]-Q[0]*ae,z[1]-Q[1]*ae)}B.zoom(null,he)}})}function $(I,W,H){return!H&&I.__zooming||new V(I,W)}function V(I,W){this.that=I,this.args=W,this.active=0,this.sourceEvent=null,this.extent=r.apply(I,W),this.taps=0}V.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,W){return this.mouse&&I!=="mouse"&&(this.mouse[1]=W.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=W.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=W.invert(this.touch1[0])),this.that.__zoom=W,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var W=Gt(this.that).datum();x.call(I,this.that,new qw(I,{sourceEvent:this.sourceEvent,target:w,transform:this.that.__zoom,dispatch:x}),W)}};function X(I,...W){if(!t.apply(this,arguments))return;var H=$(this,W).event(I),U=this.__zoom,C=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,s.apply(this,arguments)))),D=mn(I);if(H.wheel)(H.mouse[0][0]!==D[0]||H.mouse[0][1]!==D[1])&&(H.mouse[1]=U.invert(H.mouse[0]=D)),clearTimeout(H.wheel);else{if(U.k===C)return;H.mouse=[D,U.invert(D)],El(this),H.start()}Vo(I),H.wheel=setTimeout(B,N),H.zoom("mouse",o(k(M(U,C),H.mouse[0],H.mouse[1]),H.extent,c));function B(){H.wheel=null,H.end()}}function G(I,...W){if(y||!t.apply(this,arguments))return;var H=I.currentTarget,U=$(this,W,!0).event(I),C=Gt(I.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",ie,!0),D=mn(I,H),B=I.clientX,P=I.clientY;$p(I.view),Au(I),U.mouse=[D,this.__zoom.invert(D)],El(this),U.start();function z(oe){if(Vo(oe),!U.moved){var de=oe.clientX-B,pe=oe.clientY-P;U.moved=de*de+pe*pe>j}U.event(oe).zoom("mouse",o(k(U.that.__zoom,U.mouse[0]=mn(oe,H),U.mouse[1]),U.extent,c))}function ie(oe){C.on("mousemove.zoom mouseup.zoom",null),zp(oe.view,U.moved),Vo(oe),U.event(oe).end()}}function J(I,...W){if(t.apply(this,arguments)){var H=this.__zoom,U=mn(I.changedTouches?I.changedTouches[0]:I,this),C=H.invert(U),D=H.k*(I.shiftKey?.5:2),B=o(k(M(H,D),U,C),r.apply(this,W),c);Vo(I),h>0?Gt(this).transition().duration(h).call(A,B,U,I):Gt(this).call(w.transform,B,U,I)}}function Z(I,...W){if(t.apply(this,arguments)){var H=I.touches,U=H.length,C=$(this,W,I.changedTouches.length===U).event(I),D,B,P,z;for(Au(I),B=0;B`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},Jo=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],eg=["Enter"," ","Escape"],tg={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Ki;(function(t){t.Strict="strict",t.Loose="loose"})(Ki||(Ki={}));var ni;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(ni||(ni={}));var es;(function(t){t.Partial="partial",t.Full="full"})(es||(es={}));const ng={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Pr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Pr||(Pr={}));var ts;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(ts||(ts={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const wh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function rg(t){return t===null?null:t?"valid":"invalid"}const ig=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,t1=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),vc=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),as=(t,r=[0,0])=>{const{width:o,height:s}=Sn(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},n1=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):vc(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,Wl(a,Al(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?Ul(s):{x:0,y:0,width:0,height:0}},us=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=Wl(o,Al(a)),s=!0)}),s?Ul(o):{x:0,y:0,width:0,height:0}},xc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,x=r.width/a,v=r.height/a,m=[];for(const y of t.values()){const{measured:_,selectable:N=!0,hidden:j=!1}=y;if(c&&!N||j)continue;const E=_.width??y.width??y.initialWidth??0,w=_.height??y.height??y.initialHeight??0,{x:M,y:k}=y.internals.positionAbsolute,b=ag(h,p,x,v,M,k,E,w),A=E*w,$=u&&b>0;(!y.internals.handleBounds||$||b>=A||y.dragging)&&m.push(y)}return m},r1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function i1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=Sn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function o1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const h=i1(t,c),p=us(h),x=_c(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(x,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function og({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),h=c.parentId?o.get(c.parentId):void 0,{x:p,y:x}=h?h.internals.positionAbsolute:{x:0,y:0},v=c.origin??s;let m=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",wn.error005());else{const{width:_,height:N}=Sn(h);_&&N&&(m=[[p,x],[p+_,x+N]])}else h&&si(c.extent)&&(m=[[c.extent[0][0]+p,c.extent[0][1]+x],[c.extent[1][0]+p,c.extent[1][1]+x]]);const y=si(m)?oi(r,m,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",wn.error015())),{position:{x:y.x-p+(c.measured.width??0)*v[0],y:y.y-x+(c.measured.height??0)*v[1]},positionAbsolute:y}}async function s1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(y=>y.id)),c=[];for(const y of o){if(y.deletable===!1)continue;const _=u.has(y.id),N=!_&&y.parentId&&c.find(j=>j.id===y.parentId);(_||N)&&c.push(y)}const h=new Set(r.map(y=>y.id)),p=s.filter(y=>y.deletable!==!1),v=r1(c,p);for(const y of p)h.has(y.id)&&!v.find(N=>N.id===y.id)&&v.push(y);if(!a)return{edges:v,nodes:c};const m=await a({nodes:c,edges:v});return typeof m=="boolean"?m?{edges:v,nodes:c}:{edges:[],nodes:[]}:m}const Qi=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),oi=(t={x:0,y:0},r,o)=>({x:Qi(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:Qi(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function sg(t,r,o){const{width:s,height:a}=Sn(o),{x:u,y:c}=o.internals.positionAbsolute;return oi(t,[[u,c],[u+s,c+a]],r)}const _h=(t,r,o)=>to?-Qi(Math.abs(t-o),1,r)/r:0,wc=(t,r,o=15,s=40)=>{const a=_h(t.x,s,r.width-s)*o,u=_h(t.y,s,r.height-s)*o;return[a,u]},Wl=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),rc=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),Ul=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),ns=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=vc(t)?t.internals.positionAbsolute:as(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},Al=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=vc(t)?t.internals.positionAbsolute:as(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},lg=(t,r)=>Ul(Wl(rc(t),rc(r))),ag=(t,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),x=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*x)},$l=(t,r)=>ag(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),Sh=t=>vn(t.width)&&vn(t.height)&&vn(t.x)&&vn(t.y),vn=t=>!isNaN(t)&&isFinite(t),ug=(t,r)=>(o,s)=>{},cs=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),ds=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(t-o)/a,y:(r-s)/a};return u?cs(h,c):h},Zi=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Wi(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function l1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Wi(t,o),a=Wi(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Wi(t.top??t.y??0,o),a=Wi(t.bottom??t.y??0,o),u=Wi(t.left??t.x??0,r),c=Wi(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function a1(t,r,o,s,a,u){const{x:c,y:h}=Zi(t,[r,o,s]),{x:p,y:x}=Zi({x:t.x+t.width,y:t.y+t.height},[r,o,s]),v=a-p,m=u-x;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(v),bottom:Math.floor(m)}}const _c=(t,r,o,s,a,u)=>{const c=l1(u,r,o),h=(r-c.x)/t.width,p=(o-c.y)/t.height,x=Math.min(h,p),v=Qi(x,s,a),m=t.x+t.width/2,y=t.y+t.height/2,_=r/2-m*v,N=o/2-y*v,j=a1(t,_,N,v,r,o),E={left:Math.min(j.left-c.left,0),top:Math.min(j.top-c.top,0),right:Math.min(j.right-c.right,0),bottom:Math.min(j.bottom-c.bottom,0)};return{x:_-E.left+E.right,y:N-E.top+E.bottom,zoom:v}},rs=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function si(t){return t!=null&&t!=="parent"}function Sn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function cg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function dg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function kh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function u1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function c1(t){return{...tg,...t||{}}}function Go(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=xn(t),h=ds({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y:x}=o?cs(h,r):h;return{xSnapped:p,ySnapped:x,...h}}const Sc=t=>({width:t.offsetWidth,height:t.offsetHeight}),fg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},d1=["INPUT","SELECT","TEXTAREA"];function hg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:d1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const pg=t=>"clientX"in t,xn=(t,r)=>{var u,c;const o=pg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},Nh=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...Sc(c)}})};function gg({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=t*.125+a*.375+c*.375+o*.125,x=r*.125+u*.375+h*.375+s*.125,v=Math.abs(p-t),m=Math.abs(x-r);return[p,x,v,m]}function yl(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function jh({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case Se.Left:return[r-yl(r-s,u),o];case Se.Right:return[r+yl(s-r,u),o];case Se.Top:return[r,o-yl(o-a,u)];case Se.Bottom:return[r,o+yl(a-o,u)]}}function mg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top,curvature:c=.25}){const[h,p]=jh({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[x,v]=jh({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[m,y,_,N]=gg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:x,targetControlY:v});return[`M${t},${r} C${h},${p} ${x},${v} ${s},${a}`,m,y,_,N]}function yg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const p1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,g1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),m1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",wn.error006()),r;const s=o.getEdgeId||p1;let a;return ig(t)?a={...t}:a={...t,id:s(t)},g1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function vg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=yg({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,h]}const bh={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},y1=({source:t,sourcePosition:r=Se.Bottom,target:o})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function v1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:s=Se.Top,center:a,offset:u,stepPosition:c}){const h=bh[r],p=bh[s],x={x:t.x+h.x*u,y:t.y+h.y*u},v={x:o.x+p.x*u,y:o.y+p.y*u},m=y1({source:x,sourcePosition:r,target:v}),y=m.x!==0?"x":"y",_=m[y];let N=[],j,E;const w={x:0,y:0},M={x:0,y:0},[,,k,b]=yg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[y]*p[y]===-1){y==="x"?(j=a.x??x.x+(v.x-x.x)*c,E=a.y??(x.y+v.y)/2):(j=a.x??(x.x+v.x)/2,E=a.y??x.y+(v.y-x.y)*c);const X=[{x:j,y:x.y},{x:j,y:v.y}],G=[{x:x.x,y:E},{x:v.x,y:E}];h[y]===_?N=y==="x"?X:G:N=y==="x"?G:X}else{const X=[{x:x.x,y:v.y}],G=[{x:v.x,y:x.y}];if(y==="x"?N=h.x===_?G:X:N=h.y===_?X:G,r===s){const I=Math.abs(t[y]-o[y]);if(I<=u){const W=Math.min(u-1,u-I);h[y]===_?w[y]=(x[y]>t[y]?-1:1)*W:M[y]=(v[y]>o[y]?-1:1)*W}}if(r!==s){const I=y==="x"?"y":"x",W=h[y]===p[I],H=x[I]>v[I],U=x[I]=te?(j=(J.x+Z.x)/2,E=N[0].y):(j=N[0].x,E=(J.y+Z.y)/2)}const A={x:x.x+w.x,y:x.y+w.y},$={x:v.x+M.x,y:v.y+M.y};return[[t,...A.x!==N[0].x||A.y!==N[0].y?[A]:[],...N,...$.x!==N[N.length-1].x||$.y!==N[N.length-1].y?[$]:[],o],j,E,k,b]}function x1(t,r,o,s){const a=Math.min(Eh(t,r)/2,Eh(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const x=t.xo.id===r):t[0])||null}function oc(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function _1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const x=oc(p,r);u.has(x)||(c.push({id:x,color:p.color||o,...p}),u.add(x))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const xg=1e3,S1=10,kc={nodeOrigin:[0,0],nodeExtent:Jo,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},k1={...kc,checkEquality:!0};function Nc(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function N1(t,r,o){const s=Nc(kc,o);for(const a of t.values())if(a.parentId)bc(a,t,r,s);else{const u=as(a,s.nodeOrigin),c=si(a.extent)?a.extent:s.nodeExtent,h=oi(u,c,Sn(a));a.internals.positionAbsolute=h}}function j1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function jc(t){return t==="manual"}function sc(t,r,o,s={}){var v,m;const a=Nc(k1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!jc(a.zIndexMode)?xg:0;let p=t.length>0,x=!1;r.clear(),o.clear();for(const y of t){let _=c.get(y.id);if(a.checkEquality&&y===(_==null?void 0:_.internals.userNode))r.set(y.id,_);else{const N=as(y,a.nodeOrigin),j=si(y.extent)?y.extent:a.nodeExtent,E=oi(N,j,Sn(y));_={...a.defaults,...y,measured:{width:(v=y.measured)==null?void 0:v.width,height:(m=y.measured)==null?void 0:m.height},internals:{positionAbsolute:E,handleBounds:j1(y,_),z:wg(y,h,a.zIndexMode),userNode:y}},r.set(y.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),y.parentId&&bc(_,r,o,s,u),x||(x=y.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:x}}function b1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function bc(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=Nc(kc,s),x=t.parentId,v=r.get(x);if(!v){console.warn(`Parent node ${x} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}b1(t,o),a&&!v.parentId&&v.internals.rootParentIndex===void 0&&p==="auto"&&(v.internals.rootParentIndex=++a.i,v.internals.z=v.internals.z+a.i*S1),a&&v.internals.rootParentIndex!==void 0&&(a.i=v.internals.rootParentIndex);const m=u&&!jc(p)?xg:0,{x:y,y:_,z:N}=E1(t,v,c,h,m,p),{positionAbsolute:j}=t.internals,E=y!==j.x||_!==j.y;(E||N!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:E?{x:y,y:_}:j,z:N}})}function wg(t,r,o){const s=vn(t.zIndex)?t.zIndex:0;return jc(o)?s:s+(t.selected?r:0)}function E1(t,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=Sn(t),x=as(t,o),v=si(t.extent)?oi(x,t.extent,p):x;let m=oi({x:c+v.x,y:h+v.y},s,p);t.extent==="parent"&&(m=sg(m,p,r));const y=wg(t,a,u),_=r.internals.z??0;return{x:m.x,y:m.y,z:_>=y?_+1:y}}function Ec(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const x=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??ns(p),v=lg(x,h.rect);u.set(h.parentId,{expandedRect:v,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},x)=>{var k;const v=p.internals.positionAbsolute,m=Sn(p),y=p.origin??s,_=h.x0||N>0||w||M)&&(a.push({id:x,type:"position",position:{x:p.position.x-_+w,y:p.position.y-N+M}}),(k=o.get(x))==null||k.forEach(b=>{t.some(A=>A.id===b.id)||a.push({id:b.id,type:"position",position:{x:b.position.x+_,y:b.position.y+N}})})),(m.width0){const _=Ec(y,r,o,a);x.push(..._)}return{changes:x,updatedInternals:p}}async function M1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Ih(t,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${t}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${t}-${u}`;const x=s.get(c)||new Map;s.set(c,x.set(o,r))}}function _g(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},x=`${a}-${c}--${u}-${h}`,v=`${u}-${h}--${a}-${c}`;Ih("source",p,v,t,a,c),Ih("target",p,x,t,u,h),r.set(s.id,s)}}function Sg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:Sg(o,r):!1}function Rh(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function P1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!Sg(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function $u({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[x,v]of r){const m=(c=o.get(x))==null?void 0:c.internals.userNode;m&&a.push({...m,position:v.position,dragging:s})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function I1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=cs(u,r);return{x:c.x-u.x,y:c.y-u.y}}function R1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,x={x:0,y:0},v=null,m=!1,y=null,_=!1,N=!1,j=null;function E({noDragClassName:M,handleSelector:k,domNode:b,isSelectable:A,nodeId:$,nodeClickDistance:V=0}){y=Gt(b);function X({x:re,y:te}){const{nodeLookup:I,nodeExtent:W,snapGrid:H,snapToGrid:U,nodeOrigin:C,onNodeDrag:D,onSelectionDrag:B,onError:P,updateNodePositions:z}=r();u={x:re,y:te};let ie=!1;const oe=h.size>1,de=oe&&W?rc(us(h)):null,pe=oe&&U?I1({dragItems:h,snapGrid:H,x:re,y:te}):null;for(const[he,Q]of h){if(!I.has(he))continue;let ae={x:re-Q.distance.x,y:te-Q.distance.y};U&&(ae=pe?{x:Math.round(ae.x+pe.x),y:Math.round(ae.y+pe.y)}:cs(ae,H));let me=null;if(oe&&W&&!Q.extent&&de){const{positionAbsolute:ne}=Q.internals,Ne=ne.x-de.x+W[0][0],Me=ne.x+Q.measured.width-de.x2+W[1][0],Re=ne.y-de.y+W[0][1],Le=ne.y+Q.measured.height-de.y2+W[1][1];me=[[Ne,Re],[Me,Le]]}const{position:ke,positionAbsolute:ve}=og({nodeId:he,nextPosition:ae,nodeLookup:I,nodeExtent:me||W,nodeOrigin:C,onError:P});ie=ie||Q.position.x!==ke.x||Q.position.y!==ke.y,Q.position=ke,Q.internals.positionAbsolute=ve}if(N=N||ie,!!ie&&(z(h,!0),j&&(s||D||!$&&B))){const[he,Q]=$u({nodeId:$,dragItems:h,nodeLookup:I});s==null||s(j,h,he,Q),D==null||D(j,he,Q),$||B==null||B(j,Q)}}async function G(){if(!v)return;const{transform:re,panBy:te,autoPanSpeed:I,autoPanOnNodeDrag:W}=r();if(!W){p=!1,cancelAnimationFrame(c);return}const[H,U]=wc(x,v,I);(H!==0||U!==0)&&(u.x=(u.x??0)-H/re[2],u.y=(u.y??0)-U/re[2],await te({x:H,y:U})&&X(u)),c=requestAnimationFrame(G)}function J(re){var oe;const{nodeLookup:te,multiSelectionActive:I,nodesDraggable:W,transform:H,snapGrid:U,snapToGrid:C,selectNodesOnDrag:D,onNodeDragStart:B,onSelectionDragStart:P,unselectNodesAndEdges:z}=r();m=!0,(!D||!A)&&!I&&$&&((oe=te.get($))!=null&&oe.selected||z()),A&&D&&$&&(t==null||t($));const ie=Go(re.sourceEvent,{transform:H,snapGrid:U,snapToGrid:C,containerBounds:v});if(u=ie,h=P1(te,W,ie,$),h.size>0&&(o||B||!$&&P)){const[de,pe]=$u({nodeId:$,dragItems:h,nodeLookup:te});o==null||o(re.sourceEvent,h,de,pe),B==null||B(re.sourceEvent,de,pe),$||P==null||P(re.sourceEvent,pe)}}const Z=Dp().clickDistance(V).on("start",re=>{const{domNode:te,nodeDragThreshold:I,transform:W,snapGrid:H,snapToGrid:U}=r();v=(te==null?void 0:te.getBoundingClientRect())||null,_=!1,N=!1,j=re.sourceEvent,I===0&&J(re),u=Go(re.sourceEvent,{transform:W,snapGrid:H,snapToGrid:U,containerBounds:v}),x=xn(re.sourceEvent,v)}).on("drag",re=>{const{autoPanOnNodeDrag:te,transform:I,snapGrid:W,snapToGrid:H,nodeDragThreshold:U,nodeLookup:C}=r(),D=Go(re.sourceEvent,{transform:I,snapGrid:W,snapToGrid:H,containerBounds:v});if(j=re.sourceEvent,(re.sourceEvent.type==="touchmove"&&re.sourceEvent.touches.length>1||$&&!C.has($))&&(_=!0),!_){if(!p&&te&&m&&(p=!0,G()),!m){const B=xn(re.sourceEvent,v),P=B.x-x.x,z=B.y-x.y;Math.sqrt(P*P+z*z)>U&&J(re)}(u.x!==D.xSnapped||u.y!==D.ySnapped)&&h&&m&&(x=xn(re.sourceEvent,v),X(D))}}).on("end",re=>{if(!m||_){_&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,m=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:te,updateNodePositions:I,onNodeDragStop:W,onSelectionDragStop:H}=r();if(N&&(I(h,!1),N=!1),a||W||!$&&H){const[U,C]=$u({nodeId:$,dragItems:h,nodeLookup:te,dragging:!1});a==null||a(re.sourceEvent,h,U,C),W==null||W(re.sourceEvent,U,C),$||H==null||H(re.sourceEvent,C)}}}).filter(re=>{const te=re.target;return!re.button&&(!M||!Rh(te,`.${M}`,b))&&(!k||Rh(te,k,b))});y.call(Z)}function w(){y==null||y.on(".drag",null)}return{update:E,destroy:w}}function T1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())$l(a,ns(u))>0&&s.push(u);return s}const L1=250;function A1(t,r,o,s){var h,p;let a=[],u=1/0;const c=T1(t,o,r+L1);for(const x of c){const v=[...((h=x.internals.handleBounds)==null?void 0:h.source)??[],...((p=x.internals.handleBounds)==null?void 0:p.target)??[]];for(const m of v){if(s.nodeId===m.nodeId&&s.type===m.type&&s.id===m.id)continue;const{x:y,y:_}=li(x,m,m.position,!0),N=Math.sqrt(Math.pow(y-t.x,2)+Math.pow(_-t.y,2));N>r||(N1){const x=s.type==="source"?"target":"source";return a.find(v=>v.type===x)??a[0]}return a[0]}function kg(t,r,o,s,a,u=!1){var x,v,m;const c=s.get(t);if(!c)return null;const h=a==="strict"?(x=c.internals.handleBounds)==null?void 0:x[r]:[...((v=c.internals.handleBounds)==null?void 0:v.source)??[],...((m=c.internals.handleBounds)==null?void 0:m.target)??[]],p=(o?h==null?void 0:h.find(y=>y.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...li(c,p,p.position,!0)}:p}function Ng(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function $1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const jg=()=>!0;function z1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:x,autoPanOnConnect:v,flowId:m,panBy:y,cancelConnection:_,onConnectStart:N,onConnect:j,onConnectEnd:E,isValidConnection:w=jg,onReconnectEnd:M,updateConnection:k,getTransform:b,getFromHandle:A,autoPanSpeed:$,dragThreshold:V=1,handleDomNode:X}){const G=fg(t.target);let J=0,Z;const{x:re,y:te}=xn(t),I=Ng(u,X),W=h==null?void 0:h.getBoundingClientRect();let H=!1;if(!W||!I)return;const U=kg(a,I,s,p,r);if(!U)return;let C=xn(t,W),D=!1,B=null,P=!1,z=null;function ie(){if(!v||!W)return;const[ke,ve]=wc(C,W,$);y({x:ke,y:ve}),J=requestAnimationFrame(ie)}const oe={...U,nodeId:a,type:I,position:U.position},de=p.get(a);let he={inProgress:!0,isValid:null,from:li(de,oe,Se.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:de,to:C,toHandle:null,toPosition:wh[oe.position],toNode:null,pointer:C};function Q(){H=!0,k(he),N==null||N(t,{nodeId:a,handleId:s,handleType:I})}V===0&&Q();function ae(ke){if(!H){const{x:Le,y:Ze}=xn(ke),pt=Le-re,Xe=Ze-te;if(!(pt*pt+Xe*Xe>V*V))return;Q()}if(!A()||!oe){me(ke);return}const ve=b();C=xn(ke,W),Z=A1(ds(C,ve,!1,[1,1]),o,p,oe),D||(ie(),D=!0);const ne=bg(ke,{handle:Z,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:w,doc:G,lib:x,flowId:m,nodeLookup:p});z=ne.handleDomNode,B=ne.connection,P=$1(!!Z,ne.isValid);const Ne=p.get(a),Me=Ne?li(Ne,oe,Se.Left,!0):he.from,Re={...he,from:Me,isValid:P,to:ne.toHandle&&P?Zi({x:ne.toHandle.x,y:ne.toHandle.y},ve):C,toHandle:ne.toHandle,toPosition:P&&ne.toHandle?ne.toHandle.position:wh[oe.position],toNode:ne.toHandle?p.get(ne.toHandle.nodeId):null,pointer:C};k(Re),he=Re}function me(ke){if(!("touches"in ke&&ke.touches.length>0)){if(H){(Z||z)&&B&&P&&(j==null||j(B));const{inProgress:ve,...ne}=he,Ne={...ne,toPosition:he.toHandle?he.toPosition:null};E==null||E(ke,Ne),u&&(M==null||M(ke,Ne))}_(),cancelAnimationFrame(J),D=!1,P=!1,B=null,z=null,G.removeEventListener("mousemove",ae),G.removeEventListener("mouseup",me),G.removeEventListener("touchmove",ae),G.removeEventListener("touchend",me)}}G.addEventListener("mousemove",ae),G.addEventListener("mouseup",me),G.addEventListener("touchmove",ae),G.addEventListener("touchend",me)}function bg(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:x=jg,nodeLookup:v}){const m=u==="target",y=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:N}=xn(t),j=c.elementFromPoint(_,N),E=j!=null&&j.classList.contains(`${h}-flow__handle`)?j:y,w={handleDomNode:E,isValid:!1,connection:null,toHandle:null};if(E){const M=Ng(void 0,E),k=E.getAttribute("data-nodeid"),b=E.getAttribute("data-handleid"),A=E.classList.contains("connectable"),$=E.classList.contains("connectableend");if(!k||!M)return w;const V={source:m?k:s,sourceHandle:m?b:a,target:m?s:k,targetHandle:m?a:b};w.connection=V;const G=A&&$&&(o===Ki.Strict?m&&M==="source"||!m&&M==="target":k!==s||b!==a);w.isValid=G&&x(V),w.toHandle=kg(k,M,b,v,o,!0)}return w}const lc={onPointerDown:z1,isValid:bg};function D1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Gt(t);function u({translateExtent:h,width:p,height:x,zoomStep:v=1,pannable:m=!0,zoomable:y=!0,inversePan:_=!1}){const N=k=>{if(k.sourceEvent.type!=="wheel"||!r)return;const b=o(),A=k.sourceEvent.ctrlKey&&rs()?10:1,$=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*v,V=b[2]*Math.pow(2,$*A);r.scaleTo(V)};let j=[0,0];const E=k=>{(k.sourceEvent.type==="mousedown"||k.sourceEvent.type==="touchstart")&&(j=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY])},w=k=>{const b=o();if(k.sourceEvent.type!=="mousemove"&&k.sourceEvent.type!=="touchmove"||!r)return;const A=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY],$=[A[0]-j[0],A[1]-j[1]];j=A;const V=s()*Math.max(b[2],Math.log(b[2]))*(_?-1:1),X={x:b[0]-$[0]*V,y:b[1]-$[1]*V},G=[[0,0],[p,x]];r.setViewportConstrained({x:X.x,y:X.y,zoom:b[2]},G,h)},M=Jp().on("start",E).on("zoom",m?w:null).on("zoom.wheel",y?N:null);a.call(M,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:mn}}const Yl=t=>({x:t.x,y:t.y,zoom:t.k}),zu=({x:t,y:r,zoom:o})=>Vl.translate(t,r).scale(o),Cr=(t,r)=>t.target.closest(`.${r}`),Eg=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),O1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Du=(t,r=0,o=O1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Cg=t=>{const r=t.ctrlKey&&rs()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function F1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:x}){return v=>{if(Cr(v,r))return v.ctrlKey&&v.preventDefault(),!1;v.preventDefault(),v.stopImmediatePropagation();const m=o.property("__zoom").k||1;if(v.ctrlKey&&c){const E=mn(v),w=Cg(v),M=m*Math.pow(2,w);s.scaleTo(o,M,E,v);return}const y=v.deltaMode===1?20:1;let _=a===ni.Vertical?0:v.deltaX*y,N=a===ni.Horizontal?0:v.deltaY*y;!rs()&&v.shiftKey&&a!==ni.Vertical&&(_=v.deltaY*y,N=0),s.translateBy(o,-(_/m)*u,-(N/m)*u,{internal:!0});const j=Yl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(v,j):(t.isPanScrolling=!0,h==null||h(v,j)),t.panScrollTimeout=setTimeout(()=>{x==null||x(v,j),t.isPanScrolling=!1},150)}}function H1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=Cr(s,t);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function B1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=Yl(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function V1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;t.usedRightMouseButton=!!(o&&Eg(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,Yl(u.transform)))}}function W1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&Eg(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const p=Yl(c.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function U1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:x,lib:v,connectionInProgress:m}){return y=>{var w;const _=r||o,N=s&&y.ctrlKey,j=y.type==="wheel";if(y.button===1&&y.type==="mousedown"&&(Cr(y,`${v}-flow__node`)||Cr(y,`${v}-flow__edge`)||Cr(y,`${v}-flow__selection`)||Cr(y,`${v}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!c&&!s||h||m&&!j||Cr(y,p)&&j||Cr(y,x)&&(!j||u&&j&&!r)||!s&&y.ctrlKey&&j)return!1;if(!s&&y.type==="touchstart"&&((w=y.touches)==null?void 0:w.length)>1)return y.preventDefault(),!1;if(!_&&!u&&!N&&j||!a&&(y.type==="mousedown"||y.type==="touchstart")||Array.isArray(a)&&!a.includes(y.button)&&y.type==="mousedown")return!1;const E=Array.isArray(a)&&a.includes(y.button)||!y.button||y.button<=1;return(!y.ctrlKey||j||t)&&E}}function Y1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const x={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},v=t.getBoundingClientRect();let m=[[0,0],[v.width,v.height]];const y=typeof ResizeObserver<"u"?new ResizeObserver(te=>{const I=te[0];I&&(m=[[0,0],[I.contentRect.width,I.contentRect.height]])}):null;y==null||y.observe(t);const _=Jp().extent(()=>m).scaleExtent([r,o]).translateExtent(s),N=Gt(t).call(_);b({x:a.x,y:a.y,zoom:Qi(a.zoom,r,o)},[[0,0],[v.width,v.height]],s);const j=N.on("wheel.zoom"),E=N.on("dblclick.zoom");_.wheelDelta(Cg);async function w(te,I){return N?new Promise(W=>{_==null||_.interpolate((I==null?void 0:I.interpolate)==="linear"?Yo:Nl).transform(Du(N,I==null?void 0:I.duration,I==null?void 0:I.ease,()=>W(!0)),te)}):!1}function M({noWheelClassName:te,noPanClassName:I,onPaneContextMenu:W,userSelectionActive:H,panOnScroll:U,panOnDrag:C,panOnScrollMode:D,panOnScrollSpeed:B,preventScrolling:P,zoomOnPinch:z,zoomOnScroll:ie,zoomOnDoubleClick:oe,panActivationKeyPressed:de=!1,zoomActivationKeyPressed:pe,lib:he,onTransformChange:Q,connectionInProgress:ae,paneClickDistance:me,selectionOnDrag:ke}){H&&!x.isZoomingOrPanning&&k();const ve=U&&!pe&&!H;_.clickDistance(ke?1/0:!vn(me)||me<0?0:me);const ne=ve?F1({zoomPanValues:x,noWheelClassName:te,d3Selection:N,d3Zoom:_,panOnScrollMode:D,panOnScrollSpeed:B,zoomOnPinch:z,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):H1({noWheelClassName:te,preventScrolling:P,d3ZoomHandler:j});N.on("wheel.zoom",ne,{passive:!1});const Ne=B1({zoomPanValues:x,onDraggingChange:p,onPanZoomStart:c});_.on("start",Ne);const Me=V1({zoomPanValues:x,panOnDrag:C,onPaneContextMenu:!!W,onPanZoom:u,onTransformChange:Q});_.on("zoom",Me);const Re=W1({zoomPanValues:x,panOnDrag:C,panOnScroll:U,onPaneContextMenu:W,onPanZoomEnd:h,onDraggingChange:p});_.on("end",Re);const Le=U1({panActivationKeyPressed:de,zoomActivationKeyPressed:pe,panOnDrag:C,zoomOnScroll:ie,panOnScroll:U,zoomOnDoubleClick:oe,zoomOnPinch:z,userSelectionActive:H,noPanClassName:I,noWheelClassName:te,lib:he,connectionInProgress:ae});_.filter(Le),oe?N.on("dblclick.zoom",E):N.on("dblclick.zoom",null)}function k(){_.on("zoom",null)}async function b(te,I,W){const H=zu(te),U=_==null?void 0:_.constrain()(H,I,W);return U&&await w(U),U}async function A(te,I){const W=zu(te);return await w(W,I),W}function $(te){if(N){const I=zu(te),W=N.property("__zoom");(W.k!==te.zoom||W.x!==te.x||W.y!==te.y)&&(_==null||_.transform(N,I,null,{sync:!0}))}}function V(){const te=N?Zp(N.node()):{x:0,y:0,k:1};return{x:te.x,y:te.y,zoom:te.k}}async function X(te,I){return N?new Promise(W=>{_==null||_.interpolate((I==null?void 0:I.interpolate)==="linear"?Yo:Nl).scaleTo(Du(N,I==null?void 0:I.duration,I==null?void 0:I.ease,()=>W(!0)),te)}):!1}async function G(te,I){return N?new Promise(W=>{_==null||_.interpolate((I==null?void 0:I.interpolate)==="linear"?Yo:Nl).scaleBy(Du(N,I==null?void 0:I.duration,I==null?void 0:I.ease,()=>W(!0)),te)}):!1}function J(te){_==null||_.scaleExtent(te)}function Z(te){_==null||_.translateExtent(te)}function re(te){const I=!vn(te)||te<0?0:te;_==null||_.clickDistance(I)}return{update:M,destroy:k,setViewport:A,setViewportConstrained:b,getViewport:V,scaleTo:X,scaleBy:G,setScaleExtent:J,setTranslateExtent:Z,syncViewport:$,setClickDistance:re}}var Ji;(function(t){t.Line="line",t.Handle="handle"})(Ji||(Ji={}));function G1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function Th(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function br(t,r){return Math.max(0,r-t)}function Er(t,r){return Math.max(0,t-r)}function vl(t,r,o){return Math.max(0,r-t,t-o)}function Lh(t,r){return t?!r:r}function X1(t,r,o,s,a,u,c,h){let{affectsX:p,affectsY:x}=r;const{isHorizontal:v,isVertical:m}=r,y=v&&m,{xSnapped:_,ySnapped:N}=o,{minWidth:j,maxWidth:E,minHeight:w,maxHeight:M}=s,{x:k,y:b,width:A,height:$,aspectRatio:V}=t;let X=Math.floor(v?_-t.pointerX:0),G=Math.floor(m?N-t.pointerY:0);const J=A+(p?-X:X),Z=$+(x?-G:G),re=-u[0]*A,te=-u[1]*$;let I=vl(J,j,E),W=vl(Z,w,M);if(c){let C=0,D=0;p&&X<0?C=br(k+X+re,c[0][0]):!p&&X>0&&(C=Er(k+J+re,c[1][0])),x&&G<0?D=br(b+G+te,c[0][1]):!x&&G>0&&(D=Er(b+Z+te,c[1][1])),I=Math.max(I,C),W=Math.max(W,D)}if(h){let C=0,D=0;p&&X>0?C=Er(k+X,h[0][0]):!p&&X<0&&(C=br(k+J,h[1][0])),x&&G>0?D=Er(b+G,h[0][1]):!x&&G<0&&(D=br(b+Z,h[1][1])),I=Math.max(I,C),W=Math.max(W,D)}if(a){if(v){const C=vl(J/V,w,M)*V;if(I=Math.max(I,C),c){let D=0;!p&&!x||p&&!x&&y?D=Er(b+te+J/V,c[1][1])*V:D=br(b+te+(p?X:-X)/V,c[0][1])*V,I=Math.max(I,D)}if(h){let D=0;!p&&!x||p&&!x&&y?D=br(b+J/V,h[1][1])*V:D=Er(b+(p?X:-X)/V,h[0][1])*V,I=Math.max(I,D)}}if(m){const C=vl(Z*V,j,E)/V;if(W=Math.max(W,C),c){let D=0;!p&&!x||x&&!p&&y?D=Er(k+Z*V+re,c[1][0])/V:D=br(k+(x?G:-G)*V+re,c[0][0])/V,W=Math.max(W,D)}if(h){let D=0;!p&&!x||x&&!p&&y?D=br(k+Z*V,h[1][0])/V:D=Er(k+(x?G:-G)*V,h[0][0])/V,W=Math.max(W,D)}}}G=G+(G<0?W:-W),X=X+(X<0?I:-I),a&&(y?J>Z*V?G=(Lh(p,x)?-X:X)/V:X=(Lh(p,x)?-G:G)*V:v?(G=X/V,x=p):(X=G*V,p=x));const H=p?k+X:k,U=x?b+G:b;return{width:A+(p?-X:X),height:$+(x?-G:G),x:u[0]*X*(p?-1:1)+H,y:u[1]*G*(x?-1:1)+U}}const Mg={width:0,height:0,x:0,y:0},q1={...Mg,pointerX:0,pointerY:0,aspectRatio:1};function K1(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function Q1({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Gt(t);let c={controlDirection:Th("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:x,boundaries:v,keepAspectRatio:m,resizeDirection:y,onResizeStart:_,onResize:N,onResizeEnd:j,shouldResize:E}){let w={...Mg},M={...q1};c={boundaries:v,resizeDirection:y,keepAspectRatio:m,controlDirection:Th(x)};let k,b=null,A=[],$,V,X,G=!1;const J=Dp().on("start",Z=>{const{nodeLookup:re,transform:te,snapGrid:I,snapToGrid:W,nodeOrigin:H,paneDomNode:U}=o();if(k=re.get(r),!k)return;b=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:C,ySnapped:D}=Go(Z.sourceEvent,{transform:te,snapGrid:I,snapToGrid:W,containerBounds:b});w={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},M={...w,pointerX:C,pointerY:D,aspectRatio:w.width/w.height},$=void 0,V=si(k.extent)?k.extent:void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&($=re.get(k.parentId)),$&&k.extent==="parent"&&(V=[[0,0],[$.measured.width,$.measured.height]]),A=[],X=void 0;for(const[B,P]of re)if(P.parentId===r&&(A.push({id:B,position:{...P.position},extent:P.extent}),P.extent==="parent"||P.expandParent)){const z=K1(P,k,P.origin??H);X?X=[[Math.min(z[0][0],X[0][0]),Math.min(z[0][1],X[0][1])],[Math.max(z[1][0],X[1][0]),Math.max(z[1][1],X[1][1])]]:X=z}_==null||_(Z,{...w})}).on("drag",Z=>{const{transform:re,snapGrid:te,snapToGrid:I,nodeOrigin:W}=o(),H=Go(Z.sourceEvent,{transform:re,snapGrid:te,snapToGrid:I,containerBounds:b}),U=[];if(!k)return;const{x:C,y:D,width:B,height:P}=w,z={},ie=k.origin??W,{width:oe,height:de,x:pe,y:he}=X1(M,c.controlDirection,H,c.boundaries,c.keepAspectRatio,ie,V,X),Q=oe!==B,ae=de!==P,me=pe!==C&&Q,ke=he!==D&&ae;if(!me&&!ke&&!Q&&!ae)return;if((me||ke||ie[0]===1||ie[1]===1)&&(z.x=me?pe:w.x,z.y=ke?he:w.y,w.x=z.x,w.y=z.y,A.length>0)){const Me=pe-C,Re=he-D;for(const Le of A)Le.position={x:Le.position.x-Me+ie[0]*(oe-B),y:Le.position.y-Re+ie[1]*(de-P)},U.push(Le)}if((Q||ae)&&(z.width=Q&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:w.width,z.height=ae&&(!c.resizeDirection||c.resizeDirection==="vertical")?de:w.height,w.width=z.width,w.height=z.height),$&&k.expandParent){const Me=ie[0]*(z.width??0);z.x&&z.x{G&&(j==null||j(Z,{...w}),a==null||a({...w}),G=!1)});u.call(J)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Ou={exports:{}},Fu={},Hu={exports:{}},Bu={};/** - * @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 Ah;function Z1(){if(Ah)return Bu;Ah=1;var t=os();function r(m,y){return m===y&&(m!==0||1/m===1/y)||m!==m&&y!==y}var o=typeof Object.is=="function"?Object.is:r,s=t.useState,a=t.useEffect,u=t.useLayoutEffect,c=t.useDebugValue;function h(m,y){var _=y(),N=s({inst:{value:_,getSnapshot:y}}),j=N[0].inst,E=N[1];return u(function(){j.value=_,j.getSnapshot=y,p(j)&&E({inst:j})},[m,_,y]),a(function(){return p(j)&&E({inst:j}),m(function(){p(j)&&E({inst:j})})},[m]),c(_),_}function p(m){var y=m.getSnapshot;m=m.value;try{var _=y();return!o(m,_)}catch{return!0}}function x(m,y){return y()}var v=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?x:h;return Bu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:v,Bu}var $h;function J1(){return $h||($h=1,Hu.exports=Z1()),Hu.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 zh;function e_(){if(zh)return Fu;zh=1;var t=os(),r=J1();function o(x,v){return x===v&&(x!==0||1/x===1/v)||x!==x&&v!==v}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Fu.useSyncExternalStoreWithSelector=function(x,v,m,y,_){var N=u(null);if(N.current===null){var j={hasValue:!1,value:null};N.current=j}else j=N.current;N=h(function(){function w($){if(!M){if(M=!0,k=$,$=y($),_!==void 0&&j.hasValue){var V=j.value;if(_(V,$))return b=V}return b=$}if(V=b,s(k,$))return V;var X=y($);return _!==void 0&&_(V,X)?(k=$,V):(k=$,b=X)}var M=!1,k,b,A=m===void 0?null:m;return[function(){return w(v())},A===null?void 0:function(){return w(A())}]},[v,m,y,_]);var E=a(x,N[0],N[1]);return c(function(){j.hasValue=!0,j.value=E},[E]),p(E),E},Fu}var Dh;function t_(){return Dh||(Dh=1,Ou.exports=e_()),Ou.exports}var n_=t_();const r_=wp(n_),i_={},Oh=t=>{let r;const o=new Set,s=(v,m)=>{const y=typeof v=="function"?v(r):v;if(!Object.is(y,r)){const _=r;r=m??(typeof y!="object"||y===null)?y:Object.assign({},r,y),o.forEach(N=>N(r,_))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>x,subscribe:v=>(o.add(v),()=>o.delete(v)),destroy:()=>{(i_?"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."),o.clear()}},x=r=t(s,a,p);return p},o_=t=>t?Oh(t):Oh,{useDebugValue:s_}=t0,{useSyncExternalStoreWithSelector:l_}=r_,a_=t=>t;function Pg(t,r=a_,o){const s=l_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return s_(s),s}const Fh=(t,r)=>{const o=o_(t),s=(a,u=r)=>Pg(o,a,u);return Object.assign(s,o),s},u_=(t,r)=>t?Fh(t,r):Fh;function Qe(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}_p();const Gl=L.createContext(null),c_=Gl.Provider,Ig=wn.error001("react");function ze(t,r){const o=L.useContext(Gl);if(o===null)throw new Error(Ig);return Pg(o,t,r)}function Ye(){const t=L.useContext(Gl);if(t===null)throw new Error(Ig);return L.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Hh={display:"none"},d_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Rg="react-flow__node-desc",Tg="react-flow__edge-desc",f_="react-flow__aria-live",h_=t=>t.ariaLiveMessage,p_=t=>t.ariaLabelConfig;function g_({rfId:t}){const r=ze(h_);return d.jsx("div",{id:`${f_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:d_,children:r})}function m_({rfId:t,disableKeyboardA11y:r}){const o=ze(p_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${Rg}-${t}`,style:Hh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${Tg}-${t}`,style:Hh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(g_,{rfId:t})]})}const Xl=L.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return d.jsx("div",{className:rt(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});Xl.displayName="Panel";const Bh="https://reactflow.dev?utm_source=attribution";function y_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:d.jsx(Xl,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Bh}`,children:d.jsx("a",{href:Bh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const v_=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},xl=t=>t.id;function x_(t,r){return Qe(t.selectedNodes.map(xl),r.selectedNodes.map(xl))&&Qe(t.selectedEdges.map(xl),r.selectedEdges.map(xl))}function w_({onSelectionChange:t}){const r=Ye(),{selectedNodes:o,selectedEdges:s}=ze(v_,x_);return L.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const __=t=>!!t.onSelectionChangeHandlers;function S_({onSelectionChange:t}){const r=ze(__);return t||r?d.jsx(w_,{onSelectionChange:t}):null}const Lg=[0,0],k_={x:0,y:0,zoom:1},N_=["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"],Vh=[...N_,"rfId"],j_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Wh={translateExtent:Jo,nodeOrigin:Lg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function b_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=ze(j_,Qe),x=Ye();L.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{v.current=Wh,h()}),[]);const v=L.useRef(Wh);return L.useEffect(()=>{for(const m of Vh){const y=t[m],_=v.current[m];y!==_&&(typeof t[m]>"u"||(m==="nodes"?r(y):m==="edges"?o(y):m==="minZoom"?s(y):m==="maxZoom"?a(y):m==="translateExtent"?u(y):m==="nodeExtent"?c(y):m==="ariaLabelConfig"?x.setState({ariaLabelConfig:c1(y)}):m==="fitView"?x.setState({fitViewQueued:y}):m==="fitViewOptions"?x.setState({fitViewOptions:y}):x.setState({[m]:y})))}v.current=t},Vh.map(m=>t[m])),null}function Uh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function E_(t){var s;const[r,o]=L.useState(t==="system"?null:t);return L.useEffect(()=>{if(t!=="system"){o(t);return}const a=Uh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=Uh())!=null&&s.matches?"dark":"light"}const Yh=typeof document<"u"?document:null;function is(t=null,r={target:Yh,actInsideInputWithModifier:!0}){const[o,s]=L.useState(!1),a=L.useRef(!1),u=L.useRef(new Set([])),[c,h]=L.useMemo(()=>{if(t!==null){const x=(Array.isArray(t)?t:[t]).filter(m=>typeof m=="string").map(m=>m.replace(/\+/g,` -`).replace(` - -`,` -+`).split(` -`)),v=x.reduce((m,y)=>m.concat(...y),[]);return[x,v]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Yh,x=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const v=_=>{var E,w;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!x)&&hg(_))return!1;const j=Xh(_.code,h);if(u.current.add(_[j]),Gh(c,u.current,!1)){const M=((w=(E=_.composedPath)==null?void 0:E.call(_))==null?void 0:w[0])||_.target,k=(M==null?void 0:M.nodeName)==="BUTTON"||(M==null?void 0:M.nodeName)==="A";r.preventDefault!==!1&&(a.current||!k)&&_.preventDefault(),s(!0)}},m=_=>{const N=Xh(_.code,h);Gh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[N]),_.key==="Meta"&&u.current.clear(),a.current=!1},y=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",v),p==null||p.addEventListener("keyup",m),window.addEventListener("blur",y),window.addEventListener("contextmenu",y),()=>{p==null||p.removeEventListener("keydown",v),p==null||p.removeEventListener("keyup",m),window.removeEventListener("blur",y),window.removeEventListener("contextmenu",y)}}},[t,s]),o}function Gh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Xh(t,r){return r.includes(t)?"code":"key"}const C_=()=>{const t=Ye();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=_c(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),x={x:r.x-h,y:r.y-p},v=o.snapGrid??a,m=o.snapToGrid??u;return ds(x,s,m,v)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=Zi(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function Ag(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)M_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function M_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function P_(t,r){return Ag(t,r)}function I_(t,r){return Ag(t,r)}function Jr(t,r){return{id:t,type:"select",selected:r}}function Ui(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(Jr(u.id,c)))}return s}function qh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Kh(t){return{id:t.id,type:"remove"}}const R_=ug();function T_(t,r,o={}){return m1(t,r,{...o,onError:o.onError??R_})}const Qh=t=>t1(t),L_=t=>ig(t);function $g(t){return L.forwardRef(t)}const zg=typeof window<"u"?L.useLayoutEffect:L.useEffect;function Zh(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>A_(()=>o(a=>a+BigInt(1))));return zg(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function A_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Dg=L.createContext(null);function $_({children:t}){const r=Ye(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:x,hasDefaultNodes:v,onNodesChange:m,nodeLookup:y,fitViewQueued:_,onNodesChangeMiddlewareMap:N}=r.getState();let j=p;for(const w of h)j=typeof w=="function"?w(j):w;let E=qh({items:j,lookup:y});for(const w of N.values())E=w(E);v&&x(j),E.length>0?m==null||m(E):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:w,nodes:M,setNodes:k}=r.getState();w&&k(M)})},[]),s=Zh(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:x,hasDefaultEdges:v,onEdgesChange:m,edgeLookup:y}=r.getState();let _=p;for(const N of h)_=typeof N=="function"?N(_):N;v?x(_):m&&m(qh({items:_,lookup:y}))},[]),u=Zh(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Dg.Provider,{value:c,children:t})}function z_(){const t=L.useContext(Dg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const D_=t=>!!t.panZoom;function ql(){const t=C_(),r=Ye(),o=z_(),s=ze(D_),a=L.useMemo(()=>{const u=m=>r.getState().nodeLookup.get(m),c=m=>{o.nodeQueue.push(m)},h=m=>{o.edgeQueue.push(m)},p=m=>{var w,M;const{nodeLookup:y,nodeOrigin:_}=r.getState(),N=Qh(m)?m:y.get(m.id),j=N.parentId?dg(N.position,N.measured,N.parentId,y,_):N.position,E={...N,position:j,width:((w=N.measured)==null?void 0:w.width)??N.width,height:((M=N.measured)==null?void 0:M.height)??N.height};return ns(E)},x=(m,y,_={replace:!1})=>{c(N=>N.map(j=>{if(j.id===m){const E=typeof y=="function"?y(j):y;return _.replace&&Qh(E)?E:{...j,...E}}return j}))},v=(m,y,_={replace:!1})=>{h(N=>N.map(j=>{if(j.id===m){const E=typeof y=="function"?y(j):y;return _.replace&&L_(E)?E:{...j,...E}}return j}))};return{getNodes:()=>r.getState().nodes.map(m=>({...m})),getNode:m=>{var y;return(y=u(m))==null?void 0:y.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:m=[]}=r.getState();return m.map(y=>({...y}))},getEdge:m=>r.getState().edgeLookup.get(m),setNodes:c,setEdges:h,addNodes:m=>{const y=Array.isArray(m)?m:[m];o.nodeQueue.push(_=>[..._,...y])},addEdges:m=>{const y=Array.isArray(m)?m:[m];o.edgeQueue.push(_=>[..._,...y])},toObject:()=>{const{nodes:m=[],edges:y=[],transform:_}=r.getState(),[N,j,E]=_;return{nodes:m.map(w=>({...w})),edges:y.map(w=>({...w})),viewport:{x:N,y:j,zoom:E}}},deleteElements:async({nodes:m=[],edges:y=[]})=>{const{nodes:_,edges:N,onNodesDelete:j,onEdgesDelete:E,triggerNodeChanges:w,triggerEdgeChanges:M,onDelete:k,onBeforeDelete:b}=r.getState(),{nodes:A,edges:$}=await s1({nodesToRemove:m,edgesToRemove:y,nodes:_,edges:N,onBeforeDelete:b}),V=$.length>0,X=A.length>0;if(V){const G=$.map(Kh);E==null||E($),M(G)}if(X){const G=A.map(Kh);j==null||j(A),w(G)}return(X||V)&&(k==null||k({nodes:A,edges:$})),{deletedNodes:A,deletedEdges:$}},getIntersectingNodes:(m,y=!0,_)=>{const N=Sh(m),j=N?m:p(m),E=_!==void 0;return j?(_||r.getState().nodes).filter(w=>{const M=r.getState().nodeLookup.get(w.id);if(M&&!N&&(w.id===m.id||!M.internals.positionAbsolute))return!1;const k=ns(E?w:M),b=$l(k,j);return y&&b>0||b>=k.width*k.height||b>=j.width*j.height}):[]},isNodeIntersecting:(m,y,_=!0)=>{const j=Sh(m)?m:p(m);if(!j)return!1;const E=$l(j,y);return _&&E>0||E>=y.width*y.height||E>=j.width*j.height},updateNode:x,updateNodeData:(m,y,_={replace:!1})=>{x(m,N=>{const j=typeof y=="function"?y(N):y;return _.replace?{...N,data:j}:{...N,data:{...N.data,...j}}},_)},updateEdge:v,updateEdgeData:(m,y,_={replace:!1})=>{v(m,N=>{const j=typeof y=="function"?y(N):y;return _.replace?{...N,data:j}:{...N,data:{...N.data,...j}}},_)},getNodesBounds:m=>{const{nodeLookup:y,nodeOrigin:_}=r.getState();return n1(m,{nodeLookup:y,nodeOrigin:_})},getHandleConnections:({type:m,id:y,nodeId:_})=>{var N;return Array.from(((N=r.getState().connectionLookup.get(`${_}-${m}${y?`-${y}`:""}`))==null?void 0:N.values())??[])},getNodeConnections:({type:m,handleId:y,nodeId:_})=>{var N;return Array.from(((N=r.getState().connectionLookup.get(`${_}${m?y?`-${m}-${y}`:`-${m}`:""}`))==null?void 0:N.values())??[])},fitView:async m=>{const y=r.getState().fitViewResolver??u1();return r.setState({fitViewQueued:!0,fitViewOptions:m,fitViewResolver:y}),o.nodeQueue.push(_=>[..._]),y.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const Jh=t=>t.selected,O_=typeof window<"u"?window:void 0;function F_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ye(),{deleteElements:s}=ql(),a=is(t,{actInsideInputWithModifier:!1}),u=is(r,{target:O_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(Jh),edges:c.filter(Jh)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function H_(t){const r=Ye();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=Sc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",wn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const Kl={position:"absolute",width:"100%",height:"100%",top:0,left:0},B_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function V_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=ni.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:x,translateExtent:v,minZoom:m,maxZoom:y,zoomActivationKeyCode:_,preventScrolling:N=!0,children:j,noWheelClassName:E,noPanClassName:w,onViewportChange:M,isControlledViewport:k,paneClickDistance:b,selectionOnDrag:A}){const $=Ye(),V=L.useRef(null),{userSelectionActive:X,lib:G,connectionInProgress:J}=ze(B_,Qe),Z=is(_),re=L.useRef();H_(V);const te=L.useCallback(I=>{M==null||M({x:I[0],y:I[1],zoom:I[2]}),k||$.setState({transform:I})},[M,k]);return L.useEffect(()=>{if(V.current){re.current=Y1({domNode:V.current,minZoom:m,maxZoom:y,translateExtent:v,viewport:x,onDraggingChange:U=>$.setState(C=>C.paneDragging===U?C:{paneDragging:U}),onPanZoomStart:(U,C)=>{const{onViewportChangeStart:D,onMoveStart:B}=$.getState();B==null||B(U,C),D==null||D(C)},onPanZoom:(U,C)=>{const{onViewportChange:D,onMove:B}=$.getState();B==null||B(U,C),D==null||D(C)},onPanZoomEnd:(U,C)=>{const{onViewportChangeEnd:D,onMoveEnd:B}=$.getState();B==null||B(U,C),D==null||D(C)}});const{x:I,y:W,zoom:H}=re.current.getViewport();return $.setState({panZoom:re.current,transform:[I,W,H],domNode:V.current.closest(".react-flow")}),()=>{var U;(U=re.current)==null||U.destroy()}}},[]),L.useEffect(()=>{var I;(I=re.current)==null||I.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:Z,preventScrolling:N,noPanClassName:w,userSelectionActive:X,noWheelClassName:E,lib:G,onTransformChange:te,connectionInProgress:J,selectionOnDrag:A,paneClickDistance:b})},[t,r,o,s,a,u,c,h,p,Z,N,w,X,E,G,te,J,A,b]),d.jsx("div",{className:"react-flow__renderer",ref:V,style:Kl,children:j})}const W_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function U_(){const{userSelectionActive:t,userSelectionRect:r}=ze(W_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const Vu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},Y_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function G_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=es.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:x,onPaneContextMenu:v,onPaneScroll:m,onPaneMouseEnter:y,onPaneMouseMove:_,onPaneMouseLeave:N,children:j}){const E=L.useRef(0),w=Ye(),{userSelectionActive:M,elementsSelectable:k,dragging:b,panBy:A,autoPanSpeed:$}=ze(Y_,Qe),V=k&&(t||M),X=L.useRef(null),G=L.useRef(),J=L.useRef(new Set),Z=L.useRef(new Set),re=L.useRef(!1),te=L.useRef(!1),I=L.useRef({x:0,y:0}),W=L.useRef(!1),H=Q=>{if(te.current||re.current||w.getState().connection.inProgress){te.current=!1,re.current=!1;return}x==null||x(Q),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},U=Q=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Q.preventDefault();return}v==null||v(Q)},C=m?Q=>m(Q):void 0,D=Q=>{te.current&&(Q.stopPropagation(),te.current=!1)},B=Q=>{var Le,Ze;if(Q.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:ae,transform:me}=w.getState();if(G.current=ae==null?void 0:ae.getBoundingClientRect(),!G.current)return;const ke=Q.target===X.current;if(!ke&&!!Q.target.closest(".nokey")||!t||!(c&&ke||r)||Q.button!==0||!Q.isPrimary)return;(Ze=(Le=Q.target)==null?void 0:Le.setPointerCapture)==null||Ze.call(Le,Q.pointerId),te.current=!1;const{x:Ne,y:Me}=xn(Q.nativeEvent,G.current),Re=ds({x:Ne,y:Me},me);w.setState({userSelectionRect:{width:0,height:0,startX:Re.x,startY:Re.y,x:Ne,y:Me}}),ke||(Q.stopPropagation(),Q.preventDefault())};function P(Q,ae){const{userSelectionRect:me}=w.getState();if(!me)return;const{transform:ke,nodeLookup:ve,edgeLookup:ne,connectionLookup:Ne,triggerNodeChanges:Me,triggerEdgeChanges:Re,defaultEdgeOptions:Le}=w.getState(),Ze={x:me.startX,y:me.startY},{x:pt,y:Xe}=Zi(Ze,ke),it={startX:Ze.x,startY:Ze.y,x:Qdt.id)),Z.current=new Set;const ot=(Le==null?void 0:Le.selectable)??!0;for(const dt of J.current){const gt=Ne.get(dt);if(gt)for(const{edgeId:mt}of gt.values()){const Pt=ne.get(mt);Pt&&(Pt.selectable??ot)&&Z.current.add(mt)}}if(!kh(on,J.current)){const dt=Ui(ve,J.current,!0);Me(dt)}if(!kh(Mt,Z.current)){const dt=Ui(ne,Z.current);Re(dt)}w.setState({userSelectionRect:it,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!a||!G.current)return;const[Q,ae]=wc(I.current,G.current,$);A({x:Q,y:ae}).then(me=>{if(!te.current||!me){E.current=requestAnimationFrame(z);return}const{x:ke,y:ve}=I.current;P(ke,ve),E.current=requestAnimationFrame(z)})}const ie=()=>{cancelAnimationFrame(E.current),E.current=0,W.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=Q=>{const{userSelectionRect:ae,transform:me,resetSelectedElements:ke}=w.getState();if(!G.current||!ae)return;const{x:ve,y:ne}=xn(Q.nativeEvent,G.current);I.current={x:ve,y:ne};const Ne=Zi({x:ae.startX,y:ae.startY},me);if(!te.current){const Me=r?0:u;if(Math.hypot(ve-Ne.x,ne-Ne.y)<=Me)return;ke(),h==null||h(Q)}te.current=!0,W.current||(z(),W.current=!0),P(ve,ne)},de=Q=>{var ae,me;if(!V){Q.target===X.current&&w.getState().connection.inProgress&&(re.current=!0);return}Q.button===0&&((me=(ae=Q.target)==null?void 0:ae.releasePointerCapture)==null||me.call(ae,Q.pointerId),!M&&Q.target===X.current&&w.getState().userSelectionRect&&(H==null||H(Q)),w.setState({userSelectionActive:!1,userSelectionRect:null}),te.current&&(p==null||p(Q),w.setState({nodesSelectionActive:J.current.size>0})),ie())},pe=Q=>{var ae,me;(me=(ae=Q.target)==null?void 0:ae.releasePointerCapture)==null||me.call(ae,Q.pointerId),ie()},he=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:rt(["react-flow__pane",{draggable:he,dragging:b,selection:t}]),onClick:V?void 0:Vu(H,X),onContextMenu:Vu(U,X),onWheel:Vu(C,X),onPointerEnter:V?void 0:y,onPointerMove:V?oe:_,onPointerUp:de,onPointerCancel:V?pe:void 0,onPointerDownCapture:V?B:void 0,onClickCapture:V?D:void 0,onPointerLeave:N,ref:X,style:Kl,children:[j,d.jsx(U_,{})]})}function ac({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),x=h.get(t);if(!x){p==null||p("012",wn.error012(t));return}r.setState({nodesSelectionActive:!1}),x.selected?(o||x.selected&&c)&&(u({nodes:[x],edges:[]}),requestAnimationFrame(()=>{var v;return(v=s==null?void 0:s.current)==null?void 0:v.blur()})):a([t])}function Og({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ye(),[p,x]=L.useState(!1),v=L.useRef();return L.useEffect(()=>{if(!r)return v.current=R1({getStoreItems:()=>h.getState(),onNodeMouseDown:m=>{ac({id:m,store:h,nodeRef:t})},onDragStart:()=>{x(!0)},onDragStop:()=>{x(!1)}}),()=>{var m;(m=v.current)==null||m.destroy(),v.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!v.current||v.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const X_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Fg(){const t=Ye();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:x,nodeOrigin:v}=t.getState(),m=new Map,y=X_(c),_=a?u[0]:5,N=a?u[1]:5,j=o.direction.x*_*o.factor,E=o.direction.y*N*o.factor;for(const[,w]of x){if(!y(w))continue;let M={x:w.internals.positionAbsolute.x+j,y:w.internals.positionAbsolute.y+E};a&&(M=cs(M,u));const{position:k,positionAbsolute:b}=og({nodeId:w.id,nextPosition:M,nodeLookup:x,nodeExtent:s,nodeOrigin:v,onError:h});w.position=k,w.internals.positionAbsolute=b,m.set(w.id,w)}p(m)},[])}const Cc=L.createContext(null),q_=Cc.Provider;Cc.Consumer;const Hg=()=>L.useContext(Cc),K_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Bg=L.createContext(null);function Q_({children:t}){const r=ze(K_,Qe);return d.jsx(Bg.Provider,{value:r,children:t})}function Z_(){const t=L.useContext(Bg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const J_={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},eS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:x}=c;if(!h&&!a)return J_;const v=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:v,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Ki.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:v&&x}};function tS({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:x,onMouseDown:v,onTouchStart:m,...y},_){var W,H;const N=c||null,j=t==="target",E=Ye(),w=Hg(),{connectOnClick:M,noPanClassName:k,rfId:b}=Z_(),{connectingFrom:A,connectingTo:$,clickConnecting:V,isPossibleEndHandle:X,connectionInProcess:G,clickConnectionInProcess:J,valid:Z}=ze(eS(w,N,t),Qe);w||(H=(W=E.getState()).onError)==null||H.call(W,"010",wn.error010());const re=U=>{const{defaultEdgeOptions:C,onConnect:D,hasDefaultEdges:B}=E.getState(),P={...C,...U};if(B){const{edges:z,setEdges:ie,onError:oe}=E.getState();ie(T_(P,z,{onError:oe}))}D==null||D(P),h==null||h(P)},te=U=>{if(!w)return;const C=pg(U.nativeEvent);if(a&&(C&&U.button===0||!C)){const D=E.getState();lc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:j,handleId:N,nodeId:w,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...B)=>{var P,z;return(z=(P=E.getState()).onConnectEnd)==null?void 0:z.call(P,...B)},updateConnection:D.updateConnection,onConnect:re,isValidConnection:o||((...B)=>{var P,z;return((z=(P=E.getState()).isValidConnection)==null?void 0:z.call(P,...B))??!0}),getTransform:()=>E.getState().transform,getFromHandle:()=>E.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}C?v==null||v(U):m==null||m(U)},I=U=>{const{onClickConnectStart:C,onClickConnectEnd:D,connectionClickStartHandle:B,connectionMode:P,isValidConnection:z,lib:ie,rfId:oe,nodeLookup:de,connection:pe}=E.getState();if(!w||!B&&!a)return;if(!B){C==null||C(U.nativeEvent,{nodeId:w,handleId:N,handleType:t}),E.setState({connectionClickStartHandle:{nodeId:w,type:t,id:N}});return}const he=fg(U.target),Q=o||z,{connection:ae,isValid:me}=lc.isValid(U.nativeEvent,{handle:{nodeId:w,id:N,type:t},connectionMode:P,fromNodeId:B.nodeId,fromHandleId:B.id||null,fromType:B.type,isValidConnection:Q,flowId:oe,doc:he,lib:ie,nodeLookup:de});me&&ae&&re(ae);const ke=structuredClone(pe);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,D==null||D(U,ke),E.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":N,"data-nodeid":w,"data-handlepos":r,"data-id":`${b}-${w}-${N}-${t}`,className:rt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",k,x,{source:!j,target:j,connectable:s,connectablestart:a,connectableend:u,clickconnecting:V,connectingfrom:A,connectingto:$,valid:Z,connectionindicator:s&&(!G||X)&&(G||J?u:a)}]),onMouseDown:te,onTouchStart:te,onClick:M?I:void 0,ref:_,...y,children:p})}const eo=L.memo($g(tS));function nS({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(eo,{type:"source",position:o,isConnectable:r})]})}function rS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:s=Se.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(eo,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(eo,{type:"source",position:s,isConnectable:r})]})}function iS(){return null}function oS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(eo,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const zl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},ep={input:nS,default:rS,output:oS,group:iS};function sS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const lS=t=>{const{width:r,height:o,x:s,y:a}=us(t.nodeLookup,{filter:u=>!!u.selected});return{width:vn(r)?r:null,height:vn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function aS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ye(),{width:a,height:u,transformString:c,userSelectionActive:h}=ze(lS,Qe),p=Fg(),x=L.useRef(null);L.useEffect(()=>{var _;o||(_=x.current)==null||_.focus({preventScroll:!0})},[o]);const v=!h&&a!==null&&u!==null;if(Og({nodeRef:x,disabled:!v}),!v)return null;const m=t?_=>{const N=s.getState().nodes.filter(j=>j.selected);t(_,N)}:void 0,y=_=>{Object.prototype.hasOwnProperty.call(zl,_.key)&&(_.preventDefault(),p({direction:zl[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:rt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:x,className:"react-flow__nodesselection-rect",onContextMenu:m,tabIndex:o?void 0:-1,onKeyDown:o?void 0:y,style:{width:a,height:u}})})}const tp=typeof window<"u"?window:void 0,uS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Vg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:x,selectionOnDrag:v,selectionMode:m,onSelectionStart:y,onSelectionEnd:_,multiSelectionKeyCode:N,panActivationKeyCode:j,zoomActivationKeyCode:E,elementsSelectable:w,zoomOnScroll:M,zoomOnPinch:k,panOnScroll:b,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:V,panOnDrag:X,autoPanOnSelection:G,defaultViewport:J,translateExtent:Z,minZoom:re,maxZoom:te,preventScrolling:I,onSelectionContextMenu:W,noWheelClassName:H,noPanClassName:U,disableKeyboardA11y:C,onViewportChange:D,isControlledViewport:B}){const{nodesSelectionActive:P,userSelectionActive:z}=ze(uS,Qe),ie=is(x,{target:tp}),oe=is(j,{target:tp}),de=oe||X,pe=oe||b,he=v&&de!==!0,Q=ie||z||he;return F_({deleteKeyCode:p,multiSelectionKeyCode:N}),d.jsx(V_,{onPaneContextMenu:u,elementsSelectable:w,zoomOnScroll:M,zoomOnPinch:k,panOnScroll:pe,panActivationKeyPressed:oe,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:V,panOnDrag:!ie&&de,defaultViewport:J,translateExtent:Z,minZoom:re,maxZoom:te,zoomActivationKeyCode:E,preventScrolling:I,noWheelClassName:H,noPanClassName:U,onViewportChange:D,isControlledViewport:B,paneClickDistance:h,selectionOnDrag:he,children:d.jsxs(G_,{onSelectionStart:y,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:de,autoPanOnSelection:G,isSelecting:!!Q,selectionMode:m,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:he,children:[t,P&&d.jsx(aS,{onSelectionContextMenu:W,noPanClassName:U,disableKeyboardA11y:C})]})})}Vg.displayName="FlowRenderer";const cS=L.memo(Vg),dS=t=>r=>t?xc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function fS(t){return ze(L.useCallback(dS(t),[t]),Qe)}const hS=t=>t.updateNodeInternals;function pS(){const t=ze(hS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function gS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ye(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),x=L.useRef(r),v=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!v||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[v,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const m=x.current!==r,y=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(m||y||_)&&(x.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function mS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:x,nodesFocusable:v,resizeObserver:m,noDragClassName:y,noPanClassName:_,disableKeyboardA11y:N,rfId:j,nodeTypes:E,nodeClickDistance:w,onError:M}){const{node:k,internals:b,isParent:A}=ze(Q=>{const ae=Q.nodeLookup.get(t),me=Q.parentLookup.has(t);return{node:ae,internals:ae.internals,isParent:me}},Qe);let $=k.type||"default",V=(E==null?void 0:E[$])||ep[$];V===void 0&&(M==null||M("003",wn.error003($)),$="default",V=(E==null?void 0:E.default)||ep.default);const X=!!(k.draggable||h&&typeof k.draggable>"u"),G=!!(k.selectable||p&&typeof k.selectable>"u"),J=!!(k.connectable||x&&typeof k.connectable>"u"),Z=!!(k.focusable||v&&typeof k.focusable>"u"),re=Ye(),te=cg(k),I=gS({node:k,nodeType:$,hasDimensions:te,resizeObserver:m}),W=Og({nodeRef:I,disabled:k.hidden||!X,noDragClassName:y,handleSelector:k.dragHandle,nodeId:t,isSelectable:G,nodeClickDistance:w}),H=Fg();if(k.hidden)return null;const U=Sn(k),C=sS(k),D=G||X||r||o||s||a,B=o?Q=>o(Q,{...b.userNode}):void 0,P=s?Q=>s(Q,{...b.userNode}):void 0,z=a?Q=>a(Q,{...b.userNode}):void 0,ie=u?Q=>u(Q,{...b.userNode}):void 0,oe=c?Q=>c(Q,{...b.userNode}):void 0,de=Q=>{const{selectNodesOnDrag:ae,nodeDragThreshold:me}=re.getState();G&&(!ae||!X||me>0)&&ac({id:t,store:re,nodeRef:I}),r&&r(Q,{...b.userNode})},pe=Q=>{if(!(hg(Q.nativeEvent)||N)){if(eg.includes(Q.key)&&G){const ae=Q.key==="Escape";ac({id:t,store:re,unselect:ae,nodeRef:I})}else if(X&&k.selected&&Object.prototype.hasOwnProperty.call(zl,Q.key)){Q.preventDefault();const{ariaLabelConfig:ae}=re.getState();re.setState({ariaLiveMessage:ae["node.a11yDescription.ariaLiveMessage"]({direction:Q.key.replace("Arrow","").toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),H({direction:zl[Q.key],factor:Q.shiftKey?4:1})}}},he=()=>{var Ne;if(N||!((Ne=I.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:Q,width:ae,height:me,autoPanOnNodeFocus:ke,setCenter:ve}=re.getState();if(!ke)return;xc(new Map([[t,k]]),{x:0,y:0,width:ae,height:me},Q,!0).length>0||ve(k.position.x+U.width/2,k.position.y+U.height/2,{zoom:Q[2]})};return d.jsx("div",{className:rt(["react-flow__node",`react-flow__node-${$}`,{[_]:X},k.className,{selected:k.selected,selectable:G,parent:A,draggable:X,dragging:W}]),ref:I,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:te?"visible":"hidden",...k.style,...C},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:B,onMouseMove:P,onMouseLeave:z,onContextMenu:ie,onClick:de,onDoubleClick:oe,onKeyDown:Z?pe:void 0,tabIndex:Z?0:void 0,onFocus:Z?he:void 0,role:k.ariaRole??(Z?"group":void 0),"aria-roledescription":"node","aria-describedby":N?void 0:`${Rg}-${j}`,"aria-label":k.ariaLabel,...k.domAttributes,children:d.jsx(q_,{value:t,children:d.jsx(V,{id:t,data:k.data,type:$,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:k.selected??!1,selectable:G,draggable:X,deletable:k.deletable??!0,isConnectable:J,sourcePosition:k.sourcePosition,targetPosition:k.targetPosition,dragging:W,dragHandle:k.dragHandle,zIndex:b.z,parentId:k.parentId,...U})})})}var yS=L.memo(mS);const vS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Wg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=ze(vS,Qe),u=fS(t.onlyRenderVisibleElements),c=pS();return d.jsx("div",{className:"react-flow__nodes",style:Kl,children:u.map(h=>d.jsx(yS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Wg.displayName="NodeRenderer";const xS=L.memo(Wg);function wS(t){return ze(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&h1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const _S=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},SS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},np={[ts.Arrow]:_S,[ts.ArrowClosed]:SS};function kS(t){const r=Ye();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(np,t)?np[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",wn.error009(t)),null)},[t])}const NS=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=kS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},Ug=({defaultColor:t,rfId:r})=>{const o=ze(u=>u.edges),s=ze(u=>u.defaultEdgeOptions),a=L.useMemo(()=>_1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(NS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Ug.displayName="MarkerDefinitions";var jS=L.memo(Ug);function Yg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:x,...v}){const[m,y]=L.useState({x:1,y:0,width:0,height:0}),_=rt(["react-flow__edge-textwrapper",x]),N=L.useRef(null);return L.useEffect(()=>{if(N.current){const j=N.current.getBBox();y({x:j.x,y:j.y,width:j.width,height:j.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-m.width/2} ${r-m.height/2})`,className:_,visibility:m.width?"visible":"hidden",...v,children:[a&&d.jsx("rect",{width:m.width+2*c[0],x:-c[0],y:-c[1],height:m.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:m.height/2,dy:"0.3em",ref:N,style:s,children:o}),p]}):null}Yg.displayName="EdgeText";const bS=L.memo(Yg);function Ql({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:x=20,...v}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...v,d:t,fill:"none",className:rt(["react-flow__edge-path",v.className])}),x?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:x,className:"react-flow__edge-interaction"}):null,s&&vn(r)&&vn(o)?d.jsx(bS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function rp({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function Gg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top}){const[c,h]=rp({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,x]=rp({pos:u,x1:s,y1:a,x2:t,y2:r}),[v,m,y,_]=gg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:x});return[`M${t},${r} C${c},${h} ${p},${x} ${s},${a}`,v,m,y,_]}function Xg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:x,labelShowBg:v,labelBgStyle:m,labelBgPadding:y,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,interactionWidth:w})=>{const[M,k,b]=Gg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),A=t.isInternal?void 0:r;return d.jsx(Ql,{id:A,path:M,labelX:k,labelY:b,label:p,labelStyle:x,labelShowBg:v,labelBgStyle:m,labelBgPadding:y,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,interactionWidth:w})})}const ES=Xg({isInternal:!1}),qg=Xg({isInternal:!0});ES.displayName="SimpleBezierEdge";qg.displayName="SimpleBezierEdgeInternal";function Kg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:m,style:y,sourcePosition:_=Se.Bottom,targetPosition:N=Se.Top,markerEnd:j,markerStart:E,pathOptions:w,interactionWidth:M})=>{const[k,b,A]=ic({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:N,borderRadius:w==null?void 0:w.borderRadius,offset:w==null?void 0:w.offset,stepPosition:w==null?void 0:w.stepPosition}),$=t.isInternal?void 0:r;return d.jsx(Ql,{id:$,path:k,labelX:b,labelY:A,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:m,style:y,markerEnd:j,markerStart:E,interactionWidth:M})})}const Qg=Kg({isInternal:!1}),Zg=Kg({isInternal:!0});Qg.displayName="SmoothStepEdge";Zg.displayName="SmoothStepEdgeInternal";function Jg(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(Qg,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const CS=Jg({isInternal:!1}),em=Jg({isInternal:!0});CS.displayName="StepEdge";em.displayName="StepEdgeInternal";function tm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:m,style:y,markerEnd:_,markerStart:N,interactionWidth:j})=>{const[E,w,M]=vg({sourceX:o,sourceY:s,targetX:a,targetY:u}),k=t.isInternal?void 0:r;return d.jsx(Ql,{id:k,path:E,labelX:w,labelY:M,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:v,labelBgBorderRadius:m,style:y,markerEnd:_,markerStart:N,interactionWidth:j})})}const MS=tm({isInternal:!1}),nm=tm({isInternal:!0});MS.displayName="StraightEdge";nm.displayName="StraightEdgeInternal";function rm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:x,labelShowBg:v,labelBgStyle:m,labelBgPadding:y,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,pathOptions:w,interactionWidth:M})=>{const[k,b,A]=mg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:w==null?void 0:w.curvature}),$=t.isInternal?void 0:r;return d.jsx(Ql,{id:$,path:k,labelX:b,labelY:A,label:p,labelStyle:x,labelShowBg:v,labelBgStyle:m,labelBgPadding:y,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,interactionWidth:M})})}const PS=rm({isInternal:!1}),im=rm({isInternal:!0});PS.displayName="BezierEdge";im.displayName="BezierEdgeInternal";const ip={default:im,straight:nm,step:em,smoothstep:Zg,simplebezier:qg},op={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},IS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,RS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,sp="react-flow__edgeupdater";function lp({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:rt([sp,`${sp}-${h}`]),cx:IS(r,s,t),cy:RS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function TS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:x,onReconnectStart:v,onReconnectEnd:m,setReconnecting:y,setUpdateHover:_}){const N=Ye(),j=(b,A)=>{if(b.button!==0)return;const{autoPanOnConnect:$,domNode:V,connectionMode:X,connectionRadius:G,lib:J,onConnectStart:Z,cancelConnection:re,nodeLookup:te,rfId:I,panBy:W,updateConnection:H}=N.getState(),U=A.type==="target",C=(P,z)=>{y(!1),m==null||m(P,o,A.type,z)},D=P=>x==null?void 0:x(o,P),B=(P,z)=>{y(!0),v==null||v(b,o,A.type),Z==null||Z(P,z)};lc.onPointerDown(b.nativeEvent,{autoPanOnConnect:$,connectionMode:X,connectionRadius:G,domNode:V,handleId:A.id,nodeId:A.nodeId,nodeLookup:te,isTarget:U,edgeUpdaterType:A.type,lib:J,flowId:I,cancelConnection:re,panBy:W,isValidConnection:(...P)=>{var z,ie;return((ie=(z=N.getState()).isValidConnection)==null?void 0:ie.call(z,...P))??!0},onConnect:D,onConnectStart:B,onConnectEnd:(...P)=>{var z,ie;return(ie=(z=N.getState()).onConnectEnd)==null?void 0:ie.call(z,...P)},onReconnectEnd:C,updateConnection:H,getTransform:()=>N.getState().transform,getFromHandle:()=>N.getState().connection.fromHandle,dragThreshold:N.getState().connectionDragThreshold,handleDomNode:b.currentTarget})},E=b=>j(b,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),w=b=>j(b,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),M=()=>_(!0),k=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(lp,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:E,onMouseEnter:M,onMouseOut:k,type:"source"}),(t===!0||t==="target")&&d.jsx(lp,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:w,onMouseEnter:M,onMouseOut:k,type:"target"})]})}function LS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:x,reconnectRadius:v,onReconnect:m,onReconnectStart:y,onReconnectEnd:_,rfId:N,edgeTypes:j,noPanClassName:E,onError:w,disableKeyboardA11y:M}){let k=ze(ve=>ve.edgeLookup.get(t));const b=ze(ve=>ve.defaultEdgeOptions);k=b?{...b,...k}:k;let A=k.type||"default",$=(j==null?void 0:j[A])||ip[A];$===void 0&&(w==null||w("011",wn.error011(A)),A="default",$=(j==null?void 0:j.default)||ip.default);const V=!!(k.focusable||r&&typeof k.focusable>"u"),X=typeof m<"u"&&(k.reconnectable||o&&typeof k.reconnectable>"u"),G=!!(k.selectable||s&&typeof k.selectable>"u"),J=L.useRef(null),[Z,re]=L.useState(!1),[te,I]=L.useState(!1),W=Ye(),{zIndex:H=k.zIndex,sourceX:U,sourceY:C,targetX:D,targetY:B,sourcePosition:P,targetPosition:z}=ze(L.useCallback(ve=>{const ne=ve.nodeLookup.get(k.source),Ne=ve.nodeLookup.get(k.target);if(!ne||!Ne)return op;const Me=w1({id:t,sourceNode:ne,targetNode:Ne,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:ve.connectionMode,onError:w}),Re=f1({selected:k.selected,zIndex:k.zIndex,sourceNode:ne,targetNode:Ne,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||op,zIndex:Re}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex,w]),Qe),ie=L.useMemo(()=>k.markerStart?`url('#${oc(k.markerStart,N)}')`:void 0,[k.markerStart,N]),oe=L.useMemo(()=>k.markerEnd?`url('#${oc(k.markerEnd,N)}')`:void 0,[k.markerEnd,N]);if(k.hidden||U===null||C===null||D===null||B===null)return null;const de=ve=>{var Re;const{addSelectedEdges:ne,unselectNodesAndEdges:Ne,multiSelectionActive:Me}=W.getState();G&&(W.setState({nodesSelectionActive:!1}),k.selected&&Me?(Ne({nodes:[],edges:[k]}),(Re=J.current)==null||Re.blur()):ne([t])),a&&a(ve,k)},pe=u?ve=>{u(ve,{...k})}:void 0,he=c?ve=>{c(ve,{...k})}:void 0,Q=h?ve=>{h(ve,{...k})}:void 0,ae=p?ve=>{p(ve,{...k})}:void 0,me=x?ve=>{x(ve,{...k})}:void 0,ke=ve=>{var ne;if(!M&&eg.includes(ve.key)&&G){const{unselectNodesAndEdges:Ne,addSelectedEdges:Me}=W.getState();ve.key==="Escape"?((ne=J.current)==null||ne.blur(),Ne({edges:[k]})):Me([t])}};return d.jsx("svg",{style:{zIndex:H},children:d.jsxs("g",{className:rt(["react-flow__edge",`react-flow__edge-${A}`,k.className,E,{selected:k.selected,animated:k.animated,inactive:!G&&!a,updating:Z,selectable:G}]),onClick:de,onDoubleClick:pe,onContextMenu:he,onMouseEnter:Q,onMouseMove:ae,onMouseLeave:me,onKeyDown:V?ke:void 0,tabIndex:V?0:void 0,role:k.ariaRole??(V?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":k.ariaLabel===null?void 0:k.ariaLabel||`Edge from ${k.source} to ${k.target}`,"aria-describedby":V?`${Tg}-${N}`:void 0,ref:J,...k.domAttributes,children:[!te&&d.jsx($,{id:t,source:k.source,target:k.target,type:k.type,selected:k.selected,animated:k.animated,selectable:G,deletable:k.deletable??!0,label:k.label,labelStyle:k.labelStyle,labelShowBg:k.labelShowBg,labelBgStyle:k.labelBgStyle,labelBgPadding:k.labelBgPadding,labelBgBorderRadius:k.labelBgBorderRadius,sourceX:U,sourceY:C,targetX:D,targetY:B,sourcePosition:P,targetPosition:z,data:k.data,style:k.style,sourceHandleId:k.sourceHandle,targetHandleId:k.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in k?k.pathOptions:void 0,interactionWidth:k.interactionWidth}),X&&d.jsx(TS,{edge:k,isReconnectable:X,reconnectRadius:v,onReconnect:m,onReconnectStart:y,onReconnectEnd:_,sourceX:U,sourceY:C,targetX:D,targetY:B,sourcePosition:P,targetPosition:z,setUpdateHover:re,setReconnecting:I})]})})}var AS=L.memo(LS);const $S=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function om({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:x,onEdgeClick:v,reconnectRadius:m,onEdgeDoubleClick:y,onReconnectStart:_,onReconnectEnd:N,disableKeyboardA11y:j}){const{edgesFocusable:E,edgesReconnectable:w,elementsSelectable:M,onError:k}=ze($S,Qe),b=wS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(jS,{defaultColor:t,rfId:o}),b.map(A=>d.jsx(AS,{id:A,edgesFocusable:E,edgesReconnectable:w,elementsSelectable:M,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:x,onClick:v,reconnectRadius:m,onDoubleClick:y,onReconnectStart:_,onReconnectEnd:N,rfId:o,onError:k,edgeTypes:s,disableKeyboardA11y:j},A))]})}om.displayName="EdgeRenderer";const zS=L.memo(om),ap=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function DS({children:t}){const r=Ye(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return zg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=ap(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:ap(s)},children:t})}function OS(t){const r=ql(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const FS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function HS(t){const r=ze(FS),o=Ye();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function BS(t){return t.connection.inProgress?{...t.connection,to:ds(t.connection.to,t.transform)}:{...t.connection}}function VS(t){return BS}function WS(t){const r=VS();return ze(r,Qe)}const US=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function YS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=ze(US,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:rt(["react-flow__connection",rg(h)]),children:d.jsx(sm,{style:r,type:o,CustomComponent:s,isValid:h})})})}const sm=({style:t,type:r=Pr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:x,toNode:v,toHandle:m,toPosition:y,pointer:_}=WS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:x.x,toY:x.y,fromPosition:p,toPosition:y,connectionStatus:rg(s),toNode:v,toHandle:m,pointer:_});let N="";const j={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:x.x,targetY:x.y,targetPosition:y};switch(r){case Pr.Bezier:[N]=mg(j);break;case Pr.SimpleBezier:[N]=Gg(j);break;case Pr.Step:[N]=ic({...j,borderRadius:0});break;case Pr.SmoothStep:[N]=ic(j);break;default:[N]=vg(j)}return d.jsx("path",{d:N,fill:"none",className:"react-flow__connection-path",style:t})};sm.displayName="ConnectionLine";const GS={};function up(t=GS){L.useRef(t),Ye(),L.useEffect(()=>{},[t])}function XS(){Ye(),L.useRef(!1),L.useEffect(()=>{},[])}function lm({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:v,onSelectionContextMenu:m,onSelectionStart:y,onSelectionEnd:_,connectionLineType:N,connectionLineStyle:j,connectionLineComponent:E,connectionLineContainerStyle:w,selectionKeyCode:M,selectionOnDrag:k,selectionMode:b,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:V,deleteKeyCode:X,onlyRenderVisibleElements:G,elementsSelectable:J,defaultViewport:Z,translateExtent:re,minZoom:te,maxZoom:I,preventScrolling:W,defaultMarkerColor:H,zoomOnScroll:U,zoomOnPinch:C,panOnScroll:D,panOnScrollSpeed:B,panOnScrollMode:P,zoomOnDoubleClick:z,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:de,onPaneMouseEnter:pe,onPaneMouseMove:he,onPaneMouseLeave:Q,onPaneScroll:ae,onPaneContextMenu:me,paneClickDistance:ke,nodeClickDistance:ve,onEdgeContextMenu:ne,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Re,reconnectRadius:Le,onReconnect:Ze,onReconnectStart:pt,onReconnectEnd:Xe,noDragClassName:it,noWheelClassName:on,noPanClassName:Mt,disableKeyboardA11y:ot,nodeExtent:dt,rfId:gt,viewport:mt,onViewportChange:Pt,nodesDraggable:kn}){return up(t),up(r),XS(),OS(o),HS(mt),d.jsx(cS,{onPaneClick:de,onPaneMouseEnter:pe,onPaneMouseMove:he,onPaneMouseLeave:Q,onPaneContextMenu:me,onPaneScroll:ae,paneClickDistance:ke,deleteKeyCode:X,selectionKeyCode:M,selectionOnDrag:k,selectionMode:b,onSelectionStart:y,onSelectionEnd:_,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:V,elementsSelectable:J,zoomOnScroll:U,zoomOnPinch:C,zoomOnDoubleClick:z,panOnScroll:D,panOnScrollSpeed:B,panOnScrollMode:P,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:Z,translateExtent:re,minZoom:te,maxZoom:I,onSelectionContextMenu:m,preventScrolling:W,noDragClassName:it,noWheelClassName:on,noPanClassName:Mt,disableKeyboardA11y:ot,onViewportChange:Pt,isControlledViewport:!!mt,children:d.jsxs(DS,{children:[d.jsx(zS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:Ze,onReconnectStart:pt,onReconnectEnd:Xe,onlyRenderVisibleElements:G,onEdgeContextMenu:ne,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Re,reconnectRadius:Le,defaultMarkerColor:H,noPanClassName:Mt,disableKeyboardA11y:ot,rfId:gt}),d.jsx(YS,{style:j,type:N,component:E,containerStyle:w}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(xS,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:v,nodeClickDistance:ve,onlyRenderVisibleElements:G,noPanClassName:Mt,noDragClassName:it,disableKeyboardA11y:ot,nodeExtent:dt,rfId:gt,nodesDraggable:kn}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}lm.displayName="GraphView";const qS=L.memo(lm),KS=ug(),cp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:x=2,nodeOrigin:v,nodeExtent:m,zIndexMode:y="basic"}={})=>{const _=new Map,N=new Map,j=new Map,E=new Map,w=s??r??[],M=o??t??[],k=v??[0,0],b=m??Jo;_g(j,E,w);const{nodesInitialized:A}=sc(M,_,N,{nodeOrigin:k,nodeExtent:b,zIndexMode:y});let $=[0,0,1];if(c&&a&&u){const V=us(_,{filter:Z=>!!((Z.width||Z.initialWidth)&&(Z.height||Z.initialHeight))}),{x:X,y:G,zoom:J}=_c(V,a,u,p,x,(h==null?void 0:h.padding)??.1);$=[X,G,J]}return{rfId:"1",width:a??0,height:u??0,transform:$,nodes:M,nodesInitialized:A,nodeLookup:_,parentLookup:N,edges:w,edgeLookup:E,connectionLookup:j,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:x,translateExtent:Jo,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ki.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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...ng},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:KS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:tg,zIndexMode:y,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},QS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:x,nodeOrigin:v,nodeExtent:m,zIndexMode:y})=>u_((_,N)=>{async function j(){const{nodeLookup:E,panZoom:w,fitViewOptions:M,fitViewResolver:k,width:b,height:A,minZoom:$,maxZoom:V}=N();w&&(await o1({nodes:E,width:b,height:A,panZoom:w,minZoom:$,maxZoom:V},M),k==null||k.resolve(!0),_({fitViewResolver:null}))}return{...cp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:x,nodeOrigin:v,nodeExtent:m,defaultNodes:o,defaultEdges:s,zIndexMode:y}),setNodes:E=>{const{nodeLookup:w,parentLookup:M,nodeOrigin:k,nodeExtent:b,elevateNodesOnSelect:A,fitViewQueued:$,zIndexMode:V,nodesSelectionActive:X}=N(),{nodesInitialized:G,hasSelectedNodes:J}=sc(E,w,M,{nodeOrigin:k,nodeExtent:b,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:V}),Z=X&&J;$&&G?(j(),_({nodes:E,nodesInitialized:G,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:Z})):_({nodes:E,nodesInitialized:G,nodesSelectionActive:Z})},setEdges:E=>{const{connectionLookup:w,edgeLookup:M}=N();_g(w,M,E),_({edges:E})},setDefaultNodesAndEdges:(E,w)=>{if(E){const{setNodes:M}=N();M(E),_({hasDefaultNodes:!0})}if(w){const{setEdges:M}=N();M(w),_({hasDefaultEdges:!0})}},updateNodeInternals:E=>{const{triggerNodeChanges:w,nodeLookup:M,parentLookup:k,domNode:b,nodeOrigin:A,nodeExtent:$,debug:V,fitViewQueued:X,zIndexMode:G}=N(),{changes:J,updatedInternals:Z}=C1(E,M,k,b,A,$,G);Z&&(N1(M,k,{nodeOrigin:A,nodeExtent:$,zIndexMode:G}),X?(j(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(J==null?void 0:J.length)>0&&(V&&console.log("React Flow: trigger node changes",J),w==null||w(J)))},updateNodePositions:(E,w=!1)=>{const M=[];let k=[];const{nodeLookup:b,triggerNodeChanges:A,connection:$,updateConnection:V,onNodesChangeMiddlewareMap:X}=N();for(const[G,J]of E){const Z=b.get(G),re=!!(Z!=null&&Z.expandParent&&(Z!=null&&Z.parentId)&&(J!=null&&J.position)),te={id:G,type:"position",position:re?{x:Math.max(0,J.position.x),y:Math.max(0,J.position.y)}:J.position,dragging:w};if(Z&&$.inProgress&&$.fromNode.id===Z.id){const I=li(Z,$.fromHandle,Se.Left,!0);V({...$,from:I})}re&&Z.parentId&&M.push({id:G,parentId:Z.parentId,rect:{...J.internals.positionAbsolute,width:J.measured.width??0,height:J.measured.height??0}}),k.push(te)}if(M.length>0){const{parentLookup:G,nodeOrigin:J}=N(),Z=Ec(M,b,G,J);k.push(...Z)}for(const G of X.values())k=G(k);A(k)},triggerNodeChanges:E=>{const{onNodesChange:w,setNodes:M,nodes:k,hasDefaultNodes:b,debug:A}=N();if(E!=null&&E.length){if(b){const $=P_(E,k);M($)}A&&console.log("React Flow: trigger node changes",E),w==null||w(E)}},triggerEdgeChanges:E=>{const{onEdgesChange:w,setEdges:M,edges:k,hasDefaultEdges:b,debug:A}=N();if(E!=null&&E.length){if(b){const $=I_(E,k);M($)}A&&console.log("React Flow: trigger edge changes",E),w==null||w(E)}},addSelectedNodes:E=>{const{multiSelectionActive:w,edgeLookup:M,nodeLookup:k,triggerNodeChanges:b,triggerEdgeChanges:A}=N();if(w){const $=E.map(V=>Jr(V,!0));b($);return}b(Ui(k,new Set([...E]),!0)),A(Ui(M))},addSelectedEdges:E=>{const{multiSelectionActive:w,edgeLookup:M,nodeLookup:k,triggerNodeChanges:b,triggerEdgeChanges:A}=N();if(w){const $=E.map(V=>Jr(V,!0));A($);return}A(Ui(M,new Set([...E]))),b(Ui(k,new Set,!0))},unselectNodesAndEdges:({nodes:E,edges:w}={})=>{const{edges:M,nodes:k,nodeLookup:b,triggerNodeChanges:A,triggerEdgeChanges:$}=N(),V=E||k,X=w||M,G=[];for(const Z of V){if(!Z.selected)continue;const re=b.get(Z.id);re&&(re.selected=!1),G.push(Jr(Z.id,!1))}const J=[];for(const Z of X)Z.selected&&J.push(Jr(Z.id,!1));A(G),$(J)},setMinZoom:E=>{const{panZoom:w,maxZoom:M}=N();w==null||w.setScaleExtent([E,M]),_({minZoom:E})},setMaxZoom:E=>{const{panZoom:w,minZoom:M}=N();w==null||w.setScaleExtent([M,E]),_({maxZoom:E})},setTranslateExtent:E=>{var w;(w=N().panZoom)==null||w.setTranslateExtent(E),_({translateExtent:E})},resetSelectedElements:()=>{const{edges:E,nodes:w,triggerNodeChanges:M,triggerEdgeChanges:k,elementsSelectable:b}=N();if(!b)return;const A=w.reduce((V,X)=>X.selected?[...V,Jr(X.id,!1)]:V,[]),$=E.reduce((V,X)=>X.selected?[...V,Jr(X.id,!1)]:V,[]);M(A),k($)},setNodeExtent:E=>{const{nodes:w,nodeLookup:M,parentLookup:k,nodeOrigin:b,elevateNodesOnSelect:A,nodeExtent:$,zIndexMode:V}=N();E[0][0]===$[0][0]&&E[0][1]===$[0][1]&&E[1][0]===$[1][0]&&E[1][1]===$[1][1]||(sc(w,M,k,{nodeOrigin:b,nodeExtent:E,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:V}),_({nodeExtent:E}))},panBy:E=>{const{transform:w,width:M,height:k,panZoom:b,translateExtent:A}=N();return M1({delta:E,panZoom:b,transform:w,translateExtent:A,width:M,height:k})},setCenter:async(E,w,M)=>{const{width:k,height:b,maxZoom:A,panZoom:$}=N();if(!$)return!1;const V=typeof(M==null?void 0:M.zoom)<"u"?M.zoom:A;return await $.setViewport({x:k/2-E*V,y:b/2-w*V,zoom:V},{duration:M==null?void 0:M.duration,ease:M==null?void 0:M.ease,interpolate:M==null?void 0:M.interpolate}),!0},cancelConnection:()=>{_({connection:{...ng}})},updateConnection:E=>{_({connection:E})},reset:()=>_({...cp()})}},Object.is);function am({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:x,nodeOrigin:v,nodeExtent:m,zIndexMode:y,children:_}){const[N]=L.useState(()=>QS({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:x,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:v,nodeExtent:m,zIndexMode:y}));return d.jsx(c_,{value:N,children:d.jsx($_,{children:d.jsx(Q_,{children:_})})})}function ZS({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:x,maxZoom:v,nodeOrigin:m,nodeExtent:y,zIndexMode:_}){return L.useContext(Gl)?d.jsx(d.Fragment,{children:t}):d.jsx(am,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:x,initialMaxZoom:v,nodeOrigin:m,nodeExtent:y,zIndexMode:_,children:t})}const JS={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function ek({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:x,onMove:v,onMoveStart:m,onMoveEnd:y,onConnect:_,onConnectStart:N,onConnectEnd:j,onClickConnectStart:E,onClickConnectEnd:w,onNodeMouseEnter:M,onNodeMouseMove:k,onNodeMouseLeave:b,onNodeContextMenu:A,onNodeDoubleClick:$,onNodeDragStart:V,onNodeDrag:X,onNodeDragStop:G,onNodesDelete:J,onEdgesDelete:Z,onDelete:re,onSelectionChange:te,onSelectionDragStart:I,onSelectionDrag:W,onSelectionDragStop:H,onSelectionContextMenu:U,onSelectionStart:C,onSelectionEnd:D,onBeforeDelete:B,connectionMode:P,connectionLineType:z=Pr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:de,deleteKeyCode:pe="Backspace",selectionKeyCode:he="Shift",selectionOnDrag:Q=!1,selectionMode:ae=es.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:ke=rs()?"Meta":"Control",zoomActivationKeyCode:ve=rs()?"Meta":"Control",snapToGrid:ne,snapGrid:Ne,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Re,nodesDraggable:Le,autoPanOnNodeFocus:Ze,nodesConnectable:pt,nodesFocusable:Xe,nodeOrigin:it=Lg,edgesFocusable:on,edgesReconnectable:Mt,elementsSelectable:ot=!0,defaultViewport:dt=k_,minZoom:gt=.5,maxZoom:mt=2,translateExtent:Pt=Jo,preventScrolling:kn=!0,nodeExtent:sn,defaultMarkerColor:qt="#b1b1b7",zoomOnScroll:no=!0,zoomOnPinch:rr=!0,panOnScroll:ui=!1,panOnScrollSpeed:ci=.5,panOnScrollMode:ir=ni.Free,zoomOnDoubleClick:Nn=!0,panOnDrag:Nt=!0,onPaneClick:jn,onPaneMouseEnter:bn,onPaneMouseMove:It,onPaneMouseLeave:Ft,onPaneScroll:En,onPaneContextMenu:yt,paneClickDistance:Rr=1,nodeClickDistance:Ht=0,children:Tr,onReconnect:tt,onReconnectStart:He,onReconnectEnd:ln,onEdgeContextMenu:Hn,onEdgeDoubleClick:jt,onEdgeMouseEnter:Lr,onEdgeMouseMove:bt,onEdgeMouseLeave:Cn,reconnectRadius:Kt=10,onNodesChange:Bn,onEdgesChange:di,noDragClassName:ro="nodrag",noWheelClassName:Bt="nowheel",noPanClassName:Rt="nopan",fitView:or,fitViewOptions:an,connectOnClick:Ar,attributionPosition:fi,proOptions:hi,defaultEdgeOptions:pi,elevateNodesOnSelect:gi=!0,elevateEdgesOnSelect:io=!1,disableKeyboardA11y:mi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:$r,autoPanOnSelection:zr=!0,autoPanSpeed:sr,connectionRadius:lr,isValidConnection:oo,onError:ar,style:Mn,id:vt,nodeDragThreshold:yi,connectionDragThreshold:xt,viewport:Dr,onViewportChange:vi,width:xi,height:Vn,colorMode:Pn="light",debug:Wn,onScroll:Qt,ariaLabelConfig:so,zIndexMode:wi="basic",...Or},Fr){const In=vt||"1",Rn=E_(Pn),_i=L.useCallback(Un=>{Un.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Qt==null||Qt(Un)},[Qt]);return d.jsx("div",{"data-testid":"rf__wrapper",...Or,onScroll:_i,style:{...Mn,...JS},ref:Fr,className:rt(["react-flow",a,Rn]),id:vt,role:"application",children:d.jsxs(ZS,{nodes:t,edges:r,width:xi,height:Vn,fitView:or,fitViewOptions:an,minZoom:gt,maxZoom:mt,nodeOrigin:it,nodeExtent:sn,zIndexMode:wi,children:[d.jsx(b_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:N,onConnectEnd:j,onClickConnectStart:E,onClickConnectEnd:w,nodesDraggable:Le,autoPanOnNodeFocus:Ze,nodesConnectable:pt,nodesFocusable:Xe,edgesFocusable:on,edgesReconnectable:Mt,elementsSelectable:ot,elevateNodesOnSelect:gi,elevateEdgesOnSelect:io,minZoom:gt,maxZoom:mt,nodeExtent:sn,onNodesChange:Bn,onEdgesChange:di,snapToGrid:ne,snapGrid:Ne,connectionMode:P,translateExtent:Pt,connectOnClick:Ar,defaultEdgeOptions:pi,fitView:or,fitViewOptions:an,onNodesDelete:J,onEdgesDelete:Z,onDelete:re,onNodeDragStart:V,onNodeDrag:X,onNodeDragStop:G,onSelectionDrag:W,onSelectionDragStart:I,onSelectionDragStop:H,onMove:v,onMoveStart:m,onMoveEnd:y,noPanClassName:Rt,nodeOrigin:it,rfId:In,autoPanOnConnect:Ve,autoPanOnNodeDrag:$r,autoPanSpeed:sr,onError:ar,connectionRadius:lr,isValidConnection:oo,selectNodesOnDrag:Re,nodeDragThreshold:yi,connectionDragThreshold:xt,onBeforeDelete:B,debug:Wn,ariaLabelConfig:so,zIndexMode:wi}),d.jsx(qS,{onInit:x,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:M,onNodeMouseMove:k,onNodeMouseLeave:b,onNodeContextMenu:A,onNodeDoubleClick:$,nodeTypes:u,edgeTypes:c,connectionLineType:z,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:de,selectionKeyCode:he,selectionOnDrag:Q,selectionMode:ae,deleteKeyCode:pe,multiSelectionKeyCode:ke,panActivationKeyCode:me,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:dt,translateExtent:Pt,minZoom:gt,maxZoom:mt,preventScrolling:kn,zoomOnScroll:no,zoomOnPinch:rr,zoomOnDoubleClick:Nn,panOnScroll:ui,panOnScrollSpeed:ci,panOnScrollMode:ir,panOnDrag:Nt,autoPanOnSelection:zr,onPaneClick:jn,onPaneMouseEnter:bn,onPaneMouseMove:It,onPaneMouseLeave:Ft,onPaneScroll:En,onPaneContextMenu:yt,paneClickDistance:Rr,nodeClickDistance:Ht,onSelectionContextMenu:U,onSelectionStart:C,onSelectionEnd:D,onReconnect:tt,onReconnectStart:He,onReconnectEnd:ln,onEdgeContextMenu:Hn,onEdgeDoubleClick:jt,onEdgeMouseEnter:Lr,onEdgeMouseMove:bt,onEdgeMouseLeave:Cn,reconnectRadius:Kt,defaultMarkerColor:qt,noDragClassName:ro,noWheelClassName:Bt,noPanClassName:Rt,rfId:In,disableKeyboardA11y:mi,nodeExtent:sn,viewport:Dr,onViewportChange:vi,nodesDraggable:Le}),d.jsx(S_,{onSelectionChange:te}),Tr,d.jsx(y_,{proOptions:hi,position:fi}),d.jsx(m_,{rfId:In,disableKeyboardA11y:mi})]})})}var tk=$g(ek);function nk({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:rt(["react-flow__background-pattern",o,s])})}function rk({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:rt(["react-flow__background-pattern","dots",r])})}var Ir;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Ir||(Ir={}));const ik={[Ir.Dots]:1,[Ir.Lines]:1,[Ir.Cross]:6},ok=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function um({id:t,variant:r=Ir.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:x,patternClassName:v}){const m=L.useRef(null),{transform:y,patternId:_}=ze(ok,Qe),N=s||ik[r],j=r===Ir.Dots,E=r===Ir.Cross,w=Array.isArray(o)?o:[o,o],M=[w[0]*y[2]||1,w[1]*y[2]||1],k=N*y[2],b=Array.isArray(u)?u:[u,u],A=E?[k,k]:M,$=[b[0]*y[2]+A[0]/2,b[1]*y[2]+A[1]/2],V=`${_}${t||""}`;return d.jsxs("svg",{className:rt(["react-flow__background",x]),style:{...p,...Kl,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:m,"data-testid":"rf__background",children:[d.jsx("pattern",{id:V,x:y[0]%M[0],y:y[1]%M[1],width:M[0],height:M[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:j?d.jsx(rk,{radius:k/2,className:v}):d.jsx(nk,{dimensions:A,lineWidth:a,variant:r,className:v})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${V})`})]})}um.displayName="Background";const sk=L.memo(um);function lk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ak(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function uk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 ck(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 wl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:rt(["react-flow__controls-button",r]),...o,children:t})}const fk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function cm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:x,children:v,position:m="bottom-left",orientation:y="vertical","aria-label":_}){const N=Ye(),{isInteractive:j,minZoomReached:E,maxZoomReached:w,ariaLabelConfig:M}=ze(fk,Qe),{zoomIn:k,zoomOut:b,fitView:A}=ql(),$=()=>{k(),u==null||u()},V=()=>{b(),c==null||c()},X=()=>{A(a),h==null||h()},G=()=>{N.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),p==null||p(!j)},J=y==="horizontal"?"horizontal":"vertical";return d.jsxs(Xl,{className:rt(["react-flow__controls",J,x]),position:m,style:t,"data-testid":"rf__controls","aria-label":_??M["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(wl,{onClick:$,className:"react-flow__controls-zoomin",title:M["controls.zoomIn.ariaLabel"],"aria-label":M["controls.zoomIn.ariaLabel"],disabled:w,children:d.jsx(lk,{})}),d.jsx(wl,{onClick:V,className:"react-flow__controls-zoomout",title:M["controls.zoomOut.ariaLabel"],"aria-label":M["controls.zoomOut.ariaLabel"],disabled:E,children:d.jsx(ak,{})})]}),o&&d.jsx(wl,{className:"react-flow__controls-fitview",onClick:X,title:M["controls.fitView.ariaLabel"],"aria-label":M["controls.fitView.ariaLabel"],children:d.jsx(uk,{})}),s&&d.jsx(wl,{className:"react-flow__controls-interactive",onClick:G,title:M["controls.interactive.ariaLabel"],"aria-label":M["controls.interactive.ariaLabel"],children:j?d.jsx(dk,{}):d.jsx(ck,{})}),v]})}cm.displayName="Controls";const hk=L.memo(cm);function pk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:x,borderRadius:v,shapeRendering:m,selected:y,onClick:_}){const{background:N,backgroundColor:j}=u||{},E=c||N||j;return d.jsx("rect",{className:rt(["react-flow__minimap-node",{selected:y},x]),x:r,y:o,rx:v,ry:v,width:s,height:a,style:{fill:E,stroke:h,strokeWidth:p},shapeRendering:m,onClick:_?w=>_(w,t):void 0})}const gk=L.memo(pk),mk=t=>t.nodes.map(r=>r.id),Wu=t=>t instanceof Function?t:()=>t;function yk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=gk,onClick:c}){const h=ze(mk,Qe),p=Wu(r),x=Wu(t),v=Wu(o),m=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(y=>d.jsx(xk,{id:y,nodeColorFunc:p,nodeStrokeColorFunc:x,nodeClassNameFunc:v,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:m},y))})}function vk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:x,x:v,y:m,width:y,height:_}=ze(N=>{const j=N.nodeLookup.get(t);if(!j)return{node:void 0,x:0,y:0,width:0,height:0};const E=j.internals.userNode,{x:w,y:M}=j.internals.positionAbsolute,{width:k,height:b}=Sn(E);return{node:E,x:w,y:M,width:k,height:b}},Qe);return!x||x.hidden||!cg(x)?null:d.jsx(h,{x:v,y:m,width:y,height:_,style:x.style,selected:!!x.selected,className:s(x),color:r(x),borderRadius:a,strokeColor:o(x),strokeWidth:u,shapeRendering:c,onClick:p,id:x.id})}const xk=L.memo(vk);var wk=L.memo(yk);const _k=200,Sk=150,kk=t=>!t.hidden,Nk=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?lg(us(t.nodeLookup,{filter:kk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},dp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,jk=(t,r)=>dp(t.viewBB,r.viewBB)&&dp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,bk="react-flow__minimap-desc";function dm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:x,maskStrokeColor:v,maskStrokeWidth:m,position:y="bottom-right",onClick:_,onNodeClick:N,pannable:j=!1,zoomable:E=!1,ariaLabel:w,inversePan:M,zoomStep:k=1,offsetScale:b=5}){const A=Ye(),$=L.useRef(null),{boundingRect:V,viewBB:X,rfId:G,panZoom:J,translateExtent:Z,flowWidth:re,flowHeight:te,ariaLabelConfig:I}=ze(Nk,jk),W=(t==null?void 0:t.width)??_k,H=(t==null?void 0:t.height)??Sk,U=V.width/W,C=V.height/H,D=Math.max(U,C),B=D*W,P=D*H,z=b*D,ie=V.x-(B-V.width)/2-z,oe=V.y-(P-V.height)/2-z,de=B+z*2,pe=P+z*2,he=`${bk}-${G}`,Q=L.useRef(0),ae=L.useRef();Q.current=D,L.useEffect(()=>{if($.current&&J)return ae.current=D1({domNode:$.current,panZoom:J,getTransform:()=>A.getState().transform,getViewScale:()=>Q.current}),()=>{var ne;(ne=ae.current)==null||ne.destroy()}},[J]),L.useEffect(()=>{var ne;(ne=ae.current)==null||ne.update({translateExtent:Z,width:re,height:te,inversePan:M,pannable:j,zoomStep:k,zoomable:E})},[j,E,M,k,Z,re,te]);const me=_?ne=>{var Re;const[Ne,Me]=((Re=ae.current)==null?void 0:Re.pointer(ne))||[0,0];_(ne,{x:Ne,y:Me})}:void 0,ke=N?L.useCallback((ne,Ne)=>{const Me=A.getState().nodeLookup.get(Ne).internals.userNode;N(ne,Me)},[]):void 0,ve=w??I["minimap.ariaLabel"];return d.jsx(Xl,{position:y,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-color-props":typeof v=="string"?v:void 0,"--xy-minimap-mask-stroke-width-props":typeof m=="number"?m*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:rt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:W,height:H,viewBox:`${ie} ${oe} ${de} ${pe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":he,ref:$,onClick:me,children:[ve&&d.jsx("title",{id:he,children:ve}),d.jsx(wk,{onClick:ke,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-z},${oe-z}h${de+z*2}v${pe+z*2}h${-de-z*2}z - M${X.x},${X.y}h${X.width}v${X.height}h${-X.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}dm.displayName="MiniMap";const Ek=L.memo(dm),Ck=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Mk={[Ji.Line]:"right",[Ji.Handle]:"bottom-right"};function Pk({nodeId:t,position:r,variant:o=Ji.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:x=Number.MAX_VALUE,maxHeight:v=Number.MAX_VALUE,keepAspectRatio:m=!1,resizeDirection:y,autoScale:_=!0,shouldResize:N,onResizeStart:j,onResize:E,onResizeEnd:w}){const M=Hg(),k=typeof t=="string"?t:M,b=Ye(),A=L.useRef(null),$=o===Ji.Handle,V=ze(L.useCallback(Ck($&&_),[$,_]),Qe),X=L.useRef(null),G=r??Mk[o];L.useEffect(()=>{if(!(!A.current||!k))return X.current||(X.current=Q1({domNode:A.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:Z,transform:re,snapGrid:te,snapToGrid:I,nodeOrigin:W,domNode:H}=b.getState();return{nodeLookup:Z,transform:re,snapGrid:te,snapToGrid:I,nodeOrigin:W,paneDomNode:H}},onChange:(Z,re)=>{const{triggerNodeChanges:te,nodeLookup:I,parentLookup:W,nodeOrigin:H}=b.getState(),U=[],C={x:Z.x,y:Z.y},D=I.get(k);if(D&&D.expandParent&&D.parentId){const B=D.origin??H,P=Z.width??D.measured.width??0,z=Z.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:P,height:z,...dg({x:Z.x??D.position.x,y:Z.y??D.position.y},{width:P,height:z},D.parentId,I,B)}},oe=Ec([ie],I,W,H);U.push(...oe),C.x=Z.x?Math.max(B[0]*P,Z.x):void 0,C.y=Z.y?Math.max(B[1]*z,Z.y):void 0}if(C.x!==void 0&&C.y!==void 0){const B={id:k,type:"position",position:{...C}};U.push(B)}if(Z.width!==void 0&&Z.height!==void 0){const P={id:k,type:"dimensions",resizing:!0,setAttributes:y?y==="horizontal"?"width":"height":!0,dimensions:{width:Z.width,height:Z.height}};U.push(P)}for(const B of re){const P={...B,type:"position"};U.push(P)}te(U)},onEnd:({width:Z,height:re})=>{const te={id:k,type:"dimensions",resizing:!1,dimensions:{width:Z,height:re}};b.getState().triggerNodeChanges([te])}})),X.current.update({controlPosition:G,boundaries:{minWidth:h,minHeight:p,maxWidth:x,maxHeight:v},keepAspectRatio:m,resizeDirection:y,onResizeStart:j,onResize:E,onResizeEnd:w,shouldResize:N}),()=>{var Z;(Z=X.current)==null||Z.destroy()}},[G,h,p,x,v,m,j,E,w,N]);const J=G.split("-");return d.jsx("div",{className:rt(["react-flow__resize-control","nodrag",...J,o,s]),ref:A,style:{...a,scale:V,...c&&{[$?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Pk);const Ik={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function Zl(t){return Ik[t]??8}const uc=208,cc=64,Rk=88,Tk=28,Lk=8;function Ak(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function $k(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const w of t){const M=Zl(w.type),k=s.get(M)??[];k.push(w),s.set(M,k)}const u=[...s.keys()].sort((w,M)=>w-M).map(w=>[...s.get(w)??[]].sort((M,k)=>M.name.localeCompare(k.name)||M.id.localeCompare(k.id))),c=new Set(t.map(w=>w.id)),h=new Map,p=new Map;for(const w of t)h.set(w.id,[]),p.set(w.id,[]);for(const w of r)!c.has(w.src)||!c.has(w.dst)||w.src===w.dst||(p.get(w.src).push(w.dst),h.get(w.dst).push(w.src));const x=new Map;u.forEach((w,M)=>{for(const k of w)x.set(k.id,M)});const v=new Map,m=()=>{for(const w of u)w.forEach((M,k)=>v.set(M.id,k))};m();const y=(w,M)=>{const k=w.map((b,A)=>{const $=M(b.id).map(X=>v.get(X)).filter(X=>X!==void 0),V=Ak($);return{n:b,bary:Number.isNaN(V)?A:V,name:b.name,id:b.id}});return k.sort((b,A)=>b.bary-A.bary||b.name.localeCompare(A.name)||b.id.localeCompare(A.id)),k.map(b=>b.n)},_=w=>M=>x.get(M)===w;for(let w=0;w(h.get(k)??[]).filter(_(M-1))),m();for(let M=u.length-2;M>=0;M--)u[M]=y(u[M],k=>(p.get(k)??[]).filter(_(M+1))),m()}const N=uc+Rk,j=cc+Tk,E=Math.max(...u.map(w=>w.length),1);return u.forEach((w,M)=>{const k=(E-w.length)*j/2;w.forEach((b,A)=>{o.set(b.id,{x:M*N,y:k+A*j})})}),o}const zk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),fm=90,Dk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),fp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Ok=Math.PI*(3-Math.sqrt(5)),hm=220,Fk=26,Hk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function pm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function PN(t){return fp[t]?fp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Bk(t){return t>=fm?"3d":"2d"}function Vk(t){return t>=fm?"overview":"full"}function Wk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(pm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Dk.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Wk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Yk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function Gk(t,r,o,s){const a=new Set(t.map(j=>j.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const j of r){if(!a.has(j.src)||!a.has(j.dst))continue;const E=u.get(j.src)??[];E.push({dst:j.dst,id:j.id}),u.set(j.src,E);const w=c.get(j.dst)??[];w.push({src:j.src,id:j.id}),c.set(j.dst,w)}const h=new Set(t.filter(j=>zk.has(j.type)).map(j=>j.id)),p=h.size?h:a,x=new Set,v=[o];for(;v.length;){const j=v.pop();if(!x.has(j)){x.add(j);for(const E of u.get(j)??[])x.has(E.dst)||v.push(E.dst)}}const m=new Set([o]),y=[...p].filter(j=>x.has(j)),_=new Set(y);for(;y.length;){const j=y.pop();m.add(j);for(const E of c.get(j)??[])x.has(E.src)&&!_.has(E.src)&&(_.add(E.src),y.push(E.src))}const N=new Set;for(const j of r)m.has(j.src)&&m.has(j.dst)&&N.add(j.id);return{nodeIds:m,edgeIds:N}}function IN(t){const r=new Map;for(const s of t){const a=Zl(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*hm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Fk*Math.sqrt(h+1),x=h*Ok;o.set(c.id,{x:u,y:p*Math.cos(x),z:p*Math.sin(x)})})}return o}function RN(t){const r=new Map;for(const o of t){const s=Zl(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*hm,count:s}))}const _l=16,Xk=12,qk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Kk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),hp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Qk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},pp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],gp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Zk=new Set(["looks_idempotent_on_pk","null","blank"]),Jk=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function eN(t){return hp[t]?hp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function tN(t,r,o){const s=new Map(r.map(y=>[y.id,y])),a=[];qk.has(t.type)&&a.push("sink"),Kk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(y=>y.dst===t.id),h=o.filter(y=>y.src===t.id),p=c.slice(0,_l).map(y=>Sl(y,s,y.src)),x=h.slice(0,_l).map(y=>Sl(y,s,y.dst)),v=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,m={type:t.type,typeLabel:Xo(to(t.type)),layer:Hk[Zl(t.type)]??"other",purpose:eN(t.type),name:t.name,qualifiedName:t.qualified_name,file:v,context:t.context,roles:a,facts:rN(u).filter(y=>!(y.key==="app"&&y.value===t.context)),inputs:p,outputs:x,extraInputs:Math.max(0,c.length-_l),extraOutputs:Math.max(0,h.length-_l),degreeIn:c.length,degreeOut:h.length,inputKinds:mp(c.map(y=>Sl(y,s,y.src))),outputKinds:mp(h.map(y=>Sl(y,s,y.dst))),pathSummary:""};return m.pathSummary=nN(m),m}function mp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function nN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function Sl(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Xo(to(s.type)):"",edgeType:t.type,edgeLabel:Xo(t.type),inferred:t.confidence<.8}}function rN(t){const r=[...pp.filter(a=>a in t),...Object.keys(t).filter(a=>!pp.includes(a)&&!gp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||gp.has(a)||Jk.has(a))continue;s.add(a);const u=iN(a,t[a]);u!=null&&o.push({key:a,label:Qk[a]??Xo(a),value:u})}return o}function iN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Zk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return oN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Xk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function oN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const sN=new Set,lN=L.lazy(()=>_0(()=>import("./LayeredGraph3D-DIo4wwkt.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),aN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function uN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(eo,{type:"target",position:Se.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:to(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Mr(t.name)}),d.jsx(eo,{type:"source",position:Se.Right,isConnectable:!1})]})}const cN={load:uN},dN=new Set(["django","react","stitch","arch"]);function fN({topologyKey:t}){const{fitView:r}=ql();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function hN(t,r,o=null,s={}){const a=new Map(t.map(p=>[p.id,p])),u=$k(t,r),c=t.map(p=>{var m;const x=((m=s.roles)==null?void 0:m[p.id])||[],v=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:p.id,type:"load",position:u.get(p.id)??{x:0,y:0},data:{name:p.name,type:p.type,file:p.file_path,roles:x,dim:v},selected:o===p.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:uc,height:cc,style:{width:uc,height:cc}}}),h=r.filter(p=>a.has(p.src)&&a.has(p.dst)).map(p=>{const x=aN[p.weight]||"var(--edge-cheap)",v=!!(o&&(p.src===o||p.dst===o));return{id:p.id,source:p.src,target:p.dst,type:"smoothstep",animated:p.weight==="critical",style:{stroke:x,strokeWidth:p.weight==="critical"?2.4:1.2,strokeDasharray:p.confidence<.8?"6 4":void 0},markerEnd:{type:ts.ArrowClosed,width:14,height:14,color:x},label:v?p.type.replaceAll("_"," "):void 0,labelStyle:v?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:v?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:v?[3,5]:void 0,labelBgBorderRadius:v?4:void 0}});return{rfNodes:c,rfEdges:h}}function pN({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:x}){const v=tN(t,r,o);return L.useEffect(()=>{const m=y=>{y.key==="Escape"&&s()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:v.typeLabel}),d.jsx("div",{className:"inspector-roles",children:v.roles.map(m=>d.jsx("span",{className:"inspector-chip",children:m},m))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Mr(v.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:v.purpose}),v.context?d.jsx("div",{className:"muted",children:Mr(v.context)}):null,v.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Mr(v.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Mr(v.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",v.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[v.degreeIn," in · ",v.degreeOut," out"]}),v.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:v.pathSummary}):null,v.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:v.facts.map(m=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:m.label}),d.jsx("dd",{children:Mr(m.value)})]},m.key))}):null,d.jsx(yp,{title:"Inputs",testId:"graph-inspector-inputs",links:v.inputs,extra:v.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(yp,{title:"Outputs",testId:"graph-inspector-outputs",links:v.outputs,extra:v.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",onClick:()=>a(t.id),children:"What if this changes"}):null,x?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",onClick:()=>x(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function yp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Mr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Mr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Uu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:x,repoPath:v,onOpenFile:m,pinnedId:y,onPin:_}){const[N,j]=L.useState(null),E=a!==void 0?a:N,w=ne=>{a===void 0&&j(ne),u==null||u(ne)},[M,k]=L.useState(null),[b,A]=L.useState(null),[$,V]=L.useState(new Set(dN)),[X,G]=L.useState(!1),[J,Z]=L.useState(""),[re,te]=L.useState(!1),I=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,W=M??Bk(t.length),H=b??Vk(t.length),U=X?E:null,C=L.useMemo(()=>p?Gk(t,r,p):null,[t,r,p]),D=C?t.filter(ne=>C.nodeIds.has(ne.id)):t,B=C?r.filter(ne=>C.edgeIds.has(ne.id)):r,P=L.useMemo(()=>Uk(D,B,{detail:H,families:$,focusId:U,neighborhoodOnly:!!U}),[D,B,H,$,U]),z=L.useMemo(()=>`${P.nodes.map(ne=>ne.id).join("\0")}|${P.edges.map(ne=>ne.id).join("\0")}`,[P.nodes,P.edges]),ie=E?t.find(ne=>ne.id===E)??null:null,{rfNodes:oe,rfEdges:de}=L.useMemo(()=>{const ne=hN(P.nodes,P.edges,E,{roles:c,testOverlay:h});return I&&(ne.rfEdges=ne.rfEdges.map(Ne=>({...Ne,animated:!1}))),ne},[P.nodes,P.edges,E,I,c,h]);L.useEffect(()=>{if(!s)return;const ne=t.find(Ne=>Ne.file_path===s);ne&&w(ne.id)},[s,t]);const pe=L.useMemo(()=>Yk(t,J),[t,J]),he=(ne,Ne)=>{w(Ne.id)},Q=()=>{w(null),G(!1)},ae=ie?d.jsx(pN,{node:ie,nodes:t,edges:r,onClose:Q,onWhatIf:o,onSelect:w,onOpenFile:m,pinned:y===ie.id,onPin:_,onIsolate:x?ne=>{x(p===ne?null:ne)}:void 0}):null,me=ne=>{V(Ne=>{const Me=new Set(Ne);if(Me.has(ne)){if(Me.size===1)return Ne;Me.delete(ne)}else Me.add(ne);return Me})},ke=L.useMemo(()=>{const ne=new Set;for(const Ne of t)ne.add(pm(Ne.type));return ne},[t]),ve=t.length-P.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:W==="2d"?"active":"","aria-pressed":W==="2d",onClick:()=>k("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:W==="3d"?"active":"","aria-pressed":W==="3d",onClick:()=>k("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:H==="overview"?"active":"","aria-pressed":H==="overview",onClick:()=>A("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:H==="full"?"active":"","aria-pressed":H==="full",onClick:()=>A("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(ne=>ke.has(ne)).map(ne=>d.jsx("button",{type:"button","data-testid":`graph-family-${ne}`,className:$.has(ne)?"active":"","aria-pressed":$.has(ne),onClick:()=>me(ne),children:ne},ne))}),d.jsx("button",{type:"button",className:X?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!E,onClick:()=>G(ne=>!ne),children:X?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>x==null?void 0:x(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:J,onChange:ne=>{Z(ne.target.value),te(!0)},onFocus:()=>te(!0),onBlur:()=>window.setTimeout(()=>te(!1),150)}),re&&J.trim()&&pe.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:pe.map(ne=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:Ne=>Ne.preventDefault(),onClick:()=>{w(ne.id),Z(""),te(!1)},children:[ne.name,d.jsx("span",{className:"muted",children:to(ne.type)})]})},ne.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[P.nodes.length," nodes · ",P.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:W==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(lN,{nodes:P.nodes,edges:P.edges,selectedId:E,neighborIds:U?P.neighborIds:sN,onSelect:ne=>{w(ne),ne||G(!1)}})}),ae]}):d.jsxs(am,{children:[d.jsxs(tk,{nodes:oe,edges:de,nodeTypes:cN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:he,onPaneClick:Q,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(fN,{topologyKey:z}),d.jsx(sk,{}),d.jsx(Ek,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(hk,{})]}),ae]})})]})}function gm(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function gN(t){localStorage.setItem("loadpath.editor",t)}async function mN(t,r,o,s=gm()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const vp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],yN=["preset","branch","tag","commit"];function vN(t){var a;if(!(t!=null&&t.git))return[...vp];const r=((a=t.presets)!=null&&a.length?t.presets:vp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function xN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function wN(t){return yN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function _N(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function xp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[x,v]=L.useState(!1),[m,y]=L.useState(null),[_,N]=L.useState(0),j=L.useMemo(()=>{const b=vN(u);return m===null?b:xN(b,m)},[u,m]),E=L.useMemo(()=>wN(j),[j]);L.useEffect(()=>{x&&c()},[x,c]),L.useEffect(()=>{N(0)},[m,x]);const w=()=>{v(!1),y(null)},M=b=>{r(b.value),w()},k=b=>{if(b.key==="ArrowDown"){if(b.preventDefault(),!x){v(!0);return}N(A=>Math.min(A+1,Math.max(j.length-1,0)))}else if(b.key==="ArrowUp"){if(b.preventDefault(),!x)return;N(A=>Math.max(A-1,0))}else if(b.key==="Enter"&&x){b.preventDefault();const A=j[_];A&&M(A)}else b.key==="Escape"&&x&&(b.preventDefault(),w())};return d.jsxs("div",{className:"combo",ref:p,onBlur:b=>{b.currentTarget.contains(b.relatedTarget)||w()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":x,"aria-controls":h,"aria-autocomplete":"list",onChange:b=>{r(b.target.value),x&&y(b.target.value)},onKeyDown:k}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":x,onMouseDown:b=>b.preventDefault(),onClick:()=>x?w():v(!0),children:d.jsx(v0,{})})]}),x?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:E.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):E.map(b=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:_N(b.group)}),b.items.map(A=>{const $=j.indexOf(A);return d.jsxs("button",{type:"button",role:"option","aria-selected":$===_,className:$===_?"combo-option active":"combo-option","data-testid":`ref-option-${A.group}`,onMouseDown:V=>V.preventDefault(),onMouseEnter:()=>N($),onClick:()=>M(A),children:[d.jsx("span",{className:"combo-label",children:A.label}),A.detail?d.jsx("span",{className:"combo-detail",children:A.detail}):null]},`${A.group}:${A.value}`)})]},b.group))}):null]})}function SN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[x,v]=L.useState(""),[m,y]=L.useState(!1),_=L.useRef(null),N=L.useRef(0),j=async k=>{const b=N.current+1;N.current=b,y(!0);try{const A=await Pe.browse(k);if(N.current!==b)return;a(A),c(A.path),p(A.is_git?A.path:null),v("")}catch(A){if(N.current!==b)return;v(A instanceof Error?A.message:String(A))}finally{N.current===b&&y(!1)}};L.useEffect(()=>{var k,b;j(t),(k=_.current)==null||k.focus(),(b=_.current)==null||b.select()},[t]);const E=h||(s==null?void 0:s.path)||u,w=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",M=k=>{k.key==="Escape"&&(k.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:M,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:k=>k.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:k=>{k.preventDefault(),j(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:k=>c(k.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),x?d.jsx("div",{className:"error",role:"alert",children:x}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":m,children:s!=null&&s.entries.length?s.entries.map(k=>{const b=h===k.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":b,className:b?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":k.path,onClick:()=>p(k.path),onDoubleClick:()=>void j(k.path),children:[d.jsx(kp,{}),d.jsx("span",{className:"explorer-name",children:k.name}),k.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},k.path)}):d.jsx("div",{className:"muted explorer-empty",children:m?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:E,children:E}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!E,onClick:()=>E&&r(E),children:["Use ",w]})]})]})})}const Dl=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],kN="obsidian",mm="loadpath.theme";function NN(t){return Dl.some(r=>r.id===t)}function ym(){try{const t=localStorage.getItem(mm)||"";if(NN(t))return t}catch{}return kN}function jN(t){var r;return((r=Dl.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function vm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=jN(t);try{localStorage.setItem(mm,t)}catch{}}const Yu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:h0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:p0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:g0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:m0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:y0}];function bN(t){const r=t.total||0;return r<=0?null:Math.min(100,Math.round(100*(t.done||0)/r))}function Gu(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function EN(){var Fr,In,Rn,_i,Un,De,lo,ao;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,x]=L.useState(null),[v,m]=L.useState(null),[y,_]=L.useState([]),[N,j]=L.useState("review"),[E,w]=L.useState(""),[M,k]=L.useState(""),[b,A]=L.useState(null),[$,V]=L.useState(!1),[X,G]=L.useState(""),[J,Z]=L.useState({}),[re,te]=L.useState([]),[I,W]=L.useState([]),[H,U]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[C,D]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[B,P]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[z,ie]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[oe,de]=L.useState(0),[pe,he]=L.useState(""),[Q,ae]=L.useState(ym),[me,ke]=L.useState(!1),[ve,ne]=L.useState(!1),[Ne,Me]=L.useState(!1),[Re,Le]=L.useState(null),[Ze,pt]=L.useState(null),[Xe,it]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[on,Mt]=L.useState(null),[ot,dt]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[gt,mt]=L.useState([]),[Pt,kn]=L.useState(null),[sn,qt]=L.useState(null),[no,rr]=L.useState(null),[ui,ci]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[ir,Nn]=L.useState(null),[Nt,jn]=L.useState(null),[bn,It]=L.useState(!1),[Ft,En]=L.useState(!1),yt=L.useRef(o);yt.current=o;const Rr=L.useRef(!1);Rr.current=ve;const Ht=L.useRef(""),Tr=R=>{ae(R),vm(R)},tt=L.useRef(""),He=R=>{tt.current=R,k(R)},ln=R=>{const Y=()=>{Pe.indexProgress(R).then(Ee=>{tt.current&&(Ee.phase&&Ee.phase!=="idle"&&Ee.message&&He(Ee.message),A(Ee.phase&&Ee.phase!=="idle"?bN(Ee):null))}).catch(()=>{})};Y();const fe=window.setInterval(Y,250);return()=>{window.clearInterval(fe),A(null)}};L.useEffect(()=>{Pe.settings().then(Z).catch(()=>{}).finally(()=>ke(!0)),Pe.repos().then(R=>_(R.repos)).catch(()=>{})},[]);const Hn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const R=o;let Y=!1;return Pe.architecture(R).then(fe=>{!Y&&yt.current===R&&m(fe)}).catch(()=>{}),Pe.config(R).then(fe=>{!Y&&yt.current===R&&qt(fe)}).catch(()=>{}),Pe.architectureHealth(R).then(fe=>{!Y&&yt.current===R&&rr(fe)}).catch(()=>{}),()=>{Y=!0}},[t,o]);const jt=R=>{yt.current=R,s(R),localStorage.setItem("loadpath.repo",R),R.trim()!==Ht.current&&(Ht.current="",Nn(null))},Lr=L.useCallback(R=>{const Y=(R??yt.current).trim();return!Y||Ht.current===Y?Promise.resolve():(Ht.current=Y,Pe.gitRefs(Y).then(fe=>{yt.current.trim()===Y&&Nn(fe)}).catch(()=>{Ht.current===Y&&(Ht.current="",Nn(null))}))},[]),bt=(R,Y)=>{u(R),h(Y),localStorage.setItem("loadpath.base",R),localStorage.setItem("loadpath.head",Y)},Cn=(R,Y,fe)=>{D(R),U(Y),localStorage.setItem("loadpath.provider",R),localStorage.setItem("loadpath.scmRepo",Y),fe!==void 0&&(P(fe),localStorage.setItem("loadpath.prNumber",fe))},Kt=R=>{x(R),de(0),Le(Ze&&R.nodes.some(Y=>Y.id===Ze)?Ze:null),Mt(null),kn(null),R.id&&!R.what_if&&localStorage.setItem("loadpath.lastReviewId",R.id)},Bn=async R=>{try{const Y=await Pe.reviews(R);mt(Y.reviews)}catch{mt([])}},di=async R=>{try{rr(await Pe.architectureHealth(R))}catch{rr(null)}},ro=R=>R==="github"?!!J.github_token_set:R==="gitlab"?!!J.gitlab_token_set:!!J.bitbucket_token_set,Bt=L.useCallback(async(R=C)=>{var Y;try{const fe=await Pe.scmRepos(R);W(fe.repos),(Y=fe.user)!=null&&Y.login&&Z(Ee=>({...Ee,...R==="github"?{github_user:fe.user.login}:R==="gitlab"?{gitlab_user:fe.user.login}:{bitbucket_user:fe.user.login}}))}catch{W([])}},[C]);L.useEffect(()=>{if(t!=="prs")return;let R=!1;return Bt(C).catch(()=>{R||W([])}),()=>{R=!0}},[t,C,Bt]),L.useEffect(()=>{if(!Nt)return;let R=!1,Y=0;const fe=async()=>{try{const Ee=await Pe.githubOAuthPoll(Nt.flow_id);if(R)return;if(Ee.status==="complete"){jn(null);const Ae=await Pe.settings();Z(Ae),G(Ee.user?`Signed in to GitHub as ${Ee.user}`:"Signed in to GitHub"),Bt("github");return}if(Ee.status==="pending"||Ee.status==="slow_down"){Y=window.setTimeout(fe,Math.max(Ee.interval||Nt.interval,5)*1e3);return}jn(null),w(Ee.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(Ee){if(R)return;jn(null),w(Ee instanceof Error?Ee.message:String(Ee))}};return Y=window.setTimeout(fe,Math.max(Nt.interval,5)*1e3),()=>{R=!0,window.clearTimeout(Y)}},[Nt,Bt]),L.useEffect(()=>{if(!bn)return;let R=!1,Y=0;const fe=Date.now(),Ee=async()=>{try{const Ae=await Pe.oauthStatus();if(R)return;if(Ae.bitbucket.connected){It(!1);const Fe=await Pe.settings();Z(Fe),G(Ae.bitbucket.user?`Signed in to Bitbucket as ${Ae.bitbucket.user}`:"Signed in to Bitbucket"),Bt("bitbucket");return}if(Date.now()-fe>18e4){It(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(Ee,1500)}catch(Ae){if(R)return;It(!1),w(Ae instanceof Error?Ae.message:String(Ae))}};return Y=window.setTimeout(Ee,1500),()=>{R=!0,window.clearTimeout(Y)}},[bn,Bt]),L.useEffect(()=>{if(!Ft)return;let R=!1,Y=0;const fe=Date.now(),Ee=async()=>{try{const Ae=await Pe.oauthStatus();if(R)return;if(Ae.gitlab.connected){En(!1);const Fe=await Pe.settings();Z(Fe),G(Ae.gitlab.user?`Signed in to GitLab as ${Ae.gitlab.user}`:"Signed in to GitLab"),Bt("gitlab");return}if(Date.now()-fe>18e4){En(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(Ee,1500)}catch(Ae){if(R)return;En(!1),w(Ae instanceof Error?Ae.message:String(Ae))}};return Y=window.setTimeout(Ee,1500),()=>{R=!0,window.clearTimeout(Y)}},[Ft,Bt]);const Rt=async(R=o)=>{if(!R.trim())return null;const Y=await Pe.architecture(R);return yt.current===R&&m(Y),Y},or=async R=>{const Y=R.trim();if(!(!Y||Y===yt.current)){if(tt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),G(""),x(null),m(null),j("architecture"),jt(Y),V(!0),He(`Loading ${f0(Y)}…`);try{await Promise.all([Rt(Y),Lr(Y)])}catch(fe){yt.current===Y&&w(fe instanceof Error?fe.message:String(fe))}finally{yt.current===Y&&(He(""),V(!1))}}},an=async()=>{if(tt.current||!Hn())return;w(""),G(""),He("Tracing load path…"),jt(o),bt(a,c);const R=ln(o);try{const Y=await Pe.review(o,a,c,!0,z);Kt(Y),j("review"),r("review"),await Pe.repos().then(fe=>_(fe.repos)).catch(()=>{}),await Promise.all([Rt(o),Bn(o),di(o)])}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{R(),He("")}},Ar=async(R=!0)=>{if(tt.current||!Hn())return;w(""),G(""),He(R?"Indexing…":"Full reindex…"),jt(o);const Y=ln(o);try{await Pe.index(o,R);const fe=await Rt(o);await Pe.repos().then(Ee=>_(Ee.repos)).catch(()=>{}),fe!=null&&fe.indexed&&(j("architecture"),r("architecture"))}catch(fe){w(fe instanceof Error?fe.message:String(fe))}finally{Y(),He("")}},fi=async()=>{if(!tt.current&&Hn()){w(""),G(""),He("Detecting layout…"),jt(o);try{const R=await Pe.init(o);G(R.message),await Pe.repos().then(Y=>_(Y.repos)).catch(()=>{})}catch(R){w(R instanceof Error?R.message:String(R))}finally{He("")}}},hi=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),G("Copied markdown brief")}catch(R){w(R instanceof Error?R.message:String(R))}},pi=async()=>{if(!tt.current){if(!(p!=null&&p.markdown)||!H||!B){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const R=await Pe.postComment(C,H,Number(B),p.markdown);G(R.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(R){w(R instanceof Error?R.message:String(R))}finally{He("")}}},gi=async()=>{if(!tt.current){w(""),He("Fetching pull requests…");try{const R=await Pe.prs(C,H,"open",o.trim()||void 0);te(R.pull_requests);const Y=I.find(fe=>fe.slug.toLowerCase()===H.trim().toLowerCase());Y!=null&&Y.local_path&&jt(Y.local_path)}catch(R){w(R instanceof Error?R.message:String(R))}finally{He("")}}},io=async()=>{w("");try{const R=await Pe.githubOAuthStart();jn(R),Gu(R.verification_uri_complete,"github.com","/login/device")}catch(R){w(R instanceof Error?R.message:String(R))}},mi=async()=>{w("");try{const R=await Pe.bitbucketOAuthStart();It(!0),Gu(R.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(R){It(!1),w(R instanceof Error?R.message:String(R))}},Ve=async()=>{w("");try{const R=await Pe.gitlabOAuthStart();En(!0),Gu(R.authorize_url,new URL(R.authorize_url).hostname,"/oauth/authorize")}catch(R){En(!1),w(R instanceof Error?R.message:String(R))}},$r=async R=>{if(!(tt.current||!o.trim())){w(""),He("Walking what-if path…");try{const Y=await Pe.whatIf(o,R);G(`${Y.title} — ${Y.confidence.level} · ${(Y.sinks||[]).length} sinks`),Kt({...Y,markdown:Y.markdown||"",index:Y.index||(p==null?void 0:p.index),workspace:Y.workspace||(p==null?void 0:p.workspace)}),j("review"),r("review")}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},zr=async R=>{var Ae;if(tt.current)return;Cn(R.provider,R.repo,String(R.number));const Y=I.find(Fe=>Fe.slug.toLowerCase()===R.repo.toLowerCase());Y!=null&&Y.local_path&&jt(Y.local_path),w(""),He(`Fetching ${R.provider} #${R.number}…`);const fe=(Y==null?void 0:Y.local_path)||o,Ee=fe?ln(fe):()=>{};try{const Fe=await Pe.reviewPr(R.provider,R.repo,R.number,(Y==null?void 0:Y.local_path)||o||void 0);Kt(Fe),Fe.pull_request&&typeof Fe.pull_request.repo_path=="string"&&jt(Fe.pull_request.repo_path),bt(String(Fe.base||R.target_branch),String(Fe.head||R.source_branch)),j("review"),r("review"),typeof((Ae=Fe.pull_request)==null?void 0:Ae.repo_path)=="string"&&Bn(Fe.pull_request.repo_path)}catch(Fe){bt(R.base_sha||R.target_branch,R.head_sha||R.source_branch),r("review"),w(Fe instanceof Error?Fe.message:String(Fe))}finally{Ee(),He("")}},sr=async R=>{w("");try{Z(await Pe.oauthDisconnect(R)),C===R&&W([]),G(`Disconnected ${R}`)}catch(Y){w(Y instanceof Error?Y.message:String(Y))}},lr=async R=>{R.preventDefault();const Y=new FormData(R.currentTarget),fe={github_token:String(Y.get("github_token")||""),github_oauth_client_id:String(Y.get("github_oauth_client_id")||""),github_host:String(Y.get("github_host")||""),gitlab_token:String(Y.get("gitlab_token")||""),gitlab_host:String(Y.get("gitlab_host")||""),gitlab_oauth_client_id:String(Y.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(Y.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(Y.get("bitbucket_token")||""),bitbucket_username:String(Y.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(Y.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(Y.get("bitbucket_oauth_client_secret")||""),ai_provider:String(Y.get("ai_provider")||"none"),ai_api_key:String(Y.get("ai_api_key")||""),ai_model:String(Y.get("ai_model")||""),ai_base_url:String(Y.get("ai_base_url")||"")},Ee=y.length?{...fe,workspaces:y.map(Ae=>({path:Ae.path,name:Ae.name}))}:fe;try{Z(await Pe.saveSettings(Ee)),G("Settings saved on this machine")}catch(Ae){w(Ae instanceof Error?Ae.message:String(Ae))}},oo=async()=>{if(!(!p||tt.current)){He("Residual analysis…");try{const R=await Pe.residual(p);he(R.note)}catch(R){w(R instanceof Error?R.message:String(R))}finally{He("")}}},ar=L.useRef(an);ar.current=an;const Mn=L.useRef(t);Mn.current=t;const vt=L.useRef(!1);vt.current=Ne;const yi=L.useRef(p);yi.current=p;const xt=L.useRef(oe);xt.current=oe,L.useEffect(()=>{const R=localStorage.getItem("loadpath.lastReviewId"),Y=(localStorage.getItem("loadpath.repo")||"").trim();if(!R||!Y){ci(!1);return}let fe=!1;return Pe.getReview(Y,R).then(Ee=>{fe||(Kt(Ee),bt(Ee.base||localStorage.getItem("loadpath.base")||"HEAD~1",Ee.head||localStorage.getItem("loadpath.head")||"HEAD"),Bn(Y),di(Y))}).catch(()=>{}).finally(()=>{fe||ci(!1)}),()=>{fe=!0}},[]);const Dr=L.useRef("");L.useEffect(()=>{if(!ot||!o.trim())return;let R=!1;const Y=async()=>{try{const Ee=await Pe.workspaceStatus(o);if(R)return;Dr.current&&Ee.fingerprint!==Dr.current&&!tt.current&&(ie(!0),localStorage.setItem("loadpath.dirty","1"),ar.current()),Dr.current=Ee.fingerprint}catch{}};Y();const fe=window.setInterval(Y,2e3);return()=>{R=!0,window.clearInterval(fe)}},[ot,o]),L.useEffect(()=>{const R=Y=>{var Ae;if((Y.metaKey||Y.ctrlKey)&&Y.key.toLowerCase()==="k"){Y.preventDefault(),Me(Fe=>!Fe);return}if(vt.current){Y.key==="Escape"&&(Y.preventDefault(),Me(!1));return}if(Rr.current){Y.key==="Escape"&&(Y.preventDefault(),ne(!1));return}const fe=Y.target;if(fe&&(fe.tagName==="INPUT"||fe.tagName==="TEXTAREA"||fe.tagName==="SELECT"||fe.isContentEditable)){Y.key==="Escape"&&fe.blur();return}if(Y.key==="Escape"){w(""),G(""),Le(Ze),Mt(null);return}if(Y.key==="j"||Y.key==="k"){const Fe=((Ae=yi.current)==null?void 0:Ae.read_order)||[];if(!Fe.length)return;Y.preventDefault();const un=xt.current,Tn=Y.key==="j"?Math.min(Fe.length-1,un+1):Math.max(0,un-1);de(Tn);return}const Ee=Yu.find(Fe=>Fe.shortcut===Y.key);if(Ee&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey&&r(Ee.id),(Y.metaKey||Y.ctrlKey)&&Y.key==="Enter"){if(Mn.current==="settings"||Mn.current==="prs"||tt.current)return;Y.preventDefault(),ar.current()}};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[Ze]);const vi=async(R,Y)=>{if(!o.trim())return;const fe=await mN(o,R,Y);fe.ok?G(fe.message):w(fe.message)},xi=async()=>{if(p)try{const R=await Pe.exportHtml(p),Y=URL.createObjectURL(R),fe=document.createElement("a");fe.href=Y,fe.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,fe.click(),URL.revokeObjectURL(Y),G("Saved HTML brief")}catch(R){w(R instanceof Error?R.message:String(R))}},Vn=async R=>{if(o.trim()){He("Loading stored review…");try{const Y=await Pe.getReview(o,R);Kt(Y),bt(Y.base||a,Y.head||c),j("review"),r("review");const fe=gt.find(Ee=>Ee.id!==R);if(fe)try{kn(await Pe.reviewDiff(o,R,fe.id))}catch{kn(null)}}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},Pn={selectedId:Re,onSelect:Le,nodeRoles:p==null?void 0:p.node_roles,testOverlay:Xe,isolateSource:on,onIsolate:Mt,repoPath:o,onOpenFile:vi,pinnedId:Ze,onPin:pt},Wn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void an()},{id:"index",group:"Run",label:"Index repository",run:()=>void Ar(!0)},{id:"watch",group:"Run",label:ot?"Stop watching working tree":"Watch working tree",run:()=>{const R=!ot;dt(R),localStorage.setItem("loadpath.watch",R?"1":"0")}},{id:"tests",group:"Graph",label:Xe?"Hide test overlay":"Show test overlay",run:()=>{const R=!Xe;it(R),localStorage.setItem("loadpath.testOverlay",R?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void xi()},...Yu.map(R=>({id:`tab-${R.id}`,group:"Tabs",label:`Go to ${R.label}`,hint:R.shortcut,run:()=>r(R.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(R=>({id:`node-${R.id}`,group:"Nodes",label:R.name,hint:to(R.type),run:()=>{Le(R.id),r("graph")}})),...gt.slice(0,12).map(R=>({id:`hist-${R.id}`,group:"History",label:R.title||R.id,hint:`${R.level||""} ${R.created_at||""}`.trim(),run:()=>void Vn(R.id)}))],Qt=L.useMemo(()=>N==="architecture"?(v==null?void 0:v.nodes)??[]:(p==null?void 0:p.nodes)??[],[N,v,p]),so=L.useMemo(()=>N==="architecture"?(v==null?void 0:v.edges)??[]:(p==null?void 0:p.edges)??[],[N,v,p]),wi=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:v!=null&&v.indexed?`${v.counts.nodes} nodes · ${v.counts.edges} edges`:"Not indexed",Or=((p==null?void 0:p.findings)||[]).filter(R=>!R.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Yu.map(R=>{const Y=R.icon,fe=t===R.id;return d.jsxs("button",{type:"button","data-testid":R.testId,className:fe?"nav-item active":"nav-item","aria-current":fe?"page":void 0,"aria-label":R.label,onClick:()=>r(R.id),children:[d.jsx(Y,{}),d.jsx("span",{children:R.label})]},R.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:Q,onChange:R=>Tr(R.target.value),children:["dark","light"].map(R=>d.jsx("optgroup",{label:R==="dark"?"Dark":"Light",children:Dl.filter(Y=>Y.group===R).map(Y=>d.jsx("option",{value:Y.id,children:Y.label},Y.id))},R))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:M||wi}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[M?d.jsxs("div",{className:b!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","data-testid":"progress",children:[d.jsx("i",{style:b!=null?{width:`${b}%`}:void 0}),d.jsx("span",{className:"sr-only",children:M})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[y.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:y.some(R=>R.path===o)?o:"",disabled:!!M,"aria-busy":$,onChange:R=>{R.target.value&&or(R.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),y.map(R=>d.jsxs("option",{value:R.path,children:[R.name,R.indexed?` (${R.counts.nodes})`:""]},R.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:R=>{const Y=R.target.value;s(Y),Y.trim()!==Ht.current&&(Ht.current="",Nn(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>ne(!0),children:d.jsx(kp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(xp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:R=>bt(R,c),placeholder:"base",refs:ir,onNeedRefs:Lr})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(xp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:R=>bt(a,R),placeholder:"head",refs:ir,onNeedRefs:Lr})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:z?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":z,onClick:()=>{const R=!z;ie(R),localStorage.setItem("loadpath.dirty",R?"1":"0")},children:z?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:ot?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":ot,onClick:()=>{const R=!ot;dt(R),localStorage.setItem("loadpath.watch",R?"1":"0")},children:ot?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!M,onClick:fi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!M,onClick:()=>Ar(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!M,onClick:an,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[E?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:E}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,X?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:X}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>G(""),"aria-label":"Dismiss",children:"×"})]}):null,((Fr=p==null?void 0:p.index)!=null&&Fr.stale||v!=null&&v.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((In=p==null?void 0:p.index)==null?void 0:In.django_boot)==="failed"||(v==null?void 0:v.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Rn=p==null?void 0:p.index)==null?void 0:Rn.django_boot_detail)||(v==null?void 0:v.django_boot_detail)||"django.setup() failed"}):null,(_i=p==null?void 0:p.workspace)!=null&&_i.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null]}),d.jsxs("div",{className:"stage","aria-busy":$,children:[$?d.jsxs("div",{className:"empty workspace-loading","data-testid":"workspace-loading",children:[d.jsx("h2",{children:M}),d.jsx("p",{children:"Fetching the indexed graph for this repository."})]}):null,!$&&t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(CN,{review:p,findings:Or,aiNote:pe,busy:!!M,tourIndex:oe,onTour:de,onAskAi:oo,onCopy:hi,onPost:pi,onSelect:Le,onOpenFile:vi,onExport:xi,history:gt,diff:Pt,onReopen:Vn,onWaiver:(R,Y)=>{o.trim()&&Pe.addWaiver(o,R,Y||void 0,"from review").then(fe=>{qt(fe),G(`Waived ${R} in loadpath.yml`)})}}):ui?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Uu,{nodes:p.nodes,edges:p.edges,onWhatIf:$r,focusPath:(Un=p.read_order[oe])==null?void 0:Un.path,...Pn}):null})]}),!$&&t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:v!=null&&v.indexed?d.jsx(MN,{architecture:v,busy:!!M,onReindex:()=>Ar(!1),onReview:an,onSelect:Le,config:sn,health:no,onSaveConfig:R=>{Pe.saveConfig(o,R).then(Y=>{qt(Y),G("Wrote loadpath.yml")})},onWaiver:(R,Y,fe)=>{Pe.addWaiver(o,R,Y,fe).then(Ee=>{qt(Ee),G(`Waived ${R}`)})}}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:v!=null&&v.indexed?d.jsx(Uu,{nodes:v.nodes,edges:v.edges,onWhatIf:$r,...Pn,isolateSource:null,onIsolate:void 0}):null})]}),!$&&t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":N==="review","data-testid":"graph-mode-review",className:N==="review"?"active":"",onClick:()=>j("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":N==="architecture","data-testid":"graph-mode-architecture",className:N==="architecture"?"active":"",onClick:()=>j("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:Xe?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":Xe,onClick:()=>{const R=!Xe;it(R),localStorage.setItem("loadpath.testOverlay",R?"1":"0")},children:"Tests"})]}),Qt.length?d.jsx(Uu,{nodes:Qt,edges:so,onWhatIf:$r,...Pn}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),!$&&t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:C,onChange:R=>Cn(R.target.value,H,B),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:I.length?"Search your repos":"owner/repo",value:H,onChange:R=>Cn(C,R.target.value,B),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:I.map(R=>d.jsxs("option",{value:R.slug,children:[R.private?"private":"public",R.local_path?" · local":""]},R.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!M||!ro(C),onClick:()=>{Bt(C)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!M,onClick:gi,children:"List PRs"})]}),I.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[I.length," ",C," repositor",I.length===1?"y":"ies",C==="github"&&J.github_user?` · @${String(J.github_user)}`:"",C==="gitlab"&&J.gitlab_user?` · @${String(J.gitlab_user)}`:"",C==="bitbucket"&&J.bitbucket_user?` · ${String(J.bitbucket_user)}`:""]}):null,re.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):re.map(R=>{var Y;return d.jsxs("article",{className:"pr","data-testid":`pr-${R.number}`,children:[d.jsxs("h3",{children:["#",R.number," ",R.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${R.draft?"":"open"}`,children:R.draft?"draft":R.state}),d.jsx("span",{children:R.author}),d.jsxs("span",{children:[R.source_branch," → ",R.target_branch]}),R.loadpath?d.jsxs("span",{className:`chip ${R.loadpath.level||""}`,"data-testid":`pr-loadpath-${R.number}`,children:[((Y=R.loadpath.level)==null?void 0:Y.toUpperCase())||"REVIEWED",R.loadpath.contract_break&&R.loadpath.contract_break!=="none"?` · ${R.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:R.url,target:"_blank",rel:"noreferrer",children:["Open on ",R.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${R.number}`,onClick:()=>void zr(R),children:"Review this PR"})]})]},`${R.provider}-${R.number}`)})]}),!$&&t==="settings"&&me&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:lr,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Dl.map(R=>d.jsxs("button",{type:"button","data-theme":R.id,className:Q===R.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${R.id}`,onClick:()=>Tr(R.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:R.label}),d.jsx("div",{className:"group",children:R.group})]},R.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:gm(),onChange:R=>gN(R.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:J.github_token_set?J.github_user?`Signed in as @${String(J.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:J.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void sr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!Nt||!J.github_oauth_ready,onClick:()=>void io(),children:Nt?"Waiting for GitHub…":"Sign in with GitHub"})})]}),Nt?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:Nt.user_code})," at GitHub if the browser did not fill it in."]}):null,J.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(J.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(J.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:J.gitlab_token_set?J.gitlab_user?`Signed in as @${String(J.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:J.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void sr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Ft||!J.gitlab_oauth_ready,onClick:()=>void Ve(),children:Ft?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(J.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(J.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:J.bitbucket_token_set?J.bitbucket_user?`Signed in as ${String(J.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:J.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void sr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:bn||!J.bitbucket_oauth_ready,onClick:()=>void mi(),children:bn?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),J.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(J.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(J.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((De=J.ai)==null?void 0:De.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((lo=J.ai)==null?void 0:lo.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((ao=J.ai)==null?void 0:ao.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(u0,{open:Ne,actions:Wn,onClose:()=>Me(!1)}),ve?d.jsx(SN,{initialPath:o,onClose:()=>ne(!1),onSelect:R=>{if(tt.current){w("Wait for the current job to finish before switching workspace.");return}ne(!1),or(R)}}):null]})}function CN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:x,onOpenFile:v,onExport:m,history:y,diff:_,onReopen:N,onWaiver:j}){var w,M,k,b,A,$,V,X,G,J,Z,re,te,I,W,H,U;const E=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),E.length?d.jsx("ul",{className:"reasons",children:E.map(C=>d.jsx("li",{children:C},C))}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(C=>d.jsx("span",{className:"chip",children:Xo(C)},C)),(w=t.contract_break)!=null&&w.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(C=>C.status==="todo").length})]}),(t.checklist||[]).map(C=>d.jsxs("div",{className:`check-item ${C.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>C.node_id&&x(C.node_id),children:[d.jsx("span",{className:`chip ${C.status}`,children:C.status}),C.title]}),C.detail?d.jsx("div",{className:"why",children:C.detail}):null,C.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(C.body||"")},children:"Copy test"}):null,C.kind==="finding"&&C.status==="todo"&&C.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>j(C.rule,C.node_id),children:"Waive in loadpath.yml"}):null]},C.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(M=t.workspace)!=null&&M.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((C,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",C.path]}),d.jsx("div",{className:"why",children:C.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>v(C.path),children:"Open"})]},C.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(C=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:C.title})," — ",C.files.join(", ")]},C.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(C=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>C.node_id&&x(C.node_id),children:[d.jsx("span",{className:`chip ${C.severity}`,children:C.severity}),C.message]})},C.rule+C.message))]}),d.jsx(xm,{cards:t.deepening}),(b=(k=t.contract_break)==null?void 0:k.reasons)!=null&&b.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(C=>d.jsx("div",{className:"muted",children:C},C)),($=(A=t.contract_break.sides)==null?void 0:A.rows)!=null&&$.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(C=>d.jsxs("tr",{className:C.status,children:[d.jsx("td",{children:C.field}),d.jsx("td",{children:C.serializer?"yes":"—"}),d.jsx("td",{children:C.zod?"yes":"—"}),d.jsx("td",{children:C.graphql?"yes":"—"})]},C.field))})]}):null]}):null,(V=t.auth)!=null&&V.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(C=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),C.name]},C.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(X=t.suggested_tests)==null?void 0:X.length})]}),(t.suggested_tests||[]).map(C=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:C.title}),d.jsx("pre",{className:"headline",children:C.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(C.body)},children:"Copy sketch"})]},C.title))]}):null,(G=t.trend)!=null&&G.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(C=>d.jsxs("div",{className:"muted",children:[C.level," · ",Xu(C.created_at),C.sinks!=null?` · ${C.sinks} sinks`:""]},C.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(C=>d.jsx("div",{className:"residual muted",children:C},C))]}),y.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:y.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,y.slice(0,12).map(C=>d.jsxs("button",{type:"button",className:C.id===t.id?"history-item current":"history-item",onClick:()=>N(C.id),children:[d.jsx("span",{className:`chip ${C.level||""}`,children:C.level||"walk"}),C.title||C.id.slice(0,8),d.jsx("span",{className:"muted",children:C.created_at?Xu(C.created_at):""})]},C.id))]}):null,(Z=(J=t.evolution)==null?void 0:J.notes)!=null&&Z.length||(te=(re=t.evolution)==null?void 0:re.hotspots)!=null&&te.some(C=>C.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((I=t.evolution)==null?void 0:I.notes)||[]).map(C=>d.jsx("div",{className:"muted",children:C},C)),(((W=t.evolution)==null?void 0:W.hotspots)||[]).filter(C=>C.commits).slice(0,6).map(C=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:C.path})," — ",C.commits," commits, bus factor ",C.bus_factor]},C.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:m,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(H=t.codeowners_reviewers)!=null&&H.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function MN({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var v;const x=t.findings.filter(m=>!m.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${Xu(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(m=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:m.name})," — ",(m.django_apps||[]).join(", ")||"no apps"," ·"," ",(m.owners||[]).join(", ")||"unowned"]},m.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(m=>d.jsx("div",{className:"muted",children:m},m))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:x.length})]}),x.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):x.map(m=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>m.node_id&&a(m.node_id),children:[d.jsx("span",{className:`chip ${m.severity}`,children:m.severity}),m.message]})},m.rule+m.message))]}),d.jsx(xm,{cards:t.deepening}),(v=c==null?void 0:c.points)!=null&&v.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(m=>d.jsx("i",{className:m.level||"",title:`${m.level} · ${m.findings} findings`,style:{height:`${8+Math.min(24,(m.findings||0)*4)}px`}},m.id||m.created_at))}),Object.entries(c.contexts).map(([m,y])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:m})," — last ",((_=y[y.length-1])==null?void 0:_.findings)??0," findings"]},m)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(c0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((m,y)=>y[1]-m[1]).slice(0,12).map(([m,y])=>d.jsxs("tr",{children:[d.jsx("td",{children:to(m)}),d.jsx("td",{children:y})]},m))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function xm({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:d0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}vm(ym());s0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(EN,{})}));export{Hk as L,RN as a,PN as c,d as j,IN as l,L as r,to as t}; diff --git a/src/loadpath/static/assets/index-Pc-bL4kN.js b/src/loadpath/static/assets/index-Pc-bL4kN.js new file mode 100644 index 0000000..72bdfce --- /dev/null +++ b/src/loadpath/static/assets/index-Pc-bL4kN.js @@ -0,0 +1,62 @@ +(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function wp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Eu={exports:{}},Ho={},Cu={exports:{}},Re={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Yf;function Zy(){if(Yf)return Re;Yf=1;var t=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),x=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),y=Symbol.iterator;function v(I){return I===null||typeof I!="object"?null:(I=y&&I[y]||I["@@iterator"],typeof I=="function"?I:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,j={};function E(I,$,ie){this.props=I,this.context=$,this.refs=j,this.updater=ie||_}E.prototype.isReactComponent={},E.prototype.setState=function(I,$){if(typeof I!="object"&&typeof I!="function"&&I!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,I,$,"setState")},E.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function w(){}w.prototype=E.prototype;function C(I,$,ie){this.props=I,this.context=$,this.refs=j,this.updater=ie||_}var k=C.prototype=new w;k.constructor=C,N(k,E.prototype),k.isPureReactComponent=!0;var b=Array.isArray,A=Object.prototype.hasOwnProperty,z={current:null},V={key:!0,ref:!0,__self:!0,__source:!0};function Y(I,$,ie){var oe,fe={},he=null,pe=null;if($!=null)for(oe in $.ref!==void 0&&(pe=$.ref),$.key!==void 0&&(he=""+$.key),$)A.call($,oe)&&!V.hasOwnProperty(oe)&&(fe[oe]=$[oe]);var J=arguments.length-2;if(J===1)fe.children=ie;else if(1>>1,$=M[I];if(0>>1;Ia(fe,F))he<$&&0>a(pe,fe)?(M[I]=pe,M[he]=F,I=he):(M[I]=fe,M[oe]=F,I=oe);else if(he<$&&0>a(pe,F))M[I]=pe,M[he]=F,I=he;else break e}}return D}function a(M,D){var F=M.sortIndex-D.sortIndex;return F!==0?F:M.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,h=c.now();t.unstable_now=function(){return c.now()-h}}var p=[],x=[],m=1,y=null,v=3,_=!1,N=!1,j=!1,E=typeof setTimeout=="function"?setTimeout:null,w=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function k(M){for(var D=o(x);D!==null;){if(D.callback===null)s(x);else if(D.startTime<=M)s(x),D.sortIndex=D.expirationTime,r(p,D);else break;D=o(x)}}function b(M){if(j=!1,k(M),!N)if(o(p)!==null)N=!0,H(A);else{var D=o(x);D!==null&&W(b,D.startTime-M)}}function A(M,D){N=!1,j&&(j=!1,w(Y),Y=-1),_=!0;var F=v;try{for(k(D),y=o(p);y!==null&&(!(y.expirationTime>D)||M&&!q());){var I=y.callback;if(typeof I=="function"){y.callback=null,v=y.priorityLevel;var $=I(y.expirationTime<=D);D=t.unstable_now(),typeof $=="function"?y.callback=$:y===o(p)&&s(p),k(D)}else s(p);y=o(p)}if(y!==null)var ie=!0;else{var oe=o(x);oe!==null&&W(b,oe.startTime-D),ie=!1}return ie}finally{y=null,v=F,_=!1}}var z=!1,V=null,Y=-1,K=5,re=-1;function q(){return!(t.unstable_now()-reM||125I?(M.sortIndex=F,r(x,M),o(p)===null&&M===o(x)&&(j?(w(Y),Y=-1):j=!0,W(b,F-I))):(M.sortIndex=$,r(p,M),N||_||(N=!0,H(A))),M},t.unstable_shouldYield=q,t.unstable_wrapCallback=function(M){var D=v;return function(){var F=v;v=D;try{return M.apply(this,arguments)}finally{v=F}}}})(Iu)),Iu}var Zf;function r0(){return Zf||(Zf=1,Pu.exports=n0()),Pu.exports}/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Jf;function i0(){if(Jf)return $t;Jf=1;var t=os(),r=r0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,x=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,m={},y={};function v(e){return p.call(y,e)?!0:p.call(m,e)?!1:x.test(e)?y[e]=!0:(m[e]=!0,!1)}function _(e,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function N(e,n,i,l){if(n===null||typeof n>"u"||_(e,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function j(e,n,i,l,f,g,S){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=f,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=g,this.removeEmptyString=S}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){E[e]=new j(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];E[n]=new j(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){E[e]=new j(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){E[e]=new j(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){E[e]=new j(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){E[e]=new j(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){E[e]=new j(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){E[e]=new j(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){E[e]=new j(e,5,!1,e.toLowerCase(),null,!1,!1)});var w=/[\-:]([a-z])/g;function C(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(w,C);E[n]=new j(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(w,C);E[n]=new j(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(w,C);E[n]=new j(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){E[e]=new j(e,1,!1,e.toLowerCase(),null,!1,!1)}),E.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){E[e]=new j(e,1,!1,e.toLowerCase(),null,!0,!0)});function k(e,n,i,l){var f=E.hasOwnProperty(n)?E[n]:null;(f!==null?f.type!==0:l||!(2T||f[S]!==g[T]){var O=` +`+f[S].replace(" at new "," at ");return e.displayName&&O.includes("")&&(O=O.replace("",e.displayName)),O}while(1<=S&&0<=T);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?$(e):""}function fe(e){switch(e.tag){case 5:return $(e.type);case 16:return $("Lazy");case 13:return $("Suspense");case 19:return $("SuspenseList");case 0:case 2:case 15:return e=oe(e.type,!1),e;case 11:return e=oe(e.type.render,!1),e;case 1:return e=oe(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case V:return"Fragment";case z:return"Portal";case K:return"Profiler";case Y:return"StrictMode";case te:return"Suspense";case R:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case q:return(e.displayName||"Context")+".Consumer";case re:return(e._context.displayName||"Context")+".Provider";case Z:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case U:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case H:n=e._payload,e=e._init;try{return he(e(n))}catch{}}return null}function pe(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===Y?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function J(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ae(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=ae(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function Ne(e){e._valueTracker||(e._valueTracker=me(e))}function xe(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=ae(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function ne(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function je(e,n){var i=n.checked;return F({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=J(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Te(e,n){n=n.checked,n!=null&&k(e,"checked",n,!1)}function De(e,n){Te(e,n);var i=J(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?Je(e,n.type,i):n.hasOwnProperty("defaultValue")&&Je(e,n.type,J(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function ht(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function Je(e,n,i){(n!=="number"||ne(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var Xe=Array.isArray;function lt(e,n,i,l){if(e=e.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=xt.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function rn(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var on={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},no=["Webkit","ms","Moz","O"];Object.keys(on).forEach(function(e){no.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),on[n]=on[e]})});function Dn(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||on.hasOwnProperty(e)&&on[e]?(""+n).trim():n+"px"}function di(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=Dn(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,f):e[i]=f}}var Ir=F({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Rr(e,n){if(n){if(Ir[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function nr(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var rr=null;function wn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Nt=null,Ot=null,Ft=null;function _n(e){if(e=bo(e)){if(typeof Nt!="function")throw Error(o(280));var n=e.stateNode;n&&(n=bs(n),Nt(e.stateNode,e.type,n))}}function On(e){Ot?Ft?Ft.push(e):Ft=[e]:Ot=e}function Sn(){if(Ot){var e=Ot,n=Ft;if(Ft=Ot=null,_n(e),n)for(e=0;e>>=0,e===0?32:31-(gi(e)/mi|0)|0}var En=64,Hn=4194304;function Cn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Kt(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,f=e.suspendedLanes,g=e.pingedLanes,S=i&268435455;if(S!==0){var T=S&~f;T!==0?l=Cn(T):(g&=S,g!==0&&(l=Cn(g)))}else S=i&~f,S!==0?l=Cn(S):g!==0&&(l=Cn(g));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,g=n&-n,f>=g||f===16&&(g&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function Vn(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-pt(n),e[n]=i}function wi(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=yo),Oc=" ",Fc=!1;function Hc(e,n){switch(e){case"keyup":return Ym.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Bc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ni=!1;function qm(e,n){switch(e){case"compositionend":return Bc(n);case"keypress":return n.which!==32?null:(Fc=!0,Oc);case"textInput":return e=n.data,e===Oc&&Fc?null:e;default:return null}}function Km(e,n){if(Ni)return e==="compositionend"||!la&&Hc(e,n)?(e=Tc(),gs=ta=cr=null,Ni=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=qc(i)}}function Qc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Qc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Zc(){for(var e=window,n=ne();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=ne(e.document)}return n}function ca(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function oy(e){var n=Zc(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Qc(i.ownerDocument.documentElement,i)){if(l!==null&&ca(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var f=i.textContent.length,g=Math.min(l.start,f);l=l.end===void 0?g:Math.min(l.end,f),!e.extend&&g>l&&(f=l,l=g,g=f),f=Kc(i,g);var S=Kc(i,l);f&&S&&(e.rangeCount!==1||e.anchorNode!==f.node||e.anchorOffset!==f.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),e.removeAllRanges(),g>l?(e.addRange(n),e.extend(S.node,S.offset)):(n.setEnd(S.node,S.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,ji=null,da=null,_o=null,fa=!1;function Jc(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;fa||ji==null||ji!==ne(l)||(l=ji,"selectionStart"in l&&ca(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),_o&&wo(_o,l)||(_o=l,l=ks(da,"onSelect"),0Pi||(e.current=Na[Pi],Na[Pi]=null,Pi--)}function Be(e,n){Pi++,Na[Pi]=e.current,e.current=n}var pr={},wt=hr(pr),It=hr(!1),Wr=pr;function Ii(e,n){var i=e.type.contextTypes;if(!i)return pr;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in i)f[g]=n[g];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=f),f}function Rt(e){return e=e.childContextTypes,e!=null}function Es(){Ue(It),Ue(wt)}function pd(e,n,i){if(wt.current!==pr)throw Error(o(168));Be(wt,n),Be(It,i)}function gd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,pe(e)||"Unknown",f));return F({},i,l)}function Cs(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||pr,Wr=wt.current,Be(wt,e),Be(It,It.current),!0}function md(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=gd(e,n,Wr),l.__reactInternalMemoizedMergedChildContext=e,Ue(It),Ue(wt),Be(wt,e)):Ue(It),Be(It,i)}var Gn=null,Ms=!1,ja=!1;function yd(e){Gn===null?Gn=[e]:Gn.push(e)}function yy(e){Ms=!0,yd(e)}function gr(){if(!ja&&Gn!==null){ja=!0;var e=0,n=Oe;try{var i=Gn;for(Oe=1;e>=S,f-=S,Yn=1<<32-pt(n)+f|i<Ce?(ft=Ee,Ee=null):ft=Ee.sibling;var Fe=se(X,Ee,Q[Ce],de);if(Fe===null){Ee===null&&(Ee=ft);break}e&&Ee&&Fe.alternate===null&&n(X,Ee),B=g(Fe,B,Ce),be===null?_e=Fe:be.sibling=Fe,be=Fe,Ee=ft}if(Ce===Q.length)return i(X,Ee),Ye&&Gr(X,Ce),_e;if(Ee===null){for(;CeCe?(ft=Ee,Ee=null):ft=Ee.sibling;var Nr=se(X,Ee,Fe.value,de);if(Nr===null){Ee===null&&(Ee=ft);break}e&&Ee&&Nr.alternate===null&&n(X,Ee),B=g(Nr,B,Ce),be===null?_e=Nr:be.sibling=Nr,be=Nr,Ee=ft}if(Fe.done)return i(X,Ee),Ye&&Gr(X,Ce),_e;if(Ee===null){for(;!Fe.done;Ce++,Fe=Q.next())Fe=ue(X,Fe.value,de),Fe!==null&&(B=g(Fe,B,Ce),be===null?_e=Fe:be.sibling=Fe,be=Fe);return Ye&&Gr(X,Ce),_e}for(Ee=l(X,Ee);!Fe.done;Ce++,Fe=Q.next())Fe=ge(Ee,X,Ce,Fe.value,de),Fe!==null&&(e&&Fe.alternate!==null&&Ee.delete(Fe.key===null?Ce:Fe.key),B=g(Fe,B,Ce),be===null?_e=Fe:be.sibling=Fe,be=Fe);return e&&Ee.forEach(function(Qy){return n(X,Qy)}),Ye&&Gr(X,Ce),_e}function tt(X,B,Q,de){if(typeof Q=="object"&&Q!==null&&Q.type===V&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case A:e:{for(var _e=Q.key,be=B;be!==null;){if(be.key===_e){if(_e=Q.type,_e===V){if(be.tag===7){i(X,be.sibling),B=f(be,Q.props.children),B.return=X,X=B;break e}}else if(be.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===H&&kd(_e)===be.type){i(X,be.sibling),B=f(be,Q.props),B.ref=Eo(X,be,Q),B.return=X,X=B;break e}i(X,be);break}else n(X,be);be=be.sibling}Q.type===V?(B=ei(Q.props.children,X.mode,de,Q.key),B.return=X,X=B):(de=rl(Q.type,Q.key,Q.props,null,X.mode,de),de.ref=Eo(X,B,Q),de.return=X,X=de)}return S(X);case z:e:{for(be=Q.key;B!==null;){if(B.key===be)if(B.tag===4&&B.stateNode.containerInfo===Q.containerInfo&&B.stateNode.implementation===Q.implementation){i(X,B.sibling),B=f(B,Q.children||[]),B.return=X,X=B;break e}else{i(X,B);break}else n(X,B);B=B.sibling}B=Su(Q,X.mode,de),B.return=X,X=B}return S(X);case H:return be=Q._init,tt(X,B,be(Q._payload),de)}if(Xe(Q))return ve(X,B,Q,de);if(D(Q))return we(X,B,Q,de);Ts(X,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"?(Q=""+Q,B!==null&&B.tag===6?(i(X,B.sibling),B=f(B,Q),B.return=X,X=B):(i(X,B),B=_u(Q,X.mode,de),B.return=X,X=B),S(X)):i(X,B)}return tt}var Ai=Nd(!0),jd=Nd(!1),Ls=hr(null),As=null,$i=null,Ia=null;function Ra(){Ia=$i=As=null}function Ta(e){var n=Ls.current;Ue(Ls),e._currentValue=n}function La(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function zi(e,n){As=e,Ia=$i=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Tt=!0),e.firstContext=null)}function Jt(e){var n=e._currentValue;if(Ia!==e)if(e={context:e,memoizedValue:n,next:null},$i===null){if(As===null)throw Error(o(308));$i=e,As.dependencies={lanes:0,firstContext:e}}else $i=$i.next=e;return n}var Yr=null;function Aa(e){Yr===null?Yr=[e]:Yr.push(e)}function bd(e,n,i,l){var f=n.interleaved;return f===null?(i.next=i,Aa(n)):(i.next=f.next,f.next=i),n.interleaved=i,qn(e,l)}function qn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var mr=!1;function $a(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ed(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Kn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function yr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,($e&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,qn(e,i)}return f=l.interleaved,f===null?(n.next=n,Aa(l)):(n.next=f.next,f.next=n),l.interleaved=n,qn(e,i)}function $s(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,Wn(e,i)}}function Cd(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var S={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?f=g=S:g=g.next=S,i=i.next}while(i!==null);g===null?f=g=n:g=g.next=n}else f=g=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function zs(e,n,i,l){var f=e.updateQueue;mr=!1;var g=f.firstBaseUpdate,S=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,ee=O.next;O.next=null,S===null?g=ee:S.next=ee,S=O;var le=e.alternate;le!==null&&(le=le.updateQueue,T=le.lastBaseUpdate,T!==S&&(T===null?le.firstBaseUpdate=ee:T.next=ee,le.lastBaseUpdate=O))}if(g!==null){var ue=f.baseState;S=0,le=ee=O=null,T=g;do{var se=T.lane,ge=T.eventTime;if((l&se)===se){le!==null&&(le=le.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var ve=e,we=T;switch(se=n,ge=i,we.tag){case 1:if(ve=we.payload,typeof ve=="function"){ue=ve.call(ge,ue,se);break e}ue=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=we.payload,se=typeof ve=="function"?ve.call(ge,ue,se):ve,se==null)break e;ue=F({},ue,se);break e;case 2:mr=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,se=f.effects,se===null?f.effects=[T]:se.push(T))}else ge={eventTime:ge,lane:se,tag:T.tag,payload:T.payload,callback:T.callback,next:null},le===null?(ee=le=ge,O=ue):le=le.next=ge,S|=se;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;se=T,T=se.next,se.next=null,f.lastBaseUpdate=se,f.shared.pending=null}}while(!0);if(le===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=ee,f.lastBaseUpdate=le,n=f.shared.interleaved,n!==null){f=n;do S|=f.lane,f=f.next;while(f!==n)}else g===null&&(f.shared.lanes=0);Kr|=S,e.lanes=S,e.memoizedState=ue}}function Md(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=Ha.transition;Ha.transition={};try{e(!1),n()}finally{Oe=i,Ha.transition=l}}function Xd(){return en().memoizedState}function _y(e,n,i){var l=_r(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},qd(e))Kd(n,i);else if(i=bd(e,n,i,l),i!==null){var f=Ct();fn(i,e,l,f),Qd(i,n,l)}}function Sy(e,n,i){var l=_r(e),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(qd(e))Kd(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,T=g(S,i);if(f.hasEagerState=!0,f.eagerState=T,ln(T,S)){var O=n.interleaved;O===null?(f.next=f,Aa(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=bd(e,n,f,l),i!==null&&(f=Ct(),fn(i,e,l,f),Qd(i,n,l))}}function qd(e){var n=e.alternate;return e===Ke||n!==null&&n===Ke}function Kd(e,n){Io=Fs=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Qd(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,Wn(e,i)}}var Vs={readContext:Jt,useCallback:_t,useContext:_t,useEffect:_t,useImperativeHandle:_t,useInsertionEffect:_t,useLayoutEffect:_t,useMemo:_t,useReducer:_t,useRef:_t,useState:_t,useDebugValue:_t,useDeferredValue:_t,useTransition:_t,useMutableSource:_t,useSyncExternalStore:_t,useId:_t,unstable_isNewReconciler:!1},ky={readContext:Jt,useCallback:function(e,n){return Rn().memoizedState=[e,n===void 0?null:n],e},useContext:Jt,useEffect:Fd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Hs(4194308,4,Vd.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Hs(4194308,4,e,n)},useInsertionEffect:function(e,n){return Hs(4,2,e,n)},useMemo:function(e,n){var i=Rn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=Rn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=_y.bind(null,Ke,e),[l.memoizedState,e]},useRef:function(e){var n=Rn();return e={current:e},n.memoizedState=e},useState:Dd,useDebugValue:Xa,useDeferredValue:function(e){return Rn().memoizedState=e},useTransition:function(){var e=Dd(!1),n=e[0];return e=wy.bind(null,e[1]),Rn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=Ke,f=Rn();if(Ye){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),dt===null)throw Error(o(349));(qr&30)!==0||Td(l,n,i)}f.memoizedState=i;var g={value:i,getSnapshot:n};return f.queue=g,Fd(Ad.bind(null,l,g,e),[e]),l.flags|=2048,Lo(9,Ld.bind(null,l,g,i,n),void 0,null),i},useId:function(){var e=Rn(),n=dt.identifierPrefix;if(Ye){var i=Xn,l=Yn;i=(l&~(1<<32-pt(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=Ro++,0<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=S.createElement(i,{is:l.is}):(e=S.createElement(i),i==="select"&&(S=e,l.multiple?S.multiple=!0:l.size&&(S.size=l.size))):e=S.createElementNS(e,i),e[Pn]=n,e[jo]=l,vf(e,n,!1,!1),n.stateNode=e;e:{switch(S=nr(i,l),i){case"dialog":We("cancel",e),We("close",e),f=l;break;case"iframe":case"object":case"embed":We("load",e),f=l;break;case"video":case"audio":for(f=0;fBi&&(n.flags|=128,l=!0,Ao(g,!1),n.lanes=4194304)}else{if(!l)if(e=Ds(S),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Ao(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Ye)return St(n),null}else 2*Ve()-g.renderingStartTime>Bi&&i!==1073741824&&(n.flags|=128,l=!0,Ao(g,!1),n.lanes=4194304);g.isBackwards?(S.sibling=n.child,n.child=S):(i=g.last,i!==null?i.sibling=S:n.child=S,g.last=S)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(St(n),null);case 22:case 23:return vu(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Gt&1073741824)!==0&&(St(n),n.subtreeFlags&6&&(n.flags|=8192)):St(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function Iy(e,n){switch(Ea(n),n.tag){case 1:return Rt(n.type)&&Es(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Di(),Ue(It),Ue(wt),Fa(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Da(n),null;case 13:if(Ue(qe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));Li()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Di(),null;case 10:return Ta(n.type._context),null;case 22:case 23:return vu(),null;case 24:return null;default:return null}}var Ys=!1,kt=!1,Ry=typeof WeakSet=="function"?WeakSet:Set,ye=null;function Fi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Ze(e,n,l)}else i.current=null}function su(e,n,i){try{i()}catch(l){Ze(e,n,l)}}var _f=!1;function Ty(e,n){if(va=hs,e=Zc(),ca(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,g=l.focusNode;l=l.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var S=0,T=-1,O=-1,ee=0,le=0,ue=e,se=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=S+f),ue!==g||l!==0&&ue.nodeType!==3||(O=S+l),ue.nodeType===3&&(S+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)se=ue,ue=ge;for(;;){if(ue===e)break t;if(se===i&&++ee===f&&(T=S),se===g&&++le===l&&(O=S),(ge=ue.nextSibling)!==null)break;ue=se,se=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(xa={focusedElem:e,selectionRange:i},hs=!1,ye=n;ye!==null;)if(n=ye,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ye=e;else for(;ye!==null;){n=ye;try{var ve=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(ve!==null){var we=ve.memoizedProps,tt=ve.memoizedState,X=n.stateNode,B=X.getSnapshotBeforeUpdate(n.elementType===n.type?we:un(n.type,we),tt);X.__reactInternalSnapshotBeforeUpdate=B}break;case 3:var Q=n.stateNode.containerInfo;Q.nodeType===1?Q.textContent="":Q.nodeType===9&&Q.documentElement&&Q.removeChild(Q.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(de){Ze(n,n.return,de)}if(e=n.sibling,e!==null){e.return=n.return,ye=e;break}ye=n.return}return ve=_f,_f=!1,ve}function $o(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&e)===e){var g=f.destroy;f.destroy=void 0,g!==void 0&&su(n,i,g)}f=f.next}while(f!==l)}}function Xs(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function lu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function Sf(e){var n=e.alternate;n!==null&&(e.alternate=null,Sf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[Pn],delete n[jo],delete n[ka],delete n[gy],delete n[my])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function kf(e){return e.tag===5||e.tag===3||e.tag===4}function Nf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||kf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function au(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=js));else if(l!==4&&(e=e.child,e!==null))for(au(e,n,i),e=e.sibling;e!==null;)au(e,n,i),e=e.sibling}function uu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(uu(e,n,i),e=e.sibling;e!==null;)uu(e,n,i),e=e.sibling}var gt=null,cn=!1;function vr(e,n,i){for(i=i.child;i!==null;)jf(e,n,i),i=i.sibling}function jf(e,n,i){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(lr,i)}catch{}switch(i.tag){case 5:kt||Fi(i,n);case 6:var l=gt,f=cn;gt=null,vr(e,n,i),gt=l,cn=f,gt!==null&&(cn?(e=gt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):gt.removeChild(i.stateNode));break;case 18:gt!==null&&(cn?(e=gt,i=i.stateNode,e.nodeType===8?Sa(e.parentNode,i):e.nodeType===1&&Sa(e,i),po(e)):Sa(gt,i.stateNode));break;case 4:l=gt,f=cn,gt=i.stateNode.containerInfo,cn=!0,vr(e,n,i),gt=l,cn=f;break;case 0:case 11:case 14:case 15:if(!kt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var g=f,S=g.destroy;g=g.tag,S!==void 0&&((g&2)!==0||(g&4)!==0)&&su(i,n,S),f=f.next}while(f!==l)}vr(e,n,i);break;case 1:if(!kt&&(Fi(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Ze(i,n,T)}vr(e,n,i);break;case 21:vr(e,n,i);break;case 22:i.mode&1?(kt=(l=kt)||i.memoizedState!==null,vr(e,n,i),kt=l):vr(e,n,i);break;default:vr(e,n,i)}}function bf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Ry),n.forEach(function(l){var f=By.bind(null,e,l);i.has(l)||(i.add(l),l.then(f,f))})}}function dn(e,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=S),l&=~g}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Ay(l/1960))-l,10e?16:e,wr===null)var l=!1;else{if(e=wr,wr=null,Js=0,($e&6)!==0)throw Error(o(331));var f=$e;for($e|=4,ye=e.current;ye!==null;){var g=ye,S=g.child;if((ye.flags&16)!==0){var T=g.deletions;if(T!==null){for(var O=0;OVe()-fu?Zr(e,0):du|=i),At(e,n)}function Of(e,n){n===0&&((e.mode&1)===0?n=1:(n=Hn,Hn<<=1,(Hn&130023424)===0&&(Hn=4194304)));var i=Ct();e=qn(e,n),e!==null&&(Vn(e,n,i),At(e,i))}function Hy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Of(e,i)}function By(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Of(e,i)}var Ff;Ff=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||It.current)Tt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Tt=!1,My(e,n,i);Tt=(e.flags&131072)!==0}else Tt=!1,Ye&&(n.flags&1048576)!==0&&vd(n,Is,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Gs(e,n),e=n.pendingProps;var f=Ii(n,wt.current);zi(n,i),f=Va(null,n,l,e,f,i);var g=Wa();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Rt(l)?(g=!0,Cs(n)):g=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,$a(n),f.updater=Ws,n.stateNode=f,f._reactInternals=n,Ka(n,l,e,i),n=eu(null,n,l,!0,g,i)):(n.tag=0,Ye&&g&&ba(n),Et(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Gs(e,n),e=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=Wy(l),e=un(l,e),f){case 0:n=Ja(null,n,l,e,i);break e;case 1:n=ff(null,n,l,e,i);break e;case 11:n=lf(null,n,l,e,i);break e;case 14:n=af(null,n,l,un(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:un(l,f),Ja(e,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:un(l,f),ff(e,n,l,f,i);case 3:e:{if(hf(n),e===null)throw Error(o(387));l=n.pendingProps,g=n.memoizedState,f=g.element,Ed(e,n),zs(n,l,null,i);var S=n.memoizedState;if(l=S.element,g.isDehydrated)if(g={element:l,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){f=Oi(Error(o(423)),n),n=pf(e,n,l,i,f);break e}else if(l!==f){f=Oi(Error(o(424)),n),n=pf(e,n,l,i,f);break e}else for(Ut=fr(n.stateNode.containerInfo.firstChild),Wt=n,Ye=!0,an=null,i=jd(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Li(),l===f){n=Qn(e,n,i);break e}Et(e,n,l,i)}n=n.child}return n;case 5:return Pd(n),e===null&&Ma(n),l=n.type,f=n.pendingProps,g=e!==null?e.memoizedProps:null,S=f.children,wa(l,f)?S=null:g!==null&&wa(l,g)&&(n.flags|=32),df(e,n),Et(e,n,S,i),n.child;case 6:return e===null&&Ma(n),null;case 13:return gf(e,n,i);case 4:return za(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=Ai(n,null,l,i):Et(e,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:un(l,f),lf(e,n,l,f,i);case 7:return Et(e,n,n.pendingProps,i),n.child;case 8:return Et(e,n,n.pendingProps.children,i),n.child;case 12:return Et(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,g=n.memoizedProps,S=f.value,Be(Ls,l._currentValue),l._currentValue=S,g!==null)if(ln(g.value,S)){if(g.children===f.children&&!It.current){n=Qn(e,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var T=g.dependencies;if(T!==null){S=g.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(g.tag===1){O=Kn(-1,i&-i),O.tag=2;var ee=g.updateQueue;if(ee!==null){ee=ee.shared;var le=ee.pending;le===null?O.next=O:(O.next=le.next,le.next=O),ee.pending=O}}g.lanes|=i,O=g.alternate,O!==null&&(O.lanes|=i),La(g.return,i,n),T.lanes|=i;break}O=O.next}}else if(g.tag===10)S=g.type===n.type?null:g.child;else if(g.tag===18){if(S=g.return,S===null)throw Error(o(341));S.lanes|=i,T=S.alternate,T!==null&&(T.lanes|=i),La(S,i,n),S=g.sibling}else S=g.child;if(S!==null)S.return=g;else for(S=g;S!==null;){if(S===n){S=null;break}if(g=S.sibling,g!==null){g.return=S.return,S=g;break}S=S.return}g=S}Et(e,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,zi(n,i),f=Jt(f),l=l(f),n.flags|=1,Et(e,n,l,i),n.child;case 14:return l=n.type,f=un(l,n.pendingProps),f=un(l.type,f),af(e,n,l,f,i);case 15:return uf(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:un(l,f),Gs(e,n),n.tag=1,Rt(l)?(e=!0,Cs(n)):e=!1,zi(n,i),Jd(n,l,f),Ka(n,l,f,i),eu(null,n,l,!0,e,i);case 19:return yf(e,n,i);case 22:return cf(e,n,i)}throw Error(o(156,n.tag))};function Hf(e,n){return or(e,n)}function Vy(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function nn(e,n,i,l){return new Vy(e,n,i,l)}function wu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Wy(e){if(typeof e=="function")return wu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Z)return 11;if(e===U)return 14}return 2}function kr(e,n){var i=e.alternate;return i===null?(i=nn(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function rl(e,n,i,l,f,g){var S=2;if(l=e,typeof e=="function")wu(e)&&(S=1);else if(typeof e=="string")S=5;else e:switch(e){case V:return ei(i.children,f,g,n);case Y:S=8,f|=8;break;case K:return e=nn(12,i,n,f|2),e.elementType=K,e.lanes=g,e;case te:return e=nn(13,i,n,f),e.elementType=te,e.lanes=g,e;case R:return e=nn(19,i,n,f),e.elementType=R,e.lanes=g,e;case W:return il(i,f,g,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case re:S=10;break e;case q:S=9;break e;case Z:S=11;break e;case U:S=14;break e;case H:S=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=nn(S,i,n,f),n.elementType=e,n.type=l,n.lanes=g,n}function ei(e,n,i,l){return e=nn(7,e,l,n),e.lanes=i,e}function il(e,n,i,l){return e=nn(22,e,l,n),e.elementType=W,e.lanes=i,e.stateNode={isHidden:!1},e}function _u(e,n,i){return e=nn(6,e,null,n),e.lanes=i,e}function Su(e,n,i){return n=nn(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Uy(e,n,i,l,f){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Bn(0),this.expirationTimes=Bn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Bn(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function ku(e,n,i,l,f,g,S,T,O){return e=new Uy(e,n,i,T,O),n===1?(n=1,g===!0&&(n|=8)):n=0,g=nn(3,null,null,n),e.current=g,g.stateNode=e,g.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},$a(g),e}function Gy(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),Mu.exports=i0(),Mu.exports}var th;function o0(){if(th)return dl;th=1;var t=_p();return dl.createRoot=t.createRoot,dl.hydrateRoot=t.hydrateRoot,dl}var s0=o0();function Sp(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Le(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(Sp(s,o.statusText||"Request failed"))}return o.json()}const l0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Pe={health:()=>Le("/api/health"),settings:()=>Le("/api/settings"),saveSettings:t=>{const r={...t};for(const o of l0)r[o]===""&&delete r[o];return Le("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Le("/api/repos"),browse:t=>Le(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Le(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Le("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Le(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Le(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:(t,r=!0)=>Le(`/api/architecture?repo_path=${encodeURIComponent(t)}&graph=${r?"1":"0"}`),architectureGraph:t=>Le(`/api/architecture/graph?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Le("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Le("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Le("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Le("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Le("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Le(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open",s)=>Le("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o,repo_path:s||null})}),scmRepos:t=>Le(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Le("/api/oauth/status"),githubOAuthStart:()=>Le("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Le("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Le("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Le("/api/oauth/gitlab/start"),oauthDisconnect:t=>Le("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Le("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})}),reviews:t=>Le(`/api/reviews?repo_path=${encodeURIComponent(t)}`),getReview:(t,r)=>Le(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(t)}`),reviewDiff:(t,r,o)=>Le(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(t)}&other=${encodeURIComponent(o)}`),config:t=>Le(`/api/config?repo_path=${encodeURIComponent(t)}`),saveConfig:(t,r)=>Le("/api/config",{method:"PUT",body:JSON.stringify({repo_path:t,...r})}),addWaiver:(t,r,o,s)=>Le("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:t,rule:r,node:o||null,reason:s||""})}),marks:(t,r)=>Le(`/api/marks?repo_path=${encodeURIComponent(t)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:t=>Le(`/api/architecture/health?repo_path=${encodeURIComponent(t)}`),workspaceStatus:t=>Le(`/api/workspace/status?repo_path=${encodeURIComponent(t)}`),openEditor:(t,r,o,s)=>Le("/api/open",{method:"POST",body:JSON.stringify({repo_path:t,path:r,line:o||null,editor:s||null})}),exportHtml:t=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:t})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(Sp(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(t,r,o,s)=>Le("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:t,edges:r,source_id:o,target_id:s||null})})};function a0(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):t}function u0({open:t,actions:r,onClose:o}){const[s,a]=L.useState(""),[u,c]=L.useState(0),h=L.useRef(null),p=L.useMemo(()=>a0(r,s),[r,s]);if(L.useEffect(()=>{if(!t)return;a(""),c(0);const y=window.setTimeout(()=>{var v;return(v=h.current)==null?void 0:v.focus()},0);return()=>window.clearTimeout(y)},[t]),L.useEffect(()=>{c(0)},[s]),!t)return null;const x=p[u],m=y=>{y&&(o(),y.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:y=>{y.target===y.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:y=>a(y.target.value),onKeyDown:y=>{y.key==="Escape"?(y.preventDefault(),o()):y.key==="ArrowDown"?(y.preventDefault(),c(v=>Math.min(p.length-1,v+1))):y.key==="ArrowUp"?(y.preventDefault(),c(v=>Math.max(0,v-1))):y.key==="Enter"&&(y.preventDefault(),m(x))}}),d.jsxs("ul",{children:[p.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,p.slice(0,40).map((y,v)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:v===u?"active":"",onMouseEnter:()=>c(v),onClick:()=>m(y),children:[d.jsx("span",{children:y.label}),y.hint?d.jsx("span",{className:"muted",children:y.hint}):null]})},y.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function c0({config:t,busy:r,onSave:o,onWaiver:s}){const[a,u]=L.useState(t),[c,h]=L.useState(t.available_rules[0]||""),[p,x]=L.useState(""),[m,y]=L.useState("");L.useEffect(()=>{u(t)},[t]);const v=Object.entries(a.contexts||{}),_=(C,k,b)=>{const A=a.contexts[C];if(!A)return;const z=V=>V.split(",").map(Y=>Y.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[C]:{...A,[k]:k==="name"?b:z(b)}}})},N=(C,k)=>{const b=k.trim();if(!b||b===C)return;const{[C]:A,...z}=a.contexts;A&&u({...a,contexts:{...z,[b]:{...A,name:b}}})},j=()=>{let C=1;for(;a.contexts[`context-${C}`];)C+=1;const k=`context-${C}`;u({...a,contexts:{...a.contexts,[k]:{name:k,django_apps:[],react:[],public_api:[],owners:[]}}})},E=C=>{const{[C]:k,...b}=a.contexts;u({...a,contexts:b})},w=C=>{const k=a.rules.includes(C);u({...a,rules:k?a.rules.filter(b=>b!==C):[...a.rules,C]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),v.map(([C,k])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:C})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:C,"data-testid":`config-context-name-${C}`,onBlur:b=>N(C,b.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(k.django_apps||[]).join(", "),onChange:b=>_(C,"django_apps",b.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(k.react||[]).join(", "),onChange:b=>_(C,"react",b.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(k.public_api||[]).join(", "),onChange:b=>_(C,"public_api",b.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(k.owners||[]).join(", "),onChange:b=>_(C,"owners",b.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>E(C),children:"Remove context"})]},C)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:j,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(C=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(C),onChange:()=>w(C)}),C]},C))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((C,k)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:C.rule}),C.node?` · ${C.node}`:"",C.reason?` — ${C.reason}`:""]},`${C.rule}:${C.node}:${k}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:C=>h(C.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(C=>d.jsx("option",{value:C,children:C},C))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:C=>x(C.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:m,onChange:C=>y(C.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,m),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function Xo(t){return t.replaceAll("_"," ")}function d0(t){return t.replaceAll("_"," ")}function to(t){return t.split(".").pop()||t}function Xu(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function f0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Cr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function ci({className:t,children:r}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function h0({className:t}){return d.jsxs(ci,{className:t,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function p0({className:t}){return d.jsxs(ci,{className:t,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function g0({className:t}){return d.jsxs(ci,{className:t,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function m0({className:t}){return d.jsxs(ci,{className:t,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function y0({className:t}){return d.jsxs(ci,{className:t,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function kp({className:t}){return d.jsx(ci,{className:t,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function v0({className:t}){return d.jsx(ci,{className:t,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const x0="modulepreload",w0=function(t,r){return new URL(t,r).href},nh={},_0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(m){return Promise.all(m.map(y=>Promise.resolve(y).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),x=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(m=>{if(m=w0(m,s),m in nh)return;nh[m]=!0;const y=m.endsWith(".css"),v=y?'[rel="stylesheet"]':"";if(!!s)for(let j=h.length-1;j>=0;j--){const E=h[j];if(E.href===m&&(!y||E.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${m}"]${v}`))return;const N=document.createElement("link");if(N.rel=y?"stylesheet":x0,y||(N.as="script"),N.crossOrigin="",N.href=m,x&&N.setAttribute("nonce",x),document.head.appendChild(N),y)return new Promise((j,E)=>{N.addEventListener("load",j),N.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${m}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function it(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Ol(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}kl.prototype=Ol.prototype={constructor:kl,on:function(t,r){var o=this._,s=k0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),ih.hasOwnProperty(r)?{space:ih[r],local:t}:t}function j0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===qu&&r.documentElement.namespaceURI===qu?r.createElement(t):r.createElementNS(o,t)}}function b0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Np(t){var r=Fl(t);return(r.local?b0:j0)(r)}function E0(){}function dc(t){return t==null?E0:function(){return this.querySelector(t)}}function C0(t){typeof t!="function"&&(t=dc(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=k&&(k=C+1);!(A=E[k])&&++k=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function J0(t){t||(t=ev);function r(y,v){return y&&v?t(y.__data__,v.__data__):!y-!v}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function tv(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function nv(){return Array.from(this)}function rv(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?pv:typeof r=="function"?mv:gv)(t,r,o??"")):Xi(this.node(),t)}function Xi(t,r){return t.style.getPropertyValue(r)||Mp(t).getComputedStyle(t,null).getPropertyValue(r)}function vv(t){return function(){delete this[t]}}function xv(t,r){return function(){this[t]=r}}function wv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function _v(t,r){return arguments.length>1?this.each((r==null?vv:typeof r=="function"?wv:xv)(t,r)):this.node()[t]}function Pp(t){return t.trim().split(/^|\s+/)}function fc(t){return t.classList||new Ip(t)}function Ip(t){this._node=t,this._names=Pp(t.getAttribute("class")||"")}Ip.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Rp(t,r){for(var o=fc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function qv(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function Ku(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:x,dispatch:m}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:x,enumerable:!0,configurable:!0},_:{value:m}})}Ku.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function ox(t){return!t.ctrlKey&&!t.button}function sx(){return this.parentNode}function lx(t,r){return r??{x:t.x,y:t.y}}function ax(){return navigator.maxTouchPoints||"ontouchstart"in this}function Dp(){var t=ox,r=sx,o=lx,s=ax,a={},u=Ol("start","drag","end"),c=0,h,p,x,m,y=0;function v(b){b.on("mousedown.drag",_).filter(s).on("touchstart.drag",E).on("touchmove.drag",w,ix).on("touchend.drag touchcancel.drag",C).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(b,A){if(!(m||!t.call(this,b,A))){var z=k(this,r.call(this,b,A),b,A,"mouse");z&&(Yt(b.view).on("mousemove.drag",N,qo).on("mouseup.drag",j,qo),$p(b.view),Ru(b),x=!1,h=b.clientX,p=b.clientY,z("start",b))}}function N(b){if(Gi(b),!x){var A=b.clientX-h,z=b.clientY-p;x=A*A+z*z>y}a.mouse("drag",b)}function j(b){Yt(b.view).on("mousemove.drag mouseup.drag",null),zp(b.view,x),Gi(b),a.mouse("end",b)}function E(b,A){if(t.call(this,b,A)){var z=b.changedTouches,V=r.call(this,b,A),Y=z.length,K,re;for(K=0;K>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?hl(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?hl(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=cx.exec(t))?new zt(r[1],r[2],r[3],1):(r=dx.exec(t))?new zt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=fx.exec(t))?hl(r[1],r[2],r[3],r[4]):(r=hx.exec(t))?hl(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=px.exec(t))?dh(r[1],r[2]/100,r[3]/100,1):(r=gx.exec(t))?dh(r[1],r[2]/100,r[3]/100,r[4]):oh.hasOwnProperty(t)?ah(oh[t]):t==="transparent"?new zt(NaN,NaN,NaN,0):null}function ah(t){return new zt(t>>16&255,t>>8&255,t&255,1)}function hl(t,r,o,s){return s<=0&&(t=r=o=NaN),new zt(t,r,o,s)}function vx(t){return t instanceof ls||(t=oi(t)),t?(t=t.rgb(),new zt(t.r,t.g,t.b,t.opacity)):new zt}function Qu(t,r,o,s){return arguments.length===1?vx(t):new zt(t,r,o,s??1)}function zt(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}hc(zt,Qu,Op(ls,{brighter(t){return t=t==null?Ml:Math.pow(Ml,t),new zt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Ko:Math.pow(Ko,t),new zt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new zt(ri(this.r),ri(this.g),ri(this.b),Pl(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:uh,formatHex:uh,formatHex8:xx,formatRgb:ch,toString:ch}));function uh(){return`#${ni(this.r)}${ni(this.g)}${ni(this.b)}`}function xx(){return`#${ni(this.r)}${ni(this.g)}${ni(this.b)}${ni((isNaN(this.opacity)?1:this.opacity)*255)}`}function ch(){const t=Pl(this.opacity);return`${t===1?"rgb(":"rgba("}${ri(this.r)}, ${ri(this.g)}, ${ri(this.b)}${t===1?")":`, ${t})`}`}function Pl(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ri(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ni(t){return t=ri(t),(t<16?"0":"")+t.toString(16)}function dh(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new pn(t,r,o,s)}function Fp(t){if(t instanceof pn)return new pn(t.h,t.s,t.l,t.opacity);if(t instanceof ls||(t=oi(t)),!t)return new pn;if(t instanceof pn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new pn(c,h,p,t.opacity)}function wx(t,r,o,s){return arguments.length===1?Fp(t):new pn(t,r,o,s??1)}function pn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}hc(pn,wx,Op(ls,{brighter(t){return t=t==null?Ml:Math.pow(Ml,t),new pn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Ko:Math.pow(Ko,t),new pn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new zt(Tu(t>=240?t-240:t+120,a,s),Tu(t,a,s),Tu(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new pn(fh(this.h),pl(this.s),pl(this.l),Pl(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 t=Pl(this.opacity);return`${t===1?"hsl(":"hsla("}${fh(this.h)}, ${pl(this.s)*100}%, ${pl(this.l)*100}%${t===1?")":`, ${t})`}`}}));function fh(t){return t=(t||0)%360,t<0?t+360:t}function pl(t){return Math.max(0,Math.min(1,t||0))}function Tu(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const pc=t=>()=>t;function _x(t,r){return function(o){return t+o*r}}function Sx(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function kx(t){return(t=+t)==1?Hp:function(r,o){return o-r?Sx(r,o,t):pc(isNaN(r)?o:r)}}function Hp(t,r){var o=r-t;return o?_x(t,o):pc(isNaN(t)?r:t)}const Il=(function t(r){var o=kx(r);function s(a,u){var c=o((a=Qu(a)).r,(u=Qu(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),x=Hp(a.opacity,u.opacity);return function(m){return a.r=c(m),a.g=h(m),a.b=p(m),a.opacity=x(m),a+""}}return s.gamma=t,s})(1);function Nx(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:Ln(s,a)})),o=Lu.lastIndex;return o180?m+=360:m-x>180&&(x+=360),v.push({i:y.push(a(y)+"rotate(",null,s)-2,x:Ln(x,m)})):m&&y.push(a(y)+"rotate("+m+s)}function h(x,m,y,v){x!==m?v.push({i:y.push(a(y)+"skewX(",null,s)-2,x:Ln(x,m)}):m&&y.push(a(y)+"skewX("+m+s)}function p(x,m,y,v,_,N){if(x!==y||m!==v){var j=_.push(a(_)+"scale(",null,",",null,")");N.push({i:j-4,x:Ln(x,y)},{i:j-2,x:Ln(m,v)})}else(y!==1||v!==1)&&_.push(a(_)+"scale("+y+","+v+")")}return function(x,m){var y=[],v=[];return x=t(x),m=t(m),u(x.translateX,x.translateY,m.translateX,m.translateY,y,v),c(x.rotate,m.rotate,y,v),h(x.skewX,m.skewX,y,v),p(x.scaleX,x.scaleY,m.scaleX,m.scaleY,y,v),x=m=null,function(_){for(var N=-1,j=v.length,E;++N=0&&t._call.call(void 0,r),t=t._next;--qi}function gh(){si=(Tl=Zo.now())+Hl,qi=Wo=0;try{Ox()}finally{qi=0,Hx(),si=0}}function Fx(){var t=Zo.now(),r=t-Tl;r>Up&&(Hl-=r,Tl=t)}function Hx(){for(var t,r=Rl,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:Rl=o);Uo=t,ec(s)}function ec(t){if(!qi){Wo&&(Wo=clearTimeout(Wo));var r=t-si;r>24?(t<1/0&&(Wo=setTimeout(gh,t-Zo.now()-Hl)),Bo&&(Bo=clearInterval(Bo))):(Bo||(Tl=Zo.now(),Bo=setInterval(Fx,Up)),qi=1,Gp(gh))}}function mh(t,r,o){var s=new Ll;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Bx=Ol("start","end","cancel","interrupt"),Vx=[],Xp=0,yh=1,tc=2,jl=3,vh=4,nc=5,bl=6;function Bl(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;Wx(t,o,{name:r,index:s,group:a,on:Bx,tween:Vx,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Xp})}function mc(t,r){var o=vn(t,r);if(o.state>Xp)throw new Error("too late; already scheduled");return o}function $n(t,r){var o=vn(t,r);if(o.state>jl)throw new Error("too late; already running");return o}function vn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Wx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=Yp(u,0,o.time);function u(x){o.state=yh,o.timer.restart(c,o.delay,o.time),o.delay<=x&&c(x-o.delay)}function c(x){var m,y,v,_;if(o.state!==yh)return p();for(m in s)if(_=s[m],_.name===o.name){if(_.state===jl)return mh(c);_.state===vh?(_.state=bl,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete s[m]):+mtc&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function ww(t,r,o){var s,a,u=xw(r)?mc:$n;return function(){var c=u(this,t),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function _w(t,r){var o=this._id;return arguments.length<2?vn(this.node(),o).on.on(t):this.each(ww(o,t,r))}function Sw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function kw(){return this.on("end.remove",Sw(this._id))}function Nw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=dc(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function qw(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function er(t,r,o){this.k=t,this.x=r,this.y=o}er.prototype={constructor:er,scale:function(t){return t===1?this:new er(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new er(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Vl=new er(1,0,0);Zp.prototype=er.prototype;function Zp(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Vl;return t.__zoom}function Au(t){t.stopImmediatePropagation()}function Vo(t){t.preventDefault(),t.stopImmediatePropagation()}function Kw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Qw(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function xh(){return this.__zoom||Vl}function Zw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Jw(){return navigator.maxTouchPoints||"ontouchstart"in this}function e1(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function Jp(){var t=Kw,r=Qw,o=e1,s=Zw,a=Jw,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=Nl,x=Ol("start","zoom","end"),m,y,v,_=500,N=150,j=0,E=10;function w(R){R.property("__zoom",xh).on("wheel.zoom",Y,{passive:!1}).on("mousedown.zoom",K).on("dblclick.zoom",re).filter(a).on("touchstart.zoom",q).on("touchmove.zoom",Z).on("touchend.zoom touchcancel.zoom",te).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}w.transform=function(R,U,H,W){var M=R.selection?R.selection():R;M.property("__zoom",xh),R!==M?A(R,U,H,W):M.interrupt().each(function(){z(this,arguments).event(W).start().zoom(null,typeof U=="function"?U.apply(this,arguments):U).end()})},w.scaleBy=function(R,U,H,W){w.scaleTo(R,function(){var M=this.__zoom.k,D=typeof U=="function"?U.apply(this,arguments):U;return M*D},H,W)},w.scaleTo=function(R,U,H,W){w.transform(R,function(){var M=r.apply(this,arguments),D=this.__zoom,F=H==null?b(M):typeof H=="function"?H.apply(this,arguments):H,I=D.invert(F),$=typeof U=="function"?U.apply(this,arguments):U;return o(k(C(D,$),F,I),M,c)},H,W)},w.translateBy=function(R,U,H,W){w.transform(R,function(){return o(this.__zoom.translate(typeof U=="function"?U.apply(this,arguments):U,typeof H=="function"?H.apply(this,arguments):H),r.apply(this,arguments),c)},null,W)},w.translateTo=function(R,U,H,W,M){w.transform(R,function(){var D=r.apply(this,arguments),F=this.__zoom,I=W==null?b(D):typeof W=="function"?W.apply(this,arguments):W;return o(Vl.translate(I[0],I[1]).scale(F.k).translate(typeof U=="function"?-U.apply(this,arguments):-U,typeof H=="function"?-H.apply(this,arguments):-H),D,c)},W,M)};function C(R,U){return U=Math.max(u[0],Math.min(u[1],U)),U===R.k?R:new er(U,R.x,R.y)}function k(R,U,H){var W=U[0]-H[0]*R.k,M=U[1]-H[1]*R.k;return W===R.x&&M===R.y?R:new er(R.k,W,M)}function b(R){return[(+R[0][0]+ +R[1][0])/2,(+R[0][1]+ +R[1][1])/2]}function A(R,U,H,W){R.on("start.zoom",function(){z(this,arguments).event(W).start()}).on("interrupt.zoom end.zoom",function(){z(this,arguments).event(W).end()}).tween("zoom",function(){var M=this,D=arguments,F=z(M,D).event(W),I=r.apply(M,D),$=H==null?b(I):typeof H=="function"?H.apply(M,D):H,ie=Math.max(I[1][0]-I[0][0],I[1][1]-I[0][1]),oe=M.__zoom,fe=typeof U=="function"?U.apply(M,D):U,he=p(oe.invert($).concat(ie/oe.k),fe.invert($).concat(ie/fe.k));return function(pe){if(pe===1)pe=fe;else{var J=he(pe),ae=ie/J[2];pe=new er(ae,$[0]-J[0]*ae,$[1]-J[1]*ae)}F.zoom(null,pe)}})}function z(R,U,H){return!H&&R.__zooming||new V(R,U)}function V(R,U){this.that=R,this.args=U,this.active=0,this.sourceEvent=null,this.extent=r.apply(R,U),this.taps=0}V.prototype={event:function(R){return R&&(this.sourceEvent=R),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(R,U){return this.mouse&&R!=="mouse"&&(this.mouse[1]=U.invert(this.mouse[0])),this.touch0&&R!=="touch"&&(this.touch0[1]=U.invert(this.touch0[0])),this.touch1&&R!=="touch"&&(this.touch1[1]=U.invert(this.touch1[0])),this.that.__zoom=U,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(R){var U=Yt(this.that).datum();x.call(R,this.that,new qw(R,{sourceEvent:this.sourceEvent,target:w,transform:this.that.__zoom,dispatch:x}),U)}};function Y(R,...U){if(!t.apply(this,arguments))return;var H=z(this,U).event(R),W=this.__zoom,M=Math.max(u[0],Math.min(u[1],W.k*Math.pow(2,s.apply(this,arguments)))),D=hn(R);if(H.wheel)(H.mouse[0][0]!==D[0]||H.mouse[0][1]!==D[1])&&(H.mouse[1]=W.invert(H.mouse[0]=D)),clearTimeout(H.wheel);else{if(W.k===M)return;H.mouse=[D,W.invert(D)],El(this),H.start()}Vo(R),H.wheel=setTimeout(F,N),H.zoom("mouse",o(k(C(W,M),H.mouse[0],H.mouse[1]),H.extent,c));function F(){H.wheel=null,H.end()}}function K(R,...U){if(v||!t.apply(this,arguments))return;var H=R.currentTarget,W=z(this,U,!0).event(R),M=Yt(R.view).on("mousemove.zoom",$,!0).on("mouseup.zoom",ie,!0),D=hn(R,H),F=R.clientX,I=R.clientY;$p(R.view),Au(R),W.mouse=[D,this.__zoom.invert(D)],El(this),W.start();function $(oe){if(Vo(oe),!W.moved){var fe=oe.clientX-F,he=oe.clientY-I;W.moved=fe*fe+he*he>j}W.event(oe).zoom("mouse",o(k(W.that.__zoom,W.mouse[0]=hn(oe,H),W.mouse[1]),W.extent,c))}function ie(oe){M.on("mousemove.zoom mouseup.zoom",null),zp(oe.view,W.moved),Vo(oe),W.event(oe).end()}}function re(R,...U){if(t.apply(this,arguments)){var H=this.__zoom,W=hn(R.changedTouches?R.changedTouches[0]:R,this),M=H.invert(W),D=H.k*(R.shiftKey?.5:2),F=o(k(C(H,D),W,M),r.apply(this,U),c);Vo(R),h>0?Yt(this).transition().duration(h).call(A,F,W,R):Yt(this).call(w.transform,F,W,R)}}function q(R,...U){if(t.apply(this,arguments)){var H=R.touches,W=H.length,M=z(this,U,R.changedTouches.length===W).event(R),D,F,I,$;for(Au(R),F=0;F`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},Jo=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],eg=["Enter"," ","Escape"],tg={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Ki;(function(t){t.Strict="strict",t.Loose="loose"})(Ki||(Ki={}));var ii;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(ii||(ii={}));var es;(function(t){t.Partial="partial",t.Full="full"})(es||(es={}));const ng={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Mr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Mr||(Mr={}));var ts;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(ts||(ts={}));var ke;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(ke||(ke={}));const wh={[ke.Left]:ke.Right,[ke.Right]:ke.Left,[ke.Top]:ke.Bottom,[ke.Bottom]:ke.Top};function rg(t){return t===null?null:t?"valid":"invalid"}const ig=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,t1=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),vc=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),as=(t,r=[0,0])=>{const{width:o,height:s}=xn(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},n1=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):vc(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,Wl(a,Al(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?Ul(s):{x:0,y:0,width:0,height:0}},us=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=Wl(o,Al(a)),s=!0)}),s?Ul(o):{x:0,y:0,width:0,height:0}},xc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,x=r.width/a,m=r.height/a,y=[];for(const v of t.values()){const{measured:_,selectable:N=!0,hidden:j=!1}=v;if(c&&!N||j)continue;const E=_.width??v.width??v.initialWidth??0,w=_.height??v.height??v.initialHeight??0,{x:C,y:k}=v.internals.positionAbsolute,b=ag(h,p,x,m,C,k,E,w),A=E*w,z=u&&b>0;(!v.internals.handleBounds||z||b>=A||v.dragging)&&y.push(v)}return y},r1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function i1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=xn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function o1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const h=i1(t,c),p=us(h),x=_c(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(x,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function og({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),h=c.parentId?o.get(c.parentId):void 0,{x:p,y:x}=h?h.internals.positionAbsolute:{x:0,y:0},m=c.origin??s;let y=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",yn.error005());else{const{width:_,height:N}=xn(h);_&&N&&(y=[[p,x],[p+_,x+N]])}else h&&ai(c.extent)&&(y=[[c.extent[0][0]+p,c.extent[0][1]+x],[c.extent[1][0]+p,c.extent[1][1]+x]]);const v=ai(y)?li(r,y,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",yn.error015())),{position:{x:v.x-p+(c.measured.width??0)*m[0],y:v.y-x+(c.measured.height??0)*m[1]},positionAbsolute:v}}async function s1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(v=>v.id)),c=[];for(const v of o){if(v.deletable===!1)continue;const _=u.has(v.id),N=!_&&v.parentId&&c.find(j=>j.id===v.parentId);(_||N)&&c.push(v)}const h=new Set(r.map(v=>v.id)),p=s.filter(v=>v.deletable!==!1),m=r1(c,p);for(const v of p)h.has(v.id)&&!m.find(N=>N.id===v.id)&&m.push(v);if(!a)return{edges:m,nodes:c};const y=await a({nodes:c,edges:m});return typeof y=="boolean"?y?{edges:m,nodes:c}:{edges:[],nodes:[]}:y}const Qi=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),li=(t={x:0,y:0},r,o)=>({x:Qi(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:Qi(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function sg(t,r,o){const{width:s,height:a}=xn(o),{x:u,y:c}=o.internals.positionAbsolute;return li(t,[[u,c],[u+s,c+a]],r)}const _h=(t,r,o)=>to?-Qi(Math.abs(t-o),1,r)/r:0,wc=(t,r,o=15,s=40)=>{const a=_h(t.x,s,r.width-s)*o,u=_h(t.y,s,r.height-s)*o;return[a,u]},Wl=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),rc=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),Ul=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),ns=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=vc(t)?t.internals.positionAbsolute:as(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},Al=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=vc(t)?t.internals.positionAbsolute:as(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},lg=(t,r)=>Ul(Wl(rc(t),rc(r))),ag=(t,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),x=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*x)},$l=(t,r)=>ag(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),Sh=t=>gn(t.width)&&gn(t.height)&&gn(t.x)&&gn(t.y),gn=t=>!isNaN(t)&&isFinite(t),ug=(t,r)=>(o,s)=>{},cs=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),ds=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(t-o)/a,y:(r-s)/a};return u?cs(h,c):h},Zi=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Wi(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function l1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Wi(t,o),a=Wi(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Wi(t.top??t.y??0,o),a=Wi(t.bottom??t.y??0,o),u=Wi(t.left??t.x??0,r),c=Wi(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function a1(t,r,o,s,a,u){const{x:c,y:h}=Zi(t,[r,o,s]),{x:p,y:x}=Zi({x:t.x+t.width,y:t.y+t.height},[r,o,s]),m=a-p,y=u-x;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(m),bottom:Math.floor(y)}}const _c=(t,r,o,s,a,u)=>{const c=l1(u,r,o),h=(r-c.x)/t.width,p=(o-c.y)/t.height,x=Math.min(h,p),m=Qi(x,s,a),y=t.x+t.width/2,v=t.y+t.height/2,_=r/2-y*m,N=o/2-v*m,j=a1(t,_,N,m,r,o),E={left:Math.min(j.left-c.left,0),top:Math.min(j.top-c.top,0),right:Math.min(j.right-c.right,0),bottom:Math.min(j.bottom-c.bottom,0)};return{x:_-E.left+E.right,y:N-E.top+E.bottom,zoom:m}},rs=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function ai(t){return t!=null&&t!=="parent"}function xn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function cg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function dg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function kh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function u1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function c1(t){return{...tg,...t||{}}}function Yo(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=mn(t),h=ds({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y:x}=o?cs(h,r):h;return{xSnapped:p,ySnapped:x,...h}}const Sc=t=>({width:t.offsetWidth,height:t.offsetHeight}),fg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},d1=["INPUT","SELECT","TEXTAREA"];function hg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:d1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const pg=t=>"clientX"in t,mn=(t,r)=>{var u,c;const o=pg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},Nh=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...Sc(c)}})};function gg({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=t*.125+a*.375+c*.375+o*.125,x=r*.125+u*.375+h*.375+s*.125,m=Math.abs(p-t),y=Math.abs(x-r);return[p,x,m,y]}function yl(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function jh({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case ke.Left:return[r-yl(r-s,u),o];case ke.Right:return[r+yl(s-r,u),o];case ke.Top:return[r,o-yl(o-a,u)];case ke.Bottom:return[r,o+yl(a-o,u)]}}function mg({sourceX:t,sourceY:r,sourcePosition:o=ke.Bottom,targetX:s,targetY:a,targetPosition:u=ke.Top,curvature:c=.25}){const[h,p]=jh({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[x,m]=jh({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[y,v,_,N]=gg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:x,targetControlY:m});return[`M${t},${r} C${h},${p} ${x},${m} ${s},${a}`,y,v,_,N]}function yg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const p1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,g1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),m1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",yn.error006()),r;const s=o.getEdgeId||p1;let a;return ig(t)?a={...t}:a={...t,id:s(t)},g1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function vg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=yg({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,h]}const bh={[ke.Left]:{x:-1,y:0},[ke.Right]:{x:1,y:0},[ke.Top]:{x:0,y:-1},[ke.Bottom]:{x:0,y:1}},y1=({source:t,sourcePosition:r=ke.Bottom,target:o})=>r===ke.Left||r===ke.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function v1({source:t,sourcePosition:r=ke.Bottom,target:o,targetPosition:s=ke.Top,center:a,offset:u,stepPosition:c}){const h=bh[r],p=bh[s],x={x:t.x+h.x*u,y:t.y+h.y*u},m={x:o.x+p.x*u,y:o.y+p.y*u},y=y1({source:x,sourcePosition:r,target:m}),v=y.x!==0?"x":"y",_=y[v];let N=[],j,E;const w={x:0,y:0},C={x:0,y:0},[,,k,b]=yg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[v]*p[v]===-1){v==="x"?(j=a.x??x.x+(m.x-x.x)*c,E=a.y??(x.y+m.y)/2):(j=a.x??(x.x+m.x)/2,E=a.y??x.y+(m.y-x.y)*c);const Y=[{x:j,y:x.y},{x:j,y:m.y}],K=[{x:x.x,y:E},{x:m.x,y:E}];h[v]===_?N=v==="x"?Y:K:N=v==="x"?K:Y}else{const Y=[{x:x.x,y:m.y}],K=[{x:m.x,y:x.y}];if(v==="x"?N=h.x===_?K:Y:N=h.y===_?Y:K,r===s){const R=Math.abs(t[v]-o[v]);if(R<=u){const U=Math.min(u-1,u-R);h[v]===_?w[v]=(x[v]>t[v]?-1:1)*U:C[v]=(m[v]>o[v]?-1:1)*U}}if(r!==s){const R=v==="x"?"y":"x",U=h[v]===p[R],H=x[R]>m[R],W=x[R]=te?(j=(re.x+q.x)/2,E=N[0].y):(j=N[0].x,E=(re.y+q.y)/2)}const A={x:x.x+w.x,y:x.y+w.y},z={x:m.x+C.x,y:m.y+C.y};return[[t,...A.x!==N[0].x||A.y!==N[0].y?[A]:[],...N,...z.x!==N[N.length-1].x||z.y!==N[N.length-1].y?[z]:[],o],j,E,k,b]}function x1(t,r,o,s){const a=Math.min(Eh(t,r)/2,Eh(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const x=t.xo.id===r):t[0])||null}function oc(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function _1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const x=oc(p,r);u.has(x)||(c.push({id:x,color:p.color||o,...p}),u.add(x))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const xg=1e3,S1=10,kc={nodeOrigin:[0,0],nodeExtent:Jo,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},k1={...kc,checkEquality:!0};function Nc(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function N1(t,r,o){const s=Nc(kc,o);for(const a of t.values())if(a.parentId)bc(a,t,r,s);else{const u=as(a,s.nodeOrigin),c=ai(a.extent)?a.extent:s.nodeExtent,h=li(u,c,xn(a));a.internals.positionAbsolute=h}}function j1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function jc(t){return t==="manual"}function sc(t,r,o,s={}){var m,y;const a=Nc(k1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!jc(a.zIndexMode)?xg:0;let p=t.length>0,x=!1;r.clear(),o.clear();for(const v of t){let _=c.get(v.id);if(a.checkEquality&&v===(_==null?void 0:_.internals.userNode))r.set(v.id,_);else{const N=as(v,a.nodeOrigin),j=ai(v.extent)?v.extent:a.nodeExtent,E=li(N,j,xn(v));_={...a.defaults,...v,measured:{width:(m=v.measured)==null?void 0:m.width,height:(y=v.measured)==null?void 0:y.height},internals:{positionAbsolute:E,handleBounds:j1(v,_),z:wg(v,h,a.zIndexMode),userNode:v}},r.set(v.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),v.parentId&&bc(_,r,o,s,u),x||(x=v.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:x}}function b1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function bc(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=Nc(kc,s),x=t.parentId,m=r.get(x);if(!m){console.warn(`Parent node ${x} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}b1(t,o),a&&!m.parentId&&m.internals.rootParentIndex===void 0&&p==="auto"&&(m.internals.rootParentIndex=++a.i,m.internals.z=m.internals.z+a.i*S1),a&&m.internals.rootParentIndex!==void 0&&(a.i=m.internals.rootParentIndex);const y=u&&!jc(p)?xg:0,{x:v,y:_,z:N}=E1(t,m,c,h,y,p),{positionAbsolute:j}=t.internals,E=v!==j.x||_!==j.y;(E||N!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:E?{x:v,y:_}:j,z:N}})}function wg(t,r,o){const s=gn(t.zIndex)?t.zIndex:0;return jc(o)?s:s+(t.selected?r:0)}function E1(t,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=xn(t),x=as(t,o),m=ai(t.extent)?li(x,t.extent,p):x;let y=li({x:c+m.x,y:h+m.y},s,p);t.extent==="parent"&&(y=sg(y,p,r));const v=wg(t,a,u),_=r.internals.z??0;return{x:y.x,y:y.y,z:_>=v?_+1:v}}function Ec(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const x=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??ns(p),m=lg(x,h.rect);u.set(h.parentId,{expandedRect:m,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},x)=>{var k;const m=p.internals.positionAbsolute,y=xn(p),v=p.origin??s,_=h.x0||N>0||w||C)&&(a.push({id:x,type:"position",position:{x:p.position.x-_+w,y:p.position.y-N+C}}),(k=o.get(x))==null||k.forEach(b=>{t.some(A=>A.id===b.id)||a.push({id:b.id,type:"position",position:{x:b.position.x+_,y:b.position.y+N}})})),(y.width0){const _=Ec(v,r,o,a);x.push(..._)}return{changes:x,updatedInternals:p}}async function M1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Ih(t,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${t}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${t}-${u}`;const x=s.get(c)||new Map;s.set(c,x.set(o,r))}}function _g(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},x=`${a}-${c}--${u}-${h}`,m=`${u}-${h}--${a}-${c}`;Ih("source",p,m,t,a,c),Ih("target",p,x,t,u,h),r.set(s.id,s)}}function Sg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:Sg(o,r):!1}function Rh(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function P1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!Sg(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function $u({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[x,m]of r){const y=(c=o.get(x))==null?void 0:c.internals.userNode;y&&a.push({...y,position:m.position,dragging:s})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function I1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=cs(u,r);return{x:c.x-u.x,y:c.y-u.y}}function R1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,x={x:0,y:0},m=null,y=!1,v=null,_=!1,N=!1,j=null;function E({noDragClassName:C,handleSelector:k,domNode:b,isSelectable:A,nodeId:z,nodeClickDistance:V=0}){v=Yt(b);function Y({x:Z,y:te}){const{nodeLookup:R,nodeExtent:U,snapGrid:H,snapToGrid:W,nodeOrigin:M,onNodeDrag:D,onSelectionDrag:F,onError:I,updateNodePositions:$}=r();u={x:Z,y:te};let ie=!1;const oe=h.size>1,fe=oe&&U?rc(us(h)):null,he=oe&&W?I1({dragItems:h,snapGrid:H,x:Z,y:te}):null;for(const[pe,J]of h){if(!R.has(pe))continue;let ae={x:Z-J.distance.x,y:te-J.distance.y};W&&(ae=he?{x:Math.round(ae.x+he.x),y:Math.round(ae.y+he.y)}:cs(ae,H));let me=null;if(oe&&U&&!J.extent&&fe){const{positionAbsolute:ne}=J.internals,je=ne.x-fe.x+U[0][0],Me=ne.x+J.measured.width-fe.x2+U[1][0],Te=ne.y-fe.y+U[0][1],De=ne.y+J.measured.height-fe.y2+U[1][1];me=[[je,Te],[Me,De]]}const{position:Ne,positionAbsolute:xe}=og({nodeId:pe,nextPosition:ae,nodeLookup:R,nodeExtent:me||U,nodeOrigin:M,onError:I});ie=ie||J.position.x!==Ne.x||J.position.y!==Ne.y,J.position=Ne,J.internals.positionAbsolute=xe}if(N=N||ie,!!ie&&($(h,!0),j&&(s||D||!z&&F))){const[pe,J]=$u({nodeId:z,dragItems:h,nodeLookup:R});s==null||s(j,h,pe,J),D==null||D(j,pe,J),z||F==null||F(j,J)}}async function K(){if(!m)return;const{transform:Z,panBy:te,autoPanSpeed:R,autoPanOnNodeDrag:U}=r();if(!U){p=!1,cancelAnimationFrame(c);return}const[H,W]=wc(x,m,R);(H!==0||W!==0)&&(u.x=(u.x??0)-H/Z[2],u.y=(u.y??0)-W/Z[2],await te({x:H,y:W})&&Y(u)),c=requestAnimationFrame(K)}function re(Z){var oe;const{nodeLookup:te,multiSelectionActive:R,nodesDraggable:U,transform:H,snapGrid:W,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:F,onSelectionDragStart:I,unselectNodesAndEdges:$}=r();y=!0,(!D||!A)&&!R&&z&&((oe=te.get(z))!=null&&oe.selected||$()),A&&D&&z&&(t==null||t(z));const ie=Yo(Z.sourceEvent,{transform:H,snapGrid:W,snapToGrid:M,containerBounds:m});if(u=ie,h=P1(te,U,ie,z),h.size>0&&(o||F||!z&&I)){const[fe,he]=$u({nodeId:z,dragItems:h,nodeLookup:te});o==null||o(Z.sourceEvent,h,fe,he),F==null||F(Z.sourceEvent,fe,he),z||I==null||I(Z.sourceEvent,he)}}const q=Dp().clickDistance(V).on("start",Z=>{const{domNode:te,nodeDragThreshold:R,transform:U,snapGrid:H,snapToGrid:W}=r();m=(te==null?void 0:te.getBoundingClientRect())||null,_=!1,N=!1,j=Z.sourceEvent,R===0&&re(Z),u=Yo(Z.sourceEvent,{transform:U,snapGrid:H,snapToGrid:W,containerBounds:m}),x=mn(Z.sourceEvent,m)}).on("drag",Z=>{const{autoPanOnNodeDrag:te,transform:R,snapGrid:U,snapToGrid:H,nodeDragThreshold:W,nodeLookup:M}=r(),D=Yo(Z.sourceEvent,{transform:R,snapGrid:U,snapToGrid:H,containerBounds:m});if(j=Z.sourceEvent,(Z.sourceEvent.type==="touchmove"&&Z.sourceEvent.touches.length>1||z&&!M.has(z))&&(_=!0),!_){if(!p&&te&&y&&(p=!0,K()),!y){const F=mn(Z.sourceEvent,m),I=F.x-x.x,$=F.y-x.y;Math.sqrt(I*I+$*$)>W&&re(Z)}(u.x!==D.xSnapped||u.y!==D.ySnapped)&&h&&y&&(x=mn(Z.sourceEvent,m),Y(D))}}).on("end",Z=>{if(!y||_){_&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,y=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:te,updateNodePositions:R,onNodeDragStop:U,onSelectionDragStop:H}=r();if(N&&(R(h,!1),N=!1),a||U||!z&&H){const[W,M]=$u({nodeId:z,dragItems:h,nodeLookup:te,dragging:!1});a==null||a(Z.sourceEvent,h,W,M),U==null||U(Z.sourceEvent,W,M),z||H==null||H(Z.sourceEvent,M)}}}).filter(Z=>{const te=Z.target;return!Z.button&&(!C||!Rh(te,`.${C}`,b))&&(!k||Rh(te,k,b))});v.call(q)}function w(){v==null||v.on(".drag",null)}return{update:E,destroy:w}}function T1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())$l(a,ns(u))>0&&s.push(u);return s}const L1=250;function A1(t,r,o,s){var h,p;let a=[],u=1/0;const c=T1(t,o,r+L1);for(const x of c){const m=[...((h=x.internals.handleBounds)==null?void 0:h.source)??[],...((p=x.internals.handleBounds)==null?void 0:p.target)??[]];for(const y of m){if(s.nodeId===y.nodeId&&s.type===y.type&&s.id===y.id)continue;const{x:v,y:_}=ui(x,y,y.position,!0),N=Math.sqrt(Math.pow(v-t.x,2)+Math.pow(_-t.y,2));N>r||(N1){const x=s.type==="source"?"target":"source";return a.find(m=>m.type===x)??a[0]}return a[0]}function kg(t,r,o,s,a,u=!1){var x,m,y;const c=s.get(t);if(!c)return null;const h=a==="strict"?(x=c.internals.handleBounds)==null?void 0:x[r]:[...((m=c.internals.handleBounds)==null?void 0:m.source)??[],...((y=c.internals.handleBounds)==null?void 0:y.target)??[]],p=(o?h==null?void 0:h.find(v=>v.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...ui(c,p,p.position,!0)}:p}function Ng(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function $1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const jg=()=>!0;function z1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:x,autoPanOnConnect:m,flowId:y,panBy:v,cancelConnection:_,onConnectStart:N,onConnect:j,onConnectEnd:E,isValidConnection:w=jg,onReconnectEnd:C,updateConnection:k,getTransform:b,getFromHandle:A,autoPanSpeed:z,dragThreshold:V=1,handleDomNode:Y}){const K=fg(t.target);let re=0,q;const{x:Z,y:te}=mn(t),R=Ng(u,Y),U=h==null?void 0:h.getBoundingClientRect();let H=!1;if(!U||!R)return;const W=kg(a,R,s,p,r);if(!W)return;let M=mn(t,U),D=!1,F=null,I=!1,$=null;function ie(){if(!m||!U)return;const[Ne,xe]=wc(M,U,z);v({x:Ne,y:xe}),re=requestAnimationFrame(ie)}const oe={...W,nodeId:a,type:R,position:W.position},fe=p.get(a);let pe={inProgress:!0,isValid:null,from:ui(fe,oe,ke.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:fe,to:M,toHandle:null,toPosition:wh[oe.position],toNode:null,pointer:M};function J(){H=!0,k(pe),N==null||N(t,{nodeId:a,handleId:s,handleType:R})}V===0&&J();function ae(Ne){if(!H){const{x:De,y:ht}=mn(Ne),Je=De-Z,Xe=ht-te;if(!(Je*Je+Xe*Xe>V*V))return;J()}if(!A()||!oe){me(Ne);return}const xe=b();M=mn(Ne,U),q=A1(ds(M,xe,!1,[1,1]),o,p,oe),D||(ie(),D=!0);const ne=bg(Ne,{handle:q,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:w,doc:K,lib:x,flowId:y,nodeLookup:p});$=ne.handleDomNode,F=ne.connection,I=$1(!!q,ne.isValid);const je=p.get(a),Me=je?ui(je,oe,ke.Left,!0):pe.from,Te={...pe,from:Me,isValid:I,to:ne.toHandle&&I?Zi({x:ne.toHandle.x,y:ne.toHandle.y},xe):M,toHandle:ne.toHandle,toPosition:I&&ne.toHandle?ne.toHandle.position:wh[oe.position],toNode:ne.toHandle?p.get(ne.toHandle.nodeId):null,pointer:M};k(Te),pe=Te}function me(Ne){if(!("touches"in Ne&&Ne.touches.length>0)){if(H){(q||$)&&F&&I&&(j==null||j(F));const{inProgress:xe,...ne}=pe,je={...ne,toPosition:pe.toHandle?pe.toPosition:null};E==null||E(Ne,je),u&&(C==null||C(Ne,je))}_(),cancelAnimationFrame(re),D=!1,I=!1,F=null,$=null,K.removeEventListener("mousemove",ae),K.removeEventListener("mouseup",me),K.removeEventListener("touchmove",ae),K.removeEventListener("touchend",me)}}K.addEventListener("mousemove",ae),K.addEventListener("mouseup",me),K.addEventListener("touchmove",ae),K.addEventListener("touchend",me)}function bg(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:x=jg,nodeLookup:m}){const y=u==="target",v=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:N}=mn(t),j=c.elementFromPoint(_,N),E=j!=null&&j.classList.contains(`${h}-flow__handle`)?j:v,w={handleDomNode:E,isValid:!1,connection:null,toHandle:null};if(E){const C=Ng(void 0,E),k=E.getAttribute("data-nodeid"),b=E.getAttribute("data-handleid"),A=E.classList.contains("connectable"),z=E.classList.contains("connectableend");if(!k||!C)return w;const V={source:y?k:s,sourceHandle:y?b:a,target:y?s:k,targetHandle:y?a:b};w.connection=V;const K=A&&z&&(o===Ki.Strict?y&&C==="source"||!y&&C==="target":k!==s||b!==a);w.isValid=K&&x(V),w.toHandle=kg(k,C,b,m,o,!0)}return w}const lc={onPointerDown:z1,isValid:bg};function D1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Yt(t);function u({translateExtent:h,width:p,height:x,zoomStep:m=1,pannable:y=!0,zoomable:v=!0,inversePan:_=!1}){const N=k=>{if(k.sourceEvent.type!=="wheel"||!r)return;const b=o(),A=k.sourceEvent.ctrlKey&&rs()?10:1,z=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*m,V=b[2]*Math.pow(2,z*A);r.scaleTo(V)};let j=[0,0];const E=k=>{(k.sourceEvent.type==="mousedown"||k.sourceEvent.type==="touchstart")&&(j=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY])},w=k=>{const b=o();if(k.sourceEvent.type!=="mousemove"&&k.sourceEvent.type!=="touchmove"||!r)return;const A=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY],z=[A[0]-j[0],A[1]-j[1]];j=A;const V=s()*Math.max(b[2],Math.log(b[2]))*(_?-1:1),Y={x:b[0]-z[0]*V,y:b[1]-z[1]*V},K=[[0,0],[p,x]];r.setViewportConstrained({x:Y.x,y:Y.y,zoom:b[2]},K,h)},C=Jp().on("start",E).on("zoom",y?w:null).on("zoom.wheel",v?N:null);a.call(C,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:hn}}const Gl=t=>({x:t.x,y:t.y,zoom:t.k}),zu=({x:t,y:r,zoom:o})=>Vl.translate(t,r).scale(o),Er=(t,r)=>t.target.closest(`.${r}`),Eg=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),O1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Du=(t,r=0,o=O1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Cg=t=>{const r=t.ctrlKey&&rs()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function F1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:x}){return m=>{if(Er(m,r))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const y=o.property("__zoom").k||1;if(m.ctrlKey&&c){const E=hn(m),w=Cg(m),C=y*Math.pow(2,w);s.scaleTo(o,C,E,m);return}const v=m.deltaMode===1?20:1;let _=a===ii.Vertical?0:m.deltaX*v,N=a===ii.Horizontal?0:m.deltaY*v;!rs()&&m.shiftKey&&a!==ii.Vertical&&(_=m.deltaY*v,N=0),s.translateBy(o,-(_/y)*u,-(N/y)*u,{internal:!0});const j=Gl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(m,j):(t.isPanScrolling=!0,h==null||h(m,j)),t.panScrollTimeout=setTimeout(()=>{x==null||x(m,j),t.isPanScrolling=!1},150)}}function H1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=Er(s,t);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function B1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=Gl(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function V1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;t.usedRightMouseButton=!!(o&&Eg(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,Gl(u.transform)))}}function W1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&Eg(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const p=Gl(c.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function U1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:x,lib:m,connectionInProgress:y}){return v=>{var w;const _=r||o,N=s&&v.ctrlKey,j=v.type==="wheel";if(v.button===1&&v.type==="mousedown"&&(Er(v,`${m}-flow__node`)||Er(v,`${m}-flow__edge`)||Er(v,`${m}-flow__selection`)||Er(v,`${m}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!c&&!s||h||y&&!j||Er(v,p)&&j||Er(v,x)&&(!j||u&&j&&!r)||!s&&v.ctrlKey&&j)return!1;if(!s&&v.type==="touchstart"&&((w=v.touches)==null?void 0:w.length)>1)return v.preventDefault(),!1;if(!_&&!u&&!N&&j||!a&&(v.type==="mousedown"||v.type==="touchstart")||Array.isArray(a)&&!a.includes(v.button)&&v.type==="mousedown")return!1;const E=Array.isArray(a)&&a.includes(v.button)||!v.button||v.button<=1;return(!v.ctrlKey||j||t)&&E}}function G1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const x={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},m=t.getBoundingClientRect();let y=[[0,0],[m.width,m.height]];const v=typeof ResizeObserver<"u"?new ResizeObserver(te=>{const R=te[0];R&&(y=[[0,0],[R.contentRect.width,R.contentRect.height]])}):null;v==null||v.observe(t);const _=Jp().extent(()=>y).scaleExtent([r,o]).translateExtent(s),N=Yt(t).call(_);b({x:a.x,y:a.y,zoom:Qi(a.zoom,r,o)},[[0,0],[m.width,m.height]],s);const j=N.on("wheel.zoom"),E=N.on("dblclick.zoom");_.wheelDelta(Cg);async function w(te,R){return N?new Promise(U=>{_==null||_.interpolate((R==null?void 0:R.interpolate)==="linear"?Go:Nl).transform(Du(N,R==null?void 0:R.duration,R==null?void 0:R.ease,()=>U(!0)),te)}):!1}function C({noWheelClassName:te,noPanClassName:R,onPaneContextMenu:U,userSelectionActive:H,panOnScroll:W,panOnDrag:M,panOnScrollMode:D,panOnScrollSpeed:F,preventScrolling:I,zoomOnPinch:$,zoomOnScroll:ie,zoomOnDoubleClick:oe,panActivationKeyPressed:fe=!1,zoomActivationKeyPressed:he,lib:pe,onTransformChange:J,connectionInProgress:ae,paneClickDistance:me,selectionOnDrag:Ne}){H&&!x.isZoomingOrPanning&&k();const xe=W&&!he&&!H;_.clickDistance(Ne?1/0:!gn(me)||me<0?0:me);const ne=xe?F1({zoomPanValues:x,noWheelClassName:te,d3Selection:N,d3Zoom:_,panOnScrollMode:D,panOnScrollSpeed:F,zoomOnPinch:$,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):H1({noWheelClassName:te,preventScrolling:I,d3ZoomHandler:j});N.on("wheel.zoom",ne,{passive:!1});const je=B1({zoomPanValues:x,onDraggingChange:p,onPanZoomStart:c});_.on("start",je);const Me=V1({zoomPanValues:x,panOnDrag:M,onPaneContextMenu:!!U,onPanZoom:u,onTransformChange:J});_.on("zoom",Me);const Te=W1({zoomPanValues:x,panOnDrag:M,panOnScroll:W,onPaneContextMenu:U,onPanZoomEnd:h,onDraggingChange:p});_.on("end",Te);const De=U1({panActivationKeyPressed:fe,zoomActivationKeyPressed:he,panOnDrag:M,zoomOnScroll:ie,panOnScroll:W,zoomOnDoubleClick:oe,zoomOnPinch:$,userSelectionActive:H,noPanClassName:R,noWheelClassName:te,lib:pe,connectionInProgress:ae});_.filter(De),oe?N.on("dblclick.zoom",E):N.on("dblclick.zoom",null)}function k(){_.on("zoom",null)}async function b(te,R,U){const H=zu(te),W=_==null?void 0:_.constrain()(H,R,U);return W&&await w(W),W}async function A(te,R){const U=zu(te);return await w(U,R),U}function z(te){if(N){const R=zu(te),U=N.property("__zoom");(U.k!==te.zoom||U.x!==te.x||U.y!==te.y)&&(_==null||_.transform(N,R,null,{sync:!0}))}}function V(){const te=N?Zp(N.node()):{x:0,y:0,k:1};return{x:te.x,y:te.y,zoom:te.k}}async function Y(te,R){return N?new Promise(U=>{_==null||_.interpolate((R==null?void 0:R.interpolate)==="linear"?Go:Nl).scaleTo(Du(N,R==null?void 0:R.duration,R==null?void 0:R.ease,()=>U(!0)),te)}):!1}async function K(te,R){return N?new Promise(U=>{_==null||_.interpolate((R==null?void 0:R.interpolate)==="linear"?Go:Nl).scaleBy(Du(N,R==null?void 0:R.duration,R==null?void 0:R.ease,()=>U(!0)),te)}):!1}function re(te){_==null||_.scaleExtent(te)}function q(te){_==null||_.translateExtent(te)}function Z(te){const R=!gn(te)||te<0?0:te;_==null||_.clickDistance(R)}return{update:C,destroy:k,setViewport:A,setViewportConstrained:b,getViewport:V,scaleTo:Y,scaleBy:K,setScaleExtent:re,setTranslateExtent:q,syncViewport:z,setClickDistance:Z}}var Ji;(function(t){t.Line="line",t.Handle="handle"})(Ji||(Ji={}));function Y1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function Th(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function jr(t,r){return Math.max(0,r-t)}function br(t,r){return Math.max(0,t-r)}function vl(t,r,o){return Math.max(0,r-t,t-o)}function Lh(t,r){return t?!r:r}function X1(t,r,o,s,a,u,c,h){let{affectsX:p,affectsY:x}=r;const{isHorizontal:m,isVertical:y}=r,v=m&&y,{xSnapped:_,ySnapped:N}=o,{minWidth:j,maxWidth:E,minHeight:w,maxHeight:C}=s,{x:k,y:b,width:A,height:z,aspectRatio:V}=t;let Y=Math.floor(m?_-t.pointerX:0),K=Math.floor(y?N-t.pointerY:0);const re=A+(p?-Y:Y),q=z+(x?-K:K),Z=-u[0]*A,te=-u[1]*z;let R=vl(re,j,E),U=vl(q,w,C);if(c){let M=0,D=0;p&&Y<0?M=jr(k+Y+Z,c[0][0]):!p&&Y>0&&(M=br(k+re+Z,c[1][0])),x&&K<0?D=jr(b+K+te,c[0][1]):!x&&K>0&&(D=br(b+q+te,c[1][1])),R=Math.max(R,M),U=Math.max(U,D)}if(h){let M=0,D=0;p&&Y>0?M=br(k+Y,h[0][0]):!p&&Y<0&&(M=jr(k+re,h[1][0])),x&&K>0?D=br(b+K,h[0][1]):!x&&K<0&&(D=jr(b+q,h[1][1])),R=Math.max(R,M),U=Math.max(U,D)}if(a){if(m){const M=vl(re/V,w,C)*V;if(R=Math.max(R,M),c){let D=0;!p&&!x||p&&!x&&v?D=br(b+te+re/V,c[1][1])*V:D=jr(b+te+(p?Y:-Y)/V,c[0][1])*V,R=Math.max(R,D)}if(h){let D=0;!p&&!x||p&&!x&&v?D=jr(b+re/V,h[1][1])*V:D=br(b+(p?Y:-Y)/V,h[0][1])*V,R=Math.max(R,D)}}if(y){const M=vl(q*V,j,E)/V;if(U=Math.max(U,M),c){let D=0;!p&&!x||x&&!p&&v?D=br(k+q*V+Z,c[1][0])/V:D=jr(k+(x?K:-K)*V+Z,c[0][0])/V,U=Math.max(U,D)}if(h){let D=0;!p&&!x||x&&!p&&v?D=jr(k+q*V,h[1][0])/V:D=br(k+(x?K:-K)*V,h[0][0])/V,U=Math.max(U,D)}}}K=K+(K<0?U:-U),Y=Y+(Y<0?R:-R),a&&(v?re>q*V?K=(Lh(p,x)?-Y:Y)/V:Y=(Lh(p,x)?-K:K)*V:m?(K=Y/V,x=p):(Y=K*V,p=x));const H=p?k+Y:k,W=x?b+K:b;return{width:A+(p?-Y:Y),height:z+(x?-K:K),x:u[0]*Y*(p?-1:1)+H,y:u[1]*K*(x?-1:1)+W}}const Mg={width:0,height:0,x:0,y:0},q1={...Mg,pointerX:0,pointerY:0,aspectRatio:1};function K1(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function Q1({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Yt(t);let c={controlDirection:Th("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:x,boundaries:m,keepAspectRatio:y,resizeDirection:v,onResizeStart:_,onResize:N,onResizeEnd:j,shouldResize:E}){let w={...Mg},C={...q1};c={boundaries:m,resizeDirection:v,keepAspectRatio:y,controlDirection:Th(x)};let k,b=null,A=[],z,V,Y,K=!1;const re=Dp().on("start",q=>{const{nodeLookup:Z,transform:te,snapGrid:R,snapToGrid:U,nodeOrigin:H,paneDomNode:W}=o();if(k=Z.get(r),!k)return;b=(W==null?void 0:W.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:D}=Yo(q.sourceEvent,{transform:te,snapGrid:R,snapToGrid:U,containerBounds:b});w={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},C={...w,pointerX:M,pointerY:D,aspectRatio:w.width/w.height},z=void 0,V=ai(k.extent)?k.extent:void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(z=Z.get(k.parentId)),z&&k.extent==="parent"&&(V=[[0,0],[z.measured.width,z.measured.height]]),A=[],Y=void 0;for(const[F,I]of Z)if(I.parentId===r&&(A.push({id:F,position:{...I.position},extent:I.extent}),I.extent==="parent"||I.expandParent)){const $=K1(I,k,I.origin??H);Y?Y=[[Math.min($[0][0],Y[0][0]),Math.min($[0][1],Y[0][1])],[Math.max($[1][0],Y[1][0]),Math.max($[1][1],Y[1][1])]]:Y=$}_==null||_(q,{...w})}).on("drag",q=>{const{transform:Z,snapGrid:te,snapToGrid:R,nodeOrigin:U}=o(),H=Yo(q.sourceEvent,{transform:Z,snapGrid:te,snapToGrid:R,containerBounds:b}),W=[];if(!k)return;const{x:M,y:D,width:F,height:I}=w,$={},ie=k.origin??U,{width:oe,height:fe,x:he,y:pe}=X1(C,c.controlDirection,H,c.boundaries,c.keepAspectRatio,ie,V,Y),J=oe!==F,ae=fe!==I,me=he!==M&&J,Ne=pe!==D&&ae;if(!me&&!Ne&&!J&&!ae)return;if((me||Ne||ie[0]===1||ie[1]===1)&&($.x=me?he:w.x,$.y=Ne?pe:w.y,w.x=$.x,w.y=$.y,A.length>0)){const Me=he-M,Te=pe-D;for(const De of A)De.position={x:De.position.x-Me+ie[0]*(oe-F),y:De.position.y-Te+ie[1]*(fe-I)},W.push(De)}if((J||ae)&&($.width=J&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:w.width,$.height=ae&&(!c.resizeDirection||c.resizeDirection==="vertical")?fe:w.height,w.width=$.width,w.height=$.height),z&&k.expandParent){const Me=ie[0]*($.width??0);$.x&&$.x{K&&(j==null||j(q,{...w}),a==null||a({...w}),K=!1)});u.call(re)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Ou={exports:{}},Fu={},Hu={exports:{}},Bu={};/** + * @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 Ah;function Z1(){if(Ah)return Bu;Ah=1;var t=os();function r(y,v){return y===v&&(y!==0||1/y===1/v)||y!==y&&v!==v}var o=typeof Object.is=="function"?Object.is:r,s=t.useState,a=t.useEffect,u=t.useLayoutEffect,c=t.useDebugValue;function h(y,v){var _=v(),N=s({inst:{value:_,getSnapshot:v}}),j=N[0].inst,E=N[1];return u(function(){j.value=_,j.getSnapshot=v,p(j)&&E({inst:j})},[y,_,v]),a(function(){return p(j)&&E({inst:j}),y(function(){p(j)&&E({inst:j})})},[y]),c(_),_}function p(y){var v=y.getSnapshot;y=y.value;try{var _=v();return!o(y,_)}catch{return!0}}function x(y,v){return v()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?x:h;return Bu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:m,Bu}var $h;function J1(){return $h||($h=1,Hu.exports=Z1()),Hu.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 zh;function e_(){if(zh)return Fu;zh=1;var t=os(),r=J1();function o(x,m){return x===m&&(x!==0||1/x===1/m)||x!==x&&m!==m}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Fu.useSyncExternalStoreWithSelector=function(x,m,y,v,_){var N=u(null);if(N.current===null){var j={hasValue:!1,value:null};N.current=j}else j=N.current;N=h(function(){function w(z){if(!C){if(C=!0,k=z,z=v(z),_!==void 0&&j.hasValue){var V=j.value;if(_(V,z))return b=V}return b=z}if(V=b,s(k,z))return V;var Y=v(z);return _!==void 0&&_(V,Y)?(k=z,V):(k=z,b=Y)}var C=!1,k,b,A=y===void 0?null:y;return[function(){return w(m())},A===null?void 0:function(){return w(A())}]},[m,y,v,_]);var E=a(x,N[0],N[1]);return c(function(){j.hasValue=!0,j.value=E},[E]),p(E),E},Fu}var Dh;function t_(){return Dh||(Dh=1,Ou.exports=e_()),Ou.exports}var n_=t_();const r_=wp(n_),i_={},Oh=t=>{let r;const o=new Set,s=(m,y)=>{const v=typeof m=="function"?m(r):m;if(!Object.is(v,r)){const _=r;r=y??(typeof v!="object"||v===null)?v:Object.assign({},r,v),o.forEach(N=>N(r,_))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>x,subscribe:m=>(o.add(m),()=>o.delete(m)),destroy:()=>{(i_?"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."),o.clear()}},x=r=t(s,a,p);return p},o_=t=>t?Oh(t):Oh,{useDebugValue:s_}=t0,{useSyncExternalStoreWithSelector:l_}=r_,a_=t=>t;function Pg(t,r=a_,o){const s=l_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return s_(s),s}const Fh=(t,r)=>{const o=o_(t),s=(a,u=r)=>Pg(o,a,u);return Object.assign(s,o),s},u_=(t,r)=>t?Fh(t,r):Fh;function Qe(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}_p();const Yl=L.createContext(null),c_=Yl.Provider,Ig=yn.error001("react");function ze(t,r){const o=L.useContext(Yl);if(o===null)throw new Error(Ig);return Pg(o,t,r)}function Ge(){const t=L.useContext(Yl);if(t===null)throw new Error(Ig);return L.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Hh={display:"none"},d_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Rg="react-flow__node-desc",Tg="react-flow__edge-desc",f_="react-flow__aria-live",h_=t=>t.ariaLiveMessage,p_=t=>t.ariaLabelConfig;function g_({rfId:t}){const r=ze(h_);return d.jsx("div",{id:`${f_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:d_,children:r})}function m_({rfId:t,disableKeyboardA11y:r}){const o=ze(p_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${Rg}-${t}`,style:Hh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${Tg}-${t}`,style:Hh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(g_,{rfId:t})]})}const Xl=L.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return d.jsx("div",{className:it(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});Xl.displayName="Panel";const Bh="https://reactflow.dev?utm_source=attribution";function y_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:d.jsx(Xl,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Bh}`,children:d.jsx("a",{href:Bh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const v_=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},xl=t=>t.id;function x_(t,r){return Qe(t.selectedNodes.map(xl),r.selectedNodes.map(xl))&&Qe(t.selectedEdges.map(xl),r.selectedEdges.map(xl))}function w_({onSelectionChange:t}){const r=Ge(),{selectedNodes:o,selectedEdges:s}=ze(v_,x_);return L.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const __=t=>!!t.onSelectionChangeHandlers;function S_({onSelectionChange:t}){const r=ze(__);return t||r?d.jsx(w_,{onSelectionChange:t}):null}const Lg=[0,0],k_={x:0,y:0,zoom:1},N_=["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"],Vh=[...N_,"rfId"],j_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Wh={translateExtent:Jo,nodeOrigin:Lg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function b_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=ze(j_,Qe),x=Ge();L.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{m.current=Wh,h()}),[]);const m=L.useRef(Wh);return L.useEffect(()=>{for(const y of Vh){const v=t[y],_=m.current[y];v!==_&&(typeof t[y]>"u"||(y==="nodes"?r(v):y==="edges"?o(v):y==="minZoom"?s(v):y==="maxZoom"?a(v):y==="translateExtent"?u(v):y==="nodeExtent"?c(v):y==="ariaLabelConfig"?x.setState({ariaLabelConfig:c1(v)}):y==="fitView"?x.setState({fitViewQueued:v}):y==="fitViewOptions"?x.setState({fitViewOptions:v}):x.setState({[y]:v})))}m.current=t},Vh.map(y=>t[y])),null}function Uh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function E_(t){var s;const[r,o]=L.useState(t==="system"?null:t);return L.useEffect(()=>{if(t!=="system"){o(t);return}const a=Uh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=Uh())!=null&&s.matches?"dark":"light"}const Gh=typeof document<"u"?document:null;function is(t=null,r={target:Gh,actInsideInputWithModifier:!0}){const[o,s]=L.useState(!1),a=L.useRef(!1),u=L.useRef(new Set([])),[c,h]=L.useMemo(()=>{if(t!==null){const x=(Array.isArray(t)?t:[t]).filter(y=>typeof y=="string").map(y=>y.replace(/\+/g,` +`).replace(` + +`,` ++`).split(` +`)),m=x.reduce((y,v)=>y.concat(...v),[]);return[x,m]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Gh,x=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const m=_=>{var E,w;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!x)&&hg(_))return!1;const j=Xh(_.code,h);if(u.current.add(_[j]),Yh(c,u.current,!1)){const C=((w=(E=_.composedPath)==null?void 0:E.call(_))==null?void 0:w[0])||_.target,k=(C==null?void 0:C.nodeName)==="BUTTON"||(C==null?void 0:C.nodeName)==="A";r.preventDefault!==!1&&(a.current||!k)&&_.preventDefault(),s(!0)}},y=_=>{const N=Xh(_.code,h);Yh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[N]),_.key==="Meta"&&u.current.clear(),a.current=!1},v=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",m),p==null||p.addEventListener("keyup",y),window.addEventListener("blur",v),window.addEventListener("contextmenu",v),()=>{p==null||p.removeEventListener("keydown",m),p==null||p.removeEventListener("keyup",y),window.removeEventListener("blur",v),window.removeEventListener("contextmenu",v)}}},[t,s]),o}function Yh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Xh(t,r){return r.includes(t)?"code":"key"}const C_=()=>{const t=Ge();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=_c(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),x={x:r.x-h,y:r.y-p},m=o.snapGrid??a,y=o.snapToGrid??u;return ds(x,s,y,m)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=Zi(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function Ag(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)M_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function M_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function P_(t,r){return Ag(t,r)}function I_(t,r){return Ag(t,r)}function ti(t,r){return{id:t,type:"select",selected:r}}function Ui(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(ti(u.id,c)))}return s}function qh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Kh(t){return{id:t.id,type:"remove"}}const R_=ug();function T_(t,r,o={}){return m1(t,r,{...o,onError:o.onError??R_})}const Qh=t=>t1(t),L_=t=>ig(t);function $g(t){return L.forwardRef(t)}const zg=typeof window<"u"?L.useLayoutEffect:L.useEffect;function Zh(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>A_(()=>o(a=>a+BigInt(1))));return zg(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function A_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Dg=L.createContext(null);function $_({children:t}){const r=Ge(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:x,hasDefaultNodes:m,onNodesChange:y,nodeLookup:v,fitViewQueued:_,onNodesChangeMiddlewareMap:N}=r.getState();let j=p;for(const w of h)j=typeof w=="function"?w(j):w;let E=qh({items:j,lookup:v});for(const w of N.values())E=w(E);m&&x(j),E.length>0?y==null||y(E):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:w,nodes:C,setNodes:k}=r.getState();w&&k(C)})},[]),s=Zh(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:x,hasDefaultEdges:m,onEdgesChange:y,edgeLookup:v}=r.getState();let _=p;for(const N of h)_=typeof N=="function"?N(_):N;m?x(_):y&&y(qh({items:_,lookup:v}))},[]),u=Zh(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Dg.Provider,{value:c,children:t})}function z_(){const t=L.useContext(Dg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const D_=t=>!!t.panZoom;function ql(){const t=C_(),r=Ge(),o=z_(),s=ze(D_),a=L.useMemo(()=>{const u=y=>r.getState().nodeLookup.get(y),c=y=>{o.nodeQueue.push(y)},h=y=>{o.edgeQueue.push(y)},p=y=>{var w,C;const{nodeLookup:v,nodeOrigin:_}=r.getState(),N=Qh(y)?y:v.get(y.id),j=N.parentId?dg(N.position,N.measured,N.parentId,v,_):N.position,E={...N,position:j,width:((w=N.measured)==null?void 0:w.width)??N.width,height:((C=N.measured)==null?void 0:C.height)??N.height};return ns(E)},x=(y,v,_={replace:!1})=>{c(N=>N.map(j=>{if(j.id===y){const E=typeof v=="function"?v(j):v;return _.replace&&Qh(E)?E:{...j,...E}}return j}))},m=(y,v,_={replace:!1})=>{h(N=>N.map(j=>{if(j.id===y){const E=typeof v=="function"?v(j):v;return _.replace&&L_(E)?E:{...j,...E}}return j}))};return{getNodes:()=>r.getState().nodes.map(y=>({...y})),getNode:y=>{var v;return(v=u(y))==null?void 0:v.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:y=[]}=r.getState();return y.map(v=>({...v}))},getEdge:y=>r.getState().edgeLookup.get(y),setNodes:c,setEdges:h,addNodes:y=>{const v=Array.isArray(y)?y:[y];o.nodeQueue.push(_=>[..._,...v])},addEdges:y=>{const v=Array.isArray(y)?y:[y];o.edgeQueue.push(_=>[..._,...v])},toObject:()=>{const{nodes:y=[],edges:v=[],transform:_}=r.getState(),[N,j,E]=_;return{nodes:y.map(w=>({...w})),edges:v.map(w=>({...w})),viewport:{x:N,y:j,zoom:E}}},deleteElements:async({nodes:y=[],edges:v=[]})=>{const{nodes:_,edges:N,onNodesDelete:j,onEdgesDelete:E,triggerNodeChanges:w,triggerEdgeChanges:C,onDelete:k,onBeforeDelete:b}=r.getState(),{nodes:A,edges:z}=await s1({nodesToRemove:y,edgesToRemove:v,nodes:_,edges:N,onBeforeDelete:b}),V=z.length>0,Y=A.length>0;if(V){const K=z.map(Kh);E==null||E(z),C(K)}if(Y){const K=A.map(Kh);j==null||j(A),w(K)}return(Y||V)&&(k==null||k({nodes:A,edges:z})),{deletedNodes:A,deletedEdges:z}},getIntersectingNodes:(y,v=!0,_)=>{const N=Sh(y),j=N?y:p(y),E=_!==void 0;return j?(_||r.getState().nodes).filter(w=>{const C=r.getState().nodeLookup.get(w.id);if(C&&!N&&(w.id===y.id||!C.internals.positionAbsolute))return!1;const k=ns(E?w:C),b=$l(k,j);return v&&b>0||b>=k.width*k.height||b>=j.width*j.height}):[]},isNodeIntersecting:(y,v,_=!0)=>{const j=Sh(y)?y:p(y);if(!j)return!1;const E=$l(j,v);return _&&E>0||E>=v.width*v.height||E>=j.width*j.height},updateNode:x,updateNodeData:(y,v,_={replace:!1})=>{x(y,N=>{const j=typeof v=="function"?v(N):v;return _.replace?{...N,data:j}:{...N,data:{...N.data,...j}}},_)},updateEdge:m,updateEdgeData:(y,v,_={replace:!1})=>{m(y,N=>{const j=typeof v=="function"?v(N):v;return _.replace?{...N,data:j}:{...N,data:{...N.data,...j}}},_)},getNodesBounds:y=>{const{nodeLookup:v,nodeOrigin:_}=r.getState();return n1(y,{nodeLookup:v,nodeOrigin:_})},getHandleConnections:({type:y,id:v,nodeId:_})=>{var N;return Array.from(((N=r.getState().connectionLookup.get(`${_}-${y}${v?`-${v}`:""}`))==null?void 0:N.values())??[])},getNodeConnections:({type:y,handleId:v,nodeId:_})=>{var N;return Array.from(((N=r.getState().connectionLookup.get(`${_}${y?v?`-${y}-${v}`:`-${y}`:""}`))==null?void 0:N.values())??[])},fitView:async y=>{const v=r.getState().fitViewResolver??u1();return r.setState({fitViewQueued:!0,fitViewOptions:y,fitViewResolver:v}),o.nodeQueue.push(_=>[..._]),v.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const Jh=t=>t.selected,O_=typeof window<"u"?window:void 0;function F_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ge(),{deleteElements:s}=ql(),a=is(t,{actInsideInputWithModifier:!1}),u=is(r,{target:O_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(Jh),edges:c.filter(Jh)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function H_(t){const r=Ge();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=Sc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",yn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const Kl={position:"absolute",width:"100%",height:"100%",top:0,left:0},B_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function V_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=ii.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:x,translateExtent:m,minZoom:y,maxZoom:v,zoomActivationKeyCode:_,preventScrolling:N=!0,children:j,noWheelClassName:E,noPanClassName:w,onViewportChange:C,isControlledViewport:k,paneClickDistance:b,selectionOnDrag:A}){const z=Ge(),V=L.useRef(null),{userSelectionActive:Y,lib:K,connectionInProgress:re}=ze(B_,Qe),q=is(_),Z=L.useRef();H_(V);const te=L.useCallback(R=>{C==null||C({x:R[0],y:R[1],zoom:R[2]}),k||z.setState({transform:R})},[C,k]);return L.useEffect(()=>{if(V.current){Z.current=G1({domNode:V.current,minZoom:y,maxZoom:v,translateExtent:m,viewport:x,onDraggingChange:W=>z.setState(M=>M.paneDragging===W?M:{paneDragging:W}),onPanZoomStart:(W,M)=>{const{onViewportChangeStart:D,onMoveStart:F}=z.getState();F==null||F(W,M),D==null||D(M)},onPanZoom:(W,M)=>{const{onViewportChange:D,onMove:F}=z.getState();F==null||F(W,M),D==null||D(M)},onPanZoomEnd:(W,M)=>{const{onViewportChangeEnd:D,onMoveEnd:F}=z.getState();F==null||F(W,M),D==null||D(M)}});const{x:R,y:U,zoom:H}=Z.current.getViewport();return z.setState({panZoom:Z.current,transform:[R,U,H],domNode:V.current.closest(".react-flow")}),()=>{var W;(W=Z.current)==null||W.destroy()}}},[]),L.useEffect(()=>{var R;(R=Z.current)==null||R.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:q,preventScrolling:N,noPanClassName:w,userSelectionActive:Y,noWheelClassName:E,lib:K,onTransformChange:te,connectionInProgress:re,selectionOnDrag:A,paneClickDistance:b})},[t,r,o,s,a,u,c,h,p,q,N,w,Y,E,K,te,re,A,b]),d.jsx("div",{className:"react-flow__renderer",ref:V,style:Kl,children:j})}const W_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function U_(){const{userSelectionActive:t,userSelectionRect:r}=ze(W_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const Vu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},G_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function Y_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=es.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:x,onPaneContextMenu:m,onPaneScroll:y,onPaneMouseEnter:v,onPaneMouseMove:_,onPaneMouseLeave:N,children:j}){const E=L.useRef(0),w=Ge(),{userSelectionActive:C,elementsSelectable:k,dragging:b,panBy:A,autoPanSpeed:z}=ze(G_,Qe),V=k&&(t||C),Y=L.useRef(null),K=L.useRef(),re=L.useRef(new Set),q=L.useRef(new Set),Z=L.useRef(!1),te=L.useRef(!1),R=L.useRef({x:0,y:0}),U=L.useRef(!1),H=J=>{if(te.current||Z.current||w.getState().connection.inProgress){te.current=!1,Z.current=!1;return}x==null||x(J),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},W=J=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){J.preventDefault();return}m==null||m(J)},M=y?J=>y(J):void 0,D=J=>{te.current&&(J.stopPropagation(),te.current=!1)},F=J=>{var De,ht;if(J.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:ae,transform:me}=w.getState();if(K.current=ae==null?void 0:ae.getBoundingClientRect(),!K.current)return;const Ne=J.target===Y.current;if(!Ne&&!!J.target.closest(".nokey")||!t||!(c&&Ne||r)||J.button!==0||!J.isPrimary)return;(ht=(De=J.target)==null?void 0:De.setPointerCapture)==null||ht.call(De,J.pointerId),te.current=!1;const{x:je,y:Me}=mn(J.nativeEvent,K.current),Te=ds({x:je,y:Me},me);w.setState({userSelectionRect:{width:0,height:0,startX:Te.x,startY:Te.y,x:je,y:Me}}),Ne||(J.stopPropagation(),J.preventDefault())};function I(J,ae){const{userSelectionRect:me}=w.getState();if(!me)return;const{transform:Ne,nodeLookup:xe,edgeLookup:ne,connectionLookup:je,triggerNodeChanges:Me,triggerEdgeChanges:Te,defaultEdgeOptions:De}=w.getState(),ht={x:me.startX,y:me.startY},{x:Je,y:Xe}=Zi(ht,Ne),lt={startX:ht.x,startY:ht.y,x:Jat.id)),q.current=new Set;const qt=(De==null?void 0:De.selectable)??!0;for(const at of re.current){const et=je.get(at);if(et)for(const{edgeId:vt}of et.values()){const xt=ne.get(vt);xt&&(xt.selectable??qt)&&q.current.add(vt)}}if(!kh(yt,re.current)){const at=Ui(xe,re.current,!0);Me(at)}if(!kh(Dt,q.current)){const at=Ui(ne,q.current);Te(at)}w.setState({userSelectionRect:lt,userSelectionActive:!0,nodesSelectionActive:!1})}function $(){if(!a||!K.current)return;const[J,ae]=wc(R.current,K.current,z);A({x:J,y:ae}).then(me=>{if(!te.current||!me){E.current=requestAnimationFrame($);return}const{x:Ne,y:xe}=R.current;I(Ne,xe),E.current=requestAnimationFrame($)})}const ie=()=>{cancelAnimationFrame(E.current),E.current=0,U.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=J=>{const{userSelectionRect:ae,transform:me,resetSelectedElements:Ne}=w.getState();if(!K.current||!ae)return;const{x:xe,y:ne}=mn(J.nativeEvent,K.current);R.current={x:xe,y:ne};const je=Zi({x:ae.startX,y:ae.startY},me);if(!te.current){const Me=r?0:u;if(Math.hypot(xe-je.x,ne-je.y)<=Me)return;Ne(),h==null||h(J)}te.current=!0,U.current||($(),U.current=!0),I(xe,ne)},fe=J=>{var ae,me;if(!V){J.target===Y.current&&w.getState().connection.inProgress&&(Z.current=!0);return}J.button===0&&((me=(ae=J.target)==null?void 0:ae.releasePointerCapture)==null||me.call(ae,J.pointerId),!C&&J.target===Y.current&&w.getState().userSelectionRect&&(H==null||H(J)),w.setState({userSelectionActive:!1,userSelectionRect:null}),te.current&&(p==null||p(J),w.setState({nodesSelectionActive:re.current.size>0})),ie())},he=J=>{var ae,me;(me=(ae=J.target)==null?void 0:ae.releasePointerCapture)==null||me.call(ae,J.pointerId),ie()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:it(["react-flow__pane",{draggable:pe,dragging:b,selection:t}]),onClick:V?void 0:Vu(H,Y),onContextMenu:Vu(W,Y),onWheel:Vu(M,Y),onPointerEnter:V?void 0:v,onPointerMove:V?oe:_,onPointerUp:fe,onPointerCancel:V?he:void 0,onPointerDownCapture:V?F:void 0,onClickCapture:V?D:void 0,onPointerLeave:N,ref:Y,style:Kl,children:[j,d.jsx(U_,{})]})}function ac({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),x=h.get(t);if(!x){p==null||p("012",yn.error012(t));return}r.setState({nodesSelectionActive:!1}),x.selected?(o||x.selected&&c)&&(u({nodes:[x],edges:[]}),requestAnimationFrame(()=>{var m;return(m=s==null?void 0:s.current)==null?void 0:m.blur()})):a([t])}function Og({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ge(),[p,x]=L.useState(!1),m=L.useRef();return L.useEffect(()=>{if(!r)return m.current=R1({getStoreItems:()=>h.getState(),onNodeMouseDown:y=>{ac({id:y,store:h,nodeRef:t})},onDragStart:()=>{x(!0)},onDragStop:()=>{x(!1)}}),()=>{var y;(y=m.current)==null||y.destroy(),m.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!m.current||m.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const X_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Fg(){const t=Ge();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:x,nodeOrigin:m}=t.getState(),y=new Map,v=X_(c),_=a?u[0]:5,N=a?u[1]:5,j=o.direction.x*_*o.factor,E=o.direction.y*N*o.factor;for(const[,w]of x){if(!v(w))continue;let C={x:w.internals.positionAbsolute.x+j,y:w.internals.positionAbsolute.y+E};a&&(C=cs(C,u));const{position:k,positionAbsolute:b}=og({nodeId:w.id,nextPosition:C,nodeLookup:x,nodeExtent:s,nodeOrigin:m,onError:h});w.position=k,w.internals.positionAbsolute=b,y.set(w.id,w)}p(y)},[])}const Cc=L.createContext(null),q_=Cc.Provider;Cc.Consumer;const Hg=()=>L.useContext(Cc),K_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Bg=L.createContext(null);function Q_({children:t}){const r=ze(K_,Qe);return d.jsx(Bg.Provider,{value:r,children:t})}function Z_(){const t=L.useContext(Bg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const J_={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},eS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:x}=c;if(!h&&!a)return J_;const m=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:m,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Ki.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:m&&x}};function tS({type:t="source",position:r=ke.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:x,onMouseDown:m,onTouchStart:y,...v},_){var U,H;const N=c||null,j=t==="target",E=Ge(),w=Hg(),{connectOnClick:C,noPanClassName:k,rfId:b}=Z_(),{connectingFrom:A,connectingTo:z,clickConnecting:V,isPossibleEndHandle:Y,connectionInProcess:K,clickConnectionInProcess:re,valid:q}=ze(eS(w,N,t),Qe);w||(H=(U=E.getState()).onError)==null||H.call(U,"010",yn.error010());const Z=W=>{const{defaultEdgeOptions:M,onConnect:D,hasDefaultEdges:F}=E.getState(),I={...M,...W};if(F){const{edges:$,setEdges:ie,onError:oe}=E.getState();ie(T_(I,$,{onError:oe}))}D==null||D(I),h==null||h(I)},te=W=>{if(!w)return;const M=pg(W.nativeEvent);if(a&&(M&&W.button===0||!M)){const D=E.getState();lc.onPointerDown(W.nativeEvent,{handleDomNode:W.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:j,handleId:N,nodeId:w,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...F)=>{var I,$;return($=(I=E.getState()).onConnectEnd)==null?void 0:$.call(I,...F)},updateConnection:D.updateConnection,onConnect:Z,isValidConnection:o||((...F)=>{var I,$;return(($=(I=E.getState()).isValidConnection)==null?void 0:$.call(I,...F))??!0}),getTransform:()=>E.getState().transform,getFromHandle:()=>E.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}M?m==null||m(W):y==null||y(W)},R=W=>{const{onClickConnectStart:M,onClickConnectEnd:D,connectionClickStartHandle:F,connectionMode:I,isValidConnection:$,lib:ie,rfId:oe,nodeLookup:fe,connection:he}=E.getState();if(!w||!F&&!a)return;if(!F){M==null||M(W.nativeEvent,{nodeId:w,handleId:N,handleType:t}),E.setState({connectionClickStartHandle:{nodeId:w,type:t,id:N}});return}const pe=fg(W.target),J=o||$,{connection:ae,isValid:me}=lc.isValid(W.nativeEvent,{handle:{nodeId:w,id:N,type:t},connectionMode:I,fromNodeId:F.nodeId,fromHandleId:F.id||null,fromType:F.type,isValidConnection:J,flowId:oe,doc:pe,lib:ie,nodeLookup:fe});me&&ae&&Z(ae);const Ne=structuredClone(he);delete Ne.inProgress,Ne.toPosition=Ne.toHandle?Ne.toHandle.position:null,D==null||D(W,Ne),E.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":N,"data-nodeid":w,"data-handlepos":r,"data-id":`${b}-${w}-${N}-${t}`,className:it(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",k,x,{source:!j,target:j,connectable:s,connectablestart:a,connectableend:u,clickconnecting:V,connectingfrom:A,connectingto:z,valid:q,connectionindicator:s&&(!K||Y)&&(K||re?u:a)}]),onMouseDown:te,onTouchStart:te,onClick:C?R:void 0,ref:_,...v,children:p})}const eo=L.memo($g(tS));function nS({data:t,isConnectable:r,sourcePosition:o=ke.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(eo,{type:"source",position:o,isConnectable:r})]})}function rS({data:t,isConnectable:r,targetPosition:o=ke.Top,sourcePosition:s=ke.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(eo,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(eo,{type:"source",position:s,isConnectable:r})]})}function iS(){return null}function oS({data:t,isConnectable:r,targetPosition:o=ke.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(eo,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const zl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},ep={input:nS,default:rS,output:oS,group:iS};function sS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const lS=t=>{const{width:r,height:o,x:s,y:a}=us(t.nodeLookup,{filter:u=>!!u.selected});return{width:gn(r)?r:null,height:gn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function aS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ge(),{width:a,height:u,transformString:c,userSelectionActive:h}=ze(lS,Qe),p=Fg(),x=L.useRef(null);L.useEffect(()=>{var _;o||(_=x.current)==null||_.focus({preventScroll:!0})},[o]);const m=!h&&a!==null&&u!==null;if(Og({nodeRef:x,disabled:!m}),!m)return null;const y=t?_=>{const N=s.getState().nodes.filter(j=>j.selected);t(_,N)}:void 0,v=_=>{Object.prototype.hasOwnProperty.call(zl,_.key)&&(_.preventDefault(),p({direction:zl[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:it(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:x,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:o?void 0:-1,onKeyDown:o?void 0:v,style:{width:a,height:u}})})}const tp=typeof window<"u"?window:void 0,uS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Vg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:x,selectionOnDrag:m,selectionMode:y,onSelectionStart:v,onSelectionEnd:_,multiSelectionKeyCode:N,panActivationKeyCode:j,zoomActivationKeyCode:E,elementsSelectable:w,zoomOnScroll:C,zoomOnPinch:k,panOnScroll:b,panOnScrollSpeed:A,panOnScrollMode:z,zoomOnDoubleClick:V,panOnDrag:Y,autoPanOnSelection:K,defaultViewport:re,translateExtent:q,minZoom:Z,maxZoom:te,preventScrolling:R,onSelectionContextMenu:U,noWheelClassName:H,noPanClassName:W,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:F}){const{nodesSelectionActive:I,userSelectionActive:$}=ze(uS,Qe),ie=is(x,{target:tp}),oe=is(j,{target:tp}),fe=oe||Y,he=oe||b,pe=m&&fe!==!0,J=ie||$||pe;return F_({deleteKeyCode:p,multiSelectionKeyCode:N}),d.jsx(V_,{onPaneContextMenu:u,elementsSelectable:w,zoomOnScroll:C,zoomOnPinch:k,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:A,panOnScrollMode:z,zoomOnDoubleClick:V,panOnDrag:!ie&&fe,defaultViewport:re,translateExtent:q,minZoom:Z,maxZoom:te,zoomActivationKeyCode:E,preventScrolling:R,noWheelClassName:H,noPanClassName:W,onViewportChange:D,isControlledViewport:F,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(Y_,{onSelectionStart:v,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:K,isSelecting:!!J,selectionMode:y,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:pe,children:[t,I&&d.jsx(aS,{onSelectionContextMenu:U,noPanClassName:W,disableKeyboardA11y:M})]})})}Vg.displayName="FlowRenderer";const cS=L.memo(Vg),dS=t=>r=>t?xc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function fS(t){return ze(L.useCallback(dS(t),[t]),Qe)}const hS=t=>t.updateNodeInternals;function pS(){const t=ze(hS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function gS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ge(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),x=L.useRef(r),m=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!m||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[m,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const y=x.current!==r,v=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(y||v||_)&&(x.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function mS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:x,nodesFocusable:m,resizeObserver:y,noDragClassName:v,noPanClassName:_,disableKeyboardA11y:N,rfId:j,nodeTypes:E,nodeClickDistance:w,onError:C}){const{node:k,internals:b,isParent:A}=ze(J=>{const ae=J.nodeLookup.get(t),me=J.parentLookup.has(t);return{node:ae,internals:ae.internals,isParent:me}},Qe);let z=k.type||"default",V=(E==null?void 0:E[z])||ep[z];V===void 0&&(C==null||C("003",yn.error003(z)),z="default",V=(E==null?void 0:E.default)||ep.default);const Y=!!(k.draggable||h&&typeof k.draggable>"u"),K=!!(k.selectable||p&&typeof k.selectable>"u"),re=!!(k.connectable||x&&typeof k.connectable>"u"),q=!!(k.focusable||m&&typeof k.focusable>"u"),Z=Ge(),te=cg(k),R=gS({node:k,nodeType:z,hasDimensions:te,resizeObserver:y}),U=Og({nodeRef:R,disabled:k.hidden||!Y,noDragClassName:v,handleSelector:k.dragHandle,nodeId:t,isSelectable:K,nodeClickDistance:w}),H=Fg();if(k.hidden)return null;const W=xn(k),M=sS(k),D=K||Y||r||o||s||a,F=o?J=>o(J,{...b.userNode}):void 0,I=s?J=>s(J,{...b.userNode}):void 0,$=a?J=>a(J,{...b.userNode}):void 0,ie=u?J=>u(J,{...b.userNode}):void 0,oe=c?J=>c(J,{...b.userNode}):void 0,fe=J=>{const{selectNodesOnDrag:ae,nodeDragThreshold:me}=Z.getState();K&&(!ae||!Y||me>0)&&ac({id:t,store:Z,nodeRef:R}),r&&r(J,{...b.userNode})},he=J=>{if(!(hg(J.nativeEvent)||N)){if(eg.includes(J.key)&&K){const ae=J.key==="Escape";ac({id:t,store:Z,unselect:ae,nodeRef:R})}else if(Y&&k.selected&&Object.prototype.hasOwnProperty.call(zl,J.key)){J.preventDefault();const{ariaLabelConfig:ae}=Z.getState();Z.setState({ariaLiveMessage:ae["node.a11yDescription.ariaLiveMessage"]({direction:J.key.replace("Arrow","").toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),H({direction:zl[J.key],factor:J.shiftKey?4:1})}}},pe=()=>{var je;if(N||!((je=R.current)!=null&&je.matches(":focus-visible")))return;const{transform:J,width:ae,height:me,autoPanOnNodeFocus:Ne,setCenter:xe}=Z.getState();if(!Ne)return;xc(new Map([[t,k]]),{x:0,y:0,width:ae,height:me},J,!0).length>0||xe(k.position.x+W.width/2,k.position.y+W.height/2,{zoom:J[2]})};return d.jsx("div",{className:it(["react-flow__node",`react-flow__node-${z}`,{[_]:Y},k.className,{selected:k.selected,selectable:K,parent:A,draggable:Y,dragging:U}]),ref:R,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:te?"visible":"hidden",...k.style,...M},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:F,onMouseMove:I,onMouseLeave:$,onContextMenu:ie,onClick:fe,onDoubleClick:oe,onKeyDown:q?he:void 0,tabIndex:q?0:void 0,onFocus:q?pe:void 0,role:k.ariaRole??(q?"group":void 0),"aria-roledescription":"node","aria-describedby":N?void 0:`${Rg}-${j}`,"aria-label":k.ariaLabel,...k.domAttributes,children:d.jsx(q_,{value:t,children:d.jsx(V,{id:t,data:k.data,type:z,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:k.selected??!1,selectable:K,draggable:Y,deletable:k.deletable??!0,isConnectable:re,sourcePosition:k.sourcePosition,targetPosition:k.targetPosition,dragging:U,dragHandle:k.dragHandle,zIndex:b.z,parentId:k.parentId,...W})})})}var yS=L.memo(mS);const vS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Wg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=ze(vS,Qe),u=fS(t.onlyRenderVisibleElements),c=pS();return d.jsx("div",{className:"react-flow__nodes",style:Kl,children:u.map(h=>d.jsx(yS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Wg.displayName="NodeRenderer";const xS=L.memo(Wg);function wS(t){return ze(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&h1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const _S=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},SS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},np={[ts.Arrow]:_S,[ts.ArrowClosed]:SS};function kS(t){const r=Ge();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(np,t)?np[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",yn.error009(t)),null)},[t])}const NS=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=kS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},Ug=({defaultColor:t,rfId:r})=>{const o=ze(u=>u.edges),s=ze(u=>u.defaultEdgeOptions),a=L.useMemo(()=>_1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(NS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Ug.displayName="MarkerDefinitions";var jS=L.memo(Ug);function Gg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:x,...m}){const[y,v]=L.useState({x:1,y:0,width:0,height:0}),_=it(["react-flow__edge-textwrapper",x]),N=L.useRef(null);return L.useEffect(()=>{if(N.current){const j=N.current.getBBox();v({x:j.x,y:j.y,width:j.width,height:j.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-y.width/2} ${r-y.height/2})`,className:_,visibility:y.width?"visible":"hidden",...m,children:[a&&d.jsx("rect",{width:y.width+2*c[0],x:-c[0],y:-c[1],height:y.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:N,style:s,children:o}),p]}):null}Gg.displayName="EdgeText";const bS=L.memo(Gg);function Ql({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:x=20,...m}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...m,d:t,fill:"none",className:it(["react-flow__edge-path",m.className])}),x?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:x,className:"react-flow__edge-interaction"}):null,s&&gn(r)&&gn(o)?d.jsx(bS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function rp({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===ke.Left||t===ke.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function Yg({sourceX:t,sourceY:r,sourcePosition:o=ke.Bottom,targetX:s,targetY:a,targetPosition:u=ke.Top}){const[c,h]=rp({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,x]=rp({pos:u,x1:s,y1:a,x2:t,y2:r}),[m,y,v,_]=gg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:x});return[`M${t},${r} C${c},${h} ${p},${x} ${s},${a}`,m,y,v,_]}function Xg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:x,labelShowBg:m,labelBgStyle:y,labelBgPadding:v,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,interactionWidth:w})=>{const[C,k,b]=Yg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),A=t.isInternal?void 0:r;return d.jsx(Ql,{id:A,path:C,labelX:k,labelY:b,label:p,labelStyle:x,labelShowBg:m,labelBgStyle:y,labelBgPadding:v,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,interactionWidth:w})})}const ES=Xg({isInternal:!1}),qg=Xg({isInternal:!0});ES.displayName="SimpleBezierEdge";qg.displayName="SimpleBezierEdgeInternal";function Kg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:m,labelBgBorderRadius:y,style:v,sourcePosition:_=ke.Bottom,targetPosition:N=ke.Top,markerEnd:j,markerStart:E,pathOptions:w,interactionWidth:C})=>{const[k,b,A]=ic({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:N,borderRadius:w==null?void 0:w.borderRadius,offset:w==null?void 0:w.offset,stepPosition:w==null?void 0:w.stepPosition}),z=t.isInternal?void 0:r;return d.jsx(Ql,{id:z,path:k,labelX:b,labelY:A,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:m,labelBgBorderRadius:y,style:v,markerEnd:j,markerStart:E,interactionWidth:C})})}const Qg=Kg({isInternal:!1}),Zg=Kg({isInternal:!0});Qg.displayName="SmoothStepEdge";Zg.displayName="SmoothStepEdgeInternal";function Jg(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(Qg,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const CS=Jg({isInternal:!1}),em=Jg({isInternal:!0});CS.displayName="StepEdge";em.displayName="StepEdgeInternal";function tm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:m,labelBgBorderRadius:y,style:v,markerEnd:_,markerStart:N,interactionWidth:j})=>{const[E,w,C]=vg({sourceX:o,sourceY:s,targetX:a,targetY:u}),k=t.isInternal?void 0:r;return d.jsx(Ql,{id:k,path:E,labelX:w,labelY:C,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:m,labelBgBorderRadius:y,style:v,markerEnd:_,markerStart:N,interactionWidth:j})})}const MS=tm({isInternal:!1}),nm=tm({isInternal:!0});MS.displayName="StraightEdge";nm.displayName="StraightEdgeInternal";function rm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=ke.Bottom,targetPosition:h=ke.Top,label:p,labelStyle:x,labelShowBg:m,labelBgStyle:y,labelBgPadding:v,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,pathOptions:w,interactionWidth:C})=>{const[k,b,A]=mg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:w==null?void 0:w.curvature}),z=t.isInternal?void 0:r;return d.jsx(Ql,{id:z,path:k,labelX:b,labelY:A,label:p,labelStyle:x,labelShowBg:m,labelBgStyle:y,labelBgPadding:v,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,interactionWidth:C})})}const PS=rm({isInternal:!1}),im=rm({isInternal:!0});PS.displayName="BezierEdge";im.displayName="BezierEdgeInternal";const ip={default:im,straight:nm,step:em,smoothstep:Zg,simplebezier:qg},op={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},IS=(t,r,o)=>o===ke.Left?t-r:o===ke.Right?t+r:t,RS=(t,r,o)=>o===ke.Top?t-r:o===ke.Bottom?t+r:t,sp="react-flow__edgeupdater";function lp({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:it([sp,`${sp}-${h}`]),cx:IS(r,s,t),cy:RS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function TS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:x,onReconnectStart:m,onReconnectEnd:y,setReconnecting:v,setUpdateHover:_}){const N=Ge(),j=(b,A)=>{if(b.button!==0)return;const{autoPanOnConnect:z,domNode:V,connectionMode:Y,connectionRadius:K,lib:re,onConnectStart:q,cancelConnection:Z,nodeLookup:te,rfId:R,panBy:U,updateConnection:H}=N.getState(),W=A.type==="target",M=(I,$)=>{v(!1),y==null||y(I,o,A.type,$)},D=I=>x==null?void 0:x(o,I),F=(I,$)=>{v(!0),m==null||m(b,o,A.type),q==null||q(I,$)};lc.onPointerDown(b.nativeEvent,{autoPanOnConnect:z,connectionMode:Y,connectionRadius:K,domNode:V,handleId:A.id,nodeId:A.nodeId,nodeLookup:te,isTarget:W,edgeUpdaterType:A.type,lib:re,flowId:R,cancelConnection:Z,panBy:U,isValidConnection:(...I)=>{var $,ie;return((ie=($=N.getState()).isValidConnection)==null?void 0:ie.call($,...I))??!0},onConnect:D,onConnectStart:F,onConnectEnd:(...I)=>{var $,ie;return(ie=($=N.getState()).onConnectEnd)==null?void 0:ie.call($,...I)},onReconnectEnd:M,updateConnection:H,getTransform:()=>N.getState().transform,getFromHandle:()=>N.getState().connection.fromHandle,dragThreshold:N.getState().connectionDragThreshold,handleDomNode:b.currentTarget})},E=b=>j(b,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),w=b=>j(b,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),C=()=>_(!0),k=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(lp,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:E,onMouseEnter:C,onMouseOut:k,type:"source"}),(t===!0||t==="target")&&d.jsx(lp,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:w,onMouseEnter:C,onMouseOut:k,type:"target"})]})}function LS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:x,reconnectRadius:m,onReconnect:y,onReconnectStart:v,onReconnectEnd:_,rfId:N,edgeTypes:j,noPanClassName:E,onError:w,disableKeyboardA11y:C}){let k=ze(xe=>xe.edgeLookup.get(t));const b=ze(xe=>xe.defaultEdgeOptions);k=b?{...b,...k}:k;let A=k.type||"default",z=(j==null?void 0:j[A])||ip[A];z===void 0&&(w==null||w("011",yn.error011(A)),A="default",z=(j==null?void 0:j.default)||ip.default);const V=!!(k.focusable||r&&typeof k.focusable>"u"),Y=typeof y<"u"&&(k.reconnectable||o&&typeof k.reconnectable>"u"),K=!!(k.selectable||s&&typeof k.selectable>"u"),re=L.useRef(null),[q,Z]=L.useState(!1),[te,R]=L.useState(!1),U=Ge(),{zIndex:H=k.zIndex,sourceX:W,sourceY:M,targetX:D,targetY:F,sourcePosition:I,targetPosition:$}=ze(L.useCallback(xe=>{const ne=xe.nodeLookup.get(k.source),je=xe.nodeLookup.get(k.target);if(!ne||!je)return op;const Me=w1({id:t,sourceNode:ne,targetNode:je,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:xe.connectionMode,onError:w}),Te=f1({selected:k.selected,zIndex:k.zIndex,sourceNode:ne,targetNode:je,elevateOnSelect:xe.elevateEdgesOnSelect,zIndexMode:xe.zIndexMode});return{...Me||op,zIndex:Te}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex,w]),Qe),ie=L.useMemo(()=>k.markerStart?`url('#${oc(k.markerStart,N)}')`:void 0,[k.markerStart,N]),oe=L.useMemo(()=>k.markerEnd?`url('#${oc(k.markerEnd,N)}')`:void 0,[k.markerEnd,N]);if(k.hidden||W===null||M===null||D===null||F===null)return null;const fe=xe=>{var Te;const{addSelectedEdges:ne,unselectNodesAndEdges:je,multiSelectionActive:Me}=U.getState();K&&(U.setState({nodesSelectionActive:!1}),k.selected&&Me?(je({nodes:[],edges:[k]}),(Te=re.current)==null||Te.blur()):ne([t])),a&&a(xe,k)},he=u?xe=>{u(xe,{...k})}:void 0,pe=c?xe=>{c(xe,{...k})}:void 0,J=h?xe=>{h(xe,{...k})}:void 0,ae=p?xe=>{p(xe,{...k})}:void 0,me=x?xe=>{x(xe,{...k})}:void 0,Ne=xe=>{var ne;if(!C&&eg.includes(xe.key)&&K){const{unselectNodesAndEdges:je,addSelectedEdges:Me}=U.getState();xe.key==="Escape"?((ne=re.current)==null||ne.blur(),je({edges:[k]})):Me([t])}};return d.jsx("svg",{style:{zIndex:H},children:d.jsxs("g",{className:it(["react-flow__edge",`react-flow__edge-${A}`,k.className,E,{selected:k.selected,animated:k.animated,inactive:!K&&!a,updating:q,selectable:K}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:J,onMouseMove:ae,onMouseLeave:me,onKeyDown:V?Ne:void 0,tabIndex:V?0:void 0,role:k.ariaRole??(V?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":k.ariaLabel===null?void 0:k.ariaLabel||`Edge from ${k.source} to ${k.target}`,"aria-describedby":V?`${Tg}-${N}`:void 0,ref:re,...k.domAttributes,children:[!te&&d.jsx(z,{id:t,source:k.source,target:k.target,type:k.type,selected:k.selected,animated:k.animated,selectable:K,deletable:k.deletable??!0,label:k.label,labelStyle:k.labelStyle,labelShowBg:k.labelShowBg,labelBgStyle:k.labelBgStyle,labelBgPadding:k.labelBgPadding,labelBgBorderRadius:k.labelBgBorderRadius,sourceX:W,sourceY:M,targetX:D,targetY:F,sourcePosition:I,targetPosition:$,data:k.data,style:k.style,sourceHandleId:k.sourceHandle,targetHandleId:k.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in k?k.pathOptions:void 0,interactionWidth:k.interactionWidth}),Y&&d.jsx(TS,{edge:k,isReconnectable:Y,reconnectRadius:m,onReconnect:y,onReconnectStart:v,onReconnectEnd:_,sourceX:W,sourceY:M,targetX:D,targetY:F,sourcePosition:I,targetPosition:$,setUpdateHover:Z,setReconnecting:R})]})})}var AS=L.memo(LS);const $S=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function om({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:x,onEdgeClick:m,reconnectRadius:y,onEdgeDoubleClick:v,onReconnectStart:_,onReconnectEnd:N,disableKeyboardA11y:j}){const{edgesFocusable:E,edgesReconnectable:w,elementsSelectable:C,onError:k}=ze($S,Qe),b=wS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(jS,{defaultColor:t,rfId:o}),b.map(A=>d.jsx(AS,{id:A,edgesFocusable:E,edgesReconnectable:w,elementsSelectable:C,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:x,onClick:m,reconnectRadius:y,onDoubleClick:v,onReconnectStart:_,onReconnectEnd:N,rfId:o,onError:k,edgeTypes:s,disableKeyboardA11y:j},A))]})}om.displayName="EdgeRenderer";const zS=L.memo(om),ap=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function DS({children:t}){const r=Ge(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return zg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=ap(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:ap(s)},children:t})}function OS(t){const r=ql(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const FS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function HS(t){const r=ze(FS),o=Ge();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function BS(t){return t.connection.inProgress?{...t.connection,to:ds(t.connection.to,t.transform)}:{...t.connection}}function VS(t){return BS}function WS(t){const r=VS();return ze(r,Qe)}const US=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function GS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=ze(US,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:it(["react-flow__connection",rg(h)]),children:d.jsx(sm,{style:r,type:o,CustomComponent:s,isValid:h})})})}const sm=({style:t,type:r=Mr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:x,toNode:m,toHandle:y,toPosition:v,pointer:_}=WS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:x.x,toY:x.y,fromPosition:p,toPosition:v,connectionStatus:rg(s),toNode:m,toHandle:y,pointer:_});let N="";const j={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:x.x,targetY:x.y,targetPosition:v};switch(r){case Mr.Bezier:[N]=mg(j);break;case Mr.SimpleBezier:[N]=Yg(j);break;case Mr.Step:[N]=ic({...j,borderRadius:0});break;case Mr.SmoothStep:[N]=ic(j);break;default:[N]=vg(j)}return d.jsx("path",{d:N,fill:"none",className:"react-flow__connection-path",style:t})};sm.displayName="ConnectionLine";const YS={};function up(t=YS){L.useRef(t),Ge(),L.useEffect(()=>{},[t])}function XS(){Ge(),L.useRef(!1),L.useEffect(()=>{},[])}function lm({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:m,onSelectionContextMenu:y,onSelectionStart:v,onSelectionEnd:_,connectionLineType:N,connectionLineStyle:j,connectionLineComponent:E,connectionLineContainerStyle:w,selectionKeyCode:C,selectionOnDrag:k,selectionMode:b,multiSelectionKeyCode:A,panActivationKeyCode:z,zoomActivationKeyCode:V,deleteKeyCode:Y,onlyRenderVisibleElements:K,elementsSelectable:re,defaultViewport:q,translateExtent:Z,minZoom:te,maxZoom:R,preventScrolling:U,defaultMarkerColor:H,zoomOnScroll:W,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:F,panOnScrollMode:I,zoomOnDoubleClick:$,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:J,onPaneScroll:ae,onPaneContextMenu:me,paneClickDistance:Ne,nodeClickDistance:xe,onEdgeContextMenu:ne,onEdgeMouseEnter:je,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:De,onReconnect:ht,onReconnectStart:Je,onReconnectEnd:Xe,noDragClassName:lt,noWheelClassName:yt,noPanClassName:Dt,disableKeyboardA11y:qt,nodeExtent:at,rfId:et,viewport:vt,onViewportChange:xt,nodesDraggable:zn}){return up(t),up(r),XS(),OS(o),HS(vt),d.jsx(cS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:J,onPaneContextMenu:me,onPaneScroll:ae,paneClickDistance:Ne,deleteKeyCode:Y,selectionKeyCode:C,selectionOnDrag:k,selectionMode:b,onSelectionStart:v,onSelectionEnd:_,multiSelectionKeyCode:A,panActivationKeyCode:z,zoomActivationKeyCode:V,elementsSelectable:re,zoomOnScroll:W,zoomOnPinch:M,zoomOnDoubleClick:$,panOnScroll:D,panOnScrollSpeed:F,panOnScrollMode:I,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:q,translateExtent:Z,minZoom:te,maxZoom:R,onSelectionContextMenu:y,preventScrolling:U,noDragClassName:lt,noWheelClassName:yt,noPanClassName:Dt,disableKeyboardA11y:qt,onViewportChange:xt,isControlledViewport:!!vt,children:d.jsxs(DS,{children:[d.jsx(zS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:ht,onReconnectStart:Je,onReconnectEnd:Xe,onlyRenderVisibleElements:K,onEdgeContextMenu:ne,onEdgeMouseEnter:je,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:De,defaultMarkerColor:H,noPanClassName:Dt,disableKeyboardA11y:qt,rfId:et}),d.jsx(GS,{style:j,type:N,component:E,containerStyle:w}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(xS,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:m,nodeClickDistance:xe,onlyRenderVisibleElements:K,noPanClassName:Dt,noDragClassName:lt,disableKeyboardA11y:qt,nodeExtent:at,rfId:et,nodesDraggable:zn}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}lm.displayName="GraphView";const qS=L.memo(lm),KS=ug(),cp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:x=2,nodeOrigin:m,nodeExtent:y,zIndexMode:v="basic"}={})=>{const _=new Map,N=new Map,j=new Map,E=new Map,w=s??r??[],C=o??t??[],k=m??[0,0],b=y??Jo;_g(j,E,w);const{nodesInitialized:A}=sc(C,_,N,{nodeOrigin:k,nodeExtent:b,zIndexMode:v});let z=[0,0,1];if(c&&a&&u){const V=us(_,{filter:q=>!!((q.width||q.initialWidth)&&(q.height||q.initialHeight))}),{x:Y,y:K,zoom:re}=_c(V,a,u,p,x,(h==null?void 0:h.padding)??.1);z=[Y,K,re]}return{rfId:"1",width:a??0,height:u??0,transform:z,nodes:C,nodesInitialized:A,nodeLookup:_,parentLookup:N,edges:w,edgeLookup:E,connectionLookup:j,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:x,translateExtent:Jo,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ki.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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...ng},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:KS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:tg,zIndexMode:v,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},QS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:x,nodeOrigin:m,nodeExtent:y,zIndexMode:v})=>u_((_,N)=>{async function j(){const{nodeLookup:E,panZoom:w,fitViewOptions:C,fitViewResolver:k,width:b,height:A,minZoom:z,maxZoom:V}=N();w&&(await o1({nodes:E,width:b,height:A,panZoom:w,minZoom:z,maxZoom:V},C),k==null||k.resolve(!0),_({fitViewResolver:null}))}return{...cp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:x,nodeOrigin:m,nodeExtent:y,defaultNodes:o,defaultEdges:s,zIndexMode:v}),setNodes:E=>{const{nodeLookup:w,parentLookup:C,nodeOrigin:k,nodeExtent:b,elevateNodesOnSelect:A,fitViewQueued:z,zIndexMode:V,nodesSelectionActive:Y}=N(),{nodesInitialized:K,hasSelectedNodes:re}=sc(E,w,C,{nodeOrigin:k,nodeExtent:b,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:V}),q=Y&&re;z&&K?(j(),_({nodes:E,nodesInitialized:K,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:q})):_({nodes:E,nodesInitialized:K,nodesSelectionActive:q})},setEdges:E=>{const{connectionLookup:w,edgeLookup:C}=N();_g(w,C,E),_({edges:E})},setDefaultNodesAndEdges:(E,w)=>{if(E){const{setNodes:C}=N();C(E),_({hasDefaultNodes:!0})}if(w){const{setEdges:C}=N();C(w),_({hasDefaultEdges:!0})}},updateNodeInternals:E=>{const{triggerNodeChanges:w,nodeLookup:C,parentLookup:k,domNode:b,nodeOrigin:A,nodeExtent:z,debug:V,fitViewQueued:Y,zIndexMode:K}=N(),{changes:re,updatedInternals:q}=C1(E,C,k,b,A,z,K);q&&(N1(C,k,{nodeOrigin:A,nodeExtent:z,zIndexMode:K}),Y?(j(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(re==null?void 0:re.length)>0&&(V&&console.log("React Flow: trigger node changes",re),w==null||w(re)))},updateNodePositions:(E,w=!1)=>{const C=[];let k=[];const{nodeLookup:b,triggerNodeChanges:A,connection:z,updateConnection:V,onNodesChangeMiddlewareMap:Y}=N();for(const[K,re]of E){const q=b.get(K),Z=!!(q!=null&&q.expandParent&&(q!=null&&q.parentId)&&(re!=null&&re.position)),te={id:K,type:"position",position:Z?{x:Math.max(0,re.position.x),y:Math.max(0,re.position.y)}:re.position,dragging:w};if(q&&z.inProgress&&z.fromNode.id===q.id){const R=ui(q,z.fromHandle,ke.Left,!0);V({...z,from:R})}Z&&q.parentId&&C.push({id:K,parentId:q.parentId,rect:{...re.internals.positionAbsolute,width:re.measured.width??0,height:re.measured.height??0}}),k.push(te)}if(C.length>0){const{parentLookup:K,nodeOrigin:re}=N(),q=Ec(C,b,K,re);k.push(...q)}for(const K of Y.values())k=K(k);A(k)},triggerNodeChanges:E=>{const{onNodesChange:w,setNodes:C,nodes:k,hasDefaultNodes:b,debug:A}=N();if(E!=null&&E.length){if(b){const z=P_(E,k);C(z)}A&&console.log("React Flow: trigger node changes",E),w==null||w(E)}},triggerEdgeChanges:E=>{const{onEdgesChange:w,setEdges:C,edges:k,hasDefaultEdges:b,debug:A}=N();if(E!=null&&E.length){if(b){const z=I_(E,k);C(z)}A&&console.log("React Flow: trigger edge changes",E),w==null||w(E)}},addSelectedNodes:E=>{const{multiSelectionActive:w,edgeLookup:C,nodeLookup:k,triggerNodeChanges:b,triggerEdgeChanges:A}=N();if(w){const z=E.map(V=>ti(V,!0));b(z);return}b(Ui(k,new Set([...E]),!0)),A(Ui(C))},addSelectedEdges:E=>{const{multiSelectionActive:w,edgeLookup:C,nodeLookup:k,triggerNodeChanges:b,triggerEdgeChanges:A}=N();if(w){const z=E.map(V=>ti(V,!0));A(z);return}A(Ui(C,new Set([...E]))),b(Ui(k,new Set,!0))},unselectNodesAndEdges:({nodes:E,edges:w}={})=>{const{edges:C,nodes:k,nodeLookup:b,triggerNodeChanges:A,triggerEdgeChanges:z}=N(),V=E||k,Y=w||C,K=[];for(const q of V){if(!q.selected)continue;const Z=b.get(q.id);Z&&(Z.selected=!1),K.push(ti(q.id,!1))}const re=[];for(const q of Y)q.selected&&re.push(ti(q.id,!1));A(K),z(re)},setMinZoom:E=>{const{panZoom:w,maxZoom:C}=N();w==null||w.setScaleExtent([E,C]),_({minZoom:E})},setMaxZoom:E=>{const{panZoom:w,minZoom:C}=N();w==null||w.setScaleExtent([C,E]),_({maxZoom:E})},setTranslateExtent:E=>{var w;(w=N().panZoom)==null||w.setTranslateExtent(E),_({translateExtent:E})},resetSelectedElements:()=>{const{edges:E,nodes:w,triggerNodeChanges:C,triggerEdgeChanges:k,elementsSelectable:b}=N();if(!b)return;const A=w.reduce((V,Y)=>Y.selected?[...V,ti(Y.id,!1)]:V,[]),z=E.reduce((V,Y)=>Y.selected?[...V,ti(Y.id,!1)]:V,[]);C(A),k(z)},setNodeExtent:E=>{const{nodes:w,nodeLookup:C,parentLookup:k,nodeOrigin:b,elevateNodesOnSelect:A,nodeExtent:z,zIndexMode:V}=N();E[0][0]===z[0][0]&&E[0][1]===z[0][1]&&E[1][0]===z[1][0]&&E[1][1]===z[1][1]||(sc(w,C,k,{nodeOrigin:b,nodeExtent:E,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:V}),_({nodeExtent:E}))},panBy:E=>{const{transform:w,width:C,height:k,panZoom:b,translateExtent:A}=N();return M1({delta:E,panZoom:b,transform:w,translateExtent:A,width:C,height:k})},setCenter:async(E,w,C)=>{const{width:k,height:b,maxZoom:A,panZoom:z}=N();if(!z)return!1;const V=typeof(C==null?void 0:C.zoom)<"u"?C.zoom:A;return await z.setViewport({x:k/2-E*V,y:b/2-w*V,zoom:V},{duration:C==null?void 0:C.duration,ease:C==null?void 0:C.ease,interpolate:C==null?void 0:C.interpolate}),!0},cancelConnection:()=>{_({connection:{...ng}})},updateConnection:E=>{_({connection:E})},reset:()=>_({...cp()})}},Object.is);function am({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:x,nodeOrigin:m,nodeExtent:y,zIndexMode:v,children:_}){const[N]=L.useState(()=>QS({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:x,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:m,nodeExtent:y,zIndexMode:v}));return d.jsx(c_,{value:N,children:d.jsx($_,{children:d.jsx(Q_,{children:_})})})}function ZS({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:x,maxZoom:m,nodeOrigin:y,nodeExtent:v,zIndexMode:_}){return L.useContext(Yl)?d.jsx(d.Fragment,{children:t}):d.jsx(am,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:x,initialMaxZoom:m,nodeOrigin:y,nodeExtent:v,zIndexMode:_,children:t})}const JS={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function ek({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:x,onMove:m,onMoveStart:y,onMoveEnd:v,onConnect:_,onConnectStart:N,onConnectEnd:j,onClickConnectStart:E,onClickConnectEnd:w,onNodeMouseEnter:C,onNodeMouseMove:k,onNodeMouseLeave:b,onNodeContextMenu:A,onNodeDoubleClick:z,onNodeDragStart:V,onNodeDrag:Y,onNodeDragStop:K,onNodesDelete:re,onEdgesDelete:q,onDelete:Z,onSelectionChange:te,onSelectionDragStart:R,onSelectionDrag:U,onSelectionDragStop:H,onSelectionContextMenu:W,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:F,connectionMode:I,connectionLineType:$=Mr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:J=!1,selectionMode:ae=es.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:Ne=rs()?"Meta":"Control",zoomActivationKeyCode:xe=rs()?"Meta":"Control",snapToGrid:ne,snapGrid:je,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Te,nodesDraggable:De,autoPanOnNodeFocus:ht,nodesConnectable:Je,nodesFocusable:Xe,nodeOrigin:lt=Lg,edgesFocusable:yt,edgesReconnectable:Dt,elementsSelectable:qt=!0,defaultViewport:at=k_,minZoom:et=.5,maxZoom:vt=2,translateExtent:xt=Jo,preventScrolling:zn=!0,nodeExtent:rn,defaultMarkerColor:on="#b1b1b7",zoomOnScroll:no=!0,zoomOnPinch:Dn=!0,panOnScroll:di=!1,panOnScrollSpeed:Ir=.5,panOnScrollMode:Rr=ii.Free,zoomOnDoubleClick:nr=!0,panOnDrag:rr=!0,onPaneClick:wn,onPaneMouseEnter:Nt,onPaneMouseMove:Ot,onPaneMouseLeave:Ft,onPaneScroll:_n,onPaneContextMenu:On,paneClickDistance:Sn=1,nodeClickDistance:ut=0,children:Tr,onReconnect:Mt,onReconnectStart:Lr,onReconnectEnd:kn,onEdgeContextMenu:nt,onEdgeDoubleClick:He,onEdgeMouseEnter:Ar,onEdgeMouseMove:sn,onEdgeMouseLeave:Pt,reconnectRadius:Nn=10,onNodesChange:Ht,onEdgesChange:$r,noDragClassName:Fn="nodrag",noWheelClassName:zr="nowheel",noPanClassName:Bt="nopan",fitView:Dr,fitViewOptions:jt,connectOnClick:ir,attributionPosition:Or,proOptions:jn,defaultEdgeOptions:or,elevateNodesOnSelect:fi=!0,elevateEdgesOnSelect:ro=!1,disableKeyboardA11y:hi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:io,autoPanOnSelection:Fr=!0,autoPanSpeed:pi,connectionRadius:bn,isValidConnection:oo,onError:sr,style:lr,id:bt,nodeDragThreshold:Hr,connectionDragThreshold:pt,viewport:gi,onViewportChange:mi,width:yi,height:En,colorMode:Hn="light",debug:Cn,onScroll:Kt,ariaLabelConfig:Br,zIndexMode:vi="basic",...ar},xi){const Bn=bt||"1",Vn=E_(Hn),wi=L.useCallback(Wn=>{Wn.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Kt==null||Kt(Wn)},[Kt]);return d.jsx("div",{"data-testid":"rf__wrapper",...ar,onScroll:wi,style:{...lr,...JS},ref:xi,className:it(["react-flow",a,Vn]),id:bt,role:"application",children:d.jsxs(ZS,{nodes:t,edges:r,width:yi,height:En,fitView:Dr,fitViewOptions:jt,minZoom:et,maxZoom:vt,nodeOrigin:lt,nodeExtent:rn,zIndexMode:vi,children:[d.jsx(b_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:N,onConnectEnd:j,onClickConnectStart:E,onClickConnectEnd:w,nodesDraggable:De,autoPanOnNodeFocus:ht,nodesConnectable:Je,nodesFocusable:Xe,edgesFocusable:yt,edgesReconnectable:Dt,elementsSelectable:qt,elevateNodesOnSelect:fi,elevateEdgesOnSelect:ro,minZoom:et,maxZoom:vt,nodeExtent:rn,onNodesChange:Ht,onEdgesChange:$r,snapToGrid:ne,snapGrid:je,connectionMode:I,translateExtent:xt,connectOnClick:ir,defaultEdgeOptions:or,fitView:Dr,fitViewOptions:jt,onNodesDelete:re,onEdgesDelete:q,onDelete:Z,onNodeDragStart:V,onNodeDrag:Y,onNodeDragStop:K,onSelectionDrag:U,onSelectionDragStart:R,onSelectionDragStop:H,onMove:m,onMoveStart:y,onMoveEnd:v,noPanClassName:Bt,nodeOrigin:lt,rfId:Bn,autoPanOnConnect:Ve,autoPanOnNodeDrag:io,autoPanSpeed:pi,onError:sr,connectionRadius:bn,isValidConnection:oo,selectNodesOnDrag:Te,nodeDragThreshold:Hr,connectionDragThreshold:pt,onBeforeDelete:F,debug:Cn,ariaLabelConfig:Br,zIndexMode:vi}),d.jsx(qS,{onInit:x,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:C,onNodeMouseMove:k,onNodeMouseLeave:b,onNodeContextMenu:A,onNodeDoubleClick:z,nodeTypes:u,edgeTypes:c,connectionLineType:$,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:J,selectionMode:ae,deleteKeyCode:he,multiSelectionKeyCode:Ne,panActivationKeyCode:me,zoomActivationKeyCode:xe,onlyRenderVisibleElements:Me,defaultViewport:at,translateExtent:xt,minZoom:et,maxZoom:vt,preventScrolling:zn,zoomOnScroll:no,zoomOnPinch:Dn,zoomOnDoubleClick:nr,panOnScroll:di,panOnScrollSpeed:Ir,panOnScrollMode:Rr,panOnDrag:rr,autoPanOnSelection:Fr,onPaneClick:wn,onPaneMouseEnter:Nt,onPaneMouseMove:Ot,onPaneMouseLeave:Ft,onPaneScroll:_n,onPaneContextMenu:On,paneClickDistance:Sn,nodeClickDistance:ut,onSelectionContextMenu:W,onSelectionStart:M,onSelectionEnd:D,onReconnect:Mt,onReconnectStart:Lr,onReconnectEnd:kn,onEdgeContextMenu:nt,onEdgeDoubleClick:He,onEdgeMouseEnter:Ar,onEdgeMouseMove:sn,onEdgeMouseLeave:Pt,reconnectRadius:Nn,defaultMarkerColor:on,noDragClassName:Fn,noWheelClassName:zr,noPanClassName:Bt,rfId:Bn,disableKeyboardA11y:hi,nodeExtent:rn,viewport:gi,onViewportChange:mi,nodesDraggable:De}),d.jsx(S_,{onSelectionChange:te}),Tr,d.jsx(y_,{proOptions:jn,position:Or}),d.jsx(m_,{rfId:Bn,disableKeyboardA11y:hi})]})})}var tk=$g(ek);function nk({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:it(["react-flow__background-pattern",o,s])})}function rk({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:it(["react-flow__background-pattern","dots",r])})}var Pr;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Pr||(Pr={}));const ik={[Pr.Dots]:1,[Pr.Lines]:1,[Pr.Cross]:6},ok=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function um({id:t,variant:r=Pr.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:x,patternClassName:m}){const y=L.useRef(null),{transform:v,patternId:_}=ze(ok,Qe),N=s||ik[r],j=r===Pr.Dots,E=r===Pr.Cross,w=Array.isArray(o)?o:[o,o],C=[w[0]*v[2]||1,w[1]*v[2]||1],k=N*v[2],b=Array.isArray(u)?u:[u,u],A=E?[k,k]:C,z=[b[0]*v[2]+A[0]/2,b[1]*v[2]+A[1]/2],V=`${_}${t||""}`;return d.jsxs("svg",{className:it(["react-flow__background",x]),style:{...p,...Kl,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:y,"data-testid":"rf__background",children:[d.jsx("pattern",{id:V,x:v[0]%C[0],y:v[1]%C[1],width:C[0],height:C[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${z[0]},-${z[1]})`,children:j?d.jsx(rk,{radius:k/2,className:m}):d.jsx(nk,{dimensions:A,lineWidth:a,variant:r,className:m})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${V})`})]})}um.displayName="Background";const sk=L.memo(um);function lk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ak(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function uk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 ck(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 wl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:it(["react-flow__controls-button",r]),...o,children:t})}const fk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function cm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:x,children:m,position:y="bottom-left",orientation:v="vertical","aria-label":_}){const N=Ge(),{isInteractive:j,minZoomReached:E,maxZoomReached:w,ariaLabelConfig:C}=ze(fk,Qe),{zoomIn:k,zoomOut:b,fitView:A}=ql(),z=()=>{k(),u==null||u()},V=()=>{b(),c==null||c()},Y=()=>{A(a),h==null||h()},K=()=>{N.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),p==null||p(!j)},re=v==="horizontal"?"horizontal":"vertical";return d.jsxs(Xl,{className:it(["react-flow__controls",re,x]),position:y,style:t,"data-testid":"rf__controls","aria-label":_??C["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(wl,{onClick:z,className:"react-flow__controls-zoomin",title:C["controls.zoomIn.ariaLabel"],"aria-label":C["controls.zoomIn.ariaLabel"],disabled:w,children:d.jsx(lk,{})}),d.jsx(wl,{onClick:V,className:"react-flow__controls-zoomout",title:C["controls.zoomOut.ariaLabel"],"aria-label":C["controls.zoomOut.ariaLabel"],disabled:E,children:d.jsx(ak,{})})]}),o&&d.jsx(wl,{className:"react-flow__controls-fitview",onClick:Y,title:C["controls.fitView.ariaLabel"],"aria-label":C["controls.fitView.ariaLabel"],children:d.jsx(uk,{})}),s&&d.jsx(wl,{className:"react-flow__controls-interactive",onClick:K,title:C["controls.interactive.ariaLabel"],"aria-label":C["controls.interactive.ariaLabel"],children:j?d.jsx(dk,{}):d.jsx(ck,{})}),m]})}cm.displayName="Controls";const hk=L.memo(cm);function pk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:x,borderRadius:m,shapeRendering:y,selected:v,onClick:_}){const{background:N,backgroundColor:j}=u||{},E=c||N||j;return d.jsx("rect",{className:it(["react-flow__minimap-node",{selected:v},x]),x:r,y:o,rx:m,ry:m,width:s,height:a,style:{fill:E,stroke:h,strokeWidth:p},shapeRendering:y,onClick:_?w=>_(w,t):void 0})}const gk=L.memo(pk),mk=t=>t.nodes.map(r=>r.id),Wu=t=>t instanceof Function?t:()=>t;function yk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=gk,onClick:c}){const h=ze(mk,Qe),p=Wu(r),x=Wu(t),m=Wu(o),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(v=>d.jsx(xk,{id:v,nodeColorFunc:p,nodeStrokeColorFunc:x,nodeClassNameFunc:m,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:y},v))})}function vk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:x,x:m,y,width:v,height:_}=ze(N=>{const j=N.nodeLookup.get(t);if(!j)return{node:void 0,x:0,y:0,width:0,height:0};const E=j.internals.userNode,{x:w,y:C}=j.internals.positionAbsolute,{width:k,height:b}=xn(E);return{node:E,x:w,y:C,width:k,height:b}},Qe);return!x||x.hidden||!cg(x)?null:d.jsx(h,{x:m,y,width:v,height:_,style:x.style,selected:!!x.selected,className:s(x),color:r(x),borderRadius:a,strokeColor:o(x),strokeWidth:u,shapeRendering:c,onClick:p,id:x.id})}const xk=L.memo(vk);var wk=L.memo(yk);const _k=200,Sk=150,kk=t=>!t.hidden,Nk=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?lg(us(t.nodeLookup,{filter:kk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},dp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,jk=(t,r)=>dp(t.viewBB,r.viewBB)&&dp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,bk="react-flow__minimap-desc";function dm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:x,maskStrokeColor:m,maskStrokeWidth:y,position:v="bottom-right",onClick:_,onNodeClick:N,pannable:j=!1,zoomable:E=!1,ariaLabel:w,inversePan:C,zoomStep:k=1,offsetScale:b=5}){const A=Ge(),z=L.useRef(null),{boundingRect:V,viewBB:Y,rfId:K,panZoom:re,translateExtent:q,flowWidth:Z,flowHeight:te,ariaLabelConfig:R}=ze(Nk,jk),U=(t==null?void 0:t.width)??_k,H=(t==null?void 0:t.height)??Sk,W=V.width/U,M=V.height/H,D=Math.max(W,M),F=D*U,I=D*H,$=b*D,ie=V.x-(F-V.width)/2-$,oe=V.y-(I-V.height)/2-$,fe=F+$*2,he=I+$*2,pe=`${bk}-${K}`,J=L.useRef(0),ae=L.useRef();J.current=D,L.useEffect(()=>{if(z.current&&re)return ae.current=D1({domNode:z.current,panZoom:re,getTransform:()=>A.getState().transform,getViewScale:()=>J.current}),()=>{var ne;(ne=ae.current)==null||ne.destroy()}},[re]),L.useEffect(()=>{var ne;(ne=ae.current)==null||ne.update({translateExtent:q,width:Z,height:te,inversePan:C,pannable:j,zoomStep:k,zoomable:E})},[j,E,C,k,q,Z,te]);const me=_?ne=>{var Te;const[je,Me]=((Te=ae.current)==null?void 0:Te.pointer(ne))||[0,0];_(ne,{x:je,y:Me})}:void 0,Ne=N?L.useCallback((ne,je)=>{const Me=A.getState().nodeLookup.get(je).internals.userNode;N(ne,Me)},[]):void 0,xe=w??R["minimap.ariaLabel"];return d.jsx(Xl,{position:v,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof y=="number"?y*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:it(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:U,height:H,viewBox:`${ie} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:z,onClick:me,children:[xe&&d.jsx("title",{id:pe,children:xe}),d.jsx(wk,{onClick:Ne,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-$},${oe-$}h${fe+$*2}v${he+$*2}h${-fe-$*2}z + M${Y.x},${Y.y}h${Y.width}v${Y.height}h${-Y.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}dm.displayName="MiniMap";const Ek=L.memo(dm),Ck=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Mk={[Ji.Line]:"right",[Ji.Handle]:"bottom-right"};function Pk({nodeId:t,position:r,variant:o=Ji.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:x=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:y=!1,resizeDirection:v,autoScale:_=!0,shouldResize:N,onResizeStart:j,onResize:E,onResizeEnd:w}){const C=Hg(),k=typeof t=="string"?t:C,b=Ge(),A=L.useRef(null),z=o===Ji.Handle,V=ze(L.useCallback(Ck(z&&_),[z,_]),Qe),Y=L.useRef(null),K=r??Mk[o];L.useEffect(()=>{if(!(!A.current||!k))return Y.current||(Y.current=Q1({domNode:A.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:q,transform:Z,snapGrid:te,snapToGrid:R,nodeOrigin:U,domNode:H}=b.getState();return{nodeLookup:q,transform:Z,snapGrid:te,snapToGrid:R,nodeOrigin:U,paneDomNode:H}},onChange:(q,Z)=>{const{triggerNodeChanges:te,nodeLookup:R,parentLookup:U,nodeOrigin:H}=b.getState(),W=[],M={x:q.x,y:q.y},D=R.get(k);if(D&&D.expandParent&&D.parentId){const F=D.origin??H,I=q.width??D.measured.width??0,$=q.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:I,height:$,...dg({x:q.x??D.position.x,y:q.y??D.position.y},{width:I,height:$},D.parentId,R,F)}},oe=Ec([ie],R,U,H);W.push(...oe),M.x=q.x?Math.max(F[0]*I,q.x):void 0,M.y=q.y?Math.max(F[1]*$,q.y):void 0}if(M.x!==void 0&&M.y!==void 0){const F={id:k,type:"position",position:{...M}};W.push(F)}if(q.width!==void 0&&q.height!==void 0){const I={id:k,type:"dimensions",resizing:!0,setAttributes:v?v==="horizontal"?"width":"height":!0,dimensions:{width:q.width,height:q.height}};W.push(I)}for(const F of Z){const I={...F,type:"position"};W.push(I)}te(W)},onEnd:({width:q,height:Z})=>{const te={id:k,type:"dimensions",resizing:!1,dimensions:{width:q,height:Z}};b.getState().triggerNodeChanges([te])}})),Y.current.update({controlPosition:K,boundaries:{minWidth:h,minHeight:p,maxWidth:x,maxHeight:m},keepAspectRatio:y,resizeDirection:v,onResizeStart:j,onResize:E,onResizeEnd:w,shouldResize:N}),()=>{var q;(q=Y.current)==null||q.destroy()}},[K,h,p,x,m,y,j,E,w,N]);const re=K.split("-");return d.jsx("div",{className:it(["react-flow__resize-control","nodrag",...re,o,s]),ref:A,style:{...a,scale:V,...c&&{[z?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Pk);const Ik={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function Zl(t){return Ik[t]??8}const uc=208,cc=64,Rk=88,Tk=28,Lk=8;function Ak(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function $k(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const w of t){const C=Zl(w.type),k=s.get(C)??[];k.push(w),s.set(C,k)}const u=[...s.keys()].sort((w,C)=>w-C).map(w=>[...s.get(w)??[]].sort((C,k)=>C.name.localeCompare(k.name)||C.id.localeCompare(k.id))),c=new Set(t.map(w=>w.id)),h=new Map,p=new Map;for(const w of t)h.set(w.id,[]),p.set(w.id,[]);for(const w of r)!c.has(w.src)||!c.has(w.dst)||w.src===w.dst||(p.get(w.src).push(w.dst),h.get(w.dst).push(w.src));const x=new Map;u.forEach((w,C)=>{for(const k of w)x.set(k.id,C)});const m=new Map,y=()=>{for(const w of u)w.forEach((C,k)=>m.set(C.id,k))};y();const v=(w,C)=>{const k=w.map((b,A)=>{const z=C(b.id).map(Y=>m.get(Y)).filter(Y=>Y!==void 0),V=Ak(z);return{n:b,bary:Number.isNaN(V)?A:V,name:b.name,id:b.id}});return k.sort((b,A)=>b.bary-A.bary||b.name.localeCompare(A.name)||b.id.localeCompare(A.id)),k.map(b=>b.n)},_=w=>C=>x.get(C)===w;for(let w=0;w(h.get(k)??[]).filter(_(C-1))),y();for(let C=u.length-2;C>=0;C--)u[C]=v(u[C],k=>(p.get(k)??[]).filter(_(C+1))),y()}const N=uc+Rk,j=cc+Tk,E=Math.max(...u.map(w=>w.length),1);return u.forEach((w,C)=>{const k=(E-w.length)*j/2;w.forEach((b,A)=>{o.set(b.id,{x:C*N,y:k+A*j})})}),o}const zk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),fm=90,Dk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),fp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Ok=Math.PI*(3-Math.sqrt(5)),hm=220,Fk=26,Hk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function pm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function PN(t){return fp[t]?fp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Bk(t){return t>=fm?"3d":"2d"}function Vk(t){return t>=fm?"overview":"full"}function Wk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(pm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Dk.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Wk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Gk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function Yk(t,r,o,s){const a=new Set(t.map(j=>j.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const j of r){if(!a.has(j.src)||!a.has(j.dst))continue;const E=u.get(j.src)??[];E.push({dst:j.dst,id:j.id}),u.set(j.src,E);const w=c.get(j.dst)??[];w.push({src:j.src,id:j.id}),c.set(j.dst,w)}const h=new Set(t.filter(j=>zk.has(j.type)).map(j=>j.id)),p=h.size?h:a,x=new Set,m=[o];for(;m.length;){const j=m.pop();if(!x.has(j)){x.add(j);for(const E of u.get(j)??[])x.has(E.dst)||m.push(E.dst)}}const y=new Set([o]),v=[...p].filter(j=>x.has(j)),_=new Set(v);for(;v.length;){const j=v.pop();y.add(j);for(const E of c.get(j)??[])x.has(E.src)&&!_.has(E.src)&&(_.add(E.src),v.push(E.src))}const N=new Set;for(const j of r)y.has(j.src)&&y.has(j.dst)&&N.add(j.id);return{nodeIds:y,edgeIds:N}}function IN(t){const r=new Map;for(const s of t){const a=Zl(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*hm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Fk*Math.sqrt(h+1),x=h*Ok;o.set(c.id,{x:u,y:p*Math.cos(x),z:p*Math.sin(x)})})}return o}function RN(t){const r=new Map;for(const o of t){const s=Zl(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*hm,count:s}))}const _l=16,Xk=12,qk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Kk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),hp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Qk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},pp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],gp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Zk=new Set(["looks_idempotent_on_pk","null","blank"]),Jk=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function eN(t){return hp[t]?hp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function tN(t,r,o){const s=new Map(r.map(v=>[v.id,v])),a=[];qk.has(t.type)&&a.push("sink"),Kk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(v=>v.dst===t.id),h=o.filter(v=>v.src===t.id),p=c.slice(0,_l).map(v=>Sl(v,s,v.src)),x=h.slice(0,_l).map(v=>Sl(v,s,v.dst)),m=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,y={type:t.type,typeLabel:Xo(to(t.type)),layer:Hk[Zl(t.type)]??"other",purpose:eN(t.type),name:t.name,qualifiedName:t.qualified_name,file:m,context:t.context,roles:a,facts:rN(u).filter(v=>!(v.key==="app"&&v.value===t.context)),inputs:p,outputs:x,extraInputs:Math.max(0,c.length-_l),extraOutputs:Math.max(0,h.length-_l),degreeIn:c.length,degreeOut:h.length,inputKinds:mp(c.map(v=>Sl(v,s,v.src))),outputKinds:mp(h.map(v=>Sl(v,s,v.dst))),pathSummary:""};return y.pathSummary=nN(y),y}function mp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function nN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function Sl(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Xo(to(s.type)):"",edgeType:t.type,edgeLabel:Xo(t.type),inferred:t.confidence<.8}}function rN(t){const r=[...pp.filter(a=>a in t),...Object.keys(t).filter(a=>!pp.includes(a)&&!gp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||gp.has(a)||Jk.has(a))continue;s.add(a);const u=iN(a,t[a]);u!=null&&o.push({key:a,label:Qk[a]??Xo(a),value:u})}return o}function iN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Zk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return oN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Xk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function oN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const sN=new Set,lN=L.lazy(()=>_0(()=>import("./LayeredGraph3D-DtHNGq_6.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),aN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function uN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(eo,{type:"target",position:ke.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:to(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Cr(t.name)}),d.jsx(eo,{type:"source",position:ke.Right,isConnectable:!1})]})}const cN={load:uN},dN=new Set(["django","react","stitch","arch"]);function fN({topologyKey:t}){const{fitView:r}=ql();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function hN(t,r,o=null,s={}){const a=new Map(t.map(p=>[p.id,p])),u=$k(t,r),c=t.map(p=>{var y;const x=((y=s.roles)==null?void 0:y[p.id])||[],m=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:p.id,type:"load",position:u.get(p.id)??{x:0,y:0},data:{name:p.name,type:p.type,file:p.file_path,roles:x,dim:m},selected:o===p.id,sourcePosition:ke.Right,targetPosition:ke.Left,width:uc,height:cc,style:{width:uc,height:cc}}}),h=r.filter(p=>a.has(p.src)&&a.has(p.dst)).map(p=>{const x=aN[p.weight]||"var(--edge-cheap)",m=!!(o&&(p.src===o||p.dst===o));return{id:p.id,source:p.src,target:p.dst,type:"smoothstep",animated:p.weight==="critical",style:{stroke:x,strokeWidth:p.weight==="critical"?2.4:1.2,strokeDasharray:p.confidence<.8?"6 4":void 0},markerEnd:{type:ts.ArrowClosed,width:14,height:14,color:x},label:m?p.type.replaceAll("_"," "):void 0,labelStyle:m?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:m?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:m?[3,5]:void 0,labelBgBorderRadius:m?4:void 0}});return{rfNodes:c,rfEdges:h}}function pN({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:x}){const m=tN(t,r,o);return L.useEffect(()=>{const y=v=>{v.key==="Escape"&&s()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:m.typeLabel}),d.jsx("div",{className:"inspector-roles",children:m.roles.map(y=>d.jsx("span",{className:"inspector-chip",children:y},y))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Cr(m.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:m.purpose}),m.context?d.jsx("div",{className:"muted",children:Cr(m.context)}):null,m.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Cr(m.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Cr(m.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",m.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[m.degreeIn," in · ",m.degreeOut," out"]}),m.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:m.pathSummary}):null,m.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:m.facts.map(y=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:y.label}),d.jsx("dd",{children:Cr(y.value)})]},y.key))}):null,d.jsx(yp,{title:"Inputs",testId:"graph-inspector-inputs",links:m.inputs,extra:m.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(yp,{title:"Outputs",testId:"graph-inspector-outputs",links:m.outputs,extra:m.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",onClick:()=>a(t.id),children:"What if this changes"}):null,x?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",onClick:()=>x(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function yp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Cr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Cr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Uu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:x,repoPath:m,onOpenFile:y,pinnedId:v,onPin:_}){const[N,j]=L.useState(null),E=a!==void 0?a:N,w=ne=>{a===void 0&&j(ne),u==null||u(ne)},[C,k]=L.useState(null),[b,A]=L.useState(null),[z,V]=L.useState(new Set(dN)),[Y,K]=L.useState(!1),[re,q]=L.useState(""),[Z,te]=L.useState(!1),R=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,U=C??Bk(t.length),H=b??Vk(t.length),W=Y?E:null,M=L.useMemo(()=>p?Yk(t,r,p):null,[t,r,p]),D=M?t.filter(ne=>M.nodeIds.has(ne.id)):t,F=M?r.filter(ne=>M.edgeIds.has(ne.id)):r,I=L.useMemo(()=>Uk(D,F,{detail:H,families:z,focusId:W,neighborhoodOnly:!!W}),[D,F,H,z,W]),$=L.useMemo(()=>`${I.nodes.map(ne=>ne.id).join("\0")}|${I.edges.map(ne=>ne.id).join("\0")}`,[I.nodes,I.edges]),ie=E?t.find(ne=>ne.id===E)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const ne=hN(I.nodes,I.edges,E,{roles:c,testOverlay:h});return R&&(ne.rfEdges=ne.rfEdges.map(je=>({...je,animated:!1}))),ne},[I.nodes,I.edges,E,R,c,h]);L.useEffect(()=>{if(!s)return;const ne=t.find(je=>je.file_path===s);ne&&w(ne.id)},[s,t]);const he=L.useMemo(()=>Gk(t,re),[t,re]),pe=(ne,je)=>{w(je.id)},J=()=>{w(null),K(!1)},ae=ie?d.jsx(pN,{node:ie,nodes:t,edges:r,onClose:J,onWhatIf:o,onSelect:w,onOpenFile:y,pinned:v===ie.id,onPin:_,onIsolate:x?ne=>{x(p===ne?null:ne)}:void 0}):null,me=ne=>{V(je=>{const Me=new Set(je);if(Me.has(ne)){if(Me.size===1)return je;Me.delete(ne)}else Me.add(ne);return Me})},Ne=L.useMemo(()=>{const ne=new Set;for(const je of t)ne.add(pm(je.type));return ne},[t]),xe=t.length-I.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:U==="2d"?"active":"","aria-pressed":U==="2d",onClick:()=>k("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:U==="3d"?"active":"","aria-pressed":U==="3d",onClick:()=>k("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:H==="overview"?"active":"","aria-pressed":H==="overview",onClick:()=>A("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:H==="full"?"active":"","aria-pressed":H==="full",onClick:()=>A("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(ne=>Ne.has(ne)).map(ne=>d.jsx("button",{type:"button","data-testid":`graph-family-${ne}`,className:z.has(ne)?"active":"","aria-pressed":z.has(ne),onClick:()=>me(ne),children:ne},ne))}),d.jsx("button",{type:"button",className:Y?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!E,onClick:()=>K(ne=>!ne),children:Y?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>x==null?void 0:x(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:re,onChange:ne=>{q(ne.target.value),te(!0)},onFocus:()=>te(!0),onBlur:()=>window.setTimeout(()=>te(!1),150)}),Z&&re.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(ne=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:je=>je.preventDefault(),onClick:()=>{w(ne.id),q(""),te(!1)},children:[ne.name,d.jsx("span",{className:"muted",children:to(ne.type)})]})},ne.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[I.nodes.length," nodes · ",I.edges.length," edges",xe?` · ${xe} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:U==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(lN,{nodes:I.nodes,edges:I.edges,selectedId:E,neighborIds:W?I.neighborIds:sN,onSelect:ne=>{w(ne),ne||K(!1)}})}),ae]}):d.jsxs(am,{children:[d.jsxs(tk,{nodes:oe,edges:fe,nodeTypes:cN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:J,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(fN,{topologyKey:$}),d.jsx(sk,{}),d.jsx(Ek,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(hk,{})]}),ae]})})]})}function gm(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function gN(t){localStorage.setItem("loadpath.editor",t)}async function mN(t,r,o,s=gm()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const vp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],yN=["preset","branch","tag","commit"];function vN(t){var a;if(!(t!=null&&t.git))return[...vp];const r=((a=t.presets)!=null&&a.length?t.presets:vp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function xN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function wN(t){return yN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function _N(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function xp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[x,m]=L.useState(!1),[y,v]=L.useState(null),[_,N]=L.useState(0),j=L.useMemo(()=>{const b=vN(u);return y===null?b:xN(b,y)},[u,y]),E=L.useMemo(()=>wN(j),[j]);L.useEffect(()=>{x&&c()},[x,c]),L.useEffect(()=>{N(0)},[y,x]);const w=()=>{m(!1),v(null)},C=b=>{r(b.value),w()},k=b=>{if(b.key==="ArrowDown"){if(b.preventDefault(),!x){m(!0);return}N(A=>Math.min(A+1,Math.max(j.length-1,0)))}else if(b.key==="ArrowUp"){if(b.preventDefault(),!x)return;N(A=>Math.max(A-1,0))}else if(b.key==="Enter"&&x){b.preventDefault();const A=j[_];A&&C(A)}else b.key==="Escape"&&x&&(b.preventDefault(),w())};return d.jsxs("div",{className:"combo",ref:p,onBlur:b=>{b.currentTarget.contains(b.relatedTarget)||w()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":x,"aria-controls":h,"aria-autocomplete":"list",onChange:b=>{r(b.target.value),x&&v(b.target.value)},onKeyDown:k}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":x,onMouseDown:b=>b.preventDefault(),onClick:()=>x?w():m(!0),children:d.jsx(v0,{})})]}),x?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:E.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):E.map(b=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:_N(b.group)}),b.items.map(A=>{const z=j.indexOf(A);return d.jsxs("button",{type:"button",role:"option","aria-selected":z===_,className:z===_?"combo-option active":"combo-option","data-testid":`ref-option-${A.group}`,onMouseDown:V=>V.preventDefault(),onMouseEnter:()=>N(z),onClick:()=>C(A),children:[d.jsx("span",{className:"combo-label",children:A.label}),A.detail?d.jsx("span",{className:"combo-detail",children:A.detail}):null]},`${A.group}:${A.value}`)})]},b.group))}):null]})}function SN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[x,m]=L.useState(""),[y,v]=L.useState(!1),_=L.useRef(null),N=L.useRef(0),j=async k=>{const b=N.current+1;N.current=b,v(!0);try{const A=await Pe.browse(k);if(N.current!==b)return;a(A),c(A.path),p(A.is_git?A.path:null),m("")}catch(A){if(N.current!==b)return;m(A instanceof Error?A.message:String(A))}finally{N.current===b&&v(!1)}};L.useEffect(()=>{var k,b;j(t),(k=_.current)==null||k.focus(),(b=_.current)==null||b.select()},[t]);const E=h||(s==null?void 0:s.path)||u,w=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",C=k=>{k.key==="Escape"&&(k.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:C,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:k=>k.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:k=>{k.preventDefault(),j(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:k=>c(k.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),x?d.jsx("div",{className:"error",role:"alert",children:x}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":y,children:s!=null&&s.entries.length?s.entries.map(k=>{const b=h===k.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":b,className:b?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":k.path,onClick:()=>p(k.path),onDoubleClick:()=>void j(k.path),children:[d.jsx(kp,{}),d.jsx("span",{className:"explorer-name",children:k.name}),k.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},k.path)}):d.jsx("div",{className:"muted explorer-empty",children:y?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:E,children:E}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!E,onClick:()=>E&&r(E),children:["Use ",w]})]})]})})}const Dl=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],kN="obsidian",mm="loadpath.theme";function NN(t){return Dl.some(r=>r.id===t)}function ym(){try{const t=localStorage.getItem(mm)||"";if(NN(t))return t}catch{}return kN}function jN(t){var r;return((r=Dl.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function vm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=jN(t);try{localStorage.setItem(mm,t)}catch{}}const Gu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:h0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:p0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:g0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:m0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:y0}];function bN(t){const r=t.total||0;return r<=0?null:Math.min(100,Math.round(100*(t.done||0)/r))}function Yu(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function EN(){var wi,Wn,Oe,so,lo,_i,ao,uo,co;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,x]=L.useState(null),[m,y]=L.useState(null),[v,_]=L.useState([]),[N,j]=L.useState("review"),[E,w]=L.useState(""),[C,k]=L.useState(""),[b,A]=L.useState(null),[z,V]=L.useState(!1),[Y,K]=L.useState(!1),[re,q]=L.useState(""),[Z,te]=L.useState({}),[R,U]=L.useState([]),[H,W]=L.useState([]),[M,D]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[F,I]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[$,ie]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[oe,fe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[he,pe]=L.useState(0),[J,ae]=L.useState(""),[me,Ne]=L.useState(ym),[xe,ne]=L.useState(!1),[je,Me]=L.useState(!1),[Te,De]=L.useState(!1),[ht,Je]=L.useState(null),[Xe,lt]=L.useState(null),[yt,Dt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[qt,at]=L.useState(null),[et,vt]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[xt,zn]=L.useState([]),[rn,on]=L.useState(null),[no,Dn]=L.useState(null),[di,Ir]=L.useState(null),[Rr,nr]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[rr,wn]=L.useState(null),[Nt,Ot]=L.useState(null),[Ft,_n]=L.useState(!1),[On,Sn]=L.useState(!1),ut=L.useRef(o);ut.current=o;const Tr=L.useRef(!1);Tr.current=je;const Mt=L.useRef(""),Lr=L.useRef(""),kn=P=>{Ne(P),vm(P)},nt=L.useRef(""),He=P=>{nt.current=P,k(P)},Ar=P=>{const G=()=>{Pe.indexProgress(P).then(Se=>{nt.current&&(Se.phase&&Se.phase!=="idle"&&Se.message&&He(Se.message),A(Se.phase&&Se.phase!=="idle"?bN(Se):null))}).catch(()=>{})};G();const ce=window.setInterval(G,250);return()=>{window.clearInterval(ce),A(null)}};L.useEffect(()=>{Pe.settings().then(te).catch(()=>{}).finally(()=>ne(!0)),Pe.repos().then(P=>_(P.repos)).catch(()=>{})},[]);const sn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const P=o;let G=!1;return Lr.current!==P&&ir(P),Pe.config(P).then(ce=>{!G&&ut.current===P&&Dn(ce)}).catch(()=>{}),Pe.architectureHealth(P).then(ce=>{!G&&ut.current===P&&Ir(ce)}).catch(()=>{}),()=>{G=!0}},[t,o]);const Pt=P=>{ut.current=P,s(P),localStorage.setItem("loadpath.repo",P),P.trim()!==Mt.current&&(Mt.current="",wn(null))},Nn=L.useCallback(P=>{const G=(P??ut.current).trim();return!G||Mt.current===G?Promise.resolve():(Mt.current=G,Pe.gitRefs(G).then(ce=>{ut.current.trim()===G&&wn(ce)}).catch(()=>{Mt.current===G&&(Mt.current="",wn(null))}))},[]),Ht=(P,G)=>{u(P),h(G),localStorage.setItem("loadpath.base",P),localStorage.setItem("loadpath.head",G)},$r=(P,G,ce)=>{I(P),D(G),localStorage.setItem("loadpath.provider",P),localStorage.setItem("loadpath.scmRepo",G),ce!==void 0&&(ie(ce),localStorage.setItem("loadpath.prNumber",ce))},Fn=P=>{x(P),pe(0),Je(Xe&&P.nodes.some(G=>G.id===Xe)?Xe:null),at(null),on(null),P.id&&!P.what_if&&localStorage.setItem("loadpath.lastReviewId",P.id)},zr=async P=>{try{const G=await Pe.reviews(P);zn(G.reviews)}catch{zn([])}},Bt=async P=>{try{Ir(await Pe.architectureHealth(P))}catch{Ir(null)}},Dr=P=>P==="github"?!!Z.github_token_set:P==="gitlab"?!!Z.gitlab_token_set:!!Z.bitbucket_token_set,jt=L.useCallback(async(P=F)=>{var G;try{const ce=await Pe.scmRepos(P);W(ce.repos),(G=ce.user)!=null&&G.login&&te(Se=>({...Se,...P==="github"?{github_user:ce.user.login}:P==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{W([])}},[F]);L.useEffect(()=>{if(t!=="prs")return;let P=!1;return jt(F).catch(()=>{P||W([])}),()=>{P=!0}},[t,F,jt]),L.useEffect(()=>{if(!Nt)return;let P=!1,G=0;const ce=async()=>{try{const Se=await Pe.githubOAuthPoll(Nt.flow_id);if(P)return;if(Se.status==="complete"){Ot(null);const Ie=await Pe.settings();te(Ie),q(Se.user?`Signed in to GitHub as ${Se.user}`:"Signed in to GitHub"),jt("github");return}if(Se.status==="pending"||Se.status==="slow_down"){G=window.setTimeout(ce,Math.max(Se.interval||Nt.interval,5)*1e3);return}Ot(null),w(Se.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(Se){if(P)return;Ot(null),w(Se instanceof Error?Se.message:String(Se))}};return G=window.setTimeout(ce,Math.max(Nt.interval,5)*1e3),()=>{P=!0,window.clearTimeout(G)}},[Nt,jt]),L.useEffect(()=>{if(!Ft)return;let P=!1,G=0;const ce=Date.now(),Se=async()=>{try{const Ie=await Pe.oauthStatus();if(P)return;if(Ie.bitbucket.connected){_n(!1);const Ae=await Pe.settings();te(Ae),q(Ie.bitbucket.user?`Signed in to Bitbucket as ${Ie.bitbucket.user}`:"Signed in to Bitbucket"),jt("bitbucket");return}if(Date.now()-ce>18e4){_n(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}G=window.setTimeout(Se,1500)}catch(Ie){if(P)return;_n(!1),w(Ie instanceof Error?Ie.message:String(Ie))}};return G=window.setTimeout(Se,1500),()=>{P=!0,window.clearTimeout(G)}},[Ft,jt]),L.useEffect(()=>{if(!On)return;let P=!1,G=0;const ce=Date.now(),Se=async()=>{try{const Ie=await Pe.oauthStatus();if(P)return;if(Ie.gitlab.connected){Sn(!1);const Ae=await Pe.settings();te(Ae),q(Ie.gitlab.user?`Signed in to GitLab as ${Ie.gitlab.user}`:"Signed in to GitLab"),jt("gitlab");return}if(Date.now()-ce>18e4){Sn(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}G=window.setTimeout(Se,1500)}catch(Ie){if(P)return;Sn(!1),w(Ie instanceof Error?Ie.message:String(Ie))}};return G=window.setTimeout(Se,1500),()=>{P=!0,window.clearTimeout(G)}},[On,jt]);const ir=async(P=o,G=!1)=>{if(!P.trim())return null;Lr.current=P,K(!0);try{const ce=await Pe.architecture(P,!1);ut.current===P&&y(ce);const Se=Pe.architectureGraph(P).then(Ie=>{ut.current===P&&y(Ae=>Ae&&{...Ae,nodes:Ie.nodes,edges:Ie.edges,graph_pending:!1})});return Se.catch(()=>{}).finally(()=>{ut.current===P&&K(!1)}),G&&await Se,ce}catch(ce){throw ut.current===P&&K(!1),ce}},Or=async P=>{const G=P.trim();if(!(!G||G===ut.current)){if(nt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),q(""),x(null),y(null),j("architecture"),Pt(G),V(!0),He(`Loading ${f0(G)}…`);try{await Promise.all([ir(G),Nn(G)])}catch(ce){ut.current===G&&w(ce instanceof Error?ce.message:String(ce))}finally{ut.current===G&&(He(""),V(!1))}}},jn=async()=>{if(nt.current||!sn())return;w(""),q(""),He("Tracing load path…"),Pt(o),Ht(a,c);const P=Ar(o);try{const G=await Pe.review(o,a,c,!0,oe);Fn(G),j("review"),r("review"),await Pe.repos().then(ce=>_(ce.repos)).catch(()=>{}),await Promise.all([ir(o),zr(o),Bt(o)])}catch(G){w(G instanceof Error?G.message:String(G))}finally{P(),He("")}},or=async(P=!0)=>{if(nt.current||!sn())return;w(""),q(""),He(P?"Indexing…":"Full reindex…"),Pt(o);const G=Ar(o);try{await Pe.index(o,P);const ce=await ir(o);await Pe.repos().then(Se=>_(Se.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(j("architecture"),r("architecture"))}catch(ce){w(ce instanceof Error?ce.message:String(ce))}finally{G(),He("")}},fi=async()=>{if(!nt.current&&sn()){w(""),q(""),He("Detecting layout…"),Pt(o);try{const P=await Pe.init(o);q(P.message),await Pe.repos().then(G=>_(G.repos)).catch(()=>{})}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},ro=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),q("Copied markdown brief")}catch(P){w(P instanceof Error?P.message:String(P))}},hi=async()=>{if(!nt.current){if(!(p!=null&&p.markdown)||!M||!$){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const P=await Pe.postComment(F,M,Number($),p.markdown);q(P.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ve=async()=>{if(!nt.current){w(""),He("Fetching pull requests…");try{const P=await Pe.prs(F,M,"open",o.trim()||void 0);U(P.pull_requests);const G=H.find(ce=>ce.slug.toLowerCase()===M.trim().toLowerCase());G!=null&&G.local_path&&Pt(G.local_path)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},io=async()=>{w("");try{const P=await Pe.githubOAuthStart();Ot(P),Yu(P.verification_uri_complete,"github.com","/login/device")}catch(P){w(P instanceof Error?P.message:String(P))}},Fr=async()=>{w("");try{const P=await Pe.bitbucketOAuthStart();_n(!0),Yu(P.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(P){_n(!1),w(P instanceof Error?P.message:String(P))}},pi=async()=>{w("");try{const P=await Pe.gitlabOAuthStart();Sn(!0),Yu(P.authorize_url,new URL(P.authorize_url).hostname,"/oauth/authorize")}catch(P){Sn(!1),w(P instanceof Error?P.message:String(P))}},bn=async P=>{if(!(nt.current||!o.trim())){w(""),He("Walking what-if path…");try{const G=await Pe.whatIf(o,P);q(`${G.title} — ${G.confidence.level} · ${(G.sinks||[]).length} sinks`),Fn({...G,markdown:G.markdown||"",index:G.index||(p==null?void 0:p.index),workspace:G.workspace||(p==null?void 0:p.workspace)}),j("review"),r("review")}catch(G){w(G instanceof Error?G.message:String(G))}finally{He("")}}},oo=async P=>{var Ie;if(nt.current)return;$r(P.provider,P.repo,String(P.number));const G=H.find(Ae=>Ae.slug.toLowerCase()===P.repo.toLowerCase());G!=null&&G.local_path&&Pt(G.local_path),w(""),He(`Fetching ${P.provider} #${P.number}…`);const ce=(G==null?void 0:G.local_path)||o,Se=ce?Ar(ce):()=>{};try{const Ae=await Pe.reviewPr(P.provider,P.repo,P.number,(G==null?void 0:G.local_path)||o||void 0);Fn(Ae),Ae.pull_request&&typeof Ae.pull_request.repo_path=="string"&&Pt(Ae.pull_request.repo_path),Ht(String(Ae.base||P.target_branch),String(Ae.head||P.source_branch)),j("review"),r("review"),typeof((Ie=Ae.pull_request)==null?void 0:Ie.repo_path)=="string"&&zr(Ae.pull_request.repo_path)}catch(Ae){Ht(P.base_sha||P.target_branch,P.head_sha||P.source_branch),r("review"),w(Ae instanceof Error?Ae.message:String(Ae))}finally{Se(),He("")}},sr=async P=>{w("");try{te(await Pe.oauthDisconnect(P)),F===P&&W([]),q(`Disconnected ${P}`)}catch(G){w(G instanceof Error?G.message:String(G))}},lr=async P=>{P.preventDefault();const G=new FormData(P.currentTarget),ce={github_token:String(G.get("github_token")||""),github_oauth_client_id:String(G.get("github_oauth_client_id")||""),github_host:String(G.get("github_host")||""),gitlab_token:String(G.get("gitlab_token")||""),gitlab_host:String(G.get("gitlab_host")||""),gitlab_oauth_client_id:String(G.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(G.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(G.get("bitbucket_token")||""),bitbucket_username:String(G.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(G.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(G.get("bitbucket_oauth_client_secret")||""),ai_provider:String(G.get("ai_provider")||"none"),ai_api_key:String(G.get("ai_api_key")||""),ai_model:String(G.get("ai_model")||""),ai_base_url:String(G.get("ai_base_url")||"")},Se=v.length?{...ce,workspaces:v.map(Ie=>({path:Ie.path,name:Ie.name}))}:ce;try{te(await Pe.saveSettings(Se)),q("Settings saved on this machine")}catch(Ie){w(Ie instanceof Error?Ie.message:String(Ie))}},bt=async()=>{if(!(!p||nt.current)){He("Residual analysis…");try{const P=await Pe.residual(p);ae(P.note)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Hr=L.useRef(jn);Hr.current=jn;const pt=L.useRef(t);pt.current=t;const gi=L.useRef(!1);gi.current=Te;const mi=L.useRef(p);mi.current=p;const yi=L.useRef(he);yi.current=he,L.useEffect(()=>{const P=localStorage.getItem("loadpath.lastReviewId"),G=(localStorage.getItem("loadpath.repo")||"").trim();if(!P||!G){nr(!1);return}let ce=!1;return Pe.getReview(G,P).then(Se=>{ce||(Fn(Se),Ht(Se.base||localStorage.getItem("loadpath.base")||"HEAD~1",Se.head||localStorage.getItem("loadpath.head")||"HEAD"),zr(G),Bt(G))}).catch(()=>{}).finally(()=>{ce||nr(!1)}),()=>{ce=!0}},[]);const En=L.useRef("");L.useEffect(()=>{if(!et||!o.trim())return;let P=!1;const G=async()=>{try{const Se=await Pe.workspaceStatus(o);if(P)return;En.current&&Se.fingerprint!==En.current&&!nt.current&&(fe(!0),localStorage.setItem("loadpath.dirty","1"),Hr.current()),En.current=Se.fingerprint}catch{}};G();const ce=window.setInterval(G,2e3);return()=>{P=!0,window.clearInterval(ce)}},[et,o]),L.useEffect(()=>{const P=G=>{var Ie;if((G.metaKey||G.ctrlKey)&&G.key.toLowerCase()==="k"){G.preventDefault(),De(Ae=>!Ae);return}if(gi.current){G.key==="Escape"&&(G.preventDefault(),De(!1));return}if(Tr.current){G.key==="Escape"&&(G.preventDefault(),Me(!1));return}const ce=G.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){G.key==="Escape"&&ce.blur();return}if(G.key==="Escape"){w(""),q(""),Je(Xe),at(null);return}if(G.key==="j"||G.key==="k"){const Ae=((Ie=mi.current)==null?void 0:Ie.read_order)||[];if(!Ae.length)return;G.preventDefault();const ur=yi.current,Mn=G.key==="j"?Math.min(Ae.length-1,ur+1):Math.max(0,ur-1);pe(Mn);return}const Se=Gu.find(Ae=>Ae.shortcut===G.key);if(Se&&!G.metaKey&&!G.ctrlKey&&!G.altKey&&r(Se.id),(G.metaKey||G.ctrlKey)&&G.key==="Enter"){if(pt.current==="settings"||pt.current==="prs"||nt.current)return;G.preventDefault(),Hr.current()}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[Xe]);const Hn=async(P,G)=>{if(!o.trim())return;const ce=await mN(o,P,G);ce.ok?q(ce.message):w(ce.message)},Cn=async()=>{if(p)try{const P=await Pe.exportHtml(p),G=URL.createObjectURL(P),ce=document.createElement("a");ce.href=G,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(G),q("Saved HTML brief")}catch(P){w(P instanceof Error?P.message:String(P))}},Kt=async P=>{if(o.trim()){He("Loading stored review…");try{const G=await Pe.getReview(o,P);Fn(G),Ht(G.base||a,G.head||c),j("review"),r("review");const ce=xt.find(Se=>Se.id!==P);if(ce)try{on(await Pe.reviewDiff(o,P,ce.id))}catch{on(null)}}catch(G){w(G instanceof Error?G.message:String(G))}finally{He("")}}},Br={selectedId:ht,onSelect:Je,nodeRoles:p==null?void 0:p.node_roles,testOverlay:yt,isolateSource:qt,onIsolate:at,repoPath:o,onOpenFile:Hn,pinnedId:Xe,onPin:lt},vi=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},{id:"index",group:"Run",label:"Index repository",run:()=>void or(!0)},{id:"watch",group:"Run",label:et?"Stop watching working tree":"Watch working tree",run:()=>{const P=!et;vt(P),localStorage.setItem("loadpath.watch",P?"1":"0")}},{id:"tests",group:"Graph",label:yt?"Hide test overlay":"Show test overlay",run:()=>{const P=!yt;Dt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Cn()},...Gu.map(P=>({id:`tab-${P.id}`,group:"Tabs",label:`Go to ${P.label}`,hint:P.shortcut,run:()=>r(P.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(P=>({id:`node-${P.id}`,group:"Nodes",label:P.name,hint:to(P.type),run:()=>{Je(P.id),r("graph")}})),...xt.slice(0,12).map(P=>({id:`hist-${P.id}`,group:"History",label:P.title||P.id,hint:`${P.level||""} ${P.created_at||""}`.trim(),run:()=>void Kt(P.id)}))],ar=L.useMemo(()=>N==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[N,m,p]),xi=L.useMemo(()=>N==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[N,m,p]),Bn=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Vn=((p==null?void 0:p.findings)||[]).filter(P=>!P.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Gu.map(P=>{const G=P.icon,ce=t===P.id;return d.jsxs("button",{type:"button","data-testid":P.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":P.label,onClick:()=>r(P.id),children:[d.jsx(G,{}),d.jsx("span",{children:P.label})]},P.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:me,onChange:P=>kn(P.target.value),children:["dark","light"].map(P=>d.jsx("optgroup",{label:P==="dark"?"Dark":"Light",children:Dl.filter(G=>G.group===P).map(G=>d.jsx("option",{value:G.id,children:G.label},G.id))},P))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:C||Bn}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[C?d.jsxs("div",{className:b!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","data-testid":"progress",children:[d.jsx("i",{style:b!=null?{width:`${b}%`}:void 0}),d.jsx("span",{className:"sr-only",children:C})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[v.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:v.some(P=>P.path===o)?o:"",disabled:!!C,"aria-busy":z,onChange:P=>{P.target.value&&Or(P.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),v.map(P=>d.jsxs("option",{value:P.path,children:[P.name,P.indexed?` (${P.counts.nodes})`:""]},P.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:P=>{const G=P.target.value;s(G),G.trim()!==Mt.current&&(Mt.current="",wn(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>Me(!0),children:d.jsx(kp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(xp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:P=>Ht(P,c),placeholder:"base",refs:rr,onNeedRefs:Nn})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(xp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:P=>Ht(a,P),placeholder:"head",refs:rr,onNeedRefs:Nn})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:oe?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":oe,onClick:()=>{const P=!oe;fe(P),localStorage.setItem("loadpath.dirty",P?"1":"0")},children:oe?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:et?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":et,onClick:()=>{const P=!et;vt(P),localStorage.setItem("loadpath.watch",P?"1":"0")},children:et?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!C,onClick:fi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!C,onClick:()=>or(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!C,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[E?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:E}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,re?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:re}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>q(""),"aria-label":"Dismiss",children:"×"})]}):null,((wi=p==null?void 0:p.index)!=null&&wi.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((Wn=p==null?void 0:p.index)==null?void 0:Wn.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Oe=p==null?void 0:p.index)==null?void 0:Oe.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(so=p==null?void 0:p.workspace)!=null&&so.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,z?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:C||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":z||Y,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(CN,{review:p,findings:Vn,aiNote:J,busy:!!C,tourIndex:he,onTour:pe,onAskAi:bt,onCopy:ro,onPost:hi,onSelect:Je,onOpenFile:Hn,onExport:Cn,history:xt,diff:rn,onReopen:Kt,onWaiver:(P,G)=>{o.trim()&&Pe.addWaiver(o,P,G||void 0,"from review").then(ce=>{Dn(ce),q(`Waived ${P} in loadpath.yml`)})}}):Rr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Uu,{nodes:p.nodes,edges:p.edges,onWhatIf:bn,focusPath:(lo=p.read_order[he])==null?void 0:lo.path,...Br}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(MN,{architecture:m,busy:!!C,onReindex:()=>or(!1),onReview:jn,onSelect:Je,config:no,health:di,onSaveConfig:P=>{Pe.saveConfig(o,P).then(G=>{Dn(G),q("Wrote loadpath.yml")})},onWaiver:(P,G,ce)=>{Pe.addWaiver(o,P,G,ce).then(Se=>{Dn(Se),q(`Waived ${P}`)})}}):z?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:Y&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(_i=m==null?void 0:m.counts)!=null&&_i.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Uu,{nodes:m.nodes,edges:m.edges,onWhatIf:bn,...Br,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":N==="review","data-testid":"graph-mode-review",className:N==="review"?"active":"",onClick:()=>j("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":N==="architecture","data-testid":"graph-mode-architecture",className:N==="architecture"?"active":"",onClick:()=>j("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:yt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":yt,onClick:()=>{const P=!yt;Dt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")},children:"Tests"})]}),ar.length?d.jsx(Uu,{nodes:ar,edges:xi,onWhatIf:bn,...Br}):Y?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:F,onChange:P=>$r(P.target.value,M,$),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:H.length?"Search your repos":"owner/repo",value:M,onChange:P=>$r(F,P.target.value,$),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:H.map(P=>d.jsxs("option",{value:P.slug,children:[P.private?"private":"public",P.local_path?" · local":""]},P.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!C||!Dr(F),onClick:()=>{jt(F)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!C,onClick:Ve,children:"List PRs"})]}),H.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[H.length," ",F," repositor",H.length===1?"y":"ies",F==="github"&&Z.github_user?` · @${String(Z.github_user)}`:"",F==="gitlab"&&Z.gitlab_user?` · @${String(Z.gitlab_user)}`:"",F==="bitbucket"&&Z.bitbucket_user?` · ${String(Z.bitbucket_user)}`:""]}):null,R.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):R.map(P=>{var G;return d.jsxs("article",{className:"pr","data-testid":`pr-${P.number}`,children:[d.jsxs("h3",{children:["#",P.number," ",P.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${P.draft?"":"open"}`,children:P.draft?"draft":P.state}),d.jsx("span",{children:P.author}),d.jsxs("span",{children:[P.source_branch," → ",P.target_branch]}),P.loadpath?d.jsxs("span",{className:`chip ${P.loadpath.level||""}`,"data-testid":`pr-loadpath-${P.number}`,children:[((G=P.loadpath.level)==null?void 0:G.toUpperCase())||"REVIEWED",P.loadpath.contract_break&&P.loadpath.contract_break!=="none"?` · ${P.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:P.url,target:"_blank",rel:"noreferrer",children:["Open on ",P.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${P.number}`,onClick:()=>void oo(P),children:"Review this PR"})]})]},`${P.provider}-${P.number}`)})]}),t==="settings"&&xe&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:lr,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Dl.map(P=>d.jsxs("button",{type:"button","data-theme":P.id,className:me===P.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${P.id}`,onClick:()=>kn(P.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:P.label}),d.jsx("div",{className:"group",children:P.group})]},P.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:gm(),onChange:P=>gN(P.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:Z.github_token_set?Z.github_user?`Signed in as @${String(Z.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:Z.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void sr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!Nt||!Z.github_oauth_ready,onClick:()=>void io(),children:Nt?"Waiting for GitHub…":"Sign in with GitHub"})})]}),Nt?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:Nt.user_code})," at GitHub if the browser did not fill it in."]}):null,Z.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(Z.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(Z.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:Z.gitlab_token_set?Z.gitlab_user?`Signed in as @${String(Z.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:Z.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void sr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:On||!Z.gitlab_oauth_ready,onClick:()=>void pi(),children:On?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(Z.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(Z.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:Z.bitbucket_token_set?Z.bitbucket_user?`Signed in as ${String(Z.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:Z.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void sr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:Ft||!Z.bitbucket_oauth_ready,onClick:()=>void Fr(),children:Ft?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),Z.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(Z.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(Z.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((ao=Z.ai)==null?void 0:ao.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((uo=Z.ai)==null?void 0:uo.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((co=Z.ai)==null?void 0:co.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(u0,{open:Te,actions:vi,onClose:()=>De(!1)}),je?d.jsx(SN,{initialPath:o,onClose:()=>Me(!1),onSelect:P=>{if(nt.current){w("Wait for the current job to finish before switching workspace.");return}Me(!1),Or(P)}}):null]})}function CN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:x,onOpenFile:m,onExport:y,history:v,diff:_,onReopen:N,onWaiver:j}){var w,C,k,b,A,z,V,Y,K,re,q,Z,te,R,U,H,W;const E=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),E.length?d.jsx("ul",{className:"reasons",children:E.map(M=>d.jsx("li",{children:M},M))}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Xo(M)},M)),(w=t.contract_break)!=null&&w.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&x(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>j(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(C=t.workspace)!=null&&C.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>m(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&x(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(xm,{cards:t.deepening}),(b=(k=t.contract_break)==null?void 0:k.reasons)!=null&&b.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),(z=(A=t.contract_break.sides)==null?void 0:A.rows)!=null&&z.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(V=t.auth)!=null&&V.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(Y=t.suggested_tests)==null?void 0:Y.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(K=t.trend)!=null&&K.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",Xu(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),v.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:v.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,v.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>N(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?Xu(M.created_at):""})]},M.id))]}):null,(q=(re=t.evolution)==null?void 0:re.notes)!=null&&q.length||(te=(Z=t.evolution)==null?void 0:Z.hotspots)!=null&&te.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((R=t.evolution)==null?void 0:R.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((U=t.evolution)==null?void 0:U.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:y,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(H=t.codeowners_reviewers)!=null&&H.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(W=t.knowledge_owners)!=null&&W.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function MN({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var m;const x=t.findings.filter(y=>!y.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${Xu(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(y=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y.name})," — ",(y.django_apps||[]).join(", ")||"no apps"," ·"," ",(y.owners||[]).join(", ")||"unowned"]},y.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(y=>d.jsx("div",{className:"muted",children:y},y))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:x.length})]}),x.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):x.map(y=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>y.node_id&&a(y.node_id),children:[d.jsx("span",{className:`chip ${y.severity}`,children:y.severity}),y.message]})},y.rule+y.message))]}),d.jsx(xm,{cards:t.deepening}),(m=c==null?void 0:c.points)!=null&&m.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(y=>d.jsx("i",{className:y.level||"",title:`${y.level} · ${y.findings} findings`,style:{height:`${8+Math.min(24,(y.findings||0)*4)}px`}},y.id||y.created_at))}),Object.entries(c.contexts).map(([y,v])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y})," — last ",((_=v[v.length-1])==null?void 0:_.findings)??0," findings"]},y)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(c0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((y,v)=>v[1]-y[1]).slice(0,12).map(([y,v])=>d.jsxs("tr",{children:[d.jsx("td",{children:to(y)}),d.jsx("td",{children:v})]},y))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function xm({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:d0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}vm(ym());s0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(EN,{})}));export{Hk as L,RN as a,PN as c,d as j,IN as l,L as r,to as t}; diff --git a/src/loadpath/static/index.html b/src/loadpath/static/index.html index ce9c3e8..d81c363 100644 --- a/src/loadpath/static/index.html +++ b/src/loadpath/static/index.html @@ -17,7 +17,7 @@ - + diff --git a/tests/e2e/test_api_flow.py b/tests/e2e/test_api_flow.py index 7d760ee..e80ed02 100644 --- a/tests/e2e/test_api_flow.py +++ b/tests/e2e/test_api_flow.py @@ -30,7 +30,7 @@ def test_api_health_index_review_graph_settings(tmp_path, monkeypatch): status = client.get("/api/index", params={"repo_path": str(repo)}) assert status.json()["indexed"] is True - assert "nodes" not in status.json() or status.json().get("nodes") is None + assert not status.json().get("nodes") repos = client.get("/api/repos") assert any(r["path"] == str(repo.resolve()) for r in repos.json()["repos"]) @@ -43,6 +43,18 @@ def test_api_health_index_review_graph_settings(tmp_path, monkeypatch): assert any(n["name"] == "InvoicePage" for n in body_arch["nodes"]) assert "celery_tasks_must_be_idempotent_on_model_pk" in body_arch["rules"] + summary_only = client.get("/api/architecture", params={"repo_path": str(repo), "graph": 0}) + assert summary_only.status_code == 200 + assert summary_only.json()["indexed"] is True + assert summary_only.json()["graph_pending"] is True + assert summary_only.json()["nodes"] == [] + assert summary_only.json()["findings"] is not None + + graph_only = client.get("/api/architecture/graph", params={"repo_path": str(repo)}) + assert graph_only.status_code == 200 + assert any(n["name"] == "InvoicePage" for n in graph_only.json()["nodes"]) + assert graph_only.json()["edges"] + review = client.post( "/api/review", json={"repo_path": str(repo), "base": "HEAD~1", "head": "HEAD", "reindex": False}, @@ -276,7 +288,7 @@ def test_blank_and_missing_repo_path_rejected(tmp_path, monkeypatch): assert r.status_code == 400, r.text assert r.json()["detail"] == "repo_path is required" - for url in ("/api/architecture", "/api/graph", "/api/config", "/api/detect", "/api/index"): + for url in ("/api/architecture", "/api/architecture/graph", "/api/graph", "/api/config", "/api/detect", "/api/index"): r = client.get(url, params={"repo_path": ""}) assert r.status_code == 400, r.text assert r.json()["detail"] == "repo_path is required" diff --git a/tests/e2e/test_ui_flows.py b/tests/e2e/test_ui_flows.py index 2abdb35..2c45340 100644 --- a/tests/e2e/test_ui_flows.py +++ b/tests/e2e/test_ui_flows.py @@ -1,6 +1,7 @@ from __future__ import annotations import shutil +import time import pytest @@ -455,3 +456,25 @@ def test_ui_workspace_switch_shows_loading(live_app, browser_page): assert page.get_by_test_id("workspace-select").input_value() == str(repo) page.get_by_test_id("review-empty").wait_for() + +@pytest.mark.playwright +def test_ui_architecture_brief_paints_before_graph(live_app, browser_page): + base_url, repo = live_app + page = browser_page + page.goto(base_url, wait_until="networkidle") + _wait_fonts(page) + + def on_route(route): + if "/api/architecture/graph" in route.request.url: + time.sleep(1.2) + route.continue_() + + page.route("**/api/**", on_route) + page.get_by_test_id("repo-path").fill(str(repo)) + _index_repo(page, repo) + page.get_by_test_id("architecture-brief").locator(".level").wait_for(timeout=20_000) + page.get_by_test_id("graph-loading").wait_for() + assert "drawing" in page.get_by_test_id("graph-loading").inner_text().lower() + page.get_by_test_id("graph-loading").wait_for(state="hidden", timeout=20_000) + wait_visible_graph(page) + diff --git a/tests/unit/test_architecture_load.py b/tests/unit/test_architecture_load.py new file mode 100644 index 0000000..5522647 --- /dev/null +++ b/tests/unit/test_architecture_load.py @@ -0,0 +1,82 @@ +from __future__ import annotations + +import os +import time +from pathlib import Path + +from loadpath.architecture.snapshot import architecture_graph, architecture_report, workspace_index_card +from loadpath.index import default_db_path, file_hash, index_drift, index_repo +from loadpath.config import load_config +from tests.conftest import FIXTURE_ROOT, prepare_review_repo + + +def test_architecture_graph_skips_field_leaves(tmp_path: Path): + store = index_repo(FIXTURE_ROOT, db_path=tmp_path / "g.sqlite3", incremental=False) + nodes, edges = architecture_graph(store) + types = {n["type"] for n in nodes} + assert "django.serializer_field" not in types + assert "django.field" not in types + assert "django.test" not in types + assert "InvoicePage" in {n["name"] for n in nodes} + assert "InvoiceViewSet" in {n["name"] for n in nodes} + ids = {n["id"] for n in nodes} + assert all(e["src"] in ids and e["dst"] in ids for e in edges) + assert len(nodes) < len(store.nodes()) + store.close() + + +def test_architecture_summary_skips_source_file_hashes(tmp_path, monkeypatch): + repo = prepare_review_repo(tmp_path) + index_repo(repo, db_path=default_db_path(repo), incremental=False) + calls: list[str] = [] + real = file_hash + + def wrapped(path: Path) -> str: + calls.append(Path(path).name) + return real(path) + + monkeypatch.setattr("loadpath.index.file_hash", wrapped) + report = architecture_report(repo, include_graph=False) + assert report["indexed"] is True + assert report["graph_pending"] is True + assert report["nodes"] == [] + assert "InvoiceViewSet" not in {n.get("name") for n in report["nodes"]} + assert calls + assert all(name.endswith((".yml", ".yaml", ".json")) or name == "loadpath.yml" for name in calls) + + +def test_workspace_card_does_not_build_the_graph(tmp_path): + repo = prepare_review_repo(tmp_path) + index_repo(repo, db_path=default_db_path(repo), incremental=False) + card = workspace_index_card(repo) + assert card["indexed"] is True + assert card["counts"]["nodes"] > 20 + assert "billing" in card["contexts"] + assert "nodes" not in card + + +def test_mtime_drift_sees_a_touched_file(tmp_path): + repo = prepare_review_repo(tmp_path) + db = default_db_path(repo) + store = index_repo(repo, db_path=db, incremental=False) + config = load_config(repo) + fresh = index_drift(store, repo, config, hash_contents=False) + assert fresh["stale"] is False + target = repo / "backend/billing/serializers.py" + later = time.time() + 5 + os.utime(target, (later, later)) + drifted = index_drift(store, repo, config, hash_contents=False) + assert drifted["stale"] is True + assert any(p.endswith("serializers.py") for p in drifted["changed"]) + store.close() + + +def test_store_type_filter_and_edge_cache(tmp_path: Path): + store = index_repo(FIXTURE_ROOT, db_path=tmp_path / "g.sqlite3", incremental=False) + first = store.edges() + second = store.edges() + assert first is second + views = store.nodes(["django.view"]) + assert views + assert all(n["type"] == "django.view" for n in views) + store.close() diff --git a/ui/src/App.tsx b/ui/src/App.tsx index 49ebaf0..c100ed3 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -68,6 +68,7 @@ export function App() { const [busy, setBusy] = useState(""); const [indexPct, setIndexPct] = useState(null); const [workspaceLoading, setWorkspaceLoading] = useState(false); + const [graphLoading, setGraphLoading] = useState(false); const [copied, setCopied] = useState(""); const [settings, setSettings] = useState>({}); const [prs, setPrs] = useState([]); @@ -112,6 +113,7 @@ export function App() { const explorerOpenRef = useRef(false); explorerOpenRef.current = explorerOpen; const gitRefsPath = useRef(""); + const archHydratePath = useRef(""); const persistTheme = (id: ThemeId) => { setTheme(id); @@ -163,12 +165,9 @@ export function App() { if (tab !== "architecture" || !repo.trim()) return; const requested = repo; let cancelled = false; - api - .architecture(requested) - .then((report) => { - if (!cancelled && repoRef.current === requested) setArchitecture(report); - }) - .catch(() => undefined); + if (archHydratePath.current !== requested) { + void loadArchitecture(requested); + } api .config(requested) .then((doc) => { @@ -184,6 +183,8 @@ export function App() { return () => { cancelled = true; }; + // loadArchitecture is stable enough via repoRef; we only want tab/repo. + // eslint-disable-next-line react-hooks/exhaustive-deps }, [tab, repo]); const persistRepo = (path: string) => { @@ -413,11 +414,28 @@ export function App() { }; }, [gitlabWaiting, loadRemoteRepos]); - const loadArchitecture = async (path = repo) => { + const loadArchitecture = async (path = repo, waitForGraph = false) => { if (!path.trim()) return null; - const report = await api.architecture(path); - if (repoRef.current === path) setArchitecture(report); - return report; + archHydratePath.current = path; + setGraphLoading(true); + try { + const report = await api.architecture(path, false); + if (repoRef.current === path) setArchitecture(report); + const graphP = api.architectureGraph(path).then((g) => { + if (repoRef.current !== path) return; + setArchitecture((prev) => + prev ? { ...prev, nodes: g.nodes, edges: g.edges, graph_pending: false } : prev, + ); + }); + graphP.catch(() => undefined).finally(() => { + if (repoRef.current === path) setGraphLoading(false); + }); + if (waitForGraph) await graphP; + return report; + } catch (e) { + if (repoRef.current === path) setGraphLoading(false); + throw e; + } }; const switchWorkspace = async (path: string) => { @@ -1174,16 +1192,15 @@ export function App() { Uncommitted files overlap this review: {(review.workspace.dirty_overlap || []).slice(0, 6).join(", ")} ) : null} - - -
{workspaceLoading ? ( -
-

{busy}

-

Fetching the indexed graph for this repository.

+
+ {busy || "Loading workspace…"}
) : null} - {!workspaceLoading && tab === "review" && ( +
+ +
+ {tab === "review" && (
)} - {!workspaceLoading && tab === "architecture" && ( + {tab === "architecture" && (
- {architecture?.indexed ? ( + {graphLoading && !(architecture?.nodes || []).length ? ( +
+

Drawing the architecture map…

+

+ {architecture?.counts?.nodes + ? `${architecture.counts.nodes} indexed nodes. The brief is ready while the graph loads.` + : "Fetching the indexed graph."} +

+
+ ) : architecture?.indexed ? ( )} - {!workspaceLoading && tab === "graph" && ( + {tab === "graph" && (
@@ -1351,6 +1381,10 @@ export function App() {
{graphNodes.length ? ( + ) : graphLoading ? ( +

+ Drawing the architecture map… +

) : (

Index the repo or run a review first. Click a node to inspect it. @@ -1359,7 +1393,7 @@ export function App() {

)} - {!workspaceLoading && tab === "prs" && ( + {tab === "prs" && (
)} - {!workspaceLoading && tab === "settings" && settingsReady && ( + {tab === "settings" && settingsReady && (

Settings

diff --git a/ui/src/api.ts b/ui/src/api.ts index 1b5eaa1..6e35316 100644 --- a/ui/src/api.ts +++ b/ui/src/api.ts @@ -88,8 +88,14 @@ export const api = { req(`/api/index?repo_path=${encodeURIComponent(repo_path)}`), indexProgress: (repo_path: string) => req(`/api/index/progress?repo_path=${encodeURIComponent(repo_path)}`), - architecture: (repo_path: string) => - req(`/api/architecture?repo_path=${encodeURIComponent(repo_path)}`), + architecture: (repo_path: string, graph = true) => + req( + `/api/architecture?repo_path=${encodeURIComponent(repo_path)}&graph=${graph ? "1" : "0"}`, + ), + architectureGraph: (repo_path: string) => + req<{ nodes: GraphNode[]; edges: GraphEdge[]; counts: { nodes: number; edges: number } }>( + `/api/architecture/graph?repo_path=${encodeURIComponent(repo_path)}`, + ), review: (repo_path: string, base: string, head?: string, reindex = true, dirty = false) => req("/api/review", { method: "POST", diff --git a/ui/src/types.ts b/ui/src/types.ts index 705156e..a053930 100644 --- a/ui/src/types.ts +++ b/ui/src/types.ts @@ -208,6 +208,7 @@ export type ArchitectureReport = { reindex_skipped?: boolean; files_extracted?: number; boot_residuals?: string[]; + graph_pending?: boolean; }; export type ReviewSummary = { From f85f727d7c94ae2b609bdfc3978715e097951cc4 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 15 Aug 2026 23:49:40 +0000 Subject: [PATCH 05/16] Keep the architecture brief on screen while the graph request is in flight. Trust graph_pending from the summary payload, and delay the graph fetch in the UI test inside window.fetch so Playwright is not blocked on the route. Co-authored-by: zord.lack.net --- ...DtHNGq_6.js => LayeredGraph3D--37-6JMJ.js} | 2 +- .../{index-Pc-bL4kN.js => index-sgthL-dY.js} | 2 +- src/loadpath/static/index.html | 2 +- tests/e2e/test_ui_flows.py | 21 ++++++++++++------- ui/src/App.tsx | 4 ++-- 5 files changed, 18 insertions(+), 13 deletions(-) rename src/loadpath/static/assets/{LayeredGraph3D-DtHNGq_6.js => LayeredGraph3D--37-6JMJ.js} (99%) rename src/loadpath/static/assets/{index-Pc-bL4kN.js => index-sgthL-dY.js} (93%) diff --git a/src/loadpath/static/assets/LayeredGraph3D-DtHNGq_6.js b/src/loadpath/static/assets/LayeredGraph3D--37-6JMJ.js similarity index 99% rename from src/loadpath/static/assets/LayeredGraph3D-DtHNGq_6.js rename to src/loadpath/static/assets/LayeredGraph3D--37-6JMJ.js index e3c7a9e..8e93f92 100644 --- a/src/loadpath/static/assets/LayeredGraph3D-DtHNGq_6.js +++ b/src/loadpath/static/assets/LayeredGraph3D--37-6JMJ.js @@ -1,4 +1,4 @@ -import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-Pc-bL4kN.js";/** +import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-sgthL-dY.js";/** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT diff --git a/src/loadpath/static/assets/index-Pc-bL4kN.js b/src/loadpath/static/assets/index-sgthL-dY.js similarity index 93% rename from src/loadpath/static/assets/index-Pc-bL4kN.js rename to src/loadpath/static/assets/index-sgthL-dY.js index 72bdfce..890b60f 100644 --- a/src/loadpath/static/assets/index-Pc-bL4kN.js +++ b/src/loadpath/static/assets/index-sgthL-dY.js @@ -59,4 +59,4 @@ Error generating stack: `+g.message+` `,` +`).split(` `)),m=x.reduce((y,v)=>y.concat(...v),[]);return[x,m]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Gh,x=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const m=_=>{var E,w;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!x)&&hg(_))return!1;const j=Xh(_.code,h);if(u.current.add(_[j]),Yh(c,u.current,!1)){const C=((w=(E=_.composedPath)==null?void 0:E.call(_))==null?void 0:w[0])||_.target,k=(C==null?void 0:C.nodeName)==="BUTTON"||(C==null?void 0:C.nodeName)==="A";r.preventDefault!==!1&&(a.current||!k)&&_.preventDefault(),s(!0)}},y=_=>{const N=Xh(_.code,h);Yh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[N]),_.key==="Meta"&&u.current.clear(),a.current=!1},v=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",m),p==null||p.addEventListener("keyup",y),window.addEventListener("blur",v),window.addEventListener("contextmenu",v),()=>{p==null||p.removeEventListener("keydown",m),p==null||p.removeEventListener("keyup",y),window.removeEventListener("blur",v),window.removeEventListener("contextmenu",v)}}},[t,s]),o}function Yh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Xh(t,r){return r.includes(t)?"code":"key"}const C_=()=>{const t=Ge();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=_c(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),x={x:r.x-h,y:r.y-p},m=o.snapGrid??a,y=o.snapToGrid??u;return ds(x,s,y,m)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=Zi(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function Ag(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)M_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function M_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function P_(t,r){return Ag(t,r)}function I_(t,r){return Ag(t,r)}function ti(t,r){return{id:t,type:"select",selected:r}}function Ui(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(ti(u.id,c)))}return s}function qh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Kh(t){return{id:t.id,type:"remove"}}const R_=ug();function T_(t,r,o={}){return m1(t,r,{...o,onError:o.onError??R_})}const Qh=t=>t1(t),L_=t=>ig(t);function $g(t){return L.forwardRef(t)}const zg=typeof window<"u"?L.useLayoutEffect:L.useEffect;function Zh(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>A_(()=>o(a=>a+BigInt(1))));return zg(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function A_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Dg=L.createContext(null);function $_({children:t}){const r=Ge(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:x,hasDefaultNodes:m,onNodesChange:y,nodeLookup:v,fitViewQueued:_,onNodesChangeMiddlewareMap:N}=r.getState();let j=p;for(const w of h)j=typeof w=="function"?w(j):w;let E=qh({items:j,lookup:v});for(const w of N.values())E=w(E);m&&x(j),E.length>0?y==null||y(E):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:w,nodes:C,setNodes:k}=r.getState();w&&k(C)})},[]),s=Zh(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:x,hasDefaultEdges:m,onEdgesChange:y,edgeLookup:v}=r.getState();let _=p;for(const N of h)_=typeof N=="function"?N(_):N;m?x(_):y&&y(qh({items:_,lookup:v}))},[]),u=Zh(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Dg.Provider,{value:c,children:t})}function z_(){const t=L.useContext(Dg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const D_=t=>!!t.panZoom;function ql(){const t=C_(),r=Ge(),o=z_(),s=ze(D_),a=L.useMemo(()=>{const u=y=>r.getState().nodeLookup.get(y),c=y=>{o.nodeQueue.push(y)},h=y=>{o.edgeQueue.push(y)},p=y=>{var w,C;const{nodeLookup:v,nodeOrigin:_}=r.getState(),N=Qh(y)?y:v.get(y.id),j=N.parentId?dg(N.position,N.measured,N.parentId,v,_):N.position,E={...N,position:j,width:((w=N.measured)==null?void 0:w.width)??N.width,height:((C=N.measured)==null?void 0:C.height)??N.height};return ns(E)},x=(y,v,_={replace:!1})=>{c(N=>N.map(j=>{if(j.id===y){const E=typeof v=="function"?v(j):v;return _.replace&&Qh(E)?E:{...j,...E}}return j}))},m=(y,v,_={replace:!1})=>{h(N=>N.map(j=>{if(j.id===y){const E=typeof v=="function"?v(j):v;return _.replace&&L_(E)?E:{...j,...E}}return j}))};return{getNodes:()=>r.getState().nodes.map(y=>({...y})),getNode:y=>{var v;return(v=u(y))==null?void 0:v.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:y=[]}=r.getState();return y.map(v=>({...v}))},getEdge:y=>r.getState().edgeLookup.get(y),setNodes:c,setEdges:h,addNodes:y=>{const v=Array.isArray(y)?y:[y];o.nodeQueue.push(_=>[..._,...v])},addEdges:y=>{const v=Array.isArray(y)?y:[y];o.edgeQueue.push(_=>[..._,...v])},toObject:()=>{const{nodes:y=[],edges:v=[],transform:_}=r.getState(),[N,j,E]=_;return{nodes:y.map(w=>({...w})),edges:v.map(w=>({...w})),viewport:{x:N,y:j,zoom:E}}},deleteElements:async({nodes:y=[],edges:v=[]})=>{const{nodes:_,edges:N,onNodesDelete:j,onEdgesDelete:E,triggerNodeChanges:w,triggerEdgeChanges:C,onDelete:k,onBeforeDelete:b}=r.getState(),{nodes:A,edges:z}=await s1({nodesToRemove:y,edgesToRemove:v,nodes:_,edges:N,onBeforeDelete:b}),V=z.length>0,Y=A.length>0;if(V){const K=z.map(Kh);E==null||E(z),C(K)}if(Y){const K=A.map(Kh);j==null||j(A),w(K)}return(Y||V)&&(k==null||k({nodes:A,edges:z})),{deletedNodes:A,deletedEdges:z}},getIntersectingNodes:(y,v=!0,_)=>{const N=Sh(y),j=N?y:p(y),E=_!==void 0;return j?(_||r.getState().nodes).filter(w=>{const C=r.getState().nodeLookup.get(w.id);if(C&&!N&&(w.id===y.id||!C.internals.positionAbsolute))return!1;const k=ns(E?w:C),b=$l(k,j);return v&&b>0||b>=k.width*k.height||b>=j.width*j.height}):[]},isNodeIntersecting:(y,v,_=!0)=>{const j=Sh(y)?y:p(y);if(!j)return!1;const E=$l(j,v);return _&&E>0||E>=v.width*v.height||E>=j.width*j.height},updateNode:x,updateNodeData:(y,v,_={replace:!1})=>{x(y,N=>{const j=typeof v=="function"?v(N):v;return _.replace?{...N,data:j}:{...N,data:{...N.data,...j}}},_)},updateEdge:m,updateEdgeData:(y,v,_={replace:!1})=>{m(y,N=>{const j=typeof v=="function"?v(N):v;return _.replace?{...N,data:j}:{...N,data:{...N.data,...j}}},_)},getNodesBounds:y=>{const{nodeLookup:v,nodeOrigin:_}=r.getState();return n1(y,{nodeLookup:v,nodeOrigin:_})},getHandleConnections:({type:y,id:v,nodeId:_})=>{var N;return Array.from(((N=r.getState().connectionLookup.get(`${_}-${y}${v?`-${v}`:""}`))==null?void 0:N.values())??[])},getNodeConnections:({type:y,handleId:v,nodeId:_})=>{var N;return Array.from(((N=r.getState().connectionLookup.get(`${_}${y?v?`-${y}-${v}`:`-${y}`:""}`))==null?void 0:N.values())??[])},fitView:async y=>{const v=r.getState().fitViewResolver??u1();return r.setState({fitViewQueued:!0,fitViewOptions:y,fitViewResolver:v}),o.nodeQueue.push(_=>[..._]),v.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const Jh=t=>t.selected,O_=typeof window<"u"?window:void 0;function F_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ge(),{deleteElements:s}=ql(),a=is(t,{actInsideInputWithModifier:!1}),u=is(r,{target:O_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(Jh),edges:c.filter(Jh)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function H_(t){const r=Ge();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=Sc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",yn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const Kl={position:"absolute",width:"100%",height:"100%",top:0,left:0},B_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function V_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=ii.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:x,translateExtent:m,minZoom:y,maxZoom:v,zoomActivationKeyCode:_,preventScrolling:N=!0,children:j,noWheelClassName:E,noPanClassName:w,onViewportChange:C,isControlledViewport:k,paneClickDistance:b,selectionOnDrag:A}){const z=Ge(),V=L.useRef(null),{userSelectionActive:Y,lib:K,connectionInProgress:re}=ze(B_,Qe),q=is(_),Z=L.useRef();H_(V);const te=L.useCallback(R=>{C==null||C({x:R[0],y:R[1],zoom:R[2]}),k||z.setState({transform:R})},[C,k]);return L.useEffect(()=>{if(V.current){Z.current=G1({domNode:V.current,minZoom:y,maxZoom:v,translateExtent:m,viewport:x,onDraggingChange:W=>z.setState(M=>M.paneDragging===W?M:{paneDragging:W}),onPanZoomStart:(W,M)=>{const{onViewportChangeStart:D,onMoveStart:F}=z.getState();F==null||F(W,M),D==null||D(M)},onPanZoom:(W,M)=>{const{onViewportChange:D,onMove:F}=z.getState();F==null||F(W,M),D==null||D(M)},onPanZoomEnd:(W,M)=>{const{onViewportChangeEnd:D,onMoveEnd:F}=z.getState();F==null||F(W,M),D==null||D(M)}});const{x:R,y:U,zoom:H}=Z.current.getViewport();return z.setState({panZoom:Z.current,transform:[R,U,H],domNode:V.current.closest(".react-flow")}),()=>{var W;(W=Z.current)==null||W.destroy()}}},[]),L.useEffect(()=>{var R;(R=Z.current)==null||R.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:q,preventScrolling:N,noPanClassName:w,userSelectionActive:Y,noWheelClassName:E,lib:K,onTransformChange:te,connectionInProgress:re,selectionOnDrag:A,paneClickDistance:b})},[t,r,o,s,a,u,c,h,p,q,N,w,Y,E,K,te,re,A,b]),d.jsx("div",{className:"react-flow__renderer",ref:V,style:Kl,children:j})}const W_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function U_(){const{userSelectionActive:t,userSelectionRect:r}=ze(W_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const Vu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},G_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function Y_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=es.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:x,onPaneContextMenu:m,onPaneScroll:y,onPaneMouseEnter:v,onPaneMouseMove:_,onPaneMouseLeave:N,children:j}){const E=L.useRef(0),w=Ge(),{userSelectionActive:C,elementsSelectable:k,dragging:b,panBy:A,autoPanSpeed:z}=ze(G_,Qe),V=k&&(t||C),Y=L.useRef(null),K=L.useRef(),re=L.useRef(new Set),q=L.useRef(new Set),Z=L.useRef(!1),te=L.useRef(!1),R=L.useRef({x:0,y:0}),U=L.useRef(!1),H=J=>{if(te.current||Z.current||w.getState().connection.inProgress){te.current=!1,Z.current=!1;return}x==null||x(J),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},W=J=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){J.preventDefault();return}m==null||m(J)},M=y?J=>y(J):void 0,D=J=>{te.current&&(J.stopPropagation(),te.current=!1)},F=J=>{var De,ht;if(J.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:ae,transform:me}=w.getState();if(K.current=ae==null?void 0:ae.getBoundingClientRect(),!K.current)return;const Ne=J.target===Y.current;if(!Ne&&!!J.target.closest(".nokey")||!t||!(c&&Ne||r)||J.button!==0||!J.isPrimary)return;(ht=(De=J.target)==null?void 0:De.setPointerCapture)==null||ht.call(De,J.pointerId),te.current=!1;const{x:je,y:Me}=mn(J.nativeEvent,K.current),Te=ds({x:je,y:Me},me);w.setState({userSelectionRect:{width:0,height:0,startX:Te.x,startY:Te.y,x:je,y:Me}}),Ne||(J.stopPropagation(),J.preventDefault())};function I(J,ae){const{userSelectionRect:me}=w.getState();if(!me)return;const{transform:Ne,nodeLookup:xe,edgeLookup:ne,connectionLookup:je,triggerNodeChanges:Me,triggerEdgeChanges:Te,defaultEdgeOptions:De}=w.getState(),ht={x:me.startX,y:me.startY},{x:Je,y:Xe}=Zi(ht,Ne),lt={startX:ht.x,startY:ht.y,x:Jat.id)),q.current=new Set;const qt=(De==null?void 0:De.selectable)??!0;for(const at of re.current){const et=je.get(at);if(et)for(const{edgeId:vt}of et.values()){const xt=ne.get(vt);xt&&(xt.selectable??qt)&&q.current.add(vt)}}if(!kh(yt,re.current)){const at=Ui(xe,re.current,!0);Me(at)}if(!kh(Dt,q.current)){const at=Ui(ne,q.current);Te(at)}w.setState({userSelectionRect:lt,userSelectionActive:!0,nodesSelectionActive:!1})}function $(){if(!a||!K.current)return;const[J,ae]=wc(R.current,K.current,z);A({x:J,y:ae}).then(me=>{if(!te.current||!me){E.current=requestAnimationFrame($);return}const{x:Ne,y:xe}=R.current;I(Ne,xe),E.current=requestAnimationFrame($)})}const ie=()=>{cancelAnimationFrame(E.current),E.current=0,U.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=J=>{const{userSelectionRect:ae,transform:me,resetSelectedElements:Ne}=w.getState();if(!K.current||!ae)return;const{x:xe,y:ne}=mn(J.nativeEvent,K.current);R.current={x:xe,y:ne};const je=Zi({x:ae.startX,y:ae.startY},me);if(!te.current){const Me=r?0:u;if(Math.hypot(xe-je.x,ne-je.y)<=Me)return;Ne(),h==null||h(J)}te.current=!0,U.current||($(),U.current=!0),I(xe,ne)},fe=J=>{var ae,me;if(!V){J.target===Y.current&&w.getState().connection.inProgress&&(Z.current=!0);return}J.button===0&&((me=(ae=J.target)==null?void 0:ae.releasePointerCapture)==null||me.call(ae,J.pointerId),!C&&J.target===Y.current&&w.getState().userSelectionRect&&(H==null||H(J)),w.setState({userSelectionActive:!1,userSelectionRect:null}),te.current&&(p==null||p(J),w.setState({nodesSelectionActive:re.current.size>0})),ie())},he=J=>{var ae,me;(me=(ae=J.target)==null?void 0:ae.releasePointerCapture)==null||me.call(ae,J.pointerId),ie()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:it(["react-flow__pane",{draggable:pe,dragging:b,selection:t}]),onClick:V?void 0:Vu(H,Y),onContextMenu:Vu(W,Y),onWheel:Vu(M,Y),onPointerEnter:V?void 0:v,onPointerMove:V?oe:_,onPointerUp:fe,onPointerCancel:V?he:void 0,onPointerDownCapture:V?F:void 0,onClickCapture:V?D:void 0,onPointerLeave:N,ref:Y,style:Kl,children:[j,d.jsx(U_,{})]})}function ac({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),x=h.get(t);if(!x){p==null||p("012",yn.error012(t));return}r.setState({nodesSelectionActive:!1}),x.selected?(o||x.selected&&c)&&(u({nodes:[x],edges:[]}),requestAnimationFrame(()=>{var m;return(m=s==null?void 0:s.current)==null?void 0:m.blur()})):a([t])}function Og({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ge(),[p,x]=L.useState(!1),m=L.useRef();return L.useEffect(()=>{if(!r)return m.current=R1({getStoreItems:()=>h.getState(),onNodeMouseDown:y=>{ac({id:y,store:h,nodeRef:t})},onDragStart:()=>{x(!0)},onDragStop:()=>{x(!1)}}),()=>{var y;(y=m.current)==null||y.destroy(),m.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!m.current||m.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const X_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Fg(){const t=Ge();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:x,nodeOrigin:m}=t.getState(),y=new Map,v=X_(c),_=a?u[0]:5,N=a?u[1]:5,j=o.direction.x*_*o.factor,E=o.direction.y*N*o.factor;for(const[,w]of x){if(!v(w))continue;let C={x:w.internals.positionAbsolute.x+j,y:w.internals.positionAbsolute.y+E};a&&(C=cs(C,u));const{position:k,positionAbsolute:b}=og({nodeId:w.id,nextPosition:C,nodeLookup:x,nodeExtent:s,nodeOrigin:m,onError:h});w.position=k,w.internals.positionAbsolute=b,y.set(w.id,w)}p(y)},[])}const Cc=L.createContext(null),q_=Cc.Provider;Cc.Consumer;const Hg=()=>L.useContext(Cc),K_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Bg=L.createContext(null);function Q_({children:t}){const r=ze(K_,Qe);return d.jsx(Bg.Provider,{value:r,children:t})}function Z_(){const t=L.useContext(Bg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const J_={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},eS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:x}=c;if(!h&&!a)return J_;const m=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:m,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Ki.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:m&&x}};function tS({type:t="source",position:r=ke.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:x,onMouseDown:m,onTouchStart:y,...v},_){var U,H;const N=c||null,j=t==="target",E=Ge(),w=Hg(),{connectOnClick:C,noPanClassName:k,rfId:b}=Z_(),{connectingFrom:A,connectingTo:z,clickConnecting:V,isPossibleEndHandle:Y,connectionInProcess:K,clickConnectionInProcess:re,valid:q}=ze(eS(w,N,t),Qe);w||(H=(U=E.getState()).onError)==null||H.call(U,"010",yn.error010());const Z=W=>{const{defaultEdgeOptions:M,onConnect:D,hasDefaultEdges:F}=E.getState(),I={...M,...W};if(F){const{edges:$,setEdges:ie,onError:oe}=E.getState();ie(T_(I,$,{onError:oe}))}D==null||D(I),h==null||h(I)},te=W=>{if(!w)return;const M=pg(W.nativeEvent);if(a&&(M&&W.button===0||!M)){const D=E.getState();lc.onPointerDown(W.nativeEvent,{handleDomNode:W.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:j,handleId:N,nodeId:w,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...F)=>{var I,$;return($=(I=E.getState()).onConnectEnd)==null?void 0:$.call(I,...F)},updateConnection:D.updateConnection,onConnect:Z,isValidConnection:o||((...F)=>{var I,$;return(($=(I=E.getState()).isValidConnection)==null?void 0:$.call(I,...F))??!0}),getTransform:()=>E.getState().transform,getFromHandle:()=>E.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}M?m==null||m(W):y==null||y(W)},R=W=>{const{onClickConnectStart:M,onClickConnectEnd:D,connectionClickStartHandle:F,connectionMode:I,isValidConnection:$,lib:ie,rfId:oe,nodeLookup:fe,connection:he}=E.getState();if(!w||!F&&!a)return;if(!F){M==null||M(W.nativeEvent,{nodeId:w,handleId:N,handleType:t}),E.setState({connectionClickStartHandle:{nodeId:w,type:t,id:N}});return}const pe=fg(W.target),J=o||$,{connection:ae,isValid:me}=lc.isValid(W.nativeEvent,{handle:{nodeId:w,id:N,type:t},connectionMode:I,fromNodeId:F.nodeId,fromHandleId:F.id||null,fromType:F.type,isValidConnection:J,flowId:oe,doc:pe,lib:ie,nodeLookup:fe});me&&ae&&Z(ae);const Ne=structuredClone(he);delete Ne.inProgress,Ne.toPosition=Ne.toHandle?Ne.toHandle.position:null,D==null||D(W,Ne),E.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":N,"data-nodeid":w,"data-handlepos":r,"data-id":`${b}-${w}-${N}-${t}`,className:it(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",k,x,{source:!j,target:j,connectable:s,connectablestart:a,connectableend:u,clickconnecting:V,connectingfrom:A,connectingto:z,valid:q,connectionindicator:s&&(!K||Y)&&(K||re?u:a)}]),onMouseDown:te,onTouchStart:te,onClick:C?R:void 0,ref:_,...v,children:p})}const eo=L.memo($g(tS));function nS({data:t,isConnectable:r,sourcePosition:o=ke.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(eo,{type:"source",position:o,isConnectable:r})]})}function rS({data:t,isConnectable:r,targetPosition:o=ke.Top,sourcePosition:s=ke.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(eo,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(eo,{type:"source",position:s,isConnectable:r})]})}function iS(){return null}function oS({data:t,isConnectable:r,targetPosition:o=ke.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(eo,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const zl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},ep={input:nS,default:rS,output:oS,group:iS};function sS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const lS=t=>{const{width:r,height:o,x:s,y:a}=us(t.nodeLookup,{filter:u=>!!u.selected});return{width:gn(r)?r:null,height:gn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function aS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ge(),{width:a,height:u,transformString:c,userSelectionActive:h}=ze(lS,Qe),p=Fg(),x=L.useRef(null);L.useEffect(()=>{var _;o||(_=x.current)==null||_.focus({preventScroll:!0})},[o]);const m=!h&&a!==null&&u!==null;if(Og({nodeRef:x,disabled:!m}),!m)return null;const y=t?_=>{const N=s.getState().nodes.filter(j=>j.selected);t(_,N)}:void 0,v=_=>{Object.prototype.hasOwnProperty.call(zl,_.key)&&(_.preventDefault(),p({direction:zl[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:it(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:x,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:o?void 0:-1,onKeyDown:o?void 0:v,style:{width:a,height:u}})})}const tp=typeof window<"u"?window:void 0,uS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Vg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:x,selectionOnDrag:m,selectionMode:y,onSelectionStart:v,onSelectionEnd:_,multiSelectionKeyCode:N,panActivationKeyCode:j,zoomActivationKeyCode:E,elementsSelectable:w,zoomOnScroll:C,zoomOnPinch:k,panOnScroll:b,panOnScrollSpeed:A,panOnScrollMode:z,zoomOnDoubleClick:V,panOnDrag:Y,autoPanOnSelection:K,defaultViewport:re,translateExtent:q,minZoom:Z,maxZoom:te,preventScrolling:R,onSelectionContextMenu:U,noWheelClassName:H,noPanClassName:W,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:F}){const{nodesSelectionActive:I,userSelectionActive:$}=ze(uS,Qe),ie=is(x,{target:tp}),oe=is(j,{target:tp}),fe=oe||Y,he=oe||b,pe=m&&fe!==!0,J=ie||$||pe;return F_({deleteKeyCode:p,multiSelectionKeyCode:N}),d.jsx(V_,{onPaneContextMenu:u,elementsSelectable:w,zoomOnScroll:C,zoomOnPinch:k,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:A,panOnScrollMode:z,zoomOnDoubleClick:V,panOnDrag:!ie&&fe,defaultViewport:re,translateExtent:q,minZoom:Z,maxZoom:te,zoomActivationKeyCode:E,preventScrolling:R,noWheelClassName:H,noPanClassName:W,onViewportChange:D,isControlledViewport:F,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(Y_,{onSelectionStart:v,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:K,isSelecting:!!J,selectionMode:y,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:pe,children:[t,I&&d.jsx(aS,{onSelectionContextMenu:U,noPanClassName:W,disableKeyboardA11y:M})]})})}Vg.displayName="FlowRenderer";const cS=L.memo(Vg),dS=t=>r=>t?xc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function fS(t){return ze(L.useCallback(dS(t),[t]),Qe)}const hS=t=>t.updateNodeInternals;function pS(){const t=ze(hS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function gS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ge(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),x=L.useRef(r),m=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!m||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[m,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const y=x.current!==r,v=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(y||v||_)&&(x.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function mS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:x,nodesFocusable:m,resizeObserver:y,noDragClassName:v,noPanClassName:_,disableKeyboardA11y:N,rfId:j,nodeTypes:E,nodeClickDistance:w,onError:C}){const{node:k,internals:b,isParent:A}=ze(J=>{const ae=J.nodeLookup.get(t),me=J.parentLookup.has(t);return{node:ae,internals:ae.internals,isParent:me}},Qe);let z=k.type||"default",V=(E==null?void 0:E[z])||ep[z];V===void 0&&(C==null||C("003",yn.error003(z)),z="default",V=(E==null?void 0:E.default)||ep.default);const Y=!!(k.draggable||h&&typeof k.draggable>"u"),K=!!(k.selectable||p&&typeof k.selectable>"u"),re=!!(k.connectable||x&&typeof k.connectable>"u"),q=!!(k.focusable||m&&typeof k.focusable>"u"),Z=Ge(),te=cg(k),R=gS({node:k,nodeType:z,hasDimensions:te,resizeObserver:y}),U=Og({nodeRef:R,disabled:k.hidden||!Y,noDragClassName:v,handleSelector:k.dragHandle,nodeId:t,isSelectable:K,nodeClickDistance:w}),H=Fg();if(k.hidden)return null;const W=xn(k),M=sS(k),D=K||Y||r||o||s||a,F=o?J=>o(J,{...b.userNode}):void 0,I=s?J=>s(J,{...b.userNode}):void 0,$=a?J=>a(J,{...b.userNode}):void 0,ie=u?J=>u(J,{...b.userNode}):void 0,oe=c?J=>c(J,{...b.userNode}):void 0,fe=J=>{const{selectNodesOnDrag:ae,nodeDragThreshold:me}=Z.getState();K&&(!ae||!Y||me>0)&&ac({id:t,store:Z,nodeRef:R}),r&&r(J,{...b.userNode})},he=J=>{if(!(hg(J.nativeEvent)||N)){if(eg.includes(J.key)&&K){const ae=J.key==="Escape";ac({id:t,store:Z,unselect:ae,nodeRef:R})}else if(Y&&k.selected&&Object.prototype.hasOwnProperty.call(zl,J.key)){J.preventDefault();const{ariaLabelConfig:ae}=Z.getState();Z.setState({ariaLiveMessage:ae["node.a11yDescription.ariaLiveMessage"]({direction:J.key.replace("Arrow","").toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),H({direction:zl[J.key],factor:J.shiftKey?4:1})}}},pe=()=>{var je;if(N||!((je=R.current)!=null&&je.matches(":focus-visible")))return;const{transform:J,width:ae,height:me,autoPanOnNodeFocus:Ne,setCenter:xe}=Z.getState();if(!Ne)return;xc(new Map([[t,k]]),{x:0,y:0,width:ae,height:me},J,!0).length>0||xe(k.position.x+W.width/2,k.position.y+W.height/2,{zoom:J[2]})};return d.jsx("div",{className:it(["react-flow__node",`react-flow__node-${z}`,{[_]:Y},k.className,{selected:k.selected,selectable:K,parent:A,draggable:Y,dragging:U}]),ref:R,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:te?"visible":"hidden",...k.style,...M},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:F,onMouseMove:I,onMouseLeave:$,onContextMenu:ie,onClick:fe,onDoubleClick:oe,onKeyDown:q?he:void 0,tabIndex:q?0:void 0,onFocus:q?pe:void 0,role:k.ariaRole??(q?"group":void 0),"aria-roledescription":"node","aria-describedby":N?void 0:`${Rg}-${j}`,"aria-label":k.ariaLabel,...k.domAttributes,children:d.jsx(q_,{value:t,children:d.jsx(V,{id:t,data:k.data,type:z,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:k.selected??!1,selectable:K,draggable:Y,deletable:k.deletable??!0,isConnectable:re,sourcePosition:k.sourcePosition,targetPosition:k.targetPosition,dragging:U,dragHandle:k.dragHandle,zIndex:b.z,parentId:k.parentId,...W})})})}var yS=L.memo(mS);const vS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Wg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=ze(vS,Qe),u=fS(t.onlyRenderVisibleElements),c=pS();return d.jsx("div",{className:"react-flow__nodes",style:Kl,children:u.map(h=>d.jsx(yS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Wg.displayName="NodeRenderer";const xS=L.memo(Wg);function wS(t){return ze(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&h1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const _S=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},SS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},np={[ts.Arrow]:_S,[ts.ArrowClosed]:SS};function kS(t){const r=Ge();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(np,t)?np[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",yn.error009(t)),null)},[t])}const NS=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=kS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},Ug=({defaultColor:t,rfId:r})=>{const o=ze(u=>u.edges),s=ze(u=>u.defaultEdgeOptions),a=L.useMemo(()=>_1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(NS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Ug.displayName="MarkerDefinitions";var jS=L.memo(Ug);function Gg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:x,...m}){const[y,v]=L.useState({x:1,y:0,width:0,height:0}),_=it(["react-flow__edge-textwrapper",x]),N=L.useRef(null);return L.useEffect(()=>{if(N.current){const j=N.current.getBBox();v({x:j.x,y:j.y,width:j.width,height:j.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-y.width/2} ${r-y.height/2})`,className:_,visibility:y.width?"visible":"hidden",...m,children:[a&&d.jsx("rect",{width:y.width+2*c[0],x:-c[0],y:-c[1],height:y.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:N,style:s,children:o}),p]}):null}Gg.displayName="EdgeText";const bS=L.memo(Gg);function Ql({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:x=20,...m}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...m,d:t,fill:"none",className:it(["react-flow__edge-path",m.className])}),x?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:x,className:"react-flow__edge-interaction"}):null,s&&gn(r)&&gn(o)?d.jsx(bS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function rp({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===ke.Left||t===ke.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function Yg({sourceX:t,sourceY:r,sourcePosition:o=ke.Bottom,targetX:s,targetY:a,targetPosition:u=ke.Top}){const[c,h]=rp({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,x]=rp({pos:u,x1:s,y1:a,x2:t,y2:r}),[m,y,v,_]=gg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:x});return[`M${t},${r} C${c},${h} ${p},${x} ${s},${a}`,m,y,v,_]}function Xg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:x,labelShowBg:m,labelBgStyle:y,labelBgPadding:v,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,interactionWidth:w})=>{const[C,k,b]=Yg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),A=t.isInternal?void 0:r;return d.jsx(Ql,{id:A,path:C,labelX:k,labelY:b,label:p,labelStyle:x,labelShowBg:m,labelBgStyle:y,labelBgPadding:v,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,interactionWidth:w})})}const ES=Xg({isInternal:!1}),qg=Xg({isInternal:!0});ES.displayName="SimpleBezierEdge";qg.displayName="SimpleBezierEdgeInternal";function Kg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:m,labelBgBorderRadius:y,style:v,sourcePosition:_=ke.Bottom,targetPosition:N=ke.Top,markerEnd:j,markerStart:E,pathOptions:w,interactionWidth:C})=>{const[k,b,A]=ic({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:N,borderRadius:w==null?void 0:w.borderRadius,offset:w==null?void 0:w.offset,stepPosition:w==null?void 0:w.stepPosition}),z=t.isInternal?void 0:r;return d.jsx(Ql,{id:z,path:k,labelX:b,labelY:A,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:m,labelBgBorderRadius:y,style:v,markerEnd:j,markerStart:E,interactionWidth:C})})}const Qg=Kg({isInternal:!1}),Zg=Kg({isInternal:!0});Qg.displayName="SmoothStepEdge";Zg.displayName="SmoothStepEdgeInternal";function Jg(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(Qg,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const CS=Jg({isInternal:!1}),em=Jg({isInternal:!0});CS.displayName="StepEdge";em.displayName="StepEdgeInternal";function tm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:m,labelBgBorderRadius:y,style:v,markerEnd:_,markerStart:N,interactionWidth:j})=>{const[E,w,C]=vg({sourceX:o,sourceY:s,targetX:a,targetY:u}),k=t.isInternal?void 0:r;return d.jsx(Ql,{id:k,path:E,labelX:w,labelY:C,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:m,labelBgBorderRadius:y,style:v,markerEnd:_,markerStart:N,interactionWidth:j})})}const MS=tm({isInternal:!1}),nm=tm({isInternal:!0});MS.displayName="StraightEdge";nm.displayName="StraightEdgeInternal";function rm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=ke.Bottom,targetPosition:h=ke.Top,label:p,labelStyle:x,labelShowBg:m,labelBgStyle:y,labelBgPadding:v,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,pathOptions:w,interactionWidth:C})=>{const[k,b,A]=mg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:w==null?void 0:w.curvature}),z=t.isInternal?void 0:r;return d.jsx(Ql,{id:z,path:k,labelX:b,labelY:A,label:p,labelStyle:x,labelShowBg:m,labelBgStyle:y,labelBgPadding:v,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,interactionWidth:C})})}const PS=rm({isInternal:!1}),im=rm({isInternal:!0});PS.displayName="BezierEdge";im.displayName="BezierEdgeInternal";const ip={default:im,straight:nm,step:em,smoothstep:Zg,simplebezier:qg},op={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},IS=(t,r,o)=>o===ke.Left?t-r:o===ke.Right?t+r:t,RS=(t,r,o)=>o===ke.Top?t-r:o===ke.Bottom?t+r:t,sp="react-flow__edgeupdater";function lp({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:it([sp,`${sp}-${h}`]),cx:IS(r,s,t),cy:RS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function TS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:x,onReconnectStart:m,onReconnectEnd:y,setReconnecting:v,setUpdateHover:_}){const N=Ge(),j=(b,A)=>{if(b.button!==0)return;const{autoPanOnConnect:z,domNode:V,connectionMode:Y,connectionRadius:K,lib:re,onConnectStart:q,cancelConnection:Z,nodeLookup:te,rfId:R,panBy:U,updateConnection:H}=N.getState(),W=A.type==="target",M=(I,$)=>{v(!1),y==null||y(I,o,A.type,$)},D=I=>x==null?void 0:x(o,I),F=(I,$)=>{v(!0),m==null||m(b,o,A.type),q==null||q(I,$)};lc.onPointerDown(b.nativeEvent,{autoPanOnConnect:z,connectionMode:Y,connectionRadius:K,domNode:V,handleId:A.id,nodeId:A.nodeId,nodeLookup:te,isTarget:W,edgeUpdaterType:A.type,lib:re,flowId:R,cancelConnection:Z,panBy:U,isValidConnection:(...I)=>{var $,ie;return((ie=($=N.getState()).isValidConnection)==null?void 0:ie.call($,...I))??!0},onConnect:D,onConnectStart:F,onConnectEnd:(...I)=>{var $,ie;return(ie=($=N.getState()).onConnectEnd)==null?void 0:ie.call($,...I)},onReconnectEnd:M,updateConnection:H,getTransform:()=>N.getState().transform,getFromHandle:()=>N.getState().connection.fromHandle,dragThreshold:N.getState().connectionDragThreshold,handleDomNode:b.currentTarget})},E=b=>j(b,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),w=b=>j(b,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),C=()=>_(!0),k=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(lp,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:E,onMouseEnter:C,onMouseOut:k,type:"source"}),(t===!0||t==="target")&&d.jsx(lp,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:w,onMouseEnter:C,onMouseOut:k,type:"target"})]})}function LS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:x,reconnectRadius:m,onReconnect:y,onReconnectStart:v,onReconnectEnd:_,rfId:N,edgeTypes:j,noPanClassName:E,onError:w,disableKeyboardA11y:C}){let k=ze(xe=>xe.edgeLookup.get(t));const b=ze(xe=>xe.defaultEdgeOptions);k=b?{...b,...k}:k;let A=k.type||"default",z=(j==null?void 0:j[A])||ip[A];z===void 0&&(w==null||w("011",yn.error011(A)),A="default",z=(j==null?void 0:j.default)||ip.default);const V=!!(k.focusable||r&&typeof k.focusable>"u"),Y=typeof y<"u"&&(k.reconnectable||o&&typeof k.reconnectable>"u"),K=!!(k.selectable||s&&typeof k.selectable>"u"),re=L.useRef(null),[q,Z]=L.useState(!1),[te,R]=L.useState(!1),U=Ge(),{zIndex:H=k.zIndex,sourceX:W,sourceY:M,targetX:D,targetY:F,sourcePosition:I,targetPosition:$}=ze(L.useCallback(xe=>{const ne=xe.nodeLookup.get(k.source),je=xe.nodeLookup.get(k.target);if(!ne||!je)return op;const Me=w1({id:t,sourceNode:ne,targetNode:je,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:xe.connectionMode,onError:w}),Te=f1({selected:k.selected,zIndex:k.zIndex,sourceNode:ne,targetNode:je,elevateOnSelect:xe.elevateEdgesOnSelect,zIndexMode:xe.zIndexMode});return{...Me||op,zIndex:Te}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex,w]),Qe),ie=L.useMemo(()=>k.markerStart?`url('#${oc(k.markerStart,N)}')`:void 0,[k.markerStart,N]),oe=L.useMemo(()=>k.markerEnd?`url('#${oc(k.markerEnd,N)}')`:void 0,[k.markerEnd,N]);if(k.hidden||W===null||M===null||D===null||F===null)return null;const fe=xe=>{var Te;const{addSelectedEdges:ne,unselectNodesAndEdges:je,multiSelectionActive:Me}=U.getState();K&&(U.setState({nodesSelectionActive:!1}),k.selected&&Me?(je({nodes:[],edges:[k]}),(Te=re.current)==null||Te.blur()):ne([t])),a&&a(xe,k)},he=u?xe=>{u(xe,{...k})}:void 0,pe=c?xe=>{c(xe,{...k})}:void 0,J=h?xe=>{h(xe,{...k})}:void 0,ae=p?xe=>{p(xe,{...k})}:void 0,me=x?xe=>{x(xe,{...k})}:void 0,Ne=xe=>{var ne;if(!C&&eg.includes(xe.key)&&K){const{unselectNodesAndEdges:je,addSelectedEdges:Me}=U.getState();xe.key==="Escape"?((ne=re.current)==null||ne.blur(),je({edges:[k]})):Me([t])}};return d.jsx("svg",{style:{zIndex:H},children:d.jsxs("g",{className:it(["react-flow__edge",`react-flow__edge-${A}`,k.className,E,{selected:k.selected,animated:k.animated,inactive:!K&&!a,updating:q,selectable:K}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:J,onMouseMove:ae,onMouseLeave:me,onKeyDown:V?Ne:void 0,tabIndex:V?0:void 0,role:k.ariaRole??(V?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":k.ariaLabel===null?void 0:k.ariaLabel||`Edge from ${k.source} to ${k.target}`,"aria-describedby":V?`${Tg}-${N}`:void 0,ref:re,...k.domAttributes,children:[!te&&d.jsx(z,{id:t,source:k.source,target:k.target,type:k.type,selected:k.selected,animated:k.animated,selectable:K,deletable:k.deletable??!0,label:k.label,labelStyle:k.labelStyle,labelShowBg:k.labelShowBg,labelBgStyle:k.labelBgStyle,labelBgPadding:k.labelBgPadding,labelBgBorderRadius:k.labelBgBorderRadius,sourceX:W,sourceY:M,targetX:D,targetY:F,sourcePosition:I,targetPosition:$,data:k.data,style:k.style,sourceHandleId:k.sourceHandle,targetHandleId:k.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in k?k.pathOptions:void 0,interactionWidth:k.interactionWidth}),Y&&d.jsx(TS,{edge:k,isReconnectable:Y,reconnectRadius:m,onReconnect:y,onReconnectStart:v,onReconnectEnd:_,sourceX:W,sourceY:M,targetX:D,targetY:F,sourcePosition:I,targetPosition:$,setUpdateHover:Z,setReconnecting:R})]})})}var AS=L.memo(LS);const $S=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function om({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:x,onEdgeClick:m,reconnectRadius:y,onEdgeDoubleClick:v,onReconnectStart:_,onReconnectEnd:N,disableKeyboardA11y:j}){const{edgesFocusable:E,edgesReconnectable:w,elementsSelectable:C,onError:k}=ze($S,Qe),b=wS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(jS,{defaultColor:t,rfId:o}),b.map(A=>d.jsx(AS,{id:A,edgesFocusable:E,edgesReconnectable:w,elementsSelectable:C,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:x,onClick:m,reconnectRadius:y,onDoubleClick:v,onReconnectStart:_,onReconnectEnd:N,rfId:o,onError:k,edgeTypes:s,disableKeyboardA11y:j},A))]})}om.displayName="EdgeRenderer";const zS=L.memo(om),ap=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function DS({children:t}){const r=Ge(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return zg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=ap(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:ap(s)},children:t})}function OS(t){const r=ql(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const FS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function HS(t){const r=ze(FS),o=Ge();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function BS(t){return t.connection.inProgress?{...t.connection,to:ds(t.connection.to,t.transform)}:{...t.connection}}function VS(t){return BS}function WS(t){const r=VS();return ze(r,Qe)}const US=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function GS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=ze(US,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:it(["react-flow__connection",rg(h)]),children:d.jsx(sm,{style:r,type:o,CustomComponent:s,isValid:h})})})}const sm=({style:t,type:r=Mr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:x,toNode:m,toHandle:y,toPosition:v,pointer:_}=WS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:x.x,toY:x.y,fromPosition:p,toPosition:v,connectionStatus:rg(s),toNode:m,toHandle:y,pointer:_});let N="";const j={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:x.x,targetY:x.y,targetPosition:v};switch(r){case Mr.Bezier:[N]=mg(j);break;case Mr.SimpleBezier:[N]=Yg(j);break;case Mr.Step:[N]=ic({...j,borderRadius:0});break;case Mr.SmoothStep:[N]=ic(j);break;default:[N]=vg(j)}return d.jsx("path",{d:N,fill:"none",className:"react-flow__connection-path",style:t})};sm.displayName="ConnectionLine";const YS={};function up(t=YS){L.useRef(t),Ge(),L.useEffect(()=>{},[t])}function XS(){Ge(),L.useRef(!1),L.useEffect(()=>{},[])}function lm({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:m,onSelectionContextMenu:y,onSelectionStart:v,onSelectionEnd:_,connectionLineType:N,connectionLineStyle:j,connectionLineComponent:E,connectionLineContainerStyle:w,selectionKeyCode:C,selectionOnDrag:k,selectionMode:b,multiSelectionKeyCode:A,panActivationKeyCode:z,zoomActivationKeyCode:V,deleteKeyCode:Y,onlyRenderVisibleElements:K,elementsSelectable:re,defaultViewport:q,translateExtent:Z,minZoom:te,maxZoom:R,preventScrolling:U,defaultMarkerColor:H,zoomOnScroll:W,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:F,panOnScrollMode:I,zoomOnDoubleClick:$,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:J,onPaneScroll:ae,onPaneContextMenu:me,paneClickDistance:Ne,nodeClickDistance:xe,onEdgeContextMenu:ne,onEdgeMouseEnter:je,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:De,onReconnect:ht,onReconnectStart:Je,onReconnectEnd:Xe,noDragClassName:lt,noWheelClassName:yt,noPanClassName:Dt,disableKeyboardA11y:qt,nodeExtent:at,rfId:et,viewport:vt,onViewportChange:xt,nodesDraggable:zn}){return up(t),up(r),XS(),OS(o),HS(vt),d.jsx(cS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:J,onPaneContextMenu:me,onPaneScroll:ae,paneClickDistance:Ne,deleteKeyCode:Y,selectionKeyCode:C,selectionOnDrag:k,selectionMode:b,onSelectionStart:v,onSelectionEnd:_,multiSelectionKeyCode:A,panActivationKeyCode:z,zoomActivationKeyCode:V,elementsSelectable:re,zoomOnScroll:W,zoomOnPinch:M,zoomOnDoubleClick:$,panOnScroll:D,panOnScrollSpeed:F,panOnScrollMode:I,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:q,translateExtent:Z,minZoom:te,maxZoom:R,onSelectionContextMenu:y,preventScrolling:U,noDragClassName:lt,noWheelClassName:yt,noPanClassName:Dt,disableKeyboardA11y:qt,onViewportChange:xt,isControlledViewport:!!vt,children:d.jsxs(DS,{children:[d.jsx(zS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:ht,onReconnectStart:Je,onReconnectEnd:Xe,onlyRenderVisibleElements:K,onEdgeContextMenu:ne,onEdgeMouseEnter:je,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:De,defaultMarkerColor:H,noPanClassName:Dt,disableKeyboardA11y:qt,rfId:et}),d.jsx(GS,{style:j,type:N,component:E,containerStyle:w}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(xS,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:m,nodeClickDistance:xe,onlyRenderVisibleElements:K,noPanClassName:Dt,noDragClassName:lt,disableKeyboardA11y:qt,nodeExtent:at,rfId:et,nodesDraggable:zn}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}lm.displayName="GraphView";const qS=L.memo(lm),KS=ug(),cp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:x=2,nodeOrigin:m,nodeExtent:y,zIndexMode:v="basic"}={})=>{const _=new Map,N=new Map,j=new Map,E=new Map,w=s??r??[],C=o??t??[],k=m??[0,0],b=y??Jo;_g(j,E,w);const{nodesInitialized:A}=sc(C,_,N,{nodeOrigin:k,nodeExtent:b,zIndexMode:v});let z=[0,0,1];if(c&&a&&u){const V=us(_,{filter:q=>!!((q.width||q.initialWidth)&&(q.height||q.initialHeight))}),{x:Y,y:K,zoom:re}=_c(V,a,u,p,x,(h==null?void 0:h.padding)??.1);z=[Y,K,re]}return{rfId:"1",width:a??0,height:u??0,transform:z,nodes:C,nodesInitialized:A,nodeLookup:_,parentLookup:N,edges:w,edgeLookup:E,connectionLookup:j,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:x,translateExtent:Jo,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ki.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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...ng},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:KS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:tg,zIndexMode:v,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},QS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:x,nodeOrigin:m,nodeExtent:y,zIndexMode:v})=>u_((_,N)=>{async function j(){const{nodeLookup:E,panZoom:w,fitViewOptions:C,fitViewResolver:k,width:b,height:A,minZoom:z,maxZoom:V}=N();w&&(await o1({nodes:E,width:b,height:A,panZoom:w,minZoom:z,maxZoom:V},C),k==null||k.resolve(!0),_({fitViewResolver:null}))}return{...cp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:x,nodeOrigin:m,nodeExtent:y,defaultNodes:o,defaultEdges:s,zIndexMode:v}),setNodes:E=>{const{nodeLookup:w,parentLookup:C,nodeOrigin:k,nodeExtent:b,elevateNodesOnSelect:A,fitViewQueued:z,zIndexMode:V,nodesSelectionActive:Y}=N(),{nodesInitialized:K,hasSelectedNodes:re}=sc(E,w,C,{nodeOrigin:k,nodeExtent:b,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:V}),q=Y&&re;z&&K?(j(),_({nodes:E,nodesInitialized:K,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:q})):_({nodes:E,nodesInitialized:K,nodesSelectionActive:q})},setEdges:E=>{const{connectionLookup:w,edgeLookup:C}=N();_g(w,C,E),_({edges:E})},setDefaultNodesAndEdges:(E,w)=>{if(E){const{setNodes:C}=N();C(E),_({hasDefaultNodes:!0})}if(w){const{setEdges:C}=N();C(w),_({hasDefaultEdges:!0})}},updateNodeInternals:E=>{const{triggerNodeChanges:w,nodeLookup:C,parentLookup:k,domNode:b,nodeOrigin:A,nodeExtent:z,debug:V,fitViewQueued:Y,zIndexMode:K}=N(),{changes:re,updatedInternals:q}=C1(E,C,k,b,A,z,K);q&&(N1(C,k,{nodeOrigin:A,nodeExtent:z,zIndexMode:K}),Y?(j(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(re==null?void 0:re.length)>0&&(V&&console.log("React Flow: trigger node changes",re),w==null||w(re)))},updateNodePositions:(E,w=!1)=>{const C=[];let k=[];const{nodeLookup:b,triggerNodeChanges:A,connection:z,updateConnection:V,onNodesChangeMiddlewareMap:Y}=N();for(const[K,re]of E){const q=b.get(K),Z=!!(q!=null&&q.expandParent&&(q!=null&&q.parentId)&&(re!=null&&re.position)),te={id:K,type:"position",position:Z?{x:Math.max(0,re.position.x),y:Math.max(0,re.position.y)}:re.position,dragging:w};if(q&&z.inProgress&&z.fromNode.id===q.id){const R=ui(q,z.fromHandle,ke.Left,!0);V({...z,from:R})}Z&&q.parentId&&C.push({id:K,parentId:q.parentId,rect:{...re.internals.positionAbsolute,width:re.measured.width??0,height:re.measured.height??0}}),k.push(te)}if(C.length>0){const{parentLookup:K,nodeOrigin:re}=N(),q=Ec(C,b,K,re);k.push(...q)}for(const K of Y.values())k=K(k);A(k)},triggerNodeChanges:E=>{const{onNodesChange:w,setNodes:C,nodes:k,hasDefaultNodes:b,debug:A}=N();if(E!=null&&E.length){if(b){const z=P_(E,k);C(z)}A&&console.log("React Flow: trigger node changes",E),w==null||w(E)}},triggerEdgeChanges:E=>{const{onEdgesChange:w,setEdges:C,edges:k,hasDefaultEdges:b,debug:A}=N();if(E!=null&&E.length){if(b){const z=I_(E,k);C(z)}A&&console.log("React Flow: trigger edge changes",E),w==null||w(E)}},addSelectedNodes:E=>{const{multiSelectionActive:w,edgeLookup:C,nodeLookup:k,triggerNodeChanges:b,triggerEdgeChanges:A}=N();if(w){const z=E.map(V=>ti(V,!0));b(z);return}b(Ui(k,new Set([...E]),!0)),A(Ui(C))},addSelectedEdges:E=>{const{multiSelectionActive:w,edgeLookup:C,nodeLookup:k,triggerNodeChanges:b,triggerEdgeChanges:A}=N();if(w){const z=E.map(V=>ti(V,!0));A(z);return}A(Ui(C,new Set([...E]))),b(Ui(k,new Set,!0))},unselectNodesAndEdges:({nodes:E,edges:w}={})=>{const{edges:C,nodes:k,nodeLookup:b,triggerNodeChanges:A,triggerEdgeChanges:z}=N(),V=E||k,Y=w||C,K=[];for(const q of V){if(!q.selected)continue;const Z=b.get(q.id);Z&&(Z.selected=!1),K.push(ti(q.id,!1))}const re=[];for(const q of Y)q.selected&&re.push(ti(q.id,!1));A(K),z(re)},setMinZoom:E=>{const{panZoom:w,maxZoom:C}=N();w==null||w.setScaleExtent([E,C]),_({minZoom:E})},setMaxZoom:E=>{const{panZoom:w,minZoom:C}=N();w==null||w.setScaleExtent([C,E]),_({maxZoom:E})},setTranslateExtent:E=>{var w;(w=N().panZoom)==null||w.setTranslateExtent(E),_({translateExtent:E})},resetSelectedElements:()=>{const{edges:E,nodes:w,triggerNodeChanges:C,triggerEdgeChanges:k,elementsSelectable:b}=N();if(!b)return;const A=w.reduce((V,Y)=>Y.selected?[...V,ti(Y.id,!1)]:V,[]),z=E.reduce((V,Y)=>Y.selected?[...V,ti(Y.id,!1)]:V,[]);C(A),k(z)},setNodeExtent:E=>{const{nodes:w,nodeLookup:C,parentLookup:k,nodeOrigin:b,elevateNodesOnSelect:A,nodeExtent:z,zIndexMode:V}=N();E[0][0]===z[0][0]&&E[0][1]===z[0][1]&&E[1][0]===z[1][0]&&E[1][1]===z[1][1]||(sc(w,C,k,{nodeOrigin:b,nodeExtent:E,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:V}),_({nodeExtent:E}))},panBy:E=>{const{transform:w,width:C,height:k,panZoom:b,translateExtent:A}=N();return M1({delta:E,panZoom:b,transform:w,translateExtent:A,width:C,height:k})},setCenter:async(E,w,C)=>{const{width:k,height:b,maxZoom:A,panZoom:z}=N();if(!z)return!1;const V=typeof(C==null?void 0:C.zoom)<"u"?C.zoom:A;return await z.setViewport({x:k/2-E*V,y:b/2-w*V,zoom:V},{duration:C==null?void 0:C.duration,ease:C==null?void 0:C.ease,interpolate:C==null?void 0:C.interpolate}),!0},cancelConnection:()=>{_({connection:{...ng}})},updateConnection:E=>{_({connection:E})},reset:()=>_({...cp()})}},Object.is);function am({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:x,nodeOrigin:m,nodeExtent:y,zIndexMode:v,children:_}){const[N]=L.useState(()=>QS({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:x,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:m,nodeExtent:y,zIndexMode:v}));return d.jsx(c_,{value:N,children:d.jsx($_,{children:d.jsx(Q_,{children:_})})})}function ZS({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:x,maxZoom:m,nodeOrigin:y,nodeExtent:v,zIndexMode:_}){return L.useContext(Yl)?d.jsx(d.Fragment,{children:t}):d.jsx(am,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:x,initialMaxZoom:m,nodeOrigin:y,nodeExtent:v,zIndexMode:_,children:t})}const JS={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function ek({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:x,onMove:m,onMoveStart:y,onMoveEnd:v,onConnect:_,onConnectStart:N,onConnectEnd:j,onClickConnectStart:E,onClickConnectEnd:w,onNodeMouseEnter:C,onNodeMouseMove:k,onNodeMouseLeave:b,onNodeContextMenu:A,onNodeDoubleClick:z,onNodeDragStart:V,onNodeDrag:Y,onNodeDragStop:K,onNodesDelete:re,onEdgesDelete:q,onDelete:Z,onSelectionChange:te,onSelectionDragStart:R,onSelectionDrag:U,onSelectionDragStop:H,onSelectionContextMenu:W,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:F,connectionMode:I,connectionLineType:$=Mr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:J=!1,selectionMode:ae=es.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:Ne=rs()?"Meta":"Control",zoomActivationKeyCode:xe=rs()?"Meta":"Control",snapToGrid:ne,snapGrid:je,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Te,nodesDraggable:De,autoPanOnNodeFocus:ht,nodesConnectable:Je,nodesFocusable:Xe,nodeOrigin:lt=Lg,edgesFocusable:yt,edgesReconnectable:Dt,elementsSelectable:qt=!0,defaultViewport:at=k_,minZoom:et=.5,maxZoom:vt=2,translateExtent:xt=Jo,preventScrolling:zn=!0,nodeExtent:rn,defaultMarkerColor:on="#b1b1b7",zoomOnScroll:no=!0,zoomOnPinch:Dn=!0,panOnScroll:di=!1,panOnScrollSpeed:Ir=.5,panOnScrollMode:Rr=ii.Free,zoomOnDoubleClick:nr=!0,panOnDrag:rr=!0,onPaneClick:wn,onPaneMouseEnter:Nt,onPaneMouseMove:Ot,onPaneMouseLeave:Ft,onPaneScroll:_n,onPaneContextMenu:On,paneClickDistance:Sn=1,nodeClickDistance:ut=0,children:Tr,onReconnect:Mt,onReconnectStart:Lr,onReconnectEnd:kn,onEdgeContextMenu:nt,onEdgeDoubleClick:He,onEdgeMouseEnter:Ar,onEdgeMouseMove:sn,onEdgeMouseLeave:Pt,reconnectRadius:Nn=10,onNodesChange:Ht,onEdgesChange:$r,noDragClassName:Fn="nodrag",noWheelClassName:zr="nowheel",noPanClassName:Bt="nopan",fitView:Dr,fitViewOptions:jt,connectOnClick:ir,attributionPosition:Or,proOptions:jn,defaultEdgeOptions:or,elevateNodesOnSelect:fi=!0,elevateEdgesOnSelect:ro=!1,disableKeyboardA11y:hi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:io,autoPanOnSelection:Fr=!0,autoPanSpeed:pi,connectionRadius:bn,isValidConnection:oo,onError:sr,style:lr,id:bt,nodeDragThreshold:Hr,connectionDragThreshold:pt,viewport:gi,onViewportChange:mi,width:yi,height:En,colorMode:Hn="light",debug:Cn,onScroll:Kt,ariaLabelConfig:Br,zIndexMode:vi="basic",...ar},xi){const Bn=bt||"1",Vn=E_(Hn),wi=L.useCallback(Wn=>{Wn.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Kt==null||Kt(Wn)},[Kt]);return d.jsx("div",{"data-testid":"rf__wrapper",...ar,onScroll:wi,style:{...lr,...JS},ref:xi,className:it(["react-flow",a,Vn]),id:bt,role:"application",children:d.jsxs(ZS,{nodes:t,edges:r,width:yi,height:En,fitView:Dr,fitViewOptions:jt,minZoom:et,maxZoom:vt,nodeOrigin:lt,nodeExtent:rn,zIndexMode:vi,children:[d.jsx(b_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:N,onConnectEnd:j,onClickConnectStart:E,onClickConnectEnd:w,nodesDraggable:De,autoPanOnNodeFocus:ht,nodesConnectable:Je,nodesFocusable:Xe,edgesFocusable:yt,edgesReconnectable:Dt,elementsSelectable:qt,elevateNodesOnSelect:fi,elevateEdgesOnSelect:ro,minZoom:et,maxZoom:vt,nodeExtent:rn,onNodesChange:Ht,onEdgesChange:$r,snapToGrid:ne,snapGrid:je,connectionMode:I,translateExtent:xt,connectOnClick:ir,defaultEdgeOptions:or,fitView:Dr,fitViewOptions:jt,onNodesDelete:re,onEdgesDelete:q,onDelete:Z,onNodeDragStart:V,onNodeDrag:Y,onNodeDragStop:K,onSelectionDrag:U,onSelectionDragStart:R,onSelectionDragStop:H,onMove:m,onMoveStart:y,onMoveEnd:v,noPanClassName:Bt,nodeOrigin:lt,rfId:Bn,autoPanOnConnect:Ve,autoPanOnNodeDrag:io,autoPanSpeed:pi,onError:sr,connectionRadius:bn,isValidConnection:oo,selectNodesOnDrag:Te,nodeDragThreshold:Hr,connectionDragThreshold:pt,onBeforeDelete:F,debug:Cn,ariaLabelConfig:Br,zIndexMode:vi}),d.jsx(qS,{onInit:x,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:C,onNodeMouseMove:k,onNodeMouseLeave:b,onNodeContextMenu:A,onNodeDoubleClick:z,nodeTypes:u,edgeTypes:c,connectionLineType:$,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:J,selectionMode:ae,deleteKeyCode:he,multiSelectionKeyCode:Ne,panActivationKeyCode:me,zoomActivationKeyCode:xe,onlyRenderVisibleElements:Me,defaultViewport:at,translateExtent:xt,minZoom:et,maxZoom:vt,preventScrolling:zn,zoomOnScroll:no,zoomOnPinch:Dn,zoomOnDoubleClick:nr,panOnScroll:di,panOnScrollSpeed:Ir,panOnScrollMode:Rr,panOnDrag:rr,autoPanOnSelection:Fr,onPaneClick:wn,onPaneMouseEnter:Nt,onPaneMouseMove:Ot,onPaneMouseLeave:Ft,onPaneScroll:_n,onPaneContextMenu:On,paneClickDistance:Sn,nodeClickDistance:ut,onSelectionContextMenu:W,onSelectionStart:M,onSelectionEnd:D,onReconnect:Mt,onReconnectStart:Lr,onReconnectEnd:kn,onEdgeContextMenu:nt,onEdgeDoubleClick:He,onEdgeMouseEnter:Ar,onEdgeMouseMove:sn,onEdgeMouseLeave:Pt,reconnectRadius:Nn,defaultMarkerColor:on,noDragClassName:Fn,noWheelClassName:zr,noPanClassName:Bt,rfId:Bn,disableKeyboardA11y:hi,nodeExtent:rn,viewport:gi,onViewportChange:mi,nodesDraggable:De}),d.jsx(S_,{onSelectionChange:te}),Tr,d.jsx(y_,{proOptions:jn,position:Or}),d.jsx(m_,{rfId:Bn,disableKeyboardA11y:hi})]})})}var tk=$g(ek);function nk({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:it(["react-flow__background-pattern",o,s])})}function rk({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:it(["react-flow__background-pattern","dots",r])})}var Pr;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Pr||(Pr={}));const ik={[Pr.Dots]:1,[Pr.Lines]:1,[Pr.Cross]:6},ok=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function um({id:t,variant:r=Pr.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:x,patternClassName:m}){const y=L.useRef(null),{transform:v,patternId:_}=ze(ok,Qe),N=s||ik[r],j=r===Pr.Dots,E=r===Pr.Cross,w=Array.isArray(o)?o:[o,o],C=[w[0]*v[2]||1,w[1]*v[2]||1],k=N*v[2],b=Array.isArray(u)?u:[u,u],A=E?[k,k]:C,z=[b[0]*v[2]+A[0]/2,b[1]*v[2]+A[1]/2],V=`${_}${t||""}`;return d.jsxs("svg",{className:it(["react-flow__background",x]),style:{...p,...Kl,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:y,"data-testid":"rf__background",children:[d.jsx("pattern",{id:V,x:v[0]%C[0],y:v[1]%C[1],width:C[0],height:C[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${z[0]},-${z[1]})`,children:j?d.jsx(rk,{radius:k/2,className:m}):d.jsx(nk,{dimensions:A,lineWidth:a,variant:r,className:m})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${V})`})]})}um.displayName="Background";const sk=L.memo(um);function lk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ak(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function uk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 ck(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 wl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:it(["react-flow__controls-button",r]),...o,children:t})}const fk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function cm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:x,children:m,position:y="bottom-left",orientation:v="vertical","aria-label":_}){const N=Ge(),{isInteractive:j,minZoomReached:E,maxZoomReached:w,ariaLabelConfig:C}=ze(fk,Qe),{zoomIn:k,zoomOut:b,fitView:A}=ql(),z=()=>{k(),u==null||u()},V=()=>{b(),c==null||c()},Y=()=>{A(a),h==null||h()},K=()=>{N.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),p==null||p(!j)},re=v==="horizontal"?"horizontal":"vertical";return d.jsxs(Xl,{className:it(["react-flow__controls",re,x]),position:y,style:t,"data-testid":"rf__controls","aria-label":_??C["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(wl,{onClick:z,className:"react-flow__controls-zoomin",title:C["controls.zoomIn.ariaLabel"],"aria-label":C["controls.zoomIn.ariaLabel"],disabled:w,children:d.jsx(lk,{})}),d.jsx(wl,{onClick:V,className:"react-flow__controls-zoomout",title:C["controls.zoomOut.ariaLabel"],"aria-label":C["controls.zoomOut.ariaLabel"],disabled:E,children:d.jsx(ak,{})})]}),o&&d.jsx(wl,{className:"react-flow__controls-fitview",onClick:Y,title:C["controls.fitView.ariaLabel"],"aria-label":C["controls.fitView.ariaLabel"],children:d.jsx(uk,{})}),s&&d.jsx(wl,{className:"react-flow__controls-interactive",onClick:K,title:C["controls.interactive.ariaLabel"],"aria-label":C["controls.interactive.ariaLabel"],children:j?d.jsx(dk,{}):d.jsx(ck,{})}),m]})}cm.displayName="Controls";const hk=L.memo(cm);function pk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:x,borderRadius:m,shapeRendering:y,selected:v,onClick:_}){const{background:N,backgroundColor:j}=u||{},E=c||N||j;return d.jsx("rect",{className:it(["react-flow__minimap-node",{selected:v},x]),x:r,y:o,rx:m,ry:m,width:s,height:a,style:{fill:E,stroke:h,strokeWidth:p},shapeRendering:y,onClick:_?w=>_(w,t):void 0})}const gk=L.memo(pk),mk=t=>t.nodes.map(r=>r.id),Wu=t=>t instanceof Function?t:()=>t;function yk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=gk,onClick:c}){const h=ze(mk,Qe),p=Wu(r),x=Wu(t),m=Wu(o),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(v=>d.jsx(xk,{id:v,nodeColorFunc:p,nodeStrokeColorFunc:x,nodeClassNameFunc:m,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:y},v))})}function vk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:x,x:m,y,width:v,height:_}=ze(N=>{const j=N.nodeLookup.get(t);if(!j)return{node:void 0,x:0,y:0,width:0,height:0};const E=j.internals.userNode,{x:w,y:C}=j.internals.positionAbsolute,{width:k,height:b}=xn(E);return{node:E,x:w,y:C,width:k,height:b}},Qe);return!x||x.hidden||!cg(x)?null:d.jsx(h,{x:m,y,width:v,height:_,style:x.style,selected:!!x.selected,className:s(x),color:r(x),borderRadius:a,strokeColor:o(x),strokeWidth:u,shapeRendering:c,onClick:p,id:x.id})}const xk=L.memo(vk);var wk=L.memo(yk);const _k=200,Sk=150,kk=t=>!t.hidden,Nk=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?lg(us(t.nodeLookup,{filter:kk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},dp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,jk=(t,r)=>dp(t.viewBB,r.viewBB)&&dp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,bk="react-flow__minimap-desc";function dm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:x,maskStrokeColor:m,maskStrokeWidth:y,position:v="bottom-right",onClick:_,onNodeClick:N,pannable:j=!1,zoomable:E=!1,ariaLabel:w,inversePan:C,zoomStep:k=1,offsetScale:b=5}){const A=Ge(),z=L.useRef(null),{boundingRect:V,viewBB:Y,rfId:K,panZoom:re,translateExtent:q,flowWidth:Z,flowHeight:te,ariaLabelConfig:R}=ze(Nk,jk),U=(t==null?void 0:t.width)??_k,H=(t==null?void 0:t.height)??Sk,W=V.width/U,M=V.height/H,D=Math.max(W,M),F=D*U,I=D*H,$=b*D,ie=V.x-(F-V.width)/2-$,oe=V.y-(I-V.height)/2-$,fe=F+$*2,he=I+$*2,pe=`${bk}-${K}`,J=L.useRef(0),ae=L.useRef();J.current=D,L.useEffect(()=>{if(z.current&&re)return ae.current=D1({domNode:z.current,panZoom:re,getTransform:()=>A.getState().transform,getViewScale:()=>J.current}),()=>{var ne;(ne=ae.current)==null||ne.destroy()}},[re]),L.useEffect(()=>{var ne;(ne=ae.current)==null||ne.update({translateExtent:q,width:Z,height:te,inversePan:C,pannable:j,zoomStep:k,zoomable:E})},[j,E,C,k,q,Z,te]);const me=_?ne=>{var Te;const[je,Me]=((Te=ae.current)==null?void 0:Te.pointer(ne))||[0,0];_(ne,{x:je,y:Me})}:void 0,Ne=N?L.useCallback((ne,je)=>{const Me=A.getState().nodeLookup.get(je).internals.userNode;N(ne,Me)},[]):void 0,xe=w??R["minimap.ariaLabel"];return d.jsx(Xl,{position:v,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof y=="number"?y*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:it(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:U,height:H,viewBox:`${ie} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:z,onClick:me,children:[xe&&d.jsx("title",{id:pe,children:xe}),d.jsx(wk,{onClick:Ne,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-$},${oe-$}h${fe+$*2}v${he+$*2}h${-fe-$*2}z - M${Y.x},${Y.y}h${Y.width}v${Y.height}h${-Y.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}dm.displayName="MiniMap";const Ek=L.memo(dm),Ck=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Mk={[Ji.Line]:"right",[Ji.Handle]:"bottom-right"};function Pk({nodeId:t,position:r,variant:o=Ji.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:x=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:y=!1,resizeDirection:v,autoScale:_=!0,shouldResize:N,onResizeStart:j,onResize:E,onResizeEnd:w}){const C=Hg(),k=typeof t=="string"?t:C,b=Ge(),A=L.useRef(null),z=o===Ji.Handle,V=ze(L.useCallback(Ck(z&&_),[z,_]),Qe),Y=L.useRef(null),K=r??Mk[o];L.useEffect(()=>{if(!(!A.current||!k))return Y.current||(Y.current=Q1({domNode:A.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:q,transform:Z,snapGrid:te,snapToGrid:R,nodeOrigin:U,domNode:H}=b.getState();return{nodeLookup:q,transform:Z,snapGrid:te,snapToGrid:R,nodeOrigin:U,paneDomNode:H}},onChange:(q,Z)=>{const{triggerNodeChanges:te,nodeLookup:R,parentLookup:U,nodeOrigin:H}=b.getState(),W=[],M={x:q.x,y:q.y},D=R.get(k);if(D&&D.expandParent&&D.parentId){const F=D.origin??H,I=q.width??D.measured.width??0,$=q.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:I,height:$,...dg({x:q.x??D.position.x,y:q.y??D.position.y},{width:I,height:$},D.parentId,R,F)}},oe=Ec([ie],R,U,H);W.push(...oe),M.x=q.x?Math.max(F[0]*I,q.x):void 0,M.y=q.y?Math.max(F[1]*$,q.y):void 0}if(M.x!==void 0&&M.y!==void 0){const F={id:k,type:"position",position:{...M}};W.push(F)}if(q.width!==void 0&&q.height!==void 0){const I={id:k,type:"dimensions",resizing:!0,setAttributes:v?v==="horizontal"?"width":"height":!0,dimensions:{width:q.width,height:q.height}};W.push(I)}for(const F of Z){const I={...F,type:"position"};W.push(I)}te(W)},onEnd:({width:q,height:Z})=>{const te={id:k,type:"dimensions",resizing:!1,dimensions:{width:q,height:Z}};b.getState().triggerNodeChanges([te])}})),Y.current.update({controlPosition:K,boundaries:{minWidth:h,minHeight:p,maxWidth:x,maxHeight:m},keepAspectRatio:y,resizeDirection:v,onResizeStart:j,onResize:E,onResizeEnd:w,shouldResize:N}),()=>{var q;(q=Y.current)==null||q.destroy()}},[K,h,p,x,m,y,j,E,w,N]);const re=K.split("-");return d.jsx("div",{className:it(["react-flow__resize-control","nodrag",...re,o,s]),ref:A,style:{...a,scale:V,...c&&{[z?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Pk);const Ik={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function Zl(t){return Ik[t]??8}const uc=208,cc=64,Rk=88,Tk=28,Lk=8;function Ak(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function $k(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const w of t){const C=Zl(w.type),k=s.get(C)??[];k.push(w),s.set(C,k)}const u=[...s.keys()].sort((w,C)=>w-C).map(w=>[...s.get(w)??[]].sort((C,k)=>C.name.localeCompare(k.name)||C.id.localeCompare(k.id))),c=new Set(t.map(w=>w.id)),h=new Map,p=new Map;for(const w of t)h.set(w.id,[]),p.set(w.id,[]);for(const w of r)!c.has(w.src)||!c.has(w.dst)||w.src===w.dst||(p.get(w.src).push(w.dst),h.get(w.dst).push(w.src));const x=new Map;u.forEach((w,C)=>{for(const k of w)x.set(k.id,C)});const m=new Map,y=()=>{for(const w of u)w.forEach((C,k)=>m.set(C.id,k))};y();const v=(w,C)=>{const k=w.map((b,A)=>{const z=C(b.id).map(Y=>m.get(Y)).filter(Y=>Y!==void 0),V=Ak(z);return{n:b,bary:Number.isNaN(V)?A:V,name:b.name,id:b.id}});return k.sort((b,A)=>b.bary-A.bary||b.name.localeCompare(A.name)||b.id.localeCompare(A.id)),k.map(b=>b.n)},_=w=>C=>x.get(C)===w;for(let w=0;w(h.get(k)??[]).filter(_(C-1))),y();for(let C=u.length-2;C>=0;C--)u[C]=v(u[C],k=>(p.get(k)??[]).filter(_(C+1))),y()}const N=uc+Rk,j=cc+Tk,E=Math.max(...u.map(w=>w.length),1);return u.forEach((w,C)=>{const k=(E-w.length)*j/2;w.forEach((b,A)=>{o.set(b.id,{x:C*N,y:k+A*j})})}),o}const zk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),fm=90,Dk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),fp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Ok=Math.PI*(3-Math.sqrt(5)),hm=220,Fk=26,Hk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function pm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function PN(t){return fp[t]?fp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Bk(t){return t>=fm?"3d":"2d"}function Vk(t){return t>=fm?"overview":"full"}function Wk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(pm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Dk.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Wk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Gk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function Yk(t,r,o,s){const a=new Set(t.map(j=>j.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const j of r){if(!a.has(j.src)||!a.has(j.dst))continue;const E=u.get(j.src)??[];E.push({dst:j.dst,id:j.id}),u.set(j.src,E);const w=c.get(j.dst)??[];w.push({src:j.src,id:j.id}),c.set(j.dst,w)}const h=new Set(t.filter(j=>zk.has(j.type)).map(j=>j.id)),p=h.size?h:a,x=new Set,m=[o];for(;m.length;){const j=m.pop();if(!x.has(j)){x.add(j);for(const E of u.get(j)??[])x.has(E.dst)||m.push(E.dst)}}const y=new Set([o]),v=[...p].filter(j=>x.has(j)),_=new Set(v);for(;v.length;){const j=v.pop();y.add(j);for(const E of c.get(j)??[])x.has(E.src)&&!_.has(E.src)&&(_.add(E.src),v.push(E.src))}const N=new Set;for(const j of r)y.has(j.src)&&y.has(j.dst)&&N.add(j.id);return{nodeIds:y,edgeIds:N}}function IN(t){const r=new Map;for(const s of t){const a=Zl(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*hm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Fk*Math.sqrt(h+1),x=h*Ok;o.set(c.id,{x:u,y:p*Math.cos(x),z:p*Math.sin(x)})})}return o}function RN(t){const r=new Map;for(const o of t){const s=Zl(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*hm,count:s}))}const _l=16,Xk=12,qk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Kk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),hp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Qk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},pp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],gp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Zk=new Set(["looks_idempotent_on_pk","null","blank"]),Jk=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function eN(t){return hp[t]?hp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function tN(t,r,o){const s=new Map(r.map(v=>[v.id,v])),a=[];qk.has(t.type)&&a.push("sink"),Kk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(v=>v.dst===t.id),h=o.filter(v=>v.src===t.id),p=c.slice(0,_l).map(v=>Sl(v,s,v.src)),x=h.slice(0,_l).map(v=>Sl(v,s,v.dst)),m=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,y={type:t.type,typeLabel:Xo(to(t.type)),layer:Hk[Zl(t.type)]??"other",purpose:eN(t.type),name:t.name,qualifiedName:t.qualified_name,file:m,context:t.context,roles:a,facts:rN(u).filter(v=>!(v.key==="app"&&v.value===t.context)),inputs:p,outputs:x,extraInputs:Math.max(0,c.length-_l),extraOutputs:Math.max(0,h.length-_l),degreeIn:c.length,degreeOut:h.length,inputKinds:mp(c.map(v=>Sl(v,s,v.src))),outputKinds:mp(h.map(v=>Sl(v,s,v.dst))),pathSummary:""};return y.pathSummary=nN(y),y}function mp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function nN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function Sl(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Xo(to(s.type)):"",edgeType:t.type,edgeLabel:Xo(t.type),inferred:t.confidence<.8}}function rN(t){const r=[...pp.filter(a=>a in t),...Object.keys(t).filter(a=>!pp.includes(a)&&!gp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||gp.has(a)||Jk.has(a))continue;s.add(a);const u=iN(a,t[a]);u!=null&&o.push({key:a,label:Qk[a]??Xo(a),value:u})}return o}function iN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Zk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return oN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Xk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function oN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const sN=new Set,lN=L.lazy(()=>_0(()=>import("./LayeredGraph3D-DtHNGq_6.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),aN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function uN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(eo,{type:"target",position:ke.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:to(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Cr(t.name)}),d.jsx(eo,{type:"source",position:ke.Right,isConnectable:!1})]})}const cN={load:uN},dN=new Set(["django","react","stitch","arch"]);function fN({topologyKey:t}){const{fitView:r}=ql();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function hN(t,r,o=null,s={}){const a=new Map(t.map(p=>[p.id,p])),u=$k(t,r),c=t.map(p=>{var y;const x=((y=s.roles)==null?void 0:y[p.id])||[],m=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:p.id,type:"load",position:u.get(p.id)??{x:0,y:0},data:{name:p.name,type:p.type,file:p.file_path,roles:x,dim:m},selected:o===p.id,sourcePosition:ke.Right,targetPosition:ke.Left,width:uc,height:cc,style:{width:uc,height:cc}}}),h=r.filter(p=>a.has(p.src)&&a.has(p.dst)).map(p=>{const x=aN[p.weight]||"var(--edge-cheap)",m=!!(o&&(p.src===o||p.dst===o));return{id:p.id,source:p.src,target:p.dst,type:"smoothstep",animated:p.weight==="critical",style:{stroke:x,strokeWidth:p.weight==="critical"?2.4:1.2,strokeDasharray:p.confidence<.8?"6 4":void 0},markerEnd:{type:ts.ArrowClosed,width:14,height:14,color:x},label:m?p.type.replaceAll("_"," "):void 0,labelStyle:m?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:m?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:m?[3,5]:void 0,labelBgBorderRadius:m?4:void 0}});return{rfNodes:c,rfEdges:h}}function pN({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:x}){const m=tN(t,r,o);return L.useEffect(()=>{const y=v=>{v.key==="Escape"&&s()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:m.typeLabel}),d.jsx("div",{className:"inspector-roles",children:m.roles.map(y=>d.jsx("span",{className:"inspector-chip",children:y},y))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Cr(m.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:m.purpose}),m.context?d.jsx("div",{className:"muted",children:Cr(m.context)}):null,m.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Cr(m.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Cr(m.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",m.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[m.degreeIn," in · ",m.degreeOut," out"]}),m.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:m.pathSummary}):null,m.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:m.facts.map(y=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:y.label}),d.jsx("dd",{children:Cr(y.value)})]},y.key))}):null,d.jsx(yp,{title:"Inputs",testId:"graph-inspector-inputs",links:m.inputs,extra:m.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(yp,{title:"Outputs",testId:"graph-inspector-outputs",links:m.outputs,extra:m.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",onClick:()=>a(t.id),children:"What if this changes"}):null,x?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",onClick:()=>x(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function yp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Cr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Cr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Uu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:x,repoPath:m,onOpenFile:y,pinnedId:v,onPin:_}){const[N,j]=L.useState(null),E=a!==void 0?a:N,w=ne=>{a===void 0&&j(ne),u==null||u(ne)},[C,k]=L.useState(null),[b,A]=L.useState(null),[z,V]=L.useState(new Set(dN)),[Y,K]=L.useState(!1),[re,q]=L.useState(""),[Z,te]=L.useState(!1),R=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,U=C??Bk(t.length),H=b??Vk(t.length),W=Y?E:null,M=L.useMemo(()=>p?Yk(t,r,p):null,[t,r,p]),D=M?t.filter(ne=>M.nodeIds.has(ne.id)):t,F=M?r.filter(ne=>M.edgeIds.has(ne.id)):r,I=L.useMemo(()=>Uk(D,F,{detail:H,families:z,focusId:W,neighborhoodOnly:!!W}),[D,F,H,z,W]),$=L.useMemo(()=>`${I.nodes.map(ne=>ne.id).join("\0")}|${I.edges.map(ne=>ne.id).join("\0")}`,[I.nodes,I.edges]),ie=E?t.find(ne=>ne.id===E)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const ne=hN(I.nodes,I.edges,E,{roles:c,testOverlay:h});return R&&(ne.rfEdges=ne.rfEdges.map(je=>({...je,animated:!1}))),ne},[I.nodes,I.edges,E,R,c,h]);L.useEffect(()=>{if(!s)return;const ne=t.find(je=>je.file_path===s);ne&&w(ne.id)},[s,t]);const he=L.useMemo(()=>Gk(t,re),[t,re]),pe=(ne,je)=>{w(je.id)},J=()=>{w(null),K(!1)},ae=ie?d.jsx(pN,{node:ie,nodes:t,edges:r,onClose:J,onWhatIf:o,onSelect:w,onOpenFile:y,pinned:v===ie.id,onPin:_,onIsolate:x?ne=>{x(p===ne?null:ne)}:void 0}):null,me=ne=>{V(je=>{const Me=new Set(je);if(Me.has(ne)){if(Me.size===1)return je;Me.delete(ne)}else Me.add(ne);return Me})},Ne=L.useMemo(()=>{const ne=new Set;for(const je of t)ne.add(pm(je.type));return ne},[t]),xe=t.length-I.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:U==="2d"?"active":"","aria-pressed":U==="2d",onClick:()=>k("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:U==="3d"?"active":"","aria-pressed":U==="3d",onClick:()=>k("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:H==="overview"?"active":"","aria-pressed":H==="overview",onClick:()=>A("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:H==="full"?"active":"","aria-pressed":H==="full",onClick:()=>A("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(ne=>Ne.has(ne)).map(ne=>d.jsx("button",{type:"button","data-testid":`graph-family-${ne}`,className:z.has(ne)?"active":"","aria-pressed":z.has(ne),onClick:()=>me(ne),children:ne},ne))}),d.jsx("button",{type:"button",className:Y?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!E,onClick:()=>K(ne=>!ne),children:Y?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>x==null?void 0:x(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:re,onChange:ne=>{q(ne.target.value),te(!0)},onFocus:()=>te(!0),onBlur:()=>window.setTimeout(()=>te(!1),150)}),Z&&re.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(ne=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:je=>je.preventDefault(),onClick:()=>{w(ne.id),q(""),te(!1)},children:[ne.name,d.jsx("span",{className:"muted",children:to(ne.type)})]})},ne.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[I.nodes.length," nodes · ",I.edges.length," edges",xe?` · ${xe} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:U==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(lN,{nodes:I.nodes,edges:I.edges,selectedId:E,neighborIds:W?I.neighborIds:sN,onSelect:ne=>{w(ne),ne||K(!1)}})}),ae]}):d.jsxs(am,{children:[d.jsxs(tk,{nodes:oe,edges:fe,nodeTypes:cN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:J,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(fN,{topologyKey:$}),d.jsx(sk,{}),d.jsx(Ek,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(hk,{})]}),ae]})})]})}function gm(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function gN(t){localStorage.setItem("loadpath.editor",t)}async function mN(t,r,o,s=gm()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const vp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],yN=["preset","branch","tag","commit"];function vN(t){var a;if(!(t!=null&&t.git))return[...vp];const r=((a=t.presets)!=null&&a.length?t.presets:vp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function xN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function wN(t){return yN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function _N(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function xp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[x,m]=L.useState(!1),[y,v]=L.useState(null),[_,N]=L.useState(0),j=L.useMemo(()=>{const b=vN(u);return y===null?b:xN(b,y)},[u,y]),E=L.useMemo(()=>wN(j),[j]);L.useEffect(()=>{x&&c()},[x,c]),L.useEffect(()=>{N(0)},[y,x]);const w=()=>{m(!1),v(null)},C=b=>{r(b.value),w()},k=b=>{if(b.key==="ArrowDown"){if(b.preventDefault(),!x){m(!0);return}N(A=>Math.min(A+1,Math.max(j.length-1,0)))}else if(b.key==="ArrowUp"){if(b.preventDefault(),!x)return;N(A=>Math.max(A-1,0))}else if(b.key==="Enter"&&x){b.preventDefault();const A=j[_];A&&C(A)}else b.key==="Escape"&&x&&(b.preventDefault(),w())};return d.jsxs("div",{className:"combo",ref:p,onBlur:b=>{b.currentTarget.contains(b.relatedTarget)||w()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":x,"aria-controls":h,"aria-autocomplete":"list",onChange:b=>{r(b.target.value),x&&v(b.target.value)},onKeyDown:k}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":x,onMouseDown:b=>b.preventDefault(),onClick:()=>x?w():m(!0),children:d.jsx(v0,{})})]}),x?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:E.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):E.map(b=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:_N(b.group)}),b.items.map(A=>{const z=j.indexOf(A);return d.jsxs("button",{type:"button",role:"option","aria-selected":z===_,className:z===_?"combo-option active":"combo-option","data-testid":`ref-option-${A.group}`,onMouseDown:V=>V.preventDefault(),onMouseEnter:()=>N(z),onClick:()=>C(A),children:[d.jsx("span",{className:"combo-label",children:A.label}),A.detail?d.jsx("span",{className:"combo-detail",children:A.detail}):null]},`${A.group}:${A.value}`)})]},b.group))}):null]})}function SN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[x,m]=L.useState(""),[y,v]=L.useState(!1),_=L.useRef(null),N=L.useRef(0),j=async k=>{const b=N.current+1;N.current=b,v(!0);try{const A=await Pe.browse(k);if(N.current!==b)return;a(A),c(A.path),p(A.is_git?A.path:null),m("")}catch(A){if(N.current!==b)return;m(A instanceof Error?A.message:String(A))}finally{N.current===b&&v(!1)}};L.useEffect(()=>{var k,b;j(t),(k=_.current)==null||k.focus(),(b=_.current)==null||b.select()},[t]);const E=h||(s==null?void 0:s.path)||u,w=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",C=k=>{k.key==="Escape"&&(k.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:C,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:k=>k.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:k=>{k.preventDefault(),j(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:k=>c(k.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),x?d.jsx("div",{className:"error",role:"alert",children:x}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":y,children:s!=null&&s.entries.length?s.entries.map(k=>{const b=h===k.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":b,className:b?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":k.path,onClick:()=>p(k.path),onDoubleClick:()=>void j(k.path),children:[d.jsx(kp,{}),d.jsx("span",{className:"explorer-name",children:k.name}),k.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},k.path)}):d.jsx("div",{className:"muted explorer-empty",children:y?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:E,children:E}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!E,onClick:()=>E&&r(E),children:["Use ",w]})]})]})})}const Dl=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],kN="obsidian",mm="loadpath.theme";function NN(t){return Dl.some(r=>r.id===t)}function ym(){try{const t=localStorage.getItem(mm)||"";if(NN(t))return t}catch{}return kN}function jN(t){var r;return((r=Dl.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function vm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=jN(t);try{localStorage.setItem(mm,t)}catch{}}const Gu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:h0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:p0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:g0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:m0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:y0}];function bN(t){const r=t.total||0;return r<=0?null:Math.min(100,Math.round(100*(t.done||0)/r))}function Yu(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function EN(){var wi,Wn,Oe,so,lo,_i,ao,uo,co;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,x]=L.useState(null),[m,y]=L.useState(null),[v,_]=L.useState([]),[N,j]=L.useState("review"),[E,w]=L.useState(""),[C,k]=L.useState(""),[b,A]=L.useState(null),[z,V]=L.useState(!1),[Y,K]=L.useState(!1),[re,q]=L.useState(""),[Z,te]=L.useState({}),[R,U]=L.useState([]),[H,W]=L.useState([]),[M,D]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[F,I]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[$,ie]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[oe,fe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[he,pe]=L.useState(0),[J,ae]=L.useState(""),[me,Ne]=L.useState(ym),[xe,ne]=L.useState(!1),[je,Me]=L.useState(!1),[Te,De]=L.useState(!1),[ht,Je]=L.useState(null),[Xe,lt]=L.useState(null),[yt,Dt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[qt,at]=L.useState(null),[et,vt]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[xt,zn]=L.useState([]),[rn,on]=L.useState(null),[no,Dn]=L.useState(null),[di,Ir]=L.useState(null),[Rr,nr]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[rr,wn]=L.useState(null),[Nt,Ot]=L.useState(null),[Ft,_n]=L.useState(!1),[On,Sn]=L.useState(!1),ut=L.useRef(o);ut.current=o;const Tr=L.useRef(!1);Tr.current=je;const Mt=L.useRef(""),Lr=L.useRef(""),kn=P=>{Ne(P),vm(P)},nt=L.useRef(""),He=P=>{nt.current=P,k(P)},Ar=P=>{const G=()=>{Pe.indexProgress(P).then(Se=>{nt.current&&(Se.phase&&Se.phase!=="idle"&&Se.message&&He(Se.message),A(Se.phase&&Se.phase!=="idle"?bN(Se):null))}).catch(()=>{})};G();const ce=window.setInterval(G,250);return()=>{window.clearInterval(ce),A(null)}};L.useEffect(()=>{Pe.settings().then(te).catch(()=>{}).finally(()=>ne(!0)),Pe.repos().then(P=>_(P.repos)).catch(()=>{})},[]);const sn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const P=o;let G=!1;return Lr.current!==P&&ir(P),Pe.config(P).then(ce=>{!G&&ut.current===P&&Dn(ce)}).catch(()=>{}),Pe.architectureHealth(P).then(ce=>{!G&&ut.current===P&&Ir(ce)}).catch(()=>{}),()=>{G=!0}},[t,o]);const Pt=P=>{ut.current=P,s(P),localStorage.setItem("loadpath.repo",P),P.trim()!==Mt.current&&(Mt.current="",wn(null))},Nn=L.useCallback(P=>{const G=(P??ut.current).trim();return!G||Mt.current===G?Promise.resolve():(Mt.current=G,Pe.gitRefs(G).then(ce=>{ut.current.trim()===G&&wn(ce)}).catch(()=>{Mt.current===G&&(Mt.current="",wn(null))}))},[]),Ht=(P,G)=>{u(P),h(G),localStorage.setItem("loadpath.base",P),localStorage.setItem("loadpath.head",G)},$r=(P,G,ce)=>{I(P),D(G),localStorage.setItem("loadpath.provider",P),localStorage.setItem("loadpath.scmRepo",G),ce!==void 0&&(ie(ce),localStorage.setItem("loadpath.prNumber",ce))},Fn=P=>{x(P),pe(0),Je(Xe&&P.nodes.some(G=>G.id===Xe)?Xe:null),at(null),on(null),P.id&&!P.what_if&&localStorage.setItem("loadpath.lastReviewId",P.id)},zr=async P=>{try{const G=await Pe.reviews(P);zn(G.reviews)}catch{zn([])}},Bt=async P=>{try{Ir(await Pe.architectureHealth(P))}catch{Ir(null)}},Dr=P=>P==="github"?!!Z.github_token_set:P==="gitlab"?!!Z.gitlab_token_set:!!Z.bitbucket_token_set,jt=L.useCallback(async(P=F)=>{var G;try{const ce=await Pe.scmRepos(P);W(ce.repos),(G=ce.user)!=null&&G.login&&te(Se=>({...Se,...P==="github"?{github_user:ce.user.login}:P==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{W([])}},[F]);L.useEffect(()=>{if(t!=="prs")return;let P=!1;return jt(F).catch(()=>{P||W([])}),()=>{P=!0}},[t,F,jt]),L.useEffect(()=>{if(!Nt)return;let P=!1,G=0;const ce=async()=>{try{const Se=await Pe.githubOAuthPoll(Nt.flow_id);if(P)return;if(Se.status==="complete"){Ot(null);const Ie=await Pe.settings();te(Ie),q(Se.user?`Signed in to GitHub as ${Se.user}`:"Signed in to GitHub"),jt("github");return}if(Se.status==="pending"||Se.status==="slow_down"){G=window.setTimeout(ce,Math.max(Se.interval||Nt.interval,5)*1e3);return}Ot(null),w(Se.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(Se){if(P)return;Ot(null),w(Se instanceof Error?Se.message:String(Se))}};return G=window.setTimeout(ce,Math.max(Nt.interval,5)*1e3),()=>{P=!0,window.clearTimeout(G)}},[Nt,jt]),L.useEffect(()=>{if(!Ft)return;let P=!1,G=0;const ce=Date.now(),Se=async()=>{try{const Ie=await Pe.oauthStatus();if(P)return;if(Ie.bitbucket.connected){_n(!1);const Ae=await Pe.settings();te(Ae),q(Ie.bitbucket.user?`Signed in to Bitbucket as ${Ie.bitbucket.user}`:"Signed in to Bitbucket"),jt("bitbucket");return}if(Date.now()-ce>18e4){_n(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}G=window.setTimeout(Se,1500)}catch(Ie){if(P)return;_n(!1),w(Ie instanceof Error?Ie.message:String(Ie))}};return G=window.setTimeout(Se,1500),()=>{P=!0,window.clearTimeout(G)}},[Ft,jt]),L.useEffect(()=>{if(!On)return;let P=!1,G=0;const ce=Date.now(),Se=async()=>{try{const Ie=await Pe.oauthStatus();if(P)return;if(Ie.gitlab.connected){Sn(!1);const Ae=await Pe.settings();te(Ae),q(Ie.gitlab.user?`Signed in to GitLab as ${Ie.gitlab.user}`:"Signed in to GitLab"),jt("gitlab");return}if(Date.now()-ce>18e4){Sn(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}G=window.setTimeout(Se,1500)}catch(Ie){if(P)return;Sn(!1),w(Ie instanceof Error?Ie.message:String(Ie))}};return G=window.setTimeout(Se,1500),()=>{P=!0,window.clearTimeout(G)}},[On,jt]);const ir=async(P=o,G=!1)=>{if(!P.trim())return null;Lr.current=P,K(!0);try{const ce=await Pe.architecture(P,!1);ut.current===P&&y(ce);const Se=Pe.architectureGraph(P).then(Ie=>{ut.current===P&&y(Ae=>Ae&&{...Ae,nodes:Ie.nodes,edges:Ie.edges,graph_pending:!1})});return Se.catch(()=>{}).finally(()=>{ut.current===P&&K(!1)}),G&&await Se,ce}catch(ce){throw ut.current===P&&K(!1),ce}},Or=async P=>{const G=P.trim();if(!(!G||G===ut.current)){if(nt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),q(""),x(null),y(null),j("architecture"),Pt(G),V(!0),He(`Loading ${f0(G)}…`);try{await Promise.all([ir(G),Nn(G)])}catch(ce){ut.current===G&&w(ce instanceof Error?ce.message:String(ce))}finally{ut.current===G&&(He(""),V(!1))}}},jn=async()=>{if(nt.current||!sn())return;w(""),q(""),He("Tracing load path…"),Pt(o),Ht(a,c);const P=Ar(o);try{const G=await Pe.review(o,a,c,!0,oe);Fn(G),j("review"),r("review"),await Pe.repos().then(ce=>_(ce.repos)).catch(()=>{}),await Promise.all([ir(o),zr(o),Bt(o)])}catch(G){w(G instanceof Error?G.message:String(G))}finally{P(),He("")}},or=async(P=!0)=>{if(nt.current||!sn())return;w(""),q(""),He(P?"Indexing…":"Full reindex…"),Pt(o);const G=Ar(o);try{await Pe.index(o,P);const ce=await ir(o);await Pe.repos().then(Se=>_(Se.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(j("architecture"),r("architecture"))}catch(ce){w(ce instanceof Error?ce.message:String(ce))}finally{G(),He("")}},fi=async()=>{if(!nt.current&&sn()){w(""),q(""),He("Detecting layout…"),Pt(o);try{const P=await Pe.init(o);q(P.message),await Pe.repos().then(G=>_(G.repos)).catch(()=>{})}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},ro=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),q("Copied markdown brief")}catch(P){w(P instanceof Error?P.message:String(P))}},hi=async()=>{if(!nt.current){if(!(p!=null&&p.markdown)||!M||!$){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const P=await Pe.postComment(F,M,Number($),p.markdown);q(P.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ve=async()=>{if(!nt.current){w(""),He("Fetching pull requests…");try{const P=await Pe.prs(F,M,"open",o.trim()||void 0);U(P.pull_requests);const G=H.find(ce=>ce.slug.toLowerCase()===M.trim().toLowerCase());G!=null&&G.local_path&&Pt(G.local_path)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},io=async()=>{w("");try{const P=await Pe.githubOAuthStart();Ot(P),Yu(P.verification_uri_complete,"github.com","/login/device")}catch(P){w(P instanceof Error?P.message:String(P))}},Fr=async()=>{w("");try{const P=await Pe.bitbucketOAuthStart();_n(!0),Yu(P.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(P){_n(!1),w(P instanceof Error?P.message:String(P))}},pi=async()=>{w("");try{const P=await Pe.gitlabOAuthStart();Sn(!0),Yu(P.authorize_url,new URL(P.authorize_url).hostname,"/oauth/authorize")}catch(P){Sn(!1),w(P instanceof Error?P.message:String(P))}},bn=async P=>{if(!(nt.current||!o.trim())){w(""),He("Walking what-if path…");try{const G=await Pe.whatIf(o,P);q(`${G.title} — ${G.confidence.level} · ${(G.sinks||[]).length} sinks`),Fn({...G,markdown:G.markdown||"",index:G.index||(p==null?void 0:p.index),workspace:G.workspace||(p==null?void 0:p.workspace)}),j("review"),r("review")}catch(G){w(G instanceof Error?G.message:String(G))}finally{He("")}}},oo=async P=>{var Ie;if(nt.current)return;$r(P.provider,P.repo,String(P.number));const G=H.find(Ae=>Ae.slug.toLowerCase()===P.repo.toLowerCase());G!=null&&G.local_path&&Pt(G.local_path),w(""),He(`Fetching ${P.provider} #${P.number}…`);const ce=(G==null?void 0:G.local_path)||o,Se=ce?Ar(ce):()=>{};try{const Ae=await Pe.reviewPr(P.provider,P.repo,P.number,(G==null?void 0:G.local_path)||o||void 0);Fn(Ae),Ae.pull_request&&typeof Ae.pull_request.repo_path=="string"&&Pt(Ae.pull_request.repo_path),Ht(String(Ae.base||P.target_branch),String(Ae.head||P.source_branch)),j("review"),r("review"),typeof((Ie=Ae.pull_request)==null?void 0:Ie.repo_path)=="string"&&zr(Ae.pull_request.repo_path)}catch(Ae){Ht(P.base_sha||P.target_branch,P.head_sha||P.source_branch),r("review"),w(Ae instanceof Error?Ae.message:String(Ae))}finally{Se(),He("")}},sr=async P=>{w("");try{te(await Pe.oauthDisconnect(P)),F===P&&W([]),q(`Disconnected ${P}`)}catch(G){w(G instanceof Error?G.message:String(G))}},lr=async P=>{P.preventDefault();const G=new FormData(P.currentTarget),ce={github_token:String(G.get("github_token")||""),github_oauth_client_id:String(G.get("github_oauth_client_id")||""),github_host:String(G.get("github_host")||""),gitlab_token:String(G.get("gitlab_token")||""),gitlab_host:String(G.get("gitlab_host")||""),gitlab_oauth_client_id:String(G.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(G.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(G.get("bitbucket_token")||""),bitbucket_username:String(G.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(G.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(G.get("bitbucket_oauth_client_secret")||""),ai_provider:String(G.get("ai_provider")||"none"),ai_api_key:String(G.get("ai_api_key")||""),ai_model:String(G.get("ai_model")||""),ai_base_url:String(G.get("ai_base_url")||"")},Se=v.length?{...ce,workspaces:v.map(Ie=>({path:Ie.path,name:Ie.name}))}:ce;try{te(await Pe.saveSettings(Se)),q("Settings saved on this machine")}catch(Ie){w(Ie instanceof Error?Ie.message:String(Ie))}},bt=async()=>{if(!(!p||nt.current)){He("Residual analysis…");try{const P=await Pe.residual(p);ae(P.note)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Hr=L.useRef(jn);Hr.current=jn;const pt=L.useRef(t);pt.current=t;const gi=L.useRef(!1);gi.current=Te;const mi=L.useRef(p);mi.current=p;const yi=L.useRef(he);yi.current=he,L.useEffect(()=>{const P=localStorage.getItem("loadpath.lastReviewId"),G=(localStorage.getItem("loadpath.repo")||"").trim();if(!P||!G){nr(!1);return}let ce=!1;return Pe.getReview(G,P).then(Se=>{ce||(Fn(Se),Ht(Se.base||localStorage.getItem("loadpath.base")||"HEAD~1",Se.head||localStorage.getItem("loadpath.head")||"HEAD"),zr(G),Bt(G))}).catch(()=>{}).finally(()=>{ce||nr(!1)}),()=>{ce=!0}},[]);const En=L.useRef("");L.useEffect(()=>{if(!et||!o.trim())return;let P=!1;const G=async()=>{try{const Se=await Pe.workspaceStatus(o);if(P)return;En.current&&Se.fingerprint!==En.current&&!nt.current&&(fe(!0),localStorage.setItem("loadpath.dirty","1"),Hr.current()),En.current=Se.fingerprint}catch{}};G();const ce=window.setInterval(G,2e3);return()=>{P=!0,window.clearInterval(ce)}},[et,o]),L.useEffect(()=>{const P=G=>{var Ie;if((G.metaKey||G.ctrlKey)&&G.key.toLowerCase()==="k"){G.preventDefault(),De(Ae=>!Ae);return}if(gi.current){G.key==="Escape"&&(G.preventDefault(),De(!1));return}if(Tr.current){G.key==="Escape"&&(G.preventDefault(),Me(!1));return}const ce=G.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){G.key==="Escape"&&ce.blur();return}if(G.key==="Escape"){w(""),q(""),Je(Xe),at(null);return}if(G.key==="j"||G.key==="k"){const Ae=((Ie=mi.current)==null?void 0:Ie.read_order)||[];if(!Ae.length)return;G.preventDefault();const ur=yi.current,Mn=G.key==="j"?Math.min(Ae.length-1,ur+1):Math.max(0,ur-1);pe(Mn);return}const Se=Gu.find(Ae=>Ae.shortcut===G.key);if(Se&&!G.metaKey&&!G.ctrlKey&&!G.altKey&&r(Se.id),(G.metaKey||G.ctrlKey)&&G.key==="Enter"){if(pt.current==="settings"||pt.current==="prs"||nt.current)return;G.preventDefault(),Hr.current()}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[Xe]);const Hn=async(P,G)=>{if(!o.trim())return;const ce=await mN(o,P,G);ce.ok?q(ce.message):w(ce.message)},Cn=async()=>{if(p)try{const P=await Pe.exportHtml(p),G=URL.createObjectURL(P),ce=document.createElement("a");ce.href=G,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(G),q("Saved HTML brief")}catch(P){w(P instanceof Error?P.message:String(P))}},Kt=async P=>{if(o.trim()){He("Loading stored review…");try{const G=await Pe.getReview(o,P);Fn(G),Ht(G.base||a,G.head||c),j("review"),r("review");const ce=xt.find(Se=>Se.id!==P);if(ce)try{on(await Pe.reviewDiff(o,P,ce.id))}catch{on(null)}}catch(G){w(G instanceof Error?G.message:String(G))}finally{He("")}}},Br={selectedId:ht,onSelect:Je,nodeRoles:p==null?void 0:p.node_roles,testOverlay:yt,isolateSource:qt,onIsolate:at,repoPath:o,onOpenFile:Hn,pinnedId:Xe,onPin:lt},vi=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},{id:"index",group:"Run",label:"Index repository",run:()=>void or(!0)},{id:"watch",group:"Run",label:et?"Stop watching working tree":"Watch working tree",run:()=>{const P=!et;vt(P),localStorage.setItem("loadpath.watch",P?"1":"0")}},{id:"tests",group:"Graph",label:yt?"Hide test overlay":"Show test overlay",run:()=>{const P=!yt;Dt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Cn()},...Gu.map(P=>({id:`tab-${P.id}`,group:"Tabs",label:`Go to ${P.label}`,hint:P.shortcut,run:()=>r(P.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(P=>({id:`node-${P.id}`,group:"Nodes",label:P.name,hint:to(P.type),run:()=>{Je(P.id),r("graph")}})),...xt.slice(0,12).map(P=>({id:`hist-${P.id}`,group:"History",label:P.title||P.id,hint:`${P.level||""} ${P.created_at||""}`.trim(),run:()=>void Kt(P.id)}))],ar=L.useMemo(()=>N==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[N,m,p]),xi=L.useMemo(()=>N==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[N,m,p]),Bn=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Vn=((p==null?void 0:p.findings)||[]).filter(P=>!P.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Gu.map(P=>{const G=P.icon,ce=t===P.id;return d.jsxs("button",{type:"button","data-testid":P.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":P.label,onClick:()=>r(P.id),children:[d.jsx(G,{}),d.jsx("span",{children:P.label})]},P.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:me,onChange:P=>kn(P.target.value),children:["dark","light"].map(P=>d.jsx("optgroup",{label:P==="dark"?"Dark":"Light",children:Dl.filter(G=>G.group===P).map(G=>d.jsx("option",{value:G.id,children:G.label},G.id))},P))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:C||Bn}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[C?d.jsxs("div",{className:b!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","data-testid":"progress",children:[d.jsx("i",{style:b!=null?{width:`${b}%`}:void 0}),d.jsx("span",{className:"sr-only",children:C})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[v.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:v.some(P=>P.path===o)?o:"",disabled:!!C,"aria-busy":z,onChange:P=>{P.target.value&&Or(P.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),v.map(P=>d.jsxs("option",{value:P.path,children:[P.name,P.indexed?` (${P.counts.nodes})`:""]},P.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:P=>{const G=P.target.value;s(G),G.trim()!==Mt.current&&(Mt.current="",wn(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>Me(!0),children:d.jsx(kp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(xp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:P=>Ht(P,c),placeholder:"base",refs:rr,onNeedRefs:Nn})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(xp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:P=>Ht(a,P),placeholder:"head",refs:rr,onNeedRefs:Nn})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:oe?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":oe,onClick:()=>{const P=!oe;fe(P),localStorage.setItem("loadpath.dirty",P?"1":"0")},children:oe?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:et?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":et,onClick:()=>{const P=!et;vt(P),localStorage.setItem("loadpath.watch",P?"1":"0")},children:et?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!C,onClick:fi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!C,onClick:()=>or(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!C,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[E?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:E}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,re?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:re}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>q(""),"aria-label":"Dismiss",children:"×"})]}):null,((wi=p==null?void 0:p.index)!=null&&wi.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((Wn=p==null?void 0:p.index)==null?void 0:Wn.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Oe=p==null?void 0:p.index)==null?void 0:Oe.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(so=p==null?void 0:p.workspace)!=null&&so.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,z?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:C||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":z||Y,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(CN,{review:p,findings:Vn,aiNote:J,busy:!!C,tourIndex:he,onTour:pe,onAskAi:bt,onCopy:ro,onPost:hi,onSelect:Je,onOpenFile:Hn,onExport:Cn,history:xt,diff:rn,onReopen:Kt,onWaiver:(P,G)=>{o.trim()&&Pe.addWaiver(o,P,G||void 0,"from review").then(ce=>{Dn(ce),q(`Waived ${P} in loadpath.yml`)})}}):Rr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Uu,{nodes:p.nodes,edges:p.edges,onWhatIf:bn,focusPath:(lo=p.read_order[he])==null?void 0:lo.path,...Br}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(MN,{architecture:m,busy:!!C,onReindex:()=>or(!1),onReview:jn,onSelect:Je,config:no,health:di,onSaveConfig:P=>{Pe.saveConfig(o,P).then(G=>{Dn(G),q("Wrote loadpath.yml")})},onWaiver:(P,G,ce)=>{Pe.addWaiver(o,P,G,ce).then(Se=>{Dn(Se),q(`Waived ${P}`)})}}):z?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:Y&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(_i=m==null?void 0:m.counts)!=null&&_i.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Uu,{nodes:m.nodes,edges:m.edges,onWhatIf:bn,...Br,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":N==="review","data-testid":"graph-mode-review",className:N==="review"?"active":"",onClick:()=>j("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":N==="architecture","data-testid":"graph-mode-architecture",className:N==="architecture"?"active":"",onClick:()=>j("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:yt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":yt,onClick:()=>{const P=!yt;Dt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")},children:"Tests"})]}),ar.length?d.jsx(Uu,{nodes:ar,edges:xi,onWhatIf:bn,...Br}):Y?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:F,onChange:P=>$r(P.target.value,M,$),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:H.length?"Search your repos":"owner/repo",value:M,onChange:P=>$r(F,P.target.value,$),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:H.map(P=>d.jsxs("option",{value:P.slug,children:[P.private?"private":"public",P.local_path?" · local":""]},P.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!C||!Dr(F),onClick:()=>{jt(F)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!C,onClick:Ve,children:"List PRs"})]}),H.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[H.length," ",F," repositor",H.length===1?"y":"ies",F==="github"&&Z.github_user?` · @${String(Z.github_user)}`:"",F==="gitlab"&&Z.gitlab_user?` · @${String(Z.gitlab_user)}`:"",F==="bitbucket"&&Z.bitbucket_user?` · ${String(Z.bitbucket_user)}`:""]}):null,R.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):R.map(P=>{var G;return d.jsxs("article",{className:"pr","data-testid":`pr-${P.number}`,children:[d.jsxs("h3",{children:["#",P.number," ",P.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${P.draft?"":"open"}`,children:P.draft?"draft":P.state}),d.jsx("span",{children:P.author}),d.jsxs("span",{children:[P.source_branch," → ",P.target_branch]}),P.loadpath?d.jsxs("span",{className:`chip ${P.loadpath.level||""}`,"data-testid":`pr-loadpath-${P.number}`,children:[((G=P.loadpath.level)==null?void 0:G.toUpperCase())||"REVIEWED",P.loadpath.contract_break&&P.loadpath.contract_break!=="none"?` · ${P.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:P.url,target:"_blank",rel:"noreferrer",children:["Open on ",P.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${P.number}`,onClick:()=>void oo(P),children:"Review this PR"})]})]},`${P.provider}-${P.number}`)})]}),t==="settings"&&xe&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:lr,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Dl.map(P=>d.jsxs("button",{type:"button","data-theme":P.id,className:me===P.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${P.id}`,onClick:()=>kn(P.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:P.label}),d.jsx("div",{className:"group",children:P.group})]},P.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:gm(),onChange:P=>gN(P.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:Z.github_token_set?Z.github_user?`Signed in as @${String(Z.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:Z.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void sr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!Nt||!Z.github_oauth_ready,onClick:()=>void io(),children:Nt?"Waiting for GitHub…":"Sign in with GitHub"})})]}),Nt?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:Nt.user_code})," at GitHub if the browser did not fill it in."]}):null,Z.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(Z.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(Z.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:Z.gitlab_token_set?Z.gitlab_user?`Signed in as @${String(Z.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:Z.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void sr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:On||!Z.gitlab_oauth_ready,onClick:()=>void pi(),children:On?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(Z.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(Z.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:Z.bitbucket_token_set?Z.bitbucket_user?`Signed in as ${String(Z.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:Z.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void sr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:Ft||!Z.bitbucket_oauth_ready,onClick:()=>void Fr(),children:Ft?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),Z.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(Z.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(Z.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((ao=Z.ai)==null?void 0:ao.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((uo=Z.ai)==null?void 0:uo.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((co=Z.ai)==null?void 0:co.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(u0,{open:Te,actions:vi,onClose:()=>De(!1)}),je?d.jsx(SN,{initialPath:o,onClose:()=>Me(!1),onSelect:P=>{if(nt.current){w("Wait for the current job to finish before switching workspace.");return}Me(!1),Or(P)}}):null]})}function CN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:x,onOpenFile:m,onExport:y,history:v,diff:_,onReopen:N,onWaiver:j}){var w,C,k,b,A,z,V,Y,K,re,q,Z,te,R,U,H,W;const E=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),E.length?d.jsx("ul",{className:"reasons",children:E.map(M=>d.jsx("li",{children:M},M))}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Xo(M)},M)),(w=t.contract_break)!=null&&w.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&x(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>j(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(C=t.workspace)!=null&&C.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>m(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&x(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(xm,{cards:t.deepening}),(b=(k=t.contract_break)==null?void 0:k.reasons)!=null&&b.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),(z=(A=t.contract_break.sides)==null?void 0:A.rows)!=null&&z.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(V=t.auth)!=null&&V.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(Y=t.suggested_tests)==null?void 0:Y.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(K=t.trend)!=null&&K.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",Xu(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),v.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:v.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,v.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>N(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?Xu(M.created_at):""})]},M.id))]}):null,(q=(re=t.evolution)==null?void 0:re.notes)!=null&&q.length||(te=(Z=t.evolution)==null?void 0:Z.hotspots)!=null&&te.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((R=t.evolution)==null?void 0:R.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((U=t.evolution)==null?void 0:U.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:y,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(H=t.codeowners_reviewers)!=null&&H.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(W=t.knowledge_owners)!=null&&W.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function MN({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var m;const x=t.findings.filter(y=>!y.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${Xu(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(y=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y.name})," — ",(y.django_apps||[]).join(", ")||"no apps"," ·"," ",(y.owners||[]).join(", ")||"unowned"]},y.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(y=>d.jsx("div",{className:"muted",children:y},y))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:x.length})]}),x.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):x.map(y=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>y.node_id&&a(y.node_id),children:[d.jsx("span",{className:`chip ${y.severity}`,children:y.severity}),y.message]})},y.rule+y.message))]}),d.jsx(xm,{cards:t.deepening}),(m=c==null?void 0:c.points)!=null&&m.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(y=>d.jsx("i",{className:y.level||"",title:`${y.level} · ${y.findings} findings`,style:{height:`${8+Math.min(24,(y.findings||0)*4)}px`}},y.id||y.created_at))}),Object.entries(c.contexts).map(([y,v])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y})," — last ",((_=v[v.length-1])==null?void 0:_.findings)??0," findings"]},y)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(c0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((y,v)=>v[1]-y[1]).slice(0,12).map(([y,v])=>d.jsxs("tr",{children:[d.jsx("td",{children:to(y)}),d.jsx("td",{children:v})]},y))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function xm({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:d0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}vm(ym());s0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(EN,{})}));export{Hk as L,RN as a,PN as c,d as j,IN as l,L as r,to as t}; + M${Y.x},${Y.y}h${Y.width}v${Y.height}h${-Y.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}dm.displayName="MiniMap";const Ek=L.memo(dm),Ck=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Mk={[Ji.Line]:"right",[Ji.Handle]:"bottom-right"};function Pk({nodeId:t,position:r,variant:o=Ji.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:x=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:y=!1,resizeDirection:v,autoScale:_=!0,shouldResize:N,onResizeStart:j,onResize:E,onResizeEnd:w}){const C=Hg(),k=typeof t=="string"?t:C,b=Ge(),A=L.useRef(null),z=o===Ji.Handle,V=ze(L.useCallback(Ck(z&&_),[z,_]),Qe),Y=L.useRef(null),K=r??Mk[o];L.useEffect(()=>{if(!(!A.current||!k))return Y.current||(Y.current=Q1({domNode:A.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:q,transform:Z,snapGrid:te,snapToGrid:R,nodeOrigin:U,domNode:H}=b.getState();return{nodeLookup:q,transform:Z,snapGrid:te,snapToGrid:R,nodeOrigin:U,paneDomNode:H}},onChange:(q,Z)=>{const{triggerNodeChanges:te,nodeLookup:R,parentLookup:U,nodeOrigin:H}=b.getState(),W=[],M={x:q.x,y:q.y},D=R.get(k);if(D&&D.expandParent&&D.parentId){const F=D.origin??H,I=q.width??D.measured.width??0,$=q.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:I,height:$,...dg({x:q.x??D.position.x,y:q.y??D.position.y},{width:I,height:$},D.parentId,R,F)}},oe=Ec([ie],R,U,H);W.push(...oe),M.x=q.x?Math.max(F[0]*I,q.x):void 0,M.y=q.y?Math.max(F[1]*$,q.y):void 0}if(M.x!==void 0&&M.y!==void 0){const F={id:k,type:"position",position:{...M}};W.push(F)}if(q.width!==void 0&&q.height!==void 0){const I={id:k,type:"dimensions",resizing:!0,setAttributes:v?v==="horizontal"?"width":"height":!0,dimensions:{width:q.width,height:q.height}};W.push(I)}for(const F of Z){const I={...F,type:"position"};W.push(I)}te(W)},onEnd:({width:q,height:Z})=>{const te={id:k,type:"dimensions",resizing:!1,dimensions:{width:q,height:Z}};b.getState().triggerNodeChanges([te])}})),Y.current.update({controlPosition:K,boundaries:{minWidth:h,minHeight:p,maxWidth:x,maxHeight:m},keepAspectRatio:y,resizeDirection:v,onResizeStart:j,onResize:E,onResizeEnd:w,shouldResize:N}),()=>{var q;(q=Y.current)==null||q.destroy()}},[K,h,p,x,m,y,j,E,w,N]);const re=K.split("-");return d.jsx("div",{className:it(["react-flow__resize-control","nodrag",...re,o,s]),ref:A,style:{...a,scale:V,...c&&{[z?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Pk);const Ik={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function Zl(t){return Ik[t]??8}const uc=208,cc=64,Rk=88,Tk=28,Lk=8;function Ak(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function $k(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const w of t){const C=Zl(w.type),k=s.get(C)??[];k.push(w),s.set(C,k)}const u=[...s.keys()].sort((w,C)=>w-C).map(w=>[...s.get(w)??[]].sort((C,k)=>C.name.localeCompare(k.name)||C.id.localeCompare(k.id))),c=new Set(t.map(w=>w.id)),h=new Map,p=new Map;for(const w of t)h.set(w.id,[]),p.set(w.id,[]);for(const w of r)!c.has(w.src)||!c.has(w.dst)||w.src===w.dst||(p.get(w.src).push(w.dst),h.get(w.dst).push(w.src));const x=new Map;u.forEach((w,C)=>{for(const k of w)x.set(k.id,C)});const m=new Map,y=()=>{for(const w of u)w.forEach((C,k)=>m.set(C.id,k))};y();const v=(w,C)=>{const k=w.map((b,A)=>{const z=C(b.id).map(Y=>m.get(Y)).filter(Y=>Y!==void 0),V=Ak(z);return{n:b,bary:Number.isNaN(V)?A:V,name:b.name,id:b.id}});return k.sort((b,A)=>b.bary-A.bary||b.name.localeCompare(A.name)||b.id.localeCompare(A.id)),k.map(b=>b.n)},_=w=>C=>x.get(C)===w;for(let w=0;w(h.get(k)??[]).filter(_(C-1))),y();for(let C=u.length-2;C>=0;C--)u[C]=v(u[C],k=>(p.get(k)??[]).filter(_(C+1))),y()}const N=uc+Rk,j=cc+Tk,E=Math.max(...u.map(w=>w.length),1);return u.forEach((w,C)=>{const k=(E-w.length)*j/2;w.forEach((b,A)=>{o.set(b.id,{x:C*N,y:k+A*j})})}),o}const zk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),fm=90,Dk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),fp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Ok=Math.PI*(3-Math.sqrt(5)),hm=220,Fk=26,Hk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function pm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function PN(t){return fp[t]?fp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Bk(t){return t>=fm?"3d":"2d"}function Vk(t){return t>=fm?"overview":"full"}function Wk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(pm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Dk.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Wk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Gk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function Yk(t,r,o,s){const a=new Set(t.map(j=>j.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const j of r){if(!a.has(j.src)||!a.has(j.dst))continue;const E=u.get(j.src)??[];E.push({dst:j.dst,id:j.id}),u.set(j.src,E);const w=c.get(j.dst)??[];w.push({src:j.src,id:j.id}),c.set(j.dst,w)}const h=new Set(t.filter(j=>zk.has(j.type)).map(j=>j.id)),p=h.size?h:a,x=new Set,m=[o];for(;m.length;){const j=m.pop();if(!x.has(j)){x.add(j);for(const E of u.get(j)??[])x.has(E.dst)||m.push(E.dst)}}const y=new Set([o]),v=[...p].filter(j=>x.has(j)),_=new Set(v);for(;v.length;){const j=v.pop();y.add(j);for(const E of c.get(j)??[])x.has(E.src)&&!_.has(E.src)&&(_.add(E.src),v.push(E.src))}const N=new Set;for(const j of r)y.has(j.src)&&y.has(j.dst)&&N.add(j.id);return{nodeIds:y,edgeIds:N}}function IN(t){const r=new Map;for(const s of t){const a=Zl(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*hm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Fk*Math.sqrt(h+1),x=h*Ok;o.set(c.id,{x:u,y:p*Math.cos(x),z:p*Math.sin(x)})})}return o}function RN(t){const r=new Map;for(const o of t){const s=Zl(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*hm,count:s}))}const _l=16,Xk=12,qk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Kk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),hp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Qk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},pp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],gp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Zk=new Set(["looks_idempotent_on_pk","null","blank"]),Jk=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function eN(t){return hp[t]?hp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function tN(t,r,o){const s=new Map(r.map(v=>[v.id,v])),a=[];qk.has(t.type)&&a.push("sink"),Kk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(v=>v.dst===t.id),h=o.filter(v=>v.src===t.id),p=c.slice(0,_l).map(v=>Sl(v,s,v.src)),x=h.slice(0,_l).map(v=>Sl(v,s,v.dst)),m=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,y={type:t.type,typeLabel:Xo(to(t.type)),layer:Hk[Zl(t.type)]??"other",purpose:eN(t.type),name:t.name,qualifiedName:t.qualified_name,file:m,context:t.context,roles:a,facts:rN(u).filter(v=>!(v.key==="app"&&v.value===t.context)),inputs:p,outputs:x,extraInputs:Math.max(0,c.length-_l),extraOutputs:Math.max(0,h.length-_l),degreeIn:c.length,degreeOut:h.length,inputKinds:mp(c.map(v=>Sl(v,s,v.src))),outputKinds:mp(h.map(v=>Sl(v,s,v.dst))),pathSummary:""};return y.pathSummary=nN(y),y}function mp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function nN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function Sl(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Xo(to(s.type)):"",edgeType:t.type,edgeLabel:Xo(t.type),inferred:t.confidence<.8}}function rN(t){const r=[...pp.filter(a=>a in t),...Object.keys(t).filter(a=>!pp.includes(a)&&!gp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||gp.has(a)||Jk.has(a))continue;s.add(a);const u=iN(a,t[a]);u!=null&&o.push({key:a,label:Qk[a]??Xo(a),value:u})}return o}function iN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Zk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return oN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Xk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function oN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const sN=new Set,lN=L.lazy(()=>_0(()=>import("./LayeredGraph3D--37-6JMJ.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),aN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function uN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(eo,{type:"target",position:ke.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:to(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Cr(t.name)}),d.jsx(eo,{type:"source",position:ke.Right,isConnectable:!1})]})}const cN={load:uN},dN=new Set(["django","react","stitch","arch"]);function fN({topologyKey:t}){const{fitView:r}=ql();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function hN(t,r,o=null,s={}){const a=new Map(t.map(p=>[p.id,p])),u=$k(t,r),c=t.map(p=>{var y;const x=((y=s.roles)==null?void 0:y[p.id])||[],m=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:p.id,type:"load",position:u.get(p.id)??{x:0,y:0},data:{name:p.name,type:p.type,file:p.file_path,roles:x,dim:m},selected:o===p.id,sourcePosition:ke.Right,targetPosition:ke.Left,width:uc,height:cc,style:{width:uc,height:cc}}}),h=r.filter(p=>a.has(p.src)&&a.has(p.dst)).map(p=>{const x=aN[p.weight]||"var(--edge-cheap)",m=!!(o&&(p.src===o||p.dst===o));return{id:p.id,source:p.src,target:p.dst,type:"smoothstep",animated:p.weight==="critical",style:{stroke:x,strokeWidth:p.weight==="critical"?2.4:1.2,strokeDasharray:p.confidence<.8?"6 4":void 0},markerEnd:{type:ts.ArrowClosed,width:14,height:14,color:x},label:m?p.type.replaceAll("_"," "):void 0,labelStyle:m?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:m?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:m?[3,5]:void 0,labelBgBorderRadius:m?4:void 0}});return{rfNodes:c,rfEdges:h}}function pN({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:x}){const m=tN(t,r,o);return L.useEffect(()=>{const y=v=>{v.key==="Escape"&&s()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:m.typeLabel}),d.jsx("div",{className:"inspector-roles",children:m.roles.map(y=>d.jsx("span",{className:"inspector-chip",children:y},y))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Cr(m.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:m.purpose}),m.context?d.jsx("div",{className:"muted",children:Cr(m.context)}):null,m.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Cr(m.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Cr(m.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",m.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[m.degreeIn," in · ",m.degreeOut," out"]}),m.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:m.pathSummary}):null,m.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:m.facts.map(y=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:y.label}),d.jsx("dd",{children:Cr(y.value)})]},y.key))}):null,d.jsx(yp,{title:"Inputs",testId:"graph-inspector-inputs",links:m.inputs,extra:m.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(yp,{title:"Outputs",testId:"graph-inspector-outputs",links:m.outputs,extra:m.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",onClick:()=>a(t.id),children:"What if this changes"}):null,x?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",onClick:()=>x(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function yp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Cr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Cr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Uu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:x,repoPath:m,onOpenFile:y,pinnedId:v,onPin:_}){const[N,j]=L.useState(null),E=a!==void 0?a:N,w=ne=>{a===void 0&&j(ne),u==null||u(ne)},[C,k]=L.useState(null),[b,A]=L.useState(null),[z,V]=L.useState(new Set(dN)),[Y,K]=L.useState(!1),[re,q]=L.useState(""),[Z,te]=L.useState(!1),R=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,U=C??Bk(t.length),H=b??Vk(t.length),W=Y?E:null,M=L.useMemo(()=>p?Yk(t,r,p):null,[t,r,p]),D=M?t.filter(ne=>M.nodeIds.has(ne.id)):t,F=M?r.filter(ne=>M.edgeIds.has(ne.id)):r,I=L.useMemo(()=>Uk(D,F,{detail:H,families:z,focusId:W,neighborhoodOnly:!!W}),[D,F,H,z,W]),$=L.useMemo(()=>`${I.nodes.map(ne=>ne.id).join("\0")}|${I.edges.map(ne=>ne.id).join("\0")}`,[I.nodes,I.edges]),ie=E?t.find(ne=>ne.id===E)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const ne=hN(I.nodes,I.edges,E,{roles:c,testOverlay:h});return R&&(ne.rfEdges=ne.rfEdges.map(je=>({...je,animated:!1}))),ne},[I.nodes,I.edges,E,R,c,h]);L.useEffect(()=>{if(!s)return;const ne=t.find(je=>je.file_path===s);ne&&w(ne.id)},[s,t]);const he=L.useMemo(()=>Gk(t,re),[t,re]),pe=(ne,je)=>{w(je.id)},J=()=>{w(null),K(!1)},ae=ie?d.jsx(pN,{node:ie,nodes:t,edges:r,onClose:J,onWhatIf:o,onSelect:w,onOpenFile:y,pinned:v===ie.id,onPin:_,onIsolate:x?ne=>{x(p===ne?null:ne)}:void 0}):null,me=ne=>{V(je=>{const Me=new Set(je);if(Me.has(ne)){if(Me.size===1)return je;Me.delete(ne)}else Me.add(ne);return Me})},Ne=L.useMemo(()=>{const ne=new Set;for(const je of t)ne.add(pm(je.type));return ne},[t]),xe=t.length-I.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:U==="2d"?"active":"","aria-pressed":U==="2d",onClick:()=>k("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:U==="3d"?"active":"","aria-pressed":U==="3d",onClick:()=>k("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:H==="overview"?"active":"","aria-pressed":H==="overview",onClick:()=>A("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:H==="full"?"active":"","aria-pressed":H==="full",onClick:()=>A("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(ne=>Ne.has(ne)).map(ne=>d.jsx("button",{type:"button","data-testid":`graph-family-${ne}`,className:z.has(ne)?"active":"","aria-pressed":z.has(ne),onClick:()=>me(ne),children:ne},ne))}),d.jsx("button",{type:"button",className:Y?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!E,onClick:()=>K(ne=>!ne),children:Y?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>x==null?void 0:x(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:re,onChange:ne=>{q(ne.target.value),te(!0)},onFocus:()=>te(!0),onBlur:()=>window.setTimeout(()=>te(!1),150)}),Z&&re.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(ne=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:je=>je.preventDefault(),onClick:()=>{w(ne.id),q(""),te(!1)},children:[ne.name,d.jsx("span",{className:"muted",children:to(ne.type)})]})},ne.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[I.nodes.length," nodes · ",I.edges.length," edges",xe?` · ${xe} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:U==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(lN,{nodes:I.nodes,edges:I.edges,selectedId:E,neighborIds:W?I.neighborIds:sN,onSelect:ne=>{w(ne),ne||K(!1)}})}),ae]}):d.jsxs(am,{children:[d.jsxs(tk,{nodes:oe,edges:fe,nodeTypes:cN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:J,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(fN,{topologyKey:$}),d.jsx(sk,{}),d.jsx(Ek,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(hk,{})]}),ae]})})]})}function gm(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function gN(t){localStorage.setItem("loadpath.editor",t)}async function mN(t,r,o,s=gm()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const vp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],yN=["preset","branch","tag","commit"];function vN(t){var a;if(!(t!=null&&t.git))return[...vp];const r=((a=t.presets)!=null&&a.length?t.presets:vp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function xN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function wN(t){return yN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function _N(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function xp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[x,m]=L.useState(!1),[y,v]=L.useState(null),[_,N]=L.useState(0),j=L.useMemo(()=>{const b=vN(u);return y===null?b:xN(b,y)},[u,y]),E=L.useMemo(()=>wN(j),[j]);L.useEffect(()=>{x&&c()},[x,c]),L.useEffect(()=>{N(0)},[y,x]);const w=()=>{m(!1),v(null)},C=b=>{r(b.value),w()},k=b=>{if(b.key==="ArrowDown"){if(b.preventDefault(),!x){m(!0);return}N(A=>Math.min(A+1,Math.max(j.length-1,0)))}else if(b.key==="ArrowUp"){if(b.preventDefault(),!x)return;N(A=>Math.max(A-1,0))}else if(b.key==="Enter"&&x){b.preventDefault();const A=j[_];A&&C(A)}else b.key==="Escape"&&x&&(b.preventDefault(),w())};return d.jsxs("div",{className:"combo",ref:p,onBlur:b=>{b.currentTarget.contains(b.relatedTarget)||w()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":x,"aria-controls":h,"aria-autocomplete":"list",onChange:b=>{r(b.target.value),x&&v(b.target.value)},onKeyDown:k}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":x,onMouseDown:b=>b.preventDefault(),onClick:()=>x?w():m(!0),children:d.jsx(v0,{})})]}),x?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:E.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):E.map(b=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:_N(b.group)}),b.items.map(A=>{const z=j.indexOf(A);return d.jsxs("button",{type:"button",role:"option","aria-selected":z===_,className:z===_?"combo-option active":"combo-option","data-testid":`ref-option-${A.group}`,onMouseDown:V=>V.preventDefault(),onMouseEnter:()=>N(z),onClick:()=>C(A),children:[d.jsx("span",{className:"combo-label",children:A.label}),A.detail?d.jsx("span",{className:"combo-detail",children:A.detail}):null]},`${A.group}:${A.value}`)})]},b.group))}):null]})}function SN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[x,m]=L.useState(""),[y,v]=L.useState(!1),_=L.useRef(null),N=L.useRef(0),j=async k=>{const b=N.current+1;N.current=b,v(!0);try{const A=await Pe.browse(k);if(N.current!==b)return;a(A),c(A.path),p(A.is_git?A.path:null),m("")}catch(A){if(N.current!==b)return;m(A instanceof Error?A.message:String(A))}finally{N.current===b&&v(!1)}};L.useEffect(()=>{var k,b;j(t),(k=_.current)==null||k.focus(),(b=_.current)==null||b.select()},[t]);const E=h||(s==null?void 0:s.path)||u,w=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",C=k=>{k.key==="Escape"&&(k.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:C,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:k=>k.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:k=>{k.preventDefault(),j(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:k=>c(k.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),x?d.jsx("div",{className:"error",role:"alert",children:x}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":y,children:s!=null&&s.entries.length?s.entries.map(k=>{const b=h===k.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":b,className:b?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":k.path,onClick:()=>p(k.path),onDoubleClick:()=>void j(k.path),children:[d.jsx(kp,{}),d.jsx("span",{className:"explorer-name",children:k.name}),k.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},k.path)}):d.jsx("div",{className:"muted explorer-empty",children:y?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:E,children:E}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!E,onClick:()=>E&&r(E),children:["Use ",w]})]})]})})}const Dl=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],kN="obsidian",mm="loadpath.theme";function NN(t){return Dl.some(r=>r.id===t)}function ym(){try{const t=localStorage.getItem(mm)||"";if(NN(t))return t}catch{}return kN}function jN(t){var r;return((r=Dl.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function vm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=jN(t);try{localStorage.setItem(mm,t)}catch{}}const Gu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:h0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:p0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:g0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:m0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:y0}];function bN(t){const r=t.total||0;return r<=0?null:Math.min(100,Math.round(100*(t.done||0)/r))}function Yu(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function EN(){var wi,Wn,Oe,so,lo,_i,ao,uo,co;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,x]=L.useState(null),[m,y]=L.useState(null),[v,_]=L.useState([]),[N,j]=L.useState("review"),[E,w]=L.useState(""),[C,k]=L.useState(""),[b,A]=L.useState(null),[z,V]=L.useState(!1),[Y,K]=L.useState(!1),[re,q]=L.useState(""),[Z,te]=L.useState({}),[R,U]=L.useState([]),[H,W]=L.useState([]),[M,D]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[F,I]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[$,ie]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[oe,fe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[he,pe]=L.useState(0),[J,ae]=L.useState(""),[me,Ne]=L.useState(ym),[xe,ne]=L.useState(!1),[je,Me]=L.useState(!1),[Te,De]=L.useState(!1),[ht,Je]=L.useState(null),[Xe,lt]=L.useState(null),[yt,Dt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[qt,at]=L.useState(null),[et,vt]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[xt,zn]=L.useState([]),[rn,on]=L.useState(null),[no,Dn]=L.useState(null),[di,Ir]=L.useState(null),[Rr,nr]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[rr,wn]=L.useState(null),[Nt,Ot]=L.useState(null),[Ft,_n]=L.useState(!1),[On,Sn]=L.useState(!1),ut=L.useRef(o);ut.current=o;const Tr=L.useRef(!1);Tr.current=je;const Mt=L.useRef(""),Lr=L.useRef(""),kn=P=>{Ne(P),vm(P)},nt=L.useRef(""),He=P=>{nt.current=P,k(P)},Ar=P=>{const G=()=>{Pe.indexProgress(P).then(Se=>{nt.current&&(Se.phase&&Se.phase!=="idle"&&Se.message&&He(Se.message),A(Se.phase&&Se.phase!=="idle"?bN(Se):null))}).catch(()=>{})};G();const ce=window.setInterval(G,250);return()=>{window.clearInterval(ce),A(null)}};L.useEffect(()=>{Pe.settings().then(te).catch(()=>{}).finally(()=>ne(!0)),Pe.repos().then(P=>_(P.repos)).catch(()=>{})},[]);const sn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const P=o;let G=!1;return Lr.current!==P&&ir(P),Pe.config(P).then(ce=>{!G&&ut.current===P&&Dn(ce)}).catch(()=>{}),Pe.architectureHealth(P).then(ce=>{!G&&ut.current===P&&Ir(ce)}).catch(()=>{}),()=>{G=!0}},[t,o]);const Pt=P=>{ut.current=P,s(P),localStorage.setItem("loadpath.repo",P),P.trim()!==Mt.current&&(Mt.current="",wn(null))},Nn=L.useCallback(P=>{const G=(P??ut.current).trim();return!G||Mt.current===G?Promise.resolve():(Mt.current=G,Pe.gitRefs(G).then(ce=>{ut.current.trim()===G&&wn(ce)}).catch(()=>{Mt.current===G&&(Mt.current="",wn(null))}))},[]),Ht=(P,G)=>{u(P),h(G),localStorage.setItem("loadpath.base",P),localStorage.setItem("loadpath.head",G)},$r=(P,G,ce)=>{I(P),D(G),localStorage.setItem("loadpath.provider",P),localStorage.setItem("loadpath.scmRepo",G),ce!==void 0&&(ie(ce),localStorage.setItem("loadpath.prNumber",ce))},Fn=P=>{x(P),pe(0),Je(Xe&&P.nodes.some(G=>G.id===Xe)?Xe:null),at(null),on(null),P.id&&!P.what_if&&localStorage.setItem("loadpath.lastReviewId",P.id)},zr=async P=>{try{const G=await Pe.reviews(P);zn(G.reviews)}catch{zn([])}},Bt=async P=>{try{Ir(await Pe.architectureHealth(P))}catch{Ir(null)}},Dr=P=>P==="github"?!!Z.github_token_set:P==="gitlab"?!!Z.gitlab_token_set:!!Z.bitbucket_token_set,jt=L.useCallback(async(P=F)=>{var G;try{const ce=await Pe.scmRepos(P);W(ce.repos),(G=ce.user)!=null&&G.login&&te(Se=>({...Se,...P==="github"?{github_user:ce.user.login}:P==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{W([])}},[F]);L.useEffect(()=>{if(t!=="prs")return;let P=!1;return jt(F).catch(()=>{P||W([])}),()=>{P=!0}},[t,F,jt]),L.useEffect(()=>{if(!Nt)return;let P=!1,G=0;const ce=async()=>{try{const Se=await Pe.githubOAuthPoll(Nt.flow_id);if(P)return;if(Se.status==="complete"){Ot(null);const Ie=await Pe.settings();te(Ie),q(Se.user?`Signed in to GitHub as ${Se.user}`:"Signed in to GitHub"),jt("github");return}if(Se.status==="pending"||Se.status==="slow_down"){G=window.setTimeout(ce,Math.max(Se.interval||Nt.interval,5)*1e3);return}Ot(null),w(Se.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(Se){if(P)return;Ot(null),w(Se instanceof Error?Se.message:String(Se))}};return G=window.setTimeout(ce,Math.max(Nt.interval,5)*1e3),()=>{P=!0,window.clearTimeout(G)}},[Nt,jt]),L.useEffect(()=>{if(!Ft)return;let P=!1,G=0;const ce=Date.now(),Se=async()=>{try{const Ie=await Pe.oauthStatus();if(P)return;if(Ie.bitbucket.connected){_n(!1);const Ae=await Pe.settings();te(Ae),q(Ie.bitbucket.user?`Signed in to Bitbucket as ${Ie.bitbucket.user}`:"Signed in to Bitbucket"),jt("bitbucket");return}if(Date.now()-ce>18e4){_n(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}G=window.setTimeout(Se,1500)}catch(Ie){if(P)return;_n(!1),w(Ie instanceof Error?Ie.message:String(Ie))}};return G=window.setTimeout(Se,1500),()=>{P=!0,window.clearTimeout(G)}},[Ft,jt]),L.useEffect(()=>{if(!On)return;let P=!1,G=0;const ce=Date.now(),Se=async()=>{try{const Ie=await Pe.oauthStatus();if(P)return;if(Ie.gitlab.connected){Sn(!1);const Ae=await Pe.settings();te(Ae),q(Ie.gitlab.user?`Signed in to GitLab as ${Ie.gitlab.user}`:"Signed in to GitLab"),jt("gitlab");return}if(Date.now()-ce>18e4){Sn(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}G=window.setTimeout(Se,1500)}catch(Ie){if(P)return;Sn(!1),w(Ie instanceof Error?Ie.message:String(Ie))}};return G=window.setTimeout(Se,1500),()=>{P=!0,window.clearTimeout(G)}},[On,jt]);const ir=async(P=o,G=!1)=>{if(!P.trim())return null;Lr.current=P,K(!0);try{const ce=await Pe.architecture(P,!1);ut.current===P&&y(ce);const Se=Pe.architectureGraph(P).then(Ie=>{ut.current===P&&y(Ae=>Ae&&{...Ae,nodes:Ie.nodes,edges:Ie.edges,graph_pending:!1})});return Se.catch(()=>{}).finally(()=>{ut.current===P&&K(!1)}),G&&await Se,ce}catch(ce){throw ut.current===P&&K(!1),ce}},Or=async P=>{const G=P.trim();if(!(!G||G===ut.current)){if(nt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),q(""),x(null),y(null),j("architecture"),Pt(G),V(!0),He(`Loading ${f0(G)}…`);try{await Promise.all([ir(G),Nn(G)])}catch(ce){ut.current===G&&w(ce instanceof Error?ce.message:String(ce))}finally{ut.current===G&&(He(""),V(!1))}}},jn=async()=>{if(nt.current||!sn())return;w(""),q(""),He("Tracing load path…"),Pt(o),Ht(a,c);const P=Ar(o);try{const G=await Pe.review(o,a,c,!0,oe);Fn(G),j("review"),r("review"),await Pe.repos().then(ce=>_(ce.repos)).catch(()=>{}),await Promise.all([ir(o),zr(o),Bt(o)])}catch(G){w(G instanceof Error?G.message:String(G))}finally{P(),He("")}},or=async(P=!0)=>{if(nt.current||!sn())return;w(""),q(""),He(P?"Indexing…":"Full reindex…"),Pt(o);const G=Ar(o);try{await Pe.index(o,P);const ce=await ir(o);await Pe.repos().then(Se=>_(Se.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(j("architecture"),r("architecture"))}catch(ce){w(ce instanceof Error?ce.message:String(ce))}finally{G(),He("")}},fi=async()=>{if(!nt.current&&sn()){w(""),q(""),He("Detecting layout…"),Pt(o);try{const P=await Pe.init(o);q(P.message),await Pe.repos().then(G=>_(G.repos)).catch(()=>{})}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},ro=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),q("Copied markdown brief")}catch(P){w(P instanceof Error?P.message:String(P))}},hi=async()=>{if(!nt.current){if(!(p!=null&&p.markdown)||!M||!$){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const P=await Pe.postComment(F,M,Number($),p.markdown);q(P.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ve=async()=>{if(!nt.current){w(""),He("Fetching pull requests…");try{const P=await Pe.prs(F,M,"open",o.trim()||void 0);U(P.pull_requests);const G=H.find(ce=>ce.slug.toLowerCase()===M.trim().toLowerCase());G!=null&&G.local_path&&Pt(G.local_path)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},io=async()=>{w("");try{const P=await Pe.githubOAuthStart();Ot(P),Yu(P.verification_uri_complete,"github.com","/login/device")}catch(P){w(P instanceof Error?P.message:String(P))}},Fr=async()=>{w("");try{const P=await Pe.bitbucketOAuthStart();_n(!0),Yu(P.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(P){_n(!1),w(P instanceof Error?P.message:String(P))}},pi=async()=>{w("");try{const P=await Pe.gitlabOAuthStart();Sn(!0),Yu(P.authorize_url,new URL(P.authorize_url).hostname,"/oauth/authorize")}catch(P){Sn(!1),w(P instanceof Error?P.message:String(P))}},bn=async P=>{if(!(nt.current||!o.trim())){w(""),He("Walking what-if path…");try{const G=await Pe.whatIf(o,P);q(`${G.title} — ${G.confidence.level} · ${(G.sinks||[]).length} sinks`),Fn({...G,markdown:G.markdown||"",index:G.index||(p==null?void 0:p.index),workspace:G.workspace||(p==null?void 0:p.workspace)}),j("review"),r("review")}catch(G){w(G instanceof Error?G.message:String(G))}finally{He("")}}},oo=async P=>{var Ie;if(nt.current)return;$r(P.provider,P.repo,String(P.number));const G=H.find(Ae=>Ae.slug.toLowerCase()===P.repo.toLowerCase());G!=null&&G.local_path&&Pt(G.local_path),w(""),He(`Fetching ${P.provider} #${P.number}…`);const ce=(G==null?void 0:G.local_path)||o,Se=ce?Ar(ce):()=>{};try{const Ae=await Pe.reviewPr(P.provider,P.repo,P.number,(G==null?void 0:G.local_path)||o||void 0);Fn(Ae),Ae.pull_request&&typeof Ae.pull_request.repo_path=="string"&&Pt(Ae.pull_request.repo_path),Ht(String(Ae.base||P.target_branch),String(Ae.head||P.source_branch)),j("review"),r("review"),typeof((Ie=Ae.pull_request)==null?void 0:Ie.repo_path)=="string"&&zr(Ae.pull_request.repo_path)}catch(Ae){Ht(P.base_sha||P.target_branch,P.head_sha||P.source_branch),r("review"),w(Ae instanceof Error?Ae.message:String(Ae))}finally{Se(),He("")}},sr=async P=>{w("");try{te(await Pe.oauthDisconnect(P)),F===P&&W([]),q(`Disconnected ${P}`)}catch(G){w(G instanceof Error?G.message:String(G))}},lr=async P=>{P.preventDefault();const G=new FormData(P.currentTarget),ce={github_token:String(G.get("github_token")||""),github_oauth_client_id:String(G.get("github_oauth_client_id")||""),github_host:String(G.get("github_host")||""),gitlab_token:String(G.get("gitlab_token")||""),gitlab_host:String(G.get("gitlab_host")||""),gitlab_oauth_client_id:String(G.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(G.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(G.get("bitbucket_token")||""),bitbucket_username:String(G.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(G.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(G.get("bitbucket_oauth_client_secret")||""),ai_provider:String(G.get("ai_provider")||"none"),ai_api_key:String(G.get("ai_api_key")||""),ai_model:String(G.get("ai_model")||""),ai_base_url:String(G.get("ai_base_url")||"")},Se=v.length?{...ce,workspaces:v.map(Ie=>({path:Ie.path,name:Ie.name}))}:ce;try{te(await Pe.saveSettings(Se)),q("Settings saved on this machine")}catch(Ie){w(Ie instanceof Error?Ie.message:String(Ie))}},bt=async()=>{if(!(!p||nt.current)){He("Residual analysis…");try{const P=await Pe.residual(p);ae(P.note)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Hr=L.useRef(jn);Hr.current=jn;const pt=L.useRef(t);pt.current=t;const gi=L.useRef(!1);gi.current=Te;const mi=L.useRef(p);mi.current=p;const yi=L.useRef(he);yi.current=he,L.useEffect(()=>{const P=localStorage.getItem("loadpath.lastReviewId"),G=(localStorage.getItem("loadpath.repo")||"").trim();if(!P||!G){nr(!1);return}let ce=!1;return Pe.getReview(G,P).then(Se=>{ce||(Fn(Se),Ht(Se.base||localStorage.getItem("loadpath.base")||"HEAD~1",Se.head||localStorage.getItem("loadpath.head")||"HEAD"),zr(G),Bt(G))}).catch(()=>{}).finally(()=>{ce||nr(!1)}),()=>{ce=!0}},[]);const En=L.useRef("");L.useEffect(()=>{if(!et||!o.trim())return;let P=!1;const G=async()=>{try{const Se=await Pe.workspaceStatus(o);if(P)return;En.current&&Se.fingerprint!==En.current&&!nt.current&&(fe(!0),localStorage.setItem("loadpath.dirty","1"),Hr.current()),En.current=Se.fingerprint}catch{}};G();const ce=window.setInterval(G,2e3);return()=>{P=!0,window.clearInterval(ce)}},[et,o]),L.useEffect(()=>{const P=G=>{var Ie;if((G.metaKey||G.ctrlKey)&&G.key.toLowerCase()==="k"){G.preventDefault(),De(Ae=>!Ae);return}if(gi.current){G.key==="Escape"&&(G.preventDefault(),De(!1));return}if(Tr.current){G.key==="Escape"&&(G.preventDefault(),Me(!1));return}const ce=G.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){G.key==="Escape"&&ce.blur();return}if(G.key==="Escape"){w(""),q(""),Je(Xe),at(null);return}if(G.key==="j"||G.key==="k"){const Ae=((Ie=mi.current)==null?void 0:Ie.read_order)||[];if(!Ae.length)return;G.preventDefault();const ur=yi.current,Mn=G.key==="j"?Math.min(Ae.length-1,ur+1):Math.max(0,ur-1);pe(Mn);return}const Se=Gu.find(Ae=>Ae.shortcut===G.key);if(Se&&!G.metaKey&&!G.ctrlKey&&!G.altKey&&r(Se.id),(G.metaKey||G.ctrlKey)&&G.key==="Enter"){if(pt.current==="settings"||pt.current==="prs"||nt.current)return;G.preventDefault(),Hr.current()}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[Xe]);const Hn=async(P,G)=>{if(!o.trim())return;const ce=await mN(o,P,G);ce.ok?q(ce.message):w(ce.message)},Cn=async()=>{if(p)try{const P=await Pe.exportHtml(p),G=URL.createObjectURL(P),ce=document.createElement("a");ce.href=G,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(G),q("Saved HTML brief")}catch(P){w(P instanceof Error?P.message:String(P))}},Kt=async P=>{if(o.trim()){He("Loading stored review…");try{const G=await Pe.getReview(o,P);Fn(G),Ht(G.base||a,G.head||c),j("review"),r("review");const ce=xt.find(Se=>Se.id!==P);if(ce)try{on(await Pe.reviewDiff(o,P,ce.id))}catch{on(null)}}catch(G){w(G instanceof Error?G.message:String(G))}finally{He("")}}},Br={selectedId:ht,onSelect:Je,nodeRoles:p==null?void 0:p.node_roles,testOverlay:yt,isolateSource:qt,onIsolate:at,repoPath:o,onOpenFile:Hn,pinnedId:Xe,onPin:lt},vi=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},{id:"index",group:"Run",label:"Index repository",run:()=>void or(!0)},{id:"watch",group:"Run",label:et?"Stop watching working tree":"Watch working tree",run:()=>{const P=!et;vt(P),localStorage.setItem("loadpath.watch",P?"1":"0")}},{id:"tests",group:"Graph",label:yt?"Hide test overlay":"Show test overlay",run:()=>{const P=!yt;Dt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Cn()},...Gu.map(P=>({id:`tab-${P.id}`,group:"Tabs",label:`Go to ${P.label}`,hint:P.shortcut,run:()=>r(P.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(P=>({id:`node-${P.id}`,group:"Nodes",label:P.name,hint:to(P.type),run:()=>{Je(P.id),r("graph")}})),...xt.slice(0,12).map(P=>({id:`hist-${P.id}`,group:"History",label:P.title||P.id,hint:`${P.level||""} ${P.created_at||""}`.trim(),run:()=>void Kt(P.id)}))],ar=L.useMemo(()=>N==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[N,m,p]),xi=L.useMemo(()=>N==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[N,m,p]),Bn=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Vn=((p==null?void 0:p.findings)||[]).filter(P=>!P.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Gu.map(P=>{const G=P.icon,ce=t===P.id;return d.jsxs("button",{type:"button","data-testid":P.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":P.label,onClick:()=>r(P.id),children:[d.jsx(G,{}),d.jsx("span",{children:P.label})]},P.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:me,onChange:P=>kn(P.target.value),children:["dark","light"].map(P=>d.jsx("optgroup",{label:P==="dark"?"Dark":"Light",children:Dl.filter(G=>G.group===P).map(G=>d.jsx("option",{value:G.id,children:G.label},G.id))},P))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:C||Bn}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[C?d.jsxs("div",{className:b!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","data-testid":"progress",children:[d.jsx("i",{style:b!=null?{width:`${b}%`}:void 0}),d.jsx("span",{className:"sr-only",children:C})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[v.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:v.some(P=>P.path===o)?o:"",disabled:!!C,"aria-busy":z,onChange:P=>{P.target.value&&Or(P.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),v.map(P=>d.jsxs("option",{value:P.path,children:[P.name,P.indexed?` (${P.counts.nodes})`:""]},P.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:P=>{const G=P.target.value;s(G),G.trim()!==Mt.current&&(Mt.current="",wn(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>Me(!0),children:d.jsx(kp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(xp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:P=>Ht(P,c),placeholder:"base",refs:rr,onNeedRefs:Nn})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(xp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:P=>Ht(a,P),placeholder:"head",refs:rr,onNeedRefs:Nn})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:oe?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":oe,onClick:()=>{const P=!oe;fe(P),localStorage.setItem("loadpath.dirty",P?"1":"0")},children:oe?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:et?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":et,onClick:()=>{const P=!et;vt(P),localStorage.setItem("loadpath.watch",P?"1":"0")},children:et?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!C,onClick:fi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!C,onClick:()=>or(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!C,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[E?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:E}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,re?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:re}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>q(""),"aria-label":"Dismiss",children:"×"})]}):null,((wi=p==null?void 0:p.index)!=null&&wi.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((Wn=p==null?void 0:p.index)==null?void 0:Wn.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Oe=p==null?void 0:p.index)==null?void 0:Oe.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(so=p==null?void 0:p.workspace)!=null&&so.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,z?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:C||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":z||Y,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(CN,{review:p,findings:Vn,aiNote:J,busy:!!C,tourIndex:he,onTour:pe,onAskAi:bt,onCopy:ro,onPost:hi,onSelect:Je,onOpenFile:Hn,onExport:Cn,history:xt,diff:rn,onReopen:Kt,onWaiver:(P,G)=>{o.trim()&&Pe.addWaiver(o,P,G||void 0,"from review").then(ce=>{Dn(ce),q(`Waived ${P} in loadpath.yml`)})}}):Rr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Uu,{nodes:p.nodes,edges:p.edges,onWhatIf:bn,focusPath:(lo=p.read_order[he])==null?void 0:lo.path,...Br}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(MN,{architecture:m,busy:!!C,onReindex:()=>or(!1),onReview:jn,onSelect:Je,config:no,health:di,onSaveConfig:P=>{Pe.saveConfig(o,P).then(G=>{Dn(G),q("Wrote loadpath.yml")})},onWaiver:(P,G,ce)=>{Pe.addWaiver(o,P,G,ce).then(Se=>{Dn(Se),q(`Waived ${P}`)})}}):z?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(Y||m!=null&&m.graph_pending)&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(_i=m==null?void 0:m.counts)!=null&&_i.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Uu,{nodes:m.nodes,edges:m.edges,onWhatIf:bn,...Br,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":N==="review","data-testid":"graph-mode-review",className:N==="review"?"active":"",onClick:()=>j("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":N==="architecture","data-testid":"graph-mode-architecture",className:N==="architecture"?"active":"",onClick:()=>j("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:yt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":yt,onClick:()=>{const P=!yt;Dt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")},children:"Tests"})]}),ar.length?d.jsx(Uu,{nodes:ar,edges:xi,onWhatIf:bn,...Br}):Y||m!=null&&m.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:F,onChange:P=>$r(P.target.value,M,$),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:H.length?"Search your repos":"owner/repo",value:M,onChange:P=>$r(F,P.target.value,$),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:H.map(P=>d.jsxs("option",{value:P.slug,children:[P.private?"private":"public",P.local_path?" · local":""]},P.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!C||!Dr(F),onClick:()=>{jt(F)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!C,onClick:Ve,children:"List PRs"})]}),H.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[H.length," ",F," repositor",H.length===1?"y":"ies",F==="github"&&Z.github_user?` · @${String(Z.github_user)}`:"",F==="gitlab"&&Z.gitlab_user?` · @${String(Z.gitlab_user)}`:"",F==="bitbucket"&&Z.bitbucket_user?` · ${String(Z.bitbucket_user)}`:""]}):null,R.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):R.map(P=>{var G;return d.jsxs("article",{className:"pr","data-testid":`pr-${P.number}`,children:[d.jsxs("h3",{children:["#",P.number," ",P.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${P.draft?"":"open"}`,children:P.draft?"draft":P.state}),d.jsx("span",{children:P.author}),d.jsxs("span",{children:[P.source_branch," → ",P.target_branch]}),P.loadpath?d.jsxs("span",{className:`chip ${P.loadpath.level||""}`,"data-testid":`pr-loadpath-${P.number}`,children:[((G=P.loadpath.level)==null?void 0:G.toUpperCase())||"REVIEWED",P.loadpath.contract_break&&P.loadpath.contract_break!=="none"?` · ${P.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:P.url,target:"_blank",rel:"noreferrer",children:["Open on ",P.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${P.number}`,onClick:()=>void oo(P),children:"Review this PR"})]})]},`${P.provider}-${P.number}`)})]}),t==="settings"&&xe&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:lr,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Dl.map(P=>d.jsxs("button",{type:"button","data-theme":P.id,className:me===P.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${P.id}`,onClick:()=>kn(P.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:P.label}),d.jsx("div",{className:"group",children:P.group})]},P.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:gm(),onChange:P=>gN(P.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:Z.github_token_set?Z.github_user?`Signed in as @${String(Z.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:Z.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void sr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!Nt||!Z.github_oauth_ready,onClick:()=>void io(),children:Nt?"Waiting for GitHub…":"Sign in with GitHub"})})]}),Nt?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:Nt.user_code})," at GitHub if the browser did not fill it in."]}):null,Z.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(Z.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(Z.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:Z.gitlab_token_set?Z.gitlab_user?`Signed in as @${String(Z.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:Z.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void sr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:On||!Z.gitlab_oauth_ready,onClick:()=>void pi(),children:On?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(Z.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(Z.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:Z.bitbucket_token_set?Z.bitbucket_user?`Signed in as ${String(Z.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:Z.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void sr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:Ft||!Z.bitbucket_oauth_ready,onClick:()=>void Fr(),children:Ft?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),Z.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(Z.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(Z.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((ao=Z.ai)==null?void 0:ao.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((uo=Z.ai)==null?void 0:uo.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((co=Z.ai)==null?void 0:co.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(u0,{open:Te,actions:vi,onClose:()=>De(!1)}),je?d.jsx(SN,{initialPath:o,onClose:()=>Me(!1),onSelect:P=>{if(nt.current){w("Wait for the current job to finish before switching workspace.");return}Me(!1),Or(P)}}):null]})}function CN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:x,onOpenFile:m,onExport:y,history:v,diff:_,onReopen:N,onWaiver:j}){var w,C,k,b,A,z,V,Y,K,re,q,Z,te,R,U,H,W;const E=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),E.length?d.jsx("ul",{className:"reasons",children:E.map(M=>d.jsx("li",{children:M},M))}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Xo(M)},M)),(w=t.contract_break)!=null&&w.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&x(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>j(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(C=t.workspace)!=null&&C.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>m(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&x(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(xm,{cards:t.deepening}),(b=(k=t.contract_break)==null?void 0:k.reasons)!=null&&b.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),(z=(A=t.contract_break.sides)==null?void 0:A.rows)!=null&&z.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(V=t.auth)!=null&&V.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(Y=t.suggested_tests)==null?void 0:Y.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(K=t.trend)!=null&&K.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",Xu(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),v.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:v.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,v.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>N(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?Xu(M.created_at):""})]},M.id))]}):null,(q=(re=t.evolution)==null?void 0:re.notes)!=null&&q.length||(te=(Z=t.evolution)==null?void 0:Z.hotspots)!=null&&te.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((R=t.evolution)==null?void 0:R.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((U=t.evolution)==null?void 0:U.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:y,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(H=t.codeowners_reviewers)!=null&&H.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(W=t.knowledge_owners)!=null&&W.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function MN({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var m;const x=t.findings.filter(y=>!y.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${Xu(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(y=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y.name})," — ",(y.django_apps||[]).join(", ")||"no apps"," ·"," ",(y.owners||[]).join(", ")||"unowned"]},y.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(y=>d.jsx("div",{className:"muted",children:y},y))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:x.length})]}),x.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):x.map(y=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>y.node_id&&a(y.node_id),children:[d.jsx("span",{className:`chip ${y.severity}`,children:y.severity}),y.message]})},y.rule+y.message))]}),d.jsx(xm,{cards:t.deepening}),(m=c==null?void 0:c.points)!=null&&m.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(y=>d.jsx("i",{className:y.level||"",title:`${y.level} · ${y.findings} findings`,style:{height:`${8+Math.min(24,(y.findings||0)*4)}px`}},y.id||y.created_at))}),Object.entries(c.contexts).map(([y,v])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y})," — last ",((_=v[v.length-1])==null?void 0:_.findings)??0," findings"]},y)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(c0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((y,v)=>v[1]-y[1]).slice(0,12).map(([y,v])=>d.jsxs("tr",{children:[d.jsx("td",{children:to(y)}),d.jsx("td",{children:v})]},y))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function xm({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:d0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}vm(ym());s0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(EN,{})}));export{Hk as L,RN as a,PN as c,d as j,IN as l,L as r,to as t}; diff --git a/src/loadpath/static/index.html b/src/loadpath/static/index.html index d81c363..2a75dec 100644 --- a/src/loadpath/static/index.html +++ b/src/loadpath/static/index.html @@ -17,7 +17,7 @@ - + diff --git a/tests/e2e/test_ui_flows.py b/tests/e2e/test_ui_flows.py index 2c45340..5a8374c 100644 --- a/tests/e2e/test_ui_flows.py +++ b/tests/e2e/test_ui_flows.py @@ -463,17 +463,22 @@ def test_ui_architecture_brief_paints_before_graph(live_app, browser_page): page = browser_page page.goto(base_url, wait_until="networkidle") _wait_fonts(page) - - def on_route(route): - if "/api/architecture/graph" in route.request.url: - time.sleep(1.2) - route.continue_() - - page.route("**/api/**", on_route) + page.evaluate( + """() => { + const orig = window.fetch; + window.fetch = async (input, init) => { + const url = String(typeof input === "string" ? input : input.url); + if (url.includes("/api/architecture/graph")) { + await new Promise((resolve) => setTimeout(resolve, 2000)); + } + return orig.call(window, input, init); + }; + }""" + ) page.get_by_test_id("repo-path").fill(str(repo)) _index_repo(page, repo) page.get_by_test_id("architecture-brief").locator(".level").wait_for(timeout=20_000) - page.get_by_test_id("graph-loading").wait_for() + page.get_by_test_id("graph-loading").wait_for(timeout=8_000) assert "drawing" in page.get_by_test_id("graph-loading").inner_text().lower() page.get_by_test_id("graph-loading").wait_for(state="hidden", timeout=20_000) wait_visible_graph(page) diff --git a/ui/src/App.tsx b/ui/src/App.tsx index c100ed3..9d40ca8 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -1299,7 +1299,7 @@ export function App() { )}
- {graphLoading && !(architecture?.nodes || []).length ? ( + {((graphLoading || architecture?.graph_pending) && !(architecture?.nodes || []).length) ? (

Drawing the architecture map…

@@ -1381,7 +1381,7 @@ export function App() {

{graphNodes.length ? ( - ) : graphLoading ? ( + ) : graphLoading || architecture?.graph_pending ? (

Drawing the architecture map…

From 24f0a73161de5e04b2c7f82f010a0cc03bc6ad40 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 15 Aug 2026 23:55:44 +0000 Subject: [PATCH 06/16] Clarify what-if walks and restore the last git-range review. What-if is a hypothetical walk from one node, not a filter of the current map. Show that in the inspector and a banner, and add Back to git range so the previous review is not lost. Co-authored-by: zord.lack.net --- README.md | 2 +- ...-37-6JMJ.js => LayeredGraph3D-BnhN-wUA.js} | 2 +- src/loadpath/static/assets/index-ChLCMR1f.js | 62 +++++++++++++++++ ...{index-Bmsup5i5.css => index-DCcHASmi.css} | 2 +- src/loadpath/static/assets/index-sgthL-dY.js | 62 ----------------- src/loadpath/static/index.html | 4 +- tests/e2e/test_ui_flows.py | 49 ++++++++++++++ ui/src/App.tsx | 66 ++++++++++++++++++- ui/src/ImpactGraph.tsx | 23 ++++++- ui/src/styles.css | 18 +++++ ui/src/types.ts | 1 + 11 files changed, 219 insertions(+), 72 deletions(-) rename src/loadpath/static/assets/{LayeredGraph3D--37-6JMJ.js => LayeredGraph3D-BnhN-wUA.js} (99%) create mode 100644 src/loadpath/static/assets/index-ChLCMR1f.js rename src/loadpath/static/assets/{index-Bmsup5i5.css => index-DCcHASmi.css} (79%) delete mode 100644 src/loadpath/static/assets/index-sgthL-dY.js diff --git a/README.md b/README.md index cb4c35f..569a47d 100644 --- a/README.md +++ b/README.md @@ -205,7 +205,7 @@ loadpath index /tmp/acme-billing loadpath serve --open ``` -Then point the UI at `/tmp/acme-billing`, or pick it from the repo explorer. `loadpath serve` always boots the app; it does not take a repo path. Default range is `HEAD~1`…`HEAD`. Toggle **Include uncommitted** to walk the working tree. Click a node → **What if this changes** to walk sinks without a git range. The read-order list is a guided tour (prev/next highlights the file on the graph). +Then point the UI at `/tmp/acme-billing`, or pick it from the repo explorer. `loadpath serve` always boots the app; it does not take a repo path. Default range is `HEAD~1`…`HEAD`. Toggle **Include uncommitted** to walk the working tree. Click a node → **What if this changes** to walk sinks as if that node changed — no git range, and **Back to git range** restores the last real review. Isolate path to sinks only filters the current map. The read-order list is a guided tour (prev/next highlights the file on the graph). ## GitHub Action merge gate diff --git a/src/loadpath/static/assets/LayeredGraph3D--37-6JMJ.js b/src/loadpath/static/assets/LayeredGraph3D-BnhN-wUA.js similarity index 99% rename from src/loadpath/static/assets/LayeredGraph3D--37-6JMJ.js rename to src/loadpath/static/assets/LayeredGraph3D-BnhN-wUA.js index 8e93f92..4137de1 100644 --- a/src/loadpath/static/assets/LayeredGraph3D--37-6JMJ.js +++ b/src/loadpath/static/assets/LayeredGraph3D-BnhN-wUA.js @@ -1,4 +1,4 @@ -import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-sgthL-dY.js";/** +import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-ChLCMR1f.js";/** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT diff --git a/src/loadpath/static/assets/index-ChLCMR1f.js b/src/loadpath/static/assets/index-ChLCMR1f.js new file mode 100644 index 0000000..3df2524 --- /dev/null +++ b/src/loadpath/static/assets/index-ChLCMR1f.js @@ -0,0 +1,62 @@ +(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function Sp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Pu={exports:{}},Vo={},Iu={exports:{}},Ie={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var qf;function Zy(){if(qf)return Ie;qf=1;var t=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),v=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),y=Symbol.iterator;function m(R){return R===null||typeof R!="object"?null:(R=y&&R[y]||R["@@iterator"],typeof R=="function"?R:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,b={};function E(R,A,ie){this.props=R,this.context=A,this.refs=b,this.updater=ie||_}E.prototype.isReactComponent={},E.prototype.setState=function(R,A){if(typeof R!="object"&&typeof R!="function"&&R!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,R,A,"setState")},E.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function N(){}N.prototype=E.prototype;function P(R,A,ie){this.props=R,this.context=A,this.refs=b,this.updater=ie||_}var w=P.prototype=new N;w.constructor=P,k(w,E.prototype),w.isPureReactComponent=!0;var j=Array.isArray,$=Object.prototype.hasOwnProperty,D={current:null},B={key:!0,ref:!0,__self:!0,__source:!0};function Y(R,A,ie){var oe,fe={},he=null,pe=null;if(A!=null)for(oe in A.ref!==void 0&&(pe=A.ref),A.key!==void 0&&(he=""+A.key),A)$.call(A,oe)&&!B.hasOwnProperty(oe)&&(fe[oe]=A[oe]);var Z=arguments.length-2;if(Z===1)fe.children=ie;else if(1>>1,A=M[R];if(0>>1;Ra(fe,F))hea(pe,fe)?(M[R]=pe,M[he]=F,R=he):(M[R]=fe,M[oe]=F,R=oe);else if(hea(pe,F))M[R]=pe,M[he]=F,R=he;else break e}}return z}function a(M,z){var F=M.sortIndex-z.sortIndex;return F!==0?F:M.id-z.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,h=c.now();t.unstable_now=function(){return c.now()-h}}var p=[],v=[],x=1,y=null,m=3,_=!1,k=!1,b=!1,E=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,P=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(M){for(var z=o(v);z!==null;){if(z.callback===null)s(v);else if(z.startTime<=M)s(v),z.sortIndex=z.expirationTime,r(p,z);else break;z=o(v)}}function j(M){if(b=!1,w(M),!k)if(o(p)!==null)k=!0,W($);else{var z=o(v);z!==null&&U(j,z.startTime-M)}}function $(M,z){k=!1,b&&(b=!1,N(Y),Y=-1),_=!0;var F=m;try{for(w(z),y=o(p);y!==null&&(!(y.expirationTime>z)||M&&!ee());){var R=y.callback;if(typeof R=="function"){y.callback=null,m=y.priorityLevel;var A=R(y.expirationTime<=z);z=t.unstable_now(),typeof A=="function"?y.callback=A:y===o(p)&&s(p),w(z)}else s(p);y=o(p)}if(y!==null)var ie=!0;else{var oe=o(v);oe!==null&&U(j,oe.startTime-z),ie=!1}return ie}finally{y=null,m=F,_=!1}}var D=!1,B=null,Y=-1,Q=5,ne=-1;function ee(){return!(t.unstable_now()-neM||125R?(M.sortIndex=F,r(v,M),o(p)===null&&M===o(v)&&(b?(N(Y),Y=-1):b=!0,U(j,F-R))):(M.sortIndex=A,r(p,M),k||_||(k=!0,W($))),M},t.unstable_shouldYield=ee,t.unstable_wrapCallback=function(M){var z=m;return function(){var F=m;m=z;try{return M.apply(this,arguments)}finally{m=F}}}})(Lu)),Lu}var eh;function r0(){return eh||(eh=1,Tu.exports=n0()),Tu.exports}/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var th;function i0(){if(th)return zt;th=1;var t=ls(),r=r0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,v=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,x={},y={};function m(e){return p.call(y,e)?!0:p.call(x,e)?!1:v.test(e)?y[e]=!0:(x[e]=!0,!1)}function _(e,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function k(e,n,i,l){if(n===null||typeof n>"u"||_(e,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function b(e,n,i,l,f,g,S){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=f,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=g,this.removeEmptyString=S}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){E[e]=new b(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];E[n]=new b(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){E[e]=new b(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){E[e]=new b(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){E[e]=new b(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){E[e]=new b(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){E[e]=new b(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){E[e]=new b(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){E[e]=new b(e,5,!1,e.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function P(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(N,P);E[n]=new b(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(N,P);E[n]=new b(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(N,P);E[n]=new b(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){E[e]=new b(e,1,!1,e.toLowerCase(),null,!1,!1)}),E.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){E[e]=new b(e,1,!1,e.toLowerCase(),null,!0,!0)});function w(e,n,i,l){var f=E.hasOwnProperty(n)?E[n]:null;(f!==null?f.type!==0:l||!(2T||f[S]!==g[T]){var O=` +`+f[S].replace(" at new "," at ");return e.displayName&&O.includes("")&&(O=O.replace("",e.displayName)),O}while(1<=S&&0<=T);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?A(e):""}function fe(e){switch(e.tag){case 5:return A(e.type);case 16:return A("Lazy");case 13:return A("Suspense");case 19:return A("SuspenseList");case 0:case 2:case 15:return e=oe(e.type,!1),e;case 11:return e=oe(e.type.render,!1),e;case 1:return e=oe(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case B:return"Fragment";case D:return"Portal";case Q:return"Profiler";case Y:return"StrictMode";case q:return"Suspense";case C:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ee:return(e.displayName||"Context")+".Consumer";case ne:return(e._context.displayName||"Context")+".Provider";case te:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case W:n=e._payload,e=e._init;try{return he(e(n))}catch{}}return null}function pe(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===Y?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Z(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=se(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function Ne(e){e._valueTracker||(e._valueTracker=me(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=se(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function re(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function je(e,n){var i=n.checked;return F({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Z(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Re(e,n){n=n.checked,n!=null&&w(e,"checked",n,!1)}function Ae(e,n){Re(e,n);var i=Z(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?lt(e,n.type,i):n.hasOwnProperty("defaultValue")&<(e,n.type,Z(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function st(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function lt(e,n,i){(n!=="number"||re(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var at=Array.isArray;function Ye(e,n,i,l){if(e=e.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=Je.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ot(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var xn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ro=["Webkit","ms","Moz","O"];Object.keys(xn).forEach(function(e){ro.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),xn[n]=xn[e]})});function $n(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||xn.hasOwnProperty(e)&&xn[e]?(""+n).trim():n+"px"}function yi(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=$n(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,f):e[i]=f}}var ir=F({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function $r(e,n){if(n){if(ir[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function zn(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var zr=null;function or(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var sr=null,Ft=null,ct=null;function Dn(e){if(e=Co(e)){if(typeof sr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=Cs(n),sr(e.stateNode,e.type,n))}}function On(e){Ft?ct?ct.push(e):ct=[e]:Ft=e}function wn(){if(Ft){var e=Ft,n=ct;if(ct=Ft=null,Dn(e),n)for(e=0;e>>=0,e===0?32:31-(lo(e)/Ur|0)|0}var Wn=64,Un=4194304;function bn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Bt(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,f=e.suspendedLanes,g=e.pingedLanes,S=i&268435455;if(S!==0){var T=S&~f;T!==0?l=bn(T):(g&=S,g!==0&&(l=bn(g)))}else S=i&~f,S!==0?l=bn(S):g!==0&&(l=bn(g));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,g=n&-n,f>=g||f===16&&(g&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function En(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Et(n),e[n]=i}function ao(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=xo),Hc=" ",Bc=!1;function Vc(e,n){switch(e){case"keyup":return Ym.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ji=!1;function qm(e,n){switch(e){case"compositionend":return Wc(n);case"keypress":return n.which!==32?null:(Bc=!0,Hc);case"textInput":return e=n.data,e===Hc&&Bc?null:e;default:return null}}function Km(e,n){if(ji)return e==="compositionend"||!ca&&Vc(e,n)?(e=Ac(),ys=ia=gr=null,ji=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Qc(i)}}function Jc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Jc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function ed(){for(var e=window,n=re();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=re(e.document)}return n}function ha(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function oy(e){var n=ed(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Jc(i.ownerDocument.documentElement,i)){if(l!==null&&ha(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var f=i.textContent.length,g=Math.min(l.start,f);l=l.end===void 0?g:Math.min(l.end,f),!e.extend&&g>l&&(f=l,l=g,g=f),f=Zc(i,g);var S=Zc(i,l);f&&S&&(e.rangeCount!==1||e.anchorNode!==f.node||e.anchorOffset!==f.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),e.removeAllRanges(),g>l?(e.addRange(n),e.extend(S.node,S.offset)):(n.setEnd(S.node,S.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,bi=null,pa=null,ko=null,ga=!1;function td(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;ga||bi==null||bi!==re(l)||(l=bi,"selectionStart"in l&&ha(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),ko&&So(ko,l)||(ko=l,l=js(pa,"onSelect"),0Ii||(e.current=Ea[Ii],Ea[Ii]=null,Ii--)}function Be(e,n){Ii++,Ea[Ii]=e.current,e.current=n}var xr={},St=vr(xr),Rt=vr(!1),Kr=xr;function Ri(e,n){var i=e.type.contextTypes;if(!i)return xr;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in i)f[g]=n[g];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=f),f}function Tt(e){return e=e.childContextTypes,e!=null}function Ms(){Ue(Rt),Ue(St)}function md(e,n,i){if(St.current!==xr)throw Error(o(168));Be(St,n),Be(Rt,i)}function yd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,pe(e)||"Unknown",f));return F({},i,l)}function Ps(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||xr,Kr=St.current,Be(St,e),Be(Rt,Rt.current),!0}function vd(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=yd(e,n,Kr),l.__reactInternalMemoizedMergedChildContext=e,Ue(Rt),Ue(St),Be(St,e)):Ue(Rt),Be(Rt,i)}var Xn=null,Is=!1,Ca=!1;function xd(e){Xn===null?Xn=[e]:Xn.push(e)}function yy(e){Is=!0,xd(e)}function wr(){if(!Ca&&Xn!==null){Ca=!0;var e=0,n=Fe;try{var i=Xn;for(Fe=1;e>=S,f-=S,qn=1<<32-Et(n)+f|i<Ce?(pt=Ee,Ee=null):pt=Ee.sibling;var Oe=le(X,Ee,K[Ce],ce);if(Oe===null){Ee===null&&(Ee=pt);break}e&&Ee&&Oe.alternate===null&&n(X,Ee),H=g(Oe,H,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe,Ee=pt}if(Ce===K.length)return i(X,Ee),Xe&&Zr(X,Ce),_e;if(Ee===null){for(;CeCe?(pt=Ee,Ee=null):pt=Ee.sibling;var Mr=le(X,Ee,Oe.value,ce);if(Mr===null){Ee===null&&(Ee=pt);break}e&&Ee&&Mr.alternate===null&&n(X,Ee),H=g(Mr,H,Ce),be===null?_e=Mr:be.sibling=Mr,be=Mr,Ee=pt}if(Oe.done)return i(X,Ee),Xe&&Zr(X,Ce),_e;if(Ee===null){for(;!Oe.done;Ce++,Oe=K.next())Oe=ue(X,Oe.value,ce),Oe!==null&&(H=g(Oe,H,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return Xe&&Zr(X,Ce),_e}for(Ee=l(X,Ee);!Oe.done;Ce++,Oe=K.next())Oe=ge(Ee,X,Ce,Oe.value,ce),Oe!==null&&(e&&Oe.alternate!==null&&Ee.delete(Oe.key===null?Ce:Oe.key),H=g(Oe,H,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return e&&Ee.forEach(function(Qy){return n(X,Qy)}),Xe&&Zr(X,Ce),_e}function et(X,H,K,ce){if(typeof K=="object"&&K!==null&&K.type===B&&K.key===null&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case $:e:{for(var _e=K.key,be=H;be!==null;){if(be.key===_e){if(_e=K.type,_e===B){if(be.tag===7){i(X,be.sibling),H=f(be,K.props.children),H.return=X,X=H;break e}}else if(be.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===W&&jd(_e)===be.type){i(X,be.sibling),H=f(be,K.props),H.ref=Mo(X,be,K),H.return=X,X=H;break e}i(X,be);break}else n(X,be);be=be.sibling}K.type===B?(H=si(K.props.children,X.mode,ce,K.key),H.return=X,X=H):(ce=ol(K.type,K.key,K.props,null,X.mode,ce),ce.ref=Mo(X,H,K),ce.return=X,X=ce)}return S(X);case D:e:{for(be=K.key;H!==null;){if(H.key===be)if(H.tag===4&&H.stateNode.containerInfo===K.containerInfo&&H.stateNode.implementation===K.implementation){i(X,H.sibling),H=f(H,K.children||[]),H.return=X,X=H;break e}else{i(X,H);break}else n(X,H);H=H.sibling}H=ju(K,X.mode,ce),H.return=X,X=H}return S(X);case W:return be=K._init,et(X,H,be(K._payload),ce)}if(at(K))return xe(X,H,K,ce);if(z(K))return we(X,H,K,ce);As(X,K)}return typeof K=="string"&&K!==""||typeof K=="number"?(K=""+K,H!==null&&H.tag===6?(i(X,H.sibling),H=f(H,K),H.return=X,X=H):(i(X,H),H=Nu(K,X.mode,ce),H.return=X,X=H),S(X)):i(X,H)}return et}var $i=bd(!0),Ed=bd(!1),$s=vr(null),zs=null,zi=null,La=null;function Aa(){La=zi=zs=null}function $a(e){var n=$s.current;Ue($s),e._currentValue=n}function za(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function Di(e,n){zs=e,La=zi=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Lt=!0),e.firstContext=null)}function Zt(e){var n=e._currentValue;if(La!==e)if(e={context:e,memoizedValue:n,next:null},zi===null){if(zs===null)throw Error(o(308));zi=e,zs.dependencies={lanes:0,firstContext:e}}else zi=zi.next=e;return n}var Jr=null;function Da(e){Jr===null?Jr=[e]:Jr.push(e)}function Cd(e,n,i,l){var f=n.interleaved;return f===null?(i.next=i,Da(n)):(i.next=f.next,f.next=i),n.interleaved=i,Qn(e,l)}function Qn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var _r=!1;function Oa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Md(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Zn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Sr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,($e&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,Qn(e,i)}return f=l.interleaved,f===null?(n.next=n,Da(l)):(n.next=f.next,f.next=n),l.interleaved=n,Qn(e,i)}function Ds(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,hr(e,i)}}function Pd(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var S={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?f=g=S:g=g.next=S,i=i.next}while(i!==null);g===null?f=g=n:g=g.next=n}else f=g=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function Os(e,n,i,l){var f=e.updateQueue;_r=!1;var g=f.firstBaseUpdate,S=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,J=O.next;O.next=null,S===null?g=J:S.next=J,S=O;var ae=e.alternate;ae!==null&&(ae=ae.updateQueue,T=ae.lastBaseUpdate,T!==S&&(T===null?ae.firstBaseUpdate=J:T.next=J,ae.lastBaseUpdate=O))}if(g!==null){var ue=f.baseState;S=0,ae=J=O=null,T=g;do{var le=T.lane,ge=T.eventTime;if((l&le)===le){ae!==null&&(ae=ae.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var xe=e,we=T;switch(le=n,ge=i,we.tag){case 1:if(xe=we.payload,typeof xe=="function"){ue=xe.call(ge,ue,le);break e}ue=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=we.payload,le=typeof xe=="function"?xe.call(ge,ue,le):xe,le==null)break e;ue=F({},ue,le);break e;case 2:_r=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,le=f.effects,le===null?f.effects=[T]:le.push(T))}else ge={eventTime:ge,lane:le,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ae===null?(J=ae=ge,O=ue):ae=ae.next=ge,S|=le;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;le=T,T=le.next,le.next=null,f.lastBaseUpdate=le,f.shared.pending=null}}while(!0);if(ae===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=J,f.lastBaseUpdate=ae,n=f.shared.interleaved,n!==null){f=n;do S|=f.lane,f=f.next;while(f!==n)}else g===null&&(f.shared.lanes=0);ni|=S,e.lanes=S,e.memoizedState=ue}}function Id(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=Wa.transition;Wa.transition={};try{e(!1),n()}finally{Fe=i,Wa.transition=l}}function Kd(){return Jt().memoizedState}function _y(e,n,i){var l=br(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},Qd(e))Zd(n,i);else if(i=Cd(e,n,i,l),i!==null){var f=Mt();dn(i,e,l,f),Jd(i,n,l)}}function Sy(e,n,i){var l=br(e),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(Qd(e))Zd(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,T=g(S,i);if(f.hasEagerState=!0,f.eagerState=T,sn(T,S)){var O=n.interleaved;O===null?(f.next=f,Da(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=Cd(e,n,f,l),i!==null&&(f=Mt(),dn(i,e,l,f),Jd(i,n,l))}}function Qd(e){var n=e.alternate;return e===Ke||n!==null&&n===Ke}function Zd(e,n){To=Bs=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Jd(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,hr(e,i)}}var Us={readContext:Zt,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},ky={readContext:Zt,useCallback:function(e,n){return Pn().memoizedState=[e,n===void 0?null:n],e},useContext:Zt,useEffect:Bd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Vs(4194308,4,Ud.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Vs(4194308,4,e,n)},useInsertionEffect:function(e,n){return Vs(4,2,e,n)},useMemo:function(e,n){var i=Pn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=Pn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=_y.bind(null,Ke,e),[l.memoizedState,e]},useRef:function(e){var n=Pn();return e={current:e},n.memoizedState=e},useState:Fd,useDebugValue:Qa,useDeferredValue:function(e){return Pn().memoizedState=e},useTransition:function(){var e=Fd(!1),n=e[0];return e=wy.bind(null,e[1]),Pn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=Ke,f=Pn();if(Xe){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ht===null)throw Error(o(349));(ti&30)!==0||Ad(l,n,i)}f.memoizedState=i;var g={value:i,getSnapshot:n};return f.queue=g,Bd(zd.bind(null,l,g,e),[e]),l.flags|=2048,$o(9,$d.bind(null,l,g,i,n),void 0,null),i},useId:function(){var e=Pn(),n=ht.identifierPrefix;if(Xe){var i=Kn,l=qn;i=(l&~(1<<32-Et(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=Lo++,0<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=S.createElement(i,{is:l.is}):(e=S.createElement(i),i==="select"&&(S=e,l.multiple?S.multiple=!0:l.size&&(S.size=l.size))):e=S.createElementNS(e,i),e[Cn]=n,e[Eo]=l,wf(e,n,!1,!1),n.stateNode=e;e:{switch(S=zn(i,l),i){case"dialog":We("cancel",e),We("close",e),f=l;break;case"iframe":case"object":case"embed":We("load",e),f=l;break;case"video":case"audio":for(f=0;fVi&&(n.flags|=128,l=!0,zo(g,!1),n.lanes=4194304)}else{if(!l)if(e=Fs(S),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),zo(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Xe)return Nt(n),null}else 2*Ve()-g.renderingStartTime>Vi&&i!==1073741824&&(n.flags|=128,l=!0,zo(g,!1),n.lanes=4194304);g.isBackwards?(S.sibling=n.child,n.child=S):(i=g.last,i!==null?i.sibling=S:n.child=S,g.last=S)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(Nt(n),null);case 22:case 23:return _u(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Gt&1073741824)!==0&&(Nt(n),n.subtreeFlags&6&&(n.flags|=8192)):Nt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function Iy(e,n){switch(Pa(n),n.tag){case 1:return Tt(n.type)&&Ms(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Oi(),Ue(Rt),Ue(St),Va(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Ha(n),null;case 13:if(Ue(qe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));Ai()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Oi(),null;case 10:return $a(n.type._context),null;case 22:case 23:return _u(),null;case 24:return null;default:return null}}var qs=!1,jt=!1,Ry=typeof WeakSet=="function"?WeakSet:Set,ye=null;function Hi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Ze(e,n,l)}else i.current=null}function uu(e,n,i){try{i()}catch(l){Ze(e,n,l)}}var kf=!1;function Ty(e,n){if(_a=gs,e=ed(),ha(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,g=l.focusNode;l=l.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var S=0,T=-1,O=-1,J=0,ae=0,ue=e,le=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=S+f),ue!==g||l!==0&&ue.nodeType!==3||(O=S+l),ue.nodeType===3&&(S+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)le=ue,ue=ge;for(;;){if(ue===e)break t;if(le===i&&++J===f&&(T=S),le===g&&++ae===l&&(O=S),(ge=ue.nextSibling)!==null)break;ue=le,le=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(Sa={focusedElem:e,selectionRange:i},gs=!1,ye=n;ye!==null;)if(n=ye,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ye=e;else for(;ye!==null;){n=ye;try{var xe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var we=xe.memoizedProps,et=xe.memoizedState,X=n.stateNode,H=X.getSnapshotBeforeUpdate(n.elementType===n.type?we:an(n.type,we),et);X.__reactInternalSnapshotBeforeUpdate=H}break;case 3:var K=n.stateNode.containerInfo;K.nodeType===1?K.textContent="":K.nodeType===9&&K.documentElement&&K.removeChild(K.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(ce){Ze(n,n.return,ce)}if(e=n.sibling,e!==null){e.return=n.return,ye=e;break}ye=n.return}return xe=kf,kf=!1,xe}function Do(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&e)===e){var g=f.destroy;f.destroy=void 0,g!==void 0&&uu(n,i,g)}f=f.next}while(f!==l)}}function Ks(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function cu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function Nf(e){var n=e.alternate;n!==null&&(e.alternate=null,Nf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[Cn],delete n[Eo],delete n[ba],delete n[gy],delete n[my])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function jf(e){return e.tag===5||e.tag===3||e.tag===4}function bf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||jf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function du(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=Es));else if(l!==4&&(e=e.child,e!==null))for(du(e,n,i),e=e.sibling;e!==null;)du(e,n,i),e=e.sibling}function fu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(fu(e,n,i),e=e.sibling;e!==null;)fu(e,n,i),e=e.sibling}var vt=null,un=!1;function kr(e,n,i){for(i=i.child;i!==null;)Ef(e,n,i),i=i.sibling}function Ef(e,n,i){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(Vn,i)}catch{}switch(i.tag){case 5:jt||Hi(i,n);case 6:var l=vt,f=un;vt=null,kr(e,n,i),vt=l,un=f,vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):vt.removeChild(i.stateNode));break;case 18:vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?ja(e.parentNode,i):e.nodeType===1&&ja(e,i),mo(e)):ja(vt,i.stateNode));break;case 4:l=vt,f=un,vt=i.stateNode.containerInfo,un=!0,kr(e,n,i),vt=l,un=f;break;case 0:case 11:case 14:case 15:if(!jt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var g=f,S=g.destroy;g=g.tag,S!==void 0&&((g&2)!==0||(g&4)!==0)&&uu(i,n,S),f=f.next}while(f!==l)}kr(e,n,i);break;case 1:if(!jt&&(Hi(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Ze(i,n,T)}kr(e,n,i);break;case 21:kr(e,n,i);break;case 22:i.mode&1?(jt=(l=jt)||i.memoizedState!==null,kr(e,n,i),jt=l):kr(e,n,i);break;default:kr(e,n,i)}}function Cf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Ry),n.forEach(function(l){var f=By.bind(null,e,l);i.has(l)||(i.add(l),l.then(f,f))})}}function cn(e,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=S),l&=~g}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Ay(l/1960))-l,10e?16:e,jr===null)var l=!1;else{if(e=jr,jr=null,tl=0,($e&6)!==0)throw Error(o(331));var f=$e;for($e|=4,ye=e.current;ye!==null;){var g=ye,S=g.child;if((ye.flags&16)!==0){var T=g.deletions;if(T!==null){for(var O=0;OVe()-gu?ii(e,0):pu|=i),$t(e,n)}function Hf(e,n){n===0&&((e.mode&1)===0?n=1:(n=Un,Un<<=1,(Un&130023424)===0&&(Un=4194304)));var i=Mt();e=Qn(e,n),e!==null&&(En(e,n,i),$t(e,i))}function Hy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Hf(e,i)}function By(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Hf(e,i)}var Bf;Bf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Rt.current)Lt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Lt=!1,My(e,n,i);Lt=(e.flags&131072)!==0}else Lt=!1,Xe&&(n.flags&1048576)!==0&&wd(n,Ts,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Xs(e,n),e=n.pendingProps;var f=Ri(n,St.current);Di(n,i),f=Ga(null,n,l,e,f,i);var g=Ya();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Tt(l)?(g=!0,Ps(n)):g=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Oa(n),f.updater=Gs,n.stateNode=f,f._reactInternals=n,Ja(n,l,e,i),n=ru(null,n,l,!0,g,i)):(n.tag=0,Xe&&g&&Ma(n),Ct(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Xs(e,n),e=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=Wy(l),e=an(l,e),f){case 0:n=nu(null,n,l,e,i);break e;case 1:n=pf(null,n,l,e,i);break e;case 11:n=uf(null,n,l,e,i);break e;case 14:n=cf(null,n,l,an(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),nu(e,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),pf(e,n,l,f,i);case 3:e:{if(gf(n),e===null)throw Error(o(387));l=n.pendingProps,g=n.memoizedState,f=g.element,Md(e,n),Os(n,l,null,i);var S=n.memoizedState;if(l=S.element,g.isDehydrated)if(g={element:l,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){f=Fi(Error(o(423)),n),n=mf(e,n,l,i,f);break e}else if(l!==f){f=Fi(Error(o(424)),n),n=mf(e,n,l,i,f);break e}else for(Ut=yr(n.stateNode.containerInfo.firstChild),Wt=n,Xe=!0,ln=null,i=Ed(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Ai(),l===f){n=Jn(e,n,i);break e}Ct(e,n,l,i)}n=n.child}return n;case 5:return Rd(n),e===null&&Ra(n),l=n.type,f=n.pendingProps,g=e!==null?e.memoizedProps:null,S=f.children,ka(l,f)?S=null:g!==null&&ka(l,g)&&(n.flags|=32),hf(e,n),Ct(e,n,S,i),n.child;case 6:return e===null&&Ra(n),null;case 13:return yf(e,n,i);case 4:return Fa(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=$i(n,null,l,i):Ct(e,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),uf(e,n,l,f,i);case 7:return Ct(e,n,n.pendingProps,i),n.child;case 8:return Ct(e,n,n.pendingProps.children,i),n.child;case 12:return Ct(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,g=n.memoizedProps,S=f.value,Be($s,l._currentValue),l._currentValue=S,g!==null)if(sn(g.value,S)){if(g.children===f.children&&!Rt.current){n=Jn(e,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var T=g.dependencies;if(T!==null){S=g.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(g.tag===1){O=Zn(-1,i&-i),O.tag=2;var J=g.updateQueue;if(J!==null){J=J.shared;var ae=J.pending;ae===null?O.next=O:(O.next=ae.next,ae.next=O),J.pending=O}}g.lanes|=i,O=g.alternate,O!==null&&(O.lanes|=i),za(g.return,i,n),T.lanes|=i;break}O=O.next}}else if(g.tag===10)S=g.type===n.type?null:g.child;else if(g.tag===18){if(S=g.return,S===null)throw Error(o(341));S.lanes|=i,T=S.alternate,T!==null&&(T.lanes|=i),za(S,i,n),S=g.sibling}else S=g.child;if(S!==null)S.return=g;else for(S=g;S!==null;){if(S===n){S=null;break}if(g=S.sibling,g!==null){g.return=S.return,S=g;break}S=S.return}g=S}Ct(e,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,Di(n,i),f=Zt(f),l=l(f),n.flags|=1,Ct(e,n,l,i),n.child;case 14:return l=n.type,f=an(l,n.pendingProps),f=an(l.type,f),cf(e,n,l,f,i);case 15:return df(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),Xs(e,n),n.tag=1,Tt(l)?(e=!0,Ps(n)):e=!1,Di(n,i),tf(n,l,f),Ja(n,l,f,i),ru(null,n,l,!0,e,i);case 19:return xf(e,n,i);case 22:return ff(e,n,i)}throw Error(o(156,n.tag))};function Vf(e,n){return Hr(e,n)}function Vy(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tn(e,n,i,l){return new Vy(e,n,i,l)}function ku(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Wy(e){if(typeof e=="function")return ku(e)?1:0;if(e!=null){if(e=e.$$typeof,e===te)return 11;if(e===V)return 14}return 2}function Cr(e,n){var i=e.alternate;return i===null?(i=tn(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function ol(e,n,i,l,f,g){var S=2;if(l=e,typeof e=="function")ku(e)&&(S=1);else if(typeof e=="string")S=5;else e:switch(e){case B:return si(i.children,f,g,n);case Y:S=8,f|=8;break;case Q:return e=tn(12,i,n,f|2),e.elementType=Q,e.lanes=g,e;case q:return e=tn(13,i,n,f),e.elementType=q,e.lanes=g,e;case C:return e=tn(19,i,n,f),e.elementType=C,e.lanes=g,e;case U:return sl(i,f,g,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ne:S=10;break e;case ee:S=9;break e;case te:S=11;break e;case V:S=14;break e;case W:S=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=tn(S,i,n,f),n.elementType=e,n.type=l,n.lanes=g,n}function si(e,n,i,l){return e=tn(7,e,l,n),e.lanes=i,e}function sl(e,n,i,l){return e=tn(22,e,l,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function Nu(e,n,i){return e=tn(6,e,null,n),e.lanes=i,e}function ju(e,n,i){return n=tn(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Uy(e,n,i,l,f){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Gn(0),this.expirationTimes=Gn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Gn(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function bu(e,n,i,l,f,g,S,T,O){return e=new Uy(e,n,i,T,O),n===1?(n=1,g===!0&&(n|=8)):n=0,g=tn(3,null,null,n),e.current=g,g.stateNode=e,g.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Oa(g),e}function Gy(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),Ru.exports=i0(),Ru.exports}var rh;function o0(){if(rh)return hl;rh=1;var t=kp();return hl.createRoot=t.createRoot,hl.hydrateRoot=t.hydrateRoot,hl}var s0=o0();function Np(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Te(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(Np(s,o.statusText||"Request failed"))}return o.json()}const l0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Pe={health:()=>Te("/api/health"),settings:()=>Te("/api/settings"),saveSettings:t=>{const r={...t};for(const o of l0)r[o]===""&&delete r[o];return Te("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Te("/api/repos"),browse:t=>Te(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Te(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Te("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Te(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Te(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:(t,r=!0)=>Te(`/api/architecture?repo_path=${encodeURIComponent(t)}&graph=${r?"1":"0"}`),architectureGraph:t=>Te(`/api/architecture/graph?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Te("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Te("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Te("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Te("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Te("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Te(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open",s)=>Te("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o,repo_path:s||null})}),scmRepos:t=>Te(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Te("/api/oauth/status"),githubOAuthStart:()=>Te("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Te("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Te("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Te("/api/oauth/gitlab/start"),oauthDisconnect:t=>Te("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Te("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})}),reviews:t=>Te(`/api/reviews?repo_path=${encodeURIComponent(t)}`),getReview:(t,r)=>Te(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(t)}`),reviewDiff:(t,r,o)=>Te(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(t)}&other=${encodeURIComponent(o)}`),config:t=>Te(`/api/config?repo_path=${encodeURIComponent(t)}`),saveConfig:(t,r)=>Te("/api/config",{method:"PUT",body:JSON.stringify({repo_path:t,...r})}),addWaiver:(t,r,o,s)=>Te("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:t,rule:r,node:o||null,reason:s||""})}),marks:(t,r)=>Te(`/api/marks?repo_path=${encodeURIComponent(t)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:t=>Te(`/api/architecture/health?repo_path=${encodeURIComponent(t)}`),workspaceStatus:t=>Te(`/api/workspace/status?repo_path=${encodeURIComponent(t)}`),openEditor:(t,r,o,s)=>Te("/api/open",{method:"POST",body:JSON.stringify({repo_path:t,path:r,line:o||null,editor:s||null})}),exportHtml:t=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:t})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(Np(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(t,r,o,s)=>Te("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:t,edges:r,source_id:o,target_id:s||null})})};function a0(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):t}function u0({open:t,actions:r,onClose:o}){const[s,a]=L.useState(""),[u,c]=L.useState(0),h=L.useRef(null),p=L.useMemo(()=>a0(r,s),[r,s]);if(L.useEffect(()=>{if(!t)return;a(""),c(0);const y=window.setTimeout(()=>{var m;return(m=h.current)==null?void 0:m.focus()},0);return()=>window.clearTimeout(y)},[t]),L.useEffect(()=>{c(0)},[s]),!t)return null;const v=p[u],x=y=>{y&&(o(),y.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:y=>{y.target===y.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:y=>a(y.target.value),onKeyDown:y=>{y.key==="Escape"?(y.preventDefault(),o()):y.key==="ArrowDown"?(y.preventDefault(),c(m=>Math.min(p.length-1,m+1))):y.key==="ArrowUp"?(y.preventDefault(),c(m=>Math.max(0,m-1))):y.key==="Enter"&&(y.preventDefault(),x(v))}}),d.jsxs("ul",{children:[p.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,p.slice(0,40).map((y,m)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:m===u?"active":"",onMouseEnter:()=>c(m),onClick:()=>x(y),children:[d.jsx("span",{children:y.label}),y.hint?d.jsx("span",{className:"muted",children:y.hint}):null]})},y.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function c0({config:t,busy:r,onSave:o,onWaiver:s}){const[a,u]=L.useState(t),[c,h]=L.useState(t.available_rules[0]||""),[p,v]=L.useState(""),[x,y]=L.useState("");L.useEffect(()=>{u(t)},[t]);const m=Object.entries(a.contexts||{}),_=(P,w,j)=>{const $=a.contexts[P];if(!$)return;const D=B=>B.split(",").map(Y=>Y.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[P]:{...$,[w]:w==="name"?j:D(j)}}})},k=(P,w)=>{const j=w.trim();if(!j||j===P)return;const{[P]:$,...D}=a.contexts;$&&u({...a,contexts:{...D,[j]:{...$,name:j}}})},b=()=>{let P=1;for(;a.contexts[`context-${P}`];)P+=1;const w=`context-${P}`;u({...a,contexts:{...a.contexts,[w]:{name:w,django_apps:[],react:[],public_api:[],owners:[]}}})},E=P=>{const{[P]:w,...j}=a.contexts;u({...a,contexts:j})},N=P=>{const w=a.rules.includes(P);u({...a,rules:w?a.rules.filter(j=>j!==P):[...a.rules,P]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),m.map(([P,w])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:P})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:P,"data-testid":`config-context-name-${P}`,onBlur:j=>k(P,j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(w.django_apps||[]).join(", "),onChange:j=>_(P,"django_apps",j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(w.react||[]).join(", "),onChange:j=>_(P,"react",j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(w.public_api||[]).join(", "),onChange:j=>_(P,"public_api",j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(w.owners||[]).join(", "),onChange:j=>_(P,"owners",j.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>E(P),children:"Remove context"})]},P)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:b,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(P=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(P),onChange:()=>N(P)}),P]},P))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((P,w)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:P.rule}),P.node?` · ${P.node}`:"",P.reason?` — ${P.reason}`:""]},`${P.rule}:${P.node}:${w}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:P=>h(P.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(P=>d.jsx("option",{value:P,children:P},P))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:P=>v(P.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:x,onChange:P=>y(P.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,x),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function Ko(t){return t.replaceAll("_"," ")}function d0(t){return t.replaceAll("_"," ")}function no(t){return t.split(".").pop()||t}function Qu(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function f0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Tr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function mi({className:t,children:r}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function h0({className:t}){return d.jsxs(mi,{className:t,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function p0({className:t}){return d.jsxs(mi,{className:t,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function g0({className:t}){return d.jsxs(mi,{className:t,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function m0({className:t}){return d.jsxs(mi,{className:t,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function y0({className:t}){return d.jsxs(mi,{className:t,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function jp({className:t}){return d.jsx(mi,{className:t,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function v0({className:t}){return d.jsx(mi,{className:t,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const x0="modulepreload",w0=function(t,r){return new URL(t,r).href},ih={},_0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(x){return Promise.all(x.map(y=>Promise.resolve(y).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),v=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(x=>{if(x=w0(x,s),x in ih)return;ih[x]=!0;const y=x.endsWith(".css"),m=y?'[rel="stylesheet"]':"";if(!!s)for(let b=h.length-1;b>=0;b--){const E=h[b];if(E.href===x&&(!y||E.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${x}"]${m}`))return;const k=document.createElement("link");if(k.rel=y?"stylesheet":x0,y||(k.as="script"),k.crossOrigin="",k.href=x,v&&k.setAttribute("nonce",v),document.head.appendChild(k),y)return new Promise((b,E)=>{k.addEventListener("load",b),k.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${x}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function nt(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Hl(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}jl.prototype=Hl.prototype={constructor:jl,on:function(t,r){var o=this._,s=k0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),sh.hasOwnProperty(r)?{space:sh[r],local:t}:t}function j0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===Zu&&r.documentElement.namespaceURI===Zu?r.createElement(t):r.createElementNS(o,t)}}function b0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function bp(t){var r=Bl(t);return(r.local?b0:j0)(r)}function E0(){}function pc(t){return t==null?E0:function(){return this.querySelector(t)}}function C0(t){typeof t!="function"&&(t=pc(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=w&&(w=P+1);!($=E[w])&&++w=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function J0(t){t||(t=ev);function r(y,m){return y&&m?t(y.__data__,m.__data__):!y-!m}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function tv(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function nv(){return Array.from(this)}function rv(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?pv:typeof r=="function"?mv:gv)(t,r,o??"")):qi(this.node(),t)}function qi(t,r){return t.style.getPropertyValue(r)||Ip(t).getComputedStyle(t,null).getPropertyValue(r)}function vv(t){return function(){delete this[t]}}function xv(t,r){return function(){this[t]=r}}function wv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function _v(t,r){return arguments.length>1?this.each((r==null?vv:typeof r=="function"?wv:xv)(t,r)):this.node()[t]}function Rp(t){return t.trim().split(/^|\s+/)}function gc(t){return t.classList||new Tp(t)}function Tp(t){this._node=t,this._names=Rp(t.getAttribute("class")||"")}Tp.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Lp(t,r){for(var o=gc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function qv(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function Ju(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:v,dispatch:x}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:v,enumerable:!0,configurable:!0},_:{value:x}})}Ju.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function ox(t){return!t.ctrlKey&&!t.button}function sx(){return this.parentNode}function lx(t,r){return r??{x:t.x,y:t.y}}function ax(){return navigator.maxTouchPoints||"ontouchstart"in this}function Fp(){var t=ox,r=sx,o=lx,s=ax,a={},u=Hl("start","drag","end"),c=0,h,p,v,x,y=0;function m(j){j.on("mousedown.drag",_).filter(s).on("touchstart.drag",E).on("touchmove.drag",N,ix).on("touchend.drag touchcancel.drag",P).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(j,$){if(!(x||!t.call(this,j,$))){var D=w(this,r.call(this,j,$),j,$,"mouse");D&&(Yt(j.view).on("mousemove.drag",k,Qo).on("mouseup.drag",b,Qo),Dp(j.view),Au(j),v=!1,h=j.clientX,p=j.clientY,D("start",j))}}function k(j){if(Yi(j),!v){var $=j.clientX-h,D=j.clientY-p;v=$*$+D*D>y}a.mouse("drag",j)}function b(j){Yt(j.view).on("mousemove.drag mouseup.drag",null),Op(j.view,v),Yi(j),a.mouse("end",j)}function E(j,$){if(t.call(this,j,$)){var D=j.changedTouches,B=r.call(this,j,$),Y=D.length,Q,ne;for(Q=0;Q>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?gl(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?gl(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=cx.exec(t))?new Dt(r[1],r[2],r[3],1):(r=dx.exec(t))?new Dt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=fx.exec(t))?gl(r[1],r[2],r[3],r[4]):(r=hx.exec(t))?gl(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=px.exec(t))?hh(r[1],r[2]/100,r[3]/100,1):(r=gx.exec(t))?hh(r[1],r[2]/100,r[3]/100,r[4]):lh.hasOwnProperty(t)?ch(lh[t]):t==="transparent"?new Dt(NaN,NaN,NaN,0):null}function ch(t){return new Dt(t>>16&255,t>>8&255,t&255,1)}function gl(t,r,o,s){return s<=0&&(t=r=o=NaN),new Dt(t,r,o,s)}function vx(t){return t instanceof us||(t=di(t)),t?(t=t.rgb(),new Dt(t.r,t.g,t.b,t.opacity)):new Dt}function ec(t,r,o,s){return arguments.length===1?vx(t):new Dt(t,r,o,s??1)}function Dt(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}mc(Dt,ec,Hp(us,{brighter(t){return t=t==null?Il:Math.pow(Il,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Zo:Math.pow(Zo,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Dt(ui(this.r),ui(this.g),ui(this.b),Rl(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:dh,formatHex:dh,formatHex8:xx,formatRgb:fh,toString:fh}));function dh(){return`#${ai(this.r)}${ai(this.g)}${ai(this.b)}`}function xx(){return`#${ai(this.r)}${ai(this.g)}${ai(this.b)}${ai((isNaN(this.opacity)?1:this.opacity)*255)}`}function fh(){const t=Rl(this.opacity);return`${t===1?"rgb(":"rgba("}${ui(this.r)}, ${ui(this.g)}, ${ui(this.b)}${t===1?")":`, ${t})`}`}function Rl(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ui(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ai(t){return t=ui(t),(t<16?"0":"")+t.toString(16)}function hh(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new hn(t,r,o,s)}function Bp(t){if(t instanceof hn)return new hn(t.h,t.s,t.l,t.opacity);if(t instanceof us||(t=di(t)),!t)return new hn;if(t instanceof hn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new hn(c,h,p,t.opacity)}function wx(t,r,o,s){return arguments.length===1?Bp(t):new hn(t,r,o,s??1)}function hn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}mc(hn,wx,Hp(us,{brighter(t){return t=t==null?Il:Math.pow(Il,t),new hn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Zo:Math.pow(Zo,t),new hn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Dt($u(t>=240?t-240:t+120,a,s),$u(t,a,s),$u(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new hn(ph(this.h),ml(this.s),ml(this.l),Rl(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 t=Rl(this.opacity);return`${t===1?"hsl(":"hsla("}${ph(this.h)}, ${ml(this.s)*100}%, ${ml(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ph(t){return t=(t||0)%360,t<0?t+360:t}function ml(t){return Math.max(0,Math.min(1,t||0))}function $u(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const yc=t=>()=>t;function _x(t,r){return function(o){return t+o*r}}function Sx(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function kx(t){return(t=+t)==1?Vp:function(r,o){return o-r?Sx(r,o,t):yc(isNaN(r)?o:r)}}function Vp(t,r){var o=r-t;return o?_x(t,o):yc(isNaN(t)?r:t)}const Tl=(function t(r){var o=kx(r);function s(a,u){var c=o((a=ec(a)).r,(u=ec(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),v=Vp(a.opacity,u.opacity);return function(x){return a.r=c(x),a.g=h(x),a.b=p(x),a.opacity=v(x),a+""}}return s.gamma=t,s})(1);function Nx(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:Rn(s,a)})),o=zu.lastIndex;return o180?x+=360:x-v>180&&(v+=360),m.push({i:y.push(a(y)+"rotate(",null,s)-2,x:Rn(v,x)})):x&&y.push(a(y)+"rotate("+x+s)}function h(v,x,y,m){v!==x?m.push({i:y.push(a(y)+"skewX(",null,s)-2,x:Rn(v,x)}):x&&y.push(a(y)+"skewX("+x+s)}function p(v,x,y,m,_,k){if(v!==y||x!==m){var b=_.push(a(_)+"scale(",null,",",null,")");k.push({i:b-4,x:Rn(v,y)},{i:b-2,x:Rn(x,m)})}else(y!==1||m!==1)&&_.push(a(_)+"scale("+y+","+m+")")}return function(v,x){var y=[],m=[];return v=t(v),x=t(x),u(v.translateX,v.translateY,x.translateX,x.translateY,y,m),c(v.rotate,x.rotate,y,m),h(v.skewX,x.skewX,y,m),p(v.scaleX,v.scaleY,x.scaleX,x.scaleY,y,m),v=x=null,function(_){for(var k=-1,b=m.length,E;++k=0&&t._call.call(void 0,r),t=t._next;--Ki}function yh(){fi=(Al=es.now())+Vl,Ki=Go=0;try{Ox()}finally{Ki=0,Hx(),fi=0}}function Fx(){var t=es.now(),r=t-Al;r>Yp&&(Vl-=r,Al=t)}function Hx(){for(var t,r=Ll,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:Ll=o);Yo=t,rc(s)}function rc(t){if(!Ki){Go&&(Go=clearTimeout(Go));var r=t-fi;r>24?(t<1/0&&(Go=setTimeout(yh,t-es.now()-Vl)),Wo&&(Wo=clearInterval(Wo))):(Wo||(Al=es.now(),Wo=setInterval(Fx,Yp)),Ki=1,Xp(yh))}}function vh(t,r,o){var s=new $l;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Bx=Hl("start","end","cancel","interrupt"),Vx=[],Kp=0,xh=1,ic=2,El=3,wh=4,oc=5,Cl=6;function Wl(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;Wx(t,o,{name:r,index:s,group:a,on:Bx,tween:Vx,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Kp})}function xc(t,r){var o=yn(t,r);if(o.state>Kp)throw new Error("too late; already scheduled");return o}function Ln(t,r){var o=yn(t,r);if(o.state>El)throw new Error("too late; already running");return o}function yn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Wx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=qp(u,0,o.time);function u(v){o.state=xh,o.timer.restart(c,o.delay,o.time),o.delay<=v&&c(v-o.delay)}function c(v){var x,y,m,_;if(o.state!==xh)return p();for(x in s)if(_=s[x],_.name===o.name){if(_.state===El)return vh(c);_.state===wh?(_.state=Cl,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete s[x]):+xic&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function ww(t,r,o){var s,a,u=xw(r)?xc:Ln;return function(){var c=u(this,t),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function _w(t,r){var o=this._id;return arguments.length<2?yn(this.node(),o).on.on(t):this.each(ww(o,t,r))}function Sw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function kw(){return this.on("end.remove",Sw(this._id))}function Nw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=pc(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function qw(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function nr(t,r,o){this.k=t,this.x=r,this.y=o}nr.prototype={constructor:nr,scale:function(t){return t===1?this:new nr(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new nr(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Ul=new nr(1,0,0);eg.prototype=nr.prototype;function eg(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Ul;return t.__zoom}function Du(t){t.stopImmediatePropagation()}function Uo(t){t.preventDefault(),t.stopImmediatePropagation()}function Kw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Qw(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function _h(){return this.__zoom||Ul}function Zw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Jw(){return navigator.maxTouchPoints||"ontouchstart"in this}function e1(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function tg(){var t=Kw,r=Qw,o=e1,s=Zw,a=Jw,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=bl,v=Hl("start","zoom","end"),x,y,m,_=500,k=150,b=0,E=10;function N(C){C.property("__zoom",_h).on("wheel.zoom",Y,{passive:!1}).on("mousedown.zoom",Q).on("dblclick.zoom",ne).filter(a).on("touchstart.zoom",ee).on("touchmove.zoom",te).on("touchend.zoom touchcancel.zoom",q).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}N.transform=function(C,V,W,U){var M=C.selection?C.selection():C;M.property("__zoom",_h),C!==M?$(C,V,W,U):M.interrupt().each(function(){D(this,arguments).event(U).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},N.scaleBy=function(C,V,W,U){N.scaleTo(C,function(){var M=this.__zoom.k,z=typeof V=="function"?V.apply(this,arguments):V;return M*z},W,U)},N.scaleTo=function(C,V,W,U){N.transform(C,function(){var M=r.apply(this,arguments),z=this.__zoom,F=W==null?j(M):typeof W=="function"?W.apply(this,arguments):W,R=z.invert(F),A=typeof V=="function"?V.apply(this,arguments):V;return o(w(P(z,A),F,R),M,c)},W,U)},N.translateBy=function(C,V,W,U){N.transform(C,function(){return o(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),r.apply(this,arguments),c)},null,U)},N.translateTo=function(C,V,W,U,M){N.transform(C,function(){var z=r.apply(this,arguments),F=this.__zoom,R=U==null?j(z):typeof U=="function"?U.apply(this,arguments):U;return o(Ul.translate(R[0],R[1]).scale(F.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),z,c)},U,M)};function P(C,V){return V=Math.max(u[0],Math.min(u[1],V)),V===C.k?C:new nr(V,C.x,C.y)}function w(C,V,W){var U=V[0]-W[0]*C.k,M=V[1]-W[1]*C.k;return U===C.x&&M===C.y?C:new nr(C.k,U,M)}function j(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function $(C,V,W,U){C.on("start.zoom",function(){D(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){D(this,arguments).event(U).end()}).tween("zoom",function(){var M=this,z=arguments,F=D(M,z).event(U),R=r.apply(M,z),A=W==null?j(R):typeof W=="function"?W.apply(M,z):W,ie=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),oe=M.__zoom,fe=typeof V=="function"?V.apply(M,z):V,he=p(oe.invert(A).concat(ie/oe.k),fe.invert(A).concat(ie/fe.k));return function(pe){if(pe===1)pe=fe;else{var Z=he(pe),se=ie/Z[2];pe=new nr(se,A[0]-Z[0]*se,A[1]-Z[1]*se)}F.zoom(null,pe)}})}function D(C,V,W){return!W&&C.__zooming||new B(C,V)}function B(C,V){this.that=C,this.args=V,this.active=0,this.sourceEvent=null,this.extent=r.apply(C,V),this.taps=0}B.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,V){return this.mouse&&C!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var V=Yt(this.that).datum();v.call(C,this.that,new qw(C,{sourceEvent:this.sourceEvent,target:N,transform:this.that.__zoom,dispatch:v}),V)}};function Y(C,...V){if(!t.apply(this,arguments))return;var W=D(this,V).event(C),U=this.__zoom,M=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,s.apply(this,arguments)))),z=fn(C);if(W.wheel)(W.mouse[0][0]!==z[0]||W.mouse[0][1]!==z[1])&&(W.mouse[1]=U.invert(W.mouse[0]=z)),clearTimeout(W.wheel);else{if(U.k===M)return;W.mouse=[z,U.invert(z)],Ml(this),W.start()}Uo(C),W.wheel=setTimeout(F,k),W.zoom("mouse",o(w(P(U,M),W.mouse[0],W.mouse[1]),W.extent,c));function F(){W.wheel=null,W.end()}}function Q(C,...V){if(m||!t.apply(this,arguments))return;var W=C.currentTarget,U=D(this,V,!0).event(C),M=Yt(C.view).on("mousemove.zoom",A,!0).on("mouseup.zoom",ie,!0),z=fn(C,W),F=C.clientX,R=C.clientY;Dp(C.view),Du(C),U.mouse=[z,this.__zoom.invert(z)],Ml(this),U.start();function A(oe){if(Uo(oe),!U.moved){var fe=oe.clientX-F,he=oe.clientY-R;U.moved=fe*fe+he*he>b}U.event(oe).zoom("mouse",o(w(U.that.__zoom,U.mouse[0]=fn(oe,W),U.mouse[1]),U.extent,c))}function ie(oe){M.on("mousemove.zoom mouseup.zoom",null),Op(oe.view,U.moved),Uo(oe),U.event(oe).end()}}function ne(C,...V){if(t.apply(this,arguments)){var W=this.__zoom,U=fn(C.changedTouches?C.changedTouches[0]:C,this),M=W.invert(U),z=W.k*(C.shiftKey?.5:2),F=o(w(P(W,z),U,M),r.apply(this,V),c);Uo(C),h>0?Yt(this).transition().duration(h).call($,F,U,C):Yt(this).call(N.transform,F,U,C)}}function ee(C,...V){if(t.apply(this,arguments)){var W=C.touches,U=W.length,M=D(this,V,C.changedTouches.length===U).event(C),z,F,R,A;for(Du(C),F=0;F`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},ts=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ng=["Enter"," ","Escape"],rg={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Qi;(function(t){t.Strict="strict",t.Loose="loose"})(Qi||(Qi={}));var ci;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(ci||(ci={}));var ns;(function(t){t.Partial="partial",t.Full="full"})(ns||(ns={}));const ig={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Lr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Lr||(Lr={}));var rs;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(rs||(rs={}));var ke;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(ke||(ke={}));const Sh={[ke.Left]:ke.Right,[ke.Right]:ke.Left,[ke.Top]:ke.Bottom,[ke.Bottom]:ke.Top};function og(t){return t===null?null:t?"valid":"invalid"}const sg=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,t1=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),_c=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),cs=(t,r=[0,0])=>{const{width:o,height:s}=vn(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},n1=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):_c(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,Gl(a,zl(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?Yl(s):{x:0,y:0,width:0,height:0}},ds=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=Gl(o,zl(a)),s=!0)}),s?Yl(o):{x:0,y:0,width:0,height:0}},Sc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,v=r.width/a,x=r.height/a,y=[];for(const m of t.values()){const{measured:_,selectable:k=!0,hidden:b=!1}=m;if(c&&!k||b)continue;const E=_.width??m.width??m.initialWidth??0,N=_.height??m.height??m.initialHeight??0,{x:P,y:w}=m.internals.positionAbsolute,j=cg(h,p,v,x,P,w,E,N),$=E*N,D=u&&j>0;(!m.internals.handleBounds||D||j>=$||m.dragging)&&y.push(m)}return y},r1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function i1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=vn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function o1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const h=i1(t,c),p=ds(h),v=Nc(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(v,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function lg({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),h=c.parentId?o.get(c.parentId):void 0,{x:p,y:v}=h?h.internals.positionAbsolute:{x:0,y:0},x=c.origin??s;let y=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",mn.error005());else{const{width:_,height:k}=vn(h);_&&k&&(y=[[p,v],[p+_,v+k]])}else h&&pi(c.extent)&&(y=[[c.extent[0][0]+p,c.extent[0][1]+v],[c.extent[1][0]+p,c.extent[1][1]+v]]);const m=pi(y)?hi(r,y,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",mn.error015())),{position:{x:m.x-p+(c.measured.width??0)*x[0],y:m.y-v+(c.measured.height??0)*x[1]},positionAbsolute:m}}async function s1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(m=>m.id)),c=[];for(const m of o){if(m.deletable===!1)continue;const _=u.has(m.id),k=!_&&m.parentId&&c.find(b=>b.id===m.parentId);(_||k)&&c.push(m)}const h=new Set(r.map(m=>m.id)),p=s.filter(m=>m.deletable!==!1),x=r1(c,p);for(const m of p)h.has(m.id)&&!x.find(k=>k.id===m.id)&&x.push(m);if(!a)return{edges:x,nodes:c};const y=await a({nodes:c,edges:x});return typeof y=="boolean"?y?{edges:x,nodes:c}:{edges:[],nodes:[]}:y}const Zi=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),hi=(t={x:0,y:0},r,o)=>({x:Zi(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:Zi(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function ag(t,r,o){const{width:s,height:a}=vn(o),{x:u,y:c}=o.internals.positionAbsolute;return hi(t,[[u,c],[u+s,c+a]],r)}const kh=(t,r,o)=>to?-Zi(Math.abs(t-o),1,r)/r:0,kc=(t,r,o=15,s=40)=>{const a=kh(t.x,s,r.width-s)*o,u=kh(t.y,s,r.height-s)*o;return[a,u]},Gl=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),sc=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),Yl=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),is=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:cs(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},zl=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:cs(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},ug=(t,r)=>Yl(Gl(sc(t),sc(r))),cg=(t,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),v=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*v)},Dl=(t,r)=>cg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),Nh=t=>pn(t.width)&&pn(t.height)&&pn(t.x)&&pn(t.y),pn=t=>!isNaN(t)&&isFinite(t),dg=(t,r)=>(o,s)=>{},fs=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),hs=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(t-o)/a,y:(r-s)/a};return u?fs(h,c):h},Ji=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Ui(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function l1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Ui(t,o),a=Ui(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Ui(t.top??t.y??0,o),a=Ui(t.bottom??t.y??0,o),u=Ui(t.left??t.x??0,r),c=Ui(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function a1(t,r,o,s,a,u){const{x:c,y:h}=Ji(t,[r,o,s]),{x:p,y:v}=Ji({x:t.x+t.width,y:t.y+t.height},[r,o,s]),x=a-p,y=u-v;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(x),bottom:Math.floor(y)}}const Nc=(t,r,o,s,a,u)=>{const c=l1(u,r,o),h=(r-c.x)/t.width,p=(o-c.y)/t.height,v=Math.min(h,p),x=Zi(v,s,a),y=t.x+t.width/2,m=t.y+t.height/2,_=r/2-y*x,k=o/2-m*x,b=a1(t,_,k,x,r,o),E={left:Math.min(b.left-c.left,0),top:Math.min(b.top-c.top,0),right:Math.min(b.right-c.right,0),bottom:Math.min(b.bottom-c.bottom,0)};return{x:_-E.left+E.right,y:k-E.top+E.bottom,zoom:x}},os=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function pi(t){return t!=null&&t!=="parent"}function vn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function fg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function hg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function jh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function u1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function c1(t){return{...rg,...t||{}}}function qo(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=gn(t),h=hs({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y:v}=o?fs(h,r):h;return{xSnapped:p,ySnapped:v,...h}}const jc=t=>({width:t.offsetWidth,height:t.offsetHeight}),pg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},d1=["INPUT","SELECT","TEXTAREA"];function gg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:d1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const mg=t=>"clientX"in t,gn=(t,r)=>{var u,c;const o=mg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},bh=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...jc(c)}})};function yg({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=t*.125+a*.375+c*.375+o*.125,v=r*.125+u*.375+h*.375+s*.125,x=Math.abs(p-t),y=Math.abs(v-r);return[p,v,x,y]}function xl(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function Eh({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case ke.Left:return[r-xl(r-s,u),o];case ke.Right:return[r+xl(s-r,u),o];case ke.Top:return[r,o-xl(o-a,u)];case ke.Bottom:return[r,o+xl(a-o,u)]}}function vg({sourceX:t,sourceY:r,sourcePosition:o=ke.Bottom,targetX:s,targetY:a,targetPosition:u=ke.Top,curvature:c=.25}){const[h,p]=Eh({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[v,x]=Eh({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[y,m,_,k]=yg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:v,targetControlY:x});return[`M${t},${r} C${h},${p} ${v},${x} ${s},${a}`,y,m,_,k]}function xg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const p1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,g1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),m1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",mn.error006()),r;const s=o.getEdgeId||p1;let a;return sg(t)?a={...t}:a={...t,id:s(t)},g1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function wg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=xg({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,h]}const Ch={[ke.Left]:{x:-1,y:0},[ke.Right]:{x:1,y:0},[ke.Top]:{x:0,y:-1},[ke.Bottom]:{x:0,y:1}},y1=({source:t,sourcePosition:r=ke.Bottom,target:o})=>r===ke.Left||r===ke.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function v1({source:t,sourcePosition:r=ke.Bottom,target:o,targetPosition:s=ke.Top,center:a,offset:u,stepPosition:c}){const h=Ch[r],p=Ch[s],v={x:t.x+h.x*u,y:t.y+h.y*u},x={x:o.x+p.x*u,y:o.y+p.y*u},y=y1({source:v,sourcePosition:r,target:x}),m=y.x!==0?"x":"y",_=y[m];let k=[],b,E;const N={x:0,y:0},P={x:0,y:0},[,,w,j]=xg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[m]*p[m]===-1){m==="x"?(b=a.x??v.x+(x.x-v.x)*c,E=a.y??(v.y+x.y)/2):(b=a.x??(v.x+x.x)/2,E=a.y??v.y+(x.y-v.y)*c);const Y=[{x:b,y:v.y},{x:b,y:x.y}],Q=[{x:v.x,y:E},{x:x.x,y:E}];h[m]===_?k=m==="x"?Y:Q:k=m==="x"?Q:Y}else{const Y=[{x:v.x,y:x.y}],Q=[{x:x.x,y:v.y}];if(m==="x"?k=h.x===_?Q:Y:k=h.y===_?Y:Q,r===s){const C=Math.abs(t[m]-o[m]);if(C<=u){const V=Math.min(u-1,u-C);h[m]===_?N[m]=(v[m]>t[m]?-1:1)*V:P[m]=(x[m]>o[m]?-1:1)*V}}if(r!==s){const C=m==="x"?"y":"x",V=h[m]===p[C],W=v[C]>x[C],U=v[C]=q?(b=(ne.x+ee.x)/2,E=k[0].y):(b=k[0].x,E=(ne.y+ee.y)/2)}const $={x:v.x+N.x,y:v.y+N.y},D={x:x.x+P.x,y:x.y+P.y};return[[t,...$.x!==k[0].x||$.y!==k[0].y?[$]:[],...k,...D.x!==k[k.length-1].x||D.y!==k[k.length-1].y?[D]:[],o],b,E,w,j]}function x1(t,r,o,s){const a=Math.min(Mh(t,r)/2,Mh(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const v=t.xo.id===r):t[0])||null}function ac(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function _1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const v=ac(p,r);u.has(v)||(c.push({id:v,color:p.color||o,...p}),u.add(v))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const _g=1e3,S1=10,bc={nodeOrigin:[0,0],nodeExtent:ts,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},k1={...bc,checkEquality:!0};function Ec(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function N1(t,r,o){const s=Ec(bc,o);for(const a of t.values())if(a.parentId)Mc(a,t,r,s);else{const u=cs(a,s.nodeOrigin),c=pi(a.extent)?a.extent:s.nodeExtent,h=hi(u,c,vn(a));a.internals.positionAbsolute=h}}function j1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function Cc(t){return t==="manual"}function uc(t,r,o,s={}){var x,y;const a=Ec(k1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!Cc(a.zIndexMode)?_g:0;let p=t.length>0,v=!1;r.clear(),o.clear();for(const m of t){let _=c.get(m.id);if(a.checkEquality&&m===(_==null?void 0:_.internals.userNode))r.set(m.id,_);else{const k=cs(m,a.nodeOrigin),b=pi(m.extent)?m.extent:a.nodeExtent,E=hi(k,b,vn(m));_={...a.defaults,...m,measured:{width:(x=m.measured)==null?void 0:x.width,height:(y=m.measured)==null?void 0:y.height},internals:{positionAbsolute:E,handleBounds:j1(m,_),z:Sg(m,h,a.zIndexMode),userNode:m}},r.set(m.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),m.parentId&&Mc(_,r,o,s,u),v||(v=m.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:v}}function b1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function Mc(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=Ec(bc,s),v=t.parentId,x=r.get(v);if(!x){console.warn(`Parent node ${v} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}b1(t,o),a&&!x.parentId&&x.internals.rootParentIndex===void 0&&p==="auto"&&(x.internals.rootParentIndex=++a.i,x.internals.z=x.internals.z+a.i*S1),a&&x.internals.rootParentIndex!==void 0&&(a.i=x.internals.rootParentIndex);const y=u&&!Cc(p)?_g:0,{x:m,y:_,z:k}=E1(t,x,c,h,y,p),{positionAbsolute:b}=t.internals,E=m!==b.x||_!==b.y;(E||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:E?{x:m,y:_}:b,z:k}})}function Sg(t,r,o){const s=pn(t.zIndex)?t.zIndex:0;return Cc(o)?s:s+(t.selected?r:0)}function E1(t,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=vn(t),v=cs(t,o),x=pi(t.extent)?hi(v,t.extent,p):v;let y=hi({x:c+x.x,y:h+x.y},s,p);t.extent==="parent"&&(y=ag(y,p,r));const m=Sg(t,a,u),_=r.internals.z??0;return{x:y.x,y:y.y,z:_>=m?_+1:m}}function Pc(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const v=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??is(p),x=ug(v,h.rect);u.set(h.parentId,{expandedRect:x,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},v)=>{var w;const x=p.internals.positionAbsolute,y=vn(p),m=p.origin??s,_=h.x0||k>0||N||P)&&(a.push({id:v,type:"position",position:{x:p.position.x-_+N,y:p.position.y-k+P}}),(w=o.get(v))==null||w.forEach(j=>{t.some($=>$.id===j.id)||a.push({id:j.id,type:"position",position:{x:j.position.x+_,y:j.position.y+k}})})),(y.width0){const _=Pc(m,r,o,a);v.push(..._)}return{changes:v,updatedInternals:p}}async function M1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Th(t,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${t}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${t}-${u}`;const v=s.get(c)||new Map;s.set(c,v.set(o,r))}}function kg(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},v=`${a}-${c}--${u}-${h}`,x=`${u}-${h}--${a}-${c}`;Th("source",p,x,t,a,c),Th("target",p,v,t,u,h),r.set(s.id,s)}}function Ng(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:Ng(o,r):!1}function Lh(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function P1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!Ng(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function Ou({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[v,x]of r){const y=(c=o.get(v))==null?void 0:c.internals.userNode;y&&a.push({...y,position:x.position,dragging:s})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function I1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=fs(u,r);return{x:c.x-u.x,y:c.y-u.y}}function R1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,v={x:0,y:0},x=null,y=!1,m=null,_=!1,k=!1,b=null;function E({noDragClassName:P,handleSelector:w,domNode:j,isSelectable:$,nodeId:D,nodeClickDistance:B=0}){m=Yt(j);function Y({x:te,y:q}){const{nodeLookup:C,nodeExtent:V,snapGrid:W,snapToGrid:U,nodeOrigin:M,onNodeDrag:z,onSelectionDrag:F,onError:R,updateNodePositions:A}=r();u={x:te,y:q};let ie=!1;const oe=h.size>1,fe=oe&&V?sc(ds(h)):null,he=oe&&U?I1({dragItems:h,snapGrid:W,x:te,y:q}):null;for(const[pe,Z]of h){if(!C.has(pe))continue;let se={x:te-Z.distance.x,y:q-Z.distance.y};U&&(se=he?{x:Math.round(se.x+he.x),y:Math.round(se.y+he.y)}:fs(se,W));let me=null;if(oe&&V&&!Z.extent&&fe){const{positionAbsolute:re}=Z.internals,je=re.x-fe.x+V[0][0],Me=re.x+Z.measured.width-fe.x2+V[1][0],Re=re.y-fe.y+V[0][1],Ae=re.y+Z.measured.height-fe.y2+V[1][1];me=[[je,Re],[Me,Ae]]}const{position:Ne,positionAbsolute:ve}=lg({nodeId:pe,nextPosition:se,nodeLookup:C,nodeExtent:me||V,nodeOrigin:M,onError:R});ie=ie||Z.position.x!==Ne.x||Z.position.y!==Ne.y,Z.position=Ne,Z.internals.positionAbsolute=ve}if(k=k||ie,!!ie&&(A(h,!0),b&&(s||z||!D&&F))){const[pe,Z]=Ou({nodeId:D,dragItems:h,nodeLookup:C});s==null||s(b,h,pe,Z),z==null||z(b,pe,Z),D||F==null||F(b,Z)}}async function Q(){if(!x)return;const{transform:te,panBy:q,autoPanSpeed:C,autoPanOnNodeDrag:V}=r();if(!V){p=!1,cancelAnimationFrame(c);return}const[W,U]=kc(v,x,C);(W!==0||U!==0)&&(u.x=(u.x??0)-W/te[2],u.y=(u.y??0)-U/te[2],await q({x:W,y:U})&&Y(u)),c=requestAnimationFrame(Q)}function ne(te){var oe;const{nodeLookup:q,multiSelectionActive:C,nodesDraggable:V,transform:W,snapGrid:U,snapToGrid:M,selectNodesOnDrag:z,onNodeDragStart:F,onSelectionDragStart:R,unselectNodesAndEdges:A}=r();y=!0,(!z||!$)&&!C&&D&&((oe=q.get(D))!=null&&oe.selected||A()),$&&z&&D&&(t==null||t(D));const ie=qo(te.sourceEvent,{transform:W,snapGrid:U,snapToGrid:M,containerBounds:x});if(u=ie,h=P1(q,V,ie,D),h.size>0&&(o||F||!D&&R)){const[fe,he]=Ou({nodeId:D,dragItems:h,nodeLookup:q});o==null||o(te.sourceEvent,h,fe,he),F==null||F(te.sourceEvent,fe,he),D||R==null||R(te.sourceEvent,he)}}const ee=Fp().clickDistance(B).on("start",te=>{const{domNode:q,nodeDragThreshold:C,transform:V,snapGrid:W,snapToGrid:U}=r();x=(q==null?void 0:q.getBoundingClientRect())||null,_=!1,k=!1,b=te.sourceEvent,C===0&&ne(te),u=qo(te.sourceEvent,{transform:V,snapGrid:W,snapToGrid:U,containerBounds:x}),v=gn(te.sourceEvent,x)}).on("drag",te=>{const{autoPanOnNodeDrag:q,transform:C,snapGrid:V,snapToGrid:W,nodeDragThreshold:U,nodeLookup:M}=r(),z=qo(te.sourceEvent,{transform:C,snapGrid:V,snapToGrid:W,containerBounds:x});if(b=te.sourceEvent,(te.sourceEvent.type==="touchmove"&&te.sourceEvent.touches.length>1||D&&!M.has(D))&&(_=!0),!_){if(!p&&q&&y&&(p=!0,Q()),!y){const F=gn(te.sourceEvent,x),R=F.x-v.x,A=F.y-v.y;Math.sqrt(R*R+A*A)>U&&ne(te)}(u.x!==z.xSnapped||u.y!==z.ySnapped)&&h&&y&&(v=gn(te.sourceEvent,x),Y(z))}}).on("end",te=>{if(!y||_){_&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,y=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:q,updateNodePositions:C,onNodeDragStop:V,onSelectionDragStop:W}=r();if(k&&(C(h,!1),k=!1),a||V||!D&&W){const[U,M]=Ou({nodeId:D,dragItems:h,nodeLookup:q,dragging:!1});a==null||a(te.sourceEvent,h,U,M),V==null||V(te.sourceEvent,U,M),D||W==null||W(te.sourceEvent,M)}}}).filter(te=>{const q=te.target;return!te.button&&(!P||!Lh(q,`.${P}`,j))&&(!w||Lh(q,w,j))});m.call(ee)}function N(){m==null||m.on(".drag",null)}return{update:E,destroy:N}}function T1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())Dl(a,is(u))>0&&s.push(u);return s}const L1=250;function A1(t,r,o,s){var h,p;let a=[],u=1/0;const c=T1(t,o,r+L1);for(const v of c){const x=[...((h=v.internals.handleBounds)==null?void 0:h.source)??[],...((p=v.internals.handleBounds)==null?void 0:p.target)??[]];for(const y of x){if(s.nodeId===y.nodeId&&s.type===y.type&&s.id===y.id)continue;const{x:m,y:_}=gi(v,y,y.position,!0),k=Math.sqrt(Math.pow(m-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const v=s.type==="source"?"target":"source";return a.find(x=>x.type===v)??a[0]}return a[0]}function jg(t,r,o,s,a,u=!1){var v,x,y;const c=s.get(t);if(!c)return null;const h=a==="strict"?(v=c.internals.handleBounds)==null?void 0:v[r]:[...((x=c.internals.handleBounds)==null?void 0:x.source)??[],...((y=c.internals.handleBounds)==null?void 0:y.target)??[]],p=(o?h==null?void 0:h.find(m=>m.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...gi(c,p,p.position,!0)}:p}function bg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function $1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const Eg=()=>!0;function z1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:v,autoPanOnConnect:x,flowId:y,panBy:m,cancelConnection:_,onConnectStart:k,onConnect:b,onConnectEnd:E,isValidConnection:N=Eg,onReconnectEnd:P,updateConnection:w,getTransform:j,getFromHandle:$,autoPanSpeed:D,dragThreshold:B=1,handleDomNode:Y}){const Q=pg(t.target);let ne=0,ee;const{x:te,y:q}=gn(t),C=bg(u,Y),V=h==null?void 0:h.getBoundingClientRect();let W=!1;if(!V||!C)return;const U=jg(a,C,s,p,r);if(!U)return;let M=gn(t,V),z=!1,F=null,R=!1,A=null;function ie(){if(!x||!V)return;const[Ne,ve]=kc(M,V,D);m({x:Ne,y:ve}),ne=requestAnimationFrame(ie)}const oe={...U,nodeId:a,type:C,position:U.position},fe=p.get(a);let pe={inProgress:!0,isValid:null,from:gi(fe,oe,ke.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:fe,to:M,toHandle:null,toPosition:Sh[oe.position],toNode:null,pointer:M};function Z(){W=!0,w(pe),k==null||k(t,{nodeId:a,handleId:s,handleType:C})}B===0&&Z();function se(Ne){if(!W){const{x:Ae,y:st}=gn(Ne),lt=Ae-te,at=st-q;if(!(lt*lt+at*at>B*B))return;Z()}if(!$()||!oe){me(Ne);return}const ve=j();M=gn(Ne,V),ee=A1(hs(M,ve,!1,[1,1]),o,p,oe),z||(ie(),z=!0);const re=Cg(Ne,{handle:ee,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:N,doc:Q,lib:v,flowId:y,nodeLookup:p});A=re.handleDomNode,F=re.connection,R=$1(!!ee,re.isValid);const je=p.get(a),Me=je?gi(je,oe,ke.Left,!0):pe.from,Re={...pe,from:Me,isValid:R,to:re.toHandle&&R?Ji({x:re.toHandle.x,y:re.toHandle.y},ve):M,toHandle:re.toHandle,toPosition:R&&re.toHandle?re.toHandle.position:Sh[oe.position],toNode:re.toHandle?p.get(re.toHandle.nodeId):null,pointer:M};w(Re),pe=Re}function me(Ne){if(!("touches"in Ne&&Ne.touches.length>0)){if(W){(ee||A)&&F&&R&&(b==null||b(F));const{inProgress:ve,...re}=pe,je={...re,toPosition:pe.toHandle?pe.toPosition:null};E==null||E(Ne,je),u&&(P==null||P(Ne,je))}_(),cancelAnimationFrame(ne),z=!1,R=!1,F=null,A=null,Q.removeEventListener("mousemove",se),Q.removeEventListener("mouseup",me),Q.removeEventListener("touchmove",se),Q.removeEventListener("touchend",me)}}Q.addEventListener("mousemove",se),Q.addEventListener("mouseup",me),Q.addEventListener("touchmove",se),Q.addEventListener("touchend",me)}function Cg(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:v=Eg,nodeLookup:x}){const y=u==="target",m=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=gn(t),b=c.elementFromPoint(_,k),E=b!=null&&b.classList.contains(`${h}-flow__handle`)?b:m,N={handleDomNode:E,isValid:!1,connection:null,toHandle:null};if(E){const P=bg(void 0,E),w=E.getAttribute("data-nodeid"),j=E.getAttribute("data-handleid"),$=E.classList.contains("connectable"),D=E.classList.contains("connectableend");if(!w||!P)return N;const B={source:y?w:s,sourceHandle:y?j:a,target:y?s:w,targetHandle:y?a:j};N.connection=B;const Q=$&&D&&(o===Qi.Strict?y&&P==="source"||!y&&P==="target":w!==s||j!==a);N.isValid=Q&&v(B),N.toHandle=jg(w,P,j,x,o,!0)}return N}const cc={onPointerDown:z1,isValid:Cg};function D1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Yt(t);function u({translateExtent:h,width:p,height:v,zoomStep:x=1,pannable:y=!0,zoomable:m=!0,inversePan:_=!1}){const k=w=>{if(w.sourceEvent.type!=="wheel"||!r)return;const j=o(),$=w.sourceEvent.ctrlKey&&os()?10:1,D=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*x,B=j[2]*Math.pow(2,D*$);r.scaleTo(B)};let b=[0,0];const E=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(b=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},N=w=>{const j=o();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!r)return;const $=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],D=[$[0]-b[0],$[1]-b[1]];b=$;const B=s()*Math.max(j[2],Math.log(j[2]))*(_?-1:1),Y={x:j[0]-D[0]*B,y:j[1]-D[1]*B},Q=[[0,0],[p,v]];r.setViewportConstrained({x:Y.x,y:Y.y,zoom:j[2]},Q,h)},P=tg().on("start",E).on("zoom",y?N:null).on("zoom.wheel",m?k:null);a.call(P,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:fn}}const Xl=t=>({x:t.x,y:t.y,zoom:t.k}),Fu=({x:t,y:r,zoom:o})=>Ul.translate(t,r).scale(o),Rr=(t,r)=>t.target.closest(`.${r}`),Mg=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),O1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Hu=(t,r=0,o=O1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Pg=t=>{const r=t.ctrlKey&&os()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function F1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:v}){return x=>{if(Rr(x,r))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const y=o.property("__zoom").k||1;if(x.ctrlKey&&c){const E=fn(x),N=Pg(x),P=y*Math.pow(2,N);s.scaleTo(o,P,E,x);return}const m=x.deltaMode===1?20:1;let _=a===ci.Vertical?0:x.deltaX*m,k=a===ci.Horizontal?0:x.deltaY*m;!os()&&x.shiftKey&&a!==ci.Vertical&&(_=x.deltaY*m,k=0),s.translateBy(o,-(_/y)*u,-(k/y)*u,{internal:!0});const b=Xl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(x,b):(t.isPanScrolling=!0,h==null||h(x,b)),t.panScrollTimeout=setTimeout(()=>{v==null||v(x,b),t.isPanScrolling=!1},150)}}function H1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=Rr(s,t);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function B1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=Xl(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function V1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;t.usedRightMouseButton=!!(o&&Mg(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,Xl(u.transform)))}}function W1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&Mg(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const p=Xl(c.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function U1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:v,lib:x,connectionInProgress:y}){return m=>{var N;const _=r||o,k=s&&m.ctrlKey,b=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(Rr(m,`${x}-flow__node`)||Rr(m,`${x}-flow__edge`)||Rr(m,`${x}-flow__selection`)||Rr(m,`${x}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!c&&!s||h||y&&!b||Rr(m,p)&&b||Rr(m,v)&&(!b||u&&b&&!r)||!s&&m.ctrlKey&&b)return!1;if(!s&&m.type==="touchstart"&&((N=m.touches)==null?void 0:N.length)>1)return m.preventDefault(),!1;if(!_&&!u&&!k&&b||!a&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(a)&&!a.includes(m.button)&&m.type==="mousedown")return!1;const E=Array.isArray(a)&&a.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||b||t)&&E}}function G1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const v={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=t.getBoundingClientRect();let y=[[0,0],[x.width,x.height]];const m=typeof ResizeObserver<"u"?new ResizeObserver(q=>{const C=q[0];C&&(y=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;m==null||m.observe(t);const _=tg().extent(()=>y).scaleExtent([r,o]).translateExtent(s),k=Yt(t).call(_);j({x:a.x,y:a.y,zoom:Zi(a.zoom,r,o)},[[0,0],[x.width,x.height]],s);const b=k.on("wheel.zoom"),E=k.on("dblclick.zoom");_.wheelDelta(Pg);async function N(q,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Xo:bl).transform(Hu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),q)}):!1}function P({noWheelClassName:q,noPanClassName:C,onPaneContextMenu:V,userSelectionActive:W,panOnScroll:U,panOnDrag:M,panOnScrollMode:z,panOnScrollSpeed:F,preventScrolling:R,zoomOnPinch:A,zoomOnScroll:ie,zoomOnDoubleClick:oe,panActivationKeyPressed:fe=!1,zoomActivationKeyPressed:he,lib:pe,onTransformChange:Z,connectionInProgress:se,paneClickDistance:me,selectionOnDrag:Ne}){W&&!v.isZoomingOrPanning&&w();const ve=U&&!he&&!W;_.clickDistance(Ne?1/0:!pn(me)||me<0?0:me);const re=ve?F1({zoomPanValues:v,noWheelClassName:q,d3Selection:k,d3Zoom:_,panOnScrollMode:z,panOnScrollSpeed:F,zoomOnPinch:A,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):H1({noWheelClassName:q,preventScrolling:R,d3ZoomHandler:b});k.on("wheel.zoom",re,{passive:!1});const je=B1({zoomPanValues:v,onDraggingChange:p,onPanZoomStart:c});_.on("start",je);const Me=V1({zoomPanValues:v,panOnDrag:M,onPaneContextMenu:!!V,onPanZoom:u,onTransformChange:Z});_.on("zoom",Me);const Re=W1({zoomPanValues:v,panOnDrag:M,panOnScroll:U,onPaneContextMenu:V,onPanZoomEnd:h,onDraggingChange:p});_.on("end",Re);const Ae=U1({panActivationKeyPressed:fe,zoomActivationKeyPressed:he,panOnDrag:M,zoomOnScroll:ie,panOnScroll:U,zoomOnDoubleClick:oe,zoomOnPinch:A,userSelectionActive:W,noPanClassName:C,noWheelClassName:q,lib:pe,connectionInProgress:se});_.filter(Ae),oe?k.on("dblclick.zoom",E):k.on("dblclick.zoom",null)}function w(){_.on("zoom",null)}async function j(q,C,V){const W=Fu(q),U=_==null?void 0:_.constrain()(W,C,V);return U&&await N(U),U}async function $(q,C){const V=Fu(q);return await N(V,C),V}function D(q){if(k){const C=Fu(q),V=k.property("__zoom");(V.k!==q.zoom||V.x!==q.x||V.y!==q.y)&&(_==null||_.transform(k,C,null,{sync:!0}))}}function B(){const q=k?eg(k.node()):{x:0,y:0,k:1};return{x:q.x,y:q.y,zoom:q.k}}async function Y(q,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Xo:bl).scaleTo(Hu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),q)}):!1}async function Q(q,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Xo:bl).scaleBy(Hu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),q)}):!1}function ne(q){_==null||_.scaleExtent(q)}function ee(q){_==null||_.translateExtent(q)}function te(q){const C=!pn(q)||q<0?0:q;_==null||_.clickDistance(C)}return{update:P,destroy:w,setViewport:$,setViewportConstrained:j,getViewport:B,scaleTo:Y,scaleBy:Q,setScaleExtent:ne,setTranslateExtent:ee,syncViewport:D,setClickDistance:te}}var eo;(function(t){t.Line="line",t.Handle="handle"})(eo||(eo={}));function Y1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function Ah(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function Pr(t,r){return Math.max(0,r-t)}function Ir(t,r){return Math.max(0,t-r)}function wl(t,r,o){return Math.max(0,r-t,t-o)}function $h(t,r){return t?!r:r}function X1(t,r,o,s,a,u,c,h){let{affectsX:p,affectsY:v}=r;const{isHorizontal:x,isVertical:y}=r,m=x&&y,{xSnapped:_,ySnapped:k}=o,{minWidth:b,maxWidth:E,minHeight:N,maxHeight:P}=s,{x:w,y:j,width:$,height:D,aspectRatio:B}=t;let Y=Math.floor(x?_-t.pointerX:0),Q=Math.floor(y?k-t.pointerY:0);const ne=$+(p?-Y:Y),ee=D+(v?-Q:Q),te=-u[0]*$,q=-u[1]*D;let C=wl(ne,b,E),V=wl(ee,N,P);if(c){let M=0,z=0;p&&Y<0?M=Pr(w+Y+te,c[0][0]):!p&&Y>0&&(M=Ir(w+ne+te,c[1][0])),v&&Q<0?z=Pr(j+Q+q,c[0][1]):!v&&Q>0&&(z=Ir(j+ee+q,c[1][1])),C=Math.max(C,M),V=Math.max(V,z)}if(h){let M=0,z=0;p&&Y>0?M=Ir(w+Y,h[0][0]):!p&&Y<0&&(M=Pr(w+ne,h[1][0])),v&&Q>0?z=Ir(j+Q,h[0][1]):!v&&Q<0&&(z=Pr(j+ee,h[1][1])),C=Math.max(C,M),V=Math.max(V,z)}if(a){if(x){const M=wl(ne/B,N,P)*B;if(C=Math.max(C,M),c){let z=0;!p&&!v||p&&!v&&m?z=Ir(j+q+ne/B,c[1][1])*B:z=Pr(j+q+(p?Y:-Y)/B,c[0][1])*B,C=Math.max(C,z)}if(h){let z=0;!p&&!v||p&&!v&&m?z=Pr(j+ne/B,h[1][1])*B:z=Ir(j+(p?Y:-Y)/B,h[0][1])*B,C=Math.max(C,z)}}if(y){const M=wl(ee*B,b,E)/B;if(V=Math.max(V,M),c){let z=0;!p&&!v||v&&!p&&m?z=Ir(w+ee*B+te,c[1][0])/B:z=Pr(w+(v?Q:-Q)*B+te,c[0][0])/B,V=Math.max(V,z)}if(h){let z=0;!p&&!v||v&&!p&&m?z=Pr(w+ee*B,h[1][0])/B:z=Ir(w+(v?Q:-Q)*B,h[0][0])/B,V=Math.max(V,z)}}}Q=Q+(Q<0?V:-V),Y=Y+(Y<0?C:-C),a&&(m?ne>ee*B?Q=($h(p,v)?-Y:Y)/B:Y=($h(p,v)?-Q:Q)*B:x?(Q=Y/B,v=p):(Y=Q*B,p=v));const W=p?w+Y:w,U=v?j+Q:j;return{width:$+(p?-Y:Y),height:D+(v?-Q:Q),x:u[0]*Y*(p?-1:1)+W,y:u[1]*Q*(v?-1:1)+U}}const Ig={width:0,height:0,x:0,y:0},q1={...Ig,pointerX:0,pointerY:0,aspectRatio:1};function K1(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function Q1({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Yt(t);let c={controlDirection:Ah("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:v,boundaries:x,keepAspectRatio:y,resizeDirection:m,onResizeStart:_,onResize:k,onResizeEnd:b,shouldResize:E}){let N={...Ig},P={...q1};c={boundaries:x,resizeDirection:m,keepAspectRatio:y,controlDirection:Ah(v)};let w,j=null,$=[],D,B,Y,Q=!1;const ne=Fp().on("start",ee=>{const{nodeLookup:te,transform:q,snapGrid:C,snapToGrid:V,nodeOrigin:W,paneDomNode:U}=o();if(w=te.get(r),!w)return;j=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:z}=qo(ee.sourceEvent,{transform:q,snapGrid:C,snapToGrid:V,containerBounds:j});N={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},P={...N,pointerX:M,pointerY:z,aspectRatio:N.width/N.height},D=void 0,B=pi(w.extent)?w.extent:void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&(D=te.get(w.parentId)),D&&w.extent==="parent"&&(B=[[0,0],[D.measured.width,D.measured.height]]),$=[],Y=void 0;for(const[F,R]of te)if(R.parentId===r&&($.push({id:F,position:{...R.position},extent:R.extent}),R.extent==="parent"||R.expandParent)){const A=K1(R,w,R.origin??W);Y?Y=[[Math.min(A[0][0],Y[0][0]),Math.min(A[0][1],Y[0][1])],[Math.max(A[1][0],Y[1][0]),Math.max(A[1][1],Y[1][1])]]:Y=A}_==null||_(ee,{...N})}).on("drag",ee=>{const{transform:te,snapGrid:q,snapToGrid:C,nodeOrigin:V}=o(),W=qo(ee.sourceEvent,{transform:te,snapGrid:q,snapToGrid:C,containerBounds:j}),U=[];if(!w)return;const{x:M,y:z,width:F,height:R}=N,A={},ie=w.origin??V,{width:oe,height:fe,x:he,y:pe}=X1(P,c.controlDirection,W,c.boundaries,c.keepAspectRatio,ie,B,Y),Z=oe!==F,se=fe!==R,me=he!==M&&Z,Ne=pe!==z&&se;if(!me&&!Ne&&!Z&&!se)return;if((me||Ne||ie[0]===1||ie[1]===1)&&(A.x=me?he:N.x,A.y=Ne?pe:N.y,N.x=A.x,N.y=A.y,$.length>0)){const Me=he-M,Re=pe-z;for(const Ae of $)Ae.position={x:Ae.position.x-Me+ie[0]*(oe-F),y:Ae.position.y-Re+ie[1]*(fe-R)},U.push(Ae)}if((Z||se)&&(A.width=Z&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:N.width,A.height=se&&(!c.resizeDirection||c.resizeDirection==="vertical")?fe:N.height,N.width=A.width,N.height=A.height),D&&w.expandParent){const Me=ie[0]*(A.width??0);A.x&&A.x{Q&&(b==null||b(ee,{...N}),a==null||a({...N}),Q=!1)});u.call(ne)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Bu={exports:{}},Vu={},Wu={exports:{}},Uu={};/** + * @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 zh;function Z1(){if(zh)return Uu;zh=1;var t=ls();function r(y,m){return y===m&&(y!==0||1/y===1/m)||y!==y&&m!==m}var o=typeof Object.is=="function"?Object.is:r,s=t.useState,a=t.useEffect,u=t.useLayoutEffect,c=t.useDebugValue;function h(y,m){var _=m(),k=s({inst:{value:_,getSnapshot:m}}),b=k[0].inst,E=k[1];return u(function(){b.value=_,b.getSnapshot=m,p(b)&&E({inst:b})},[y,_,m]),a(function(){return p(b)&&E({inst:b}),y(function(){p(b)&&E({inst:b})})},[y]),c(_),_}function p(y){var m=y.getSnapshot;y=y.value;try{var _=m();return!o(y,_)}catch{return!0}}function v(y,m){return m()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?v:h;return Uu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:x,Uu}var Dh;function J1(){return Dh||(Dh=1,Wu.exports=Z1()),Wu.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 Oh;function e_(){if(Oh)return Vu;Oh=1;var t=ls(),r=J1();function o(v,x){return v===x&&(v!==0||1/v===1/x)||v!==v&&x!==x}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Vu.useSyncExternalStoreWithSelector=function(v,x,y,m,_){var k=u(null);if(k.current===null){var b={hasValue:!1,value:null};k.current=b}else b=k.current;k=h(function(){function N(D){if(!P){if(P=!0,w=D,D=m(D),_!==void 0&&b.hasValue){var B=b.value;if(_(B,D))return j=B}return j=D}if(B=j,s(w,D))return B;var Y=m(D);return _!==void 0&&_(B,Y)?(w=D,B):(w=D,j=Y)}var P=!1,w,j,$=y===void 0?null:y;return[function(){return N(x())},$===null?void 0:function(){return N($())}]},[x,y,m,_]);var E=a(v,k[0],k[1]);return c(function(){b.hasValue=!0,b.value=E},[E]),p(E),E},Vu}var Fh;function t_(){return Fh||(Fh=1,Bu.exports=e_()),Bu.exports}var n_=t_();const r_=Sp(n_),i_={},Hh=t=>{let r;const o=new Set,s=(x,y)=>{const m=typeof x=="function"?x(r):x;if(!Object.is(m,r)){const _=r;r=y??(typeof m!="object"||m===null)?m:Object.assign({},r,m),o.forEach(k=>k(r,_))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>v,subscribe:x=>(o.add(x),()=>o.delete(x)),destroy:()=>{(i_?"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."),o.clear()}},v=r=t(s,a,p);return p},o_=t=>t?Hh(t):Hh,{useDebugValue:s_}=t0,{useSyncExternalStoreWithSelector:l_}=r_,a_=t=>t;function Rg(t,r=a_,o){const s=l_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return s_(s),s}const Bh=(t,r)=>{const o=o_(t),s=(a,u=r)=>Rg(o,a,u);return Object.assign(s,o),s},u_=(t,r)=>t?Bh(t,r):Bh;function Qe(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}kp();const ql=L.createContext(null),c_=ql.Provider,Tg=mn.error001("react");function ze(t,r){const o=L.useContext(ql);if(o===null)throw new Error(Tg);return Rg(o,t,r)}function Ge(){const t=L.useContext(ql);if(t===null)throw new Error(Tg);return L.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Vh={display:"none"},d_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Lg="react-flow__node-desc",Ag="react-flow__edge-desc",f_="react-flow__aria-live",h_=t=>t.ariaLiveMessage,p_=t=>t.ariaLabelConfig;function g_({rfId:t}){const r=ze(h_);return d.jsx("div",{id:`${f_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:d_,children:r})}function m_({rfId:t,disableKeyboardA11y:r}){const o=ze(p_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${Lg}-${t}`,style:Vh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${Ag}-${t}`,style:Vh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(g_,{rfId:t})]})}const Kl=L.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return d.jsx("div",{className:nt(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});Kl.displayName="Panel";const Wh="https://reactflow.dev?utm_source=attribution";function y_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:d.jsx(Kl,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Wh}`,children:d.jsx("a",{href:Wh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const v_=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},_l=t=>t.id;function x_(t,r){return Qe(t.selectedNodes.map(_l),r.selectedNodes.map(_l))&&Qe(t.selectedEdges.map(_l),r.selectedEdges.map(_l))}function w_({onSelectionChange:t}){const r=Ge(),{selectedNodes:o,selectedEdges:s}=ze(v_,x_);return L.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const __=t=>!!t.onSelectionChangeHandlers;function S_({onSelectionChange:t}){const r=ze(__);return t||r?d.jsx(w_,{onSelectionChange:t}):null}const $g=[0,0],k_={x:0,y:0,zoom:1},N_=["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"],Uh=[...N_,"rfId"],j_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Gh={translateExtent:ts,nodeOrigin:$g,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function b_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=ze(j_,Qe),v=Ge();L.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{x.current=Gh,h()}),[]);const x=L.useRef(Gh);return L.useEffect(()=>{for(const y of Uh){const m=t[y],_=x.current[y];m!==_&&(typeof t[y]>"u"||(y==="nodes"?r(m):y==="edges"?o(m):y==="minZoom"?s(m):y==="maxZoom"?a(m):y==="translateExtent"?u(m):y==="nodeExtent"?c(m):y==="ariaLabelConfig"?v.setState({ariaLabelConfig:c1(m)}):y==="fitView"?v.setState({fitViewQueued:m}):y==="fitViewOptions"?v.setState({fitViewOptions:m}):v.setState({[y]:m})))}x.current=t},Uh.map(y=>t[y])),null}function Yh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function E_(t){var s;const[r,o]=L.useState(t==="system"?null:t);return L.useEffect(()=>{if(t!=="system"){o(t);return}const a=Yh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=Yh())!=null&&s.matches?"dark":"light"}const Xh=typeof document<"u"?document:null;function ss(t=null,r={target:Xh,actInsideInputWithModifier:!0}){const[o,s]=L.useState(!1),a=L.useRef(!1),u=L.useRef(new Set([])),[c,h]=L.useMemo(()=>{if(t!==null){const v=(Array.isArray(t)?t:[t]).filter(y=>typeof y=="string").map(y=>y.replace(/\+/g,` +`).replace(` + +`,` ++`).split(` +`)),x=v.reduce((y,m)=>y.concat(...m),[]);return[v,x]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Xh,v=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const x=_=>{var E,N;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!v)&&gg(_))return!1;const b=Kh(_.code,h);if(u.current.add(_[b]),qh(c,u.current,!1)){const P=((N=(E=_.composedPath)==null?void 0:E.call(_))==null?void 0:N[0])||_.target,w=(P==null?void 0:P.nodeName)==="BUTTON"||(P==null?void 0:P.nodeName)==="A";r.preventDefault!==!1&&(a.current||!w)&&_.preventDefault(),s(!0)}},y=_=>{const k=Kh(_.code,h);qh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},m=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",x),p==null||p.addEventListener("keyup",y),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{p==null||p.removeEventListener("keydown",x),p==null||p.removeEventListener("keyup",y),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,s]),o}function qh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Kh(t,r){return r.includes(t)?"code":"key"}const C_=()=>{const t=Ge();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=Nc(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),v={x:r.x-h,y:r.y-p},x=o.snapGrid??a,y=o.snapToGrid??u;return hs(v,s,y,x)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=Ji(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function zg(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)M_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function M_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function P_(t,r){return zg(t,r)}function I_(t,r){return zg(t,r)}function li(t,r){return{id:t,type:"select",selected:r}}function Gi(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(li(u.id,c)))}return s}function Qh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Zh(t){return{id:t.id,type:"remove"}}const R_=dg();function T_(t,r,o={}){return m1(t,r,{...o,onError:o.onError??R_})}const Jh=t=>t1(t),L_=t=>sg(t);function Dg(t){return L.forwardRef(t)}const Og=typeof window<"u"?L.useLayoutEffect:L.useEffect;function ep(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>A_(()=>o(a=>a+BigInt(1))));return Og(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function A_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Fg=L.createContext(null);function $_({children:t}){const r=Ge(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:v,hasDefaultNodes:x,onNodesChange:y,nodeLookup:m,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let b=p;for(const N of h)b=typeof N=="function"?N(b):N;let E=Qh({items:b,lookup:m});for(const N of k.values())E=N(E);x&&v(b),E.length>0?y==null||y(E):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:N,nodes:P,setNodes:w}=r.getState();N&&w(P)})},[]),s=ep(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:v,hasDefaultEdges:x,onEdgesChange:y,edgeLookup:m}=r.getState();let _=p;for(const k of h)_=typeof k=="function"?k(_):k;x?v(_):y&&y(Qh({items:_,lookup:m}))},[]),u=ep(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Fg.Provider,{value:c,children:t})}function z_(){const t=L.useContext(Fg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const D_=t=>!!t.panZoom;function Ql(){const t=C_(),r=Ge(),o=z_(),s=ze(D_),a=L.useMemo(()=>{const u=y=>r.getState().nodeLookup.get(y),c=y=>{o.nodeQueue.push(y)},h=y=>{o.edgeQueue.push(y)},p=y=>{var N,P;const{nodeLookup:m,nodeOrigin:_}=r.getState(),k=Jh(y)?y:m.get(y.id),b=k.parentId?hg(k.position,k.measured,k.parentId,m,_):k.position,E={...k,position:b,width:((N=k.measured)==null?void 0:N.width)??k.width,height:((P=k.measured)==null?void 0:P.height)??k.height};return is(E)},v=(y,m,_={replace:!1})=>{c(k=>k.map(b=>{if(b.id===y){const E=typeof m=="function"?m(b):m;return _.replace&&Jh(E)?E:{...b,...E}}return b}))},x=(y,m,_={replace:!1})=>{h(k=>k.map(b=>{if(b.id===y){const E=typeof m=="function"?m(b):m;return _.replace&&L_(E)?E:{...b,...E}}return b}))};return{getNodes:()=>r.getState().nodes.map(y=>({...y})),getNode:y=>{var m;return(m=u(y))==null?void 0:m.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:y=[]}=r.getState();return y.map(m=>({...m}))},getEdge:y=>r.getState().edgeLookup.get(y),setNodes:c,setEdges:h,addNodes:y=>{const m=Array.isArray(y)?y:[y];o.nodeQueue.push(_=>[..._,...m])},addEdges:y=>{const m=Array.isArray(y)?y:[y];o.edgeQueue.push(_=>[..._,...m])},toObject:()=>{const{nodes:y=[],edges:m=[],transform:_}=r.getState(),[k,b,E]=_;return{nodes:y.map(N=>({...N})),edges:m.map(N=>({...N})),viewport:{x:k,y:b,zoom:E}}},deleteElements:async({nodes:y=[],edges:m=[]})=>{const{nodes:_,edges:k,onNodesDelete:b,onEdgesDelete:E,triggerNodeChanges:N,triggerEdgeChanges:P,onDelete:w,onBeforeDelete:j}=r.getState(),{nodes:$,edges:D}=await s1({nodesToRemove:y,edgesToRemove:m,nodes:_,edges:k,onBeforeDelete:j}),B=D.length>0,Y=$.length>0;if(B){const Q=D.map(Zh);E==null||E(D),P(Q)}if(Y){const Q=$.map(Zh);b==null||b($),N(Q)}return(Y||B)&&(w==null||w({nodes:$,edges:D})),{deletedNodes:$,deletedEdges:D}},getIntersectingNodes:(y,m=!0,_)=>{const k=Nh(y),b=k?y:p(y),E=_!==void 0;return b?(_||r.getState().nodes).filter(N=>{const P=r.getState().nodeLookup.get(N.id);if(P&&!k&&(N.id===y.id||!P.internals.positionAbsolute))return!1;const w=is(E?N:P),j=Dl(w,b);return m&&j>0||j>=w.width*w.height||j>=b.width*b.height}):[]},isNodeIntersecting:(y,m,_=!0)=>{const b=Nh(y)?y:p(y);if(!b)return!1;const E=Dl(b,m);return _&&E>0||E>=m.width*m.height||E>=b.width*b.height},updateNode:v,updateNodeData:(y,m,_={replace:!1})=>{v(y,k=>{const b=typeof m=="function"?m(k):m;return _.replace?{...k,data:b}:{...k,data:{...k.data,...b}}},_)},updateEdge:x,updateEdgeData:(y,m,_={replace:!1})=>{x(y,k=>{const b=typeof m=="function"?m(k):m;return _.replace?{...k,data:b}:{...k,data:{...k.data,...b}}},_)},getNodesBounds:y=>{const{nodeLookup:m,nodeOrigin:_}=r.getState();return n1(y,{nodeLookup:m,nodeOrigin:_})},getHandleConnections:({type:y,id:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${y}${m?`-${m}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:y,handleId:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${y?m?`-${y}-${m}`:`-${y}`:""}`))==null?void 0:k.values())??[])},fitView:async y=>{const m=r.getState().fitViewResolver??u1();return r.setState({fitViewQueued:!0,fitViewOptions:y,fitViewResolver:m}),o.nodeQueue.push(_=>[..._]),m.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const tp=t=>t.selected,O_=typeof window<"u"?window:void 0;function F_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ge(),{deleteElements:s}=Ql(),a=ss(t,{actInsideInputWithModifier:!1}),u=ss(r,{target:O_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(tp),edges:c.filter(tp)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function H_(t){const r=Ge();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=jc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",mn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const Zl={position:"absolute",width:"100%",height:"100%",top:0,left:0},B_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function V_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=ci.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:v,translateExtent:x,minZoom:y,maxZoom:m,zoomActivationKeyCode:_,preventScrolling:k=!0,children:b,noWheelClassName:E,noPanClassName:N,onViewportChange:P,isControlledViewport:w,paneClickDistance:j,selectionOnDrag:$}){const D=Ge(),B=L.useRef(null),{userSelectionActive:Y,lib:Q,connectionInProgress:ne}=ze(B_,Qe),ee=ss(_),te=L.useRef();H_(B);const q=L.useCallback(C=>{P==null||P({x:C[0],y:C[1],zoom:C[2]}),w||D.setState({transform:C})},[P,w]);return L.useEffect(()=>{if(B.current){te.current=G1({domNode:B.current,minZoom:y,maxZoom:m,translateExtent:x,viewport:v,onDraggingChange:U=>D.setState(M=>M.paneDragging===U?M:{paneDragging:U}),onPanZoomStart:(U,M)=>{const{onViewportChangeStart:z,onMoveStart:F}=D.getState();F==null||F(U,M),z==null||z(M)},onPanZoom:(U,M)=>{const{onViewportChange:z,onMove:F}=D.getState();F==null||F(U,M),z==null||z(M)},onPanZoomEnd:(U,M)=>{const{onViewportChangeEnd:z,onMoveEnd:F}=D.getState();F==null||F(U,M),z==null||z(M)}});const{x:C,y:V,zoom:W}=te.current.getViewport();return D.setState({panZoom:te.current,transform:[C,V,W],domNode:B.current.closest(".react-flow")}),()=>{var U;(U=te.current)==null||U.destroy()}}},[]),L.useEffect(()=>{var C;(C=te.current)==null||C.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:ee,preventScrolling:k,noPanClassName:N,userSelectionActive:Y,noWheelClassName:E,lib:Q,onTransformChange:q,connectionInProgress:ne,selectionOnDrag:$,paneClickDistance:j})},[t,r,o,s,a,u,c,h,p,ee,k,N,Y,E,Q,q,ne,$,j]),d.jsx("div",{className:"react-flow__renderer",ref:B,style:Zl,children:b})}const W_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function U_(){const{userSelectionActive:t,userSelectionRect:r}=ze(W_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const Gu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},G_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function Y_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=ns.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:v,onPaneContextMenu:x,onPaneScroll:y,onPaneMouseEnter:m,onPaneMouseMove:_,onPaneMouseLeave:k,children:b}){const E=L.useRef(0),N=Ge(),{userSelectionActive:P,elementsSelectable:w,dragging:j,panBy:$,autoPanSpeed:D}=ze(G_,Qe),B=w&&(t||P),Y=L.useRef(null),Q=L.useRef(),ne=L.useRef(new Set),ee=L.useRef(new Set),te=L.useRef(!1),q=L.useRef(!1),C=L.useRef({x:0,y:0}),V=L.useRef(!1),W=Z=>{if(q.current||te.current||N.getState().connection.inProgress){q.current=!1,te.current=!1;return}v==null||v(Z),N.getState().resetSelectedElements(),N.setState({nodesSelectionActive:!1})},U=Z=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Z.preventDefault();return}x==null||x(Z)},M=y?Z=>y(Z):void 0,z=Z=>{q.current&&(Z.stopPropagation(),q.current=!1)},F=Z=>{var Ae,st;if(Z.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:se,transform:me}=N.getState();if(Q.current=se==null?void 0:se.getBoundingClientRect(),!Q.current)return;const Ne=Z.target===Y.current;if(!Ne&&!!Z.target.closest(".nokey")||!t||!(c&&Ne||r)||Z.button!==0||!Z.isPrimary)return;(st=(Ae=Z.target)==null?void 0:Ae.setPointerCapture)==null||st.call(Ae,Z.pointerId),q.current=!1;const{x:je,y:Me}=gn(Z.nativeEvent,Q.current),Re=hs({x:je,y:Me},me);N.setState({userSelectionRect:{width:0,height:0,startX:Re.x,startY:Re.y,x:je,y:Me}}),Ne||(Z.stopPropagation(),Z.preventDefault())};function R(Z,se){const{userSelectionRect:me}=N.getState();if(!me)return;const{transform:Ne,nodeLookup:ve,edgeLookup:re,connectionLookup:je,triggerNodeChanges:Me,triggerEdgeChanges:Re,defaultEdgeOptions:Ae}=N.getState(),st={x:me.startX,y:me.startY},{x:lt,y:at}=Ji(st,Ne),Ye={startX:st.x,startY:st.y,x:Zmt.id)),ee.current=new Set;const gt=(Ae==null?void 0:Ae.selectable)??!0;for(const mt of ne.current){const Pt=je.get(mt);if(Pt)for(const{edgeId:ut}of Pt.values()){const Je=re.get(ut);Je&&(Je.selectable??gt)&&ee.current.add(ut)}}if(!jh(wt,ne.current)){const mt=Gi(ve,ne.current,!0);Me(mt)}if(!jh(qt,ee.current)){const mt=Gi(re,ee.current);Re(mt)}N.setState({userSelectionRect:Ye,userSelectionActive:!0,nodesSelectionActive:!1})}function A(){if(!a||!Q.current)return;const[Z,se]=kc(C.current,Q.current,D);$({x:Z,y:se}).then(me=>{if(!q.current||!me){E.current=requestAnimationFrame(A);return}const{x:Ne,y:ve}=C.current;R(Ne,ve),E.current=requestAnimationFrame(A)})}const ie=()=>{cancelAnimationFrame(E.current),E.current=0,V.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=Z=>{const{userSelectionRect:se,transform:me,resetSelectedElements:Ne}=N.getState();if(!Q.current||!se)return;const{x:ve,y:re}=gn(Z.nativeEvent,Q.current);C.current={x:ve,y:re};const je=Ji({x:se.startX,y:se.startY},me);if(!q.current){const Me=r?0:u;if(Math.hypot(ve-je.x,re-je.y)<=Me)return;Ne(),h==null||h(Z)}q.current=!0,V.current||(A(),V.current=!0),R(ve,re)},fe=Z=>{var se,me;if(!B){Z.target===Y.current&&N.getState().connection.inProgress&&(te.current=!0);return}Z.button===0&&((me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),!P&&Z.target===Y.current&&N.getState().userSelectionRect&&(W==null||W(Z)),N.setState({userSelectionActive:!1,userSelectionRect:null}),q.current&&(p==null||p(Z),N.setState({nodesSelectionActive:ne.current.size>0})),ie())},he=Z=>{var se,me;(me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),ie()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:nt(["react-flow__pane",{draggable:pe,dragging:j,selection:t}]),onClick:B?void 0:Gu(W,Y),onContextMenu:Gu(U,Y),onWheel:Gu(M,Y),onPointerEnter:B?void 0:m,onPointerMove:B?oe:_,onPointerUp:fe,onPointerCancel:B?he:void 0,onPointerDownCapture:B?F:void 0,onClickCapture:B?z:void 0,onPointerLeave:k,ref:Y,style:Zl,children:[b,d.jsx(U_,{})]})}function dc({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),v=h.get(t);if(!v){p==null||p("012",mn.error012(t));return}r.setState({nodesSelectionActive:!1}),v.selected?(o||v.selected&&c)&&(u({nodes:[v],edges:[]}),requestAnimationFrame(()=>{var x;return(x=s==null?void 0:s.current)==null?void 0:x.blur()})):a([t])}function Hg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ge(),[p,v]=L.useState(!1),x=L.useRef();return L.useEffect(()=>{if(!r)return x.current=R1({getStoreItems:()=>h.getState(),onNodeMouseDown:y=>{dc({id:y,store:h,nodeRef:t})},onDragStart:()=>{v(!0)},onDragStop:()=>{v(!1)}}),()=>{var y;(y=x.current)==null||y.destroy(),x.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!x.current||x.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const X_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Bg(){const t=Ge();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:v,nodeOrigin:x}=t.getState(),y=new Map,m=X_(c),_=a?u[0]:5,k=a?u[1]:5,b=o.direction.x*_*o.factor,E=o.direction.y*k*o.factor;for(const[,N]of v){if(!m(N))continue;let P={x:N.internals.positionAbsolute.x+b,y:N.internals.positionAbsolute.y+E};a&&(P=fs(P,u));const{position:w,positionAbsolute:j}=lg({nodeId:N.id,nextPosition:P,nodeLookup:v,nodeExtent:s,nodeOrigin:x,onError:h});N.position=w,N.internals.positionAbsolute=j,y.set(N.id,N)}p(y)},[])}const Ic=L.createContext(null),q_=Ic.Provider;Ic.Consumer;const Vg=()=>L.useContext(Ic),K_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Wg=L.createContext(null);function Q_({children:t}){const r=ze(K_,Qe);return d.jsx(Wg.Provider,{value:r,children:t})}function Z_(){const t=L.useContext(Wg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const J_={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},eS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:v}=c;if(!h&&!a)return J_;const x=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:x,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Qi.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:x&&v}};function tS({type:t="source",position:r=ke.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:v,onMouseDown:x,onTouchStart:y,...m},_){var V,W;const k=c||null,b=t==="target",E=Ge(),N=Vg(),{connectOnClick:P,noPanClassName:w,rfId:j}=Z_(),{connectingFrom:$,connectingTo:D,clickConnecting:B,isPossibleEndHandle:Y,connectionInProcess:Q,clickConnectionInProcess:ne,valid:ee}=ze(eS(N,k,t),Qe);N||(W=(V=E.getState()).onError)==null||W.call(V,"010",mn.error010());const te=U=>{const{defaultEdgeOptions:M,onConnect:z,hasDefaultEdges:F}=E.getState(),R={...M,...U};if(F){const{edges:A,setEdges:ie,onError:oe}=E.getState();ie(T_(R,A,{onError:oe}))}z==null||z(R),h==null||h(R)},q=U=>{if(!N)return;const M=mg(U.nativeEvent);if(a&&(M&&U.button===0||!M)){const z=E.getState();cc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:z.autoPanOnConnect,connectionMode:z.connectionMode,connectionRadius:z.connectionRadius,domNode:z.domNode,nodeLookup:z.nodeLookup,lib:z.lib,isTarget:b,handleId:k,nodeId:N,flowId:z.rfId,panBy:z.panBy,cancelConnection:z.cancelConnection,onConnectStart:z.onConnectStart,onConnectEnd:(...F)=>{var R,A;return(A=(R=E.getState()).onConnectEnd)==null?void 0:A.call(R,...F)},updateConnection:z.updateConnection,onConnect:te,isValidConnection:o||((...F)=>{var R,A;return((A=(R=E.getState()).isValidConnection)==null?void 0:A.call(R,...F))??!0}),getTransform:()=>E.getState().transform,getFromHandle:()=>E.getState().connection.fromHandle,autoPanSpeed:z.autoPanSpeed,dragThreshold:z.connectionDragThreshold})}M?x==null||x(U):y==null||y(U)},C=U=>{const{onClickConnectStart:M,onClickConnectEnd:z,connectionClickStartHandle:F,connectionMode:R,isValidConnection:A,lib:ie,rfId:oe,nodeLookup:fe,connection:he}=E.getState();if(!N||!F&&!a)return;if(!F){M==null||M(U.nativeEvent,{nodeId:N,handleId:k,handleType:t}),E.setState({connectionClickStartHandle:{nodeId:N,type:t,id:k}});return}const pe=pg(U.target),Z=o||A,{connection:se,isValid:me}=cc.isValid(U.nativeEvent,{handle:{nodeId:N,id:k,type:t},connectionMode:R,fromNodeId:F.nodeId,fromHandleId:F.id||null,fromType:F.type,isValidConnection:Z,flowId:oe,doc:pe,lib:ie,nodeLookup:fe});me&&se&&te(se);const Ne=structuredClone(he);delete Ne.inProgress,Ne.toPosition=Ne.toHandle?Ne.toHandle.position:null,z==null||z(U,Ne),E.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":k,"data-nodeid":N,"data-handlepos":r,"data-id":`${j}-${N}-${k}-${t}`,className:nt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",w,v,{source:!b,target:b,connectable:s,connectablestart:a,connectableend:u,clickconnecting:B,connectingfrom:$,connectingto:D,valid:ee,connectionindicator:s&&(!Q||Y)&&(Q||ne?u:a)}]),onMouseDown:q,onTouchStart:q,onClick:P?C:void 0,ref:_,...m,children:p})}const to=L.memo(Dg(tS));function nS({data:t,isConnectable:r,sourcePosition:o=ke.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(to,{type:"source",position:o,isConnectable:r})]})}function rS({data:t,isConnectable:r,targetPosition:o=ke.Top,sourcePosition:s=ke.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(to,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(to,{type:"source",position:s,isConnectable:r})]})}function iS(){return null}function oS({data:t,isConnectable:r,targetPosition:o=ke.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(to,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const Ol={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},np={input:nS,default:rS,output:oS,group:iS};function sS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const lS=t=>{const{width:r,height:o,x:s,y:a}=ds(t.nodeLookup,{filter:u=>!!u.selected});return{width:pn(r)?r:null,height:pn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function aS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ge(),{width:a,height:u,transformString:c,userSelectionActive:h}=ze(lS,Qe),p=Bg(),v=L.useRef(null);L.useEffect(()=>{var _;o||(_=v.current)==null||_.focus({preventScroll:!0})},[o]);const x=!h&&a!==null&&u!==null;if(Hg({nodeRef:v,disabled:!x}),!x)return null;const y=t?_=>{const k=s.getState().nodes.filter(b=>b.selected);t(_,k)}:void 0,m=_=>{Object.prototype.hasOwnProperty.call(Ol,_.key)&&(_.preventDefault(),p({direction:Ol[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:nt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:v,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:o?void 0:-1,onKeyDown:o?void 0:m,style:{width:a,height:u}})})}const rp=typeof window<"u"?window:void 0,uS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Ug({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:v,selectionOnDrag:x,selectionMode:y,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:b,zoomActivationKeyCode:E,elementsSelectable:N,zoomOnScroll:P,zoomOnPinch:w,panOnScroll:j,panOnScrollSpeed:$,panOnScrollMode:D,zoomOnDoubleClick:B,panOnDrag:Y,autoPanOnSelection:Q,defaultViewport:ne,translateExtent:ee,minZoom:te,maxZoom:q,preventScrolling:C,onSelectionContextMenu:V,noWheelClassName:W,noPanClassName:U,disableKeyboardA11y:M,onViewportChange:z,isControlledViewport:F}){const{nodesSelectionActive:R,userSelectionActive:A}=ze(uS,Qe),ie=ss(v,{target:rp}),oe=ss(b,{target:rp}),fe=oe||Y,he=oe||j,pe=x&&fe!==!0,Z=ie||A||pe;return F_({deleteKeyCode:p,multiSelectionKeyCode:k}),d.jsx(V_,{onPaneContextMenu:u,elementsSelectable:N,zoomOnScroll:P,zoomOnPinch:w,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:$,panOnScrollMode:D,zoomOnDoubleClick:B,panOnDrag:!ie&&fe,defaultViewport:ne,translateExtent:ee,minZoom:te,maxZoom:q,zoomActivationKeyCode:E,preventScrolling:C,noWheelClassName:W,noPanClassName:U,onViewportChange:z,isControlledViewport:F,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(Y_,{onSelectionStart:m,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:Q,isSelecting:!!Z,selectionMode:y,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:pe,children:[t,R&&d.jsx(aS,{onSelectionContextMenu:V,noPanClassName:U,disableKeyboardA11y:M})]})})}Ug.displayName="FlowRenderer";const cS=L.memo(Ug),dS=t=>r=>t?Sc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function fS(t){return ze(L.useCallback(dS(t),[t]),Qe)}const hS=t=>t.updateNodeInternals;function pS(){const t=ze(hS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function gS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ge(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),v=L.useRef(r),x=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!x||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[x,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const y=v.current!==r,m=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(y||m||_)&&(v.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function mS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:v,nodesFocusable:x,resizeObserver:y,noDragClassName:m,noPanClassName:_,disableKeyboardA11y:k,rfId:b,nodeTypes:E,nodeClickDistance:N,onError:P}){const{node:w,internals:j,isParent:$}=ze(Z=>{const se=Z.nodeLookup.get(t),me=Z.parentLookup.has(t);return{node:se,internals:se.internals,isParent:me}},Qe);let D=w.type||"default",B=(E==null?void 0:E[D])||np[D];B===void 0&&(P==null||P("003",mn.error003(D)),D="default",B=(E==null?void 0:E.default)||np.default);const Y=!!(w.draggable||h&&typeof w.draggable>"u"),Q=!!(w.selectable||p&&typeof w.selectable>"u"),ne=!!(w.connectable||v&&typeof w.connectable>"u"),ee=!!(w.focusable||x&&typeof w.focusable>"u"),te=Ge(),q=fg(w),C=gS({node:w,nodeType:D,hasDimensions:q,resizeObserver:y}),V=Hg({nodeRef:C,disabled:w.hidden||!Y,noDragClassName:m,handleSelector:w.dragHandle,nodeId:t,isSelectable:Q,nodeClickDistance:N}),W=Bg();if(w.hidden)return null;const U=vn(w),M=sS(w),z=Q||Y||r||o||s||a,F=o?Z=>o(Z,{...j.userNode}):void 0,R=s?Z=>s(Z,{...j.userNode}):void 0,A=a?Z=>a(Z,{...j.userNode}):void 0,ie=u?Z=>u(Z,{...j.userNode}):void 0,oe=c?Z=>c(Z,{...j.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:se,nodeDragThreshold:me}=te.getState();Q&&(!se||!Y||me>0)&&dc({id:t,store:te,nodeRef:C}),r&&r(Z,{...j.userNode})},he=Z=>{if(!(gg(Z.nativeEvent)||k)){if(ng.includes(Z.key)&&Q){const se=Z.key==="Escape";dc({id:t,store:te,unselect:se,nodeRef:C})}else if(Y&&w.selected&&Object.prototype.hasOwnProperty.call(Ol,Z.key)){Z.preventDefault();const{ariaLabelConfig:se}=te.getState();te.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),W({direction:Ol[Z.key],factor:Z.shiftKey?4:1})}}},pe=()=>{var je;if(k||!((je=C.current)!=null&&je.matches(":focus-visible")))return;const{transform:Z,width:se,height:me,autoPanOnNodeFocus:Ne,setCenter:ve}=te.getState();if(!Ne)return;Sc(new Map([[t,w]]),{x:0,y:0,width:se,height:me},Z,!0).length>0||ve(w.position.x+U.width/2,w.position.y+U.height/2,{zoom:Z[2]})};return d.jsx("div",{className:nt(["react-flow__node",`react-flow__node-${D}`,{[_]:Y},w.className,{selected:w.selected,selectable:Q,parent:$,draggable:Y,dragging:V}]),ref:C,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:z?"all":"none",visibility:q?"visible":"hidden",...w.style,...M},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:F,onMouseMove:R,onMouseLeave:A,onContextMenu:ie,onClick:fe,onDoubleClick:oe,onKeyDown:ee?he:void 0,tabIndex:ee?0:void 0,onFocus:ee?pe:void 0,role:w.ariaRole??(ee?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${Lg}-${b}`,"aria-label":w.ariaLabel,...w.domAttributes,children:d.jsx(q_,{value:t,children:d.jsx(B,{id:t,data:w.data,type:D,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:w.selected??!1,selectable:Q,draggable:Y,deletable:w.deletable??!0,isConnectable:ne,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:V,dragHandle:w.dragHandle,zIndex:j.z,parentId:w.parentId,...U})})})}var yS=L.memo(mS);const vS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Gg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=ze(vS,Qe),u=fS(t.onlyRenderVisibleElements),c=pS();return d.jsx("div",{className:"react-flow__nodes",style:Zl,children:u.map(h=>d.jsx(yS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Gg.displayName="NodeRenderer";const xS=L.memo(Gg);function wS(t){return ze(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&h1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const _S=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},SS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ip={[rs.Arrow]:_S,[rs.ArrowClosed]:SS};function kS(t){const r=Ge();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(ip,t)?ip[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",mn.error009(t)),null)},[t])}const NS=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=kS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},Yg=({defaultColor:t,rfId:r})=>{const o=ze(u=>u.edges),s=ze(u=>u.defaultEdgeOptions),a=L.useMemo(()=>_1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(NS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Yg.displayName="MarkerDefinitions";var jS=L.memo(Yg);function Xg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:v,...x}){const[y,m]=L.useState({x:1,y:0,width:0,height:0}),_=nt(["react-flow__edge-textwrapper",v]),k=L.useRef(null);return L.useEffect(()=>{if(k.current){const b=k.current.getBBox();m({x:b.x,y:b.y,width:b.width,height:b.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-y.width/2} ${r-y.height/2})`,className:_,visibility:y.width?"visible":"hidden",...x,children:[a&&d.jsx("rect",{width:y.width+2*c[0],x:-c[0],y:-c[1],height:y.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:k,style:s,children:o}),p]}):null}Xg.displayName="EdgeText";const bS=L.memo(Xg);function Jl({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:v=20,...x}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...x,d:t,fill:"none",className:nt(["react-flow__edge-path",x.className])}),v?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:v,className:"react-flow__edge-interaction"}):null,s&&pn(r)&&pn(o)?d.jsx(bS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function op({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===ke.Left||t===ke.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function qg({sourceX:t,sourceY:r,sourcePosition:o=ke.Bottom,targetX:s,targetY:a,targetPosition:u=ke.Top}){const[c,h]=op({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,v]=op({pos:u,x1:s,y1:a,x2:t,y2:r}),[x,y,m,_]=yg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:v});return[`M${t},${r} C${c},${h} ${p},${v} ${s},${a}`,x,y,m,_]}function Kg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,interactionWidth:N})=>{const[P,w,j]=qg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),$=t.isInternal?void 0:r;return d.jsx(Jl,{id:$,path:P,labelX:w,labelY:j,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,interactionWidth:N})})}const ES=Kg({isInternal:!1}),Qg=Kg({isInternal:!0});ES.displayName="SimpleBezierEdge";Qg.displayName="SimpleBezierEdgeInternal";function Zg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,sourcePosition:_=ke.Bottom,targetPosition:k=ke.Top,markerEnd:b,markerStart:E,pathOptions:N,interactionWidth:P})=>{const[w,j,$]=lc({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:N==null?void 0:N.borderRadius,offset:N==null?void 0:N.offset,stepPosition:N==null?void 0:N.stepPosition}),D=t.isInternal?void 0:r;return d.jsx(Jl,{id:D,path:w,labelX:j,labelY:$,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:b,markerStart:E,interactionWidth:P})})}const Jg=Zg({isInternal:!1}),em=Zg({isInternal:!0});Jg.displayName="SmoothStepEdge";em.displayName="SmoothStepEdgeInternal";function tm(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(Jg,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const CS=tm({isInternal:!1}),nm=tm({isInternal:!0});CS.displayName="StepEdge";nm.displayName="StepEdgeInternal";function rm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:b})=>{const[E,N,P]=wg({sourceX:o,sourceY:s,targetX:a,targetY:u}),w=t.isInternal?void 0:r;return d.jsx(Jl,{id:w,path:E,labelX:N,labelY:P,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:b})})}const MS=rm({isInternal:!1}),im=rm({isInternal:!0});MS.displayName="StraightEdge";im.displayName="StraightEdgeInternal";function om(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=ke.Bottom,targetPosition:h=ke.Top,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,pathOptions:N,interactionWidth:P})=>{const[w,j,$]=vg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:N==null?void 0:N.curvature}),D=t.isInternal?void 0:r;return d.jsx(Jl,{id:D,path:w,labelX:j,labelY:$,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,interactionWidth:P})})}const PS=om({isInternal:!1}),sm=om({isInternal:!0});PS.displayName="BezierEdge";sm.displayName="BezierEdgeInternal";const sp={default:sm,straight:im,step:nm,smoothstep:em,simplebezier:Qg},lp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},IS=(t,r,o)=>o===ke.Left?t-r:o===ke.Right?t+r:t,RS=(t,r,o)=>o===ke.Top?t-r:o===ke.Bottom?t+r:t,ap="react-flow__edgeupdater";function up({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:nt([ap,`${ap}-${h}`]),cx:IS(r,s,t),cy:RS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function TS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:v,onReconnectStart:x,onReconnectEnd:y,setReconnecting:m,setUpdateHover:_}){const k=Ge(),b=(j,$)=>{if(j.button!==0)return;const{autoPanOnConnect:D,domNode:B,connectionMode:Y,connectionRadius:Q,lib:ne,onConnectStart:ee,cancelConnection:te,nodeLookup:q,rfId:C,panBy:V,updateConnection:W}=k.getState(),U=$.type==="target",M=(R,A)=>{m(!1),y==null||y(R,o,$.type,A)},z=R=>v==null?void 0:v(o,R),F=(R,A)=>{m(!0),x==null||x(j,o,$.type),ee==null||ee(R,A)};cc.onPointerDown(j.nativeEvent,{autoPanOnConnect:D,connectionMode:Y,connectionRadius:Q,domNode:B,handleId:$.id,nodeId:$.nodeId,nodeLookup:q,isTarget:U,edgeUpdaterType:$.type,lib:ne,flowId:C,cancelConnection:te,panBy:V,isValidConnection:(...R)=>{var A,ie;return((ie=(A=k.getState()).isValidConnection)==null?void 0:ie.call(A,...R))??!0},onConnect:z,onConnectStart:F,onConnectEnd:(...R)=>{var A,ie;return(ie=(A=k.getState()).onConnectEnd)==null?void 0:ie.call(A,...R)},onReconnectEnd:M,updateConnection:W,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},E=j=>b(j,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),N=j=>b(j,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),P=()=>_(!0),w=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(up,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:E,onMouseEnter:P,onMouseOut:w,type:"source"}),(t===!0||t==="target")&&d.jsx(up,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:N,onMouseEnter:P,onMouseOut:w,type:"target"})]})}function LS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,rfId:k,edgeTypes:b,noPanClassName:E,onError:N,disableKeyboardA11y:P}){let w=ze(ve=>ve.edgeLookup.get(t));const j=ze(ve=>ve.defaultEdgeOptions);w=j?{...j,...w}:w;let $=w.type||"default",D=(b==null?void 0:b[$])||sp[$];D===void 0&&(N==null||N("011",mn.error011($)),$="default",D=(b==null?void 0:b.default)||sp.default);const B=!!(w.focusable||r&&typeof w.focusable>"u"),Y=typeof y<"u"&&(w.reconnectable||o&&typeof w.reconnectable>"u"),Q=!!(w.selectable||s&&typeof w.selectable>"u"),ne=L.useRef(null),[ee,te]=L.useState(!1),[q,C]=L.useState(!1),V=Ge(),{zIndex:W=w.zIndex,sourceX:U,sourceY:M,targetX:z,targetY:F,sourcePosition:R,targetPosition:A}=ze(L.useCallback(ve=>{const re=ve.nodeLookup.get(w.source),je=ve.nodeLookup.get(w.target);if(!re||!je)return lp;const Me=w1({id:t,sourceNode:re,targetNode:je,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:ve.connectionMode,onError:N}),Re=f1({selected:w.selected,zIndex:w.zIndex,sourceNode:re,targetNode:je,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||lp,zIndex:Re}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex,N]),Qe),ie=L.useMemo(()=>w.markerStart?`url('#${ac(w.markerStart,k)}')`:void 0,[w.markerStart,k]),oe=L.useMemo(()=>w.markerEnd?`url('#${ac(w.markerEnd,k)}')`:void 0,[w.markerEnd,k]);if(w.hidden||U===null||M===null||z===null||F===null)return null;const fe=ve=>{var Re;const{addSelectedEdges:re,unselectNodesAndEdges:je,multiSelectionActive:Me}=V.getState();Q&&(V.setState({nodesSelectionActive:!1}),w.selected&&Me?(je({nodes:[],edges:[w]}),(Re=ne.current)==null||Re.blur()):re([t])),a&&a(ve,w)},he=u?ve=>{u(ve,{...w})}:void 0,pe=c?ve=>{c(ve,{...w})}:void 0,Z=h?ve=>{h(ve,{...w})}:void 0,se=p?ve=>{p(ve,{...w})}:void 0,me=v?ve=>{v(ve,{...w})}:void 0,Ne=ve=>{var re;if(!P&&ng.includes(ve.key)&&Q){const{unselectNodesAndEdges:je,addSelectedEdges:Me}=V.getState();ve.key==="Escape"?((re=ne.current)==null||re.blur(),je({edges:[w]})):Me([t])}};return d.jsx("svg",{style:{zIndex:W},children:d.jsxs("g",{className:nt(["react-flow__edge",`react-flow__edge-${$}`,w.className,E,{selected:w.selected,animated:w.animated,inactive:!Q&&!a,updating:ee,selectable:Q}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:Z,onMouseMove:se,onMouseLeave:me,onKeyDown:B?Ne:void 0,tabIndex:B?0:void 0,role:w.ariaRole??(B?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":B?`${Ag}-${k}`:void 0,ref:ne,...w.domAttributes,children:[!q&&d.jsx(D,{id:t,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:Q,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:U,sourceY:M,targetX:z,targetY:F,sourcePosition:R,targetPosition:A,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),Y&&d.jsx(TS,{edge:w,isReconnectable:Y,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,sourceX:U,sourceY:M,targetX:z,targetY:F,sourcePosition:R,targetPosition:A,setUpdateHover:te,setReconnecting:C})]})})}var AS=L.memo(LS);const $S=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function lm({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:v,onEdgeClick:x,reconnectRadius:y,onEdgeDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:b}){const{edgesFocusable:E,edgesReconnectable:N,elementsSelectable:P,onError:w}=ze($S,Qe),j=wS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(jS,{defaultColor:t,rfId:o}),j.map($=>d.jsx(AS,{id:$,edgesFocusable:E,edgesReconnectable:N,elementsSelectable:P,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,onClick:x,reconnectRadius:y,onDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:w,edgeTypes:s,disableKeyboardA11y:b},$))]})}lm.displayName="EdgeRenderer";const zS=L.memo(lm),cp=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function DS({children:t}){const r=Ge(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return Og(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=cp(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:cp(s)},children:t})}function OS(t){const r=Ql(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const FS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function HS(t){const r=ze(FS),o=Ge();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function BS(t){return t.connection.inProgress?{...t.connection,to:hs(t.connection.to,t.transform)}:{...t.connection}}function VS(t){return BS}function WS(t){const r=VS();return ze(r,Qe)}const US=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function GS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=ze(US,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:nt(["react-flow__connection",og(h)]),children:d.jsx(am,{style:r,type:o,CustomComponent:s,isValid:h})})})}const am=({style:t,type:r=Lr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:v,toNode:x,toHandle:y,toPosition:m,pointer:_}=WS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:v.x,toY:v.y,fromPosition:p,toPosition:m,connectionStatus:og(s),toNode:x,toHandle:y,pointer:_});let k="";const b={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:v.x,targetY:v.y,targetPosition:m};switch(r){case Lr.Bezier:[k]=vg(b);break;case Lr.SimpleBezier:[k]=qg(b);break;case Lr.Step:[k]=lc({...b,borderRadius:0});break;case Lr.SmoothStep:[k]=lc(b);break;default:[k]=wg(b)}return d.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};am.displayName="ConnectionLine";const YS={};function dp(t=YS){L.useRef(t),Ge(),L.useEffect(()=>{},[t])}function XS(){Ge(),L.useRef(!1),L.useEffect(()=>{},[])}function um({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,onSelectionContextMenu:y,onSelectionStart:m,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:b,connectionLineComponent:E,connectionLineContainerStyle:N,selectionKeyCode:P,selectionOnDrag:w,selectionMode:j,multiSelectionKeyCode:$,panActivationKeyCode:D,zoomActivationKeyCode:B,deleteKeyCode:Y,onlyRenderVisibleElements:Q,elementsSelectable:ne,defaultViewport:ee,translateExtent:te,minZoom:q,maxZoom:C,preventScrolling:V,defaultMarkerColor:W,zoomOnScroll:U,zoomOnPinch:M,panOnScroll:z,panOnScrollSpeed:F,panOnScrollMode:R,zoomOnDoubleClick:A,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneScroll:se,onPaneContextMenu:me,paneClickDistance:Ne,nodeClickDistance:ve,onEdgeContextMenu:re,onEdgeMouseEnter:je,onEdgeMouseMove:Me,onEdgeMouseLeave:Re,reconnectRadius:Ae,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,noDragClassName:Ye,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,viewport:ut,onViewportChange:Je,nodesDraggable:An}){return dp(t),dp(r),XS(),OS(o),HS(ut),d.jsx(cS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneContextMenu:me,onPaneScroll:se,paneClickDistance:Ne,deleteKeyCode:Y,selectionKeyCode:P,selectionOnDrag:w,selectionMode:j,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:$,panActivationKeyCode:D,zoomActivationKeyCode:B,elementsSelectable:ne,zoomOnScroll:U,zoomOnPinch:M,zoomOnDoubleClick:A,panOnScroll:z,panOnScrollSpeed:F,panOnScrollMode:R,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:ee,translateExtent:te,minZoom:q,maxZoom:C,onSelectionContextMenu:y,preventScrolling:V,noDragClassName:Ye,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,onViewportChange:Je,isControlledViewport:!!ut,children:d.jsxs(DS,{children:[d.jsx(zS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,onlyRenderVisibleElements:Q,onEdgeContextMenu:re,onEdgeMouseEnter:je,onEdgeMouseMove:Me,onEdgeMouseLeave:Re,reconnectRadius:Ae,defaultMarkerColor:W,noPanClassName:qt,disableKeyboardA11y:gt,rfId:Pt}),d.jsx(GS,{style:b,type:k,component:E,containerStyle:N}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(xS,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,nodeClickDistance:ve,onlyRenderVisibleElements:Q,noPanClassName:qt,noDragClassName:Ye,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,nodesDraggable:An}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}um.displayName="GraphView";const qS=L.memo(um),KS=dg(),fp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:v=2,nodeOrigin:x,nodeExtent:y,zIndexMode:m="basic"}={})=>{const _=new Map,k=new Map,b=new Map,E=new Map,N=s??r??[],P=o??t??[],w=x??[0,0],j=y??ts;kg(b,E,N);const{nodesInitialized:$}=uc(P,_,k,{nodeOrigin:w,nodeExtent:j,zIndexMode:m});let D=[0,0,1];if(c&&a&&u){const B=ds(_,{filter:ee=>!!((ee.width||ee.initialWidth)&&(ee.height||ee.initialHeight))}),{x:Y,y:Q,zoom:ne}=Nc(B,a,u,p,v,(h==null?void 0:h.padding)??.1);D=[Y,Q,ne]}return{rfId:"1",width:a??0,height:u??0,transform:D,nodes:P,nodesInitialized:$,nodeLookup:_,parentLookup:k,edges:N,edgeLookup:E,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:v,translateExtent:ts,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Qi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...ig},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:KS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:rg,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},QS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m})=>u_((_,k)=>{async function b(){const{nodeLookup:E,panZoom:N,fitViewOptions:P,fitViewResolver:w,width:j,height:$,minZoom:D,maxZoom:B}=k();N&&(await o1({nodes:E,width:j,height:$,panZoom:N,minZoom:D,maxZoom:B},P),w==null||w.resolve(!0),_({fitViewResolver:null}))}return{...fp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,defaultNodes:o,defaultEdges:s,zIndexMode:m}),setNodes:E=>{const{nodeLookup:N,parentLookup:P,nodeOrigin:w,nodeExtent:j,elevateNodesOnSelect:$,fitViewQueued:D,zIndexMode:B,nodesSelectionActive:Y}=k(),{nodesInitialized:Q,hasSelectedNodes:ne}=uc(E,N,P,{nodeOrigin:w,nodeExtent:j,elevateNodesOnSelect:$,checkEquality:!0,zIndexMode:B}),ee=Y&≠D&&Q?(b(),_({nodes:E,nodesInitialized:Q,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:ee})):_({nodes:E,nodesInitialized:Q,nodesSelectionActive:ee})},setEdges:E=>{const{connectionLookup:N,edgeLookup:P}=k();kg(N,P,E),_({edges:E})},setDefaultNodesAndEdges:(E,N)=>{if(E){const{setNodes:P}=k();P(E),_({hasDefaultNodes:!0})}if(N){const{setEdges:P}=k();P(N),_({hasDefaultEdges:!0})}},updateNodeInternals:E=>{const{triggerNodeChanges:N,nodeLookup:P,parentLookup:w,domNode:j,nodeOrigin:$,nodeExtent:D,debug:B,fitViewQueued:Y,zIndexMode:Q}=k(),{changes:ne,updatedInternals:ee}=C1(E,P,w,j,$,D,Q);ee&&(N1(P,w,{nodeOrigin:$,nodeExtent:D,zIndexMode:Q}),Y?(b(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(ne==null?void 0:ne.length)>0&&(B&&console.log("React Flow: trigger node changes",ne),N==null||N(ne)))},updateNodePositions:(E,N=!1)=>{const P=[];let w=[];const{nodeLookup:j,triggerNodeChanges:$,connection:D,updateConnection:B,onNodesChangeMiddlewareMap:Y}=k();for(const[Q,ne]of E){const ee=j.get(Q),te=!!(ee!=null&&ee.expandParent&&(ee!=null&&ee.parentId)&&(ne!=null&&ne.position)),q={id:Q,type:"position",position:te?{x:Math.max(0,ne.position.x),y:Math.max(0,ne.position.y)}:ne.position,dragging:N};if(ee&&D.inProgress&&D.fromNode.id===ee.id){const C=gi(ee,D.fromHandle,ke.Left,!0);B({...D,from:C})}te&&ee.parentId&&P.push({id:Q,parentId:ee.parentId,rect:{...ne.internals.positionAbsolute,width:ne.measured.width??0,height:ne.measured.height??0}}),w.push(q)}if(P.length>0){const{parentLookup:Q,nodeOrigin:ne}=k(),ee=Pc(P,j,Q,ne);w.push(...ee)}for(const Q of Y.values())w=Q(w);$(w)},triggerNodeChanges:E=>{const{onNodesChange:N,setNodes:P,nodes:w,hasDefaultNodes:j,debug:$}=k();if(E!=null&&E.length){if(j){const D=P_(E,w);P(D)}$&&console.log("React Flow: trigger node changes",E),N==null||N(E)}},triggerEdgeChanges:E=>{const{onEdgesChange:N,setEdges:P,edges:w,hasDefaultEdges:j,debug:$}=k();if(E!=null&&E.length){if(j){const D=I_(E,w);P(D)}$&&console.log("React Flow: trigger edge changes",E),N==null||N(E)}},addSelectedNodes:E=>{const{multiSelectionActive:N,edgeLookup:P,nodeLookup:w,triggerNodeChanges:j,triggerEdgeChanges:$}=k();if(N){const D=E.map(B=>li(B,!0));j(D);return}j(Gi(w,new Set([...E]),!0)),$(Gi(P))},addSelectedEdges:E=>{const{multiSelectionActive:N,edgeLookup:P,nodeLookup:w,triggerNodeChanges:j,triggerEdgeChanges:$}=k();if(N){const D=E.map(B=>li(B,!0));$(D);return}$(Gi(P,new Set([...E]))),j(Gi(w,new Set,!0))},unselectNodesAndEdges:({nodes:E,edges:N}={})=>{const{edges:P,nodes:w,nodeLookup:j,triggerNodeChanges:$,triggerEdgeChanges:D}=k(),B=E||w,Y=N||P,Q=[];for(const ee of B){if(!ee.selected)continue;const te=j.get(ee.id);te&&(te.selected=!1),Q.push(li(ee.id,!1))}const ne=[];for(const ee of Y)ee.selected&&ne.push(li(ee.id,!1));$(Q),D(ne)},setMinZoom:E=>{const{panZoom:N,maxZoom:P}=k();N==null||N.setScaleExtent([E,P]),_({minZoom:E})},setMaxZoom:E=>{const{panZoom:N,minZoom:P}=k();N==null||N.setScaleExtent([P,E]),_({maxZoom:E})},setTranslateExtent:E=>{var N;(N=k().panZoom)==null||N.setTranslateExtent(E),_({translateExtent:E})},resetSelectedElements:()=>{const{edges:E,nodes:N,triggerNodeChanges:P,triggerEdgeChanges:w,elementsSelectable:j}=k();if(!j)return;const $=N.reduce((B,Y)=>Y.selected?[...B,li(Y.id,!1)]:B,[]),D=E.reduce((B,Y)=>Y.selected?[...B,li(Y.id,!1)]:B,[]);P($),w(D)},setNodeExtent:E=>{const{nodes:N,nodeLookup:P,parentLookup:w,nodeOrigin:j,elevateNodesOnSelect:$,nodeExtent:D,zIndexMode:B}=k();E[0][0]===D[0][0]&&E[0][1]===D[0][1]&&E[1][0]===D[1][0]&&E[1][1]===D[1][1]||(uc(N,P,w,{nodeOrigin:j,nodeExtent:E,elevateNodesOnSelect:$,checkEquality:!1,zIndexMode:B}),_({nodeExtent:E}))},panBy:E=>{const{transform:N,width:P,height:w,panZoom:j,translateExtent:$}=k();return M1({delta:E,panZoom:j,transform:N,translateExtent:$,width:P,height:w})},setCenter:async(E,N,P)=>{const{width:w,height:j,maxZoom:$,panZoom:D}=k();if(!D)return!1;const B=typeof(P==null?void 0:P.zoom)<"u"?P.zoom:$;return await D.setViewport({x:w/2-E*B,y:j/2-N*B,zoom:B},{duration:P==null?void 0:P.duration,ease:P==null?void 0:P.ease,interpolate:P==null?void 0:P.interpolate}),!0},cancelConnection:()=>{_({connection:{...ig}})},updateConnection:E=>{_({connection:E})},reset:()=>_({...fp()})}},Object.is);function cm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m,children:_}){const[k]=L.useState(()=>QS({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:v,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:x,nodeExtent:y,zIndexMode:m}));return d.jsx(c_,{value:k,children:d.jsx($_,{children:d.jsx(Q_,{children:_})})})}function ZS({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:v,maxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_}){return L.useContext(ql)?d.jsx(d.Fragment,{children:t}):d.jsx(cm,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:v,initialMaxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_,children:t})}const JS={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function ek({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:v,onMove:x,onMoveStart:y,onMoveEnd:m,onConnect:_,onConnectStart:k,onConnectEnd:b,onClickConnectStart:E,onClickConnectEnd:N,onNodeMouseEnter:P,onNodeMouseMove:w,onNodeMouseLeave:j,onNodeContextMenu:$,onNodeDoubleClick:D,onNodeDragStart:B,onNodeDrag:Y,onNodeDragStop:Q,onNodesDelete:ne,onEdgesDelete:ee,onDelete:te,onSelectionChange:q,onSelectionDragStart:C,onSelectionDrag:V,onSelectionDragStop:W,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:z,onBeforeDelete:F,connectionMode:R,connectionLineType:A=Lr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:Z=!1,selectionMode:se=ns.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:Ne=os()?"Meta":"Control",zoomActivationKeyCode:ve=os()?"Meta":"Control",snapToGrid:re,snapGrid:je,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Re,nodesDraggable:Ae,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,nodeOrigin:Ye=$g,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt=!0,defaultViewport:mt=k_,minZoom:Pt=.5,maxZoom:ut=2,translateExtent:Je=ts,preventScrolling:An=!0,nodeExtent:Ot,defaultMarkerColor:xn="#b1b1b7",zoomOnScroll:ro=!0,zoomOnPinch:$n=!0,panOnScroll:yi=!1,panOnScrollSpeed:ir=.5,panOnScrollMode:$r=ci.Free,zoomOnDoubleClick:zn=!0,panOnDrag:zr=!0,onPaneClick:or,onPaneMouseEnter:sr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn=1,nodeClickDistance:Fn=0,children:_n,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:lr,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn=10,onNodesChange:Ht,onEdgesChange:Or,noDragClassName:nn="nodrag",noWheelClassName:Fr="nowheel",noPanClassName:yt="nopan",fitView:Hn,fitViewOptions:ar,connectOnClick:io,attributionPosition:It,proOptions:Bn,defaultEdgeOptions:Hr,elevateNodesOnSelect:jn=!0,elevateEdgesOnSelect:Br=!1,disableKeyboardA11y:vi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:oo,autoPanOnSelection:Vr=!0,autoPanSpeed:xi,connectionRadius:ur,isValidConnection:so,onError:cr,style:Vn,id:bt,nodeDragThreshold:Wr,connectionDragThreshold:Et,viewport:lo,onViewportChange:Ur,width:Gr,height:Wn,colorMode:Un="light",debug:bn,onScroll:Bt,ariaLabelConfig:wi,zIndexMode:Yr="basic",...dr},fr){const Gn=bt||"1",En=E_(Un),ao=L.useCallback(hr=>{hr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Bt==null||Bt(hr)},[Bt]);return d.jsx("div",{"data-testid":"rf__wrapper",...dr,onScroll:ao,style:{...Vn,...JS},ref:fr,className:nt(["react-flow",a,En]),id:bt,role:"application",children:d.jsxs(ZS,{nodes:t,edges:r,width:Gr,height:Wn,fitView:Hn,fitViewOptions:ar,minZoom:Pt,maxZoom:ut,nodeOrigin:Ye,nodeExtent:Ot,zIndexMode:Yr,children:[d.jsx(b_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:k,onConnectEnd:b,onClickConnectStart:E,onClickConnectEnd:N,nodesDraggable:Ae,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt,elevateNodesOnSelect:jn,elevateEdgesOnSelect:Br,minZoom:Pt,maxZoom:ut,nodeExtent:Ot,onNodesChange:Ht,onEdgesChange:Or,snapToGrid:re,snapGrid:je,connectionMode:R,translateExtent:Je,connectOnClick:io,defaultEdgeOptions:Hr,fitView:Hn,fitViewOptions:ar,onNodesDelete:ne,onEdgesDelete:ee,onDelete:te,onNodeDragStart:B,onNodeDrag:Y,onNodeDragStop:Q,onSelectionDrag:V,onSelectionDragStart:C,onSelectionDragStop:W,onMove:x,onMoveStart:y,onMoveEnd:m,noPanClassName:yt,nodeOrigin:Ye,rfId:Gn,autoPanOnConnect:Ve,autoPanOnNodeDrag:oo,autoPanSpeed:xi,onError:cr,connectionRadius:ur,isValidConnection:so,selectNodesOnDrag:Re,nodeDragThreshold:Wr,connectionDragThreshold:Et,onBeforeDelete:F,debug:bn,ariaLabelConfig:wi,zIndexMode:Yr}),d.jsx(qS,{onInit:v,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:P,onNodeMouseMove:w,onNodeMouseLeave:j,onNodeContextMenu:$,onNodeDoubleClick:D,nodeTypes:u,edgeTypes:c,connectionLineType:A,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:Z,selectionMode:se,deleteKeyCode:he,multiSelectionKeyCode:Ne,panActivationKeyCode:me,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:mt,translateExtent:Je,minZoom:Pt,maxZoom:ut,preventScrolling:An,zoomOnScroll:ro,zoomOnPinch:$n,zoomOnDoubleClick:zn,panOnScroll:yi,panOnScrollSpeed:ir,panOnScrollMode:$r,panOnDrag:zr,autoPanOnSelection:Vr,onPaneClick:or,onPaneMouseEnter:sr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn,nodeClickDistance:Fn,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:z,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:lr,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn,defaultMarkerColor:xn,noDragClassName:nn,noWheelClassName:Fr,noPanClassName:yt,rfId:Gn,disableKeyboardA11y:vi,nodeExtent:Ot,viewport:lo,onViewportChange:Ur,nodesDraggable:Ae}),d.jsx(S_,{onSelectionChange:q}),_n,d.jsx(y_,{proOptions:Bn,position:It}),d.jsx(m_,{rfId:Gn,disableKeyboardA11y:vi})]})})}var tk=Dg(ek);function nk({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:nt(["react-flow__background-pattern",o,s])})}function rk({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:nt(["react-flow__background-pattern","dots",r])})}var Ar;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Ar||(Ar={}));const ik={[Ar.Dots]:1,[Ar.Lines]:1,[Ar.Cross]:6},ok=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function dm({id:t,variant:r=Ar.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:v,patternClassName:x}){const y=L.useRef(null),{transform:m,patternId:_}=ze(ok,Qe),k=s||ik[r],b=r===Ar.Dots,E=r===Ar.Cross,N=Array.isArray(o)?o:[o,o],P=[N[0]*m[2]||1,N[1]*m[2]||1],w=k*m[2],j=Array.isArray(u)?u:[u,u],$=E?[w,w]:P,D=[j[0]*m[2]+$[0]/2,j[1]*m[2]+$[1]/2],B=`${_}${t||""}`;return d.jsxs("svg",{className:nt(["react-flow__background",v]),style:{...p,...Zl,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:y,"data-testid":"rf__background",children:[d.jsx("pattern",{id:B,x:m[0]%P[0],y:m[1]%P[1],width:P[0],height:P[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${D[0]},-${D[1]})`,children:b?d.jsx(rk,{radius:w/2,className:x}):d.jsx(nk,{dimensions:$,lineWidth:a,variant:r,className:x})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${B})`})]})}dm.displayName="Background";const sk=L.memo(dm);function lk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ak(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function uk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 ck(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 Sl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:nt(["react-flow__controls-button",r]),...o,children:t})}const fk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function fm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:v,children:x,position:y="bottom-left",orientation:m="vertical","aria-label":_}){const k=Ge(),{isInteractive:b,minZoomReached:E,maxZoomReached:N,ariaLabelConfig:P}=ze(fk,Qe),{zoomIn:w,zoomOut:j,fitView:$}=Ql(),D=()=>{w(),u==null||u()},B=()=>{j(),c==null||c()},Y=()=>{$(a),h==null||h()},Q=()=>{k.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),p==null||p(!b)},ne=m==="horizontal"?"horizontal":"vertical";return d.jsxs(Kl,{className:nt(["react-flow__controls",ne,v]),position:y,style:t,"data-testid":"rf__controls","aria-label":_??P["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(Sl,{onClick:D,className:"react-flow__controls-zoomin",title:P["controls.zoomIn.ariaLabel"],"aria-label":P["controls.zoomIn.ariaLabel"],disabled:N,children:d.jsx(lk,{})}),d.jsx(Sl,{onClick:B,className:"react-flow__controls-zoomout",title:P["controls.zoomOut.ariaLabel"],"aria-label":P["controls.zoomOut.ariaLabel"],disabled:E,children:d.jsx(ak,{})})]}),o&&d.jsx(Sl,{className:"react-flow__controls-fitview",onClick:Y,title:P["controls.fitView.ariaLabel"],"aria-label":P["controls.fitView.ariaLabel"],children:d.jsx(uk,{})}),s&&d.jsx(Sl,{className:"react-flow__controls-interactive",onClick:Q,title:P["controls.interactive.ariaLabel"],"aria-label":P["controls.interactive.ariaLabel"],children:b?d.jsx(dk,{}):d.jsx(ck,{})}),x]})}fm.displayName="Controls";const hk=L.memo(fm);function pk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:v,borderRadius:x,shapeRendering:y,selected:m,onClick:_}){const{background:k,backgroundColor:b}=u||{},E=c||k||b;return d.jsx("rect",{className:nt(["react-flow__minimap-node",{selected:m},v]),x:r,y:o,rx:x,ry:x,width:s,height:a,style:{fill:E,stroke:h,strokeWidth:p},shapeRendering:y,onClick:_?N=>_(N,t):void 0})}const gk=L.memo(pk),mk=t=>t.nodes.map(r=>r.id),Yu=t=>t instanceof Function?t:()=>t;function yk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=gk,onClick:c}){const h=ze(mk,Qe),p=Yu(r),v=Yu(t),x=Yu(o),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(m=>d.jsx(xk,{id:m,nodeColorFunc:p,nodeStrokeColorFunc:v,nodeClassNameFunc:x,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:y},m))})}function vk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:v,x,y,width:m,height:_}=ze(k=>{const b=k.nodeLookup.get(t);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const E=b.internals.userNode,{x:N,y:P}=b.internals.positionAbsolute,{width:w,height:j}=vn(E);return{node:E,x:N,y:P,width:w,height:j}},Qe);return!v||v.hidden||!fg(v)?null:d.jsx(h,{x,y,width:m,height:_,style:v.style,selected:!!v.selected,className:s(v),color:r(v),borderRadius:a,strokeColor:o(v),strokeWidth:u,shapeRendering:c,onClick:p,id:v.id})}const xk=L.memo(vk);var wk=L.memo(yk);const _k=200,Sk=150,kk=t=>!t.hidden,Nk=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?ug(ds(t.nodeLookup,{filter:kk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},hp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,jk=(t,r)=>hp(t.viewBB,r.viewBB)&&hp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,bk="react-flow__minimap-desc";function hm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:v,maskStrokeColor:x,maskStrokeWidth:y,position:m="bottom-right",onClick:_,onNodeClick:k,pannable:b=!1,zoomable:E=!1,ariaLabel:N,inversePan:P,zoomStep:w=1,offsetScale:j=5}){const $=Ge(),D=L.useRef(null),{boundingRect:B,viewBB:Y,rfId:Q,panZoom:ne,translateExtent:ee,flowWidth:te,flowHeight:q,ariaLabelConfig:C}=ze(Nk,jk),V=(t==null?void 0:t.width)??_k,W=(t==null?void 0:t.height)??Sk,U=B.width/V,M=B.height/W,z=Math.max(U,M),F=z*V,R=z*W,A=j*z,ie=B.x-(F-B.width)/2-A,oe=B.y-(R-B.height)/2-A,fe=F+A*2,he=R+A*2,pe=`${bk}-${Q}`,Z=L.useRef(0),se=L.useRef();Z.current=z,L.useEffect(()=>{if(D.current&&ne)return se.current=D1({domNode:D.current,panZoom:ne,getTransform:()=>$.getState().transform,getViewScale:()=>Z.current}),()=>{var re;(re=se.current)==null||re.destroy()}},[ne]),L.useEffect(()=>{var re;(re=se.current)==null||re.update({translateExtent:ee,width:te,height:q,inversePan:P,pannable:b,zoomStep:w,zoomable:E})},[b,E,P,w,ee,te,q]);const me=_?re=>{var Re;const[je,Me]=((Re=se.current)==null?void 0:Re.pointer(re))||[0,0];_(re,{x:je,y:Me})}:void 0,Ne=k?L.useCallback((re,je)=>{const Me=$.getState().nodeLookup.get(je).internals.userNode;k(re,Me)},[]):void 0,ve=N??C["minimap.ariaLabel"];return d.jsx(Kl,{position:m,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof v=="string"?v:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof y=="number"?y*z:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:nt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:V,height:W,viewBox:`${ie} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:D,onClick:me,children:[ve&&d.jsx("title",{id:pe,children:ve}),d.jsx(wk,{onClick:Ne,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-A},${oe-A}h${fe+A*2}v${he+A*2}h${-fe-A*2}z + M${Y.x},${Y.y}h${Y.width}v${Y.height}h${-Y.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}hm.displayName="MiniMap";const Ek=L.memo(hm),Ck=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Mk={[eo.Line]:"right",[eo.Handle]:"bottom-right"};function Pk({nodeId:t,position:r,variant:o=eo.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:v=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:y=!1,resizeDirection:m,autoScale:_=!0,shouldResize:k,onResizeStart:b,onResize:E,onResizeEnd:N}){const P=Vg(),w=typeof t=="string"?t:P,j=Ge(),$=L.useRef(null),D=o===eo.Handle,B=ze(L.useCallback(Ck(D&&_),[D,_]),Qe),Y=L.useRef(null),Q=r??Mk[o];L.useEffect(()=>{if(!(!$.current||!w))return Y.current||(Y.current=Q1({domNode:$.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:ee,transform:te,snapGrid:q,snapToGrid:C,nodeOrigin:V,domNode:W}=j.getState();return{nodeLookup:ee,transform:te,snapGrid:q,snapToGrid:C,nodeOrigin:V,paneDomNode:W}},onChange:(ee,te)=>{const{triggerNodeChanges:q,nodeLookup:C,parentLookup:V,nodeOrigin:W}=j.getState(),U=[],M={x:ee.x,y:ee.y},z=C.get(w);if(z&&z.expandParent&&z.parentId){const F=z.origin??W,R=ee.width??z.measured.width??0,A=ee.height??z.measured.height??0,ie={id:z.id,parentId:z.parentId,rect:{width:R,height:A,...hg({x:ee.x??z.position.x,y:ee.y??z.position.y},{width:R,height:A},z.parentId,C,F)}},oe=Pc([ie],C,V,W);U.push(...oe),M.x=ee.x?Math.max(F[0]*R,ee.x):void 0,M.y=ee.y?Math.max(F[1]*A,ee.y):void 0}if(M.x!==void 0&&M.y!==void 0){const F={id:w,type:"position",position:{...M}};U.push(F)}if(ee.width!==void 0&&ee.height!==void 0){const R={id:w,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:ee.width,height:ee.height}};U.push(R)}for(const F of te){const R={...F,type:"position"};U.push(R)}q(U)},onEnd:({width:ee,height:te})=>{const q={id:w,type:"dimensions",resizing:!1,dimensions:{width:ee,height:te}};j.getState().triggerNodeChanges([q])}})),Y.current.update({controlPosition:Q,boundaries:{minWidth:h,minHeight:p,maxWidth:v,maxHeight:x},keepAspectRatio:y,resizeDirection:m,onResizeStart:b,onResize:E,onResizeEnd:N,shouldResize:k}),()=>{var ee;(ee=Y.current)==null||ee.destroy()}},[Q,h,p,v,x,y,b,E,N,k]);const ne=Q.split("-");return d.jsx("div",{className:nt(["react-flow__resize-control","nodrag",...ne,o,s]),ref:$,style:{...a,scale:B,...c&&{[D?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Pk);const Ik={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function ea(t){return Ik[t]??8}const fc=208,hc=64,Rk=88,Tk=28,Lk=8;function Ak(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function $k(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const N of t){const P=ea(N.type),w=s.get(P)??[];w.push(N),s.set(P,w)}const u=[...s.keys()].sort((N,P)=>N-P).map(N=>[...s.get(N)??[]].sort((P,w)=>P.name.localeCompare(w.name)||P.id.localeCompare(w.id))),c=new Set(t.map(N=>N.id)),h=new Map,p=new Map;for(const N of t)h.set(N.id,[]),p.set(N.id,[]);for(const N of r)!c.has(N.src)||!c.has(N.dst)||N.src===N.dst||(p.get(N.src).push(N.dst),h.get(N.dst).push(N.src));const v=new Map;u.forEach((N,P)=>{for(const w of N)v.set(w.id,P)});const x=new Map,y=()=>{for(const N of u)N.forEach((P,w)=>x.set(P.id,w))};y();const m=(N,P)=>{const w=N.map((j,$)=>{const D=P(j.id).map(Y=>x.get(Y)).filter(Y=>Y!==void 0),B=Ak(D);return{n:j,bary:Number.isNaN(B)?$:B,name:j.name,id:j.id}});return w.sort((j,$)=>j.bary-$.bary||j.name.localeCompare($.name)||j.id.localeCompare($.id)),w.map(j=>j.n)},_=N=>P=>v.get(P)===N;for(let N=0;N(h.get(w)??[]).filter(_(P-1))),y();for(let P=u.length-2;P>=0;P--)u[P]=m(u[P],w=>(p.get(w)??[]).filter(_(P+1))),y()}const k=fc+Rk,b=hc+Tk,E=Math.max(...u.map(N=>N.length),1);return u.forEach((N,P)=>{const w=(E-N.length)*b/2;N.forEach((j,$)=>{o.set(j.id,{x:P*k,y:w+$*b})})}),o}const zk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),pm=90,Dk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),pp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Ok=Math.PI*(3-Math.sqrt(5)),gm=220,Fk=26,Hk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function mm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function PN(t){return pp[t]?pp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Bk(t){return t>=pm?"3d":"2d"}function Vk(t){return t>=pm?"overview":"full"}function Wk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(mm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Dk.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Wk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Gk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function Yk(t,r,o,s){const a=new Set(t.map(b=>b.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const b of r){if(!a.has(b.src)||!a.has(b.dst))continue;const E=u.get(b.src)??[];E.push({dst:b.dst,id:b.id}),u.set(b.src,E);const N=c.get(b.dst)??[];N.push({src:b.src,id:b.id}),c.set(b.dst,N)}const h=new Set(t.filter(b=>zk.has(b.type)).map(b=>b.id)),p=h.size?h:a,v=new Set,x=[o];for(;x.length;){const b=x.pop();if(!v.has(b)){v.add(b);for(const E of u.get(b)??[])v.has(E.dst)||x.push(E.dst)}}const y=new Set([o]),m=[...p].filter(b=>v.has(b)),_=new Set(m);for(;m.length;){const b=m.pop();y.add(b);for(const E of c.get(b)??[])v.has(E.src)&&!_.has(E.src)&&(_.add(E.src),m.push(E.src))}const k=new Set;for(const b of r)y.has(b.src)&&y.has(b.dst)&&k.add(b.id);return{nodeIds:y,edgeIds:k}}function IN(t){const r=new Map;for(const s of t){const a=ea(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*gm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Fk*Math.sqrt(h+1),v=h*Ok;o.set(c.id,{x:u,y:p*Math.cos(v),z:p*Math.sin(v)})})}return o}function RN(t){const r=new Map;for(const o of t){const s=ea(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*gm,count:s}))}const kl=16,Xk=12,qk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Kk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),gp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Qk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},mp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],yp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Zk=new Set(["looks_idempotent_on_pk","null","blank"]),Jk=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function eN(t){return gp[t]?gp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function tN(t,r,o){const s=new Map(r.map(m=>[m.id,m])),a=[];qk.has(t.type)&&a.push("sink"),Kk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(m=>m.dst===t.id),h=o.filter(m=>m.src===t.id),p=c.slice(0,kl).map(m=>Nl(m,s,m.src)),v=h.slice(0,kl).map(m=>Nl(m,s,m.dst)),x=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,y={type:t.type,typeLabel:Ko(no(t.type)),layer:Hk[ea(t.type)]??"other",purpose:eN(t.type),name:t.name,qualifiedName:t.qualified_name,file:x,context:t.context,roles:a,facts:rN(u).filter(m=>!(m.key==="app"&&m.value===t.context)),inputs:p,outputs:v,extraInputs:Math.max(0,c.length-kl),extraOutputs:Math.max(0,h.length-kl),degreeIn:c.length,degreeOut:h.length,inputKinds:vp(c.map(m=>Nl(m,s,m.src))),outputKinds:vp(h.map(m=>Nl(m,s,m.dst))),pathSummary:""};return y.pathSummary=nN(y),y}function vp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function nN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function Nl(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Ko(no(s.type)):"",edgeType:t.type,edgeLabel:Ko(t.type),inferred:t.confidence<.8}}function rN(t){const r=[...mp.filter(a=>a in t),...Object.keys(t).filter(a=>!mp.includes(a)&&!yp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||yp.has(a)||Jk.has(a))continue;s.add(a);const u=iN(a,t[a]);u!=null&&o.push({key:a,label:Qk[a]??Ko(a),value:u})}return o}function iN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Zk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return oN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Xk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function oN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const sN=new Set,lN=L.lazy(()=>_0(()=>import("./LayeredGraph3D-BnhN-wUA.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),aN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function uN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(to,{type:"target",position:ke.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:no(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Tr(t.name)}),d.jsx(to,{type:"source",position:ke.Right,isConnectable:!1})]})}const cN={load:uN},dN=new Set(["django","react","stitch","arch"]);function fN({topologyKey:t}){const{fitView:r}=Ql();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function hN(t,r,o=null,s={}){const a=new Map(t.map(p=>[p.id,p])),u=$k(t,r),c=t.map(p=>{var y;const v=((y=s.roles)==null?void 0:y[p.id])||[],x=!!s.testOverlay&&!v.includes("tested")&&!v.includes("untested")&&!v.includes("test")&&!v.includes("seed");return{id:p.id,type:"load",position:u.get(p.id)??{x:0,y:0},data:{name:p.name,type:p.type,file:p.file_path,roles:v,dim:x},selected:o===p.id,sourcePosition:ke.Right,targetPosition:ke.Left,width:fc,height:hc,style:{width:fc,height:hc}}}),h=r.filter(p=>a.has(p.src)&&a.has(p.dst)).map(p=>{const v=aN[p.weight]||"var(--edge-cheap)",x=!!(o&&(p.src===o||p.dst===o));return{id:p.id,source:p.src,target:p.dst,type:"smoothstep",animated:p.weight==="critical",style:{stroke:v,strokeWidth:p.weight==="critical"?2.4:1.2,strokeDasharray:p.confidence<.8?"6 4":void 0},markerEnd:{type:rs.ArrowClosed,width:14,height:14,color:v},label:x?p.type.replaceAll("_"," "):void 0,labelStyle:x?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:x?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:x?[3,5]:void 0,labelBgBorderRadius:x?4:void 0}});return{rfNodes:c,rfEdges:h}}function pN({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:v}){const x=tN(t,r,o);return L.useEffect(()=>{const y=m=>{m.key==="Escape"&&s()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:x.typeLabel}),d.jsx("div",{className:"inspector-roles",children:x.roles.map(y=>d.jsx("span",{className:"inspector-chip",children:y},y))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Tr(x.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:x.purpose}),x.context?d.jsx("div",{className:"muted",children:Tr(x.context)}):null,x.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Tr(x.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Tr(x.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",x.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[x.degreeIn," in · ",x.degreeOut," out"]}),x.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:x.pathSummary}):null,x.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:x.facts.map(y=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:y.label}),d.jsx("dd",{children:Tr(y.value)})]},y.key))}):null,d.jsx(xp,{title:"Inputs",testId:"graph-inspector-inputs",links:x.inputs,extra:x.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(xp,{title:"Outputs",testId:"graph-inspector-outputs",links:x.outputs,extra:x.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),a?d.jsx("p",{className:"whatif-hint","data-testid":"whatif-hint",children:v?"Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map.":"Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."}):null,d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",title:"Start a hypothetical walk from this node. Does not use Base/Head.",onClick:()=>a(t.id),children:"What if this changes"}):null,v?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",title:"Hide nodes that are not on a path from here to a sink. Does not start a new walk.",onClick:()=>v(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function xp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Xu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:v,repoPath:x,onOpenFile:y,pinnedId:m,onPin:_}){const[k,b]=L.useState(null),E=a!==void 0?a:k,N=re=>{a===void 0&&b(re),u==null||u(re)},[P,w]=L.useState(null),[j,$]=L.useState(null),[D,B]=L.useState(new Set(dN)),[Y,Q]=L.useState(!1),[ne,ee]=L.useState(""),[te,q]=L.useState(!1),C=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,V=P??Bk(t.length),W=j??Vk(t.length),U=Y?E:null,M=L.useMemo(()=>p?Yk(t,r,p):null,[t,r,p]),z=M?t.filter(re=>M.nodeIds.has(re.id)):t,F=M?r.filter(re=>M.edgeIds.has(re.id)):r,R=L.useMemo(()=>Uk(z,F,{detail:W,families:D,focusId:U,neighborhoodOnly:!!U}),[z,F,W,D,U]),A=L.useMemo(()=>`${R.nodes.map(re=>re.id).join("\0")}|${R.edges.map(re=>re.id).join("\0")}`,[R.nodes,R.edges]),ie=E?t.find(re=>re.id===E)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const re=hN(R.nodes,R.edges,E,{roles:c,testOverlay:h});return C&&(re.rfEdges=re.rfEdges.map(je=>({...je,animated:!1}))),re},[R.nodes,R.edges,E,C,c,h]);L.useEffect(()=>{if(!s)return;const re=t.find(je=>je.file_path===s);re&&N(re.id)},[s,t]);const he=L.useMemo(()=>Gk(t,ne),[t,ne]),pe=(re,je)=>{N(je.id)},Z=()=>{N(null),Q(!1)},se=ie?d.jsx(pN,{node:ie,nodes:t,edges:r,onClose:Z,onWhatIf:o,onSelect:N,onOpenFile:y,pinned:m===ie.id,onPin:_,onIsolate:v?re=>{v(p===re?null:re)}:void 0}):null,me=re=>{B(je=>{const Me=new Set(je);if(Me.has(re)){if(Me.size===1)return je;Me.delete(re)}else Me.add(re);return Me})},Ne=L.useMemo(()=>{const re=new Set;for(const je of t)re.add(mm(je.type));return re},[t]),ve=t.length-R.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:V==="2d"?"active":"","aria-pressed":V==="2d",onClick:()=>w("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:V==="3d"?"active":"","aria-pressed":V==="3d",onClick:()=>w("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:W==="overview"?"active":"","aria-pressed":W==="overview",onClick:()=>$("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:W==="full"?"active":"","aria-pressed":W==="full",onClick:()=>$("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(re=>Ne.has(re)).map(re=>d.jsx("button",{type:"button","data-testid":`graph-family-${re}`,className:D.has(re)?"active":"","aria-pressed":D.has(re),onClick:()=>me(re),children:re},re))}),d.jsx("button",{type:"button",className:Y?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!E,onClick:()=>Q(re=>!re),children:Y?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>v==null?void 0:v(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:ne,onChange:re=>{ee(re.target.value),q(!0)},onFocus:()=>q(!0),onBlur:()=>window.setTimeout(()=>q(!1),150)}),te&&ne.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(re=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:je=>je.preventDefault(),onClick:()=>{N(re.id),ee(""),q(!1)},children:[re.name,d.jsx("span",{className:"muted",children:no(re.type)})]})},re.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[R.nodes.length," nodes · ",R.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:V==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(lN,{nodes:R.nodes,edges:R.edges,selectedId:E,neighborIds:U?R.neighborIds:sN,onSelect:re=>{N(re),re||Q(!1)}})}),se]}):d.jsxs(cm,{children:[d.jsxs(tk,{nodes:oe,edges:fe,nodeTypes:cN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:Z,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(fN,{topologyKey:A}),d.jsx(sk,{}),d.jsx(Ek,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(hk,{})]}),se]})})]})}function ym(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function gN(t){localStorage.setItem("loadpath.editor",t)}async function mN(t,r,o,s=ym()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const wp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],yN=["preset","branch","tag","commit"];function vN(t){var a;if(!(t!=null&&t.git))return[...wp];const r=((a=t.presets)!=null&&a.length?t.presets:wp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function xN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function wN(t){return yN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function _N(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function _p({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[v,x]=L.useState(!1),[y,m]=L.useState(null),[_,k]=L.useState(0),b=L.useMemo(()=>{const j=vN(u);return y===null?j:xN(j,y)},[u,y]),E=L.useMemo(()=>wN(b),[b]);L.useEffect(()=>{v&&c()},[v,c]),L.useEffect(()=>{k(0)},[y,v]);const N=()=>{x(!1),m(null)},P=j=>{r(j.value),N()},w=j=>{if(j.key==="ArrowDown"){if(j.preventDefault(),!v){x(!0);return}k($=>Math.min($+1,Math.max(b.length-1,0)))}else if(j.key==="ArrowUp"){if(j.preventDefault(),!v)return;k($=>Math.max($-1,0))}else if(j.key==="Enter"&&v){j.preventDefault();const $=b[_];$&&P($)}else j.key==="Escape"&&v&&(j.preventDefault(),N())};return d.jsxs("div",{className:"combo",ref:p,onBlur:j=>{j.currentTarget.contains(j.relatedTarget)||N()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":v,"aria-controls":h,"aria-autocomplete":"list",onChange:j=>{r(j.target.value),v&&m(j.target.value)},onKeyDown:w}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":v,onMouseDown:j=>j.preventDefault(),onClick:()=>v?N():x(!0),children:d.jsx(v0,{})})]}),v?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:E.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):E.map(j=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:_N(j.group)}),j.items.map($=>{const D=b.indexOf($);return d.jsxs("button",{type:"button",role:"option","aria-selected":D===_,className:D===_?"combo-option active":"combo-option","data-testid":`ref-option-${$.group}`,onMouseDown:B=>B.preventDefault(),onMouseEnter:()=>k(D),onClick:()=>P($),children:[d.jsx("span",{className:"combo-label",children:$.label}),$.detail?d.jsx("span",{className:"combo-detail",children:$.detail}):null]},`${$.group}:${$.value}`)})]},j.group))}):null]})}function SN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[v,x]=L.useState(""),[y,m]=L.useState(!1),_=L.useRef(null),k=L.useRef(0),b=async w=>{const j=k.current+1;k.current=j,m(!0);try{const $=await Pe.browse(w);if(k.current!==j)return;a($),c($.path),p($.is_git?$.path:null),x("")}catch($){if(k.current!==j)return;x($ instanceof Error?$.message:String($))}finally{k.current===j&&m(!1)}};L.useEffect(()=>{var w,j;b(t),(w=_.current)==null||w.focus(),(j=_.current)==null||j.select()},[t]);const E=h||(s==null?void 0:s.path)||u,N=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",P=w=>{w.key==="Escape"&&(w.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:P,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:w=>w.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:w=>{w.preventDefault(),b(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:w=>c(w.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void b(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void b(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),v?d.jsx("div",{className:"error",role:"alert",children:v}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":y,children:s!=null&&s.entries.length?s.entries.map(w=>{const j=h===w.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":j,className:j?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":w.path,onClick:()=>p(w.path),onDoubleClick:()=>void b(w.path),children:[d.jsx(jp,{}),d.jsx("span",{className:"explorer-name",children:w.name}),w.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},w.path)}):d.jsx("div",{className:"muted explorer-empty",children:y?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:E,children:E}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!E,onClick:()=>E&&r(E),children:["Use ",N]})]})]})})}const Fl=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],kN="obsidian",vm="loadpath.theme";function NN(t){return Fl.some(r=>r.id===t)}function xm(){try{const t=localStorage.getItem(vm)||"";if(NN(t))return t}catch{}return kN}function jN(t){var r;return((r=Fl.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function wm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=jN(t);try{localStorage.setItem(vm,t)}catch{}}const qu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:h0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:p0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:g0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:m0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:y0}];function bN(t){const r=t.total||0;return r<=0?null:Math.min(100,Math.round(100*(t.done||0)/r))}function Ku(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function EN(){var uo,co,_i,fo,ho,po,Si,Xr,rn,on;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,v]=L.useState(null),[x,y]=L.useState(null),[m,_]=L.useState(null),[k,b]=L.useState([]),[E,N]=L.useState("review"),[P,w]=L.useState(""),[j,$]=L.useState(""),[D,B]=L.useState(null),[Y,Q]=L.useState(!1),[ne,ee]=L.useState(!1),[te,q]=L.useState(""),[C,V]=L.useState({}),[W,U]=L.useState([]),[M,z]=L.useState([]),[F,R]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[A,ie]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[oe,fe]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[he,pe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[Z,se]=L.useState(0),[me,Ne]=L.useState(""),[ve,re]=L.useState(xm),[je,Me]=L.useState(!1),[Re,Ae]=L.useState(!1),[st,lt]=L.useState(!1),[at,Ye]=L.useState(null),[wt,qt]=L.useState(null),[gt,mt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[Pt,ut]=L.useState(null),[Je,An]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[Ot,xn]=L.useState([]),[ro,$n]=L.useState(null),[yi,ir]=L.useState(null),[$r,zn]=L.useState(null),[zr,or]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[sr,Ft]=L.useState(null),[ct,Dn]=L.useState(null),[On,wn]=L.useState(!1),[Fn,_n]=L.useState(!1),rt=L.useRef(o);rt.current=o;const Dr=L.useRef(!1);Dr.current=Re;const _t=L.useRef(""),lr=L.useRef(""),Sn=I=>{re(I),wm(I)},dt=L.useRef(""),He=I=>{dt.current=I,$(I)},kn=I=>{const G=()=>{Pe.indexProgress(I).then(Se=>{dt.current&&(Se.phase&&Se.phase!=="idle"&&Se.message&&He(Se.message),B(Se.phase&&Se.phase!=="idle"?bN(Se):null))}).catch(()=>{})};G();const de=window.setInterval(G,250);return()=>{window.clearInterval(de),B(null)}};L.useEffect(()=>{Pe.settings().then(V).catch(()=>{}).finally(()=>Me(!0)),Pe.repos().then(I=>b(I.repos)).catch(()=>{})},[]);const Nn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const I=o;let G=!1;return lr.current!==I&&Bn(I),Pe.config(I).then(de=>{!G&&rt.current===I&&ir(de)}).catch(()=>{}),Pe.architectureHealth(I).then(de=>{!G&&rt.current===I&&zn(de)}).catch(()=>{}),()=>{G=!0}},[t,o]);const Ht=I=>{rt.current=I,s(I),localStorage.setItem("loadpath.repo",I),I.trim()!==_t.current&&(_t.current="",Ft(null))},Or=L.useCallback(I=>{const G=(I??rt.current).trim();return!G||_t.current===G?Promise.resolve():(_t.current=G,Pe.gitRefs(G).then(de=>{rt.current.trim()===G&&Ft(de)}).catch(()=>{_t.current===G&&(_t.current="",Ft(null))}))},[]),nn=(I,G)=>{u(I),h(G),localStorage.setItem("loadpath.base",I),localStorage.setItem("loadpath.head",G)},Fr=(I,G,de)=>{ie(I),R(G),localStorage.setItem("loadpath.provider",I),localStorage.setItem("loadpath.scmRepo",G),de!==void 0&&(fe(de),localStorage.setItem("loadpath.prNumber",de))},yt=I=>{v(I),se(0),Ye(wt&&I.nodes.some(G=>G.id===wt)?wt:null),ut(null),$n(null),I.what_if||(y(I),I.id&&localStorage.setItem("loadpath.lastReviewId",I.id))},Hn=async I=>{try{const G=await Pe.reviews(I);xn(G.reviews)}catch{xn([])}},ar=async I=>{try{zn(await Pe.architectureHealth(I))}catch{zn(null)}},io=I=>I==="github"?!!C.github_token_set:I==="gitlab"?!!C.gitlab_token_set:!!C.bitbucket_token_set,It=L.useCallback(async(I=A)=>{var G;try{const de=await Pe.scmRepos(I);z(de.repos),(G=de.user)!=null&&G.login&&V(Se=>({...Se,...I==="github"?{github_user:de.user.login}:I==="gitlab"?{gitlab_user:de.user.login}:{bitbucket_user:de.user.login}}))}catch{z([])}},[A]);L.useEffect(()=>{if(t!=="prs")return;let I=!1;return It(A).catch(()=>{I||z([])}),()=>{I=!0}},[t,A,It]),L.useEffect(()=>{if(!ct)return;let I=!1,G=0;const de=async()=>{try{const Se=await Pe.githubOAuthPoll(ct.flow_id);if(I)return;if(Se.status==="complete"){Dn(null);const Le=await Pe.settings();V(Le),q(Se.user?`Signed in to GitHub as ${Se.user}`:"Signed in to GitHub"),It("github");return}if(Se.status==="pending"||Se.status==="slow_down"){G=window.setTimeout(de,Math.max(Se.interval||ct.interval,5)*1e3);return}Dn(null),w(Se.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(Se){if(I)return;Dn(null),w(Se instanceof Error?Se.message:String(Se))}};return G=window.setTimeout(de,Math.max(ct.interval,5)*1e3),()=>{I=!0,window.clearTimeout(G)}},[ct,It]),L.useEffect(()=>{if(!On)return;let I=!1,G=0;const de=Date.now(),Se=async()=>{try{const Le=await Pe.oauthStatus();if(I)return;if(Le.bitbucket.connected){wn(!1);const De=await Pe.settings();V(De),q(Le.bitbucket.user?`Signed in to Bitbucket as ${Le.bitbucket.user}`:"Signed in to Bitbucket"),It("bitbucket");return}if(Date.now()-de>18e4){wn(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}G=window.setTimeout(Se,1500)}catch(Le){if(I)return;wn(!1),w(Le instanceof Error?Le.message:String(Le))}};return G=window.setTimeout(Se,1500),()=>{I=!0,window.clearTimeout(G)}},[On,It]),L.useEffect(()=>{if(!Fn)return;let I=!1,G=0;const de=Date.now(),Se=async()=>{try{const Le=await Pe.oauthStatus();if(I)return;if(Le.gitlab.connected){_n(!1);const De=await Pe.settings();V(De),q(Le.gitlab.user?`Signed in to GitLab as ${Le.gitlab.user}`:"Signed in to GitLab"),It("gitlab");return}if(Date.now()-de>18e4){_n(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}G=window.setTimeout(Se,1500)}catch(Le){if(I)return;_n(!1),w(Le instanceof Error?Le.message:String(Le))}};return G=window.setTimeout(Se,1500),()=>{I=!0,window.clearTimeout(G)}},[Fn,It]);const Bn=async(I=o,G=!1)=>{if(!I.trim())return null;lr.current=I,ee(!0);try{const de=await Pe.architecture(I,!1);rt.current===I&&_(de);const Se=Pe.architectureGraph(I).then(Le=>{rt.current===I&&_(De=>De&&{...De,nodes:Le.nodes,edges:Le.edges,graph_pending:!1})});return Se.catch(()=>{}).finally(()=>{rt.current===I&&ee(!1)}),G&&await Se,de}catch(de){throw rt.current===I&&ee(!1),de}},Hr=async I=>{const G=I.trim();if(!(!G||G===rt.current)){if(dt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),q(""),v(null),y(null),_(null),N("architecture"),Ht(G),Q(!0),He(`Loading ${f0(G)}…`);try{await Promise.all([Bn(G),Or(G)])}catch(de){rt.current===G&&w(de instanceof Error?de.message:String(de))}finally{rt.current===G&&(He(""),Q(!1))}}},jn=async()=>{if(dt.current||!Nn())return;w(""),q(""),He("Tracing load path…"),Ht(o),nn(a,c);const I=kn(o);try{const G=await Pe.review(o,a,c,!0,he);yt(G),N("review"),r("review"),await Pe.repos().then(de=>b(de.repos)).catch(()=>{}),await Promise.all([Bn(o),Hn(o),ar(o)])}catch(G){w(G instanceof Error?G.message:String(G))}finally{I(),He("")}},Br=async(I=!0)=>{if(dt.current||!Nn())return;w(""),q(""),He(I?"Indexing…":"Full reindex…"),Ht(o);const G=kn(o);try{await Pe.index(o,I);const de=await Bn(o);await Pe.repos().then(Se=>b(Se.repos)).catch(()=>{}),de!=null&&de.indexed&&(N("architecture"),r("architecture"))}catch(de){w(de instanceof Error?de.message:String(de))}finally{G(),He("")}},vi=async()=>{if(!dt.current&&Nn()){w(""),q(""),He("Detecting layout…"),Ht(o);try{const I=await Pe.init(o);q(I.message),await Pe.repos().then(G=>b(G.repos)).catch(()=>{})}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},Ve=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),q("Copied markdown brief")}catch(I){w(I instanceof Error?I.message:String(I))}},oo=async()=>{if(!dt.current){if(p!=null&&p.what_if){w("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first.");return}if(!(p!=null&&p.markdown)||!F||!oe){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const I=await Pe.postComment(A,F,Number(oe),p.markdown);q(I.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},Vr=async()=>{if(!dt.current){w(""),He("Fetching pull requests…");try{const I=await Pe.prs(A,F,"open",o.trim()||void 0);U(I.pull_requests);const G=M.find(de=>de.slug.toLowerCase()===F.trim().toLowerCase());G!=null&&G.local_path&&Ht(G.local_path)}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},xi=async()=>{w("");try{const I=await Pe.githubOAuthStart();Dn(I),Ku(I.verification_uri_complete,"github.com","/login/device")}catch(I){w(I instanceof Error?I.message:String(I))}},ur=async()=>{w("");try{const I=await Pe.bitbucketOAuthStart();wn(!0),Ku(I.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(I){wn(!1),w(I instanceof Error?I.message:String(I))}},so=async()=>{w("");try{const I=await Pe.gitlabOAuthStart();_n(!0),Ku(I.authorize_url,new URL(I.authorize_url).hostname,"/oauth/authorize")}catch(I){_n(!1),w(I instanceof Error?I.message:String(I))}},cr=async I=>{if(!(dt.current||!o.trim())){w(""),He("Walking what-if path…");try{const G=await Pe.whatIf(o,I);q(`${G.title} — ${G.confidence.level} · ${(G.sinks||[]).length} sinks`),yt({...G,markdown:G.markdown||"",index:G.index||(p==null?void 0:p.index),workspace:G.workspace||(p==null?void 0:p.workspace)}),N("review"),r("review")}catch(G){w(G instanceof Error?G.message:String(G))}finally{He("")}}},Vn=()=>{if(x){yt(x),N("review"),r("review"),q("Restored the last git-range walk");return}v(null),se(0),Ye(null),ut(null),$n(null),N("architecture"),r("architecture"),q("")},bt=async I=>{var Le;if(dt.current)return;Fr(I.provider,I.repo,String(I.number));const G=M.find(De=>De.slug.toLowerCase()===I.repo.toLowerCase());G!=null&&G.local_path&&Ht(G.local_path),w(""),He(`Fetching ${I.provider} #${I.number}…`);const de=(G==null?void 0:G.local_path)||o,Se=de?kn(de):()=>{};try{const De=await Pe.reviewPr(I.provider,I.repo,I.number,(G==null?void 0:G.local_path)||o||void 0);yt(De),De.pull_request&&typeof De.pull_request.repo_path=="string"&&Ht(De.pull_request.repo_path),nn(String(De.base||I.target_branch),String(De.head||I.source_branch)),N("review"),r("review"),typeof((Le=De.pull_request)==null?void 0:Le.repo_path)=="string"&&Hn(De.pull_request.repo_path)}catch(De){nn(I.base_sha||I.target_branch,I.head_sha||I.source_branch),r("review"),w(De instanceof Error?De.message:String(De))}finally{Se(),He("")}},Wr=async I=>{w("");try{V(await Pe.oauthDisconnect(I)),A===I&&z([]),q(`Disconnected ${I}`)}catch(G){w(G instanceof Error?G.message:String(G))}},Et=async I=>{I.preventDefault();const G=new FormData(I.currentTarget),de={github_token:String(G.get("github_token")||""),github_oauth_client_id:String(G.get("github_oauth_client_id")||""),github_host:String(G.get("github_host")||""),gitlab_token:String(G.get("gitlab_token")||""),gitlab_host:String(G.get("gitlab_host")||""),gitlab_oauth_client_id:String(G.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(G.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(G.get("bitbucket_token")||""),bitbucket_username:String(G.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(G.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(G.get("bitbucket_oauth_client_secret")||""),ai_provider:String(G.get("ai_provider")||"none"),ai_api_key:String(G.get("ai_api_key")||""),ai_model:String(G.get("ai_model")||""),ai_base_url:String(G.get("ai_base_url")||"")},Se=k.length?{...de,workspaces:k.map(Le=>({path:Le.path,name:Le.name}))}:de;try{V(await Pe.saveSettings(Se)),q("Settings saved on this machine")}catch(Le){w(Le instanceof Error?Le.message:String(Le))}},lo=async()=>{if(!(!p||dt.current)){He("Residual analysis…");try{const I=await Pe.residual(p);Ne(I.note)}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},Ur=L.useRef(jn);Ur.current=jn;const Gr=L.useRef(t);Gr.current=t;const Wn=L.useRef(!1);Wn.current=st;const Un=L.useRef(p);Un.current=p;const bn=L.useRef(Z);bn.current=Z,L.useEffect(()=>{const I=localStorage.getItem("loadpath.lastReviewId"),G=(localStorage.getItem("loadpath.repo")||"").trim();if(!I||!G){or(!1);return}let de=!1;return Pe.getReview(G,I).then(Se=>{de||(yt(Se),nn(Se.base||localStorage.getItem("loadpath.base")||"HEAD~1",Se.head||localStorage.getItem("loadpath.head")||"HEAD"),Hn(G),ar(G))}).catch(()=>{}).finally(()=>{de||or(!1)}),()=>{de=!0}},[]);const Bt=L.useRef("");L.useEffect(()=>{if(!Je||!o.trim())return;let I=!1;const G=async()=>{try{const Se=await Pe.workspaceStatus(o);if(I)return;Bt.current&&Se.fingerprint!==Bt.current&&!dt.current&&(pe(!0),localStorage.setItem("loadpath.dirty","1"),Ur.current()),Bt.current=Se.fingerprint}catch{}};G();const de=window.setInterval(G,2e3);return()=>{I=!0,window.clearInterval(de)}},[Je,o]),L.useEffect(()=>{const I=G=>{var Le;if((G.metaKey||G.ctrlKey)&&G.key.toLowerCase()==="k"){G.preventDefault(),lt(De=>!De);return}if(Wn.current){G.key==="Escape"&&(G.preventDefault(),lt(!1));return}if(Dr.current){G.key==="Escape"&&(G.preventDefault(),Ae(!1));return}const de=G.target;if(de&&(de.tagName==="INPUT"||de.tagName==="TEXTAREA"||de.tagName==="SELECT"||de.isContentEditable)){G.key==="Escape"&&de.blur();return}if(G.key==="Escape"){w(""),q(""),Ye(wt),ut(null);return}if(G.key==="j"||G.key==="k"){const De=((Le=Un.current)==null?void 0:Le.read_order)||[];if(!De.length)return;G.preventDefault();const pr=bn.current,ta=G.key==="j"?Math.min(De.length-1,pr+1):Math.max(0,pr-1);se(ta);return}const Se=qu.find(De=>De.shortcut===G.key);if(Se&&!G.metaKey&&!G.ctrlKey&&!G.altKey&&r(Se.id),(G.metaKey||G.ctrlKey)&&G.key==="Enter"){if(Gr.current==="settings"||Gr.current==="prs"||dt.current)return;G.preventDefault(),Ur.current()}};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[wt]);const wi=async(I,G)=>{if(!o.trim())return;const de=await mN(o,I,G);de.ok?q(de.message):w(de.message)},Yr=async()=>{if(p)try{const I=await Pe.exportHtml(p),G=URL.createObjectURL(I),de=document.createElement("a");de.href=G,de.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,de.click(),URL.revokeObjectURL(G),q("Saved HTML brief")}catch(I){w(I instanceof Error?I.message:String(I))}},dr=async I=>{if(o.trim()){He("Loading stored review…");try{const G=await Pe.getReview(o,I);yt(G),nn(G.base||a,G.head||c),N("review"),r("review");const de=Ot.find(Se=>Se.id!==I);if(de)try{$n(await Pe.reviewDiff(o,I,de.id))}catch{$n(null)}}catch(G){w(G instanceof Error?G.message:String(G))}finally{He("")}}},fr={selectedId:at,onSelect:Ye,nodeRoles:p==null?void 0:p.node_roles,testOverlay:gt,isolateSource:Pt,onIsolate:ut,repoPath:o,onOpenFile:wi,pinnedId:wt,onPin:qt},Gn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},...p!=null&&p.what_if?[{id:"exit-whatif",group:"Review",label:x?"Back to git-range walk":"Exit what-if walk",run:Vn}]:[],{id:"index",group:"Run",label:"Index repository",run:()=>void Br(!0)},{id:"watch",group:"Run",label:Je?"Stop watching working tree":"Watch working tree",run:()=>{const I=!Je;An(I),localStorage.setItem("loadpath.watch",I?"1":"0")}},{id:"tests",group:"Graph",label:gt?"Hide test overlay":"Show test overlay",run:()=>{const I=!gt;mt(I),localStorage.setItem("loadpath.testOverlay",I?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Yr()},...qu.map(I=>({id:`tab-${I.id}`,group:"Tabs",label:`Go to ${I.label}`,hint:I.shortcut,run:()=>r(I.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(I=>({id:`node-${I.id}`,group:"Nodes",label:I.name,hint:no(I.type),run:()=>{Ye(I.id),r("graph")}})),...Ot.slice(0,12).map(I=>({id:`hist-${I.id}`,group:"History",label:I.title||I.id,hint:`${I.level||""} ${I.created_at||""}`.trim(),run:()=>void dr(I.id)}))],En=L.useMemo(()=>E==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[E,m,p]),ao=L.useMemo(()=>E==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[E,m,p]),hr=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Fe=((p==null?void 0:p.findings)||[]).filter(I=>!I.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),qu.map(I=>{const G=I.icon,de=t===I.id;return d.jsxs("button",{type:"button","data-testid":I.testId,className:de?"nav-item active":"nav-item","aria-current":de?"page":void 0,"aria-label":I.label,onClick:()=>r(I.id),children:[d.jsx(G,{}),d.jsx("span",{children:I.label})]},I.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:ve,onChange:I=>Sn(I.target.value),children:["dark","light"].map(I=>d.jsx("optgroup",{label:I==="dark"?"Dark":"Light",children:Fl.filter(G=>G.group===I).map(G=>d.jsx("option",{value:G.id,children:G.label},G.id))},I))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:j||hr}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[j?d.jsxs("div",{className:D!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","data-testid":"progress",children:[d.jsx("i",{style:D!=null?{width:`${D}%`}:void 0}),d.jsx("span",{className:"sr-only",children:j})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[k.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:k.some(I=>I.path===o)?o:"",disabled:!!j,"aria-busy":Y,onChange:I=>{I.target.value&&Hr(I.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),k.map(I=>d.jsxs("option",{value:I.path,children:[I.name,I.indexed?` (${I.counts.nodes})`:""]},I.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:I=>{const G=I.target.value;s(G),G.trim()!==_t.current&&(_t.current="",Ft(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>Ae(!0),children:d.jsx(jp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(_p,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:I=>nn(I,c),placeholder:"base",refs:sr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(_p,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:I=>nn(a,I),placeholder:"head",refs:sr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:he?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":he,onClick:()=>{const I=!he;pe(I),localStorage.setItem("loadpath.dirty",I?"1":"0")},children:he?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:Je?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":Je,onClick:()=>{const I=!Je;An(I),localStorage.setItem("loadpath.watch",I?"1":"0")},children:Je?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.what_if?"what-if · ":"",p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!j,onClick:vi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!j,onClick:()=>Br(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!j,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[P?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:P}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,te?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:te}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>q(""),"aria-label":"Dismiss",children:"×"})]}):null,((uo=p==null?void 0:p.index)!=null&&uo.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((co=p==null?void 0:p.index)==null?void 0:co.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((_i=p==null?void 0:p.index)==null?void 0:_i.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(fo=p==null?void 0:p.workspace)!=null&&fo.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,p!=null&&p.what_if?d.jsxs("div",{className:"banner whatif","data-testid":"whatif-banner",children:[d.jsxs("span",{children:["Hypothetical walk from"," ",d.jsx("strong",{children:((ho=p.node)==null?void 0:ho.name)||"this node"}),". Loadpath ignored Base/Head and asked which sinks would feel this node change — not a filter of the current map."]}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-exit-whatif",onClick:Vn,children:x?"Back to git range":"Back to architecture"})]}):null,Y?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:j||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":Y||ne,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(CN,{review:p,findings:Fe,aiNote:me,busy:!!j,tourIndex:Z,onTour:se,onAskAi:lo,onCopy:Ve,onPost:oo,onSelect:Ye,onOpenFile:wi,onExport:Yr,history:Ot,diff:ro,onReopen:dr,onWaiver:(I,G)=>{o.trim()&&Pe.addWaiver(o,I,G||void 0,"from review").then(de=>{ir(de),q(`Waived ${I} in loadpath.yml`)})}}):zr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Xu,{nodes:p.nodes,edges:p.edges,onWhatIf:cr,focusPath:(po=p.read_order[Z])==null?void 0:po.path,...fr}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(MN,{architecture:m,busy:!!j,onReindex:()=>Br(!1),onReview:jn,onSelect:Ye,config:yi,health:$r,onSaveConfig:I=>{Pe.saveConfig(o,I).then(G=>{ir(G),q("Wrote loadpath.yml")})},onWaiver:(I,G,de)=>{Pe.addWaiver(o,I,G,de).then(Se=>{ir(Se),q(`Waived ${I}`)})}}):Y?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(ne||m!=null&&m.graph_pending)&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(Si=m==null?void 0:m.counts)!=null&&Si.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Xu,{nodes:m.nodes,edges:m.edges,onWhatIf:cr,...fr,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":E==="review","data-testid":"graph-mode-review",className:E==="review"?"active":"",onClick:()=>N("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":E==="architecture","data-testid":"graph-mode-architecture",className:E==="architecture"?"active":"",onClick:()=>N("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:gt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":gt,onClick:()=>{const I=!gt;mt(I),localStorage.setItem("loadpath.testOverlay",I?"1":"0")},children:"Tests"})]}),En.length?d.jsx(Xu,{nodes:En,edges:ao,onWhatIf:cr,...fr}):ne||m!=null&&m.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:A,onChange:I=>Fr(I.target.value,F,oe),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:M.length?"Search your repos":"owner/repo",value:F,onChange:I=>Fr(A,I.target.value,oe),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:M.map(I=>d.jsxs("option",{value:I.slug,children:[I.private?"private":"public",I.local_path?" · local":""]},I.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!j||!io(A),onClick:()=>{It(A)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!j,onClick:Vr,children:"List PRs"})]}),M.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[M.length," ",A," repositor",M.length===1?"y":"ies",A==="github"&&C.github_user?` · @${String(C.github_user)}`:"",A==="gitlab"&&C.gitlab_user?` · @${String(C.gitlab_user)}`:"",A==="bitbucket"&&C.bitbucket_user?` · ${String(C.bitbucket_user)}`:""]}):null,W.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):W.map(I=>{var G;return d.jsxs("article",{className:"pr","data-testid":`pr-${I.number}`,children:[d.jsxs("h3",{children:["#",I.number," ",I.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${I.draft?"":"open"}`,children:I.draft?"draft":I.state}),d.jsx("span",{children:I.author}),d.jsxs("span",{children:[I.source_branch," → ",I.target_branch]}),I.loadpath?d.jsxs("span",{className:`chip ${I.loadpath.level||""}`,"data-testid":`pr-loadpath-${I.number}`,children:[((G=I.loadpath.level)==null?void 0:G.toUpperCase())||"REVIEWED",I.loadpath.contract_break&&I.loadpath.contract_break!=="none"?` · ${I.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:I.url,target:"_blank",rel:"noreferrer",children:["Open on ",I.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${I.number}`,onClick:()=>void bt(I),children:"Review this PR"})]})]},`${I.provider}-${I.number}`)})]}),t==="settings"&&je&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Et,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Fl.map(I=>d.jsxs("button",{type:"button","data-theme":I.id,className:ve===I.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${I.id}`,onClick:()=>Sn(I.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:I.label}),d.jsx("div",{className:"group",children:I.group})]},I.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:ym(),onChange:I=>gN(I.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:C.github_token_set?C.github_user?`Signed in as @${String(C.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void Wr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!ct||!C.github_oauth_ready,onClick:()=>void xi(),children:ct?"Waiting for GitHub…":"Sign in with GitHub"})})]}),ct?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:ct.user_code})," at GitHub if the browser did not fill it in."]}):null,C.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(C.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(C.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:C.gitlab_token_set?C.gitlab_user?`Signed in as @${String(C.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void Wr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Fn||!C.gitlab_oauth_ready,onClick:()=>void so(),children:Fn?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(C.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(C.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:C.bitbucket_token_set?C.bitbucket_user?`Signed in as ${String(C.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void Wr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:On||!C.bitbucket_oauth_ready,onClick:()=>void ur(),children:On?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),C.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(C.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(C.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((Xr=C.ai)==null?void 0:Xr.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((rn=C.ai)==null?void 0:rn.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((on=C.ai)==null?void 0:on.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(u0,{open:st,actions:Gn,onClose:()=>lt(!1)}),Re?d.jsx(SN,{initialPath:o,onClose:()=>Ae(!1),onSelect:I=>{if(dt.current){w("Wait for the current job to finish before switching workspace.");return}Ae(!1),Hr(I)}}):null]})}function CN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:v,onOpenFile:x,onExport:y,history:m,diff:_,onReopen:k,onWaiver:b}){var N,P,w,j,$,D,B,Y,Q,ne,ee,te,q,C,V,W,U;const E=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),E.length?d.jsx("ul",{className:"reasons",children:E.map(M=>d.jsx("li",{children:M},M))}):null,t.what_if?d.jsx("span",{className:"chip whatif","data-testid":"whatif-chip",children:"what-if"}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Ko(M)},M)),(N=t.contract_break)!=null&&N.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>b(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(P=t.workspace)!=null&&P.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,z)=>d.jsxs("div",{className:z===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(z),children:[z+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>x(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(_m,{cards:t.deepening}),(j=(w=t.contract_break)==null?void 0:w.reasons)!=null&&j.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),(D=($=t.contract_break.sides)==null?void 0:$.rows)!=null&&D.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(B=t.auth)!=null&&B.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(Y=t.suggested_tests)==null?void 0:Y.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(Q=t.trend)!=null&&Q.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",Qu(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),m.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:m.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,m.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>k(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?Qu(M.created_at):""})]},M.id))]}):null,(ee=(ne=t.evolution)==null?void 0:ne.notes)!=null&&ee.length||(q=(te=t.evolution)==null?void 0:te.hotspots)!=null&&q.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((C=t.evolution)==null?void 0:C.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((V=t.evolution)==null?void 0:V.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:y,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",disabled:s||!!t.what_if,title:t.what_if?"Hypothetical walks are not posted to a pull request":void 0,onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(W=t.codeowners_reviewers)!=null&&W.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function MN({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var x;const v=t.findings.filter(y=>!y.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${Qu(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(y=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y.name})," — ",(y.django_apps||[]).join(", ")||"no apps"," ·"," ",(y.owners||[]).join(", ")||"unowned"]},y.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(y=>d.jsx("div",{className:"muted",children:y},y))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:v.length})]}),v.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):v.map(y=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>y.node_id&&a(y.node_id),children:[d.jsx("span",{className:`chip ${y.severity}`,children:y.severity}),y.message]})},y.rule+y.message))]}),d.jsx(_m,{cards:t.deepening}),(x=c==null?void 0:c.points)!=null&&x.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(y=>d.jsx("i",{className:y.level||"",title:`${y.level} · ${y.findings} findings`,style:{height:`${8+Math.min(24,(y.findings||0)*4)}px`}},y.id||y.created_at))}),Object.entries(c.contexts).map(([y,m])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y})," — last ",((_=m[m.length-1])==null?void 0:_.findings)??0," findings"]},y)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(c0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((y,m)=>m[1]-y[1]).slice(0,12).map(([y,m])=>d.jsxs("tr",{children:[d.jsx("td",{children:no(y)}),d.jsx("td",{children:m})]},y))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function _m({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:d0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}wm(xm());s0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(EN,{})}));export{Hk as L,RN as a,PN as c,d as j,IN as l,L as r,no as t}; diff --git a/src/loadpath/static/assets/index-Bmsup5i5.css b/src/loadpath/static/assets/index-DCcHASmi.css similarity index 79% rename from src/loadpath/static/assets/index-Bmsup5i5.css rename to src/loadpath/static/assets/index-DCcHASmi.css index 9546aef..0bba5ec 100644 --- a/src/loadpath/static/assets/index-Bmsup5i5.css +++ b/src/loadpath/static/assets/index-DCcHASmi.css @@ -1 +1 @@ -.react-flow{direction:ltr;--xy-edge-stroke-default: #b1b1b7;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #555;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(255, 255, 255, .5);--xy-minimap-background-color-default: #fff;--xy-minimap-mask-background-color-default: rgba(240, 240, 240, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #e2e2e2;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: transparent;--xy-background-pattern-dots-color-default: #91919a;--xy-background-pattern-lines-color-default: #eee;--xy-background-pattern-cross-color-default: #e2e2e2;background-color:var(--xy-background-color, var(--xy-background-color-default));--xy-node-color-default: inherit;--xy-node-border-default: 1px solid #1a192b;--xy-node-background-color-default: #fff;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #1a192b;--xy-node-border-radius-default: 3px;--xy-handle-background-color-default: #1a192b;--xy-handle-border-color-default: #fff;--xy-selection-background-color-default: rgba(0, 89, 220, .08);--xy-selection-border-default: 1px dotted rgba(0, 89, 220, .8);--xy-controls-button-background-color-default: #fefefe;--xy-controls-button-background-color-hover-default: #f4f4f4;--xy-controls-button-color-default: inherit;--xy-controls-button-color-hover-default: inherit;--xy-controls-button-border-color-default: #eee;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #ffffff;--xy-edge-label-color-default: inherit;--xy-resize-background-color-default: #3367d9}.react-flow.dark{--xy-edge-stroke-default: #3e3e3e;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #727272;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(150, 150, 150, .25);--xy-minimap-background-color-default: #141414;--xy-minimap-mask-background-color-default: rgba(60, 60, 60, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #2b2b2b;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: #141414;--xy-background-pattern-dots-color-default: #555;--xy-background-pattern-lines-color-default: #333;--xy-background-pattern-cross-color-default: #333;--xy-node-color-default: #f8f8f8;--xy-node-border-default: 1px solid #3c3c3c;--xy-node-background-color-default: #1e1e1e;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #999;--xy-handle-background-color-default: #bebebe;--xy-handle-border-color-default: #1e1e1e;--xy-selection-background-color-default: rgba(200, 200, 220, .08);--xy-selection-border-default: 1px dotted rgba(200, 200, 220, .8);--xy-controls-button-background-color-default: #2b2b2b;--xy-controls-button-background-color-hover-default: #3e3e3e;--xy-controls-button-color-default: #f8f8f8;--xy-controls-button-color-hover-default: #fff;--xy-controls-button-border-color-default: #5b5b5b;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #141414;--xy-edge-label-color-default: #f8f8f8}.react-flow__background{background-color:var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1;touch-action:none}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{overflow:visible;position:absolute;pointer-events:none}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__arrowhead polyline{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:dashdraw .5s linear infinite}svg.react-flow__connectionline{z-index:1001;overflow:visible;position:absolute}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background-color:var(--xy-handle-background-color, var(--xy-handle-background-color-default));border:1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));border-radius:100%}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:0;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__pane.selection .react-flow__panel{pointer-events:none}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.top.center,.react-flow__panel.bottom.center{left:50%;transform:translate(-15px) translate(-50%)}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.left.center,.react-flow__panel.right.center{top:50%;transform:translateY(-15px) translateY(-50%)}.react-flow__attribution{font-size:10px;background:var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;left:0;top:0}.react-flow__viewport-portal{position:absolute;width:100%;height:100%;left:0;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__minimap{background:var( --xy-minimap-background-color-props, var(--xy-minimap-background-color, var(--xy-minimap-background-color-default)) )}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var( --xy-minimap-mask-background-color-props, var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default)) );stroke:var( --xy-minimap-mask-stroke-color-props, var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default)) );stroke-width:var( --xy-minimap-mask-stroke-width-props, var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default)) )}.react-flow__minimap-node{fill:var( --xy-minimap-node-background-color-props, var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default)) );stroke:var( --xy-minimap-node-stroke-color-props, var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default)) );stroke-width:var( --xy-minimap-node-stroke-width-props, var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default)) )}.react-flow__background-pattern.dots{fill:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default)) )}.react-flow__background-pattern.lines{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default)) )}.react-flow__background-pattern.cross{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default)) )}.react-flow__controls{display:flex;flex-direction:column;box-shadow:var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default))}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{display:flex;justify-content:center;align-items:center;height:26px;width:26px;padding:4px;border:none;background:var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));border-bottom:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) );color:var( --xy-controls-button-color-props, var(--xy-controls-button-color, var(--xy-controls-button-color-default)) );cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px;fill:currentColor}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:var(--xy-node-border-radius, var(--xy-node-border-radius-default));width:150px;font-size:12px;color:var(--xy-node-color, var(--xy-node-color-default));text-align:center;border:var(--xy-node-border, var(--xy-node-border-default));background-color:var(--xy-node-background-color, var(--xy-node-background-color-default))}.react-flow__node-input.selectable:hover,.react-flow__node-default.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default))}.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default))}.react-flow__node-group{background-color:var(--xy-node-group-background-color, var(--xy-node-group-background-color-default))}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color, var(--xy-selection-background-color-default));border:var(--xy-selection-border, var(--xy-selection-border-default))}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls-button:hover{background:var( --xy-controls-button-background-color-hover-props, var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default)) );color:var( --xy-controls-button-color-hover-props, var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default)) )}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__controls-button:last-child{border-bottom:none}.react-flow__controls.horizontal .react-flow__controls-button{border-bottom:none;border-right:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) )}.react-flow__controls.horizontal .react-flow__controls-button:last-child{border-right:none}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:5px;height:5px;border:1px solid #fff;border-radius:1px;background-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));translate:-50% -50%}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}.react-flow__edge-textbg{fill:var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default))}.react-flow__edge-text{fill:var(--xy-edge-label-color, var(--xy-edge-label-color-default))}:root,[data-theme=obsidian]{--bg: #070b10;--bg-2: #0d141c;--surface: #121a24;--line: #1e2c3c;--ink: #e7eef6;--muted: #8b9bb0;--high: #2a9d8f;--medium: #e9c46a;--low: #e76f51;--critical: #e85d04;--accent: #4cc9f0;--rail-from: #0b1219;--rail-to: #070b10;--rail-active: #15202c;--btn: #173044;--btn-line: #24506c;--btn-primary: #134e4a;--btn-primary-line: #2a9d8f;--node-bg: #101822;--node-line: #2a3d52;--graph-bg: #070b10;--graph-grid: rgba(42, 80, 120, .09);--edge-cheap: #4a5568;--edge-expensive: #f4a261;--edge-critical: #e85d04;--shadow: rgba(76, 201, 240, .08)}[data-theme=nord]{--bg: #2e3440;--bg-2: #3b4252;--surface: #434c5e;--line: #4c566a;--ink: #eceff4;--muted: #d8dee9;--high: #a3be8c;--medium: #ebcb8b;--low: #bf616a;--critical: #d08770;--accent: #88c0d0;--rail-from: #3b4252;--rail-to: #2e3440;--rail-active: #4c566a;--btn: #434c5e;--btn-line: #81a1c1;--btn-primary: #5e81ac;--btn-primary-line: #88c0d0;--node-bg: #3b4252;--node-line: #81a1c1;--graph-bg: #2e3440;--graph-grid: rgba(136, 192, 208, .12);--edge-cheap: #4c566a;--edge-expensive: #d08770;--edge-critical: #bf616a;--shadow: rgba(136, 192, 208, .12)}[data-theme=solarized-dark]{--bg: #002b36;--bg-2: #073642;--surface: #0a3944;--line: #16444f;--ink: #eee8d5;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #2aa198;--rail-from: #073642;--rail-to: #002b36;--rail-active: #16444f;--btn: #073642;--btn-line: #268bd2;--btn-primary: #0a4a42;--btn-primary-line: #2aa198;--node-bg: #073642;--node-line: #268bd2;--graph-bg: #002b36;--graph-grid: rgba(42, 161, 152, .12);--edge-cheap: #586e75;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(42, 161, 152, .12)}[data-theme=forest]{--bg: #0e1510;--bg-2: #152019;--surface: #1b2a20;--line: #2c4334;--ink: #e4f0e6;--muted: #8eaa96;--high: #6ab04c;--medium: #c8a951;--low: #e17055;--critical: #d35400;--accent: #7bed9f;--rail-from: #152019;--rail-to: #0e1510;--rail-active: #1f3326;--btn: #1f3326;--btn-line: #3d6b4f;--btn-primary: #1e4d32;--btn-primary-line: #6ab04c;--node-bg: #16241b;--node-line: #3d6b4f;--graph-bg: #0e1510;--graph-grid: rgba(123, 237, 159, .1);--edge-cheap: #3d6b4f;--edge-expensive: #c8a951;--edge-critical: #d35400;--shadow: rgba(123, 237, 159, .1)}[data-theme=rose]{--bg: #191724;--bg-2: #1f1d2e;--surface: #26233a;--line: #403d52;--ink: #e0def4;--muted: #908caa;--high: #9ccfd8;--medium: #f6c177;--low: #eb6f92;--critical: #eb6f92;--accent: #c4a7e7;--rail-from: #1f1d2e;--rail-to: #191724;--rail-active: #26233a;--btn: #26233a;--btn-line: #c4a7e7;--btn-primary: #3a2f4d;--btn-primary-line: #c4a7e7;--node-bg: #1f1d2e;--node-line: #524f67;--graph-bg: #191724;--graph-grid: rgba(196, 167, 231, .12);--edge-cheap: #524f67;--edge-expensive: #f6c177;--edge-critical: #eb6f92;--shadow: rgba(196, 167, 231, .12)}[data-theme=amber]{--bg: #120e0a;--bg-2: #1c1610;--surface: #261e16;--line: #3d2f22;--ink: #f4e6d0;--muted: #b59a78;--high: #c4d6a0;--medium: #e9b44c;--low: #d8572a;--critical: #c0392b;--accent: #f0a05a;--rail-from: #1c1610;--rail-to: #120e0a;--rail-active: #2b2218;--btn: #2b2218;--btn-line: #8a5a2b;--btn-primary: #4a3418;--btn-primary-line: #f0a05a;--node-bg: #1c1610;--node-line: #8a5a2b;--graph-bg: #120e0a;--graph-grid: rgba(240, 160, 90, .12);--edge-cheap: #5c4a38;--edge-expensive: #e9b44c;--edge-critical: #d8572a;--shadow: rgba(240, 160, 90, .12)}[data-theme=volcano]{--bg: #14090a;--bg-2: #1e0e10;--surface: #2a1416;--line: #4a2226;--ink: #fde8e4;--muted: #c48b86;--high: #7bed9f;--medium: #f6c90e;--low: #ff6b6b;--critical: #ff3b3b;--accent: #ff7b54;--rail-from: #1e0e10;--rail-to: #14090a;--rail-active: #32181b;--btn: #32181b;--btn-line: #ff7b54;--btn-primary: #5a1f18;--btn-primary-line: #ff7b54;--node-bg: #1e0e10;--node-line: #7a3330;--graph-bg: #14090a;--graph-grid: rgba(255, 123, 84, .12);--edge-cheap: #5a3330;--edge-expensive: #ff7b54;--edge-critical: #ff3b3b;--shadow: rgba(255, 123, 84, .14)}[data-theme=lavender]{--bg: #12101c;--bg-2: #1a1730;--surface: #221e3c;--line: #3b3560;--ink: #efeaff;--muted: #b3a7d6;--high: #80ffdb;--medium: #ffd166;--low: #ff6b9d;--critical: #ff4d6d;--accent: #c77dff;--rail-from: #1a1730;--rail-to: #12101c;--rail-active: #2a2550;--btn: #2a2550;--btn-line: #c77dff;--btn-primary: #3d2a66;--btn-primary-line: #c77dff;--node-bg: #1a1730;--node-line: #5a4d8a;--graph-bg: #12101c;--graph-grid: rgba(199, 125, 255, .12);--edge-cheap: #5a4d8a;--edge-expensive: #ffd166;--edge-critical: #ff4d6d;--shadow: rgba(199, 125, 255, .14)}[data-theme=neon-noir]{--bg: #05060a;--bg-2: #0a0c14;--surface: #10131c;--line: #1e2436;--ink: #f0f4ff;--muted: #8b93b0;--high: #39ff88;--medium: #ffe66d;--low: #ff2d95;--critical: #ff3d5a;--accent: #00f0ff;--rail-from: #0a0c14;--rail-to: #05060a;--rail-active: #151a2a;--btn: #151a2a;--btn-line: #00f0ff;--btn-primary: #063a40;--btn-primary-line: #00f0ff;--node-bg: #0a0c14;--node-line: #2a3550;--graph-bg: #05060a;--graph-grid: rgba(0, 240, 255, .12);--edge-cheap: #3a4560;--edge-expensive: #ff2d95;--edge-critical: #ff3d5a;--shadow: rgba(0, 240, 255, .22)}[data-theme=synthwave]{--bg: #1a0a2e;--bg-2: #240b3d;--surface: #2d1250;--line: #4a1d7a;--ink: #ffe6fb;--muted: #c49ad8;--high: #00f5d4;--medium: #ffd60a;--low: #ff6b9d;--critical: #ff006e;--accent: #ff2bd6;--rail-from: #240b3d;--rail-to: #1a0a2e;--rail-active: #3a1570;--btn: #3a1570;--btn-line: #ff2bd6;--btn-primary: #5a0a4a;--btn-primary-line: #ff2bd6;--node-bg: #240b3d;--node-line: #7b2cbf;--graph-bg: #1a0a2e;--graph-grid: rgba(255, 43, 214, .16);--edge-cheap: #5a3a80;--edge-expensive: #ff9e00;--edge-critical: #ff006e;--shadow: rgba(255, 43, 214, .24)}[data-theme=phosphor]{--bg: #020804;--bg-2: #061208;--surface: #0a1a0e;--line: #163c1e;--ink: #c8ffc8;--muted: #5aaa5a;--high: #39ff14;--medium: #c8f542;--low: #ffb000;--critical: #ff5e00;--accent: #00ff66;--rail-from: #061208;--rail-to: #020804;--rail-active: #0e2414;--btn: #0e2414;--btn-line: #00ff66;--btn-primary: #0a3a18;--btn-primary-line: #00ff66;--node-bg: #061208;--node-line: #1e6a32;--graph-bg: #020804;--graph-grid: rgba(0, 255, 102, .12);--edge-cheap: #1e5a2a;--edge-expensive: #c8f542;--edge-critical: #ff5e00;--shadow: rgba(0, 255, 102, .2)}[data-theme=aurora]{--bg: #071018;--bg-2: #0c1c28;--surface: #122636;--line: #1e3d52;--ink: #e8fff6;--muted: #7eb8a8;--high: #5fffcf;--medium: #ffe566;--low: #ff7eb6;--critical: #ff4d6d;--accent: #7cffb2;--rail-from: #0c1c28;--rail-to: #071018;--rail-active: #163044;--btn: #163044;--btn-line: #7cffb2;--btn-primary: #0e3d3a;--btn-primary-line: #7cffb2;--node-bg: #0c1c28;--node-line: #2a6a78;--graph-bg: #071018;--graph-grid: rgba(124, 255, 178, .12);--edge-cheap: #2a5a68;--edge-expensive: #c9a0ff;--edge-critical: #ff4d6d;--shadow: rgba(124, 255, 178, .18)}[data-theme=biolume]{--bg: #02141c;--bg-2: #042430;--surface: #073040;--line: #0a4a5c;--ink: #e6fffb;--muted: #6eb8b0;--high: #5dffb0;--medium: #ffe066;--low: #ff79c6;--critical: #ff4d6d;--accent: #18e7d4;--rail-from: #042430;--rail-to: #02141c;--rail-active: #0a3848;--btn: #0a3848;--btn-line: #18e7d4;--btn-primary: #0a4a48;--btn-primary-line: #18e7d4;--node-bg: #042430;--node-line: #1a7080;--graph-bg: #02141c;--graph-grid: rgba(24, 231, 212, .12);--edge-cheap: #1a5a68;--edge-expensive: #ff79c6;--edge-critical: #ff4d6d;--shadow: rgba(24, 231, 212, .2)}[data-theme=carbon]{--bg: #0d0d0f;--bg-2: #16161a;--surface: #1e1e24;--line: #33333c;--ink: #f2f2f4;--muted: #9a9aa8;--high: #3dd68c;--medium: #f0c040;--low: #ff5a5a;--critical: #ff2a2a;--accent: #ff2a2a;--rail-from: #16161a;--rail-to: #0d0d0f;--rail-active: #24242c;--btn: #24242c;--btn-line: #ff2a2a;--btn-primary: #4a1212;--btn-primary-line: #ff2a2a;--node-bg: #16161a;--node-line: #4a4a55;--graph-bg: #0d0d0f;--graph-grid: rgba(255, 42, 42, .1);--edge-cheap: #4a4a55;--edge-expensive: #ff8a3d;--edge-critical: #ff2a2a;--shadow: rgba(255, 42, 42, .18)}[data-theme=paper]{--bg: #f6f1e8;--bg-2: #efe6d6;--surface: #fffaf2;--line: #d9cbb6;--ink: #2b241c;--muted: #6f6456;--high: #2a7a4b;--medium: #b5811a;--low: #c0392b;--critical: #a93226;--accent: #1d6a7a;--rail-from: #efe6d6;--rail-to: #e7dcc8;--rail-active: #e2d3bb;--btn: #fffaf2;--btn-line: #c9b79a;--btn-primary: #d7eee0;--btn-primary-line: #2a7a4b;--node-bg: #fffaf2;--node-line: #c9b79a;--graph-bg: #f6f1e8;--graph-grid: rgba(29, 106, 122, .1);--edge-cheap: #b7a48c;--edge-expensive: #c0392b;--edge-critical: #a93226;--shadow: rgba(43, 36, 28, .08)}[data-theme=solarized-light]{--bg: #fdf6e3;--bg-2: #eee8d5;--surface: #f5efdc;--line: #d6cba9;--ink: #657b83;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #268bd2;--rail-from: #eee8d5;--rail-to: #e6dfc8;--rail-active: #e0d9c0;--btn: #fdf6e3;--btn-line: #93a1a1;--btn-primary: #e8efc8;--btn-primary-line: #859900;--node-bg: #fdf6e3;--node-line: #93a1a1;--graph-bg: #fdf6e3;--graph-grid: rgba(38, 139, 210, .12);--edge-cheap: #93a1a1;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(101, 123, 131, .1)}[data-theme=seafoam]{--bg: #eef7f4;--bg-2: #dff0ea;--surface: #ffffff;--line: #b7d5cc;--ink: #17332c;--muted: #4d7268;--high: #1b8a5a;--medium: #c48a14;--low: #c44536;--critical: #9b2d22;--accent: #1d9a8a;--rail-from: #dff0ea;--rail-to: #cfe6de;--rail-active: #c4ddd4;--btn: #ffffff;--btn-line: #8fbfb2;--btn-primary: #d4f0e4;--btn-primary-line: #1b8a5a;--node-bg: #ffffff;--node-line: #8fbfb2;--graph-bg: #eef7f4;--graph-grid: rgba(29, 154, 138, .12);--edge-cheap: #8fbfb2;--edge-expensive: #c48a14;--edge-critical: #c44536;--shadow: rgba(23, 51, 44, .08)}[data-theme=high-contrast]{--bg: #ffffff;--bg-2: #f2f2f2;--surface: #ffffff;--line: #111111;--ink: #000000;--muted: #222222;--high: #007a33;--medium: #8a5a00;--low: #b00000;--critical: #9b0000;--accent: #0033cc;--rail-from: #f2f2f2;--rail-to: #e6e6e6;--rail-active: #d9d9d9;--btn: #ffffff;--btn-line: #000000;--btn-primary: #d9f2e3;--btn-primary-line: #007a33;--node-bg: #ffffff;--node-line: #000000;--graph-bg: #ffffff;--graph-grid: rgba(0, 0, 0, .12);--edge-cheap: #444444;--edge-expensive: #8a5a00;--edge-critical: #b00000;--shadow: rgba(0, 0, 0, .12)}[data-theme=sakura]{--bg: #fff0f5;--bg-2: #ffe4ee;--surface: #fff7fa;--line: #f5b8cc;--ink: #4a1830;--muted: #a05a78;--high: #1a8a5c;--medium: #c48a14;--low: #d63d6e;--critical: #b01040;--accent: #e84a8a;--rail-from: #ffe4ee;--rail-to: #f8d4e0;--rail-active: #f5c8d8;--btn: #fff7fa;--btn-line: #e89ab0;--btn-primary: #ffd6e6;--btn-primary-line: #e84a8a;--node-bg: #fff7fa;--node-line: #e89ab0;--graph-bg: #fff0f5;--graph-grid: rgba(232, 74, 138, .12);--edge-cheap: #d4a0b0;--edge-expensive: #d63d6e;--edge-critical: #b01040;--shadow: rgba(74, 24, 48, .1)}[data-theme=citrus]{--bg: #fffce8;--bg-2: #fff3b0;--surface: #fffef5;--line: #e8d44a;--ink: #2a2a08;--muted: #6a6a20;--high: #2a8a20;--medium: #d4a000;--low: #e85d04;--critical: #c0392b;--accent: #5aad14;--rail-from: #fff3b0;--rail-to: #ffe98a;--rail-active: #ffe066;--btn: #fffef5;--btn-line: #d4c030;--btn-primary: #e8f5b8;--btn-primary-line: #5aad14;--node-bg: #fffef5;--node-line: #d4c030;--graph-bg: #fffce8;--graph-grid: rgba(90, 173, 20, .14);--edge-cheap: #c4b040;--edge-expensive: #e85d04;--edge-critical: #c0392b;--shadow: rgba(42, 42, 8, .1)}[data-theme=peach]{--bg: #fff3eb;--bg-2: #ffe0cc;--surface: #fffaf6;--line: #f0c4a8;--ink: #3a2218;--muted: #8a5a48;--high: #2a8a5c;--medium: #d48a14;--low: #e85d3a;--critical: #c0392b;--accent: #ff6b35;--rail-from: #ffe0cc;--rail-to: #ffd4b8;--rail-active: #ffc8a8;--btn: #fffaf6;--btn-line: #e8a888;--btn-primary: #ffe0cc;--btn-primary-line: #ff6b35;--node-bg: #fffaf6;--node-line: #e8a888;--graph-bg: #fff3eb;--graph-grid: rgba(255, 107, 53, .12);--edge-cheap: #d4a088;--edge-expensive: #e85d3a;--edge-critical: #c0392b;--shadow: rgba(58, 34, 24, .1)}[data-theme=candy]{--bg: #f4f0ff;--bg-2: #e8dcff;--surface: #fbf8ff;--line: #d4c0f0;--ink: #2a1848;--muted: #6a5890;--high: #1a8a6a;--medium: #c48a14;--low: #e84a8a;--critical: #c01060;--accent: #ff5eb1;--rail-from: #e8dcff;--rail-to: #ddd0ff;--rail-active: #d4c4ff;--btn: #fbf8ff;--btn-line: #c4a8e8;--btn-primary: #ffd6ec;--btn-primary-line: #ff5eb1;--node-bg: #fbf8ff;--node-line: #c4a8e8;--graph-bg: #f4f0ff;--graph-grid: rgba(255, 94, 177, .14);--edge-cheap: #b0a0d0;--edge-expensive: #e84a8a;--edge-critical: #c01060;--shadow: rgba(42, 24, 72, .1)}[data-theme=sky]{--bg: #e8f4ff;--bg-2: #cfe8ff;--surface: #f5faff;--line: #90c8f0;--ink: #0a2848;--muted: #3a6080;--high: #0a8a4a;--medium: #c48a14;--low: #e85d3a;--critical: #c0392b;--accent: #0077ff;--rail-from: #cfe8ff;--rail-to: #b8dcff;--rail-active: #a8d4ff;--btn: #f5faff;--btn-line: #70b0e0;--btn-primary: #cfe8ff;--btn-primary-line: #0077ff;--node-bg: #f5faff;--node-line: #70b0e0;--graph-bg: #e8f4ff;--graph-grid: rgba(0, 119, 255, .12);--edge-cheap: #80b0d0;--edge-expensive: #e85d3a;--edge-critical: #c0392b;--shadow: rgba(10, 40, 72, .1)}[data-theme=coral]{--bg: #fff1ee;--bg-2: #ffddd6;--surface: #fff8f6;--line: #f0b0a4;--ink: #3a1814;--muted: #8a5048;--high: #0d9488;--medium: #d48a14;--low: #e85d4a;--critical: #c0392b;--accent: #0d9488;--rail-from: #ffddd6;--rail-to: #ffd0c6;--rail-active: #ffc4b8;--btn: #fff8f6;--btn-line: #e89888;--btn-primary: #d4f4ee;--btn-primary-line: #0d9488;--node-bg: #fff8f6;--node-line: #e89888;--graph-bg: #fff1ee;--graph-grid: rgba(13, 148, 136, .14);--edge-cheap: #d4a098;--edge-expensive: #e85d4a;--edge-critical: #c0392b;--shadow: rgba(58, 24, 20, .1)}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}:root{--radius: 6px;--radius-lg: 10px;--control-h: 32px;--font: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;--mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;--focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);--space: 8px}body{background:var(--bg);color:var(--ink);font-family:var(--font);font-size:13px;line-height:1.45;-webkit-font-smoothing:antialiased}button,input,select,textarea{font-family:inherit;font-size:inherit;color:inherit}button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,a:focus-visible,summary:focus-visible{outline:none;box-shadow:var(--focus-ring)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.skip{position:absolute;left:12px;top:-40px;z-index:50;background:var(--surface);color:var(--ink);border:1px solid var(--accent);border-radius:var(--radius);padding:8px 12px}.skip:focus{top:12px}.app{display:grid;grid-template-columns:232px 1fr;height:100%}.rail{border-right:1px solid var(--line);background:linear-gradient(180deg,var(--rail-from),var(--rail-to));padding:16px 12px;display:flex;flex-direction:column;gap:2px;min-width:0}.brand{display:flex;flex-direction:column;gap:2px;padding:4px 8px 16px}.brand-mark{font-family:var(--mono);letter-spacing:.16em;font-size:11px;text-transform:uppercase;color:var(--accent);font-weight:600}.brand-sub{font-size:11px;color:var(--muted)}.nav-item{display:flex;align-items:center;gap:10px;background:transparent;border:0;text-align:left;padding:8px 10px;border-radius:var(--radius);color:var(--muted);cursor:pointer;width:100%}.nav-item:hover{background:color-mix(in srgb,var(--rail-active) 70%,transparent);color:var(--ink)}.nav-item.active{background:var(--rail-active);color:var(--ink);font-weight:500}.nav-item svg{flex-shrink:0}.theme-pick{margin-top:14px;display:grid;gap:4px;padding:0 2px}.theme-pick label{font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);font-weight:500}.theme-pick select,.field select,.field input,.topbar input,.topbar select,.settings input,.settings select,.explorer-path input{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:0 10px;height:var(--control-h);width:100%}.rail-foot{margin-top:auto;padding:12px 8px 4px;border-top:1px solid var(--line);display:grid;gap:6px}.kbd-hint{font-size:11px;color:var(--muted)}kbd{font-family:var(--mono);font-size:10px;border:1px solid var(--line);border-radius:4px;padding:0 4px;background:var(--surface)}.main{display:flex;flex-direction:column;min-width:0;min-height:0;position:relative;background:var(--bg)}.progress{position:absolute;top:0;left:0;right:0;height:2px;overflow:hidden;z-index:30;background:color-mix(in srgb,var(--accent) 20%,transparent)}.progress i{display:block;height:100%;width:32%;background:var(--accent);animation:indeterminate 1.1s ease-in-out infinite}.progress.determinate i{width:0;animation:none;transform:none;transition:width .2s ease-out}@keyframes indeterminate{0%{transform:translate(-120%)}to{transform:translate(400%)}}.topbar{display:flex;gap:10px;align-items:flex-end;padding:10px 16px;border-bottom:1px solid var(--line);background:var(--bg-2);flex-wrap:wrap}.field{display:grid;gap:4px;min-width:0}.field>span{font-size:11px;color:var(--muted);font-weight:500}.field.path{flex:1;min-width:180px}.field.ref{width:188px;flex:0 0 188px}.field.workspace{width:180px;flex:0 0 180px}.path-row,.combo-row{display:flex;min-width:0}.path-row input,.combo-row input{flex:1;min-width:0}.combo{position:relative;min-width:0}.combo-row input{border-top-right-radius:0;border-bottom-right-radius:0}.topbar .icon-btn{width:var(--control-h);padding:0;flex:0 0 var(--control-h)}.combo-toggle{border-top-left-radius:0;border-bottom-left-radius:0;border-left:0}.combo-menu{position:absolute;top:calc(100% + 4px);right:0;left:auto;min-width:340px;max-width:min(480px,70vw);max-height:360px;overflow:auto;z-index:40;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:0 12px 32px var(--shadow);padding:6px 0}.combo-heading{font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);font-weight:600;padding:8px 12px 4px}.combo-menu .combo-option{display:flex;flex-direction:column;align-items:flex-start;gap:2px;width:100%;text-align:left;background:transparent;border:0;border-radius:0;height:auto;padding:6px 12px;color:var(--ink);cursor:pointer}.combo-menu .combo-option:hover,.combo-menu .combo-option.active{background:var(--rail-active)}.combo-label{font-family:var(--mono);font-size:12px}.combo-detail{color:var(--muted);font-size:12px;line-height:1.35;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}.combo-empty{padding:10px 12px}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:50;background:color-mix(in srgb,var(--bg) 72%,transparent);display:grid;place-items:center;padding:24px}.modal{width:min(720px,100%);max-height:min(640px,90vh);background:var(--bg-2);border:1px solid var(--line);border-radius:var(--radius-lg);box-shadow:0 16px 48px var(--shadow);display:flex;flex-direction:column;overflow:hidden}.modal-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:14px 16px 10px;border-bottom:1px solid var(--line)}.modal-head h2{font-size:15px}.modal-head .muted{margin:4px 0 0}.explorer-path{display:flex;gap:8px;padding:12px 16px;border-bottom:1px solid var(--line)}.explorer-path input{flex:1;min-width:0}.explorer-list{flex:1;overflow:auto;padding:8px;min-height:220px}.explorer-row{display:flex;align-items:center;gap:8px;width:100%;text-align:left;background:transparent;border:0;border-radius:var(--radius);padding:8px 10px;color:var(--ink);cursor:pointer;height:auto}.explorer-row:hover,.explorer-row.active{background:var(--rail-active)}.explorer-name{min-width:0;overflow:hidden;text-overflow:ellipsis}.git-badge{margin-left:auto;margin-bottom:0}.explorer-empty{padding:18px 10px}.modal-foot{display:flex;align-items:center;gap:12px;padding:12px 16px;border-top:1px solid var(--line)}.explorer-current{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--mono);font-size:12px}.topbar input,.topbar select{min-width:0}.topbar-actions{display:flex;gap:8px;margin-left:auto;align-items:center;padding-bottom:0}.btn,.topbar button{background:var(--btn);border:1px solid var(--btn-line);border-radius:var(--radius);height:var(--control-h);padding:0 12px;cursor:pointer;font-weight:500;display:inline-flex;align-items:center;justify-content:center;gap:6px;white-space:nowrap}.btn:hover,.topbar button:hover{filter:brightness(1.08)}.btn:disabled,.topbar button:disabled{opacity:.55;cursor:not-allowed;filter:none}.btn.primary{background:var(--btn-primary);border-color:var(--btn-primary-line)}.btn.ghost{background:transparent}.alerts{display:grid;gap:8px;padding:10px 16px 0}.alerts:empty{display:none;padding:0}.stage{flex:1;min-height:0;display:flex;flex-direction:column}.content{flex:1;min-height:0;display:grid;grid-template-columns:minmax(340px,420px) 1fr}.brief{overflow:auto;border-right:1px solid var(--line);padding:16px 18px 24px;background:radial-gradient(circle at 0 0,color-mix(in srgb,var(--accent) 8%,transparent),transparent 42%),var(--bg)}.graph-wrap{position:relative;min-height:0;display:flex;flex-direction:column}.impact-graph{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-toolbar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.graph-count{margin-left:auto;font-size:11px}.chip-btn{background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.chip-btn:hover{color:var(--ink)}.chip-btn.active{background:var(--rail-active);color:var(--ink)}.chip-btn:disabled{opacity:.45;cursor:not-allowed}.graph-stage{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-stage .react-flow,.graph-3d,.graph-3d-host,.graph-3d-canvas-host{flex:1;width:100%;height:100%;min-height:280px}.graph-3d{position:relative;background:var(--graph-bg);display:flex;flex-direction:column}.graph-3d-host{position:relative;min-height:0;display:flex;flex-direction:column}.graph-3d-canvas-host{position:relative;min-height:0;background:var(--graph-bg)}.graph-3d canvas{display:block;width:100%;height:100%}.graph-3d-tip{position:absolute;pointer-events:none;z-index:2;max-width:320px;padding:6px 8px;border-radius:var(--radius);background:var(--surface);border:1px solid var(--line);color:var(--ink);font-size:11px;line-height:1.35;box-shadow:0 8px 24px var(--shadow)}.graph-3d-tip .t{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.graph-3d-tip .n{font-weight:600}.graph-3d-hint{position:absolute;left:10px;bottom:10px;z-index:2;margin:0;font-size:11px;color:var(--muted);max-width:min(420px,calc(100% - 24px));pointer-events:none}.graph-wrap .react-flow{background-color:var(--graph-bg);background-image:linear-gradient(var(--graph-grid) 1px,transparent 1px),linear-gradient(90deg,var(--graph-grid) 1px,transparent 1px);background-size:24px 24px}.react-flow__minimap{background:var(--graph-bg)!important;border:1px solid var(--line)!important;border-radius:var(--radius);overflow:hidden;box-shadow:0 8px 24px var(--shadow)}.react-flow__minimap-node{fill:var(--muted);stroke:none}.react-flow__minimap-node.selected{fill:var(--accent)}.react-flow__minimap-mask{fill:#00000073!important;stroke:var(--accent)!important}.react-flow__controls{box-shadow:none!important}.react-flow__controls-button{background:var(--surface)!important;border-bottom:1px solid var(--line)!important;fill:var(--ink)!important}h1{font-size:18px;margin:0 0 6px;font-weight:600}h2{font-size:13px;margin:0;font-weight:600}.merge-box{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:12px 14px;margin-bottom:12px}.merge-box.high{border-color:color-mix(in srgb,var(--high) 55%,var(--line))}.merge-box.medium{border-color:color-mix(in srgb,var(--medium) 55%,var(--line))}.merge-box.low{border-color:color-mix(in srgb,var(--low) 55%,var(--line))}.level{font-family:var(--mono);font-weight:600;font-size:14px}.level.high{color:var(--high)}.level.medium{color:var(--medium)}.level.low{color:var(--low)}.merge-title{margin-top:4px;font-size:13px;color:var(--ink)}.reasons{margin:10px 0 0;padding:0 0 0 18px;color:var(--muted)}.reasons li{margin:0 0 4px}.metrics{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:0 0 14px}.metric{border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);padding:8px 10px}.metric .n{font-family:var(--mono);font-size:16px;font-weight:600;font-variant-numeric:tabular-nums}.metric .l{font-size:11px;color:var(--muted);margin-top:2px}.section{border-top:1px solid var(--line);padding:8px 0 4px}.section>summary{cursor:pointer;list-style:none;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.07em;font-weight:600;padding:6px 0}.section>summary::-webkit-details-marker{display:none}.section>summary .count{font-family:var(--mono);letter-spacing:0;text-transform:none;border:1px solid var(--line);border-radius:999px;padding:0 7px;height:18px;display:inline-flex;align-items:center;font-size:11px}.kicker{color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.08em;margin:16px 0 6px;font-weight:600}.chip{display:inline-flex;align-items:center;font-size:11px;padding:2px 8px;border-radius:999px;border:1px solid var(--line);margin:0 6px 6px 0;color:var(--muted);background:var(--surface)}.chip.blocker{color:var(--low);border-color:var(--low)}.chip.warning{color:var(--medium);border-color:var(--medium)}.chip.strong{color:var(--low);border-color:var(--low)}.chip.worth_exploring{color:var(--medium);border-color:var(--medium)}.chip.speculative{color:var(--muted);border-color:var(--line)}.chip.open{color:var(--high);border-color:color-mix(in srgb,var(--high) 50%,var(--line))}.file{font-family:var(--mono);font-size:12px;color:var(--accent)}.read-item,.finding,.residual{padding:8px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.read-item:last-child,.finding:last-child{border-bottom:0}.read-item.tour-current{background:color-mix(in srgb,var(--accent) 12%,var(--surface));border-color:var(--accent)}.tour-row{margin-top:8px;align-items:center}.field.dirty .chip-btn{height:32px}.muted{color:var(--muted);font-size:13px;line-height:1.45}.error{color:var(--low);padding:8px 12px;border:1px solid var(--low);background:color-mix(in srgb,var(--low) 10%,var(--surface));border-radius:var(--radius);display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.banner{padding:8px 12px;border-radius:var(--radius);border:1px solid var(--line);background:var(--surface);font-size:13px;line-height:1.45;display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.banner.warn{border-color:var(--medium);color:var(--medium)}.banner.stale{border-color:var(--low);color:var(--low)}.banner .dismiss{background:transparent;border:0;color:inherit;cursor:pointer;height:auto;padding:0 2px;opacity:.7}.empty{padding:24px 8px;color:var(--muted);font-size:13px;line-height:1.55}.workspace-loading{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;min-height:220px;padding:48px 16px}.empty h2{font-size:16px;color:var(--ink);margin-bottom:8px}.empty ol{margin:12px 0 0 18px;padding:0}.empty code,code{font-family:var(--mono);font-size:12px;color:var(--accent)}.btn-row{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}.pr-list{padding:16px;overflow:auto}.pr-toolbar{display:flex;gap:8px;align-items:flex-end;margin-bottom:14px}.pr-toolbar .field{flex:1}.pr-toolbar .field.provider{flex:0 0 140px}.scm-count{margin:0 0 12px;font-size:12px}.scm-login{display:flex;justify-content:space-between;gap:12px;align-items:center;padding:10px 0;border-top:1px solid var(--line)}.scm-login:first-of-type{border-top:0;padding-top:0}.scm-login .btn-row{margin-top:0}.scm-login p{margin:2px 0 0}.oauth-code{font-size:13px;margin:0}.oauth-code code{font-size:14px;letter-spacing:.08em}.pr{border:1px solid var(--line);background:var(--surface);padding:12px 14px;border-radius:var(--radius-lg);margin-bottom:10px}.pr h3{margin:0 0 4px;font-size:14px;font-weight:600}.pr-meta{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center;margin:6px 0 10px}.pr-actions{display:flex;gap:8px;align-items:center}.settings{padding:24px;max-width:760px;overflow:auto;display:grid;gap:16px}.settings-card{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:16px;display:grid;gap:8px}.settings-card h2{font-size:14px;margin-bottom:2px}.settings label{font-size:12px;color:var(--muted);font-weight:500}.theme-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px}.theme-swatch{border:1px solid var(--line);background:var(--bg);color:var(--ink);border-radius:var(--radius);padding:10px;text-align:left;cursor:pointer;height:auto;box-shadow:0 1px 8px var(--shadow)}.theme-swatch.active{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent),0 1px 8px var(--shadow)}.theme-swatch .swatch-bar{height:6px;border-radius:3px;margin-bottom:8px;background:linear-gradient(90deg,var(--accent),var(--high),var(--medium),var(--low))}.theme-swatch .name{font-size:13px;font-weight:600}.theme-swatch .group{font-size:11px;color:var(--muted)}.headline{white-space:pre-wrap;font-family:var(--mono);font-size:12px;color:var(--muted);margin:8px 0 0}.graph-modes{display:flex;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.seg{display:inline-flex;border:1px solid var(--line);border-radius:999px;padding:2px;background:var(--surface)}.seg button,.graph-modes button{background:transparent;border:0;border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.seg button.active,.graph-modes button.active{background:var(--rail-active);color:var(--ink)}.legend{margin-left:auto;display:flex;gap:12px;color:var(--muted);font-size:11px}.legend i{display:inline-block;width:14px;height:2px;margin-right:6px;vertical-align:middle;background:var(--edge-cheap)}.legend i.exp{background:var(--edge-expensive)}.legend i.crit{background:var(--edge-critical);height:3px}.legend i.dash{border-top:2px dashed var(--muted);background:none;height:0}.legend i.seed{height:10px;width:10px;border-radius:2px;background:color-mix(in srgb,var(--medium) 70%,var(--node-bg))}.legend i.down{height:10px;width:10px;border-radius:2px;border:1px solid color-mix(in srgb,var(--accent) 45%,var(--node-line));background:var(--node-bg)}.inspector{position:absolute;top:12px;right:12px;z-index:5;width:300px;max-width:calc(100% - 24px);max-height:calc(100% - 24px);overflow-x:hidden;overflow-y:auto;overflow-wrap:break-word;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-lg);padding:10px 12px;box-shadow:0 8px 24px var(--shadow);font-size:12px}.inspector .t{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}.inspector .n,.inspector .file,.inspector .muted{overflow-wrap:break-word}.inspector .n{font-weight:600;margin:4px 0}.inspector-head{display:flex;align-items:flex-start;gap:8px}.inspector-roles{display:flex;flex-wrap:wrap;justify-content:flex-end;flex:1;gap:4px}.inspector-chip{font-size:10px;text-transform:uppercase;letter-spacing:.04em;padding:1px 6px;border-radius:999px;border:1px solid var(--line);color:var(--muted);white-space:nowrap}.inspector-close{flex:0 0 auto;width:24px;height:24px;padding:0;border:1px solid var(--line);border-radius:var(--radius);background:transparent;color:var(--muted);font-size:16px;line-height:1;cursor:pointer}.inspector-close:hover{color:var(--ink)}.inspector-purpose{margin:6px 0 8px;color:var(--ink);font-size:12px;line-height:1.4}.inspector-layer{margin-top:4px;font-size:11px}.inspector-degree{font-size:11px}.inspector-path{margin:6px 0 0;font-size:12px;line-height:1.4;color:var(--muted)}.inspector-facts{margin:10px 0 0;padding-top:8px;border-top:1px solid var(--line)}.inspector-fact{display:grid;grid-template-columns:minmax(64px,92px) minmax(0,1fr);gap:8px;padding:3px 0;align-items:start}.inspector-fact dt{color:var(--muted);font-size:11px;margin:0}.inspector-fact dd{margin:0;overflow-wrap:break-word}.inspector-section{margin-top:10px;padding-top:8px;border-top:1px solid var(--line)}.inspector-section h3{margin:0 0 6px;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.07em;font-weight:600}.inspector-section .count{font-family:var(--mono);letter-spacing:0;text-transform:none;border:1px solid var(--line);border-radius:999px;padding:0 7px;height:18px;display:inline-flex;align-items:center;font-size:11px}.inspector-section ul{list-style:none;margin:0;padding:0}.inspector-section li{padding:4px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.inspector-section li:last-child{border-bottom:0}.inspector-link-name{display:block;font-weight:600;overflow-wrap:break-word}.inspector-link-meta{display:block;color:var(--muted);font-size:11px}.lp-node{padding:8px 10px;border-radius:var(--radius);border:1px solid var(--node-line);background:var(--node-bg);width:208px;max-width:100%;height:64px;box-sizing:border-box;box-shadow:0 0 0 1px var(--shadow);overflow:visible;position:relative}.lp-node .t{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.lp-node .n{font-size:13px;font-weight:600;line-height:1.2;overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow-wrap:anywhere}.lp-node.selected{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}.lp-node.role-seed{border-color:var(--medium);background:color-mix(in srgb,var(--medium) 14%,var(--node-bg))}.lp-node.role-downstream{border-color:color-mix(in srgb,var(--accent) 45%,var(--node-line))}.lp-node.role-untested{box-shadow:inset 3px 0 0 var(--low)}.lp-node.role-tested{box-shadow:inset 3px 0 0 var(--high)}.lp-node.role-contract{outline:1px dashed color-mix(in srgb,var(--accent) 50%,transparent)}.lp-node.dim{opacity:.38}.merge-box.compact{padding:6px 10px;min-width:92px;margin:0}.merge-box.compact .level{font-size:12px}.palette-scrim{position:fixed;top:0;right:0;bottom:0;left:0;background:color-mix(in srgb,var(--bg) 55%,transparent);z-index:40;display:grid;place-items:start center;padding-top:12vh}.palette{width:min(640px,calc(100vw - 32px));background:var(--surface);border:1px solid var(--line);border-radius:12px;box-shadow:0 18px 60px var(--shadow);overflow:hidden}.palette input{width:100%;border:0;border-bottom:1px solid var(--line);background:transparent;color:var(--ink);padding:14px 16px;font:inherit}.palette ul{list-style:none;margin:0;padding:6px;max-height:360px;overflow:auto}.palette li button{width:100%;display:flex;justify-content:space-between;gap:12px;text-align:left;background:transparent;border:0;color:var(--ink);padding:8px 10px;border-radius:8px;cursor:pointer}.palette li button.active,.palette li button:hover{background:var(--rail-active)}.palette-foot{padding:8px 12px 10px}.graph-search{position:relative;min-width:140px}.graph-search input{width:100%;background:var(--bg-2);border:1px solid var(--line);color:var(--ink);border-radius:8px;padding:6px 8px;font:inherit}.graph-search-hits{position:absolute;z-index:5;left:0;right:0;top:calc(100% + 4px);background:var(--surface);border:1px solid var(--line);border-radius:8px;list-style:none;margin:0;padding:4px;max-height:240px;overflow:auto}.graph-search-hits button{width:100%;display:flex;justify-content:space-between;gap:8px;background:transparent;border:0;color:var(--ink);text-align:left;padding:6px 8px;cursor:pointer}.graph-search-hits button:hover{background:var(--rail-active)}.inspector-link{display:flex;flex-direction:column;width:100%;background:transparent;border:0;color:inherit;text-align:left;cursor:pointer;padding:0}.file-row{display:flex;flex-direction:column;gap:6px}.linkish{background:none;border:0;color:inherit;font:inherit;text-align:left;cursor:pointer;padding:0}.history-item,.check-item{display:flex;flex-wrap:wrap;gap:8px;align-items:baseline;width:100%;background:transparent;border:0;color:inherit;font:inherit;text-align:left;padding:6px 0;cursor:pointer}.history-item.current{color:var(--accent)}.check-row{display:flex;gap:8px;align-items:center;margin:4px 0}.sparkline{display:flex;align-items:flex-end;gap:3px;height:36px;margin:8px 0}.sparkline i{flex:1;background:var(--muted);border-radius:2px 2px 0 0;min-width:4px}.sparkline i.high{background:var(--high)}.sparkline i.medium{background:var(--medium)}.sparkline i.low{background:var(--low)}.config-editor .field{display:flex;flex-direction:column;gap:4px;margin:8px 0}.config-editor input,.config-editor select{background:var(--bg-2);border:1px solid var(--line);color:var(--ink);border-radius:8px;padding:6px 8px}.react-flow__node-load .react-flow__handle{width:8px;height:8px;border:none;background:transparent;opacity:0}.type-table{width:100%;border-collapse:collapse;font-size:12px}.type-table td{padding:3px 0}.type-table td:last-child{text-align:right;font-family:var(--mono);font-variant-numeric:tabular-nums;color:var(--muted)}@media(prefers-reduced-motion:reduce){.progress i{animation:none;width:100%}.progress.determinate i{width:var(--progress, 100%)}*{scroll-behavior:auto!important}}@media(max-width:960px){.app{grid-template-columns:56px 1fr}.brand-sub,.nav-item span,.theme-pick,.kbd-hint,.rail-foot .muted{display:none}.nav-item{justify-content:center;padding:10px}.content{grid-template-columns:1fr}.brief{border-right:0;border-bottom:1px solid var(--line);max-height:42vh}} +.react-flow{direction:ltr;--xy-edge-stroke-default: #b1b1b7;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #555;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(255, 255, 255, .5);--xy-minimap-background-color-default: #fff;--xy-minimap-mask-background-color-default: rgba(240, 240, 240, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #e2e2e2;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: transparent;--xy-background-pattern-dots-color-default: #91919a;--xy-background-pattern-lines-color-default: #eee;--xy-background-pattern-cross-color-default: #e2e2e2;background-color:var(--xy-background-color, var(--xy-background-color-default));--xy-node-color-default: inherit;--xy-node-border-default: 1px solid #1a192b;--xy-node-background-color-default: #fff;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #1a192b;--xy-node-border-radius-default: 3px;--xy-handle-background-color-default: #1a192b;--xy-handle-border-color-default: #fff;--xy-selection-background-color-default: rgba(0, 89, 220, .08);--xy-selection-border-default: 1px dotted rgba(0, 89, 220, .8);--xy-controls-button-background-color-default: #fefefe;--xy-controls-button-background-color-hover-default: #f4f4f4;--xy-controls-button-color-default: inherit;--xy-controls-button-color-hover-default: inherit;--xy-controls-button-border-color-default: #eee;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #ffffff;--xy-edge-label-color-default: inherit;--xy-resize-background-color-default: #3367d9}.react-flow.dark{--xy-edge-stroke-default: #3e3e3e;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #727272;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(150, 150, 150, .25);--xy-minimap-background-color-default: #141414;--xy-minimap-mask-background-color-default: rgba(60, 60, 60, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #2b2b2b;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: #141414;--xy-background-pattern-dots-color-default: #555;--xy-background-pattern-lines-color-default: #333;--xy-background-pattern-cross-color-default: #333;--xy-node-color-default: #f8f8f8;--xy-node-border-default: 1px solid #3c3c3c;--xy-node-background-color-default: #1e1e1e;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #999;--xy-handle-background-color-default: #bebebe;--xy-handle-border-color-default: #1e1e1e;--xy-selection-background-color-default: rgba(200, 200, 220, .08);--xy-selection-border-default: 1px dotted rgba(200, 200, 220, .8);--xy-controls-button-background-color-default: #2b2b2b;--xy-controls-button-background-color-hover-default: #3e3e3e;--xy-controls-button-color-default: #f8f8f8;--xy-controls-button-color-hover-default: #fff;--xy-controls-button-border-color-default: #5b5b5b;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #141414;--xy-edge-label-color-default: #f8f8f8}.react-flow__background{background-color:var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1;touch-action:none}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{overflow:visible;position:absolute;pointer-events:none}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__arrowhead polyline{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:dashdraw .5s linear infinite}svg.react-flow__connectionline{z-index:1001;overflow:visible;position:absolute}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background-color:var(--xy-handle-background-color, var(--xy-handle-background-color-default));border:1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));border-radius:100%}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:0;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__pane.selection .react-flow__panel{pointer-events:none}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.top.center,.react-flow__panel.bottom.center{left:50%;transform:translate(-15px) translate(-50%)}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.left.center,.react-flow__panel.right.center{top:50%;transform:translateY(-15px) translateY(-50%)}.react-flow__attribution{font-size:10px;background:var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;left:0;top:0}.react-flow__viewport-portal{position:absolute;width:100%;height:100%;left:0;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__minimap{background:var( --xy-minimap-background-color-props, var(--xy-minimap-background-color, var(--xy-minimap-background-color-default)) )}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var( --xy-minimap-mask-background-color-props, var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default)) );stroke:var( --xy-minimap-mask-stroke-color-props, var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default)) );stroke-width:var( --xy-minimap-mask-stroke-width-props, var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default)) )}.react-flow__minimap-node{fill:var( --xy-minimap-node-background-color-props, var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default)) );stroke:var( --xy-minimap-node-stroke-color-props, var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default)) );stroke-width:var( --xy-minimap-node-stroke-width-props, var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default)) )}.react-flow__background-pattern.dots{fill:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default)) )}.react-flow__background-pattern.lines{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default)) )}.react-flow__background-pattern.cross{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default)) )}.react-flow__controls{display:flex;flex-direction:column;box-shadow:var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default))}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{display:flex;justify-content:center;align-items:center;height:26px;width:26px;padding:4px;border:none;background:var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));border-bottom:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) );color:var( --xy-controls-button-color-props, var(--xy-controls-button-color, var(--xy-controls-button-color-default)) );cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px;fill:currentColor}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:var(--xy-node-border-radius, var(--xy-node-border-radius-default));width:150px;font-size:12px;color:var(--xy-node-color, var(--xy-node-color-default));text-align:center;border:var(--xy-node-border, var(--xy-node-border-default));background-color:var(--xy-node-background-color, var(--xy-node-background-color-default))}.react-flow__node-input.selectable:hover,.react-flow__node-default.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default))}.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default))}.react-flow__node-group{background-color:var(--xy-node-group-background-color, var(--xy-node-group-background-color-default))}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color, var(--xy-selection-background-color-default));border:var(--xy-selection-border, var(--xy-selection-border-default))}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls-button:hover{background:var( --xy-controls-button-background-color-hover-props, var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default)) );color:var( --xy-controls-button-color-hover-props, var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default)) )}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__controls-button:last-child{border-bottom:none}.react-flow__controls.horizontal .react-flow__controls-button{border-bottom:none;border-right:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) )}.react-flow__controls.horizontal .react-flow__controls-button:last-child{border-right:none}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:5px;height:5px;border:1px solid #fff;border-radius:1px;background-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));translate:-50% -50%}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}.react-flow__edge-textbg{fill:var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default))}.react-flow__edge-text{fill:var(--xy-edge-label-color, var(--xy-edge-label-color-default))}:root,[data-theme=obsidian]{--bg: #070b10;--bg-2: #0d141c;--surface: #121a24;--line: #1e2c3c;--ink: #e7eef6;--muted: #8b9bb0;--high: #2a9d8f;--medium: #e9c46a;--low: #e76f51;--critical: #e85d04;--accent: #4cc9f0;--rail-from: #0b1219;--rail-to: #070b10;--rail-active: #15202c;--btn: #173044;--btn-line: #24506c;--btn-primary: #134e4a;--btn-primary-line: #2a9d8f;--node-bg: #101822;--node-line: #2a3d52;--graph-bg: #070b10;--graph-grid: rgba(42, 80, 120, .09);--edge-cheap: #4a5568;--edge-expensive: #f4a261;--edge-critical: #e85d04;--shadow: rgba(76, 201, 240, .08)}[data-theme=nord]{--bg: #2e3440;--bg-2: #3b4252;--surface: #434c5e;--line: #4c566a;--ink: #eceff4;--muted: #d8dee9;--high: #a3be8c;--medium: #ebcb8b;--low: #bf616a;--critical: #d08770;--accent: #88c0d0;--rail-from: #3b4252;--rail-to: #2e3440;--rail-active: #4c566a;--btn: #434c5e;--btn-line: #81a1c1;--btn-primary: #5e81ac;--btn-primary-line: #88c0d0;--node-bg: #3b4252;--node-line: #81a1c1;--graph-bg: #2e3440;--graph-grid: rgba(136, 192, 208, .12);--edge-cheap: #4c566a;--edge-expensive: #d08770;--edge-critical: #bf616a;--shadow: rgba(136, 192, 208, .12)}[data-theme=solarized-dark]{--bg: #002b36;--bg-2: #073642;--surface: #0a3944;--line: #16444f;--ink: #eee8d5;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #2aa198;--rail-from: #073642;--rail-to: #002b36;--rail-active: #16444f;--btn: #073642;--btn-line: #268bd2;--btn-primary: #0a4a42;--btn-primary-line: #2aa198;--node-bg: #073642;--node-line: #268bd2;--graph-bg: #002b36;--graph-grid: rgba(42, 161, 152, .12);--edge-cheap: #586e75;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(42, 161, 152, .12)}[data-theme=forest]{--bg: #0e1510;--bg-2: #152019;--surface: #1b2a20;--line: #2c4334;--ink: #e4f0e6;--muted: #8eaa96;--high: #6ab04c;--medium: #c8a951;--low: #e17055;--critical: #d35400;--accent: #7bed9f;--rail-from: #152019;--rail-to: #0e1510;--rail-active: #1f3326;--btn: #1f3326;--btn-line: #3d6b4f;--btn-primary: #1e4d32;--btn-primary-line: #6ab04c;--node-bg: #16241b;--node-line: #3d6b4f;--graph-bg: #0e1510;--graph-grid: rgba(123, 237, 159, .1);--edge-cheap: #3d6b4f;--edge-expensive: #c8a951;--edge-critical: #d35400;--shadow: rgba(123, 237, 159, .1)}[data-theme=rose]{--bg: #191724;--bg-2: #1f1d2e;--surface: #26233a;--line: #403d52;--ink: #e0def4;--muted: #908caa;--high: #9ccfd8;--medium: #f6c177;--low: #eb6f92;--critical: #eb6f92;--accent: #c4a7e7;--rail-from: #1f1d2e;--rail-to: #191724;--rail-active: #26233a;--btn: #26233a;--btn-line: #c4a7e7;--btn-primary: #3a2f4d;--btn-primary-line: #c4a7e7;--node-bg: #1f1d2e;--node-line: #524f67;--graph-bg: #191724;--graph-grid: rgba(196, 167, 231, .12);--edge-cheap: #524f67;--edge-expensive: #f6c177;--edge-critical: #eb6f92;--shadow: rgba(196, 167, 231, .12)}[data-theme=amber]{--bg: #120e0a;--bg-2: #1c1610;--surface: #261e16;--line: #3d2f22;--ink: #f4e6d0;--muted: #b59a78;--high: #c4d6a0;--medium: #e9b44c;--low: #d8572a;--critical: #c0392b;--accent: #f0a05a;--rail-from: #1c1610;--rail-to: #120e0a;--rail-active: #2b2218;--btn: #2b2218;--btn-line: #8a5a2b;--btn-primary: #4a3418;--btn-primary-line: #f0a05a;--node-bg: #1c1610;--node-line: #8a5a2b;--graph-bg: #120e0a;--graph-grid: rgba(240, 160, 90, .12);--edge-cheap: #5c4a38;--edge-expensive: #e9b44c;--edge-critical: #d8572a;--shadow: rgba(240, 160, 90, .12)}[data-theme=volcano]{--bg: #14090a;--bg-2: #1e0e10;--surface: #2a1416;--line: #4a2226;--ink: #fde8e4;--muted: #c48b86;--high: #7bed9f;--medium: #f6c90e;--low: #ff6b6b;--critical: #ff3b3b;--accent: #ff7b54;--rail-from: #1e0e10;--rail-to: #14090a;--rail-active: #32181b;--btn: #32181b;--btn-line: #ff7b54;--btn-primary: #5a1f18;--btn-primary-line: #ff7b54;--node-bg: #1e0e10;--node-line: #7a3330;--graph-bg: #14090a;--graph-grid: rgba(255, 123, 84, .12);--edge-cheap: #5a3330;--edge-expensive: #ff7b54;--edge-critical: #ff3b3b;--shadow: rgba(255, 123, 84, .14)}[data-theme=lavender]{--bg: #12101c;--bg-2: #1a1730;--surface: #221e3c;--line: #3b3560;--ink: #efeaff;--muted: #b3a7d6;--high: #80ffdb;--medium: #ffd166;--low: #ff6b9d;--critical: #ff4d6d;--accent: #c77dff;--rail-from: #1a1730;--rail-to: #12101c;--rail-active: #2a2550;--btn: #2a2550;--btn-line: #c77dff;--btn-primary: #3d2a66;--btn-primary-line: #c77dff;--node-bg: #1a1730;--node-line: #5a4d8a;--graph-bg: #12101c;--graph-grid: rgba(199, 125, 255, .12);--edge-cheap: #5a4d8a;--edge-expensive: #ffd166;--edge-critical: #ff4d6d;--shadow: rgba(199, 125, 255, .14)}[data-theme=neon-noir]{--bg: #05060a;--bg-2: #0a0c14;--surface: #10131c;--line: #1e2436;--ink: #f0f4ff;--muted: #8b93b0;--high: #39ff88;--medium: #ffe66d;--low: #ff2d95;--critical: #ff3d5a;--accent: #00f0ff;--rail-from: #0a0c14;--rail-to: #05060a;--rail-active: #151a2a;--btn: #151a2a;--btn-line: #00f0ff;--btn-primary: #063a40;--btn-primary-line: #00f0ff;--node-bg: #0a0c14;--node-line: #2a3550;--graph-bg: #05060a;--graph-grid: rgba(0, 240, 255, .12);--edge-cheap: #3a4560;--edge-expensive: #ff2d95;--edge-critical: #ff3d5a;--shadow: rgba(0, 240, 255, .22)}[data-theme=synthwave]{--bg: #1a0a2e;--bg-2: #240b3d;--surface: #2d1250;--line: #4a1d7a;--ink: #ffe6fb;--muted: #c49ad8;--high: #00f5d4;--medium: #ffd60a;--low: #ff6b9d;--critical: #ff006e;--accent: #ff2bd6;--rail-from: #240b3d;--rail-to: #1a0a2e;--rail-active: #3a1570;--btn: #3a1570;--btn-line: #ff2bd6;--btn-primary: #5a0a4a;--btn-primary-line: #ff2bd6;--node-bg: #240b3d;--node-line: #7b2cbf;--graph-bg: #1a0a2e;--graph-grid: rgba(255, 43, 214, .16);--edge-cheap: #5a3a80;--edge-expensive: #ff9e00;--edge-critical: #ff006e;--shadow: rgba(255, 43, 214, .24)}[data-theme=phosphor]{--bg: #020804;--bg-2: #061208;--surface: #0a1a0e;--line: #163c1e;--ink: #c8ffc8;--muted: #5aaa5a;--high: #39ff14;--medium: #c8f542;--low: #ffb000;--critical: #ff5e00;--accent: #00ff66;--rail-from: #061208;--rail-to: #020804;--rail-active: #0e2414;--btn: #0e2414;--btn-line: #00ff66;--btn-primary: #0a3a18;--btn-primary-line: #00ff66;--node-bg: #061208;--node-line: #1e6a32;--graph-bg: #020804;--graph-grid: rgba(0, 255, 102, .12);--edge-cheap: #1e5a2a;--edge-expensive: #c8f542;--edge-critical: #ff5e00;--shadow: rgba(0, 255, 102, .2)}[data-theme=aurora]{--bg: #071018;--bg-2: #0c1c28;--surface: #122636;--line: #1e3d52;--ink: #e8fff6;--muted: #7eb8a8;--high: #5fffcf;--medium: #ffe566;--low: #ff7eb6;--critical: #ff4d6d;--accent: #7cffb2;--rail-from: #0c1c28;--rail-to: #071018;--rail-active: #163044;--btn: #163044;--btn-line: #7cffb2;--btn-primary: #0e3d3a;--btn-primary-line: #7cffb2;--node-bg: #0c1c28;--node-line: #2a6a78;--graph-bg: #071018;--graph-grid: rgba(124, 255, 178, .12);--edge-cheap: #2a5a68;--edge-expensive: #c9a0ff;--edge-critical: #ff4d6d;--shadow: rgba(124, 255, 178, .18)}[data-theme=biolume]{--bg: #02141c;--bg-2: #042430;--surface: #073040;--line: #0a4a5c;--ink: #e6fffb;--muted: #6eb8b0;--high: #5dffb0;--medium: #ffe066;--low: #ff79c6;--critical: #ff4d6d;--accent: #18e7d4;--rail-from: #042430;--rail-to: #02141c;--rail-active: #0a3848;--btn: #0a3848;--btn-line: #18e7d4;--btn-primary: #0a4a48;--btn-primary-line: #18e7d4;--node-bg: #042430;--node-line: #1a7080;--graph-bg: #02141c;--graph-grid: rgba(24, 231, 212, .12);--edge-cheap: #1a5a68;--edge-expensive: #ff79c6;--edge-critical: #ff4d6d;--shadow: rgba(24, 231, 212, .2)}[data-theme=carbon]{--bg: #0d0d0f;--bg-2: #16161a;--surface: #1e1e24;--line: #33333c;--ink: #f2f2f4;--muted: #9a9aa8;--high: #3dd68c;--medium: #f0c040;--low: #ff5a5a;--critical: #ff2a2a;--accent: #ff2a2a;--rail-from: #16161a;--rail-to: #0d0d0f;--rail-active: #24242c;--btn: #24242c;--btn-line: #ff2a2a;--btn-primary: #4a1212;--btn-primary-line: #ff2a2a;--node-bg: #16161a;--node-line: #4a4a55;--graph-bg: #0d0d0f;--graph-grid: rgba(255, 42, 42, .1);--edge-cheap: #4a4a55;--edge-expensive: #ff8a3d;--edge-critical: #ff2a2a;--shadow: rgba(255, 42, 42, .18)}[data-theme=paper]{--bg: #f6f1e8;--bg-2: #efe6d6;--surface: #fffaf2;--line: #d9cbb6;--ink: #2b241c;--muted: #6f6456;--high: #2a7a4b;--medium: #b5811a;--low: #c0392b;--critical: #a93226;--accent: #1d6a7a;--rail-from: #efe6d6;--rail-to: #e7dcc8;--rail-active: #e2d3bb;--btn: #fffaf2;--btn-line: #c9b79a;--btn-primary: #d7eee0;--btn-primary-line: #2a7a4b;--node-bg: #fffaf2;--node-line: #c9b79a;--graph-bg: #f6f1e8;--graph-grid: rgba(29, 106, 122, .1);--edge-cheap: #b7a48c;--edge-expensive: #c0392b;--edge-critical: #a93226;--shadow: rgba(43, 36, 28, .08)}[data-theme=solarized-light]{--bg: #fdf6e3;--bg-2: #eee8d5;--surface: #f5efdc;--line: #d6cba9;--ink: #657b83;--muted: #93a1a1;--high: #859900;--medium: #b58900;--low: #dc322f;--critical: #cb4b16;--accent: #268bd2;--rail-from: #eee8d5;--rail-to: #e6dfc8;--rail-active: #e0d9c0;--btn: #fdf6e3;--btn-line: #93a1a1;--btn-primary: #e8efc8;--btn-primary-line: #859900;--node-bg: #fdf6e3;--node-line: #93a1a1;--graph-bg: #fdf6e3;--graph-grid: rgba(38, 139, 210, .12);--edge-cheap: #93a1a1;--edge-expensive: #cb4b16;--edge-critical: #dc322f;--shadow: rgba(101, 123, 131, .1)}[data-theme=seafoam]{--bg: #eef7f4;--bg-2: #dff0ea;--surface: #ffffff;--line: #b7d5cc;--ink: #17332c;--muted: #4d7268;--high: #1b8a5a;--medium: #c48a14;--low: #c44536;--critical: #9b2d22;--accent: #1d9a8a;--rail-from: #dff0ea;--rail-to: #cfe6de;--rail-active: #c4ddd4;--btn: #ffffff;--btn-line: #8fbfb2;--btn-primary: #d4f0e4;--btn-primary-line: #1b8a5a;--node-bg: #ffffff;--node-line: #8fbfb2;--graph-bg: #eef7f4;--graph-grid: rgba(29, 154, 138, .12);--edge-cheap: #8fbfb2;--edge-expensive: #c48a14;--edge-critical: #c44536;--shadow: rgba(23, 51, 44, .08)}[data-theme=high-contrast]{--bg: #ffffff;--bg-2: #f2f2f2;--surface: #ffffff;--line: #111111;--ink: #000000;--muted: #222222;--high: #007a33;--medium: #8a5a00;--low: #b00000;--critical: #9b0000;--accent: #0033cc;--rail-from: #f2f2f2;--rail-to: #e6e6e6;--rail-active: #d9d9d9;--btn: #ffffff;--btn-line: #000000;--btn-primary: #d9f2e3;--btn-primary-line: #007a33;--node-bg: #ffffff;--node-line: #000000;--graph-bg: #ffffff;--graph-grid: rgba(0, 0, 0, .12);--edge-cheap: #444444;--edge-expensive: #8a5a00;--edge-critical: #b00000;--shadow: rgba(0, 0, 0, .12)}[data-theme=sakura]{--bg: #fff0f5;--bg-2: #ffe4ee;--surface: #fff7fa;--line: #f5b8cc;--ink: #4a1830;--muted: #a05a78;--high: #1a8a5c;--medium: #c48a14;--low: #d63d6e;--critical: #b01040;--accent: #e84a8a;--rail-from: #ffe4ee;--rail-to: #f8d4e0;--rail-active: #f5c8d8;--btn: #fff7fa;--btn-line: #e89ab0;--btn-primary: #ffd6e6;--btn-primary-line: #e84a8a;--node-bg: #fff7fa;--node-line: #e89ab0;--graph-bg: #fff0f5;--graph-grid: rgba(232, 74, 138, .12);--edge-cheap: #d4a0b0;--edge-expensive: #d63d6e;--edge-critical: #b01040;--shadow: rgba(74, 24, 48, .1)}[data-theme=citrus]{--bg: #fffce8;--bg-2: #fff3b0;--surface: #fffef5;--line: #e8d44a;--ink: #2a2a08;--muted: #6a6a20;--high: #2a8a20;--medium: #d4a000;--low: #e85d04;--critical: #c0392b;--accent: #5aad14;--rail-from: #fff3b0;--rail-to: #ffe98a;--rail-active: #ffe066;--btn: #fffef5;--btn-line: #d4c030;--btn-primary: #e8f5b8;--btn-primary-line: #5aad14;--node-bg: #fffef5;--node-line: #d4c030;--graph-bg: #fffce8;--graph-grid: rgba(90, 173, 20, .14);--edge-cheap: #c4b040;--edge-expensive: #e85d04;--edge-critical: #c0392b;--shadow: rgba(42, 42, 8, .1)}[data-theme=peach]{--bg: #fff3eb;--bg-2: #ffe0cc;--surface: #fffaf6;--line: #f0c4a8;--ink: #3a2218;--muted: #8a5a48;--high: #2a8a5c;--medium: #d48a14;--low: #e85d3a;--critical: #c0392b;--accent: #ff6b35;--rail-from: #ffe0cc;--rail-to: #ffd4b8;--rail-active: #ffc8a8;--btn: #fffaf6;--btn-line: #e8a888;--btn-primary: #ffe0cc;--btn-primary-line: #ff6b35;--node-bg: #fffaf6;--node-line: #e8a888;--graph-bg: #fff3eb;--graph-grid: rgba(255, 107, 53, .12);--edge-cheap: #d4a088;--edge-expensive: #e85d3a;--edge-critical: #c0392b;--shadow: rgba(58, 34, 24, .1)}[data-theme=candy]{--bg: #f4f0ff;--bg-2: #e8dcff;--surface: #fbf8ff;--line: #d4c0f0;--ink: #2a1848;--muted: #6a5890;--high: #1a8a6a;--medium: #c48a14;--low: #e84a8a;--critical: #c01060;--accent: #ff5eb1;--rail-from: #e8dcff;--rail-to: #ddd0ff;--rail-active: #d4c4ff;--btn: #fbf8ff;--btn-line: #c4a8e8;--btn-primary: #ffd6ec;--btn-primary-line: #ff5eb1;--node-bg: #fbf8ff;--node-line: #c4a8e8;--graph-bg: #f4f0ff;--graph-grid: rgba(255, 94, 177, .14);--edge-cheap: #b0a0d0;--edge-expensive: #e84a8a;--edge-critical: #c01060;--shadow: rgba(42, 24, 72, .1)}[data-theme=sky]{--bg: #e8f4ff;--bg-2: #cfe8ff;--surface: #f5faff;--line: #90c8f0;--ink: #0a2848;--muted: #3a6080;--high: #0a8a4a;--medium: #c48a14;--low: #e85d3a;--critical: #c0392b;--accent: #0077ff;--rail-from: #cfe8ff;--rail-to: #b8dcff;--rail-active: #a8d4ff;--btn: #f5faff;--btn-line: #70b0e0;--btn-primary: #cfe8ff;--btn-primary-line: #0077ff;--node-bg: #f5faff;--node-line: #70b0e0;--graph-bg: #e8f4ff;--graph-grid: rgba(0, 119, 255, .12);--edge-cheap: #80b0d0;--edge-expensive: #e85d3a;--edge-critical: #c0392b;--shadow: rgba(10, 40, 72, .1)}[data-theme=coral]{--bg: #fff1ee;--bg-2: #ffddd6;--surface: #fff8f6;--line: #f0b0a4;--ink: #3a1814;--muted: #8a5048;--high: #0d9488;--medium: #d48a14;--low: #e85d4a;--critical: #c0392b;--accent: #0d9488;--rail-from: #ffddd6;--rail-to: #ffd0c6;--rail-active: #ffc4b8;--btn: #fff8f6;--btn-line: #e89888;--btn-primary: #d4f4ee;--btn-primary-line: #0d9488;--node-bg: #fff8f6;--node-line: #e89888;--graph-bg: #fff1ee;--graph-grid: rgba(13, 148, 136, .14);--edge-cheap: #d4a098;--edge-expensive: #e85d4a;--edge-critical: #c0392b;--shadow: rgba(58, 24, 20, .1)}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}:root{--radius: 6px;--radius-lg: 10px;--control-h: 32px;--font: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;--mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;--focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);--space: 8px}body{background:var(--bg);color:var(--ink);font-family:var(--font);font-size:13px;line-height:1.45;-webkit-font-smoothing:antialiased}button,input,select,textarea{font-family:inherit;font-size:inherit;color:inherit}button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,a:focus-visible,summary:focus-visible{outline:none;box-shadow:var(--focus-ring)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}.skip{position:absolute;left:12px;top:-40px;z-index:50;background:var(--surface);color:var(--ink);border:1px solid var(--accent);border-radius:var(--radius);padding:8px 12px}.skip:focus{top:12px}.app{display:grid;grid-template-columns:232px 1fr;height:100%}.rail{border-right:1px solid var(--line);background:linear-gradient(180deg,var(--rail-from),var(--rail-to));padding:16px 12px;display:flex;flex-direction:column;gap:2px;min-width:0}.brand{display:flex;flex-direction:column;gap:2px;padding:4px 8px 16px}.brand-mark{font-family:var(--mono);letter-spacing:.16em;font-size:11px;text-transform:uppercase;color:var(--accent);font-weight:600}.brand-sub{font-size:11px;color:var(--muted)}.nav-item{display:flex;align-items:center;gap:10px;background:transparent;border:0;text-align:left;padding:8px 10px;border-radius:var(--radius);color:var(--muted);cursor:pointer;width:100%}.nav-item:hover{background:color-mix(in srgb,var(--rail-active) 70%,transparent);color:var(--ink)}.nav-item.active{background:var(--rail-active);color:var(--ink);font-weight:500}.nav-item svg{flex-shrink:0}.theme-pick{margin-top:14px;display:grid;gap:4px;padding:0 2px}.theme-pick label{font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);font-weight:500}.theme-pick select,.field select,.field input,.topbar input,.topbar select,.settings input,.settings select,.explorer-path input{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:0 10px;height:var(--control-h);width:100%}.rail-foot{margin-top:auto;padding:12px 8px 4px;border-top:1px solid var(--line);display:grid;gap:6px}.kbd-hint{font-size:11px;color:var(--muted)}kbd{font-family:var(--mono);font-size:10px;border:1px solid var(--line);border-radius:4px;padding:0 4px;background:var(--surface)}.main{display:flex;flex-direction:column;min-width:0;min-height:0;position:relative;background:var(--bg)}.progress{position:absolute;top:0;left:0;right:0;height:2px;overflow:hidden;z-index:30;background:color-mix(in srgb,var(--accent) 20%,transparent)}.progress i{display:block;height:100%;width:32%;background:var(--accent);animation:indeterminate 1.1s ease-in-out infinite}.progress.determinate i{width:0;animation:none;transform:none;transition:width .2s ease-out}@keyframes indeterminate{0%{transform:translate(-120%)}to{transform:translate(400%)}}.topbar{display:flex;gap:10px;align-items:flex-end;padding:10px 16px;border-bottom:1px solid var(--line);background:var(--bg-2);flex-wrap:wrap}.field{display:grid;gap:4px;min-width:0}.field>span{font-size:11px;color:var(--muted);font-weight:500}.field.path{flex:1;min-width:180px}.field.ref{width:188px;flex:0 0 188px}.field.workspace{width:180px;flex:0 0 180px}.path-row,.combo-row{display:flex;min-width:0}.path-row input,.combo-row input{flex:1;min-width:0}.combo{position:relative;min-width:0}.combo-row input{border-top-right-radius:0;border-bottom-right-radius:0}.topbar .icon-btn{width:var(--control-h);padding:0;flex:0 0 var(--control-h)}.combo-toggle{border-top-left-radius:0;border-bottom-left-radius:0;border-left:0}.combo-menu{position:absolute;top:calc(100% + 4px);right:0;left:auto;min-width:340px;max-width:min(480px,70vw);max-height:360px;overflow:auto;z-index:40;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:0 12px 32px var(--shadow);padding:6px 0}.combo-heading{font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);font-weight:600;padding:8px 12px 4px}.combo-menu .combo-option{display:flex;flex-direction:column;align-items:flex-start;gap:2px;width:100%;text-align:left;background:transparent;border:0;border-radius:0;height:auto;padding:6px 12px;color:var(--ink);cursor:pointer}.combo-menu .combo-option:hover,.combo-menu .combo-option.active{background:var(--rail-active)}.combo-label{font-family:var(--mono);font-size:12px}.combo-detail{color:var(--muted);font-size:12px;line-height:1.35;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}.combo-empty{padding:10px 12px}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:50;background:color-mix(in srgb,var(--bg) 72%,transparent);display:grid;place-items:center;padding:24px}.modal{width:min(720px,100%);max-height:min(640px,90vh);background:var(--bg-2);border:1px solid var(--line);border-radius:var(--radius-lg);box-shadow:0 16px 48px var(--shadow);display:flex;flex-direction:column;overflow:hidden}.modal-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:14px 16px 10px;border-bottom:1px solid var(--line)}.modal-head h2{font-size:15px}.modal-head .muted{margin:4px 0 0}.explorer-path{display:flex;gap:8px;padding:12px 16px;border-bottom:1px solid var(--line)}.explorer-path input{flex:1;min-width:0}.explorer-list{flex:1;overflow:auto;padding:8px;min-height:220px}.explorer-row{display:flex;align-items:center;gap:8px;width:100%;text-align:left;background:transparent;border:0;border-radius:var(--radius);padding:8px 10px;color:var(--ink);cursor:pointer;height:auto}.explorer-row:hover,.explorer-row.active{background:var(--rail-active)}.explorer-name{min-width:0;overflow:hidden;text-overflow:ellipsis}.git-badge{margin-left:auto;margin-bottom:0}.explorer-empty{padding:18px 10px}.modal-foot{display:flex;align-items:center;gap:12px;padding:12px 16px;border-top:1px solid var(--line)}.explorer-current{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--mono);font-size:12px}.topbar input,.topbar select{min-width:0}.topbar-actions{display:flex;gap:8px;margin-left:auto;align-items:center;padding-bottom:0}.btn,.topbar button{background:var(--btn);border:1px solid var(--btn-line);border-radius:var(--radius);height:var(--control-h);padding:0 12px;cursor:pointer;font-weight:500;display:inline-flex;align-items:center;justify-content:center;gap:6px;white-space:nowrap}.btn:hover,.topbar button:hover{filter:brightness(1.08)}.btn:disabled,.topbar button:disabled{opacity:.55;cursor:not-allowed;filter:none}.btn.primary{background:var(--btn-primary);border-color:var(--btn-primary-line)}.btn.ghost{background:transparent}.alerts{display:grid;gap:8px;padding:10px 16px 0}.alerts:empty{display:none;padding:0}.stage{flex:1;min-height:0;display:flex;flex-direction:column}.content{flex:1;min-height:0;display:grid;grid-template-columns:minmax(340px,420px) 1fr}.brief{overflow:auto;border-right:1px solid var(--line);padding:16px 18px 24px;background:radial-gradient(circle at 0 0,color-mix(in srgb,var(--accent) 8%,transparent),transparent 42%),var(--bg)}.graph-wrap{position:relative;min-height:0;display:flex;flex-direction:column}.impact-graph{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-toolbar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.graph-count{margin-left:auto;font-size:11px}.chip-btn{background:var(--surface);border:1px solid var(--line);border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.chip-btn:hover{color:var(--ink)}.chip-btn.active{background:var(--rail-active);color:var(--ink)}.chip-btn:disabled{opacity:.45;cursor:not-allowed}.graph-stage{flex:1;min-height:0;position:relative;display:flex;flex-direction:column}.graph-stage .react-flow,.graph-3d,.graph-3d-host,.graph-3d-canvas-host{flex:1;width:100%;height:100%;min-height:280px}.graph-3d{position:relative;background:var(--graph-bg);display:flex;flex-direction:column}.graph-3d-host{position:relative;min-height:0;display:flex;flex-direction:column}.graph-3d-canvas-host{position:relative;min-height:0;background:var(--graph-bg)}.graph-3d canvas{display:block;width:100%;height:100%}.graph-3d-tip{position:absolute;pointer-events:none;z-index:2;max-width:320px;padding:6px 8px;border-radius:var(--radius);background:var(--surface);border:1px solid var(--line);color:var(--ink);font-size:11px;line-height:1.35;box-shadow:0 8px 24px var(--shadow)}.graph-3d-tip .t{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.graph-3d-tip .n{font-weight:600}.graph-3d-hint{position:absolute;left:10px;bottom:10px;z-index:2;margin:0;font-size:11px;color:var(--muted);max-width:min(420px,calc(100% - 24px));pointer-events:none}.graph-wrap .react-flow{background-color:var(--graph-bg);background-image:linear-gradient(var(--graph-grid) 1px,transparent 1px),linear-gradient(90deg,var(--graph-grid) 1px,transparent 1px);background-size:24px 24px}.react-flow__minimap{background:var(--graph-bg)!important;border:1px solid var(--line)!important;border-radius:var(--radius);overflow:hidden;box-shadow:0 8px 24px var(--shadow)}.react-flow__minimap-node{fill:var(--muted);stroke:none}.react-flow__minimap-node.selected{fill:var(--accent)}.react-flow__minimap-mask{fill:#00000073!important;stroke:var(--accent)!important}.react-flow__controls{box-shadow:none!important}.react-flow__controls-button{background:var(--surface)!important;border-bottom:1px solid var(--line)!important;fill:var(--ink)!important}h1{font-size:18px;margin:0 0 6px;font-weight:600}h2{font-size:13px;margin:0;font-weight:600}.merge-box{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:12px 14px;margin-bottom:12px}.merge-box.high{border-color:color-mix(in srgb,var(--high) 55%,var(--line))}.merge-box.medium{border-color:color-mix(in srgb,var(--medium) 55%,var(--line))}.merge-box.low{border-color:color-mix(in srgb,var(--low) 55%,var(--line))}.level{font-family:var(--mono);font-weight:600;font-size:14px}.level.high{color:var(--high)}.level.medium{color:var(--medium)}.level.low{color:var(--low)}.merge-title{margin-top:4px;font-size:13px;color:var(--ink)}.reasons{margin:10px 0 0;padding:0 0 0 18px;color:var(--muted)}.reasons li{margin:0 0 4px}.metrics{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:0 0 14px}.metric{border:1px solid var(--line);border-radius:var(--radius);background:var(--surface);padding:8px 10px}.metric .n{font-family:var(--mono);font-size:16px;font-weight:600;font-variant-numeric:tabular-nums}.metric .l{font-size:11px;color:var(--muted);margin-top:2px}.section{border-top:1px solid var(--line);padding:8px 0 4px}.section>summary{cursor:pointer;list-style:none;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.07em;font-weight:600;padding:6px 0}.section>summary::-webkit-details-marker{display:none}.section>summary .count{font-family:var(--mono);letter-spacing:0;text-transform:none;border:1px solid var(--line);border-radius:999px;padding:0 7px;height:18px;display:inline-flex;align-items:center;font-size:11px}.kicker{color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.08em;margin:16px 0 6px;font-weight:600}.chip{display:inline-flex;align-items:center;font-size:11px;padding:2px 8px;border-radius:999px;border:1px solid var(--line);margin:0 6px 6px 0;color:var(--muted);background:var(--surface)}.chip.blocker{color:var(--low);border-color:var(--low)}.chip.warning{color:var(--medium);border-color:var(--medium)}.chip.strong{color:var(--low);border-color:var(--low)}.chip.worth_exploring{color:var(--medium);border-color:var(--medium)}.chip.speculative{color:var(--muted);border-color:var(--line)}.chip.open{color:var(--high);border-color:color-mix(in srgb,var(--high) 50%,var(--line))}.file{font-family:var(--mono);font-size:12px;color:var(--accent)}.read-item,.finding,.residual{padding:8px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.read-item:last-child,.finding:last-child{border-bottom:0}.read-item.tour-current{background:color-mix(in srgb,var(--accent) 12%,var(--surface));border-color:var(--accent)}.tour-row{margin-top:8px;align-items:center}.field.dirty .chip-btn{height:32px}.muted{color:var(--muted);font-size:13px;line-height:1.45}.error{color:var(--low);padding:8px 12px;border:1px solid var(--low);background:color-mix(in srgb,var(--low) 10%,var(--surface));border-radius:var(--radius);display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.banner{padding:8px 12px;border-radius:var(--radius);border:1px solid var(--line);background:var(--surface);font-size:13px;line-height:1.45;display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.banner.warn{border-color:var(--medium);color:var(--medium)}.banner.stale{border-color:var(--low);color:var(--low)}.banner.whatif{border-color:var(--accent);align-items:center}.banner.whatif .btn{flex:0 0 auto;white-space:nowrap}.chip.whatif{color:var(--accent);border-color:color-mix(in srgb,var(--accent) 55%,var(--line))}.whatif-hint{margin:10px 0 0;font-size:12px;line-height:1.4;color:var(--muted)}.banner .dismiss{background:transparent;border:0;color:inherit;cursor:pointer;height:auto;padding:0 2px;opacity:.7}.empty{padding:24px 8px;color:var(--muted);font-size:13px;line-height:1.55}.workspace-loading{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;min-height:220px;padding:48px 16px}.empty h2{font-size:16px;color:var(--ink);margin-bottom:8px}.empty ol{margin:12px 0 0 18px;padding:0}.empty code,code{font-family:var(--mono);font-size:12px;color:var(--accent)}.btn-row{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}.pr-list{padding:16px;overflow:auto}.pr-toolbar{display:flex;gap:8px;align-items:flex-end;margin-bottom:14px}.pr-toolbar .field{flex:1}.pr-toolbar .field.provider{flex:0 0 140px}.scm-count{margin:0 0 12px;font-size:12px}.scm-login{display:flex;justify-content:space-between;gap:12px;align-items:center;padding:10px 0;border-top:1px solid var(--line)}.scm-login:first-of-type{border-top:0;padding-top:0}.scm-login .btn-row{margin-top:0}.scm-login p{margin:2px 0 0}.oauth-code{font-size:13px;margin:0}.oauth-code code{font-size:14px;letter-spacing:.08em}.pr{border:1px solid var(--line);background:var(--surface);padding:12px 14px;border-radius:var(--radius-lg);margin-bottom:10px}.pr h3{margin:0 0 4px;font-size:14px;font-weight:600}.pr-meta{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center;margin:6px 0 10px}.pr-actions{display:flex;gap:8px;align-items:center}.settings{padding:24px;max-width:760px;overflow:auto;display:grid;gap:16px}.settings-card{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius-lg);padding:16px;display:grid;gap:8px}.settings-card h2{font-size:14px;margin-bottom:2px}.settings label{font-size:12px;color:var(--muted);font-weight:500}.theme-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px}.theme-swatch{border:1px solid var(--line);background:var(--bg);color:var(--ink);border-radius:var(--radius);padding:10px;text-align:left;cursor:pointer;height:auto;box-shadow:0 1px 8px var(--shadow)}.theme-swatch.active{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent),0 1px 8px var(--shadow)}.theme-swatch .swatch-bar{height:6px;border-radius:3px;margin-bottom:8px;background:linear-gradient(90deg,var(--accent),var(--high),var(--medium),var(--low))}.theme-swatch .name{font-size:13px;font-weight:600}.theme-swatch .group{font-size:11px;color:var(--muted)}.headline{white-space:pre-wrap;font-family:var(--mono);font-size:12px;color:var(--muted);margin:8px 0 0}.graph-modes{display:flex;gap:8px;align-items:center;padding:8px 14px;border-bottom:1px solid var(--line);background:var(--bg-2)}.seg{display:inline-flex;border:1px solid var(--line);border-radius:999px;padding:2px;background:var(--surface)}.seg button,.graph-modes button{background:transparent;border:0;border-radius:999px;padding:4px 12px;color:var(--muted);cursor:pointer;height:26px}.seg button.active,.graph-modes button.active{background:var(--rail-active);color:var(--ink)}.legend{margin-left:auto;display:flex;gap:12px;color:var(--muted);font-size:11px}.legend i{display:inline-block;width:14px;height:2px;margin-right:6px;vertical-align:middle;background:var(--edge-cheap)}.legend i.exp{background:var(--edge-expensive)}.legend i.crit{background:var(--edge-critical);height:3px}.legend i.dash{border-top:2px dashed var(--muted);background:none;height:0}.legend i.seed{height:10px;width:10px;border-radius:2px;background:color-mix(in srgb,var(--medium) 70%,var(--node-bg))}.legend i.down{height:10px;width:10px;border-radius:2px;border:1px solid color-mix(in srgb,var(--accent) 45%,var(--node-line));background:var(--node-bg)}.inspector{position:absolute;top:12px;right:12px;z-index:5;width:300px;max-width:calc(100% - 24px);max-height:calc(100% - 24px);overflow-x:hidden;overflow-y:auto;overflow-wrap:break-word;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-lg);padding:10px 12px;box-shadow:0 8px 24px var(--shadow);font-size:12px}.inspector .t{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}.inspector .n,.inspector .file,.inspector .muted{overflow-wrap:break-word}.inspector .n{font-weight:600;margin:4px 0}.inspector-head{display:flex;align-items:flex-start;gap:8px}.inspector-roles{display:flex;flex-wrap:wrap;justify-content:flex-end;flex:1;gap:4px}.inspector-chip{font-size:10px;text-transform:uppercase;letter-spacing:.04em;padding:1px 6px;border-radius:999px;border:1px solid var(--line);color:var(--muted);white-space:nowrap}.inspector-close{flex:0 0 auto;width:24px;height:24px;padding:0;border:1px solid var(--line);border-radius:var(--radius);background:transparent;color:var(--muted);font-size:16px;line-height:1;cursor:pointer}.inspector-close:hover{color:var(--ink)}.inspector-purpose{margin:6px 0 8px;color:var(--ink);font-size:12px;line-height:1.4}.inspector-layer{margin-top:4px;font-size:11px}.inspector-degree{font-size:11px}.inspector-path{margin:6px 0 0;font-size:12px;line-height:1.4;color:var(--muted)}.inspector-facts{margin:10px 0 0;padding-top:8px;border-top:1px solid var(--line)}.inspector-fact{display:grid;grid-template-columns:minmax(64px,92px) minmax(0,1fr);gap:8px;padding:3px 0;align-items:start}.inspector-fact dt{color:var(--muted);font-size:11px;margin:0}.inspector-fact dd{margin:0;overflow-wrap:break-word}.inspector-section{margin-top:10px;padding-top:8px;border-top:1px solid var(--line)}.inspector-section h3{margin:0 0 6px;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.07em;font-weight:600}.inspector-section .count{font-family:var(--mono);letter-spacing:0;text-transform:none;border:1px solid var(--line);border-radius:999px;padding:0 7px;height:18px;display:inline-flex;align-items:center;font-size:11px}.inspector-section ul{list-style:none;margin:0;padding:0}.inspector-section li{padding:4px 0;border-bottom:1px solid color-mix(in srgb,var(--line) 70%,transparent)}.inspector-section li:last-child{border-bottom:0}.inspector-link-name{display:block;font-weight:600;overflow-wrap:break-word}.inspector-link-meta{display:block;color:var(--muted);font-size:11px}.lp-node{padding:8px 10px;border-radius:var(--radius);border:1px solid var(--node-line);background:var(--node-bg);width:208px;max-width:100%;height:64px;box-sizing:border-box;box-shadow:0 0 0 1px var(--shadow);overflow:visible;position:relative}.lp-node .t{font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.lp-node .n{font-size:13px;font-weight:600;line-height:1.2;overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow-wrap:anywhere}.lp-node.selected{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}.lp-node.role-seed{border-color:var(--medium);background:color-mix(in srgb,var(--medium) 14%,var(--node-bg))}.lp-node.role-downstream{border-color:color-mix(in srgb,var(--accent) 45%,var(--node-line))}.lp-node.role-untested{box-shadow:inset 3px 0 0 var(--low)}.lp-node.role-tested{box-shadow:inset 3px 0 0 var(--high)}.lp-node.role-contract{outline:1px dashed color-mix(in srgb,var(--accent) 50%,transparent)}.lp-node.dim{opacity:.38}.merge-box.compact{padding:6px 10px;min-width:92px;margin:0}.merge-box.compact .level{font-size:12px}.palette-scrim{position:fixed;top:0;right:0;bottom:0;left:0;background:color-mix(in srgb,var(--bg) 55%,transparent);z-index:40;display:grid;place-items:start center;padding-top:12vh}.palette{width:min(640px,calc(100vw - 32px));background:var(--surface);border:1px solid var(--line);border-radius:12px;box-shadow:0 18px 60px var(--shadow);overflow:hidden}.palette input{width:100%;border:0;border-bottom:1px solid var(--line);background:transparent;color:var(--ink);padding:14px 16px;font:inherit}.palette ul{list-style:none;margin:0;padding:6px;max-height:360px;overflow:auto}.palette li button{width:100%;display:flex;justify-content:space-between;gap:12px;text-align:left;background:transparent;border:0;color:var(--ink);padding:8px 10px;border-radius:8px;cursor:pointer}.palette li button.active,.palette li button:hover{background:var(--rail-active)}.palette-foot{padding:8px 12px 10px}.graph-search{position:relative;min-width:140px}.graph-search input{width:100%;background:var(--bg-2);border:1px solid var(--line);color:var(--ink);border-radius:8px;padding:6px 8px;font:inherit}.graph-search-hits{position:absolute;z-index:5;left:0;right:0;top:calc(100% + 4px);background:var(--surface);border:1px solid var(--line);border-radius:8px;list-style:none;margin:0;padding:4px;max-height:240px;overflow:auto}.graph-search-hits button{width:100%;display:flex;justify-content:space-between;gap:8px;background:transparent;border:0;color:var(--ink);text-align:left;padding:6px 8px;cursor:pointer}.graph-search-hits button:hover{background:var(--rail-active)}.inspector-link{display:flex;flex-direction:column;width:100%;background:transparent;border:0;color:inherit;text-align:left;cursor:pointer;padding:0}.file-row{display:flex;flex-direction:column;gap:6px}.linkish{background:none;border:0;color:inherit;font:inherit;text-align:left;cursor:pointer;padding:0}.history-item,.check-item{display:flex;flex-wrap:wrap;gap:8px;align-items:baseline;width:100%;background:transparent;border:0;color:inherit;font:inherit;text-align:left;padding:6px 0;cursor:pointer}.history-item.current{color:var(--accent)}.check-row{display:flex;gap:8px;align-items:center;margin:4px 0}.sparkline{display:flex;align-items:flex-end;gap:3px;height:36px;margin:8px 0}.sparkline i{flex:1;background:var(--muted);border-radius:2px 2px 0 0;min-width:4px}.sparkline i.high{background:var(--high)}.sparkline i.medium{background:var(--medium)}.sparkline i.low{background:var(--low)}.config-editor .field{display:flex;flex-direction:column;gap:4px;margin:8px 0}.config-editor input,.config-editor select{background:var(--bg-2);border:1px solid var(--line);color:var(--ink);border-radius:8px;padding:6px 8px}.react-flow__node-load .react-flow__handle{width:8px;height:8px;border:none;background:transparent;opacity:0}.type-table{width:100%;border-collapse:collapse;font-size:12px}.type-table td{padding:3px 0}.type-table td:last-child{text-align:right;font-family:var(--mono);font-variant-numeric:tabular-nums;color:var(--muted)}@media(prefers-reduced-motion:reduce){.progress i{animation:none;width:100%}.progress.determinate i{width:var(--progress, 100%)}*{scroll-behavior:auto!important}}@media(max-width:960px){.app{grid-template-columns:56px 1fr}.brand-sub,.nav-item span,.theme-pick,.kbd-hint,.rail-foot .muted{display:none}.nav-item{justify-content:center;padding:10px}.content{grid-template-columns:1fr}.brief{border-right:0;border-bottom:1px solid var(--line);max-height:42vh}} diff --git a/src/loadpath/static/assets/index-sgthL-dY.js b/src/loadpath/static/assets/index-sgthL-dY.js deleted file mode 100644 index 890b60f..0000000 --- a/src/loadpath/static/assets/index-sgthL-dY.js +++ /dev/null @@ -1,62 +0,0 @@ -(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function wp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Eu={exports:{}},Ho={},Cu={exports:{}},Re={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Yf;function Zy(){if(Yf)return Re;Yf=1;var t=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),x=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),y=Symbol.iterator;function v(I){return I===null||typeof I!="object"?null:(I=y&&I[y]||I["@@iterator"],typeof I=="function"?I:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,j={};function E(I,$,ie){this.props=I,this.context=$,this.refs=j,this.updater=ie||_}E.prototype.isReactComponent={},E.prototype.setState=function(I,$){if(typeof I!="object"&&typeof I!="function"&&I!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,I,$,"setState")},E.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function w(){}w.prototype=E.prototype;function C(I,$,ie){this.props=I,this.context=$,this.refs=j,this.updater=ie||_}var k=C.prototype=new w;k.constructor=C,N(k,E.prototype),k.isPureReactComponent=!0;var b=Array.isArray,A=Object.prototype.hasOwnProperty,z={current:null},V={key:!0,ref:!0,__self:!0,__source:!0};function Y(I,$,ie){var oe,fe={},he=null,pe=null;if($!=null)for(oe in $.ref!==void 0&&(pe=$.ref),$.key!==void 0&&(he=""+$.key),$)A.call($,oe)&&!V.hasOwnProperty(oe)&&(fe[oe]=$[oe]);var J=arguments.length-2;if(J===1)fe.children=ie;else if(1>>1,$=M[I];if(0>>1;Ia(fe,F))he<$&&0>a(pe,fe)?(M[I]=pe,M[he]=F,I=he):(M[I]=fe,M[oe]=F,I=oe);else if(he<$&&0>a(pe,F))M[I]=pe,M[he]=F,I=he;else break e}}return D}function a(M,D){var F=M.sortIndex-D.sortIndex;return F!==0?F:M.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,h=c.now();t.unstable_now=function(){return c.now()-h}}var p=[],x=[],m=1,y=null,v=3,_=!1,N=!1,j=!1,E=typeof setTimeout=="function"?setTimeout:null,w=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function k(M){for(var D=o(x);D!==null;){if(D.callback===null)s(x);else if(D.startTime<=M)s(x),D.sortIndex=D.expirationTime,r(p,D);else break;D=o(x)}}function b(M){if(j=!1,k(M),!N)if(o(p)!==null)N=!0,H(A);else{var D=o(x);D!==null&&W(b,D.startTime-M)}}function A(M,D){N=!1,j&&(j=!1,w(Y),Y=-1),_=!0;var F=v;try{for(k(D),y=o(p);y!==null&&(!(y.expirationTime>D)||M&&!q());){var I=y.callback;if(typeof I=="function"){y.callback=null,v=y.priorityLevel;var $=I(y.expirationTime<=D);D=t.unstable_now(),typeof $=="function"?y.callback=$:y===o(p)&&s(p),k(D)}else s(p);y=o(p)}if(y!==null)var ie=!0;else{var oe=o(x);oe!==null&&W(b,oe.startTime-D),ie=!1}return ie}finally{y=null,v=F,_=!1}}var z=!1,V=null,Y=-1,K=5,re=-1;function q(){return!(t.unstable_now()-reM||125I?(M.sortIndex=F,r(x,M),o(p)===null&&M===o(x)&&(j?(w(Y),Y=-1):j=!0,W(b,F-I))):(M.sortIndex=$,r(p,M),N||_||(N=!0,H(A))),M},t.unstable_shouldYield=q,t.unstable_wrapCallback=function(M){var D=v;return function(){var F=v;v=D;try{return M.apply(this,arguments)}finally{v=F}}}})(Iu)),Iu}var Zf;function r0(){return Zf||(Zf=1,Pu.exports=n0()),Pu.exports}/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Jf;function i0(){if(Jf)return $t;Jf=1;var t=os(),r=r0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,x=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,m={},y={};function v(e){return p.call(y,e)?!0:p.call(m,e)?!1:x.test(e)?y[e]=!0:(m[e]=!0,!1)}function _(e,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function N(e,n,i,l){if(n===null||typeof n>"u"||_(e,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function j(e,n,i,l,f,g,S){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=f,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=g,this.removeEmptyString=S}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){E[e]=new j(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];E[n]=new j(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){E[e]=new j(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){E[e]=new j(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){E[e]=new j(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){E[e]=new j(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){E[e]=new j(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){E[e]=new j(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){E[e]=new j(e,5,!1,e.toLowerCase(),null,!1,!1)});var w=/[\-:]([a-z])/g;function C(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(w,C);E[n]=new j(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(w,C);E[n]=new j(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(w,C);E[n]=new j(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){E[e]=new j(e,1,!1,e.toLowerCase(),null,!1,!1)}),E.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){E[e]=new j(e,1,!1,e.toLowerCase(),null,!0,!0)});function k(e,n,i,l){var f=E.hasOwnProperty(n)?E[n]:null;(f!==null?f.type!==0:l||!(2T||f[S]!==g[T]){var O=` -`+f[S].replace(" at new "," at ");return e.displayName&&O.includes("")&&(O=O.replace("",e.displayName)),O}while(1<=S&&0<=T);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?$(e):""}function fe(e){switch(e.tag){case 5:return $(e.type);case 16:return $("Lazy");case 13:return $("Suspense");case 19:return $("SuspenseList");case 0:case 2:case 15:return e=oe(e.type,!1),e;case 11:return e=oe(e.type.render,!1),e;case 1:return e=oe(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case V:return"Fragment";case z:return"Portal";case K:return"Profiler";case Y:return"StrictMode";case te:return"Suspense";case R:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case q:return(e.displayName||"Context")+".Consumer";case re:return(e._context.displayName||"Context")+".Provider";case Z:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case U:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case H:n=e._payload,e=e._init;try{return he(e(n))}catch{}}return null}function pe(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===Y?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function J(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ae(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=ae(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function Ne(e){e._valueTracker||(e._valueTracker=me(e))}function xe(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=ae(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function ne(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function je(e,n){var i=n.checked;return F({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=J(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Te(e,n){n=n.checked,n!=null&&k(e,"checked",n,!1)}function De(e,n){Te(e,n);var i=J(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?Je(e,n.type,i):n.hasOwnProperty("defaultValue")&&Je(e,n.type,J(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function ht(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function Je(e,n,i){(n!=="number"||ne(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var Xe=Array.isArray;function lt(e,n,i,l){if(e=e.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=xt.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function rn(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var on={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},no=["Webkit","ms","Moz","O"];Object.keys(on).forEach(function(e){no.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),on[n]=on[e]})});function Dn(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||on.hasOwnProperty(e)&&on[e]?(""+n).trim():n+"px"}function di(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=Dn(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,f):e[i]=f}}var Ir=F({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Rr(e,n){if(n){if(Ir[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function nr(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var rr=null;function wn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Nt=null,Ot=null,Ft=null;function _n(e){if(e=bo(e)){if(typeof Nt!="function")throw Error(o(280));var n=e.stateNode;n&&(n=bs(n),Nt(e.stateNode,e.type,n))}}function On(e){Ot?Ft?Ft.push(e):Ft=[e]:Ot=e}function Sn(){if(Ot){var e=Ot,n=Ft;if(Ft=Ot=null,_n(e),n)for(e=0;e>>=0,e===0?32:31-(gi(e)/mi|0)|0}var En=64,Hn=4194304;function Cn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Kt(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,f=e.suspendedLanes,g=e.pingedLanes,S=i&268435455;if(S!==0){var T=S&~f;T!==0?l=Cn(T):(g&=S,g!==0&&(l=Cn(g)))}else S=i&~f,S!==0?l=Cn(S):g!==0&&(l=Cn(g));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,g=n&-n,f>=g||f===16&&(g&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function Vn(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-pt(n),e[n]=i}function wi(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=yo),Oc=" ",Fc=!1;function Hc(e,n){switch(e){case"keyup":return Ym.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Bc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ni=!1;function qm(e,n){switch(e){case"compositionend":return Bc(n);case"keypress":return n.which!==32?null:(Fc=!0,Oc);case"textInput":return e=n.data,e===Oc&&Fc?null:e;default:return null}}function Km(e,n){if(Ni)return e==="compositionend"||!la&&Hc(e,n)?(e=Tc(),gs=ta=cr=null,Ni=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=qc(i)}}function Qc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Qc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Zc(){for(var e=window,n=ne();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=ne(e.document)}return n}function ca(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function oy(e){var n=Zc(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Qc(i.ownerDocument.documentElement,i)){if(l!==null&&ca(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var f=i.textContent.length,g=Math.min(l.start,f);l=l.end===void 0?g:Math.min(l.end,f),!e.extend&&g>l&&(f=l,l=g,g=f),f=Kc(i,g);var S=Kc(i,l);f&&S&&(e.rangeCount!==1||e.anchorNode!==f.node||e.anchorOffset!==f.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),e.removeAllRanges(),g>l?(e.addRange(n),e.extend(S.node,S.offset)):(n.setEnd(S.node,S.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,ji=null,da=null,_o=null,fa=!1;function Jc(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;fa||ji==null||ji!==ne(l)||(l=ji,"selectionStart"in l&&ca(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),_o&&wo(_o,l)||(_o=l,l=ks(da,"onSelect"),0Pi||(e.current=Na[Pi],Na[Pi]=null,Pi--)}function Be(e,n){Pi++,Na[Pi]=e.current,e.current=n}var pr={},wt=hr(pr),It=hr(!1),Wr=pr;function Ii(e,n){var i=e.type.contextTypes;if(!i)return pr;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in i)f[g]=n[g];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=f),f}function Rt(e){return e=e.childContextTypes,e!=null}function Es(){Ue(It),Ue(wt)}function pd(e,n,i){if(wt.current!==pr)throw Error(o(168));Be(wt,n),Be(It,i)}function gd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,pe(e)||"Unknown",f));return F({},i,l)}function Cs(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||pr,Wr=wt.current,Be(wt,e),Be(It,It.current),!0}function md(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=gd(e,n,Wr),l.__reactInternalMemoizedMergedChildContext=e,Ue(It),Ue(wt),Be(wt,e)):Ue(It),Be(It,i)}var Gn=null,Ms=!1,ja=!1;function yd(e){Gn===null?Gn=[e]:Gn.push(e)}function yy(e){Ms=!0,yd(e)}function gr(){if(!ja&&Gn!==null){ja=!0;var e=0,n=Oe;try{var i=Gn;for(Oe=1;e>=S,f-=S,Yn=1<<32-pt(n)+f|i<Ce?(ft=Ee,Ee=null):ft=Ee.sibling;var Fe=se(X,Ee,Q[Ce],de);if(Fe===null){Ee===null&&(Ee=ft);break}e&&Ee&&Fe.alternate===null&&n(X,Ee),B=g(Fe,B,Ce),be===null?_e=Fe:be.sibling=Fe,be=Fe,Ee=ft}if(Ce===Q.length)return i(X,Ee),Ye&&Gr(X,Ce),_e;if(Ee===null){for(;CeCe?(ft=Ee,Ee=null):ft=Ee.sibling;var Nr=se(X,Ee,Fe.value,de);if(Nr===null){Ee===null&&(Ee=ft);break}e&&Ee&&Nr.alternate===null&&n(X,Ee),B=g(Nr,B,Ce),be===null?_e=Nr:be.sibling=Nr,be=Nr,Ee=ft}if(Fe.done)return i(X,Ee),Ye&&Gr(X,Ce),_e;if(Ee===null){for(;!Fe.done;Ce++,Fe=Q.next())Fe=ue(X,Fe.value,de),Fe!==null&&(B=g(Fe,B,Ce),be===null?_e=Fe:be.sibling=Fe,be=Fe);return Ye&&Gr(X,Ce),_e}for(Ee=l(X,Ee);!Fe.done;Ce++,Fe=Q.next())Fe=ge(Ee,X,Ce,Fe.value,de),Fe!==null&&(e&&Fe.alternate!==null&&Ee.delete(Fe.key===null?Ce:Fe.key),B=g(Fe,B,Ce),be===null?_e=Fe:be.sibling=Fe,be=Fe);return e&&Ee.forEach(function(Qy){return n(X,Qy)}),Ye&&Gr(X,Ce),_e}function tt(X,B,Q,de){if(typeof Q=="object"&&Q!==null&&Q.type===V&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case A:e:{for(var _e=Q.key,be=B;be!==null;){if(be.key===_e){if(_e=Q.type,_e===V){if(be.tag===7){i(X,be.sibling),B=f(be,Q.props.children),B.return=X,X=B;break e}}else if(be.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===H&&kd(_e)===be.type){i(X,be.sibling),B=f(be,Q.props),B.ref=Eo(X,be,Q),B.return=X,X=B;break e}i(X,be);break}else n(X,be);be=be.sibling}Q.type===V?(B=ei(Q.props.children,X.mode,de,Q.key),B.return=X,X=B):(de=rl(Q.type,Q.key,Q.props,null,X.mode,de),de.ref=Eo(X,B,Q),de.return=X,X=de)}return S(X);case z:e:{for(be=Q.key;B!==null;){if(B.key===be)if(B.tag===4&&B.stateNode.containerInfo===Q.containerInfo&&B.stateNode.implementation===Q.implementation){i(X,B.sibling),B=f(B,Q.children||[]),B.return=X,X=B;break e}else{i(X,B);break}else n(X,B);B=B.sibling}B=Su(Q,X.mode,de),B.return=X,X=B}return S(X);case H:return be=Q._init,tt(X,B,be(Q._payload),de)}if(Xe(Q))return ve(X,B,Q,de);if(D(Q))return we(X,B,Q,de);Ts(X,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"?(Q=""+Q,B!==null&&B.tag===6?(i(X,B.sibling),B=f(B,Q),B.return=X,X=B):(i(X,B),B=_u(Q,X.mode,de),B.return=X,X=B),S(X)):i(X,B)}return tt}var Ai=Nd(!0),jd=Nd(!1),Ls=hr(null),As=null,$i=null,Ia=null;function Ra(){Ia=$i=As=null}function Ta(e){var n=Ls.current;Ue(Ls),e._currentValue=n}function La(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function zi(e,n){As=e,Ia=$i=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Tt=!0),e.firstContext=null)}function Jt(e){var n=e._currentValue;if(Ia!==e)if(e={context:e,memoizedValue:n,next:null},$i===null){if(As===null)throw Error(o(308));$i=e,As.dependencies={lanes:0,firstContext:e}}else $i=$i.next=e;return n}var Yr=null;function Aa(e){Yr===null?Yr=[e]:Yr.push(e)}function bd(e,n,i,l){var f=n.interleaved;return f===null?(i.next=i,Aa(n)):(i.next=f.next,f.next=i),n.interleaved=i,qn(e,l)}function qn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var mr=!1;function $a(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ed(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Kn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function yr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,($e&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,qn(e,i)}return f=l.interleaved,f===null?(n.next=n,Aa(l)):(n.next=f.next,f.next=n),l.interleaved=n,qn(e,i)}function $s(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,Wn(e,i)}}function Cd(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var S={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?f=g=S:g=g.next=S,i=i.next}while(i!==null);g===null?f=g=n:g=g.next=n}else f=g=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function zs(e,n,i,l){var f=e.updateQueue;mr=!1;var g=f.firstBaseUpdate,S=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,ee=O.next;O.next=null,S===null?g=ee:S.next=ee,S=O;var le=e.alternate;le!==null&&(le=le.updateQueue,T=le.lastBaseUpdate,T!==S&&(T===null?le.firstBaseUpdate=ee:T.next=ee,le.lastBaseUpdate=O))}if(g!==null){var ue=f.baseState;S=0,le=ee=O=null,T=g;do{var se=T.lane,ge=T.eventTime;if((l&se)===se){le!==null&&(le=le.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var ve=e,we=T;switch(se=n,ge=i,we.tag){case 1:if(ve=we.payload,typeof ve=="function"){ue=ve.call(ge,ue,se);break e}ue=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=we.payload,se=typeof ve=="function"?ve.call(ge,ue,se):ve,se==null)break e;ue=F({},ue,se);break e;case 2:mr=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,se=f.effects,se===null?f.effects=[T]:se.push(T))}else ge={eventTime:ge,lane:se,tag:T.tag,payload:T.payload,callback:T.callback,next:null},le===null?(ee=le=ge,O=ue):le=le.next=ge,S|=se;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;se=T,T=se.next,se.next=null,f.lastBaseUpdate=se,f.shared.pending=null}}while(!0);if(le===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=ee,f.lastBaseUpdate=le,n=f.shared.interleaved,n!==null){f=n;do S|=f.lane,f=f.next;while(f!==n)}else g===null&&(f.shared.lanes=0);Kr|=S,e.lanes=S,e.memoizedState=ue}}function Md(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=Ha.transition;Ha.transition={};try{e(!1),n()}finally{Oe=i,Ha.transition=l}}function Xd(){return en().memoizedState}function _y(e,n,i){var l=_r(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},qd(e))Kd(n,i);else if(i=bd(e,n,i,l),i!==null){var f=Ct();fn(i,e,l,f),Qd(i,n,l)}}function Sy(e,n,i){var l=_r(e),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(qd(e))Kd(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,T=g(S,i);if(f.hasEagerState=!0,f.eagerState=T,ln(T,S)){var O=n.interleaved;O===null?(f.next=f,Aa(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=bd(e,n,f,l),i!==null&&(f=Ct(),fn(i,e,l,f),Qd(i,n,l))}}function qd(e){var n=e.alternate;return e===Ke||n!==null&&n===Ke}function Kd(e,n){Io=Fs=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Qd(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,Wn(e,i)}}var Vs={readContext:Jt,useCallback:_t,useContext:_t,useEffect:_t,useImperativeHandle:_t,useInsertionEffect:_t,useLayoutEffect:_t,useMemo:_t,useReducer:_t,useRef:_t,useState:_t,useDebugValue:_t,useDeferredValue:_t,useTransition:_t,useMutableSource:_t,useSyncExternalStore:_t,useId:_t,unstable_isNewReconciler:!1},ky={readContext:Jt,useCallback:function(e,n){return Rn().memoizedState=[e,n===void 0?null:n],e},useContext:Jt,useEffect:Fd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Hs(4194308,4,Vd.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Hs(4194308,4,e,n)},useInsertionEffect:function(e,n){return Hs(4,2,e,n)},useMemo:function(e,n){var i=Rn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=Rn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=_y.bind(null,Ke,e),[l.memoizedState,e]},useRef:function(e){var n=Rn();return e={current:e},n.memoizedState=e},useState:Dd,useDebugValue:Xa,useDeferredValue:function(e){return Rn().memoizedState=e},useTransition:function(){var e=Dd(!1),n=e[0];return e=wy.bind(null,e[1]),Rn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=Ke,f=Rn();if(Ye){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),dt===null)throw Error(o(349));(qr&30)!==0||Td(l,n,i)}f.memoizedState=i;var g={value:i,getSnapshot:n};return f.queue=g,Fd(Ad.bind(null,l,g,e),[e]),l.flags|=2048,Lo(9,Ld.bind(null,l,g,i,n),void 0,null),i},useId:function(){var e=Rn(),n=dt.identifierPrefix;if(Ye){var i=Xn,l=Yn;i=(l&~(1<<32-pt(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=Ro++,0<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=S.createElement(i,{is:l.is}):(e=S.createElement(i),i==="select"&&(S=e,l.multiple?S.multiple=!0:l.size&&(S.size=l.size))):e=S.createElementNS(e,i),e[Pn]=n,e[jo]=l,vf(e,n,!1,!1),n.stateNode=e;e:{switch(S=nr(i,l),i){case"dialog":We("cancel",e),We("close",e),f=l;break;case"iframe":case"object":case"embed":We("load",e),f=l;break;case"video":case"audio":for(f=0;fBi&&(n.flags|=128,l=!0,Ao(g,!1),n.lanes=4194304)}else{if(!l)if(e=Ds(S),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Ao(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Ye)return St(n),null}else 2*Ve()-g.renderingStartTime>Bi&&i!==1073741824&&(n.flags|=128,l=!0,Ao(g,!1),n.lanes=4194304);g.isBackwards?(S.sibling=n.child,n.child=S):(i=g.last,i!==null?i.sibling=S:n.child=S,g.last=S)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(St(n),null);case 22:case 23:return vu(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Gt&1073741824)!==0&&(St(n),n.subtreeFlags&6&&(n.flags|=8192)):St(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function Iy(e,n){switch(Ea(n),n.tag){case 1:return Rt(n.type)&&Es(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Di(),Ue(It),Ue(wt),Fa(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Da(n),null;case 13:if(Ue(qe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));Li()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Di(),null;case 10:return Ta(n.type._context),null;case 22:case 23:return vu(),null;case 24:return null;default:return null}}var Ys=!1,kt=!1,Ry=typeof WeakSet=="function"?WeakSet:Set,ye=null;function Fi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Ze(e,n,l)}else i.current=null}function su(e,n,i){try{i()}catch(l){Ze(e,n,l)}}var _f=!1;function Ty(e,n){if(va=hs,e=Zc(),ca(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,g=l.focusNode;l=l.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var S=0,T=-1,O=-1,ee=0,le=0,ue=e,se=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=S+f),ue!==g||l!==0&&ue.nodeType!==3||(O=S+l),ue.nodeType===3&&(S+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)se=ue,ue=ge;for(;;){if(ue===e)break t;if(se===i&&++ee===f&&(T=S),se===g&&++le===l&&(O=S),(ge=ue.nextSibling)!==null)break;ue=se,se=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(xa={focusedElem:e,selectionRange:i},hs=!1,ye=n;ye!==null;)if(n=ye,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ye=e;else for(;ye!==null;){n=ye;try{var ve=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(ve!==null){var we=ve.memoizedProps,tt=ve.memoizedState,X=n.stateNode,B=X.getSnapshotBeforeUpdate(n.elementType===n.type?we:un(n.type,we),tt);X.__reactInternalSnapshotBeforeUpdate=B}break;case 3:var Q=n.stateNode.containerInfo;Q.nodeType===1?Q.textContent="":Q.nodeType===9&&Q.documentElement&&Q.removeChild(Q.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(de){Ze(n,n.return,de)}if(e=n.sibling,e!==null){e.return=n.return,ye=e;break}ye=n.return}return ve=_f,_f=!1,ve}function $o(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&e)===e){var g=f.destroy;f.destroy=void 0,g!==void 0&&su(n,i,g)}f=f.next}while(f!==l)}}function Xs(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function lu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function Sf(e){var n=e.alternate;n!==null&&(e.alternate=null,Sf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[Pn],delete n[jo],delete n[ka],delete n[gy],delete n[my])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function kf(e){return e.tag===5||e.tag===3||e.tag===4}function Nf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||kf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function au(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=js));else if(l!==4&&(e=e.child,e!==null))for(au(e,n,i),e=e.sibling;e!==null;)au(e,n,i),e=e.sibling}function uu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(uu(e,n,i),e=e.sibling;e!==null;)uu(e,n,i),e=e.sibling}var gt=null,cn=!1;function vr(e,n,i){for(i=i.child;i!==null;)jf(e,n,i),i=i.sibling}function jf(e,n,i){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(lr,i)}catch{}switch(i.tag){case 5:kt||Fi(i,n);case 6:var l=gt,f=cn;gt=null,vr(e,n,i),gt=l,cn=f,gt!==null&&(cn?(e=gt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):gt.removeChild(i.stateNode));break;case 18:gt!==null&&(cn?(e=gt,i=i.stateNode,e.nodeType===8?Sa(e.parentNode,i):e.nodeType===1&&Sa(e,i),po(e)):Sa(gt,i.stateNode));break;case 4:l=gt,f=cn,gt=i.stateNode.containerInfo,cn=!0,vr(e,n,i),gt=l,cn=f;break;case 0:case 11:case 14:case 15:if(!kt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var g=f,S=g.destroy;g=g.tag,S!==void 0&&((g&2)!==0||(g&4)!==0)&&su(i,n,S),f=f.next}while(f!==l)}vr(e,n,i);break;case 1:if(!kt&&(Fi(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Ze(i,n,T)}vr(e,n,i);break;case 21:vr(e,n,i);break;case 22:i.mode&1?(kt=(l=kt)||i.memoizedState!==null,vr(e,n,i),kt=l):vr(e,n,i);break;default:vr(e,n,i)}}function bf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Ry),n.forEach(function(l){var f=By.bind(null,e,l);i.has(l)||(i.add(l),l.then(f,f))})}}function dn(e,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=S),l&=~g}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Ay(l/1960))-l,10e?16:e,wr===null)var l=!1;else{if(e=wr,wr=null,Js=0,($e&6)!==0)throw Error(o(331));var f=$e;for($e|=4,ye=e.current;ye!==null;){var g=ye,S=g.child;if((ye.flags&16)!==0){var T=g.deletions;if(T!==null){for(var O=0;OVe()-fu?Zr(e,0):du|=i),At(e,n)}function Of(e,n){n===0&&((e.mode&1)===0?n=1:(n=Hn,Hn<<=1,(Hn&130023424)===0&&(Hn=4194304)));var i=Ct();e=qn(e,n),e!==null&&(Vn(e,n,i),At(e,i))}function Hy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Of(e,i)}function By(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Of(e,i)}var Ff;Ff=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||It.current)Tt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Tt=!1,My(e,n,i);Tt=(e.flags&131072)!==0}else Tt=!1,Ye&&(n.flags&1048576)!==0&&vd(n,Is,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Gs(e,n),e=n.pendingProps;var f=Ii(n,wt.current);zi(n,i),f=Va(null,n,l,e,f,i);var g=Wa();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Rt(l)?(g=!0,Cs(n)):g=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,$a(n),f.updater=Ws,n.stateNode=f,f._reactInternals=n,Ka(n,l,e,i),n=eu(null,n,l,!0,g,i)):(n.tag=0,Ye&&g&&ba(n),Et(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Gs(e,n),e=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=Wy(l),e=un(l,e),f){case 0:n=Ja(null,n,l,e,i);break e;case 1:n=ff(null,n,l,e,i);break e;case 11:n=lf(null,n,l,e,i);break e;case 14:n=af(null,n,l,un(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:un(l,f),Ja(e,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:un(l,f),ff(e,n,l,f,i);case 3:e:{if(hf(n),e===null)throw Error(o(387));l=n.pendingProps,g=n.memoizedState,f=g.element,Ed(e,n),zs(n,l,null,i);var S=n.memoizedState;if(l=S.element,g.isDehydrated)if(g={element:l,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){f=Oi(Error(o(423)),n),n=pf(e,n,l,i,f);break e}else if(l!==f){f=Oi(Error(o(424)),n),n=pf(e,n,l,i,f);break e}else for(Ut=fr(n.stateNode.containerInfo.firstChild),Wt=n,Ye=!0,an=null,i=jd(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Li(),l===f){n=Qn(e,n,i);break e}Et(e,n,l,i)}n=n.child}return n;case 5:return Pd(n),e===null&&Ma(n),l=n.type,f=n.pendingProps,g=e!==null?e.memoizedProps:null,S=f.children,wa(l,f)?S=null:g!==null&&wa(l,g)&&(n.flags|=32),df(e,n),Et(e,n,S,i),n.child;case 6:return e===null&&Ma(n),null;case 13:return gf(e,n,i);case 4:return za(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=Ai(n,null,l,i):Et(e,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:un(l,f),lf(e,n,l,f,i);case 7:return Et(e,n,n.pendingProps,i),n.child;case 8:return Et(e,n,n.pendingProps.children,i),n.child;case 12:return Et(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,g=n.memoizedProps,S=f.value,Be(Ls,l._currentValue),l._currentValue=S,g!==null)if(ln(g.value,S)){if(g.children===f.children&&!It.current){n=Qn(e,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var T=g.dependencies;if(T!==null){S=g.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(g.tag===1){O=Kn(-1,i&-i),O.tag=2;var ee=g.updateQueue;if(ee!==null){ee=ee.shared;var le=ee.pending;le===null?O.next=O:(O.next=le.next,le.next=O),ee.pending=O}}g.lanes|=i,O=g.alternate,O!==null&&(O.lanes|=i),La(g.return,i,n),T.lanes|=i;break}O=O.next}}else if(g.tag===10)S=g.type===n.type?null:g.child;else if(g.tag===18){if(S=g.return,S===null)throw Error(o(341));S.lanes|=i,T=S.alternate,T!==null&&(T.lanes|=i),La(S,i,n),S=g.sibling}else S=g.child;if(S!==null)S.return=g;else for(S=g;S!==null;){if(S===n){S=null;break}if(g=S.sibling,g!==null){g.return=S.return,S=g;break}S=S.return}g=S}Et(e,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,zi(n,i),f=Jt(f),l=l(f),n.flags|=1,Et(e,n,l,i),n.child;case 14:return l=n.type,f=un(l,n.pendingProps),f=un(l.type,f),af(e,n,l,f,i);case 15:return uf(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:un(l,f),Gs(e,n),n.tag=1,Rt(l)?(e=!0,Cs(n)):e=!1,zi(n,i),Jd(n,l,f),Ka(n,l,f,i),eu(null,n,l,!0,e,i);case 19:return yf(e,n,i);case 22:return cf(e,n,i)}throw Error(o(156,n.tag))};function Hf(e,n){return or(e,n)}function Vy(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function nn(e,n,i,l){return new Vy(e,n,i,l)}function wu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Wy(e){if(typeof e=="function")return wu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Z)return 11;if(e===U)return 14}return 2}function kr(e,n){var i=e.alternate;return i===null?(i=nn(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function rl(e,n,i,l,f,g){var S=2;if(l=e,typeof e=="function")wu(e)&&(S=1);else if(typeof e=="string")S=5;else e:switch(e){case V:return ei(i.children,f,g,n);case Y:S=8,f|=8;break;case K:return e=nn(12,i,n,f|2),e.elementType=K,e.lanes=g,e;case te:return e=nn(13,i,n,f),e.elementType=te,e.lanes=g,e;case R:return e=nn(19,i,n,f),e.elementType=R,e.lanes=g,e;case W:return il(i,f,g,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case re:S=10;break e;case q:S=9;break e;case Z:S=11;break e;case U:S=14;break e;case H:S=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=nn(S,i,n,f),n.elementType=e,n.type=l,n.lanes=g,n}function ei(e,n,i,l){return e=nn(7,e,l,n),e.lanes=i,e}function il(e,n,i,l){return e=nn(22,e,l,n),e.elementType=W,e.lanes=i,e.stateNode={isHidden:!1},e}function _u(e,n,i){return e=nn(6,e,null,n),e.lanes=i,e}function Su(e,n,i){return n=nn(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Uy(e,n,i,l,f){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Bn(0),this.expirationTimes=Bn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Bn(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function ku(e,n,i,l,f,g,S,T,O){return e=new Uy(e,n,i,T,O),n===1?(n=1,g===!0&&(n|=8)):n=0,g=nn(3,null,null,n),e.current=g,g.stateNode=e,g.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},$a(g),e}function Gy(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),Mu.exports=i0(),Mu.exports}var th;function o0(){if(th)return dl;th=1;var t=_p();return dl.createRoot=t.createRoot,dl.hydrateRoot=t.hydrateRoot,dl}var s0=o0();function Sp(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Le(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(Sp(s,o.statusText||"Request failed"))}return o.json()}const l0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Pe={health:()=>Le("/api/health"),settings:()=>Le("/api/settings"),saveSettings:t=>{const r={...t};for(const o of l0)r[o]===""&&delete r[o];return Le("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Le("/api/repos"),browse:t=>Le(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Le(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Le("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Le(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Le(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:(t,r=!0)=>Le(`/api/architecture?repo_path=${encodeURIComponent(t)}&graph=${r?"1":"0"}`),architectureGraph:t=>Le(`/api/architecture/graph?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Le("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Le("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Le("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Le("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Le("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Le(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open",s)=>Le("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o,repo_path:s||null})}),scmRepos:t=>Le(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Le("/api/oauth/status"),githubOAuthStart:()=>Le("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Le("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Le("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Le("/api/oauth/gitlab/start"),oauthDisconnect:t=>Le("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Le("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})}),reviews:t=>Le(`/api/reviews?repo_path=${encodeURIComponent(t)}`),getReview:(t,r)=>Le(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(t)}`),reviewDiff:(t,r,o)=>Le(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(t)}&other=${encodeURIComponent(o)}`),config:t=>Le(`/api/config?repo_path=${encodeURIComponent(t)}`),saveConfig:(t,r)=>Le("/api/config",{method:"PUT",body:JSON.stringify({repo_path:t,...r})}),addWaiver:(t,r,o,s)=>Le("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:t,rule:r,node:o||null,reason:s||""})}),marks:(t,r)=>Le(`/api/marks?repo_path=${encodeURIComponent(t)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:t=>Le(`/api/architecture/health?repo_path=${encodeURIComponent(t)}`),workspaceStatus:t=>Le(`/api/workspace/status?repo_path=${encodeURIComponent(t)}`),openEditor:(t,r,o,s)=>Le("/api/open",{method:"POST",body:JSON.stringify({repo_path:t,path:r,line:o||null,editor:s||null})}),exportHtml:t=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:t})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(Sp(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(t,r,o,s)=>Le("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:t,edges:r,source_id:o,target_id:s||null})})};function a0(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):t}function u0({open:t,actions:r,onClose:o}){const[s,a]=L.useState(""),[u,c]=L.useState(0),h=L.useRef(null),p=L.useMemo(()=>a0(r,s),[r,s]);if(L.useEffect(()=>{if(!t)return;a(""),c(0);const y=window.setTimeout(()=>{var v;return(v=h.current)==null?void 0:v.focus()},0);return()=>window.clearTimeout(y)},[t]),L.useEffect(()=>{c(0)},[s]),!t)return null;const x=p[u],m=y=>{y&&(o(),y.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:y=>{y.target===y.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:y=>a(y.target.value),onKeyDown:y=>{y.key==="Escape"?(y.preventDefault(),o()):y.key==="ArrowDown"?(y.preventDefault(),c(v=>Math.min(p.length-1,v+1))):y.key==="ArrowUp"?(y.preventDefault(),c(v=>Math.max(0,v-1))):y.key==="Enter"&&(y.preventDefault(),m(x))}}),d.jsxs("ul",{children:[p.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,p.slice(0,40).map((y,v)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:v===u?"active":"",onMouseEnter:()=>c(v),onClick:()=>m(y),children:[d.jsx("span",{children:y.label}),y.hint?d.jsx("span",{className:"muted",children:y.hint}):null]})},y.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function c0({config:t,busy:r,onSave:o,onWaiver:s}){const[a,u]=L.useState(t),[c,h]=L.useState(t.available_rules[0]||""),[p,x]=L.useState(""),[m,y]=L.useState("");L.useEffect(()=>{u(t)},[t]);const v=Object.entries(a.contexts||{}),_=(C,k,b)=>{const A=a.contexts[C];if(!A)return;const z=V=>V.split(",").map(Y=>Y.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[C]:{...A,[k]:k==="name"?b:z(b)}}})},N=(C,k)=>{const b=k.trim();if(!b||b===C)return;const{[C]:A,...z}=a.contexts;A&&u({...a,contexts:{...z,[b]:{...A,name:b}}})},j=()=>{let C=1;for(;a.contexts[`context-${C}`];)C+=1;const k=`context-${C}`;u({...a,contexts:{...a.contexts,[k]:{name:k,django_apps:[],react:[],public_api:[],owners:[]}}})},E=C=>{const{[C]:k,...b}=a.contexts;u({...a,contexts:b})},w=C=>{const k=a.rules.includes(C);u({...a,rules:k?a.rules.filter(b=>b!==C):[...a.rules,C]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),v.map(([C,k])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:C})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:C,"data-testid":`config-context-name-${C}`,onBlur:b=>N(C,b.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(k.django_apps||[]).join(", "),onChange:b=>_(C,"django_apps",b.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(k.react||[]).join(", "),onChange:b=>_(C,"react",b.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(k.public_api||[]).join(", "),onChange:b=>_(C,"public_api",b.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(k.owners||[]).join(", "),onChange:b=>_(C,"owners",b.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>E(C),children:"Remove context"})]},C)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:j,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(C=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(C),onChange:()=>w(C)}),C]},C))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((C,k)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:C.rule}),C.node?` · ${C.node}`:"",C.reason?` — ${C.reason}`:""]},`${C.rule}:${C.node}:${k}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:C=>h(C.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(C=>d.jsx("option",{value:C,children:C},C))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:C=>x(C.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:m,onChange:C=>y(C.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,m),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function Xo(t){return t.replaceAll("_"," ")}function d0(t){return t.replaceAll("_"," ")}function to(t){return t.split(".").pop()||t}function Xu(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function f0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Cr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function ci({className:t,children:r}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function h0({className:t}){return d.jsxs(ci,{className:t,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function p0({className:t}){return d.jsxs(ci,{className:t,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function g0({className:t}){return d.jsxs(ci,{className:t,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function m0({className:t}){return d.jsxs(ci,{className:t,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function y0({className:t}){return d.jsxs(ci,{className:t,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function kp({className:t}){return d.jsx(ci,{className:t,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function v0({className:t}){return d.jsx(ci,{className:t,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const x0="modulepreload",w0=function(t,r){return new URL(t,r).href},nh={},_0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(m){return Promise.all(m.map(y=>Promise.resolve(y).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),x=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(m=>{if(m=w0(m,s),m in nh)return;nh[m]=!0;const y=m.endsWith(".css"),v=y?'[rel="stylesheet"]':"";if(!!s)for(let j=h.length-1;j>=0;j--){const E=h[j];if(E.href===m&&(!y||E.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${m}"]${v}`))return;const N=document.createElement("link");if(N.rel=y?"stylesheet":x0,y||(N.as="script"),N.crossOrigin="",N.href=m,x&&N.setAttribute("nonce",x),document.head.appendChild(N),y)return new Promise((j,E)=>{N.addEventListener("load",j),N.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${m}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function it(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Ol(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}kl.prototype=Ol.prototype={constructor:kl,on:function(t,r){var o=this._,s=k0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),ih.hasOwnProperty(r)?{space:ih[r],local:t}:t}function j0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===qu&&r.documentElement.namespaceURI===qu?r.createElement(t):r.createElementNS(o,t)}}function b0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Np(t){var r=Fl(t);return(r.local?b0:j0)(r)}function E0(){}function dc(t){return t==null?E0:function(){return this.querySelector(t)}}function C0(t){typeof t!="function"&&(t=dc(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=k&&(k=C+1);!(A=E[k])&&++k=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function J0(t){t||(t=ev);function r(y,v){return y&&v?t(y.__data__,v.__data__):!y-!v}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function tv(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function nv(){return Array.from(this)}function rv(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?pv:typeof r=="function"?mv:gv)(t,r,o??"")):Xi(this.node(),t)}function Xi(t,r){return t.style.getPropertyValue(r)||Mp(t).getComputedStyle(t,null).getPropertyValue(r)}function vv(t){return function(){delete this[t]}}function xv(t,r){return function(){this[t]=r}}function wv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function _v(t,r){return arguments.length>1?this.each((r==null?vv:typeof r=="function"?wv:xv)(t,r)):this.node()[t]}function Pp(t){return t.trim().split(/^|\s+/)}function fc(t){return t.classList||new Ip(t)}function Ip(t){this._node=t,this._names=Pp(t.getAttribute("class")||"")}Ip.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Rp(t,r){for(var o=fc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function qv(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function Ku(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:x,dispatch:m}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:x,enumerable:!0,configurable:!0},_:{value:m}})}Ku.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function ox(t){return!t.ctrlKey&&!t.button}function sx(){return this.parentNode}function lx(t,r){return r??{x:t.x,y:t.y}}function ax(){return navigator.maxTouchPoints||"ontouchstart"in this}function Dp(){var t=ox,r=sx,o=lx,s=ax,a={},u=Ol("start","drag","end"),c=0,h,p,x,m,y=0;function v(b){b.on("mousedown.drag",_).filter(s).on("touchstart.drag",E).on("touchmove.drag",w,ix).on("touchend.drag touchcancel.drag",C).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(b,A){if(!(m||!t.call(this,b,A))){var z=k(this,r.call(this,b,A),b,A,"mouse");z&&(Yt(b.view).on("mousemove.drag",N,qo).on("mouseup.drag",j,qo),$p(b.view),Ru(b),x=!1,h=b.clientX,p=b.clientY,z("start",b))}}function N(b){if(Gi(b),!x){var A=b.clientX-h,z=b.clientY-p;x=A*A+z*z>y}a.mouse("drag",b)}function j(b){Yt(b.view).on("mousemove.drag mouseup.drag",null),zp(b.view,x),Gi(b),a.mouse("end",b)}function E(b,A){if(t.call(this,b,A)){var z=b.changedTouches,V=r.call(this,b,A),Y=z.length,K,re;for(K=0;K>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?hl(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?hl(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=cx.exec(t))?new zt(r[1],r[2],r[3],1):(r=dx.exec(t))?new zt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=fx.exec(t))?hl(r[1],r[2],r[3],r[4]):(r=hx.exec(t))?hl(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=px.exec(t))?dh(r[1],r[2]/100,r[3]/100,1):(r=gx.exec(t))?dh(r[1],r[2]/100,r[3]/100,r[4]):oh.hasOwnProperty(t)?ah(oh[t]):t==="transparent"?new zt(NaN,NaN,NaN,0):null}function ah(t){return new zt(t>>16&255,t>>8&255,t&255,1)}function hl(t,r,o,s){return s<=0&&(t=r=o=NaN),new zt(t,r,o,s)}function vx(t){return t instanceof ls||(t=oi(t)),t?(t=t.rgb(),new zt(t.r,t.g,t.b,t.opacity)):new zt}function Qu(t,r,o,s){return arguments.length===1?vx(t):new zt(t,r,o,s??1)}function zt(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}hc(zt,Qu,Op(ls,{brighter(t){return t=t==null?Ml:Math.pow(Ml,t),new zt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Ko:Math.pow(Ko,t),new zt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new zt(ri(this.r),ri(this.g),ri(this.b),Pl(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:uh,formatHex:uh,formatHex8:xx,formatRgb:ch,toString:ch}));function uh(){return`#${ni(this.r)}${ni(this.g)}${ni(this.b)}`}function xx(){return`#${ni(this.r)}${ni(this.g)}${ni(this.b)}${ni((isNaN(this.opacity)?1:this.opacity)*255)}`}function ch(){const t=Pl(this.opacity);return`${t===1?"rgb(":"rgba("}${ri(this.r)}, ${ri(this.g)}, ${ri(this.b)}${t===1?")":`, ${t})`}`}function Pl(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ri(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ni(t){return t=ri(t),(t<16?"0":"")+t.toString(16)}function dh(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new pn(t,r,o,s)}function Fp(t){if(t instanceof pn)return new pn(t.h,t.s,t.l,t.opacity);if(t instanceof ls||(t=oi(t)),!t)return new pn;if(t instanceof pn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new pn(c,h,p,t.opacity)}function wx(t,r,o,s){return arguments.length===1?Fp(t):new pn(t,r,o,s??1)}function pn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}hc(pn,wx,Op(ls,{brighter(t){return t=t==null?Ml:Math.pow(Ml,t),new pn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Ko:Math.pow(Ko,t),new pn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new zt(Tu(t>=240?t-240:t+120,a,s),Tu(t,a,s),Tu(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new pn(fh(this.h),pl(this.s),pl(this.l),Pl(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 t=Pl(this.opacity);return`${t===1?"hsl(":"hsla("}${fh(this.h)}, ${pl(this.s)*100}%, ${pl(this.l)*100}%${t===1?")":`, ${t})`}`}}));function fh(t){return t=(t||0)%360,t<0?t+360:t}function pl(t){return Math.max(0,Math.min(1,t||0))}function Tu(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const pc=t=>()=>t;function _x(t,r){return function(o){return t+o*r}}function Sx(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function kx(t){return(t=+t)==1?Hp:function(r,o){return o-r?Sx(r,o,t):pc(isNaN(r)?o:r)}}function Hp(t,r){var o=r-t;return o?_x(t,o):pc(isNaN(t)?r:t)}const Il=(function t(r){var o=kx(r);function s(a,u){var c=o((a=Qu(a)).r,(u=Qu(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),x=Hp(a.opacity,u.opacity);return function(m){return a.r=c(m),a.g=h(m),a.b=p(m),a.opacity=x(m),a+""}}return s.gamma=t,s})(1);function Nx(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:Ln(s,a)})),o=Lu.lastIndex;return o180?m+=360:m-x>180&&(x+=360),v.push({i:y.push(a(y)+"rotate(",null,s)-2,x:Ln(x,m)})):m&&y.push(a(y)+"rotate("+m+s)}function h(x,m,y,v){x!==m?v.push({i:y.push(a(y)+"skewX(",null,s)-2,x:Ln(x,m)}):m&&y.push(a(y)+"skewX("+m+s)}function p(x,m,y,v,_,N){if(x!==y||m!==v){var j=_.push(a(_)+"scale(",null,",",null,")");N.push({i:j-4,x:Ln(x,y)},{i:j-2,x:Ln(m,v)})}else(y!==1||v!==1)&&_.push(a(_)+"scale("+y+","+v+")")}return function(x,m){var y=[],v=[];return x=t(x),m=t(m),u(x.translateX,x.translateY,m.translateX,m.translateY,y,v),c(x.rotate,m.rotate,y,v),h(x.skewX,m.skewX,y,v),p(x.scaleX,x.scaleY,m.scaleX,m.scaleY,y,v),x=m=null,function(_){for(var N=-1,j=v.length,E;++N=0&&t._call.call(void 0,r),t=t._next;--qi}function gh(){si=(Tl=Zo.now())+Hl,qi=Wo=0;try{Ox()}finally{qi=0,Hx(),si=0}}function Fx(){var t=Zo.now(),r=t-Tl;r>Up&&(Hl-=r,Tl=t)}function Hx(){for(var t,r=Rl,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:Rl=o);Uo=t,ec(s)}function ec(t){if(!qi){Wo&&(Wo=clearTimeout(Wo));var r=t-si;r>24?(t<1/0&&(Wo=setTimeout(gh,t-Zo.now()-Hl)),Bo&&(Bo=clearInterval(Bo))):(Bo||(Tl=Zo.now(),Bo=setInterval(Fx,Up)),qi=1,Gp(gh))}}function mh(t,r,o){var s=new Ll;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Bx=Ol("start","end","cancel","interrupt"),Vx=[],Xp=0,yh=1,tc=2,jl=3,vh=4,nc=5,bl=6;function Bl(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;Wx(t,o,{name:r,index:s,group:a,on:Bx,tween:Vx,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Xp})}function mc(t,r){var o=vn(t,r);if(o.state>Xp)throw new Error("too late; already scheduled");return o}function $n(t,r){var o=vn(t,r);if(o.state>jl)throw new Error("too late; already running");return o}function vn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Wx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=Yp(u,0,o.time);function u(x){o.state=yh,o.timer.restart(c,o.delay,o.time),o.delay<=x&&c(x-o.delay)}function c(x){var m,y,v,_;if(o.state!==yh)return p();for(m in s)if(_=s[m],_.name===o.name){if(_.state===jl)return mh(c);_.state===vh?(_.state=bl,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete s[m]):+mtc&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function ww(t,r,o){var s,a,u=xw(r)?mc:$n;return function(){var c=u(this,t),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function _w(t,r){var o=this._id;return arguments.length<2?vn(this.node(),o).on.on(t):this.each(ww(o,t,r))}function Sw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function kw(){return this.on("end.remove",Sw(this._id))}function Nw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=dc(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function qw(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function er(t,r,o){this.k=t,this.x=r,this.y=o}er.prototype={constructor:er,scale:function(t){return t===1?this:new er(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new er(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Vl=new er(1,0,0);Zp.prototype=er.prototype;function Zp(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Vl;return t.__zoom}function Au(t){t.stopImmediatePropagation()}function Vo(t){t.preventDefault(),t.stopImmediatePropagation()}function Kw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Qw(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function xh(){return this.__zoom||Vl}function Zw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Jw(){return navigator.maxTouchPoints||"ontouchstart"in this}function e1(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function Jp(){var t=Kw,r=Qw,o=e1,s=Zw,a=Jw,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=Nl,x=Ol("start","zoom","end"),m,y,v,_=500,N=150,j=0,E=10;function w(R){R.property("__zoom",xh).on("wheel.zoom",Y,{passive:!1}).on("mousedown.zoom",K).on("dblclick.zoom",re).filter(a).on("touchstart.zoom",q).on("touchmove.zoom",Z).on("touchend.zoom touchcancel.zoom",te).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}w.transform=function(R,U,H,W){var M=R.selection?R.selection():R;M.property("__zoom",xh),R!==M?A(R,U,H,W):M.interrupt().each(function(){z(this,arguments).event(W).start().zoom(null,typeof U=="function"?U.apply(this,arguments):U).end()})},w.scaleBy=function(R,U,H,W){w.scaleTo(R,function(){var M=this.__zoom.k,D=typeof U=="function"?U.apply(this,arguments):U;return M*D},H,W)},w.scaleTo=function(R,U,H,W){w.transform(R,function(){var M=r.apply(this,arguments),D=this.__zoom,F=H==null?b(M):typeof H=="function"?H.apply(this,arguments):H,I=D.invert(F),$=typeof U=="function"?U.apply(this,arguments):U;return o(k(C(D,$),F,I),M,c)},H,W)},w.translateBy=function(R,U,H,W){w.transform(R,function(){return o(this.__zoom.translate(typeof U=="function"?U.apply(this,arguments):U,typeof H=="function"?H.apply(this,arguments):H),r.apply(this,arguments),c)},null,W)},w.translateTo=function(R,U,H,W,M){w.transform(R,function(){var D=r.apply(this,arguments),F=this.__zoom,I=W==null?b(D):typeof W=="function"?W.apply(this,arguments):W;return o(Vl.translate(I[0],I[1]).scale(F.k).translate(typeof U=="function"?-U.apply(this,arguments):-U,typeof H=="function"?-H.apply(this,arguments):-H),D,c)},W,M)};function C(R,U){return U=Math.max(u[0],Math.min(u[1],U)),U===R.k?R:new er(U,R.x,R.y)}function k(R,U,H){var W=U[0]-H[0]*R.k,M=U[1]-H[1]*R.k;return W===R.x&&M===R.y?R:new er(R.k,W,M)}function b(R){return[(+R[0][0]+ +R[1][0])/2,(+R[0][1]+ +R[1][1])/2]}function A(R,U,H,W){R.on("start.zoom",function(){z(this,arguments).event(W).start()}).on("interrupt.zoom end.zoom",function(){z(this,arguments).event(W).end()}).tween("zoom",function(){var M=this,D=arguments,F=z(M,D).event(W),I=r.apply(M,D),$=H==null?b(I):typeof H=="function"?H.apply(M,D):H,ie=Math.max(I[1][0]-I[0][0],I[1][1]-I[0][1]),oe=M.__zoom,fe=typeof U=="function"?U.apply(M,D):U,he=p(oe.invert($).concat(ie/oe.k),fe.invert($).concat(ie/fe.k));return function(pe){if(pe===1)pe=fe;else{var J=he(pe),ae=ie/J[2];pe=new er(ae,$[0]-J[0]*ae,$[1]-J[1]*ae)}F.zoom(null,pe)}})}function z(R,U,H){return!H&&R.__zooming||new V(R,U)}function V(R,U){this.that=R,this.args=U,this.active=0,this.sourceEvent=null,this.extent=r.apply(R,U),this.taps=0}V.prototype={event:function(R){return R&&(this.sourceEvent=R),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(R,U){return this.mouse&&R!=="mouse"&&(this.mouse[1]=U.invert(this.mouse[0])),this.touch0&&R!=="touch"&&(this.touch0[1]=U.invert(this.touch0[0])),this.touch1&&R!=="touch"&&(this.touch1[1]=U.invert(this.touch1[0])),this.that.__zoom=U,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(R){var U=Yt(this.that).datum();x.call(R,this.that,new qw(R,{sourceEvent:this.sourceEvent,target:w,transform:this.that.__zoom,dispatch:x}),U)}};function Y(R,...U){if(!t.apply(this,arguments))return;var H=z(this,U).event(R),W=this.__zoom,M=Math.max(u[0],Math.min(u[1],W.k*Math.pow(2,s.apply(this,arguments)))),D=hn(R);if(H.wheel)(H.mouse[0][0]!==D[0]||H.mouse[0][1]!==D[1])&&(H.mouse[1]=W.invert(H.mouse[0]=D)),clearTimeout(H.wheel);else{if(W.k===M)return;H.mouse=[D,W.invert(D)],El(this),H.start()}Vo(R),H.wheel=setTimeout(F,N),H.zoom("mouse",o(k(C(W,M),H.mouse[0],H.mouse[1]),H.extent,c));function F(){H.wheel=null,H.end()}}function K(R,...U){if(v||!t.apply(this,arguments))return;var H=R.currentTarget,W=z(this,U,!0).event(R),M=Yt(R.view).on("mousemove.zoom",$,!0).on("mouseup.zoom",ie,!0),D=hn(R,H),F=R.clientX,I=R.clientY;$p(R.view),Au(R),W.mouse=[D,this.__zoom.invert(D)],El(this),W.start();function $(oe){if(Vo(oe),!W.moved){var fe=oe.clientX-F,he=oe.clientY-I;W.moved=fe*fe+he*he>j}W.event(oe).zoom("mouse",o(k(W.that.__zoom,W.mouse[0]=hn(oe,H),W.mouse[1]),W.extent,c))}function ie(oe){M.on("mousemove.zoom mouseup.zoom",null),zp(oe.view,W.moved),Vo(oe),W.event(oe).end()}}function re(R,...U){if(t.apply(this,arguments)){var H=this.__zoom,W=hn(R.changedTouches?R.changedTouches[0]:R,this),M=H.invert(W),D=H.k*(R.shiftKey?.5:2),F=o(k(C(H,D),W,M),r.apply(this,U),c);Vo(R),h>0?Yt(this).transition().duration(h).call(A,F,W,R):Yt(this).call(w.transform,F,W,R)}}function q(R,...U){if(t.apply(this,arguments)){var H=R.touches,W=H.length,M=z(this,U,R.changedTouches.length===W).event(R),D,F,I,$;for(Au(R),F=0;F`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},Jo=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],eg=["Enter"," ","Escape"],tg={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Ki;(function(t){t.Strict="strict",t.Loose="loose"})(Ki||(Ki={}));var ii;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(ii||(ii={}));var es;(function(t){t.Partial="partial",t.Full="full"})(es||(es={}));const ng={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Mr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Mr||(Mr={}));var ts;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(ts||(ts={}));var ke;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(ke||(ke={}));const wh={[ke.Left]:ke.Right,[ke.Right]:ke.Left,[ke.Top]:ke.Bottom,[ke.Bottom]:ke.Top};function rg(t){return t===null?null:t?"valid":"invalid"}const ig=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,t1=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),vc=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),as=(t,r=[0,0])=>{const{width:o,height:s}=xn(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},n1=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):vc(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,Wl(a,Al(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?Ul(s):{x:0,y:0,width:0,height:0}},us=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=Wl(o,Al(a)),s=!0)}),s?Ul(o):{x:0,y:0,width:0,height:0}},xc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,x=r.width/a,m=r.height/a,y=[];for(const v of t.values()){const{measured:_,selectable:N=!0,hidden:j=!1}=v;if(c&&!N||j)continue;const E=_.width??v.width??v.initialWidth??0,w=_.height??v.height??v.initialHeight??0,{x:C,y:k}=v.internals.positionAbsolute,b=ag(h,p,x,m,C,k,E,w),A=E*w,z=u&&b>0;(!v.internals.handleBounds||z||b>=A||v.dragging)&&y.push(v)}return y},r1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function i1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=xn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function o1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const h=i1(t,c),p=us(h),x=_c(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(x,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function og({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),h=c.parentId?o.get(c.parentId):void 0,{x:p,y:x}=h?h.internals.positionAbsolute:{x:0,y:0},m=c.origin??s;let y=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",yn.error005());else{const{width:_,height:N}=xn(h);_&&N&&(y=[[p,x],[p+_,x+N]])}else h&&ai(c.extent)&&(y=[[c.extent[0][0]+p,c.extent[0][1]+x],[c.extent[1][0]+p,c.extent[1][1]+x]]);const v=ai(y)?li(r,y,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",yn.error015())),{position:{x:v.x-p+(c.measured.width??0)*m[0],y:v.y-x+(c.measured.height??0)*m[1]},positionAbsolute:v}}async function s1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(v=>v.id)),c=[];for(const v of o){if(v.deletable===!1)continue;const _=u.has(v.id),N=!_&&v.parentId&&c.find(j=>j.id===v.parentId);(_||N)&&c.push(v)}const h=new Set(r.map(v=>v.id)),p=s.filter(v=>v.deletable!==!1),m=r1(c,p);for(const v of p)h.has(v.id)&&!m.find(N=>N.id===v.id)&&m.push(v);if(!a)return{edges:m,nodes:c};const y=await a({nodes:c,edges:m});return typeof y=="boolean"?y?{edges:m,nodes:c}:{edges:[],nodes:[]}:y}const Qi=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),li=(t={x:0,y:0},r,o)=>({x:Qi(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:Qi(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function sg(t,r,o){const{width:s,height:a}=xn(o),{x:u,y:c}=o.internals.positionAbsolute;return li(t,[[u,c],[u+s,c+a]],r)}const _h=(t,r,o)=>to?-Qi(Math.abs(t-o),1,r)/r:0,wc=(t,r,o=15,s=40)=>{const a=_h(t.x,s,r.width-s)*o,u=_h(t.y,s,r.height-s)*o;return[a,u]},Wl=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),rc=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),Ul=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),ns=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=vc(t)?t.internals.positionAbsolute:as(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},Al=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=vc(t)?t.internals.positionAbsolute:as(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},lg=(t,r)=>Ul(Wl(rc(t),rc(r))),ag=(t,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),x=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*x)},$l=(t,r)=>ag(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),Sh=t=>gn(t.width)&&gn(t.height)&&gn(t.x)&&gn(t.y),gn=t=>!isNaN(t)&&isFinite(t),ug=(t,r)=>(o,s)=>{},cs=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),ds=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(t-o)/a,y:(r-s)/a};return u?cs(h,c):h},Zi=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Wi(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function l1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Wi(t,o),a=Wi(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Wi(t.top??t.y??0,o),a=Wi(t.bottom??t.y??0,o),u=Wi(t.left??t.x??0,r),c=Wi(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function a1(t,r,o,s,a,u){const{x:c,y:h}=Zi(t,[r,o,s]),{x:p,y:x}=Zi({x:t.x+t.width,y:t.y+t.height},[r,o,s]),m=a-p,y=u-x;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(m),bottom:Math.floor(y)}}const _c=(t,r,o,s,a,u)=>{const c=l1(u,r,o),h=(r-c.x)/t.width,p=(o-c.y)/t.height,x=Math.min(h,p),m=Qi(x,s,a),y=t.x+t.width/2,v=t.y+t.height/2,_=r/2-y*m,N=o/2-v*m,j=a1(t,_,N,m,r,o),E={left:Math.min(j.left-c.left,0),top:Math.min(j.top-c.top,0),right:Math.min(j.right-c.right,0),bottom:Math.min(j.bottom-c.bottom,0)};return{x:_-E.left+E.right,y:N-E.top+E.bottom,zoom:m}},rs=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function ai(t){return t!=null&&t!=="parent"}function xn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function cg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function dg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function kh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function u1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function c1(t){return{...tg,...t||{}}}function Yo(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=mn(t),h=ds({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y:x}=o?cs(h,r):h;return{xSnapped:p,ySnapped:x,...h}}const Sc=t=>({width:t.offsetWidth,height:t.offsetHeight}),fg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},d1=["INPUT","SELECT","TEXTAREA"];function hg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:d1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const pg=t=>"clientX"in t,mn=(t,r)=>{var u,c;const o=pg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},Nh=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...Sc(c)}})};function gg({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=t*.125+a*.375+c*.375+o*.125,x=r*.125+u*.375+h*.375+s*.125,m=Math.abs(p-t),y=Math.abs(x-r);return[p,x,m,y]}function yl(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function jh({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case ke.Left:return[r-yl(r-s,u),o];case ke.Right:return[r+yl(s-r,u),o];case ke.Top:return[r,o-yl(o-a,u)];case ke.Bottom:return[r,o+yl(a-o,u)]}}function mg({sourceX:t,sourceY:r,sourcePosition:o=ke.Bottom,targetX:s,targetY:a,targetPosition:u=ke.Top,curvature:c=.25}){const[h,p]=jh({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[x,m]=jh({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[y,v,_,N]=gg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:x,targetControlY:m});return[`M${t},${r} C${h},${p} ${x},${m} ${s},${a}`,y,v,_,N]}function yg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const p1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,g1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),m1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",yn.error006()),r;const s=o.getEdgeId||p1;let a;return ig(t)?a={...t}:a={...t,id:s(t)},g1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function vg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=yg({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,h]}const bh={[ke.Left]:{x:-1,y:0},[ke.Right]:{x:1,y:0},[ke.Top]:{x:0,y:-1},[ke.Bottom]:{x:0,y:1}},y1=({source:t,sourcePosition:r=ke.Bottom,target:o})=>r===ke.Left||r===ke.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function v1({source:t,sourcePosition:r=ke.Bottom,target:o,targetPosition:s=ke.Top,center:a,offset:u,stepPosition:c}){const h=bh[r],p=bh[s],x={x:t.x+h.x*u,y:t.y+h.y*u},m={x:o.x+p.x*u,y:o.y+p.y*u},y=y1({source:x,sourcePosition:r,target:m}),v=y.x!==0?"x":"y",_=y[v];let N=[],j,E;const w={x:0,y:0},C={x:0,y:0},[,,k,b]=yg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[v]*p[v]===-1){v==="x"?(j=a.x??x.x+(m.x-x.x)*c,E=a.y??(x.y+m.y)/2):(j=a.x??(x.x+m.x)/2,E=a.y??x.y+(m.y-x.y)*c);const Y=[{x:j,y:x.y},{x:j,y:m.y}],K=[{x:x.x,y:E},{x:m.x,y:E}];h[v]===_?N=v==="x"?Y:K:N=v==="x"?K:Y}else{const Y=[{x:x.x,y:m.y}],K=[{x:m.x,y:x.y}];if(v==="x"?N=h.x===_?K:Y:N=h.y===_?Y:K,r===s){const R=Math.abs(t[v]-o[v]);if(R<=u){const U=Math.min(u-1,u-R);h[v]===_?w[v]=(x[v]>t[v]?-1:1)*U:C[v]=(m[v]>o[v]?-1:1)*U}}if(r!==s){const R=v==="x"?"y":"x",U=h[v]===p[R],H=x[R]>m[R],W=x[R]=te?(j=(re.x+q.x)/2,E=N[0].y):(j=N[0].x,E=(re.y+q.y)/2)}const A={x:x.x+w.x,y:x.y+w.y},z={x:m.x+C.x,y:m.y+C.y};return[[t,...A.x!==N[0].x||A.y!==N[0].y?[A]:[],...N,...z.x!==N[N.length-1].x||z.y!==N[N.length-1].y?[z]:[],o],j,E,k,b]}function x1(t,r,o,s){const a=Math.min(Eh(t,r)/2,Eh(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const x=t.xo.id===r):t[0])||null}function oc(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function _1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const x=oc(p,r);u.has(x)||(c.push({id:x,color:p.color||o,...p}),u.add(x))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const xg=1e3,S1=10,kc={nodeOrigin:[0,0],nodeExtent:Jo,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},k1={...kc,checkEquality:!0};function Nc(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function N1(t,r,o){const s=Nc(kc,o);for(const a of t.values())if(a.parentId)bc(a,t,r,s);else{const u=as(a,s.nodeOrigin),c=ai(a.extent)?a.extent:s.nodeExtent,h=li(u,c,xn(a));a.internals.positionAbsolute=h}}function j1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function jc(t){return t==="manual"}function sc(t,r,o,s={}){var m,y;const a=Nc(k1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!jc(a.zIndexMode)?xg:0;let p=t.length>0,x=!1;r.clear(),o.clear();for(const v of t){let _=c.get(v.id);if(a.checkEquality&&v===(_==null?void 0:_.internals.userNode))r.set(v.id,_);else{const N=as(v,a.nodeOrigin),j=ai(v.extent)?v.extent:a.nodeExtent,E=li(N,j,xn(v));_={...a.defaults,...v,measured:{width:(m=v.measured)==null?void 0:m.width,height:(y=v.measured)==null?void 0:y.height},internals:{positionAbsolute:E,handleBounds:j1(v,_),z:wg(v,h,a.zIndexMode),userNode:v}},r.set(v.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),v.parentId&&bc(_,r,o,s,u),x||(x=v.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:x}}function b1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function bc(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=Nc(kc,s),x=t.parentId,m=r.get(x);if(!m){console.warn(`Parent node ${x} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}b1(t,o),a&&!m.parentId&&m.internals.rootParentIndex===void 0&&p==="auto"&&(m.internals.rootParentIndex=++a.i,m.internals.z=m.internals.z+a.i*S1),a&&m.internals.rootParentIndex!==void 0&&(a.i=m.internals.rootParentIndex);const y=u&&!jc(p)?xg:0,{x:v,y:_,z:N}=E1(t,m,c,h,y,p),{positionAbsolute:j}=t.internals,E=v!==j.x||_!==j.y;(E||N!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:E?{x:v,y:_}:j,z:N}})}function wg(t,r,o){const s=gn(t.zIndex)?t.zIndex:0;return jc(o)?s:s+(t.selected?r:0)}function E1(t,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=xn(t),x=as(t,o),m=ai(t.extent)?li(x,t.extent,p):x;let y=li({x:c+m.x,y:h+m.y},s,p);t.extent==="parent"&&(y=sg(y,p,r));const v=wg(t,a,u),_=r.internals.z??0;return{x:y.x,y:y.y,z:_>=v?_+1:v}}function Ec(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const x=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??ns(p),m=lg(x,h.rect);u.set(h.parentId,{expandedRect:m,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},x)=>{var k;const m=p.internals.positionAbsolute,y=xn(p),v=p.origin??s,_=h.x0||N>0||w||C)&&(a.push({id:x,type:"position",position:{x:p.position.x-_+w,y:p.position.y-N+C}}),(k=o.get(x))==null||k.forEach(b=>{t.some(A=>A.id===b.id)||a.push({id:b.id,type:"position",position:{x:b.position.x+_,y:b.position.y+N}})})),(y.width0){const _=Ec(v,r,o,a);x.push(..._)}return{changes:x,updatedInternals:p}}async function M1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Ih(t,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${t}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${t}-${u}`;const x=s.get(c)||new Map;s.set(c,x.set(o,r))}}function _g(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},x=`${a}-${c}--${u}-${h}`,m=`${u}-${h}--${a}-${c}`;Ih("source",p,m,t,a,c),Ih("target",p,x,t,u,h),r.set(s.id,s)}}function Sg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:Sg(o,r):!1}function Rh(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function P1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!Sg(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function $u({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[x,m]of r){const y=(c=o.get(x))==null?void 0:c.internals.userNode;y&&a.push({...y,position:m.position,dragging:s})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function I1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=cs(u,r);return{x:c.x-u.x,y:c.y-u.y}}function R1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,x={x:0,y:0},m=null,y=!1,v=null,_=!1,N=!1,j=null;function E({noDragClassName:C,handleSelector:k,domNode:b,isSelectable:A,nodeId:z,nodeClickDistance:V=0}){v=Yt(b);function Y({x:Z,y:te}){const{nodeLookup:R,nodeExtent:U,snapGrid:H,snapToGrid:W,nodeOrigin:M,onNodeDrag:D,onSelectionDrag:F,onError:I,updateNodePositions:$}=r();u={x:Z,y:te};let ie=!1;const oe=h.size>1,fe=oe&&U?rc(us(h)):null,he=oe&&W?I1({dragItems:h,snapGrid:H,x:Z,y:te}):null;for(const[pe,J]of h){if(!R.has(pe))continue;let ae={x:Z-J.distance.x,y:te-J.distance.y};W&&(ae=he?{x:Math.round(ae.x+he.x),y:Math.round(ae.y+he.y)}:cs(ae,H));let me=null;if(oe&&U&&!J.extent&&fe){const{positionAbsolute:ne}=J.internals,je=ne.x-fe.x+U[0][0],Me=ne.x+J.measured.width-fe.x2+U[1][0],Te=ne.y-fe.y+U[0][1],De=ne.y+J.measured.height-fe.y2+U[1][1];me=[[je,Te],[Me,De]]}const{position:Ne,positionAbsolute:xe}=og({nodeId:pe,nextPosition:ae,nodeLookup:R,nodeExtent:me||U,nodeOrigin:M,onError:I});ie=ie||J.position.x!==Ne.x||J.position.y!==Ne.y,J.position=Ne,J.internals.positionAbsolute=xe}if(N=N||ie,!!ie&&($(h,!0),j&&(s||D||!z&&F))){const[pe,J]=$u({nodeId:z,dragItems:h,nodeLookup:R});s==null||s(j,h,pe,J),D==null||D(j,pe,J),z||F==null||F(j,J)}}async function K(){if(!m)return;const{transform:Z,panBy:te,autoPanSpeed:R,autoPanOnNodeDrag:U}=r();if(!U){p=!1,cancelAnimationFrame(c);return}const[H,W]=wc(x,m,R);(H!==0||W!==0)&&(u.x=(u.x??0)-H/Z[2],u.y=(u.y??0)-W/Z[2],await te({x:H,y:W})&&Y(u)),c=requestAnimationFrame(K)}function re(Z){var oe;const{nodeLookup:te,multiSelectionActive:R,nodesDraggable:U,transform:H,snapGrid:W,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:F,onSelectionDragStart:I,unselectNodesAndEdges:$}=r();y=!0,(!D||!A)&&!R&&z&&((oe=te.get(z))!=null&&oe.selected||$()),A&&D&&z&&(t==null||t(z));const ie=Yo(Z.sourceEvent,{transform:H,snapGrid:W,snapToGrid:M,containerBounds:m});if(u=ie,h=P1(te,U,ie,z),h.size>0&&(o||F||!z&&I)){const[fe,he]=$u({nodeId:z,dragItems:h,nodeLookup:te});o==null||o(Z.sourceEvent,h,fe,he),F==null||F(Z.sourceEvent,fe,he),z||I==null||I(Z.sourceEvent,he)}}const q=Dp().clickDistance(V).on("start",Z=>{const{domNode:te,nodeDragThreshold:R,transform:U,snapGrid:H,snapToGrid:W}=r();m=(te==null?void 0:te.getBoundingClientRect())||null,_=!1,N=!1,j=Z.sourceEvent,R===0&&re(Z),u=Yo(Z.sourceEvent,{transform:U,snapGrid:H,snapToGrid:W,containerBounds:m}),x=mn(Z.sourceEvent,m)}).on("drag",Z=>{const{autoPanOnNodeDrag:te,transform:R,snapGrid:U,snapToGrid:H,nodeDragThreshold:W,nodeLookup:M}=r(),D=Yo(Z.sourceEvent,{transform:R,snapGrid:U,snapToGrid:H,containerBounds:m});if(j=Z.sourceEvent,(Z.sourceEvent.type==="touchmove"&&Z.sourceEvent.touches.length>1||z&&!M.has(z))&&(_=!0),!_){if(!p&&te&&y&&(p=!0,K()),!y){const F=mn(Z.sourceEvent,m),I=F.x-x.x,$=F.y-x.y;Math.sqrt(I*I+$*$)>W&&re(Z)}(u.x!==D.xSnapped||u.y!==D.ySnapped)&&h&&y&&(x=mn(Z.sourceEvent,m),Y(D))}}).on("end",Z=>{if(!y||_){_&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,y=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:te,updateNodePositions:R,onNodeDragStop:U,onSelectionDragStop:H}=r();if(N&&(R(h,!1),N=!1),a||U||!z&&H){const[W,M]=$u({nodeId:z,dragItems:h,nodeLookup:te,dragging:!1});a==null||a(Z.sourceEvent,h,W,M),U==null||U(Z.sourceEvent,W,M),z||H==null||H(Z.sourceEvent,M)}}}).filter(Z=>{const te=Z.target;return!Z.button&&(!C||!Rh(te,`.${C}`,b))&&(!k||Rh(te,k,b))});v.call(q)}function w(){v==null||v.on(".drag",null)}return{update:E,destroy:w}}function T1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())$l(a,ns(u))>0&&s.push(u);return s}const L1=250;function A1(t,r,o,s){var h,p;let a=[],u=1/0;const c=T1(t,o,r+L1);for(const x of c){const m=[...((h=x.internals.handleBounds)==null?void 0:h.source)??[],...((p=x.internals.handleBounds)==null?void 0:p.target)??[]];for(const y of m){if(s.nodeId===y.nodeId&&s.type===y.type&&s.id===y.id)continue;const{x:v,y:_}=ui(x,y,y.position,!0),N=Math.sqrt(Math.pow(v-t.x,2)+Math.pow(_-t.y,2));N>r||(N1){const x=s.type==="source"?"target":"source";return a.find(m=>m.type===x)??a[0]}return a[0]}function kg(t,r,o,s,a,u=!1){var x,m,y;const c=s.get(t);if(!c)return null;const h=a==="strict"?(x=c.internals.handleBounds)==null?void 0:x[r]:[...((m=c.internals.handleBounds)==null?void 0:m.source)??[],...((y=c.internals.handleBounds)==null?void 0:y.target)??[]],p=(o?h==null?void 0:h.find(v=>v.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...ui(c,p,p.position,!0)}:p}function Ng(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function $1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const jg=()=>!0;function z1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:x,autoPanOnConnect:m,flowId:y,panBy:v,cancelConnection:_,onConnectStart:N,onConnect:j,onConnectEnd:E,isValidConnection:w=jg,onReconnectEnd:C,updateConnection:k,getTransform:b,getFromHandle:A,autoPanSpeed:z,dragThreshold:V=1,handleDomNode:Y}){const K=fg(t.target);let re=0,q;const{x:Z,y:te}=mn(t),R=Ng(u,Y),U=h==null?void 0:h.getBoundingClientRect();let H=!1;if(!U||!R)return;const W=kg(a,R,s,p,r);if(!W)return;let M=mn(t,U),D=!1,F=null,I=!1,$=null;function ie(){if(!m||!U)return;const[Ne,xe]=wc(M,U,z);v({x:Ne,y:xe}),re=requestAnimationFrame(ie)}const oe={...W,nodeId:a,type:R,position:W.position},fe=p.get(a);let pe={inProgress:!0,isValid:null,from:ui(fe,oe,ke.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:fe,to:M,toHandle:null,toPosition:wh[oe.position],toNode:null,pointer:M};function J(){H=!0,k(pe),N==null||N(t,{nodeId:a,handleId:s,handleType:R})}V===0&&J();function ae(Ne){if(!H){const{x:De,y:ht}=mn(Ne),Je=De-Z,Xe=ht-te;if(!(Je*Je+Xe*Xe>V*V))return;J()}if(!A()||!oe){me(Ne);return}const xe=b();M=mn(Ne,U),q=A1(ds(M,xe,!1,[1,1]),o,p,oe),D||(ie(),D=!0);const ne=bg(Ne,{handle:q,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:w,doc:K,lib:x,flowId:y,nodeLookup:p});$=ne.handleDomNode,F=ne.connection,I=$1(!!q,ne.isValid);const je=p.get(a),Me=je?ui(je,oe,ke.Left,!0):pe.from,Te={...pe,from:Me,isValid:I,to:ne.toHandle&&I?Zi({x:ne.toHandle.x,y:ne.toHandle.y},xe):M,toHandle:ne.toHandle,toPosition:I&&ne.toHandle?ne.toHandle.position:wh[oe.position],toNode:ne.toHandle?p.get(ne.toHandle.nodeId):null,pointer:M};k(Te),pe=Te}function me(Ne){if(!("touches"in Ne&&Ne.touches.length>0)){if(H){(q||$)&&F&&I&&(j==null||j(F));const{inProgress:xe,...ne}=pe,je={...ne,toPosition:pe.toHandle?pe.toPosition:null};E==null||E(Ne,je),u&&(C==null||C(Ne,je))}_(),cancelAnimationFrame(re),D=!1,I=!1,F=null,$=null,K.removeEventListener("mousemove",ae),K.removeEventListener("mouseup",me),K.removeEventListener("touchmove",ae),K.removeEventListener("touchend",me)}}K.addEventListener("mousemove",ae),K.addEventListener("mouseup",me),K.addEventListener("touchmove",ae),K.addEventListener("touchend",me)}function bg(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:x=jg,nodeLookup:m}){const y=u==="target",v=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:N}=mn(t),j=c.elementFromPoint(_,N),E=j!=null&&j.classList.contains(`${h}-flow__handle`)?j:v,w={handleDomNode:E,isValid:!1,connection:null,toHandle:null};if(E){const C=Ng(void 0,E),k=E.getAttribute("data-nodeid"),b=E.getAttribute("data-handleid"),A=E.classList.contains("connectable"),z=E.classList.contains("connectableend");if(!k||!C)return w;const V={source:y?k:s,sourceHandle:y?b:a,target:y?s:k,targetHandle:y?a:b};w.connection=V;const K=A&&z&&(o===Ki.Strict?y&&C==="source"||!y&&C==="target":k!==s||b!==a);w.isValid=K&&x(V),w.toHandle=kg(k,C,b,m,o,!0)}return w}const lc={onPointerDown:z1,isValid:bg};function D1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Yt(t);function u({translateExtent:h,width:p,height:x,zoomStep:m=1,pannable:y=!0,zoomable:v=!0,inversePan:_=!1}){const N=k=>{if(k.sourceEvent.type!=="wheel"||!r)return;const b=o(),A=k.sourceEvent.ctrlKey&&rs()?10:1,z=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*m,V=b[2]*Math.pow(2,z*A);r.scaleTo(V)};let j=[0,0];const E=k=>{(k.sourceEvent.type==="mousedown"||k.sourceEvent.type==="touchstart")&&(j=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY])},w=k=>{const b=o();if(k.sourceEvent.type!=="mousemove"&&k.sourceEvent.type!=="touchmove"||!r)return;const A=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY],z=[A[0]-j[0],A[1]-j[1]];j=A;const V=s()*Math.max(b[2],Math.log(b[2]))*(_?-1:1),Y={x:b[0]-z[0]*V,y:b[1]-z[1]*V},K=[[0,0],[p,x]];r.setViewportConstrained({x:Y.x,y:Y.y,zoom:b[2]},K,h)},C=Jp().on("start",E).on("zoom",y?w:null).on("zoom.wheel",v?N:null);a.call(C,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:hn}}const Gl=t=>({x:t.x,y:t.y,zoom:t.k}),zu=({x:t,y:r,zoom:o})=>Vl.translate(t,r).scale(o),Er=(t,r)=>t.target.closest(`.${r}`),Eg=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),O1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Du=(t,r=0,o=O1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Cg=t=>{const r=t.ctrlKey&&rs()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function F1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:x}){return m=>{if(Er(m,r))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const y=o.property("__zoom").k||1;if(m.ctrlKey&&c){const E=hn(m),w=Cg(m),C=y*Math.pow(2,w);s.scaleTo(o,C,E,m);return}const v=m.deltaMode===1?20:1;let _=a===ii.Vertical?0:m.deltaX*v,N=a===ii.Horizontal?0:m.deltaY*v;!rs()&&m.shiftKey&&a!==ii.Vertical&&(_=m.deltaY*v,N=0),s.translateBy(o,-(_/y)*u,-(N/y)*u,{internal:!0});const j=Gl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(m,j):(t.isPanScrolling=!0,h==null||h(m,j)),t.panScrollTimeout=setTimeout(()=>{x==null||x(m,j),t.isPanScrolling=!1},150)}}function H1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=Er(s,t);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function B1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=Gl(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function V1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;t.usedRightMouseButton=!!(o&&Eg(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,Gl(u.transform)))}}function W1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&Eg(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const p=Gl(c.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function U1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:x,lib:m,connectionInProgress:y}){return v=>{var w;const _=r||o,N=s&&v.ctrlKey,j=v.type==="wheel";if(v.button===1&&v.type==="mousedown"&&(Er(v,`${m}-flow__node`)||Er(v,`${m}-flow__edge`)||Er(v,`${m}-flow__selection`)||Er(v,`${m}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!c&&!s||h||y&&!j||Er(v,p)&&j||Er(v,x)&&(!j||u&&j&&!r)||!s&&v.ctrlKey&&j)return!1;if(!s&&v.type==="touchstart"&&((w=v.touches)==null?void 0:w.length)>1)return v.preventDefault(),!1;if(!_&&!u&&!N&&j||!a&&(v.type==="mousedown"||v.type==="touchstart")||Array.isArray(a)&&!a.includes(v.button)&&v.type==="mousedown")return!1;const E=Array.isArray(a)&&a.includes(v.button)||!v.button||v.button<=1;return(!v.ctrlKey||j||t)&&E}}function G1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const x={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},m=t.getBoundingClientRect();let y=[[0,0],[m.width,m.height]];const v=typeof ResizeObserver<"u"?new ResizeObserver(te=>{const R=te[0];R&&(y=[[0,0],[R.contentRect.width,R.contentRect.height]])}):null;v==null||v.observe(t);const _=Jp().extent(()=>y).scaleExtent([r,o]).translateExtent(s),N=Yt(t).call(_);b({x:a.x,y:a.y,zoom:Qi(a.zoom,r,o)},[[0,0],[m.width,m.height]],s);const j=N.on("wheel.zoom"),E=N.on("dblclick.zoom");_.wheelDelta(Cg);async function w(te,R){return N?new Promise(U=>{_==null||_.interpolate((R==null?void 0:R.interpolate)==="linear"?Go:Nl).transform(Du(N,R==null?void 0:R.duration,R==null?void 0:R.ease,()=>U(!0)),te)}):!1}function C({noWheelClassName:te,noPanClassName:R,onPaneContextMenu:U,userSelectionActive:H,panOnScroll:W,panOnDrag:M,panOnScrollMode:D,panOnScrollSpeed:F,preventScrolling:I,zoomOnPinch:$,zoomOnScroll:ie,zoomOnDoubleClick:oe,panActivationKeyPressed:fe=!1,zoomActivationKeyPressed:he,lib:pe,onTransformChange:J,connectionInProgress:ae,paneClickDistance:me,selectionOnDrag:Ne}){H&&!x.isZoomingOrPanning&&k();const xe=W&&!he&&!H;_.clickDistance(Ne?1/0:!gn(me)||me<0?0:me);const ne=xe?F1({zoomPanValues:x,noWheelClassName:te,d3Selection:N,d3Zoom:_,panOnScrollMode:D,panOnScrollSpeed:F,zoomOnPinch:$,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):H1({noWheelClassName:te,preventScrolling:I,d3ZoomHandler:j});N.on("wheel.zoom",ne,{passive:!1});const je=B1({zoomPanValues:x,onDraggingChange:p,onPanZoomStart:c});_.on("start",je);const Me=V1({zoomPanValues:x,panOnDrag:M,onPaneContextMenu:!!U,onPanZoom:u,onTransformChange:J});_.on("zoom",Me);const Te=W1({zoomPanValues:x,panOnDrag:M,panOnScroll:W,onPaneContextMenu:U,onPanZoomEnd:h,onDraggingChange:p});_.on("end",Te);const De=U1({panActivationKeyPressed:fe,zoomActivationKeyPressed:he,panOnDrag:M,zoomOnScroll:ie,panOnScroll:W,zoomOnDoubleClick:oe,zoomOnPinch:$,userSelectionActive:H,noPanClassName:R,noWheelClassName:te,lib:pe,connectionInProgress:ae});_.filter(De),oe?N.on("dblclick.zoom",E):N.on("dblclick.zoom",null)}function k(){_.on("zoom",null)}async function b(te,R,U){const H=zu(te),W=_==null?void 0:_.constrain()(H,R,U);return W&&await w(W),W}async function A(te,R){const U=zu(te);return await w(U,R),U}function z(te){if(N){const R=zu(te),U=N.property("__zoom");(U.k!==te.zoom||U.x!==te.x||U.y!==te.y)&&(_==null||_.transform(N,R,null,{sync:!0}))}}function V(){const te=N?Zp(N.node()):{x:0,y:0,k:1};return{x:te.x,y:te.y,zoom:te.k}}async function Y(te,R){return N?new Promise(U=>{_==null||_.interpolate((R==null?void 0:R.interpolate)==="linear"?Go:Nl).scaleTo(Du(N,R==null?void 0:R.duration,R==null?void 0:R.ease,()=>U(!0)),te)}):!1}async function K(te,R){return N?new Promise(U=>{_==null||_.interpolate((R==null?void 0:R.interpolate)==="linear"?Go:Nl).scaleBy(Du(N,R==null?void 0:R.duration,R==null?void 0:R.ease,()=>U(!0)),te)}):!1}function re(te){_==null||_.scaleExtent(te)}function q(te){_==null||_.translateExtent(te)}function Z(te){const R=!gn(te)||te<0?0:te;_==null||_.clickDistance(R)}return{update:C,destroy:k,setViewport:A,setViewportConstrained:b,getViewport:V,scaleTo:Y,scaleBy:K,setScaleExtent:re,setTranslateExtent:q,syncViewport:z,setClickDistance:Z}}var Ji;(function(t){t.Line="line",t.Handle="handle"})(Ji||(Ji={}));function Y1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function Th(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function jr(t,r){return Math.max(0,r-t)}function br(t,r){return Math.max(0,t-r)}function vl(t,r,o){return Math.max(0,r-t,t-o)}function Lh(t,r){return t?!r:r}function X1(t,r,o,s,a,u,c,h){let{affectsX:p,affectsY:x}=r;const{isHorizontal:m,isVertical:y}=r,v=m&&y,{xSnapped:_,ySnapped:N}=o,{minWidth:j,maxWidth:E,minHeight:w,maxHeight:C}=s,{x:k,y:b,width:A,height:z,aspectRatio:V}=t;let Y=Math.floor(m?_-t.pointerX:0),K=Math.floor(y?N-t.pointerY:0);const re=A+(p?-Y:Y),q=z+(x?-K:K),Z=-u[0]*A,te=-u[1]*z;let R=vl(re,j,E),U=vl(q,w,C);if(c){let M=0,D=0;p&&Y<0?M=jr(k+Y+Z,c[0][0]):!p&&Y>0&&(M=br(k+re+Z,c[1][0])),x&&K<0?D=jr(b+K+te,c[0][1]):!x&&K>0&&(D=br(b+q+te,c[1][1])),R=Math.max(R,M),U=Math.max(U,D)}if(h){let M=0,D=0;p&&Y>0?M=br(k+Y,h[0][0]):!p&&Y<0&&(M=jr(k+re,h[1][0])),x&&K>0?D=br(b+K,h[0][1]):!x&&K<0&&(D=jr(b+q,h[1][1])),R=Math.max(R,M),U=Math.max(U,D)}if(a){if(m){const M=vl(re/V,w,C)*V;if(R=Math.max(R,M),c){let D=0;!p&&!x||p&&!x&&v?D=br(b+te+re/V,c[1][1])*V:D=jr(b+te+(p?Y:-Y)/V,c[0][1])*V,R=Math.max(R,D)}if(h){let D=0;!p&&!x||p&&!x&&v?D=jr(b+re/V,h[1][1])*V:D=br(b+(p?Y:-Y)/V,h[0][1])*V,R=Math.max(R,D)}}if(y){const M=vl(q*V,j,E)/V;if(U=Math.max(U,M),c){let D=0;!p&&!x||x&&!p&&v?D=br(k+q*V+Z,c[1][0])/V:D=jr(k+(x?K:-K)*V+Z,c[0][0])/V,U=Math.max(U,D)}if(h){let D=0;!p&&!x||x&&!p&&v?D=jr(k+q*V,h[1][0])/V:D=br(k+(x?K:-K)*V,h[0][0])/V,U=Math.max(U,D)}}}K=K+(K<0?U:-U),Y=Y+(Y<0?R:-R),a&&(v?re>q*V?K=(Lh(p,x)?-Y:Y)/V:Y=(Lh(p,x)?-K:K)*V:m?(K=Y/V,x=p):(Y=K*V,p=x));const H=p?k+Y:k,W=x?b+K:b;return{width:A+(p?-Y:Y),height:z+(x?-K:K),x:u[0]*Y*(p?-1:1)+H,y:u[1]*K*(x?-1:1)+W}}const Mg={width:0,height:0,x:0,y:0},q1={...Mg,pointerX:0,pointerY:0,aspectRatio:1};function K1(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function Q1({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Yt(t);let c={controlDirection:Th("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:x,boundaries:m,keepAspectRatio:y,resizeDirection:v,onResizeStart:_,onResize:N,onResizeEnd:j,shouldResize:E}){let w={...Mg},C={...q1};c={boundaries:m,resizeDirection:v,keepAspectRatio:y,controlDirection:Th(x)};let k,b=null,A=[],z,V,Y,K=!1;const re=Dp().on("start",q=>{const{nodeLookup:Z,transform:te,snapGrid:R,snapToGrid:U,nodeOrigin:H,paneDomNode:W}=o();if(k=Z.get(r),!k)return;b=(W==null?void 0:W.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:D}=Yo(q.sourceEvent,{transform:te,snapGrid:R,snapToGrid:U,containerBounds:b});w={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},C={...w,pointerX:M,pointerY:D,aspectRatio:w.width/w.height},z=void 0,V=ai(k.extent)?k.extent:void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(z=Z.get(k.parentId)),z&&k.extent==="parent"&&(V=[[0,0],[z.measured.width,z.measured.height]]),A=[],Y=void 0;for(const[F,I]of Z)if(I.parentId===r&&(A.push({id:F,position:{...I.position},extent:I.extent}),I.extent==="parent"||I.expandParent)){const $=K1(I,k,I.origin??H);Y?Y=[[Math.min($[0][0],Y[0][0]),Math.min($[0][1],Y[0][1])],[Math.max($[1][0],Y[1][0]),Math.max($[1][1],Y[1][1])]]:Y=$}_==null||_(q,{...w})}).on("drag",q=>{const{transform:Z,snapGrid:te,snapToGrid:R,nodeOrigin:U}=o(),H=Yo(q.sourceEvent,{transform:Z,snapGrid:te,snapToGrid:R,containerBounds:b}),W=[];if(!k)return;const{x:M,y:D,width:F,height:I}=w,$={},ie=k.origin??U,{width:oe,height:fe,x:he,y:pe}=X1(C,c.controlDirection,H,c.boundaries,c.keepAspectRatio,ie,V,Y),J=oe!==F,ae=fe!==I,me=he!==M&&J,Ne=pe!==D&&ae;if(!me&&!Ne&&!J&&!ae)return;if((me||Ne||ie[0]===1||ie[1]===1)&&($.x=me?he:w.x,$.y=Ne?pe:w.y,w.x=$.x,w.y=$.y,A.length>0)){const Me=he-M,Te=pe-D;for(const De of A)De.position={x:De.position.x-Me+ie[0]*(oe-F),y:De.position.y-Te+ie[1]*(fe-I)},W.push(De)}if((J||ae)&&($.width=J&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:w.width,$.height=ae&&(!c.resizeDirection||c.resizeDirection==="vertical")?fe:w.height,w.width=$.width,w.height=$.height),z&&k.expandParent){const Me=ie[0]*($.width??0);$.x&&$.x{K&&(j==null||j(q,{...w}),a==null||a({...w}),K=!1)});u.call(re)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Ou={exports:{}},Fu={},Hu={exports:{}},Bu={};/** - * @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 Ah;function Z1(){if(Ah)return Bu;Ah=1;var t=os();function r(y,v){return y===v&&(y!==0||1/y===1/v)||y!==y&&v!==v}var o=typeof Object.is=="function"?Object.is:r,s=t.useState,a=t.useEffect,u=t.useLayoutEffect,c=t.useDebugValue;function h(y,v){var _=v(),N=s({inst:{value:_,getSnapshot:v}}),j=N[0].inst,E=N[1];return u(function(){j.value=_,j.getSnapshot=v,p(j)&&E({inst:j})},[y,_,v]),a(function(){return p(j)&&E({inst:j}),y(function(){p(j)&&E({inst:j})})},[y]),c(_),_}function p(y){var v=y.getSnapshot;y=y.value;try{var _=v();return!o(y,_)}catch{return!0}}function x(y,v){return v()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?x:h;return Bu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:m,Bu}var $h;function J1(){return $h||($h=1,Hu.exports=Z1()),Hu.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 zh;function e_(){if(zh)return Fu;zh=1;var t=os(),r=J1();function o(x,m){return x===m&&(x!==0||1/x===1/m)||x!==x&&m!==m}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Fu.useSyncExternalStoreWithSelector=function(x,m,y,v,_){var N=u(null);if(N.current===null){var j={hasValue:!1,value:null};N.current=j}else j=N.current;N=h(function(){function w(z){if(!C){if(C=!0,k=z,z=v(z),_!==void 0&&j.hasValue){var V=j.value;if(_(V,z))return b=V}return b=z}if(V=b,s(k,z))return V;var Y=v(z);return _!==void 0&&_(V,Y)?(k=z,V):(k=z,b=Y)}var C=!1,k,b,A=y===void 0?null:y;return[function(){return w(m())},A===null?void 0:function(){return w(A())}]},[m,y,v,_]);var E=a(x,N[0],N[1]);return c(function(){j.hasValue=!0,j.value=E},[E]),p(E),E},Fu}var Dh;function t_(){return Dh||(Dh=1,Ou.exports=e_()),Ou.exports}var n_=t_();const r_=wp(n_),i_={},Oh=t=>{let r;const o=new Set,s=(m,y)=>{const v=typeof m=="function"?m(r):m;if(!Object.is(v,r)){const _=r;r=y??(typeof v!="object"||v===null)?v:Object.assign({},r,v),o.forEach(N=>N(r,_))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>x,subscribe:m=>(o.add(m),()=>o.delete(m)),destroy:()=>{(i_?"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."),o.clear()}},x=r=t(s,a,p);return p},o_=t=>t?Oh(t):Oh,{useDebugValue:s_}=t0,{useSyncExternalStoreWithSelector:l_}=r_,a_=t=>t;function Pg(t,r=a_,o){const s=l_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return s_(s),s}const Fh=(t,r)=>{const o=o_(t),s=(a,u=r)=>Pg(o,a,u);return Object.assign(s,o),s},u_=(t,r)=>t?Fh(t,r):Fh;function Qe(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}_p();const Yl=L.createContext(null),c_=Yl.Provider,Ig=yn.error001("react");function ze(t,r){const o=L.useContext(Yl);if(o===null)throw new Error(Ig);return Pg(o,t,r)}function Ge(){const t=L.useContext(Yl);if(t===null)throw new Error(Ig);return L.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Hh={display:"none"},d_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Rg="react-flow__node-desc",Tg="react-flow__edge-desc",f_="react-flow__aria-live",h_=t=>t.ariaLiveMessage,p_=t=>t.ariaLabelConfig;function g_({rfId:t}){const r=ze(h_);return d.jsx("div",{id:`${f_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:d_,children:r})}function m_({rfId:t,disableKeyboardA11y:r}){const o=ze(p_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${Rg}-${t}`,style:Hh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${Tg}-${t}`,style:Hh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(g_,{rfId:t})]})}const Xl=L.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return d.jsx("div",{className:it(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});Xl.displayName="Panel";const Bh="https://reactflow.dev?utm_source=attribution";function y_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:d.jsx(Xl,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Bh}`,children:d.jsx("a",{href:Bh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const v_=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},xl=t=>t.id;function x_(t,r){return Qe(t.selectedNodes.map(xl),r.selectedNodes.map(xl))&&Qe(t.selectedEdges.map(xl),r.selectedEdges.map(xl))}function w_({onSelectionChange:t}){const r=Ge(),{selectedNodes:o,selectedEdges:s}=ze(v_,x_);return L.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const __=t=>!!t.onSelectionChangeHandlers;function S_({onSelectionChange:t}){const r=ze(__);return t||r?d.jsx(w_,{onSelectionChange:t}):null}const Lg=[0,0],k_={x:0,y:0,zoom:1},N_=["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"],Vh=[...N_,"rfId"],j_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Wh={translateExtent:Jo,nodeOrigin:Lg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function b_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=ze(j_,Qe),x=Ge();L.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{m.current=Wh,h()}),[]);const m=L.useRef(Wh);return L.useEffect(()=>{for(const y of Vh){const v=t[y],_=m.current[y];v!==_&&(typeof t[y]>"u"||(y==="nodes"?r(v):y==="edges"?o(v):y==="minZoom"?s(v):y==="maxZoom"?a(v):y==="translateExtent"?u(v):y==="nodeExtent"?c(v):y==="ariaLabelConfig"?x.setState({ariaLabelConfig:c1(v)}):y==="fitView"?x.setState({fitViewQueued:v}):y==="fitViewOptions"?x.setState({fitViewOptions:v}):x.setState({[y]:v})))}m.current=t},Vh.map(y=>t[y])),null}function Uh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function E_(t){var s;const[r,o]=L.useState(t==="system"?null:t);return L.useEffect(()=>{if(t!=="system"){o(t);return}const a=Uh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=Uh())!=null&&s.matches?"dark":"light"}const Gh=typeof document<"u"?document:null;function is(t=null,r={target:Gh,actInsideInputWithModifier:!0}){const[o,s]=L.useState(!1),a=L.useRef(!1),u=L.useRef(new Set([])),[c,h]=L.useMemo(()=>{if(t!==null){const x=(Array.isArray(t)?t:[t]).filter(y=>typeof y=="string").map(y=>y.replace(/\+/g,` -`).replace(` - -`,` -+`).split(` -`)),m=x.reduce((y,v)=>y.concat(...v),[]);return[x,m]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Gh,x=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const m=_=>{var E,w;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!x)&&hg(_))return!1;const j=Xh(_.code,h);if(u.current.add(_[j]),Yh(c,u.current,!1)){const C=((w=(E=_.composedPath)==null?void 0:E.call(_))==null?void 0:w[0])||_.target,k=(C==null?void 0:C.nodeName)==="BUTTON"||(C==null?void 0:C.nodeName)==="A";r.preventDefault!==!1&&(a.current||!k)&&_.preventDefault(),s(!0)}},y=_=>{const N=Xh(_.code,h);Yh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[N]),_.key==="Meta"&&u.current.clear(),a.current=!1},v=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",m),p==null||p.addEventListener("keyup",y),window.addEventListener("blur",v),window.addEventListener("contextmenu",v),()=>{p==null||p.removeEventListener("keydown",m),p==null||p.removeEventListener("keyup",y),window.removeEventListener("blur",v),window.removeEventListener("contextmenu",v)}}},[t,s]),o}function Yh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Xh(t,r){return r.includes(t)?"code":"key"}const C_=()=>{const t=Ge();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=_c(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),x={x:r.x-h,y:r.y-p},m=o.snapGrid??a,y=o.snapToGrid??u;return ds(x,s,y,m)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=Zi(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function Ag(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)M_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function M_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function P_(t,r){return Ag(t,r)}function I_(t,r){return Ag(t,r)}function ti(t,r){return{id:t,type:"select",selected:r}}function Ui(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(ti(u.id,c)))}return s}function qh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Kh(t){return{id:t.id,type:"remove"}}const R_=ug();function T_(t,r,o={}){return m1(t,r,{...o,onError:o.onError??R_})}const Qh=t=>t1(t),L_=t=>ig(t);function $g(t){return L.forwardRef(t)}const zg=typeof window<"u"?L.useLayoutEffect:L.useEffect;function Zh(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>A_(()=>o(a=>a+BigInt(1))));return zg(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function A_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Dg=L.createContext(null);function $_({children:t}){const r=Ge(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:x,hasDefaultNodes:m,onNodesChange:y,nodeLookup:v,fitViewQueued:_,onNodesChangeMiddlewareMap:N}=r.getState();let j=p;for(const w of h)j=typeof w=="function"?w(j):w;let E=qh({items:j,lookup:v});for(const w of N.values())E=w(E);m&&x(j),E.length>0?y==null||y(E):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:w,nodes:C,setNodes:k}=r.getState();w&&k(C)})},[]),s=Zh(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:x,hasDefaultEdges:m,onEdgesChange:y,edgeLookup:v}=r.getState();let _=p;for(const N of h)_=typeof N=="function"?N(_):N;m?x(_):y&&y(qh({items:_,lookup:v}))},[]),u=Zh(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Dg.Provider,{value:c,children:t})}function z_(){const t=L.useContext(Dg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const D_=t=>!!t.panZoom;function ql(){const t=C_(),r=Ge(),o=z_(),s=ze(D_),a=L.useMemo(()=>{const u=y=>r.getState().nodeLookup.get(y),c=y=>{o.nodeQueue.push(y)},h=y=>{o.edgeQueue.push(y)},p=y=>{var w,C;const{nodeLookup:v,nodeOrigin:_}=r.getState(),N=Qh(y)?y:v.get(y.id),j=N.parentId?dg(N.position,N.measured,N.parentId,v,_):N.position,E={...N,position:j,width:((w=N.measured)==null?void 0:w.width)??N.width,height:((C=N.measured)==null?void 0:C.height)??N.height};return ns(E)},x=(y,v,_={replace:!1})=>{c(N=>N.map(j=>{if(j.id===y){const E=typeof v=="function"?v(j):v;return _.replace&&Qh(E)?E:{...j,...E}}return j}))},m=(y,v,_={replace:!1})=>{h(N=>N.map(j=>{if(j.id===y){const E=typeof v=="function"?v(j):v;return _.replace&&L_(E)?E:{...j,...E}}return j}))};return{getNodes:()=>r.getState().nodes.map(y=>({...y})),getNode:y=>{var v;return(v=u(y))==null?void 0:v.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:y=[]}=r.getState();return y.map(v=>({...v}))},getEdge:y=>r.getState().edgeLookup.get(y),setNodes:c,setEdges:h,addNodes:y=>{const v=Array.isArray(y)?y:[y];o.nodeQueue.push(_=>[..._,...v])},addEdges:y=>{const v=Array.isArray(y)?y:[y];o.edgeQueue.push(_=>[..._,...v])},toObject:()=>{const{nodes:y=[],edges:v=[],transform:_}=r.getState(),[N,j,E]=_;return{nodes:y.map(w=>({...w})),edges:v.map(w=>({...w})),viewport:{x:N,y:j,zoom:E}}},deleteElements:async({nodes:y=[],edges:v=[]})=>{const{nodes:_,edges:N,onNodesDelete:j,onEdgesDelete:E,triggerNodeChanges:w,triggerEdgeChanges:C,onDelete:k,onBeforeDelete:b}=r.getState(),{nodes:A,edges:z}=await s1({nodesToRemove:y,edgesToRemove:v,nodes:_,edges:N,onBeforeDelete:b}),V=z.length>0,Y=A.length>0;if(V){const K=z.map(Kh);E==null||E(z),C(K)}if(Y){const K=A.map(Kh);j==null||j(A),w(K)}return(Y||V)&&(k==null||k({nodes:A,edges:z})),{deletedNodes:A,deletedEdges:z}},getIntersectingNodes:(y,v=!0,_)=>{const N=Sh(y),j=N?y:p(y),E=_!==void 0;return j?(_||r.getState().nodes).filter(w=>{const C=r.getState().nodeLookup.get(w.id);if(C&&!N&&(w.id===y.id||!C.internals.positionAbsolute))return!1;const k=ns(E?w:C),b=$l(k,j);return v&&b>0||b>=k.width*k.height||b>=j.width*j.height}):[]},isNodeIntersecting:(y,v,_=!0)=>{const j=Sh(y)?y:p(y);if(!j)return!1;const E=$l(j,v);return _&&E>0||E>=v.width*v.height||E>=j.width*j.height},updateNode:x,updateNodeData:(y,v,_={replace:!1})=>{x(y,N=>{const j=typeof v=="function"?v(N):v;return _.replace?{...N,data:j}:{...N,data:{...N.data,...j}}},_)},updateEdge:m,updateEdgeData:(y,v,_={replace:!1})=>{m(y,N=>{const j=typeof v=="function"?v(N):v;return _.replace?{...N,data:j}:{...N,data:{...N.data,...j}}},_)},getNodesBounds:y=>{const{nodeLookup:v,nodeOrigin:_}=r.getState();return n1(y,{nodeLookup:v,nodeOrigin:_})},getHandleConnections:({type:y,id:v,nodeId:_})=>{var N;return Array.from(((N=r.getState().connectionLookup.get(`${_}-${y}${v?`-${v}`:""}`))==null?void 0:N.values())??[])},getNodeConnections:({type:y,handleId:v,nodeId:_})=>{var N;return Array.from(((N=r.getState().connectionLookup.get(`${_}${y?v?`-${y}-${v}`:`-${y}`:""}`))==null?void 0:N.values())??[])},fitView:async y=>{const v=r.getState().fitViewResolver??u1();return r.setState({fitViewQueued:!0,fitViewOptions:y,fitViewResolver:v}),o.nodeQueue.push(_=>[..._]),v.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const Jh=t=>t.selected,O_=typeof window<"u"?window:void 0;function F_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ge(),{deleteElements:s}=ql(),a=is(t,{actInsideInputWithModifier:!1}),u=is(r,{target:O_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(Jh),edges:c.filter(Jh)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function H_(t){const r=Ge();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=Sc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",yn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const Kl={position:"absolute",width:"100%",height:"100%",top:0,left:0},B_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function V_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=ii.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:x,translateExtent:m,minZoom:y,maxZoom:v,zoomActivationKeyCode:_,preventScrolling:N=!0,children:j,noWheelClassName:E,noPanClassName:w,onViewportChange:C,isControlledViewport:k,paneClickDistance:b,selectionOnDrag:A}){const z=Ge(),V=L.useRef(null),{userSelectionActive:Y,lib:K,connectionInProgress:re}=ze(B_,Qe),q=is(_),Z=L.useRef();H_(V);const te=L.useCallback(R=>{C==null||C({x:R[0],y:R[1],zoom:R[2]}),k||z.setState({transform:R})},[C,k]);return L.useEffect(()=>{if(V.current){Z.current=G1({domNode:V.current,minZoom:y,maxZoom:v,translateExtent:m,viewport:x,onDraggingChange:W=>z.setState(M=>M.paneDragging===W?M:{paneDragging:W}),onPanZoomStart:(W,M)=>{const{onViewportChangeStart:D,onMoveStart:F}=z.getState();F==null||F(W,M),D==null||D(M)},onPanZoom:(W,M)=>{const{onViewportChange:D,onMove:F}=z.getState();F==null||F(W,M),D==null||D(M)},onPanZoomEnd:(W,M)=>{const{onViewportChangeEnd:D,onMoveEnd:F}=z.getState();F==null||F(W,M),D==null||D(M)}});const{x:R,y:U,zoom:H}=Z.current.getViewport();return z.setState({panZoom:Z.current,transform:[R,U,H],domNode:V.current.closest(".react-flow")}),()=>{var W;(W=Z.current)==null||W.destroy()}}},[]),L.useEffect(()=>{var R;(R=Z.current)==null||R.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:q,preventScrolling:N,noPanClassName:w,userSelectionActive:Y,noWheelClassName:E,lib:K,onTransformChange:te,connectionInProgress:re,selectionOnDrag:A,paneClickDistance:b})},[t,r,o,s,a,u,c,h,p,q,N,w,Y,E,K,te,re,A,b]),d.jsx("div",{className:"react-flow__renderer",ref:V,style:Kl,children:j})}const W_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function U_(){const{userSelectionActive:t,userSelectionRect:r}=ze(W_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const Vu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},G_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function Y_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=es.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:x,onPaneContextMenu:m,onPaneScroll:y,onPaneMouseEnter:v,onPaneMouseMove:_,onPaneMouseLeave:N,children:j}){const E=L.useRef(0),w=Ge(),{userSelectionActive:C,elementsSelectable:k,dragging:b,panBy:A,autoPanSpeed:z}=ze(G_,Qe),V=k&&(t||C),Y=L.useRef(null),K=L.useRef(),re=L.useRef(new Set),q=L.useRef(new Set),Z=L.useRef(!1),te=L.useRef(!1),R=L.useRef({x:0,y:0}),U=L.useRef(!1),H=J=>{if(te.current||Z.current||w.getState().connection.inProgress){te.current=!1,Z.current=!1;return}x==null||x(J),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},W=J=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){J.preventDefault();return}m==null||m(J)},M=y?J=>y(J):void 0,D=J=>{te.current&&(J.stopPropagation(),te.current=!1)},F=J=>{var De,ht;if(J.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:ae,transform:me}=w.getState();if(K.current=ae==null?void 0:ae.getBoundingClientRect(),!K.current)return;const Ne=J.target===Y.current;if(!Ne&&!!J.target.closest(".nokey")||!t||!(c&&Ne||r)||J.button!==0||!J.isPrimary)return;(ht=(De=J.target)==null?void 0:De.setPointerCapture)==null||ht.call(De,J.pointerId),te.current=!1;const{x:je,y:Me}=mn(J.nativeEvent,K.current),Te=ds({x:je,y:Me},me);w.setState({userSelectionRect:{width:0,height:0,startX:Te.x,startY:Te.y,x:je,y:Me}}),Ne||(J.stopPropagation(),J.preventDefault())};function I(J,ae){const{userSelectionRect:me}=w.getState();if(!me)return;const{transform:Ne,nodeLookup:xe,edgeLookup:ne,connectionLookup:je,triggerNodeChanges:Me,triggerEdgeChanges:Te,defaultEdgeOptions:De}=w.getState(),ht={x:me.startX,y:me.startY},{x:Je,y:Xe}=Zi(ht,Ne),lt={startX:ht.x,startY:ht.y,x:Jat.id)),q.current=new Set;const qt=(De==null?void 0:De.selectable)??!0;for(const at of re.current){const et=je.get(at);if(et)for(const{edgeId:vt}of et.values()){const xt=ne.get(vt);xt&&(xt.selectable??qt)&&q.current.add(vt)}}if(!kh(yt,re.current)){const at=Ui(xe,re.current,!0);Me(at)}if(!kh(Dt,q.current)){const at=Ui(ne,q.current);Te(at)}w.setState({userSelectionRect:lt,userSelectionActive:!0,nodesSelectionActive:!1})}function $(){if(!a||!K.current)return;const[J,ae]=wc(R.current,K.current,z);A({x:J,y:ae}).then(me=>{if(!te.current||!me){E.current=requestAnimationFrame($);return}const{x:Ne,y:xe}=R.current;I(Ne,xe),E.current=requestAnimationFrame($)})}const ie=()=>{cancelAnimationFrame(E.current),E.current=0,U.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=J=>{const{userSelectionRect:ae,transform:me,resetSelectedElements:Ne}=w.getState();if(!K.current||!ae)return;const{x:xe,y:ne}=mn(J.nativeEvent,K.current);R.current={x:xe,y:ne};const je=Zi({x:ae.startX,y:ae.startY},me);if(!te.current){const Me=r?0:u;if(Math.hypot(xe-je.x,ne-je.y)<=Me)return;Ne(),h==null||h(J)}te.current=!0,U.current||($(),U.current=!0),I(xe,ne)},fe=J=>{var ae,me;if(!V){J.target===Y.current&&w.getState().connection.inProgress&&(Z.current=!0);return}J.button===0&&((me=(ae=J.target)==null?void 0:ae.releasePointerCapture)==null||me.call(ae,J.pointerId),!C&&J.target===Y.current&&w.getState().userSelectionRect&&(H==null||H(J)),w.setState({userSelectionActive:!1,userSelectionRect:null}),te.current&&(p==null||p(J),w.setState({nodesSelectionActive:re.current.size>0})),ie())},he=J=>{var ae,me;(me=(ae=J.target)==null?void 0:ae.releasePointerCapture)==null||me.call(ae,J.pointerId),ie()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:it(["react-flow__pane",{draggable:pe,dragging:b,selection:t}]),onClick:V?void 0:Vu(H,Y),onContextMenu:Vu(W,Y),onWheel:Vu(M,Y),onPointerEnter:V?void 0:v,onPointerMove:V?oe:_,onPointerUp:fe,onPointerCancel:V?he:void 0,onPointerDownCapture:V?F:void 0,onClickCapture:V?D:void 0,onPointerLeave:N,ref:Y,style:Kl,children:[j,d.jsx(U_,{})]})}function ac({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),x=h.get(t);if(!x){p==null||p("012",yn.error012(t));return}r.setState({nodesSelectionActive:!1}),x.selected?(o||x.selected&&c)&&(u({nodes:[x],edges:[]}),requestAnimationFrame(()=>{var m;return(m=s==null?void 0:s.current)==null?void 0:m.blur()})):a([t])}function Og({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ge(),[p,x]=L.useState(!1),m=L.useRef();return L.useEffect(()=>{if(!r)return m.current=R1({getStoreItems:()=>h.getState(),onNodeMouseDown:y=>{ac({id:y,store:h,nodeRef:t})},onDragStart:()=>{x(!0)},onDragStop:()=>{x(!1)}}),()=>{var y;(y=m.current)==null||y.destroy(),m.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!m.current||m.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const X_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Fg(){const t=Ge();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:x,nodeOrigin:m}=t.getState(),y=new Map,v=X_(c),_=a?u[0]:5,N=a?u[1]:5,j=o.direction.x*_*o.factor,E=o.direction.y*N*o.factor;for(const[,w]of x){if(!v(w))continue;let C={x:w.internals.positionAbsolute.x+j,y:w.internals.positionAbsolute.y+E};a&&(C=cs(C,u));const{position:k,positionAbsolute:b}=og({nodeId:w.id,nextPosition:C,nodeLookup:x,nodeExtent:s,nodeOrigin:m,onError:h});w.position=k,w.internals.positionAbsolute=b,y.set(w.id,w)}p(y)},[])}const Cc=L.createContext(null),q_=Cc.Provider;Cc.Consumer;const Hg=()=>L.useContext(Cc),K_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Bg=L.createContext(null);function Q_({children:t}){const r=ze(K_,Qe);return d.jsx(Bg.Provider,{value:r,children:t})}function Z_(){const t=L.useContext(Bg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const J_={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},eS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:x}=c;if(!h&&!a)return J_;const m=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:m,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Ki.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:m&&x}};function tS({type:t="source",position:r=ke.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:x,onMouseDown:m,onTouchStart:y,...v},_){var U,H;const N=c||null,j=t==="target",E=Ge(),w=Hg(),{connectOnClick:C,noPanClassName:k,rfId:b}=Z_(),{connectingFrom:A,connectingTo:z,clickConnecting:V,isPossibleEndHandle:Y,connectionInProcess:K,clickConnectionInProcess:re,valid:q}=ze(eS(w,N,t),Qe);w||(H=(U=E.getState()).onError)==null||H.call(U,"010",yn.error010());const Z=W=>{const{defaultEdgeOptions:M,onConnect:D,hasDefaultEdges:F}=E.getState(),I={...M,...W};if(F){const{edges:$,setEdges:ie,onError:oe}=E.getState();ie(T_(I,$,{onError:oe}))}D==null||D(I),h==null||h(I)},te=W=>{if(!w)return;const M=pg(W.nativeEvent);if(a&&(M&&W.button===0||!M)){const D=E.getState();lc.onPointerDown(W.nativeEvent,{handleDomNode:W.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:j,handleId:N,nodeId:w,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...F)=>{var I,$;return($=(I=E.getState()).onConnectEnd)==null?void 0:$.call(I,...F)},updateConnection:D.updateConnection,onConnect:Z,isValidConnection:o||((...F)=>{var I,$;return(($=(I=E.getState()).isValidConnection)==null?void 0:$.call(I,...F))??!0}),getTransform:()=>E.getState().transform,getFromHandle:()=>E.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}M?m==null||m(W):y==null||y(W)},R=W=>{const{onClickConnectStart:M,onClickConnectEnd:D,connectionClickStartHandle:F,connectionMode:I,isValidConnection:$,lib:ie,rfId:oe,nodeLookup:fe,connection:he}=E.getState();if(!w||!F&&!a)return;if(!F){M==null||M(W.nativeEvent,{nodeId:w,handleId:N,handleType:t}),E.setState({connectionClickStartHandle:{nodeId:w,type:t,id:N}});return}const pe=fg(W.target),J=o||$,{connection:ae,isValid:me}=lc.isValid(W.nativeEvent,{handle:{nodeId:w,id:N,type:t},connectionMode:I,fromNodeId:F.nodeId,fromHandleId:F.id||null,fromType:F.type,isValidConnection:J,flowId:oe,doc:pe,lib:ie,nodeLookup:fe});me&&ae&&Z(ae);const Ne=structuredClone(he);delete Ne.inProgress,Ne.toPosition=Ne.toHandle?Ne.toHandle.position:null,D==null||D(W,Ne),E.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":N,"data-nodeid":w,"data-handlepos":r,"data-id":`${b}-${w}-${N}-${t}`,className:it(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",k,x,{source:!j,target:j,connectable:s,connectablestart:a,connectableend:u,clickconnecting:V,connectingfrom:A,connectingto:z,valid:q,connectionindicator:s&&(!K||Y)&&(K||re?u:a)}]),onMouseDown:te,onTouchStart:te,onClick:C?R:void 0,ref:_,...v,children:p})}const eo=L.memo($g(tS));function nS({data:t,isConnectable:r,sourcePosition:o=ke.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(eo,{type:"source",position:o,isConnectable:r})]})}function rS({data:t,isConnectable:r,targetPosition:o=ke.Top,sourcePosition:s=ke.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(eo,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(eo,{type:"source",position:s,isConnectable:r})]})}function iS(){return null}function oS({data:t,isConnectable:r,targetPosition:o=ke.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(eo,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const zl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},ep={input:nS,default:rS,output:oS,group:iS};function sS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const lS=t=>{const{width:r,height:o,x:s,y:a}=us(t.nodeLookup,{filter:u=>!!u.selected});return{width:gn(r)?r:null,height:gn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function aS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ge(),{width:a,height:u,transformString:c,userSelectionActive:h}=ze(lS,Qe),p=Fg(),x=L.useRef(null);L.useEffect(()=>{var _;o||(_=x.current)==null||_.focus({preventScroll:!0})},[o]);const m=!h&&a!==null&&u!==null;if(Og({nodeRef:x,disabled:!m}),!m)return null;const y=t?_=>{const N=s.getState().nodes.filter(j=>j.selected);t(_,N)}:void 0,v=_=>{Object.prototype.hasOwnProperty.call(zl,_.key)&&(_.preventDefault(),p({direction:zl[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:it(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:x,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:o?void 0:-1,onKeyDown:o?void 0:v,style:{width:a,height:u}})})}const tp=typeof window<"u"?window:void 0,uS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Vg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:x,selectionOnDrag:m,selectionMode:y,onSelectionStart:v,onSelectionEnd:_,multiSelectionKeyCode:N,panActivationKeyCode:j,zoomActivationKeyCode:E,elementsSelectable:w,zoomOnScroll:C,zoomOnPinch:k,panOnScroll:b,panOnScrollSpeed:A,panOnScrollMode:z,zoomOnDoubleClick:V,panOnDrag:Y,autoPanOnSelection:K,defaultViewport:re,translateExtent:q,minZoom:Z,maxZoom:te,preventScrolling:R,onSelectionContextMenu:U,noWheelClassName:H,noPanClassName:W,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:F}){const{nodesSelectionActive:I,userSelectionActive:$}=ze(uS,Qe),ie=is(x,{target:tp}),oe=is(j,{target:tp}),fe=oe||Y,he=oe||b,pe=m&&fe!==!0,J=ie||$||pe;return F_({deleteKeyCode:p,multiSelectionKeyCode:N}),d.jsx(V_,{onPaneContextMenu:u,elementsSelectable:w,zoomOnScroll:C,zoomOnPinch:k,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:A,panOnScrollMode:z,zoomOnDoubleClick:V,panOnDrag:!ie&&fe,defaultViewport:re,translateExtent:q,minZoom:Z,maxZoom:te,zoomActivationKeyCode:E,preventScrolling:R,noWheelClassName:H,noPanClassName:W,onViewportChange:D,isControlledViewport:F,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(Y_,{onSelectionStart:v,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:K,isSelecting:!!J,selectionMode:y,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:pe,children:[t,I&&d.jsx(aS,{onSelectionContextMenu:U,noPanClassName:W,disableKeyboardA11y:M})]})})}Vg.displayName="FlowRenderer";const cS=L.memo(Vg),dS=t=>r=>t?xc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function fS(t){return ze(L.useCallback(dS(t),[t]),Qe)}const hS=t=>t.updateNodeInternals;function pS(){const t=ze(hS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function gS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ge(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),x=L.useRef(r),m=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!m||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[m,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const y=x.current!==r,v=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(y||v||_)&&(x.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function mS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:x,nodesFocusable:m,resizeObserver:y,noDragClassName:v,noPanClassName:_,disableKeyboardA11y:N,rfId:j,nodeTypes:E,nodeClickDistance:w,onError:C}){const{node:k,internals:b,isParent:A}=ze(J=>{const ae=J.nodeLookup.get(t),me=J.parentLookup.has(t);return{node:ae,internals:ae.internals,isParent:me}},Qe);let z=k.type||"default",V=(E==null?void 0:E[z])||ep[z];V===void 0&&(C==null||C("003",yn.error003(z)),z="default",V=(E==null?void 0:E.default)||ep.default);const Y=!!(k.draggable||h&&typeof k.draggable>"u"),K=!!(k.selectable||p&&typeof k.selectable>"u"),re=!!(k.connectable||x&&typeof k.connectable>"u"),q=!!(k.focusable||m&&typeof k.focusable>"u"),Z=Ge(),te=cg(k),R=gS({node:k,nodeType:z,hasDimensions:te,resizeObserver:y}),U=Og({nodeRef:R,disabled:k.hidden||!Y,noDragClassName:v,handleSelector:k.dragHandle,nodeId:t,isSelectable:K,nodeClickDistance:w}),H=Fg();if(k.hidden)return null;const W=xn(k),M=sS(k),D=K||Y||r||o||s||a,F=o?J=>o(J,{...b.userNode}):void 0,I=s?J=>s(J,{...b.userNode}):void 0,$=a?J=>a(J,{...b.userNode}):void 0,ie=u?J=>u(J,{...b.userNode}):void 0,oe=c?J=>c(J,{...b.userNode}):void 0,fe=J=>{const{selectNodesOnDrag:ae,nodeDragThreshold:me}=Z.getState();K&&(!ae||!Y||me>0)&&ac({id:t,store:Z,nodeRef:R}),r&&r(J,{...b.userNode})},he=J=>{if(!(hg(J.nativeEvent)||N)){if(eg.includes(J.key)&&K){const ae=J.key==="Escape";ac({id:t,store:Z,unselect:ae,nodeRef:R})}else if(Y&&k.selected&&Object.prototype.hasOwnProperty.call(zl,J.key)){J.preventDefault();const{ariaLabelConfig:ae}=Z.getState();Z.setState({ariaLiveMessage:ae["node.a11yDescription.ariaLiveMessage"]({direction:J.key.replace("Arrow","").toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),H({direction:zl[J.key],factor:J.shiftKey?4:1})}}},pe=()=>{var je;if(N||!((je=R.current)!=null&&je.matches(":focus-visible")))return;const{transform:J,width:ae,height:me,autoPanOnNodeFocus:Ne,setCenter:xe}=Z.getState();if(!Ne)return;xc(new Map([[t,k]]),{x:0,y:0,width:ae,height:me},J,!0).length>0||xe(k.position.x+W.width/2,k.position.y+W.height/2,{zoom:J[2]})};return d.jsx("div",{className:it(["react-flow__node",`react-flow__node-${z}`,{[_]:Y},k.className,{selected:k.selected,selectable:K,parent:A,draggable:Y,dragging:U}]),ref:R,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:te?"visible":"hidden",...k.style,...M},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:F,onMouseMove:I,onMouseLeave:$,onContextMenu:ie,onClick:fe,onDoubleClick:oe,onKeyDown:q?he:void 0,tabIndex:q?0:void 0,onFocus:q?pe:void 0,role:k.ariaRole??(q?"group":void 0),"aria-roledescription":"node","aria-describedby":N?void 0:`${Rg}-${j}`,"aria-label":k.ariaLabel,...k.domAttributes,children:d.jsx(q_,{value:t,children:d.jsx(V,{id:t,data:k.data,type:z,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:k.selected??!1,selectable:K,draggable:Y,deletable:k.deletable??!0,isConnectable:re,sourcePosition:k.sourcePosition,targetPosition:k.targetPosition,dragging:U,dragHandle:k.dragHandle,zIndex:b.z,parentId:k.parentId,...W})})})}var yS=L.memo(mS);const vS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Wg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=ze(vS,Qe),u=fS(t.onlyRenderVisibleElements),c=pS();return d.jsx("div",{className:"react-flow__nodes",style:Kl,children:u.map(h=>d.jsx(yS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Wg.displayName="NodeRenderer";const xS=L.memo(Wg);function wS(t){return ze(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&h1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const _S=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},SS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},np={[ts.Arrow]:_S,[ts.ArrowClosed]:SS};function kS(t){const r=Ge();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(np,t)?np[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",yn.error009(t)),null)},[t])}const NS=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=kS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},Ug=({defaultColor:t,rfId:r})=>{const o=ze(u=>u.edges),s=ze(u=>u.defaultEdgeOptions),a=L.useMemo(()=>_1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(NS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Ug.displayName="MarkerDefinitions";var jS=L.memo(Ug);function Gg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:x,...m}){const[y,v]=L.useState({x:1,y:0,width:0,height:0}),_=it(["react-flow__edge-textwrapper",x]),N=L.useRef(null);return L.useEffect(()=>{if(N.current){const j=N.current.getBBox();v({x:j.x,y:j.y,width:j.width,height:j.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-y.width/2} ${r-y.height/2})`,className:_,visibility:y.width?"visible":"hidden",...m,children:[a&&d.jsx("rect",{width:y.width+2*c[0],x:-c[0],y:-c[1],height:y.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:N,style:s,children:o}),p]}):null}Gg.displayName="EdgeText";const bS=L.memo(Gg);function Ql({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:x=20,...m}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...m,d:t,fill:"none",className:it(["react-flow__edge-path",m.className])}),x?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:x,className:"react-flow__edge-interaction"}):null,s&&gn(r)&&gn(o)?d.jsx(bS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function rp({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===ke.Left||t===ke.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function Yg({sourceX:t,sourceY:r,sourcePosition:o=ke.Bottom,targetX:s,targetY:a,targetPosition:u=ke.Top}){const[c,h]=rp({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,x]=rp({pos:u,x1:s,y1:a,x2:t,y2:r}),[m,y,v,_]=gg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:x});return[`M${t},${r} C${c},${h} ${p},${x} ${s},${a}`,m,y,v,_]}function Xg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:x,labelShowBg:m,labelBgStyle:y,labelBgPadding:v,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,interactionWidth:w})=>{const[C,k,b]=Yg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),A=t.isInternal?void 0:r;return d.jsx(Ql,{id:A,path:C,labelX:k,labelY:b,label:p,labelStyle:x,labelShowBg:m,labelBgStyle:y,labelBgPadding:v,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,interactionWidth:w})})}const ES=Xg({isInternal:!1}),qg=Xg({isInternal:!0});ES.displayName="SimpleBezierEdge";qg.displayName="SimpleBezierEdgeInternal";function Kg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:m,labelBgBorderRadius:y,style:v,sourcePosition:_=ke.Bottom,targetPosition:N=ke.Top,markerEnd:j,markerStart:E,pathOptions:w,interactionWidth:C})=>{const[k,b,A]=ic({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:N,borderRadius:w==null?void 0:w.borderRadius,offset:w==null?void 0:w.offset,stepPosition:w==null?void 0:w.stepPosition}),z=t.isInternal?void 0:r;return d.jsx(Ql,{id:z,path:k,labelX:b,labelY:A,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:m,labelBgBorderRadius:y,style:v,markerEnd:j,markerStart:E,interactionWidth:C})})}const Qg=Kg({isInternal:!1}),Zg=Kg({isInternal:!0});Qg.displayName="SmoothStepEdge";Zg.displayName="SmoothStepEdgeInternal";function Jg(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(Qg,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const CS=Jg({isInternal:!1}),em=Jg({isInternal:!0});CS.displayName="StepEdge";em.displayName="StepEdgeInternal";function tm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:m,labelBgBorderRadius:y,style:v,markerEnd:_,markerStart:N,interactionWidth:j})=>{const[E,w,C]=vg({sourceX:o,sourceY:s,targetX:a,targetY:u}),k=t.isInternal?void 0:r;return d.jsx(Ql,{id:k,path:E,labelX:w,labelY:C,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:x,labelBgPadding:m,labelBgBorderRadius:y,style:v,markerEnd:_,markerStart:N,interactionWidth:j})})}const MS=tm({isInternal:!1}),nm=tm({isInternal:!0});MS.displayName="StraightEdge";nm.displayName="StraightEdgeInternal";function rm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=ke.Bottom,targetPosition:h=ke.Top,label:p,labelStyle:x,labelShowBg:m,labelBgStyle:y,labelBgPadding:v,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,pathOptions:w,interactionWidth:C})=>{const[k,b,A]=mg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:w==null?void 0:w.curvature}),z=t.isInternal?void 0:r;return d.jsx(Ql,{id:z,path:k,labelX:b,labelY:A,label:p,labelStyle:x,labelShowBg:m,labelBgStyle:y,labelBgPadding:v,labelBgBorderRadius:_,style:N,markerEnd:j,markerStart:E,interactionWidth:C})})}const PS=rm({isInternal:!1}),im=rm({isInternal:!0});PS.displayName="BezierEdge";im.displayName="BezierEdgeInternal";const ip={default:im,straight:nm,step:em,smoothstep:Zg,simplebezier:qg},op={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},IS=(t,r,o)=>o===ke.Left?t-r:o===ke.Right?t+r:t,RS=(t,r,o)=>o===ke.Top?t-r:o===ke.Bottom?t+r:t,sp="react-flow__edgeupdater";function lp({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:it([sp,`${sp}-${h}`]),cx:IS(r,s,t),cy:RS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function TS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:x,onReconnectStart:m,onReconnectEnd:y,setReconnecting:v,setUpdateHover:_}){const N=Ge(),j=(b,A)=>{if(b.button!==0)return;const{autoPanOnConnect:z,domNode:V,connectionMode:Y,connectionRadius:K,lib:re,onConnectStart:q,cancelConnection:Z,nodeLookup:te,rfId:R,panBy:U,updateConnection:H}=N.getState(),W=A.type==="target",M=(I,$)=>{v(!1),y==null||y(I,o,A.type,$)},D=I=>x==null?void 0:x(o,I),F=(I,$)=>{v(!0),m==null||m(b,o,A.type),q==null||q(I,$)};lc.onPointerDown(b.nativeEvent,{autoPanOnConnect:z,connectionMode:Y,connectionRadius:K,domNode:V,handleId:A.id,nodeId:A.nodeId,nodeLookup:te,isTarget:W,edgeUpdaterType:A.type,lib:re,flowId:R,cancelConnection:Z,panBy:U,isValidConnection:(...I)=>{var $,ie;return((ie=($=N.getState()).isValidConnection)==null?void 0:ie.call($,...I))??!0},onConnect:D,onConnectStart:F,onConnectEnd:(...I)=>{var $,ie;return(ie=($=N.getState()).onConnectEnd)==null?void 0:ie.call($,...I)},onReconnectEnd:M,updateConnection:H,getTransform:()=>N.getState().transform,getFromHandle:()=>N.getState().connection.fromHandle,dragThreshold:N.getState().connectionDragThreshold,handleDomNode:b.currentTarget})},E=b=>j(b,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),w=b=>j(b,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),C=()=>_(!0),k=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(lp,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:E,onMouseEnter:C,onMouseOut:k,type:"source"}),(t===!0||t==="target")&&d.jsx(lp,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:w,onMouseEnter:C,onMouseOut:k,type:"target"})]})}function LS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:x,reconnectRadius:m,onReconnect:y,onReconnectStart:v,onReconnectEnd:_,rfId:N,edgeTypes:j,noPanClassName:E,onError:w,disableKeyboardA11y:C}){let k=ze(xe=>xe.edgeLookup.get(t));const b=ze(xe=>xe.defaultEdgeOptions);k=b?{...b,...k}:k;let A=k.type||"default",z=(j==null?void 0:j[A])||ip[A];z===void 0&&(w==null||w("011",yn.error011(A)),A="default",z=(j==null?void 0:j.default)||ip.default);const V=!!(k.focusable||r&&typeof k.focusable>"u"),Y=typeof y<"u"&&(k.reconnectable||o&&typeof k.reconnectable>"u"),K=!!(k.selectable||s&&typeof k.selectable>"u"),re=L.useRef(null),[q,Z]=L.useState(!1),[te,R]=L.useState(!1),U=Ge(),{zIndex:H=k.zIndex,sourceX:W,sourceY:M,targetX:D,targetY:F,sourcePosition:I,targetPosition:$}=ze(L.useCallback(xe=>{const ne=xe.nodeLookup.get(k.source),je=xe.nodeLookup.get(k.target);if(!ne||!je)return op;const Me=w1({id:t,sourceNode:ne,targetNode:je,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:xe.connectionMode,onError:w}),Te=f1({selected:k.selected,zIndex:k.zIndex,sourceNode:ne,targetNode:je,elevateOnSelect:xe.elevateEdgesOnSelect,zIndexMode:xe.zIndexMode});return{...Me||op,zIndex:Te}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex,w]),Qe),ie=L.useMemo(()=>k.markerStart?`url('#${oc(k.markerStart,N)}')`:void 0,[k.markerStart,N]),oe=L.useMemo(()=>k.markerEnd?`url('#${oc(k.markerEnd,N)}')`:void 0,[k.markerEnd,N]);if(k.hidden||W===null||M===null||D===null||F===null)return null;const fe=xe=>{var Te;const{addSelectedEdges:ne,unselectNodesAndEdges:je,multiSelectionActive:Me}=U.getState();K&&(U.setState({nodesSelectionActive:!1}),k.selected&&Me?(je({nodes:[],edges:[k]}),(Te=re.current)==null||Te.blur()):ne([t])),a&&a(xe,k)},he=u?xe=>{u(xe,{...k})}:void 0,pe=c?xe=>{c(xe,{...k})}:void 0,J=h?xe=>{h(xe,{...k})}:void 0,ae=p?xe=>{p(xe,{...k})}:void 0,me=x?xe=>{x(xe,{...k})}:void 0,Ne=xe=>{var ne;if(!C&&eg.includes(xe.key)&&K){const{unselectNodesAndEdges:je,addSelectedEdges:Me}=U.getState();xe.key==="Escape"?((ne=re.current)==null||ne.blur(),je({edges:[k]})):Me([t])}};return d.jsx("svg",{style:{zIndex:H},children:d.jsxs("g",{className:it(["react-flow__edge",`react-flow__edge-${A}`,k.className,E,{selected:k.selected,animated:k.animated,inactive:!K&&!a,updating:q,selectable:K}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:J,onMouseMove:ae,onMouseLeave:me,onKeyDown:V?Ne:void 0,tabIndex:V?0:void 0,role:k.ariaRole??(V?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":k.ariaLabel===null?void 0:k.ariaLabel||`Edge from ${k.source} to ${k.target}`,"aria-describedby":V?`${Tg}-${N}`:void 0,ref:re,...k.domAttributes,children:[!te&&d.jsx(z,{id:t,source:k.source,target:k.target,type:k.type,selected:k.selected,animated:k.animated,selectable:K,deletable:k.deletable??!0,label:k.label,labelStyle:k.labelStyle,labelShowBg:k.labelShowBg,labelBgStyle:k.labelBgStyle,labelBgPadding:k.labelBgPadding,labelBgBorderRadius:k.labelBgBorderRadius,sourceX:W,sourceY:M,targetX:D,targetY:F,sourcePosition:I,targetPosition:$,data:k.data,style:k.style,sourceHandleId:k.sourceHandle,targetHandleId:k.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in k?k.pathOptions:void 0,interactionWidth:k.interactionWidth}),Y&&d.jsx(TS,{edge:k,isReconnectable:Y,reconnectRadius:m,onReconnect:y,onReconnectStart:v,onReconnectEnd:_,sourceX:W,sourceY:M,targetX:D,targetY:F,sourcePosition:I,targetPosition:$,setUpdateHover:Z,setReconnecting:R})]})})}var AS=L.memo(LS);const $S=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function om({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:x,onEdgeClick:m,reconnectRadius:y,onEdgeDoubleClick:v,onReconnectStart:_,onReconnectEnd:N,disableKeyboardA11y:j}){const{edgesFocusable:E,edgesReconnectable:w,elementsSelectable:C,onError:k}=ze($S,Qe),b=wS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(jS,{defaultColor:t,rfId:o}),b.map(A=>d.jsx(AS,{id:A,edgesFocusable:E,edgesReconnectable:w,elementsSelectable:C,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:x,onClick:m,reconnectRadius:y,onDoubleClick:v,onReconnectStart:_,onReconnectEnd:N,rfId:o,onError:k,edgeTypes:s,disableKeyboardA11y:j},A))]})}om.displayName="EdgeRenderer";const zS=L.memo(om),ap=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function DS({children:t}){const r=Ge(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return zg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=ap(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:ap(s)},children:t})}function OS(t){const r=ql(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const FS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function HS(t){const r=ze(FS),o=Ge();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function BS(t){return t.connection.inProgress?{...t.connection,to:ds(t.connection.to,t.transform)}:{...t.connection}}function VS(t){return BS}function WS(t){const r=VS();return ze(r,Qe)}const US=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function GS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=ze(US,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:it(["react-flow__connection",rg(h)]),children:d.jsx(sm,{style:r,type:o,CustomComponent:s,isValid:h})})})}const sm=({style:t,type:r=Mr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:x,toNode:m,toHandle:y,toPosition:v,pointer:_}=WS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:x.x,toY:x.y,fromPosition:p,toPosition:v,connectionStatus:rg(s),toNode:m,toHandle:y,pointer:_});let N="";const j={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:x.x,targetY:x.y,targetPosition:v};switch(r){case Mr.Bezier:[N]=mg(j);break;case Mr.SimpleBezier:[N]=Yg(j);break;case Mr.Step:[N]=ic({...j,borderRadius:0});break;case Mr.SmoothStep:[N]=ic(j);break;default:[N]=vg(j)}return d.jsx("path",{d:N,fill:"none",className:"react-flow__connection-path",style:t})};sm.displayName="ConnectionLine";const YS={};function up(t=YS){L.useRef(t),Ge(),L.useEffect(()=>{},[t])}function XS(){Ge(),L.useRef(!1),L.useEffect(()=>{},[])}function lm({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:m,onSelectionContextMenu:y,onSelectionStart:v,onSelectionEnd:_,connectionLineType:N,connectionLineStyle:j,connectionLineComponent:E,connectionLineContainerStyle:w,selectionKeyCode:C,selectionOnDrag:k,selectionMode:b,multiSelectionKeyCode:A,panActivationKeyCode:z,zoomActivationKeyCode:V,deleteKeyCode:Y,onlyRenderVisibleElements:K,elementsSelectable:re,defaultViewport:q,translateExtent:Z,minZoom:te,maxZoom:R,preventScrolling:U,defaultMarkerColor:H,zoomOnScroll:W,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:F,panOnScrollMode:I,zoomOnDoubleClick:$,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:J,onPaneScroll:ae,onPaneContextMenu:me,paneClickDistance:Ne,nodeClickDistance:xe,onEdgeContextMenu:ne,onEdgeMouseEnter:je,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:De,onReconnect:ht,onReconnectStart:Je,onReconnectEnd:Xe,noDragClassName:lt,noWheelClassName:yt,noPanClassName:Dt,disableKeyboardA11y:qt,nodeExtent:at,rfId:et,viewport:vt,onViewportChange:xt,nodesDraggable:zn}){return up(t),up(r),XS(),OS(o),HS(vt),d.jsx(cS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:J,onPaneContextMenu:me,onPaneScroll:ae,paneClickDistance:Ne,deleteKeyCode:Y,selectionKeyCode:C,selectionOnDrag:k,selectionMode:b,onSelectionStart:v,onSelectionEnd:_,multiSelectionKeyCode:A,panActivationKeyCode:z,zoomActivationKeyCode:V,elementsSelectable:re,zoomOnScroll:W,zoomOnPinch:M,zoomOnDoubleClick:$,panOnScroll:D,panOnScrollSpeed:F,panOnScrollMode:I,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:q,translateExtent:Z,minZoom:te,maxZoom:R,onSelectionContextMenu:y,preventScrolling:U,noDragClassName:lt,noWheelClassName:yt,noPanClassName:Dt,disableKeyboardA11y:qt,onViewportChange:xt,isControlledViewport:!!vt,children:d.jsxs(DS,{children:[d.jsx(zS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:ht,onReconnectStart:Je,onReconnectEnd:Xe,onlyRenderVisibleElements:K,onEdgeContextMenu:ne,onEdgeMouseEnter:je,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:De,defaultMarkerColor:H,noPanClassName:Dt,disableKeyboardA11y:qt,rfId:et}),d.jsx(GS,{style:j,type:N,component:E,containerStyle:w}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(xS,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:m,nodeClickDistance:xe,onlyRenderVisibleElements:K,noPanClassName:Dt,noDragClassName:lt,disableKeyboardA11y:qt,nodeExtent:at,rfId:et,nodesDraggable:zn}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}lm.displayName="GraphView";const qS=L.memo(lm),KS=ug(),cp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:x=2,nodeOrigin:m,nodeExtent:y,zIndexMode:v="basic"}={})=>{const _=new Map,N=new Map,j=new Map,E=new Map,w=s??r??[],C=o??t??[],k=m??[0,0],b=y??Jo;_g(j,E,w);const{nodesInitialized:A}=sc(C,_,N,{nodeOrigin:k,nodeExtent:b,zIndexMode:v});let z=[0,0,1];if(c&&a&&u){const V=us(_,{filter:q=>!!((q.width||q.initialWidth)&&(q.height||q.initialHeight))}),{x:Y,y:K,zoom:re}=_c(V,a,u,p,x,(h==null?void 0:h.padding)??.1);z=[Y,K,re]}return{rfId:"1",width:a??0,height:u??0,transform:z,nodes:C,nodesInitialized:A,nodeLookup:_,parentLookup:N,edges:w,edgeLookup:E,connectionLookup:j,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:x,translateExtent:Jo,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ki.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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...ng},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:KS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:tg,zIndexMode:v,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},QS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:x,nodeOrigin:m,nodeExtent:y,zIndexMode:v})=>u_((_,N)=>{async function j(){const{nodeLookup:E,panZoom:w,fitViewOptions:C,fitViewResolver:k,width:b,height:A,minZoom:z,maxZoom:V}=N();w&&(await o1({nodes:E,width:b,height:A,panZoom:w,minZoom:z,maxZoom:V},C),k==null||k.resolve(!0),_({fitViewResolver:null}))}return{...cp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:x,nodeOrigin:m,nodeExtent:y,defaultNodes:o,defaultEdges:s,zIndexMode:v}),setNodes:E=>{const{nodeLookup:w,parentLookup:C,nodeOrigin:k,nodeExtent:b,elevateNodesOnSelect:A,fitViewQueued:z,zIndexMode:V,nodesSelectionActive:Y}=N(),{nodesInitialized:K,hasSelectedNodes:re}=sc(E,w,C,{nodeOrigin:k,nodeExtent:b,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:V}),q=Y&&re;z&&K?(j(),_({nodes:E,nodesInitialized:K,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:q})):_({nodes:E,nodesInitialized:K,nodesSelectionActive:q})},setEdges:E=>{const{connectionLookup:w,edgeLookup:C}=N();_g(w,C,E),_({edges:E})},setDefaultNodesAndEdges:(E,w)=>{if(E){const{setNodes:C}=N();C(E),_({hasDefaultNodes:!0})}if(w){const{setEdges:C}=N();C(w),_({hasDefaultEdges:!0})}},updateNodeInternals:E=>{const{triggerNodeChanges:w,nodeLookup:C,parentLookup:k,domNode:b,nodeOrigin:A,nodeExtent:z,debug:V,fitViewQueued:Y,zIndexMode:K}=N(),{changes:re,updatedInternals:q}=C1(E,C,k,b,A,z,K);q&&(N1(C,k,{nodeOrigin:A,nodeExtent:z,zIndexMode:K}),Y?(j(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(re==null?void 0:re.length)>0&&(V&&console.log("React Flow: trigger node changes",re),w==null||w(re)))},updateNodePositions:(E,w=!1)=>{const C=[];let k=[];const{nodeLookup:b,triggerNodeChanges:A,connection:z,updateConnection:V,onNodesChangeMiddlewareMap:Y}=N();for(const[K,re]of E){const q=b.get(K),Z=!!(q!=null&&q.expandParent&&(q!=null&&q.parentId)&&(re!=null&&re.position)),te={id:K,type:"position",position:Z?{x:Math.max(0,re.position.x),y:Math.max(0,re.position.y)}:re.position,dragging:w};if(q&&z.inProgress&&z.fromNode.id===q.id){const R=ui(q,z.fromHandle,ke.Left,!0);V({...z,from:R})}Z&&q.parentId&&C.push({id:K,parentId:q.parentId,rect:{...re.internals.positionAbsolute,width:re.measured.width??0,height:re.measured.height??0}}),k.push(te)}if(C.length>0){const{parentLookup:K,nodeOrigin:re}=N(),q=Ec(C,b,K,re);k.push(...q)}for(const K of Y.values())k=K(k);A(k)},triggerNodeChanges:E=>{const{onNodesChange:w,setNodes:C,nodes:k,hasDefaultNodes:b,debug:A}=N();if(E!=null&&E.length){if(b){const z=P_(E,k);C(z)}A&&console.log("React Flow: trigger node changes",E),w==null||w(E)}},triggerEdgeChanges:E=>{const{onEdgesChange:w,setEdges:C,edges:k,hasDefaultEdges:b,debug:A}=N();if(E!=null&&E.length){if(b){const z=I_(E,k);C(z)}A&&console.log("React Flow: trigger edge changes",E),w==null||w(E)}},addSelectedNodes:E=>{const{multiSelectionActive:w,edgeLookup:C,nodeLookup:k,triggerNodeChanges:b,triggerEdgeChanges:A}=N();if(w){const z=E.map(V=>ti(V,!0));b(z);return}b(Ui(k,new Set([...E]),!0)),A(Ui(C))},addSelectedEdges:E=>{const{multiSelectionActive:w,edgeLookup:C,nodeLookup:k,triggerNodeChanges:b,triggerEdgeChanges:A}=N();if(w){const z=E.map(V=>ti(V,!0));A(z);return}A(Ui(C,new Set([...E]))),b(Ui(k,new Set,!0))},unselectNodesAndEdges:({nodes:E,edges:w}={})=>{const{edges:C,nodes:k,nodeLookup:b,triggerNodeChanges:A,triggerEdgeChanges:z}=N(),V=E||k,Y=w||C,K=[];for(const q of V){if(!q.selected)continue;const Z=b.get(q.id);Z&&(Z.selected=!1),K.push(ti(q.id,!1))}const re=[];for(const q of Y)q.selected&&re.push(ti(q.id,!1));A(K),z(re)},setMinZoom:E=>{const{panZoom:w,maxZoom:C}=N();w==null||w.setScaleExtent([E,C]),_({minZoom:E})},setMaxZoom:E=>{const{panZoom:w,minZoom:C}=N();w==null||w.setScaleExtent([C,E]),_({maxZoom:E})},setTranslateExtent:E=>{var w;(w=N().panZoom)==null||w.setTranslateExtent(E),_({translateExtent:E})},resetSelectedElements:()=>{const{edges:E,nodes:w,triggerNodeChanges:C,triggerEdgeChanges:k,elementsSelectable:b}=N();if(!b)return;const A=w.reduce((V,Y)=>Y.selected?[...V,ti(Y.id,!1)]:V,[]),z=E.reduce((V,Y)=>Y.selected?[...V,ti(Y.id,!1)]:V,[]);C(A),k(z)},setNodeExtent:E=>{const{nodes:w,nodeLookup:C,parentLookup:k,nodeOrigin:b,elevateNodesOnSelect:A,nodeExtent:z,zIndexMode:V}=N();E[0][0]===z[0][0]&&E[0][1]===z[0][1]&&E[1][0]===z[1][0]&&E[1][1]===z[1][1]||(sc(w,C,k,{nodeOrigin:b,nodeExtent:E,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:V}),_({nodeExtent:E}))},panBy:E=>{const{transform:w,width:C,height:k,panZoom:b,translateExtent:A}=N();return M1({delta:E,panZoom:b,transform:w,translateExtent:A,width:C,height:k})},setCenter:async(E,w,C)=>{const{width:k,height:b,maxZoom:A,panZoom:z}=N();if(!z)return!1;const V=typeof(C==null?void 0:C.zoom)<"u"?C.zoom:A;return await z.setViewport({x:k/2-E*V,y:b/2-w*V,zoom:V},{duration:C==null?void 0:C.duration,ease:C==null?void 0:C.ease,interpolate:C==null?void 0:C.interpolate}),!0},cancelConnection:()=>{_({connection:{...ng}})},updateConnection:E=>{_({connection:E})},reset:()=>_({...cp()})}},Object.is);function am({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:x,nodeOrigin:m,nodeExtent:y,zIndexMode:v,children:_}){const[N]=L.useState(()=>QS({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:x,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:m,nodeExtent:y,zIndexMode:v}));return d.jsx(c_,{value:N,children:d.jsx($_,{children:d.jsx(Q_,{children:_})})})}function ZS({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:x,maxZoom:m,nodeOrigin:y,nodeExtent:v,zIndexMode:_}){return L.useContext(Yl)?d.jsx(d.Fragment,{children:t}):d.jsx(am,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:x,initialMaxZoom:m,nodeOrigin:y,nodeExtent:v,zIndexMode:_,children:t})}const JS={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function ek({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:x,onMove:m,onMoveStart:y,onMoveEnd:v,onConnect:_,onConnectStart:N,onConnectEnd:j,onClickConnectStart:E,onClickConnectEnd:w,onNodeMouseEnter:C,onNodeMouseMove:k,onNodeMouseLeave:b,onNodeContextMenu:A,onNodeDoubleClick:z,onNodeDragStart:V,onNodeDrag:Y,onNodeDragStop:K,onNodesDelete:re,onEdgesDelete:q,onDelete:Z,onSelectionChange:te,onSelectionDragStart:R,onSelectionDrag:U,onSelectionDragStop:H,onSelectionContextMenu:W,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:F,connectionMode:I,connectionLineType:$=Mr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:J=!1,selectionMode:ae=es.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:Ne=rs()?"Meta":"Control",zoomActivationKeyCode:xe=rs()?"Meta":"Control",snapToGrid:ne,snapGrid:je,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Te,nodesDraggable:De,autoPanOnNodeFocus:ht,nodesConnectable:Je,nodesFocusable:Xe,nodeOrigin:lt=Lg,edgesFocusable:yt,edgesReconnectable:Dt,elementsSelectable:qt=!0,defaultViewport:at=k_,minZoom:et=.5,maxZoom:vt=2,translateExtent:xt=Jo,preventScrolling:zn=!0,nodeExtent:rn,defaultMarkerColor:on="#b1b1b7",zoomOnScroll:no=!0,zoomOnPinch:Dn=!0,panOnScroll:di=!1,panOnScrollSpeed:Ir=.5,panOnScrollMode:Rr=ii.Free,zoomOnDoubleClick:nr=!0,panOnDrag:rr=!0,onPaneClick:wn,onPaneMouseEnter:Nt,onPaneMouseMove:Ot,onPaneMouseLeave:Ft,onPaneScroll:_n,onPaneContextMenu:On,paneClickDistance:Sn=1,nodeClickDistance:ut=0,children:Tr,onReconnect:Mt,onReconnectStart:Lr,onReconnectEnd:kn,onEdgeContextMenu:nt,onEdgeDoubleClick:He,onEdgeMouseEnter:Ar,onEdgeMouseMove:sn,onEdgeMouseLeave:Pt,reconnectRadius:Nn=10,onNodesChange:Ht,onEdgesChange:$r,noDragClassName:Fn="nodrag",noWheelClassName:zr="nowheel",noPanClassName:Bt="nopan",fitView:Dr,fitViewOptions:jt,connectOnClick:ir,attributionPosition:Or,proOptions:jn,defaultEdgeOptions:or,elevateNodesOnSelect:fi=!0,elevateEdgesOnSelect:ro=!1,disableKeyboardA11y:hi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:io,autoPanOnSelection:Fr=!0,autoPanSpeed:pi,connectionRadius:bn,isValidConnection:oo,onError:sr,style:lr,id:bt,nodeDragThreshold:Hr,connectionDragThreshold:pt,viewport:gi,onViewportChange:mi,width:yi,height:En,colorMode:Hn="light",debug:Cn,onScroll:Kt,ariaLabelConfig:Br,zIndexMode:vi="basic",...ar},xi){const Bn=bt||"1",Vn=E_(Hn),wi=L.useCallback(Wn=>{Wn.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Kt==null||Kt(Wn)},[Kt]);return d.jsx("div",{"data-testid":"rf__wrapper",...ar,onScroll:wi,style:{...lr,...JS},ref:xi,className:it(["react-flow",a,Vn]),id:bt,role:"application",children:d.jsxs(ZS,{nodes:t,edges:r,width:yi,height:En,fitView:Dr,fitViewOptions:jt,minZoom:et,maxZoom:vt,nodeOrigin:lt,nodeExtent:rn,zIndexMode:vi,children:[d.jsx(b_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:N,onConnectEnd:j,onClickConnectStart:E,onClickConnectEnd:w,nodesDraggable:De,autoPanOnNodeFocus:ht,nodesConnectable:Je,nodesFocusable:Xe,edgesFocusable:yt,edgesReconnectable:Dt,elementsSelectable:qt,elevateNodesOnSelect:fi,elevateEdgesOnSelect:ro,minZoom:et,maxZoom:vt,nodeExtent:rn,onNodesChange:Ht,onEdgesChange:$r,snapToGrid:ne,snapGrid:je,connectionMode:I,translateExtent:xt,connectOnClick:ir,defaultEdgeOptions:or,fitView:Dr,fitViewOptions:jt,onNodesDelete:re,onEdgesDelete:q,onDelete:Z,onNodeDragStart:V,onNodeDrag:Y,onNodeDragStop:K,onSelectionDrag:U,onSelectionDragStart:R,onSelectionDragStop:H,onMove:m,onMoveStart:y,onMoveEnd:v,noPanClassName:Bt,nodeOrigin:lt,rfId:Bn,autoPanOnConnect:Ve,autoPanOnNodeDrag:io,autoPanSpeed:pi,onError:sr,connectionRadius:bn,isValidConnection:oo,selectNodesOnDrag:Te,nodeDragThreshold:Hr,connectionDragThreshold:pt,onBeforeDelete:F,debug:Cn,ariaLabelConfig:Br,zIndexMode:vi}),d.jsx(qS,{onInit:x,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:C,onNodeMouseMove:k,onNodeMouseLeave:b,onNodeContextMenu:A,onNodeDoubleClick:z,nodeTypes:u,edgeTypes:c,connectionLineType:$,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:J,selectionMode:ae,deleteKeyCode:he,multiSelectionKeyCode:Ne,panActivationKeyCode:me,zoomActivationKeyCode:xe,onlyRenderVisibleElements:Me,defaultViewport:at,translateExtent:xt,minZoom:et,maxZoom:vt,preventScrolling:zn,zoomOnScroll:no,zoomOnPinch:Dn,zoomOnDoubleClick:nr,panOnScroll:di,panOnScrollSpeed:Ir,panOnScrollMode:Rr,panOnDrag:rr,autoPanOnSelection:Fr,onPaneClick:wn,onPaneMouseEnter:Nt,onPaneMouseMove:Ot,onPaneMouseLeave:Ft,onPaneScroll:_n,onPaneContextMenu:On,paneClickDistance:Sn,nodeClickDistance:ut,onSelectionContextMenu:W,onSelectionStart:M,onSelectionEnd:D,onReconnect:Mt,onReconnectStart:Lr,onReconnectEnd:kn,onEdgeContextMenu:nt,onEdgeDoubleClick:He,onEdgeMouseEnter:Ar,onEdgeMouseMove:sn,onEdgeMouseLeave:Pt,reconnectRadius:Nn,defaultMarkerColor:on,noDragClassName:Fn,noWheelClassName:zr,noPanClassName:Bt,rfId:Bn,disableKeyboardA11y:hi,nodeExtent:rn,viewport:gi,onViewportChange:mi,nodesDraggable:De}),d.jsx(S_,{onSelectionChange:te}),Tr,d.jsx(y_,{proOptions:jn,position:Or}),d.jsx(m_,{rfId:Bn,disableKeyboardA11y:hi})]})})}var tk=$g(ek);function nk({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:it(["react-flow__background-pattern",o,s])})}function rk({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:it(["react-flow__background-pattern","dots",r])})}var Pr;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Pr||(Pr={}));const ik={[Pr.Dots]:1,[Pr.Lines]:1,[Pr.Cross]:6},ok=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function um({id:t,variant:r=Pr.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:x,patternClassName:m}){const y=L.useRef(null),{transform:v,patternId:_}=ze(ok,Qe),N=s||ik[r],j=r===Pr.Dots,E=r===Pr.Cross,w=Array.isArray(o)?o:[o,o],C=[w[0]*v[2]||1,w[1]*v[2]||1],k=N*v[2],b=Array.isArray(u)?u:[u,u],A=E?[k,k]:C,z=[b[0]*v[2]+A[0]/2,b[1]*v[2]+A[1]/2],V=`${_}${t||""}`;return d.jsxs("svg",{className:it(["react-flow__background",x]),style:{...p,...Kl,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:y,"data-testid":"rf__background",children:[d.jsx("pattern",{id:V,x:v[0]%C[0],y:v[1]%C[1],width:C[0],height:C[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${z[0]},-${z[1]})`,children:j?d.jsx(rk,{radius:k/2,className:m}):d.jsx(nk,{dimensions:A,lineWidth:a,variant:r,className:m})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${V})`})]})}um.displayName="Background";const sk=L.memo(um);function lk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ak(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function uk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 ck(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 wl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:it(["react-flow__controls-button",r]),...o,children:t})}const fk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function cm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:x,children:m,position:y="bottom-left",orientation:v="vertical","aria-label":_}){const N=Ge(),{isInteractive:j,minZoomReached:E,maxZoomReached:w,ariaLabelConfig:C}=ze(fk,Qe),{zoomIn:k,zoomOut:b,fitView:A}=ql(),z=()=>{k(),u==null||u()},V=()=>{b(),c==null||c()},Y=()=>{A(a),h==null||h()},K=()=>{N.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),p==null||p(!j)},re=v==="horizontal"?"horizontal":"vertical";return d.jsxs(Xl,{className:it(["react-flow__controls",re,x]),position:y,style:t,"data-testid":"rf__controls","aria-label":_??C["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(wl,{onClick:z,className:"react-flow__controls-zoomin",title:C["controls.zoomIn.ariaLabel"],"aria-label":C["controls.zoomIn.ariaLabel"],disabled:w,children:d.jsx(lk,{})}),d.jsx(wl,{onClick:V,className:"react-flow__controls-zoomout",title:C["controls.zoomOut.ariaLabel"],"aria-label":C["controls.zoomOut.ariaLabel"],disabled:E,children:d.jsx(ak,{})})]}),o&&d.jsx(wl,{className:"react-flow__controls-fitview",onClick:Y,title:C["controls.fitView.ariaLabel"],"aria-label":C["controls.fitView.ariaLabel"],children:d.jsx(uk,{})}),s&&d.jsx(wl,{className:"react-flow__controls-interactive",onClick:K,title:C["controls.interactive.ariaLabel"],"aria-label":C["controls.interactive.ariaLabel"],children:j?d.jsx(dk,{}):d.jsx(ck,{})}),m]})}cm.displayName="Controls";const hk=L.memo(cm);function pk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:x,borderRadius:m,shapeRendering:y,selected:v,onClick:_}){const{background:N,backgroundColor:j}=u||{},E=c||N||j;return d.jsx("rect",{className:it(["react-flow__minimap-node",{selected:v},x]),x:r,y:o,rx:m,ry:m,width:s,height:a,style:{fill:E,stroke:h,strokeWidth:p},shapeRendering:y,onClick:_?w=>_(w,t):void 0})}const gk=L.memo(pk),mk=t=>t.nodes.map(r=>r.id),Wu=t=>t instanceof Function?t:()=>t;function yk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=gk,onClick:c}){const h=ze(mk,Qe),p=Wu(r),x=Wu(t),m=Wu(o),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(v=>d.jsx(xk,{id:v,nodeColorFunc:p,nodeStrokeColorFunc:x,nodeClassNameFunc:m,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:y},v))})}function vk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:x,x:m,y,width:v,height:_}=ze(N=>{const j=N.nodeLookup.get(t);if(!j)return{node:void 0,x:0,y:0,width:0,height:0};const E=j.internals.userNode,{x:w,y:C}=j.internals.positionAbsolute,{width:k,height:b}=xn(E);return{node:E,x:w,y:C,width:k,height:b}},Qe);return!x||x.hidden||!cg(x)?null:d.jsx(h,{x:m,y,width:v,height:_,style:x.style,selected:!!x.selected,className:s(x),color:r(x),borderRadius:a,strokeColor:o(x),strokeWidth:u,shapeRendering:c,onClick:p,id:x.id})}const xk=L.memo(vk);var wk=L.memo(yk);const _k=200,Sk=150,kk=t=>!t.hidden,Nk=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?lg(us(t.nodeLookup,{filter:kk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},dp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,jk=(t,r)=>dp(t.viewBB,r.viewBB)&&dp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,bk="react-flow__minimap-desc";function dm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:x,maskStrokeColor:m,maskStrokeWidth:y,position:v="bottom-right",onClick:_,onNodeClick:N,pannable:j=!1,zoomable:E=!1,ariaLabel:w,inversePan:C,zoomStep:k=1,offsetScale:b=5}){const A=Ge(),z=L.useRef(null),{boundingRect:V,viewBB:Y,rfId:K,panZoom:re,translateExtent:q,flowWidth:Z,flowHeight:te,ariaLabelConfig:R}=ze(Nk,jk),U=(t==null?void 0:t.width)??_k,H=(t==null?void 0:t.height)??Sk,W=V.width/U,M=V.height/H,D=Math.max(W,M),F=D*U,I=D*H,$=b*D,ie=V.x-(F-V.width)/2-$,oe=V.y-(I-V.height)/2-$,fe=F+$*2,he=I+$*2,pe=`${bk}-${K}`,J=L.useRef(0),ae=L.useRef();J.current=D,L.useEffect(()=>{if(z.current&&re)return ae.current=D1({domNode:z.current,panZoom:re,getTransform:()=>A.getState().transform,getViewScale:()=>J.current}),()=>{var ne;(ne=ae.current)==null||ne.destroy()}},[re]),L.useEffect(()=>{var ne;(ne=ae.current)==null||ne.update({translateExtent:q,width:Z,height:te,inversePan:C,pannable:j,zoomStep:k,zoomable:E})},[j,E,C,k,q,Z,te]);const me=_?ne=>{var Te;const[je,Me]=((Te=ae.current)==null?void 0:Te.pointer(ne))||[0,0];_(ne,{x:je,y:Me})}:void 0,Ne=N?L.useCallback((ne,je)=>{const Me=A.getState().nodeLookup.get(je).internals.userNode;N(ne,Me)},[]):void 0,xe=w??R["minimap.ariaLabel"];return d.jsx(Xl,{position:v,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof y=="number"?y*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:it(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:U,height:H,viewBox:`${ie} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:z,onClick:me,children:[xe&&d.jsx("title",{id:pe,children:xe}),d.jsx(wk,{onClick:Ne,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-$},${oe-$}h${fe+$*2}v${he+$*2}h${-fe-$*2}z - M${Y.x},${Y.y}h${Y.width}v${Y.height}h${-Y.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}dm.displayName="MiniMap";const Ek=L.memo(dm),Ck=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Mk={[Ji.Line]:"right",[Ji.Handle]:"bottom-right"};function Pk({nodeId:t,position:r,variant:o=Ji.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:x=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:y=!1,resizeDirection:v,autoScale:_=!0,shouldResize:N,onResizeStart:j,onResize:E,onResizeEnd:w}){const C=Hg(),k=typeof t=="string"?t:C,b=Ge(),A=L.useRef(null),z=o===Ji.Handle,V=ze(L.useCallback(Ck(z&&_),[z,_]),Qe),Y=L.useRef(null),K=r??Mk[o];L.useEffect(()=>{if(!(!A.current||!k))return Y.current||(Y.current=Q1({domNode:A.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:q,transform:Z,snapGrid:te,snapToGrid:R,nodeOrigin:U,domNode:H}=b.getState();return{nodeLookup:q,transform:Z,snapGrid:te,snapToGrid:R,nodeOrigin:U,paneDomNode:H}},onChange:(q,Z)=>{const{triggerNodeChanges:te,nodeLookup:R,parentLookup:U,nodeOrigin:H}=b.getState(),W=[],M={x:q.x,y:q.y},D=R.get(k);if(D&&D.expandParent&&D.parentId){const F=D.origin??H,I=q.width??D.measured.width??0,$=q.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:I,height:$,...dg({x:q.x??D.position.x,y:q.y??D.position.y},{width:I,height:$},D.parentId,R,F)}},oe=Ec([ie],R,U,H);W.push(...oe),M.x=q.x?Math.max(F[0]*I,q.x):void 0,M.y=q.y?Math.max(F[1]*$,q.y):void 0}if(M.x!==void 0&&M.y!==void 0){const F={id:k,type:"position",position:{...M}};W.push(F)}if(q.width!==void 0&&q.height!==void 0){const I={id:k,type:"dimensions",resizing:!0,setAttributes:v?v==="horizontal"?"width":"height":!0,dimensions:{width:q.width,height:q.height}};W.push(I)}for(const F of Z){const I={...F,type:"position"};W.push(I)}te(W)},onEnd:({width:q,height:Z})=>{const te={id:k,type:"dimensions",resizing:!1,dimensions:{width:q,height:Z}};b.getState().triggerNodeChanges([te])}})),Y.current.update({controlPosition:K,boundaries:{minWidth:h,minHeight:p,maxWidth:x,maxHeight:m},keepAspectRatio:y,resizeDirection:v,onResizeStart:j,onResize:E,onResizeEnd:w,shouldResize:N}),()=>{var q;(q=Y.current)==null||q.destroy()}},[K,h,p,x,m,y,j,E,w,N]);const re=K.split("-");return d.jsx("div",{className:it(["react-flow__resize-control","nodrag",...re,o,s]),ref:A,style:{...a,scale:V,...c&&{[z?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Pk);const Ik={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function Zl(t){return Ik[t]??8}const uc=208,cc=64,Rk=88,Tk=28,Lk=8;function Ak(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function $k(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const w of t){const C=Zl(w.type),k=s.get(C)??[];k.push(w),s.set(C,k)}const u=[...s.keys()].sort((w,C)=>w-C).map(w=>[...s.get(w)??[]].sort((C,k)=>C.name.localeCompare(k.name)||C.id.localeCompare(k.id))),c=new Set(t.map(w=>w.id)),h=new Map,p=new Map;for(const w of t)h.set(w.id,[]),p.set(w.id,[]);for(const w of r)!c.has(w.src)||!c.has(w.dst)||w.src===w.dst||(p.get(w.src).push(w.dst),h.get(w.dst).push(w.src));const x=new Map;u.forEach((w,C)=>{for(const k of w)x.set(k.id,C)});const m=new Map,y=()=>{for(const w of u)w.forEach((C,k)=>m.set(C.id,k))};y();const v=(w,C)=>{const k=w.map((b,A)=>{const z=C(b.id).map(Y=>m.get(Y)).filter(Y=>Y!==void 0),V=Ak(z);return{n:b,bary:Number.isNaN(V)?A:V,name:b.name,id:b.id}});return k.sort((b,A)=>b.bary-A.bary||b.name.localeCompare(A.name)||b.id.localeCompare(A.id)),k.map(b=>b.n)},_=w=>C=>x.get(C)===w;for(let w=0;w(h.get(k)??[]).filter(_(C-1))),y();for(let C=u.length-2;C>=0;C--)u[C]=v(u[C],k=>(p.get(k)??[]).filter(_(C+1))),y()}const N=uc+Rk,j=cc+Tk,E=Math.max(...u.map(w=>w.length),1);return u.forEach((w,C)=>{const k=(E-w.length)*j/2;w.forEach((b,A)=>{o.set(b.id,{x:C*N,y:k+A*j})})}),o}const zk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),fm=90,Dk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),fp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Ok=Math.PI*(3-Math.sqrt(5)),hm=220,Fk=26,Hk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function pm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function PN(t){return fp[t]?fp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Bk(t){return t>=fm?"3d":"2d"}function Vk(t){return t>=fm?"overview":"full"}function Wk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(pm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Dk.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Wk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Gk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function Yk(t,r,o,s){const a=new Set(t.map(j=>j.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const j of r){if(!a.has(j.src)||!a.has(j.dst))continue;const E=u.get(j.src)??[];E.push({dst:j.dst,id:j.id}),u.set(j.src,E);const w=c.get(j.dst)??[];w.push({src:j.src,id:j.id}),c.set(j.dst,w)}const h=new Set(t.filter(j=>zk.has(j.type)).map(j=>j.id)),p=h.size?h:a,x=new Set,m=[o];for(;m.length;){const j=m.pop();if(!x.has(j)){x.add(j);for(const E of u.get(j)??[])x.has(E.dst)||m.push(E.dst)}}const y=new Set([o]),v=[...p].filter(j=>x.has(j)),_=new Set(v);for(;v.length;){const j=v.pop();y.add(j);for(const E of c.get(j)??[])x.has(E.src)&&!_.has(E.src)&&(_.add(E.src),v.push(E.src))}const N=new Set;for(const j of r)y.has(j.src)&&y.has(j.dst)&&N.add(j.id);return{nodeIds:y,edgeIds:N}}function IN(t){const r=new Map;for(const s of t){const a=Zl(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*hm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Fk*Math.sqrt(h+1),x=h*Ok;o.set(c.id,{x:u,y:p*Math.cos(x),z:p*Math.sin(x)})})}return o}function RN(t){const r=new Map;for(const o of t){const s=Zl(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*hm,count:s}))}const _l=16,Xk=12,qk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Kk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),hp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Qk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},pp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],gp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Zk=new Set(["looks_idempotent_on_pk","null","blank"]),Jk=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function eN(t){return hp[t]?hp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function tN(t,r,o){const s=new Map(r.map(v=>[v.id,v])),a=[];qk.has(t.type)&&a.push("sink"),Kk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(v=>v.dst===t.id),h=o.filter(v=>v.src===t.id),p=c.slice(0,_l).map(v=>Sl(v,s,v.src)),x=h.slice(0,_l).map(v=>Sl(v,s,v.dst)),m=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,y={type:t.type,typeLabel:Xo(to(t.type)),layer:Hk[Zl(t.type)]??"other",purpose:eN(t.type),name:t.name,qualifiedName:t.qualified_name,file:m,context:t.context,roles:a,facts:rN(u).filter(v=>!(v.key==="app"&&v.value===t.context)),inputs:p,outputs:x,extraInputs:Math.max(0,c.length-_l),extraOutputs:Math.max(0,h.length-_l),degreeIn:c.length,degreeOut:h.length,inputKinds:mp(c.map(v=>Sl(v,s,v.src))),outputKinds:mp(h.map(v=>Sl(v,s,v.dst))),pathSummary:""};return y.pathSummary=nN(y),y}function mp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function nN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function Sl(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Xo(to(s.type)):"",edgeType:t.type,edgeLabel:Xo(t.type),inferred:t.confidence<.8}}function rN(t){const r=[...pp.filter(a=>a in t),...Object.keys(t).filter(a=>!pp.includes(a)&&!gp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||gp.has(a)||Jk.has(a))continue;s.add(a);const u=iN(a,t[a]);u!=null&&o.push({key:a,label:Qk[a]??Xo(a),value:u})}return o}function iN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Zk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return oN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Xk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function oN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const sN=new Set,lN=L.lazy(()=>_0(()=>import("./LayeredGraph3D--37-6JMJ.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),aN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function uN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(eo,{type:"target",position:ke.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:to(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Cr(t.name)}),d.jsx(eo,{type:"source",position:ke.Right,isConnectable:!1})]})}const cN={load:uN},dN=new Set(["django","react","stitch","arch"]);function fN({topologyKey:t}){const{fitView:r}=ql();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function hN(t,r,o=null,s={}){const a=new Map(t.map(p=>[p.id,p])),u=$k(t,r),c=t.map(p=>{var y;const x=((y=s.roles)==null?void 0:y[p.id])||[],m=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:p.id,type:"load",position:u.get(p.id)??{x:0,y:0},data:{name:p.name,type:p.type,file:p.file_path,roles:x,dim:m},selected:o===p.id,sourcePosition:ke.Right,targetPosition:ke.Left,width:uc,height:cc,style:{width:uc,height:cc}}}),h=r.filter(p=>a.has(p.src)&&a.has(p.dst)).map(p=>{const x=aN[p.weight]||"var(--edge-cheap)",m=!!(o&&(p.src===o||p.dst===o));return{id:p.id,source:p.src,target:p.dst,type:"smoothstep",animated:p.weight==="critical",style:{stroke:x,strokeWidth:p.weight==="critical"?2.4:1.2,strokeDasharray:p.confidence<.8?"6 4":void 0},markerEnd:{type:ts.ArrowClosed,width:14,height:14,color:x},label:m?p.type.replaceAll("_"," "):void 0,labelStyle:m?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:m?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:m?[3,5]:void 0,labelBgBorderRadius:m?4:void 0}});return{rfNodes:c,rfEdges:h}}function pN({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:x}){const m=tN(t,r,o);return L.useEffect(()=>{const y=v=>{v.key==="Escape"&&s()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:m.typeLabel}),d.jsx("div",{className:"inspector-roles",children:m.roles.map(y=>d.jsx("span",{className:"inspector-chip",children:y},y))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Cr(m.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:m.purpose}),m.context?d.jsx("div",{className:"muted",children:Cr(m.context)}):null,m.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Cr(m.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Cr(m.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",m.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[m.degreeIn," in · ",m.degreeOut," out"]}),m.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:m.pathSummary}):null,m.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:m.facts.map(y=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:y.label}),d.jsx("dd",{children:Cr(y.value)})]},y.key))}):null,d.jsx(yp,{title:"Inputs",testId:"graph-inspector-inputs",links:m.inputs,extra:m.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(yp,{title:"Outputs",testId:"graph-inspector-outputs",links:m.outputs,extra:m.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",onClick:()=>a(t.id),children:"What if this changes"}):null,x?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",onClick:()=>x(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function yp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Cr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Cr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Uu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:x,repoPath:m,onOpenFile:y,pinnedId:v,onPin:_}){const[N,j]=L.useState(null),E=a!==void 0?a:N,w=ne=>{a===void 0&&j(ne),u==null||u(ne)},[C,k]=L.useState(null),[b,A]=L.useState(null),[z,V]=L.useState(new Set(dN)),[Y,K]=L.useState(!1),[re,q]=L.useState(""),[Z,te]=L.useState(!1),R=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,U=C??Bk(t.length),H=b??Vk(t.length),W=Y?E:null,M=L.useMemo(()=>p?Yk(t,r,p):null,[t,r,p]),D=M?t.filter(ne=>M.nodeIds.has(ne.id)):t,F=M?r.filter(ne=>M.edgeIds.has(ne.id)):r,I=L.useMemo(()=>Uk(D,F,{detail:H,families:z,focusId:W,neighborhoodOnly:!!W}),[D,F,H,z,W]),$=L.useMemo(()=>`${I.nodes.map(ne=>ne.id).join("\0")}|${I.edges.map(ne=>ne.id).join("\0")}`,[I.nodes,I.edges]),ie=E?t.find(ne=>ne.id===E)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const ne=hN(I.nodes,I.edges,E,{roles:c,testOverlay:h});return R&&(ne.rfEdges=ne.rfEdges.map(je=>({...je,animated:!1}))),ne},[I.nodes,I.edges,E,R,c,h]);L.useEffect(()=>{if(!s)return;const ne=t.find(je=>je.file_path===s);ne&&w(ne.id)},[s,t]);const he=L.useMemo(()=>Gk(t,re),[t,re]),pe=(ne,je)=>{w(je.id)},J=()=>{w(null),K(!1)},ae=ie?d.jsx(pN,{node:ie,nodes:t,edges:r,onClose:J,onWhatIf:o,onSelect:w,onOpenFile:y,pinned:v===ie.id,onPin:_,onIsolate:x?ne=>{x(p===ne?null:ne)}:void 0}):null,me=ne=>{V(je=>{const Me=new Set(je);if(Me.has(ne)){if(Me.size===1)return je;Me.delete(ne)}else Me.add(ne);return Me})},Ne=L.useMemo(()=>{const ne=new Set;for(const je of t)ne.add(pm(je.type));return ne},[t]),xe=t.length-I.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:U==="2d"?"active":"","aria-pressed":U==="2d",onClick:()=>k("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:U==="3d"?"active":"","aria-pressed":U==="3d",onClick:()=>k("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:H==="overview"?"active":"","aria-pressed":H==="overview",onClick:()=>A("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:H==="full"?"active":"","aria-pressed":H==="full",onClick:()=>A("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(ne=>Ne.has(ne)).map(ne=>d.jsx("button",{type:"button","data-testid":`graph-family-${ne}`,className:z.has(ne)?"active":"","aria-pressed":z.has(ne),onClick:()=>me(ne),children:ne},ne))}),d.jsx("button",{type:"button",className:Y?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!E,onClick:()=>K(ne=>!ne),children:Y?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>x==null?void 0:x(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:re,onChange:ne=>{q(ne.target.value),te(!0)},onFocus:()=>te(!0),onBlur:()=>window.setTimeout(()=>te(!1),150)}),Z&&re.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(ne=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:je=>je.preventDefault(),onClick:()=>{w(ne.id),q(""),te(!1)},children:[ne.name,d.jsx("span",{className:"muted",children:to(ne.type)})]})},ne.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[I.nodes.length," nodes · ",I.edges.length," edges",xe?` · ${xe} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:U==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(lN,{nodes:I.nodes,edges:I.edges,selectedId:E,neighborIds:W?I.neighborIds:sN,onSelect:ne=>{w(ne),ne||K(!1)}})}),ae]}):d.jsxs(am,{children:[d.jsxs(tk,{nodes:oe,edges:fe,nodeTypes:cN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:J,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(fN,{topologyKey:$}),d.jsx(sk,{}),d.jsx(Ek,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(hk,{})]}),ae]})})]})}function gm(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function gN(t){localStorage.setItem("loadpath.editor",t)}async function mN(t,r,o,s=gm()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const vp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],yN=["preset","branch","tag","commit"];function vN(t){var a;if(!(t!=null&&t.git))return[...vp];const r=((a=t.presets)!=null&&a.length?t.presets:vp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function xN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function wN(t){return yN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function _N(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function xp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[x,m]=L.useState(!1),[y,v]=L.useState(null),[_,N]=L.useState(0),j=L.useMemo(()=>{const b=vN(u);return y===null?b:xN(b,y)},[u,y]),E=L.useMemo(()=>wN(j),[j]);L.useEffect(()=>{x&&c()},[x,c]),L.useEffect(()=>{N(0)},[y,x]);const w=()=>{m(!1),v(null)},C=b=>{r(b.value),w()},k=b=>{if(b.key==="ArrowDown"){if(b.preventDefault(),!x){m(!0);return}N(A=>Math.min(A+1,Math.max(j.length-1,0)))}else if(b.key==="ArrowUp"){if(b.preventDefault(),!x)return;N(A=>Math.max(A-1,0))}else if(b.key==="Enter"&&x){b.preventDefault();const A=j[_];A&&C(A)}else b.key==="Escape"&&x&&(b.preventDefault(),w())};return d.jsxs("div",{className:"combo",ref:p,onBlur:b=>{b.currentTarget.contains(b.relatedTarget)||w()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":x,"aria-controls":h,"aria-autocomplete":"list",onChange:b=>{r(b.target.value),x&&v(b.target.value)},onKeyDown:k}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":x,onMouseDown:b=>b.preventDefault(),onClick:()=>x?w():m(!0),children:d.jsx(v0,{})})]}),x?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:E.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):E.map(b=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:_N(b.group)}),b.items.map(A=>{const z=j.indexOf(A);return d.jsxs("button",{type:"button",role:"option","aria-selected":z===_,className:z===_?"combo-option active":"combo-option","data-testid":`ref-option-${A.group}`,onMouseDown:V=>V.preventDefault(),onMouseEnter:()=>N(z),onClick:()=>C(A),children:[d.jsx("span",{className:"combo-label",children:A.label}),A.detail?d.jsx("span",{className:"combo-detail",children:A.detail}):null]},`${A.group}:${A.value}`)})]},b.group))}):null]})}function SN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[x,m]=L.useState(""),[y,v]=L.useState(!1),_=L.useRef(null),N=L.useRef(0),j=async k=>{const b=N.current+1;N.current=b,v(!0);try{const A=await Pe.browse(k);if(N.current!==b)return;a(A),c(A.path),p(A.is_git?A.path:null),m("")}catch(A){if(N.current!==b)return;m(A instanceof Error?A.message:String(A))}finally{N.current===b&&v(!1)}};L.useEffect(()=>{var k,b;j(t),(k=_.current)==null||k.focus(),(b=_.current)==null||b.select()},[t]);const E=h||(s==null?void 0:s.path)||u,w=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",C=k=>{k.key==="Escape"&&(k.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:C,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:k=>k.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:k=>{k.preventDefault(),j(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:k=>c(k.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),x?d.jsx("div",{className:"error",role:"alert",children:x}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":y,children:s!=null&&s.entries.length?s.entries.map(k=>{const b=h===k.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":b,className:b?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":k.path,onClick:()=>p(k.path),onDoubleClick:()=>void j(k.path),children:[d.jsx(kp,{}),d.jsx("span",{className:"explorer-name",children:k.name}),k.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},k.path)}):d.jsx("div",{className:"muted explorer-empty",children:y?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:E,children:E}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!E,onClick:()=>E&&r(E),children:["Use ",w]})]})]})})}const Dl=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],kN="obsidian",mm="loadpath.theme";function NN(t){return Dl.some(r=>r.id===t)}function ym(){try{const t=localStorage.getItem(mm)||"";if(NN(t))return t}catch{}return kN}function jN(t){var r;return((r=Dl.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function vm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=jN(t);try{localStorage.setItem(mm,t)}catch{}}const Gu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:h0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:p0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:g0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:m0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:y0}];function bN(t){const r=t.total||0;return r<=0?null:Math.min(100,Math.round(100*(t.done||0)/r))}function Yu(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function EN(){var wi,Wn,Oe,so,lo,_i,ao,uo,co;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,x]=L.useState(null),[m,y]=L.useState(null),[v,_]=L.useState([]),[N,j]=L.useState("review"),[E,w]=L.useState(""),[C,k]=L.useState(""),[b,A]=L.useState(null),[z,V]=L.useState(!1),[Y,K]=L.useState(!1),[re,q]=L.useState(""),[Z,te]=L.useState({}),[R,U]=L.useState([]),[H,W]=L.useState([]),[M,D]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[F,I]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[$,ie]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[oe,fe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[he,pe]=L.useState(0),[J,ae]=L.useState(""),[me,Ne]=L.useState(ym),[xe,ne]=L.useState(!1),[je,Me]=L.useState(!1),[Te,De]=L.useState(!1),[ht,Je]=L.useState(null),[Xe,lt]=L.useState(null),[yt,Dt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[qt,at]=L.useState(null),[et,vt]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[xt,zn]=L.useState([]),[rn,on]=L.useState(null),[no,Dn]=L.useState(null),[di,Ir]=L.useState(null),[Rr,nr]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[rr,wn]=L.useState(null),[Nt,Ot]=L.useState(null),[Ft,_n]=L.useState(!1),[On,Sn]=L.useState(!1),ut=L.useRef(o);ut.current=o;const Tr=L.useRef(!1);Tr.current=je;const Mt=L.useRef(""),Lr=L.useRef(""),kn=P=>{Ne(P),vm(P)},nt=L.useRef(""),He=P=>{nt.current=P,k(P)},Ar=P=>{const G=()=>{Pe.indexProgress(P).then(Se=>{nt.current&&(Se.phase&&Se.phase!=="idle"&&Se.message&&He(Se.message),A(Se.phase&&Se.phase!=="idle"?bN(Se):null))}).catch(()=>{})};G();const ce=window.setInterval(G,250);return()=>{window.clearInterval(ce),A(null)}};L.useEffect(()=>{Pe.settings().then(te).catch(()=>{}).finally(()=>ne(!0)),Pe.repos().then(P=>_(P.repos)).catch(()=>{})},[]);const sn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const P=o;let G=!1;return Lr.current!==P&&ir(P),Pe.config(P).then(ce=>{!G&&ut.current===P&&Dn(ce)}).catch(()=>{}),Pe.architectureHealth(P).then(ce=>{!G&&ut.current===P&&Ir(ce)}).catch(()=>{}),()=>{G=!0}},[t,o]);const Pt=P=>{ut.current=P,s(P),localStorage.setItem("loadpath.repo",P),P.trim()!==Mt.current&&(Mt.current="",wn(null))},Nn=L.useCallback(P=>{const G=(P??ut.current).trim();return!G||Mt.current===G?Promise.resolve():(Mt.current=G,Pe.gitRefs(G).then(ce=>{ut.current.trim()===G&&wn(ce)}).catch(()=>{Mt.current===G&&(Mt.current="",wn(null))}))},[]),Ht=(P,G)=>{u(P),h(G),localStorage.setItem("loadpath.base",P),localStorage.setItem("loadpath.head",G)},$r=(P,G,ce)=>{I(P),D(G),localStorage.setItem("loadpath.provider",P),localStorage.setItem("loadpath.scmRepo",G),ce!==void 0&&(ie(ce),localStorage.setItem("loadpath.prNumber",ce))},Fn=P=>{x(P),pe(0),Je(Xe&&P.nodes.some(G=>G.id===Xe)?Xe:null),at(null),on(null),P.id&&!P.what_if&&localStorage.setItem("loadpath.lastReviewId",P.id)},zr=async P=>{try{const G=await Pe.reviews(P);zn(G.reviews)}catch{zn([])}},Bt=async P=>{try{Ir(await Pe.architectureHealth(P))}catch{Ir(null)}},Dr=P=>P==="github"?!!Z.github_token_set:P==="gitlab"?!!Z.gitlab_token_set:!!Z.bitbucket_token_set,jt=L.useCallback(async(P=F)=>{var G;try{const ce=await Pe.scmRepos(P);W(ce.repos),(G=ce.user)!=null&&G.login&&te(Se=>({...Se,...P==="github"?{github_user:ce.user.login}:P==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{W([])}},[F]);L.useEffect(()=>{if(t!=="prs")return;let P=!1;return jt(F).catch(()=>{P||W([])}),()=>{P=!0}},[t,F,jt]),L.useEffect(()=>{if(!Nt)return;let P=!1,G=0;const ce=async()=>{try{const Se=await Pe.githubOAuthPoll(Nt.flow_id);if(P)return;if(Se.status==="complete"){Ot(null);const Ie=await Pe.settings();te(Ie),q(Se.user?`Signed in to GitHub as ${Se.user}`:"Signed in to GitHub"),jt("github");return}if(Se.status==="pending"||Se.status==="slow_down"){G=window.setTimeout(ce,Math.max(Se.interval||Nt.interval,5)*1e3);return}Ot(null),w(Se.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(Se){if(P)return;Ot(null),w(Se instanceof Error?Se.message:String(Se))}};return G=window.setTimeout(ce,Math.max(Nt.interval,5)*1e3),()=>{P=!0,window.clearTimeout(G)}},[Nt,jt]),L.useEffect(()=>{if(!Ft)return;let P=!1,G=0;const ce=Date.now(),Se=async()=>{try{const Ie=await Pe.oauthStatus();if(P)return;if(Ie.bitbucket.connected){_n(!1);const Ae=await Pe.settings();te(Ae),q(Ie.bitbucket.user?`Signed in to Bitbucket as ${Ie.bitbucket.user}`:"Signed in to Bitbucket"),jt("bitbucket");return}if(Date.now()-ce>18e4){_n(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}G=window.setTimeout(Se,1500)}catch(Ie){if(P)return;_n(!1),w(Ie instanceof Error?Ie.message:String(Ie))}};return G=window.setTimeout(Se,1500),()=>{P=!0,window.clearTimeout(G)}},[Ft,jt]),L.useEffect(()=>{if(!On)return;let P=!1,G=0;const ce=Date.now(),Se=async()=>{try{const Ie=await Pe.oauthStatus();if(P)return;if(Ie.gitlab.connected){Sn(!1);const Ae=await Pe.settings();te(Ae),q(Ie.gitlab.user?`Signed in to GitLab as ${Ie.gitlab.user}`:"Signed in to GitLab"),jt("gitlab");return}if(Date.now()-ce>18e4){Sn(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}G=window.setTimeout(Se,1500)}catch(Ie){if(P)return;Sn(!1),w(Ie instanceof Error?Ie.message:String(Ie))}};return G=window.setTimeout(Se,1500),()=>{P=!0,window.clearTimeout(G)}},[On,jt]);const ir=async(P=o,G=!1)=>{if(!P.trim())return null;Lr.current=P,K(!0);try{const ce=await Pe.architecture(P,!1);ut.current===P&&y(ce);const Se=Pe.architectureGraph(P).then(Ie=>{ut.current===P&&y(Ae=>Ae&&{...Ae,nodes:Ie.nodes,edges:Ie.edges,graph_pending:!1})});return Se.catch(()=>{}).finally(()=>{ut.current===P&&K(!1)}),G&&await Se,ce}catch(ce){throw ut.current===P&&K(!1),ce}},Or=async P=>{const G=P.trim();if(!(!G||G===ut.current)){if(nt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),q(""),x(null),y(null),j("architecture"),Pt(G),V(!0),He(`Loading ${f0(G)}…`);try{await Promise.all([ir(G),Nn(G)])}catch(ce){ut.current===G&&w(ce instanceof Error?ce.message:String(ce))}finally{ut.current===G&&(He(""),V(!1))}}},jn=async()=>{if(nt.current||!sn())return;w(""),q(""),He("Tracing load path…"),Pt(o),Ht(a,c);const P=Ar(o);try{const G=await Pe.review(o,a,c,!0,oe);Fn(G),j("review"),r("review"),await Pe.repos().then(ce=>_(ce.repos)).catch(()=>{}),await Promise.all([ir(o),zr(o),Bt(o)])}catch(G){w(G instanceof Error?G.message:String(G))}finally{P(),He("")}},or=async(P=!0)=>{if(nt.current||!sn())return;w(""),q(""),He(P?"Indexing…":"Full reindex…"),Pt(o);const G=Ar(o);try{await Pe.index(o,P);const ce=await ir(o);await Pe.repos().then(Se=>_(Se.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(j("architecture"),r("architecture"))}catch(ce){w(ce instanceof Error?ce.message:String(ce))}finally{G(),He("")}},fi=async()=>{if(!nt.current&&sn()){w(""),q(""),He("Detecting layout…"),Pt(o);try{const P=await Pe.init(o);q(P.message),await Pe.repos().then(G=>_(G.repos)).catch(()=>{})}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},ro=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),q("Copied markdown brief")}catch(P){w(P instanceof Error?P.message:String(P))}},hi=async()=>{if(!nt.current){if(!(p!=null&&p.markdown)||!M||!$){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const P=await Pe.postComment(F,M,Number($),p.markdown);q(P.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ve=async()=>{if(!nt.current){w(""),He("Fetching pull requests…");try{const P=await Pe.prs(F,M,"open",o.trim()||void 0);U(P.pull_requests);const G=H.find(ce=>ce.slug.toLowerCase()===M.trim().toLowerCase());G!=null&&G.local_path&&Pt(G.local_path)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},io=async()=>{w("");try{const P=await Pe.githubOAuthStart();Ot(P),Yu(P.verification_uri_complete,"github.com","/login/device")}catch(P){w(P instanceof Error?P.message:String(P))}},Fr=async()=>{w("");try{const P=await Pe.bitbucketOAuthStart();_n(!0),Yu(P.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(P){_n(!1),w(P instanceof Error?P.message:String(P))}},pi=async()=>{w("");try{const P=await Pe.gitlabOAuthStart();Sn(!0),Yu(P.authorize_url,new URL(P.authorize_url).hostname,"/oauth/authorize")}catch(P){Sn(!1),w(P instanceof Error?P.message:String(P))}},bn=async P=>{if(!(nt.current||!o.trim())){w(""),He("Walking what-if path…");try{const G=await Pe.whatIf(o,P);q(`${G.title} — ${G.confidence.level} · ${(G.sinks||[]).length} sinks`),Fn({...G,markdown:G.markdown||"",index:G.index||(p==null?void 0:p.index),workspace:G.workspace||(p==null?void 0:p.workspace)}),j("review"),r("review")}catch(G){w(G instanceof Error?G.message:String(G))}finally{He("")}}},oo=async P=>{var Ie;if(nt.current)return;$r(P.provider,P.repo,String(P.number));const G=H.find(Ae=>Ae.slug.toLowerCase()===P.repo.toLowerCase());G!=null&&G.local_path&&Pt(G.local_path),w(""),He(`Fetching ${P.provider} #${P.number}…`);const ce=(G==null?void 0:G.local_path)||o,Se=ce?Ar(ce):()=>{};try{const Ae=await Pe.reviewPr(P.provider,P.repo,P.number,(G==null?void 0:G.local_path)||o||void 0);Fn(Ae),Ae.pull_request&&typeof Ae.pull_request.repo_path=="string"&&Pt(Ae.pull_request.repo_path),Ht(String(Ae.base||P.target_branch),String(Ae.head||P.source_branch)),j("review"),r("review"),typeof((Ie=Ae.pull_request)==null?void 0:Ie.repo_path)=="string"&&zr(Ae.pull_request.repo_path)}catch(Ae){Ht(P.base_sha||P.target_branch,P.head_sha||P.source_branch),r("review"),w(Ae instanceof Error?Ae.message:String(Ae))}finally{Se(),He("")}},sr=async P=>{w("");try{te(await Pe.oauthDisconnect(P)),F===P&&W([]),q(`Disconnected ${P}`)}catch(G){w(G instanceof Error?G.message:String(G))}},lr=async P=>{P.preventDefault();const G=new FormData(P.currentTarget),ce={github_token:String(G.get("github_token")||""),github_oauth_client_id:String(G.get("github_oauth_client_id")||""),github_host:String(G.get("github_host")||""),gitlab_token:String(G.get("gitlab_token")||""),gitlab_host:String(G.get("gitlab_host")||""),gitlab_oauth_client_id:String(G.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(G.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(G.get("bitbucket_token")||""),bitbucket_username:String(G.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(G.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(G.get("bitbucket_oauth_client_secret")||""),ai_provider:String(G.get("ai_provider")||"none"),ai_api_key:String(G.get("ai_api_key")||""),ai_model:String(G.get("ai_model")||""),ai_base_url:String(G.get("ai_base_url")||"")},Se=v.length?{...ce,workspaces:v.map(Ie=>({path:Ie.path,name:Ie.name}))}:ce;try{te(await Pe.saveSettings(Se)),q("Settings saved on this machine")}catch(Ie){w(Ie instanceof Error?Ie.message:String(Ie))}},bt=async()=>{if(!(!p||nt.current)){He("Residual analysis…");try{const P=await Pe.residual(p);ae(P.note)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Hr=L.useRef(jn);Hr.current=jn;const pt=L.useRef(t);pt.current=t;const gi=L.useRef(!1);gi.current=Te;const mi=L.useRef(p);mi.current=p;const yi=L.useRef(he);yi.current=he,L.useEffect(()=>{const P=localStorage.getItem("loadpath.lastReviewId"),G=(localStorage.getItem("loadpath.repo")||"").trim();if(!P||!G){nr(!1);return}let ce=!1;return Pe.getReview(G,P).then(Se=>{ce||(Fn(Se),Ht(Se.base||localStorage.getItem("loadpath.base")||"HEAD~1",Se.head||localStorage.getItem("loadpath.head")||"HEAD"),zr(G),Bt(G))}).catch(()=>{}).finally(()=>{ce||nr(!1)}),()=>{ce=!0}},[]);const En=L.useRef("");L.useEffect(()=>{if(!et||!o.trim())return;let P=!1;const G=async()=>{try{const Se=await Pe.workspaceStatus(o);if(P)return;En.current&&Se.fingerprint!==En.current&&!nt.current&&(fe(!0),localStorage.setItem("loadpath.dirty","1"),Hr.current()),En.current=Se.fingerprint}catch{}};G();const ce=window.setInterval(G,2e3);return()=>{P=!0,window.clearInterval(ce)}},[et,o]),L.useEffect(()=>{const P=G=>{var Ie;if((G.metaKey||G.ctrlKey)&&G.key.toLowerCase()==="k"){G.preventDefault(),De(Ae=>!Ae);return}if(gi.current){G.key==="Escape"&&(G.preventDefault(),De(!1));return}if(Tr.current){G.key==="Escape"&&(G.preventDefault(),Me(!1));return}const ce=G.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){G.key==="Escape"&&ce.blur();return}if(G.key==="Escape"){w(""),q(""),Je(Xe),at(null);return}if(G.key==="j"||G.key==="k"){const Ae=((Ie=mi.current)==null?void 0:Ie.read_order)||[];if(!Ae.length)return;G.preventDefault();const ur=yi.current,Mn=G.key==="j"?Math.min(Ae.length-1,ur+1):Math.max(0,ur-1);pe(Mn);return}const Se=Gu.find(Ae=>Ae.shortcut===G.key);if(Se&&!G.metaKey&&!G.ctrlKey&&!G.altKey&&r(Se.id),(G.metaKey||G.ctrlKey)&&G.key==="Enter"){if(pt.current==="settings"||pt.current==="prs"||nt.current)return;G.preventDefault(),Hr.current()}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[Xe]);const Hn=async(P,G)=>{if(!o.trim())return;const ce=await mN(o,P,G);ce.ok?q(ce.message):w(ce.message)},Cn=async()=>{if(p)try{const P=await Pe.exportHtml(p),G=URL.createObjectURL(P),ce=document.createElement("a");ce.href=G,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(G),q("Saved HTML brief")}catch(P){w(P instanceof Error?P.message:String(P))}},Kt=async P=>{if(o.trim()){He("Loading stored review…");try{const G=await Pe.getReview(o,P);Fn(G),Ht(G.base||a,G.head||c),j("review"),r("review");const ce=xt.find(Se=>Se.id!==P);if(ce)try{on(await Pe.reviewDiff(o,P,ce.id))}catch{on(null)}}catch(G){w(G instanceof Error?G.message:String(G))}finally{He("")}}},Br={selectedId:ht,onSelect:Je,nodeRoles:p==null?void 0:p.node_roles,testOverlay:yt,isolateSource:qt,onIsolate:at,repoPath:o,onOpenFile:Hn,pinnedId:Xe,onPin:lt},vi=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},{id:"index",group:"Run",label:"Index repository",run:()=>void or(!0)},{id:"watch",group:"Run",label:et?"Stop watching working tree":"Watch working tree",run:()=>{const P=!et;vt(P),localStorage.setItem("loadpath.watch",P?"1":"0")}},{id:"tests",group:"Graph",label:yt?"Hide test overlay":"Show test overlay",run:()=>{const P=!yt;Dt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Cn()},...Gu.map(P=>({id:`tab-${P.id}`,group:"Tabs",label:`Go to ${P.label}`,hint:P.shortcut,run:()=>r(P.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(P=>({id:`node-${P.id}`,group:"Nodes",label:P.name,hint:to(P.type),run:()=>{Je(P.id),r("graph")}})),...xt.slice(0,12).map(P=>({id:`hist-${P.id}`,group:"History",label:P.title||P.id,hint:`${P.level||""} ${P.created_at||""}`.trim(),run:()=>void Kt(P.id)}))],ar=L.useMemo(()=>N==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[N,m,p]),xi=L.useMemo(()=>N==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[N,m,p]),Bn=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Vn=((p==null?void 0:p.findings)||[]).filter(P=>!P.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Gu.map(P=>{const G=P.icon,ce=t===P.id;return d.jsxs("button",{type:"button","data-testid":P.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":P.label,onClick:()=>r(P.id),children:[d.jsx(G,{}),d.jsx("span",{children:P.label})]},P.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:me,onChange:P=>kn(P.target.value),children:["dark","light"].map(P=>d.jsx("optgroup",{label:P==="dark"?"Dark":"Light",children:Dl.filter(G=>G.group===P).map(G=>d.jsx("option",{value:G.id,children:G.label},G.id))},P))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:C||Bn}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[C?d.jsxs("div",{className:b!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","data-testid":"progress",children:[d.jsx("i",{style:b!=null?{width:`${b}%`}:void 0}),d.jsx("span",{className:"sr-only",children:C})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[v.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:v.some(P=>P.path===o)?o:"",disabled:!!C,"aria-busy":z,onChange:P=>{P.target.value&&Or(P.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),v.map(P=>d.jsxs("option",{value:P.path,children:[P.name,P.indexed?` (${P.counts.nodes})`:""]},P.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:P=>{const G=P.target.value;s(G),G.trim()!==Mt.current&&(Mt.current="",wn(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>Me(!0),children:d.jsx(kp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(xp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:P=>Ht(P,c),placeholder:"base",refs:rr,onNeedRefs:Nn})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(xp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:P=>Ht(a,P),placeholder:"head",refs:rr,onNeedRefs:Nn})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:oe?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":oe,onClick:()=>{const P=!oe;fe(P),localStorage.setItem("loadpath.dirty",P?"1":"0")},children:oe?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:et?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":et,onClick:()=>{const P=!et;vt(P),localStorage.setItem("loadpath.watch",P?"1":"0")},children:et?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!C,onClick:fi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!C,onClick:()=>or(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!C,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[E?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:E}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,re?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:re}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>q(""),"aria-label":"Dismiss",children:"×"})]}):null,((wi=p==null?void 0:p.index)!=null&&wi.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((Wn=p==null?void 0:p.index)==null?void 0:Wn.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Oe=p==null?void 0:p.index)==null?void 0:Oe.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(so=p==null?void 0:p.workspace)!=null&&so.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,z?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:C||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":z||Y,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(CN,{review:p,findings:Vn,aiNote:J,busy:!!C,tourIndex:he,onTour:pe,onAskAi:bt,onCopy:ro,onPost:hi,onSelect:Je,onOpenFile:Hn,onExport:Cn,history:xt,diff:rn,onReopen:Kt,onWaiver:(P,G)=>{o.trim()&&Pe.addWaiver(o,P,G||void 0,"from review").then(ce=>{Dn(ce),q(`Waived ${P} in loadpath.yml`)})}}):Rr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Uu,{nodes:p.nodes,edges:p.edges,onWhatIf:bn,focusPath:(lo=p.read_order[he])==null?void 0:lo.path,...Br}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(MN,{architecture:m,busy:!!C,onReindex:()=>or(!1),onReview:jn,onSelect:Je,config:no,health:di,onSaveConfig:P=>{Pe.saveConfig(o,P).then(G=>{Dn(G),q("Wrote loadpath.yml")})},onWaiver:(P,G,ce)=>{Pe.addWaiver(o,P,G,ce).then(Se=>{Dn(Se),q(`Waived ${P}`)})}}):z?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(Y||m!=null&&m.graph_pending)&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(_i=m==null?void 0:m.counts)!=null&&_i.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Uu,{nodes:m.nodes,edges:m.edges,onWhatIf:bn,...Br,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":N==="review","data-testid":"graph-mode-review",className:N==="review"?"active":"",onClick:()=>j("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":N==="architecture","data-testid":"graph-mode-architecture",className:N==="architecture"?"active":"",onClick:()=>j("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:yt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":yt,onClick:()=>{const P=!yt;Dt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")},children:"Tests"})]}),ar.length?d.jsx(Uu,{nodes:ar,edges:xi,onWhatIf:bn,...Br}):Y||m!=null&&m.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:F,onChange:P=>$r(P.target.value,M,$),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:H.length?"Search your repos":"owner/repo",value:M,onChange:P=>$r(F,P.target.value,$),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:H.map(P=>d.jsxs("option",{value:P.slug,children:[P.private?"private":"public",P.local_path?" · local":""]},P.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!C||!Dr(F),onClick:()=>{jt(F)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!C,onClick:Ve,children:"List PRs"})]}),H.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[H.length," ",F," repositor",H.length===1?"y":"ies",F==="github"&&Z.github_user?` · @${String(Z.github_user)}`:"",F==="gitlab"&&Z.gitlab_user?` · @${String(Z.gitlab_user)}`:"",F==="bitbucket"&&Z.bitbucket_user?` · ${String(Z.bitbucket_user)}`:""]}):null,R.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):R.map(P=>{var G;return d.jsxs("article",{className:"pr","data-testid":`pr-${P.number}`,children:[d.jsxs("h3",{children:["#",P.number," ",P.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${P.draft?"":"open"}`,children:P.draft?"draft":P.state}),d.jsx("span",{children:P.author}),d.jsxs("span",{children:[P.source_branch," → ",P.target_branch]}),P.loadpath?d.jsxs("span",{className:`chip ${P.loadpath.level||""}`,"data-testid":`pr-loadpath-${P.number}`,children:[((G=P.loadpath.level)==null?void 0:G.toUpperCase())||"REVIEWED",P.loadpath.contract_break&&P.loadpath.contract_break!=="none"?` · ${P.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:P.url,target:"_blank",rel:"noreferrer",children:["Open on ",P.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${P.number}`,onClick:()=>void oo(P),children:"Review this PR"})]})]},`${P.provider}-${P.number}`)})]}),t==="settings"&&xe&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:lr,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Dl.map(P=>d.jsxs("button",{type:"button","data-theme":P.id,className:me===P.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${P.id}`,onClick:()=>kn(P.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:P.label}),d.jsx("div",{className:"group",children:P.group})]},P.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:gm(),onChange:P=>gN(P.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:Z.github_token_set?Z.github_user?`Signed in as @${String(Z.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:Z.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void sr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!Nt||!Z.github_oauth_ready,onClick:()=>void io(),children:Nt?"Waiting for GitHub…":"Sign in with GitHub"})})]}),Nt?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:Nt.user_code})," at GitHub if the browser did not fill it in."]}):null,Z.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(Z.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(Z.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:Z.gitlab_token_set?Z.gitlab_user?`Signed in as @${String(Z.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:Z.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void sr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:On||!Z.gitlab_oauth_ready,onClick:()=>void pi(),children:On?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(Z.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(Z.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:Z.bitbucket_token_set?Z.bitbucket_user?`Signed in as ${String(Z.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:Z.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void sr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:Ft||!Z.bitbucket_oauth_ready,onClick:()=>void Fr(),children:Ft?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),Z.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(Z.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(Z.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((ao=Z.ai)==null?void 0:ao.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((uo=Z.ai)==null?void 0:uo.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((co=Z.ai)==null?void 0:co.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(u0,{open:Te,actions:vi,onClose:()=>De(!1)}),je?d.jsx(SN,{initialPath:o,onClose:()=>Me(!1),onSelect:P=>{if(nt.current){w("Wait for the current job to finish before switching workspace.");return}Me(!1),Or(P)}}):null]})}function CN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:x,onOpenFile:m,onExport:y,history:v,diff:_,onReopen:N,onWaiver:j}){var w,C,k,b,A,z,V,Y,K,re,q,Z,te,R,U,H,W;const E=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),E.length?d.jsx("ul",{className:"reasons",children:E.map(M=>d.jsx("li",{children:M},M))}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Xo(M)},M)),(w=t.contract_break)!=null&&w.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&x(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>j(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(C=t.workspace)!=null&&C.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>m(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&x(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(xm,{cards:t.deepening}),(b=(k=t.contract_break)==null?void 0:k.reasons)!=null&&b.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),(z=(A=t.contract_break.sides)==null?void 0:A.rows)!=null&&z.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(V=t.auth)!=null&&V.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(Y=t.suggested_tests)==null?void 0:Y.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(K=t.trend)!=null&&K.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",Xu(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),v.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:v.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,v.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>N(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?Xu(M.created_at):""})]},M.id))]}):null,(q=(re=t.evolution)==null?void 0:re.notes)!=null&&q.length||(te=(Z=t.evolution)==null?void 0:Z.hotspots)!=null&&te.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((R=t.evolution)==null?void 0:R.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((U=t.evolution)==null?void 0:U.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:y,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(H=t.codeowners_reviewers)!=null&&H.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(W=t.knowledge_owners)!=null&&W.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function MN({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var m;const x=t.findings.filter(y=>!y.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${Xu(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(y=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y.name})," — ",(y.django_apps||[]).join(", ")||"no apps"," ·"," ",(y.owners||[]).join(", ")||"unowned"]},y.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(y=>d.jsx("div",{className:"muted",children:y},y))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:x.length})]}),x.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):x.map(y=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>y.node_id&&a(y.node_id),children:[d.jsx("span",{className:`chip ${y.severity}`,children:y.severity}),y.message]})},y.rule+y.message))]}),d.jsx(xm,{cards:t.deepening}),(m=c==null?void 0:c.points)!=null&&m.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(y=>d.jsx("i",{className:y.level||"",title:`${y.level} · ${y.findings} findings`,style:{height:`${8+Math.min(24,(y.findings||0)*4)}px`}},y.id||y.created_at))}),Object.entries(c.contexts).map(([y,v])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y})," — last ",((_=v[v.length-1])==null?void 0:_.findings)??0," findings"]},y)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(c0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((y,v)=>v[1]-y[1]).slice(0,12).map(([y,v])=>d.jsxs("tr",{children:[d.jsx("td",{children:to(y)}),d.jsx("td",{children:v})]},y))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function xm({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:d0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}vm(ym());s0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(EN,{})}));export{Hk as L,RN as a,PN as c,d as j,IN as l,L as r,to as t}; diff --git a/src/loadpath/static/index.html b/src/loadpath/static/index.html index 2a75dec..880ba77 100644 --- a/src/loadpath/static/index.html +++ b/src/loadpath/static/index.html @@ -17,8 +17,8 @@ - - + +
diff --git a/tests/e2e/test_ui_flows.py b/tests/e2e/test_ui_flows.py index 5a8374c..d44096d 100644 --- a/tests/e2e/test_ui_flows.py +++ b/tests/e2e/test_ui_flows.py @@ -483,3 +483,52 @@ def test_ui_architecture_brief_paints_before_graph(live_app, browser_page): page.get_by_test_id("graph-loading").wait_for(state="hidden", timeout=20_000) wait_visible_graph(page) + +@pytest.mark.playwright +def test_ui_whatif_banner_and_back_to_git_range(live_app, browser_page): + base_url, repo = live_app + page = browser_page + page.goto(base_url, wait_until="networkidle") + _wait_fonts(page) + _index_repo(page, repo) + page.get_by_test_id("btn-review").click() + page.get_by_test_id("brief").locator(".level").wait_for(timeout=30_000) + wait_visible_graph(page) + git_title = page.get_by_test_id("brief").locator(".level").inner_text() + assert "What if" not in git_title + + page.get_by_test_id("graph-search").fill("InvoiceSerializer") + page.get_by_test_id("graph-search-hits").wait_for(timeout=8_000) + page.get_by_test_id("graph-search-hits").locator("button").first.click() + inspector = page.get_by_test_id("graph-inspector") + inspector.wait_for(timeout=10_000) + hint = page.get_by_test_id("whatif-hint").inner_text().lower() + assert "no git range" in hint + assert "isolate" in hint + + with page.expect_response( + lambda r: "/api/whatif" in r.url and r.request.method == "POST", + timeout=30_000, + ) as pending: + page.get_by_test_id("btn-whatif").click() + if not pending.value.ok: + pytest.fail(f"whatif API {pending.value.status}: {pending.value.text()}") + + banner = page.get_by_test_id("whatif-banner") + banner.wait_for(timeout=15_000) + banner_text = banner.inner_text().lower() + assert "hypothetical" in banner_text + assert "base/head" in banner_text + page.get_by_test_id("whatif-chip").wait_for() + brief = page.get_by_test_id("brief").locator(".level").inner_text() + assert "What if" in brief + assert page.get_by_test_id("btn-post-comment").is_disabled() + assert page.get_by_test_id("btn-exit-whatif").inner_text().strip() == "Back to git range" + + page.get_by_test_id("btn-exit-whatif").click() + banner.wait_for(state="hidden", timeout=10_000) + restored = page.get_by_test_id("brief").locator(".level").inner_text() + assert restored == git_title + assert page.get_by_test_id("whatif-chip").count() == 0 + assert page.get_by_test_id("btn-post-comment").is_enabled() + diff --git a/ui/src/App.tsx b/ui/src/App.tsx index 9d40ca8..95de1f4 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -61,6 +61,7 @@ export function App() { const [base, setBase] = useState(localStorage.getItem("loadpath.base") || "HEAD~1"); const [head, setHead] = useState(localStorage.getItem("loadpath.head") || "HEAD"); const [review, setReview] = useState(null); + const [rangeReview, setRangeReview] = useState(null); const [architecture, setArchitecture] = useState(null); const [repos, setRepos] = useState([]); const [graphMode, setGraphMode] = useState("review"); @@ -238,8 +239,9 @@ export function App() { setSelectedId(pinnedId && next.nodes.some((n) => n.id === pinnedId) ? pinnedId : null); setIsolateSource(null); setReviewDiff(null); - if (next.id && !next.what_if) { - localStorage.setItem("loadpath.lastReviewId", next.id); + if (!next.what_if) { + setRangeReview(next); + if (next.id) localStorage.setItem("loadpath.lastReviewId", next.id); } }; @@ -448,6 +450,7 @@ export function App() { setError(""); setCopied(""); setReview(null); + setRangeReview(null); setArchitecture(null); setGraphMode("architecture"); persistRepo(next); @@ -543,6 +546,10 @@ export function App() { const postComment = async () => { if (busyRef.current) return; + if (review?.what_if) { + setError("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first."); + return; + } if (!review?.markdown || !scmRepo || !prNumber) { setError("Pick a pull request first (Pull requests tab), then post the brief."); return; @@ -631,6 +638,24 @@ export function App() { } }; + const exitWhatIf = () => { + if (rangeReview) { + rememberReview(rangeReview); + setGraphMode("review"); + setTab("review"); + setCopied("Restored the last git-range walk"); + return; + } + setReview(null); + setTourIndex(0); + setSelectedId(null); + setIsolateSource(null); + setReviewDiff(null); + setGraphMode("architecture"); + setTab("architecture"); + setCopied(""); + }; + const reviewRemotePr = async (item: PullRequest) => { if (busyRef.current) return; persistPr(item.provider, item.repo, String(item.number)); @@ -901,6 +926,16 @@ export function App() { const paletteActions: PaletteAction[] = [ { id: "review", group: "Run", label: "Review this range", hint: "⌘/Ctrl+Enter", run: () => void runReview() }, + ...(review?.what_if + ? [ + { + id: "exit-whatif", + group: "Review", + label: rangeReview ? "Back to git-range walk" : "Exit what-if walk", + run: exitWhatIf, + }, + ] + : []), { id: "index", group: "Run", label: "Index repository", run: () => void runIndex(true) }, { id: "watch", group: "Run", label: watchEnabled ? "Stop watching working tree" : "Watch working tree", run: () => { const next = !watchEnabled; @@ -1138,6 +1173,7 @@ export function App() { {review.confidence.level.toUpperCase()}
+ {review.what_if ? "what-if · " : ""} {review.confidence.covered_sinks}/{review.confidence.sinks} sinks
@@ -1192,6 +1228,18 @@ export function App() { Uncommitted files overlap this review: {(review.workspace.dirty_overlap || []).slice(0, 6).join(", ")}
) : null} + {review?.what_if ? ( +
+ + Hypothetical walk from{" "} + {review.node?.name || "this node"}. Loadpath ignored Base/Head and asked which sinks + would feel this node change — not a filter of the current map. + + +
+ ) : null} {workspaceLoading ? (
{busy || "Loading workspace…"} @@ -1835,6 +1883,11 @@ function ReviewBrief({ ))} ) : null} + {review.what_if ? ( + + what-if + + ) : null} {review.low_risk ? low-risk : null} {review.change_kinds.map((k) => ( @@ -2128,7 +2181,14 @@ function ReviewBrief({ -
diff --git a/ui/src/ImpactGraph.tsx b/ui/src/ImpactGraph.tsx index 1190039..3237c79 100644 --- a/ui/src/ImpactGraph.tsx +++ b/ui/src/ImpactGraph.tsx @@ -256,14 +256,33 @@ function GraphInspector({ empty="This node does not point at anything in this graph." onSelect={onSelect} /> + {onWhatIf ? ( +

+ {onIsolate + ? "Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map." + : "Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."} +

+ ) : null}
{onWhatIf ? ( - ) : null} {onIsolate ? ( - ) : null} diff --git a/ui/src/styles.css b/ui/src/styles.css index 7f57159..506b868 100644 --- a/ui/src/styles.css +++ b/ui/src/styles.css @@ -1371,6 +1371,24 @@ h2 { font-size: 13px; margin: 0; font-weight: 600; } } .banner.warn { border-color: var(--medium); color: var(--medium); } .banner.stale { border-color: var(--low); color: var(--low); } +.banner.whatif { + border-color: var(--accent); + align-items: center; +} +.banner.whatif .btn { + flex: 0 0 auto; + white-space: nowrap; +} +.chip.whatif { + color: var(--accent); + border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); +} +.whatif-hint { + margin: 10px 0 0; + font-size: 12px; + line-height: 1.4; + color: var(--muted); +} .banner .dismiss { background: transparent; border: 0; diff --git a/ui/src/types.ts b/ui/src/types.ts index a053930..7b0b0b5 100644 --- a/ui/src/types.ts +++ b/ui/src/types.ts @@ -123,6 +123,7 @@ export type Review = { suggested_tests?: { sink: string; type: string; kind: string; title: string; body: string }[]; trend?: { note: string; points: { id: string; created_at: string; level: string; sinks?: number }[] }; what_if?: boolean; + node?: GraphNode; evolution?: { hotspots: { path: string; commits: number; bus_factor: number; complexity?: number }[]; change_coupling: { a: string; b: string; together: number; cross_context?: boolean }[]; From 59232e683bda80966d13eee8ac6eeffd407945e3 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 16 Aug 2026 00:14:34 +0000 Subject: [PATCH 07/16] Keep the index progress bar moving only forward. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Scan, extract, boot, and stitch each used their own done/total, so the bar could hit 50–100% then drop to 0% when the next phase started. Map those phases onto one 0–100 scale, reset at the start of a run, and ignore a leftover done payload so the bar never rewinds. Co-authored-by: zord.lack.net --- src/loadpath/progress.py | 52 ++++++++++++++++ src/loadpath/server/app.py | 7 ++- ...BnhN-wUA.js => LayeredGraph3D-D_cvtTgT.js} | 2 +- .../{index-ChLCMR1f.js => index-B1t9Uvme.js} | 24 ++++---- src/loadpath/static/index.html | 2 +- tests/e2e/test_ui_flows.py | 61 +++++++++++++++++++ tests/unit/test_index_progress.py | 53 ++++++++++++++++ ui/src/App.tsx | 23 ++++--- ui/src/indexProgress.test.ts | 50 +++++++++++++++ ui/src/indexProgress.ts | 33 ++++++++++ ui/src/types.ts | 1 + 11 files changed, 285 insertions(+), 23 deletions(-) rename src/loadpath/static/assets/{LayeredGraph3D-BnhN-wUA.js => LayeredGraph3D-D_cvtTgT.js} (99%) rename src/loadpath/static/assets/{index-ChLCMR1f.js => index-B1t9Uvme.js} (65%) create mode 100644 ui/src/indexProgress.test.ts create mode 100644 ui/src/indexProgress.ts diff --git a/src/loadpath/progress.py b/src/loadpath/progress.py index 7c3a78f..2315698 100644 --- a/src/loadpath/progress.py +++ b/src/loadpath/progress.py @@ -10,18 +10,69 @@ _lock = threading.Lock() _STATE: dict[str, dict[str, Any]] = {} +# Overall bar spans. Keep in sync with ui/src/indexProgress.ts PHASE_SPANS. +PHASE_SPANS: dict[str, tuple[int, int]] = { + "scan": (0, 20), + "extract": (20, 88), + "boot": (88, 94), + "stitch": (94, 99), + "skipped": (100, 100), + "done": (100, 100), +} + +LIVE_PHASES = {"scan", "extract", "boot", "stitch"} + def progress_key(repo_root: Path | str) -> str: return str(Path(repo_root).expanduser().resolve()) +def overall_percent(event: dict[str, Any], *, floor: int = 0) -> int: + """Map a per-phase done/total event onto a monotonic 0–100 bar.""" + phase = str(event.get("phase") or "idle") + if phase in {"idle", ""}: + return max(0, min(100, floor)) + span = PHASE_SPANS.get(phase) + if span is None: + return max(0, min(100, floor)) + start, end = span + if start == end: + pct = end + else: + total = int(event.get("total") or 0) + done = int(event.get("done") or 0) + if total <= 0: + pct = start + else: + ratio = min(1.0, max(0.0, done / total)) + pct = int(round(start + (end - start) * ratio)) + return max(0, min(100, max(floor, pct))) + + def record_progress(repo_root: Path | str, event: dict[str, Any]) -> None: key = progress_key(repo_root) payload = {**event, "repo_path": key, "updated_at": time.time()} with _lock: + prev = _STATE.get(key) or {} + floor = int(prev.get("percent") or 0) + if payload.get("phase") == "scan" and int(payload.get("done") or 0) == 0: + floor = 0 + payload["percent"] = overall_percent(payload, floor=floor) _STATE[key] = payload +def begin_progress(repo_root: Path | str, message: str = "Indexing…") -> None: + record_progress( + repo_root, + { + "phase": "scan", + "done": 0, + "total": 0, + "message": message, + }, + ) + + def read_progress(repo_root: Path | str) -> dict[str, Any]: key = progress_key(repo_root) with _lock: @@ -31,6 +82,7 @@ def read_progress(repo_root: Path | str) -> dict[str, Any]: "phase": "idle", "done": 0, "total": 0, + "percent": 0, "message": "No index in progress", "repo_path": key, } diff --git a/src/loadpath/server/app.py b/src/loadpath/server/app.py index bedc968..36f660c 100644 --- a/src/loadpath/server/app.py +++ b/src/loadpath/server/app.py @@ -35,7 +35,7 @@ from loadpath.detect import detect_layout, write_draft_config from loadpath.graph.store import GraphStore from loadpath.index import default_db_path, index_repo -from loadpath.progress import progress_callback, read_progress +from loadpath.progress import begin_progress, progress_callback, read_progress from loadpath.providers.oauth import ( callback_html, disconnect_scm, @@ -379,6 +379,7 @@ def put_settings(body: SettingsUpdate) -> dict[str, Any]: @app.post("/api/index") def api_index(body: IndexRequest) -> dict[str, Any]: root = require_repo_path(body.repo_path) + begin_progress(root) store = index_repo( root, incremental=body.incremental, @@ -441,6 +442,8 @@ def api_repos() -> dict[str, Any]: @app.post("/api/review") def api_review(body: ReviewRequest) -> dict[str, Any]: root = require_repo_path(body.repo_path) + if body.reindex: + begin_progress(root) try: review = run_review( root, @@ -899,6 +902,8 @@ def api_pr_review(request: Request, body: PRReviewRequest) -> dict[str, Any]: except Exception as exc: # noqa: BLE001 raise HTTPException(400, str(exc)) from exc root = Path(prepared["repo_path"]) + if body.reindex: + begin_progress(root) try: review = run_review( root, diff --git a/src/loadpath/static/assets/LayeredGraph3D-BnhN-wUA.js b/src/loadpath/static/assets/LayeredGraph3D-D_cvtTgT.js similarity index 99% rename from src/loadpath/static/assets/LayeredGraph3D-BnhN-wUA.js rename to src/loadpath/static/assets/LayeredGraph3D-D_cvtTgT.js index 4137de1..379607c 100644 --- a/src/loadpath/static/assets/LayeredGraph3D-BnhN-wUA.js +++ b/src/loadpath/static/assets/LayeredGraph3D-D_cvtTgT.js @@ -1,4 +1,4 @@ -import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-ChLCMR1f.js";/** +import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-B1t9Uvme.js";/** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT diff --git a/src/loadpath/static/assets/index-ChLCMR1f.js b/src/loadpath/static/assets/index-B1t9Uvme.js similarity index 65% rename from src/loadpath/static/assets/index-ChLCMR1f.js rename to src/loadpath/static/assets/index-B1t9Uvme.js index 3df2524..ea04700 100644 --- a/src/loadpath/static/assets/index-ChLCMR1f.js +++ b/src/loadpath/static/assets/index-B1t9Uvme.js @@ -1,4 +1,4 @@ -(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function Sp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Pu={exports:{}},Vo={},Iu={exports:{}},Ie={};/** +(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function Sp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Pu={exports:{}},Wo={},Iu={exports:{}},Re={};/** * @license React * react.production.min.js * @@ -6,7 +6,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var qf;function Zy(){if(qf)return Ie;qf=1;var t=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),v=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),y=Symbol.iterator;function m(R){return R===null||typeof R!="object"?null:(R=y&&R[y]||R["@@iterator"],typeof R=="function"?R:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,b={};function E(R,A,ie){this.props=R,this.context=A,this.refs=b,this.updater=ie||_}E.prototype.isReactComponent={},E.prototype.setState=function(R,A){if(typeof R!="object"&&typeof R!="function"&&R!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,R,A,"setState")},E.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function N(){}N.prototype=E.prototype;function P(R,A,ie){this.props=R,this.context=A,this.refs=b,this.updater=ie||_}var w=P.prototype=new N;w.constructor=P,k(w,E.prototype),w.isPureReactComponent=!0;var j=Array.isArray,$=Object.prototype.hasOwnProperty,D={current:null},B={key:!0,ref:!0,__self:!0,__source:!0};function Y(R,A,ie){var oe,fe={},he=null,pe=null;if(A!=null)for(oe in A.ref!==void 0&&(pe=A.ref),A.key!==void 0&&(he=""+A.key),A)$.call(A,oe)&&!B.hasOwnProperty(oe)&&(fe[oe]=A[oe]);var Z=arguments.length-2;if(Z===1)fe.children=ie;else if(1>>1,A=M[R];if(0>>1;Ra(fe,F))hea(pe,fe)?(M[R]=pe,M[he]=F,R=he):(M[R]=fe,M[oe]=F,R=oe);else if(hea(pe,F))M[R]=pe,M[he]=F,R=he;else break e}}return z}function a(M,z){var F=M.sortIndex-z.sortIndex;return F!==0?F:M.id-z.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,h=c.now();t.unstable_now=function(){return c.now()-h}}var p=[],v=[],x=1,y=null,m=3,_=!1,k=!1,b=!1,E=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,P=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(M){for(var z=o(v);z!==null;){if(z.callback===null)s(v);else if(z.startTime<=M)s(v),z.sortIndex=z.expirationTime,r(p,z);else break;z=o(v)}}function j(M){if(b=!1,w(M),!k)if(o(p)!==null)k=!0,W($);else{var z=o(v);z!==null&&U(j,z.startTime-M)}}function $(M,z){k=!1,b&&(b=!1,N(Y),Y=-1),_=!0;var F=m;try{for(w(z),y=o(p);y!==null&&(!(y.expirationTime>z)||M&&!ee());){var R=y.callback;if(typeof R=="function"){y.callback=null,m=y.priorityLevel;var A=R(y.expirationTime<=z);z=t.unstable_now(),typeof A=="function"?y.callback=A:y===o(p)&&s(p),w(z)}else s(p);y=o(p)}if(y!==null)var ie=!0;else{var oe=o(v);oe!==null&&U(j,oe.startTime-z),ie=!1}return ie}finally{y=null,m=F,_=!1}}var D=!1,B=null,Y=-1,Q=5,ne=-1;function ee(){return!(t.unstable_now()-neM||125R?(M.sortIndex=F,r(v,M),o(p)===null&&M===o(v)&&(b?(N(Y),Y=-1):b=!0,U(j,F-R))):(M.sortIndex=A,r(p,M),k||_||(k=!0,W($))),M},t.unstable_shouldYield=ee,t.unstable_wrapCallback=function(M){var z=m;return function(){var F=m;m=z;try{return M.apply(this,arguments)}finally{m=F}}}})(Lu)),Lu}var eh;function r0(){return eh||(eh=1,Tu.exports=n0()),Tu.exports}/** + */var Jf;function n0(){return Jf||(Jf=1,(function(t){function r(M,D){var F=M.length;M.push(D);e:for(;0>>1,A=M[R];if(0>>1;Ra(fe,F))hea(pe,fe)?(M[R]=pe,M[he]=F,R=he):(M[R]=fe,M[oe]=F,R=oe);else if(hea(pe,F))M[R]=pe,M[he]=F,R=he;else break e}}return D}function a(M,D){var F=M.sortIndex-D.sortIndex;return F!==0?F:M.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,h=c.now();t.unstable_now=function(){return c.now()-h}}var p=[],v=[],x=1,y=null,m=3,_=!1,k=!1,b=!1,E=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,P=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(M){for(var D=o(v);D!==null;){if(D.callback===null)s(v);else if(D.startTime<=M)s(v),D.sortIndex=D.expirationTime,r(p,D);else break;D=o(v)}}function j(M){if(b=!1,w(M),!k)if(o(p)!==null)k=!0,W($);else{var D=o(v);D!==null&&U(j,D.startTime-M)}}function $(M,D){k=!1,b&&(b=!1,N(Y),Y=-1),_=!0;var F=m;try{for(w(D),y=o(p);y!==null&&(!(y.expirationTime>D)||M&&!ee());){var R=y.callback;if(typeof R=="function"){y.callback=null,m=y.priorityLevel;var A=R(y.expirationTime<=D);D=t.unstable_now(),typeof A=="function"?y.callback=A:y===o(p)&&s(p),w(D)}else s(p);y=o(p)}if(y!==null)var ie=!0;else{var oe=o(v);oe!==null&&U(j,oe.startTime-D),ie=!1}return ie}finally{y=null,m=F,_=!1}}var z=!1,B=null,Y=-1,Q=5,ne=-1;function ee(){return!(t.unstable_now()-neM||125R?(M.sortIndex=F,r(v,M),o(p)===null&&M===o(v)&&(b?(N(Y),Y=-1):b=!0,U(j,F-R))):(M.sortIndex=A,r(p,M),k||_||(k=!0,W($))),M},t.unstable_shouldYield=ee,t.unstable_wrapCallback=function(M){var D=m;return function(){var F=m;m=D;try{return M.apply(this,arguments)}finally{m=F}}}})(Lu)),Lu}var eh;function r0(){return eh||(eh=1,Tu.exports=n0()),Tu.exports}/** * @license React * react-dom.production.min.js * @@ -30,14 +30,14 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var th;function i0(){if(th)return zt;th=1;var t=ls(),r=r0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,v=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,x={},y={};function m(e){return p.call(y,e)?!0:p.call(x,e)?!1:v.test(e)?y[e]=!0:(x[e]=!0,!1)}function _(e,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function k(e,n,i,l){if(n===null||typeof n>"u"||_(e,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function b(e,n,i,l,f,g,S){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=f,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=g,this.removeEmptyString=S}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){E[e]=new b(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];E[n]=new b(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){E[e]=new b(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){E[e]=new b(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){E[e]=new b(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){E[e]=new b(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){E[e]=new b(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){E[e]=new b(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){E[e]=new b(e,5,!1,e.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function P(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(N,P);E[n]=new b(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(N,P);E[n]=new b(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(N,P);E[n]=new b(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){E[e]=new b(e,1,!1,e.toLowerCase(),null,!1,!1)}),E.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){E[e]=new b(e,1,!1,e.toLowerCase(),null,!0,!0)});function w(e,n,i,l){var f=E.hasOwnProperty(n)?E[n]:null;(f!==null?f.type!==0:l||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,v=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,x={},y={};function m(e){return p.call(y,e)?!0:p.call(x,e)?!1:v.test(e)?y[e]=!0:(x[e]=!0,!1)}function _(e,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function k(e,n,i,l){if(n===null||typeof n>"u"||_(e,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function b(e,n,i,l,f,g,S){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=f,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=g,this.removeEmptyString=S}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){E[e]=new b(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];E[n]=new b(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){E[e]=new b(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){E[e]=new b(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){E[e]=new b(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){E[e]=new b(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){E[e]=new b(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){E[e]=new b(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){E[e]=new b(e,5,!1,e.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function P(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(N,P);E[n]=new b(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(N,P);E[n]=new b(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(N,P);E[n]=new b(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){E[e]=new b(e,1,!1,e.toLowerCase(),null,!1,!1)}),E.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){E[e]=new b(e,1,!1,e.toLowerCase(),null,!0,!0)});function w(e,n,i,l){var f=E.hasOwnProperty(n)?E[n]:null;(f!==null?f.type!==0:l||!(2T||f[S]!==g[T]){var O=` -`+f[S].replace(" at new "," at ");return e.displayName&&O.includes("")&&(O=O.replace("",e.displayName)),O}while(1<=S&&0<=T);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?A(e):""}function fe(e){switch(e.tag){case 5:return A(e.type);case 16:return A("Lazy");case 13:return A("Suspense");case 19:return A("SuspenseList");case 0:case 2:case 15:return e=oe(e.type,!1),e;case 11:return e=oe(e.type.render,!1),e;case 1:return e=oe(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case B:return"Fragment";case D:return"Portal";case Q:return"Profiler";case Y:return"StrictMode";case q:return"Suspense";case C:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ee:return(e.displayName||"Context")+".Consumer";case ne:return(e._context.displayName||"Context")+".Provider";case te:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case W:n=e._payload,e=e._init;try{return he(e(n))}catch{}}return null}function pe(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===Y?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Z(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=se(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function Ne(e){e._valueTracker||(e._valueTracker=me(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=se(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function re(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function je(e,n){var i=n.checked;return F({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Z(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Re(e,n){n=n.checked,n!=null&&w(e,"checked",n,!1)}function Ae(e,n){Re(e,n);var i=Z(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?lt(e,n.type,i):n.hasOwnProperty("defaultValue")&<(e,n.type,Z(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function st(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function lt(e,n,i){(n!=="number"||re(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var at=Array.isArray;function Ye(e,n,i,l){if(e=e.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=Je.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ot(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var xn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ro=["Webkit","ms","Moz","O"];Object.keys(xn).forEach(function(e){ro.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),xn[n]=xn[e]})});function $n(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||xn.hasOwnProperty(e)&&xn[e]?(""+n).trim():n+"px"}function yi(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=$n(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,f):e[i]=f}}var ir=F({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function $r(e,n){if(n){if(ir[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function zn(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var zr=null;function or(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var sr=null,Ft=null,ct=null;function Dn(e){if(e=Co(e)){if(typeof sr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=Cs(n),sr(e.stateNode,e.type,n))}}function On(e){Ft?ct?ct.push(e):ct=[e]:Ft=e}function wn(){if(Ft){var e=Ft,n=ct;if(ct=Ft=null,Dn(e),n)for(e=0;e>>=0,e===0?32:31-(lo(e)/Ur|0)|0}var Wn=64,Un=4194304;function bn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Bt(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,f=e.suspendedLanes,g=e.pingedLanes,S=i&268435455;if(S!==0){var T=S&~f;T!==0?l=bn(T):(g&=S,g!==0&&(l=bn(g)))}else S=i&~f,S!==0?l=bn(S):g!==0&&(l=bn(g));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,g=n&-n,f>=g||f===16&&(g&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function En(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Et(n),e[n]=i}function ao(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=xo),Hc=" ",Bc=!1;function Vc(e,n){switch(e){case"keyup":return Ym.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ji=!1;function qm(e,n){switch(e){case"compositionend":return Wc(n);case"keypress":return n.which!==32?null:(Bc=!0,Hc);case"textInput":return e=n.data,e===Hc&&Bc?null:e;default:return null}}function Km(e,n){if(ji)return e==="compositionend"||!ca&&Vc(e,n)?(e=Ac(),ys=ia=gr=null,ji=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Qc(i)}}function Jc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Jc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function ed(){for(var e=window,n=re();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=re(e.document)}return n}function ha(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function oy(e){var n=ed(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Jc(i.ownerDocument.documentElement,i)){if(l!==null&&ha(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var f=i.textContent.length,g=Math.min(l.start,f);l=l.end===void 0?g:Math.min(l.end,f),!e.extend&&g>l&&(f=l,l=g,g=f),f=Zc(i,g);var S=Zc(i,l);f&&S&&(e.rangeCount!==1||e.anchorNode!==f.node||e.anchorOffset!==f.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),e.removeAllRanges(),g>l?(e.addRange(n),e.extend(S.node,S.offset)):(n.setEnd(S.node,S.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,bi=null,pa=null,ko=null,ga=!1;function td(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;ga||bi==null||bi!==re(l)||(l=bi,"selectionStart"in l&&ha(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),ko&&So(ko,l)||(ko=l,l=js(pa,"onSelect"),0Ii||(e.current=Ea[Ii],Ea[Ii]=null,Ii--)}function Be(e,n){Ii++,Ea[Ii]=e.current,e.current=n}var xr={},St=vr(xr),Rt=vr(!1),Kr=xr;function Ri(e,n){var i=e.type.contextTypes;if(!i)return xr;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in i)f[g]=n[g];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=f),f}function Tt(e){return e=e.childContextTypes,e!=null}function Ms(){Ue(Rt),Ue(St)}function md(e,n,i){if(St.current!==xr)throw Error(o(168));Be(St,n),Be(Rt,i)}function yd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,pe(e)||"Unknown",f));return F({},i,l)}function Ps(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||xr,Kr=St.current,Be(St,e),Be(Rt,Rt.current),!0}function vd(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=yd(e,n,Kr),l.__reactInternalMemoizedMergedChildContext=e,Ue(Rt),Ue(St),Be(St,e)):Ue(Rt),Be(Rt,i)}var Xn=null,Is=!1,Ca=!1;function xd(e){Xn===null?Xn=[e]:Xn.push(e)}function yy(e){Is=!0,xd(e)}function wr(){if(!Ca&&Xn!==null){Ca=!0;var e=0,n=Fe;try{var i=Xn;for(Fe=1;e>=S,f-=S,qn=1<<32-Et(n)+f|i<Ce?(pt=Ee,Ee=null):pt=Ee.sibling;var Oe=le(X,Ee,K[Ce],ce);if(Oe===null){Ee===null&&(Ee=pt);break}e&&Ee&&Oe.alternate===null&&n(X,Ee),H=g(Oe,H,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe,Ee=pt}if(Ce===K.length)return i(X,Ee),Xe&&Zr(X,Ce),_e;if(Ee===null){for(;CeCe?(pt=Ee,Ee=null):pt=Ee.sibling;var Mr=le(X,Ee,Oe.value,ce);if(Mr===null){Ee===null&&(Ee=pt);break}e&&Ee&&Mr.alternate===null&&n(X,Ee),H=g(Mr,H,Ce),be===null?_e=Mr:be.sibling=Mr,be=Mr,Ee=pt}if(Oe.done)return i(X,Ee),Xe&&Zr(X,Ce),_e;if(Ee===null){for(;!Oe.done;Ce++,Oe=K.next())Oe=ue(X,Oe.value,ce),Oe!==null&&(H=g(Oe,H,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return Xe&&Zr(X,Ce),_e}for(Ee=l(X,Ee);!Oe.done;Ce++,Oe=K.next())Oe=ge(Ee,X,Ce,Oe.value,ce),Oe!==null&&(e&&Oe.alternate!==null&&Ee.delete(Oe.key===null?Ce:Oe.key),H=g(Oe,H,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return e&&Ee.forEach(function(Qy){return n(X,Qy)}),Xe&&Zr(X,Ce),_e}function et(X,H,K,ce){if(typeof K=="object"&&K!==null&&K.type===B&&K.key===null&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case $:e:{for(var _e=K.key,be=H;be!==null;){if(be.key===_e){if(_e=K.type,_e===B){if(be.tag===7){i(X,be.sibling),H=f(be,K.props.children),H.return=X,X=H;break e}}else if(be.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===W&&jd(_e)===be.type){i(X,be.sibling),H=f(be,K.props),H.ref=Mo(X,be,K),H.return=X,X=H;break e}i(X,be);break}else n(X,be);be=be.sibling}K.type===B?(H=si(K.props.children,X.mode,ce,K.key),H.return=X,X=H):(ce=ol(K.type,K.key,K.props,null,X.mode,ce),ce.ref=Mo(X,H,K),ce.return=X,X=ce)}return S(X);case D:e:{for(be=K.key;H!==null;){if(H.key===be)if(H.tag===4&&H.stateNode.containerInfo===K.containerInfo&&H.stateNode.implementation===K.implementation){i(X,H.sibling),H=f(H,K.children||[]),H.return=X,X=H;break e}else{i(X,H);break}else n(X,H);H=H.sibling}H=ju(K,X.mode,ce),H.return=X,X=H}return S(X);case W:return be=K._init,et(X,H,be(K._payload),ce)}if(at(K))return xe(X,H,K,ce);if(z(K))return we(X,H,K,ce);As(X,K)}return typeof K=="string"&&K!==""||typeof K=="number"?(K=""+K,H!==null&&H.tag===6?(i(X,H.sibling),H=f(H,K),H.return=X,X=H):(i(X,H),H=Nu(K,X.mode,ce),H.return=X,X=H),S(X)):i(X,H)}return et}var $i=bd(!0),Ed=bd(!1),$s=vr(null),zs=null,zi=null,La=null;function Aa(){La=zi=zs=null}function $a(e){var n=$s.current;Ue($s),e._currentValue=n}function za(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function Di(e,n){zs=e,La=zi=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Lt=!0),e.firstContext=null)}function Zt(e){var n=e._currentValue;if(La!==e)if(e={context:e,memoizedValue:n,next:null},zi===null){if(zs===null)throw Error(o(308));zi=e,zs.dependencies={lanes:0,firstContext:e}}else zi=zi.next=e;return n}var Jr=null;function Da(e){Jr===null?Jr=[e]:Jr.push(e)}function Cd(e,n,i,l){var f=n.interleaved;return f===null?(i.next=i,Da(n)):(i.next=f.next,f.next=i),n.interleaved=i,Qn(e,l)}function Qn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var _r=!1;function Oa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Md(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Zn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Sr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,($e&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,Qn(e,i)}return f=l.interleaved,f===null?(n.next=n,Da(l)):(n.next=f.next,f.next=n),l.interleaved=n,Qn(e,i)}function Ds(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,hr(e,i)}}function Pd(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var S={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?f=g=S:g=g.next=S,i=i.next}while(i!==null);g===null?f=g=n:g=g.next=n}else f=g=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function Os(e,n,i,l){var f=e.updateQueue;_r=!1;var g=f.firstBaseUpdate,S=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,J=O.next;O.next=null,S===null?g=J:S.next=J,S=O;var ae=e.alternate;ae!==null&&(ae=ae.updateQueue,T=ae.lastBaseUpdate,T!==S&&(T===null?ae.firstBaseUpdate=J:T.next=J,ae.lastBaseUpdate=O))}if(g!==null){var ue=f.baseState;S=0,ae=J=O=null,T=g;do{var le=T.lane,ge=T.eventTime;if((l&le)===le){ae!==null&&(ae=ae.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var xe=e,we=T;switch(le=n,ge=i,we.tag){case 1:if(xe=we.payload,typeof xe=="function"){ue=xe.call(ge,ue,le);break e}ue=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=we.payload,le=typeof xe=="function"?xe.call(ge,ue,le):xe,le==null)break e;ue=F({},ue,le);break e;case 2:_r=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,le=f.effects,le===null?f.effects=[T]:le.push(T))}else ge={eventTime:ge,lane:le,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ae===null?(J=ae=ge,O=ue):ae=ae.next=ge,S|=le;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;le=T,T=le.next,le.next=null,f.lastBaseUpdate=le,f.shared.pending=null}}while(!0);if(ae===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=J,f.lastBaseUpdate=ae,n=f.shared.interleaved,n!==null){f=n;do S|=f.lane,f=f.next;while(f!==n)}else g===null&&(f.shared.lanes=0);ni|=S,e.lanes=S,e.memoizedState=ue}}function Id(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=Wa.transition;Wa.transition={};try{e(!1),n()}finally{Fe=i,Wa.transition=l}}function Kd(){return Jt().memoizedState}function _y(e,n,i){var l=br(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},Qd(e))Zd(n,i);else if(i=Cd(e,n,i,l),i!==null){var f=Mt();dn(i,e,l,f),Jd(i,n,l)}}function Sy(e,n,i){var l=br(e),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(Qd(e))Zd(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,T=g(S,i);if(f.hasEagerState=!0,f.eagerState=T,sn(T,S)){var O=n.interleaved;O===null?(f.next=f,Da(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=Cd(e,n,f,l),i!==null&&(f=Mt(),dn(i,e,l,f),Jd(i,n,l))}}function Qd(e){var n=e.alternate;return e===Ke||n!==null&&n===Ke}function Zd(e,n){To=Bs=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Jd(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,hr(e,i)}}var Us={readContext:Zt,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},ky={readContext:Zt,useCallback:function(e,n){return Pn().memoizedState=[e,n===void 0?null:n],e},useContext:Zt,useEffect:Bd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Vs(4194308,4,Ud.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Vs(4194308,4,e,n)},useInsertionEffect:function(e,n){return Vs(4,2,e,n)},useMemo:function(e,n){var i=Pn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=Pn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=_y.bind(null,Ke,e),[l.memoizedState,e]},useRef:function(e){var n=Pn();return e={current:e},n.memoizedState=e},useState:Fd,useDebugValue:Qa,useDeferredValue:function(e){return Pn().memoizedState=e},useTransition:function(){var e=Fd(!1),n=e[0];return e=wy.bind(null,e[1]),Pn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=Ke,f=Pn();if(Xe){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ht===null)throw Error(o(349));(ti&30)!==0||Ad(l,n,i)}f.memoizedState=i;var g={value:i,getSnapshot:n};return f.queue=g,Bd(zd.bind(null,l,g,e),[e]),l.flags|=2048,$o(9,$d.bind(null,l,g,i,n),void 0,null),i},useId:function(){var e=Pn(),n=ht.identifierPrefix;if(Xe){var i=Kn,l=qn;i=(l&~(1<<32-Et(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=Lo++,0")&&(O=O.replace("",e.displayName)),O}while(1<=S&&0<=T);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?A(e):""}function fe(e){switch(e.tag){case 5:return A(e.type);case 16:return A("Lazy");case 13:return A("Suspense");case 19:return A("SuspenseList");case 0:case 2:case 15:return e=oe(e.type,!1),e;case 11:return e=oe(e.type.render,!1),e;case 1:return e=oe(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case B:return"Fragment";case z:return"Portal";case Q:return"Profiler";case Y:return"StrictMode";case q:return"Suspense";case C:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ee:return(e.displayName||"Context")+".Consumer";case ne:return(e._context.displayName||"Context")+".Provider";case te:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case W:n=e._payload,e=e._init;try{return he(e(n))}catch{}}return null}function pe(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===Y?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Z(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=se(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function ke(e){e._valueTracker||(e._valueTracker=me(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=se(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function re(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return F({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Z(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Te(e,n){n=n.checked,n!=null&&w(e,"checked",n,!1)}function $e(e,n){Te(e,n);var i=Z(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?lt(e,n.type,i):n.hasOwnProperty("defaultValue")&<(e,n.type,Z(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function st(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function lt(e,n,i){(n!=="number"||re(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var at=Array.isArray;function Ye(e,n,i,l){if(e=e.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=Je.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ot(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var xn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},io=["Webkit","ms","Moz","O"];Object.keys(xn).forEach(function(e){io.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),xn[n]=xn[e]})});function $n(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||xn.hasOwnProperty(e)&&xn[e]?(""+n).trim():n+"px"}function vi(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=$n(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,f):e[i]=f}}var or=F({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function $r(e,n){if(n){if(or[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function zn(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var zr=null;function sr(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var lr=null,Ft=null,ct=null;function Dn(e){if(e=Mo(e)){if(typeof lr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=Ms(n),lr(e.stateNode,e.type,n))}}function On(e){Ft?ct?ct.push(e):ct=[e]:Ft=e}function wn(){if(Ft){var e=Ft,n=ct;if(ct=Ft=null,Dn(e),n)for(e=0;e>>=0,e===0?32:31-(ao(e)/Ur|0)|0}var Wn=64,Un=4194304;function bn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Bt(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,f=e.suspendedLanes,g=e.pingedLanes,S=i&268435455;if(S!==0){var T=S&~f;T!==0?l=bn(T):(g&=S,g!==0&&(l=bn(g)))}else S=i&~f,S!==0?l=bn(S):g!==0&&(l=bn(g));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,g=n&-n,f>=g||f===16&&(g&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function En(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Et(n),e[n]=i}function uo(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=wo),Hc=" ",Bc=!1;function Vc(e,n){switch(e){case"keyup":return Ym.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var bi=!1;function qm(e,n){switch(e){case"compositionend":return Wc(n);case"keypress":return n.which!==32?null:(Bc=!0,Hc);case"textInput":return e=n.data,e===Hc&&Bc?null:e;default:return null}}function Km(e,n){if(bi)return e==="compositionend"||!ca&&Vc(e,n)?(e=Ac(),vs=ia=gr=null,bi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Qc(i)}}function Jc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Jc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function ed(){for(var e=window,n=re();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=re(e.document)}return n}function ha(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function oy(e){var n=ed(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Jc(i.ownerDocument.documentElement,i)){if(l!==null&&ha(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var f=i.textContent.length,g=Math.min(l.start,f);l=l.end===void 0?g:Math.min(l.end,f),!e.extend&&g>l&&(f=l,l=g,g=f),f=Zc(i,g);var S=Zc(i,l);f&&S&&(e.rangeCount!==1||e.anchorNode!==f.node||e.anchorOffset!==f.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),e.removeAllRanges(),g>l?(e.addRange(n),e.extend(S.node,S.offset)):(n.setEnd(S.node,S.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,Ei=null,pa=null,No=null,ga=!1;function td(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;ga||Ei==null||Ei!==re(l)||(l=Ei,"selectionStart"in l&&ha(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),No&&ko(No,l)||(No=l,l=bs(pa,"onSelect"),0Ri||(e.current=Ea[Ri],Ea[Ri]=null,Ri--)}function Be(e,n){Ri++,Ea[Ri]=e.current,e.current=n}var xr={},St=vr(xr),Rt=vr(!1),Qr=xr;function Ti(e,n){var i=e.type.contextTypes;if(!i)return xr;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in i)f[g]=n[g];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=f),f}function Tt(e){return e=e.childContextTypes,e!=null}function Ps(){Ue(Rt),Ue(St)}function md(e,n,i){if(St.current!==xr)throw Error(o(168));Be(St,n),Be(Rt,i)}function yd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,pe(e)||"Unknown",f));return F({},i,l)}function Is(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||xr,Qr=St.current,Be(St,e),Be(Rt,Rt.current),!0}function vd(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=yd(e,n,Qr),l.__reactInternalMemoizedMergedChildContext=e,Ue(Rt),Ue(St),Be(St,e)):Ue(Rt),Be(Rt,i)}var qn=null,Rs=!1,Ca=!1;function xd(e){qn===null?qn=[e]:qn.push(e)}function yy(e){Rs=!0,xd(e)}function wr(){if(!Ca&&qn!==null){Ca=!0;var e=0,n=Fe;try{var i=qn;for(Fe=1;e>=S,f-=S,Kn=1<<32-Et(n)+f|i<Ce?(pt=Ee,Ee=null):pt=Ee.sibling;var Oe=le(X,Ee,K[Ce],de);if(Oe===null){Ee===null&&(Ee=pt);break}e&&Ee&&Oe.alternate===null&&n(X,Ee),H=g(Oe,H,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe,Ee=pt}if(Ce===K.length)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;CeCe?(pt=Ee,Ee=null):pt=Ee.sibling;var Mr=le(X,Ee,Oe.value,de);if(Mr===null){Ee===null&&(Ee=pt);break}e&&Ee&&Mr.alternate===null&&n(X,Ee),H=g(Mr,H,Ce),be===null?_e=Mr:be.sibling=Mr,be=Mr,Ee=pt}if(Oe.done)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;!Oe.done;Ce++,Oe=K.next())Oe=ue(X,Oe.value,de),Oe!==null&&(H=g(Oe,H,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return Xe&&Jr(X,Ce),_e}for(Ee=l(X,Ee);!Oe.done;Ce++,Oe=K.next())Oe=ge(Ee,X,Ce,Oe.value,de),Oe!==null&&(e&&Oe.alternate!==null&&Ee.delete(Oe.key===null?Ce:Oe.key),H=g(Oe,H,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return e&&Ee.forEach(function(Qy){return n(X,Qy)}),Xe&&Jr(X,Ce),_e}function et(X,H,K,de){if(typeof K=="object"&&K!==null&&K.type===B&&K.key===null&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case $:e:{for(var _e=K.key,be=H;be!==null;){if(be.key===_e){if(_e=K.type,_e===B){if(be.tag===7){i(X,be.sibling),H=f(be,K.props.children),H.return=X,X=H;break e}}else if(be.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===W&&jd(_e)===be.type){i(X,be.sibling),H=f(be,K.props),H.ref=Po(X,be,K),H.return=X,X=H;break e}i(X,be);break}else n(X,be);be=be.sibling}K.type===B?(H=li(K.props.children,X.mode,de,K.key),H.return=X,X=H):(de=sl(K.type,K.key,K.props,null,X.mode,de),de.ref=Po(X,H,K),de.return=X,X=de)}return S(X);case z:e:{for(be=K.key;H!==null;){if(H.key===be)if(H.tag===4&&H.stateNode.containerInfo===K.containerInfo&&H.stateNode.implementation===K.implementation){i(X,H.sibling),H=f(H,K.children||[]),H.return=X,X=H;break e}else{i(X,H);break}else n(X,H);H=H.sibling}H=ju(K,X.mode,de),H.return=X,X=H}return S(X);case W:return be=K._init,et(X,H,be(K._payload),de)}if(at(K))return xe(X,H,K,de);if(D(K))return we(X,H,K,de);$s(X,K)}return typeof K=="string"&&K!==""||typeof K=="number"?(K=""+K,H!==null&&H.tag===6?(i(X,H.sibling),H=f(H,K),H.return=X,X=H):(i(X,H),H=Nu(K,X.mode,de),H.return=X,X=H),S(X)):i(X,H)}return et}var zi=bd(!0),Ed=bd(!1),zs=vr(null),Ds=null,Di=null,La=null;function Aa(){La=Di=Ds=null}function $a(e){var n=zs.current;Ue(zs),e._currentValue=n}function za(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function Oi(e,n){Ds=e,La=Di=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Lt=!0),e.firstContext=null)}function Zt(e){var n=e._currentValue;if(La!==e)if(e={context:e,memoizedValue:n,next:null},Di===null){if(Ds===null)throw Error(o(308));Di=e,Ds.dependencies={lanes:0,firstContext:e}}else Di=Di.next=e;return n}var ei=null;function Da(e){ei===null?ei=[e]:ei.push(e)}function Cd(e,n,i,l){var f=n.interleaved;return f===null?(i.next=i,Da(n)):(i.next=f.next,f.next=i),n.interleaved=i,Zn(e,l)}function Zn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var _r=!1;function Oa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Md(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Jn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Sr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(ze&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,Zn(e,i)}return f=l.interleaved,f===null?(n.next=n,Da(l)):(n.next=f.next,f.next=n),l.interleaved=n,Zn(e,i)}function Os(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}function Pd(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var S={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?f=g=S:g=g.next=S,i=i.next}while(i!==null);g===null?f=g=n:g=g.next=n}else f=g=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function Fs(e,n,i,l){var f=e.updateQueue;_r=!1;var g=f.firstBaseUpdate,S=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,J=O.next;O.next=null,S===null?g=J:S.next=J,S=O;var ae=e.alternate;ae!==null&&(ae=ae.updateQueue,T=ae.lastBaseUpdate,T!==S&&(T===null?ae.firstBaseUpdate=J:T.next=J,ae.lastBaseUpdate=O))}if(g!==null){var ue=f.baseState;S=0,ae=J=O=null,T=g;do{var le=T.lane,ge=T.eventTime;if((l&le)===le){ae!==null&&(ae=ae.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var xe=e,we=T;switch(le=n,ge=i,we.tag){case 1:if(xe=we.payload,typeof xe=="function"){ue=xe.call(ge,ue,le);break e}ue=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=we.payload,le=typeof xe=="function"?xe.call(ge,ue,le):xe,le==null)break e;ue=F({},ue,le);break e;case 2:_r=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,le=f.effects,le===null?f.effects=[T]:le.push(T))}else ge={eventTime:ge,lane:le,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ae===null?(J=ae=ge,O=ue):ae=ae.next=ge,S|=le;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;le=T,T=le.next,le.next=null,f.lastBaseUpdate=le,f.shared.pending=null}}while(!0);if(ae===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=J,f.lastBaseUpdate=ae,n=f.shared.interleaved,n!==null){f=n;do S|=f.lane,f=f.next;while(f!==n)}else g===null&&(f.shared.lanes=0);ri|=S,e.lanes=S,e.memoizedState=ue}}function Id(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=Wa.transition;Wa.transition={};try{e(!1),n()}finally{Fe=i,Wa.transition=l}}function Kd(){return Jt().memoizedState}function _y(e,n,i){var l=br(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},Qd(e))Zd(n,i);else if(i=Cd(e,n,i,l),i!==null){var f=Mt();dn(i,e,l,f),Jd(i,n,l)}}function Sy(e,n,i){var l=br(e),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(Qd(e))Zd(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,T=g(S,i);if(f.hasEagerState=!0,f.eagerState=T,sn(T,S)){var O=n.interleaved;O===null?(f.next=f,Da(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=Cd(e,n,f,l),i!==null&&(f=Mt(),dn(i,e,l,f),Jd(i,n,l))}}function Qd(e){var n=e.alternate;return e===Ke||n!==null&&n===Ke}function Zd(e,n){Lo=Vs=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Jd(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}var Gs={readContext:Zt,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},ky={readContext:Zt,useCallback:function(e,n){return Pn().memoizedState=[e,n===void 0?null:n],e},useContext:Zt,useEffect:Bd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Ws(4194308,4,Ud.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Ws(4194308,4,e,n)},useInsertionEffect:function(e,n){return Ws(4,2,e,n)},useMemo:function(e,n){var i=Pn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=Pn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=_y.bind(null,Ke,e),[l.memoizedState,e]},useRef:function(e){var n=Pn();return e={current:e},n.memoizedState=e},useState:Fd,useDebugValue:Qa,useDeferredValue:function(e){return Pn().memoizedState=e},useTransition:function(){var e=Fd(!1),n=e[0];return e=wy.bind(null,e[1]),Pn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=Ke,f=Pn();if(Xe){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ht===null)throw Error(o(349));(ni&30)!==0||Ad(l,n,i)}f.memoizedState=i;var g={value:i,getSnapshot:n};return f.queue=g,Bd(zd.bind(null,l,g,e),[e]),l.flags|=2048,zo(9,$d.bind(null,l,g,i,n),void 0,null),i},useId:function(){var e=Pn(),n=ht.identifierPrefix;if(Xe){var i=Qn,l=Kn;i=(l&~(1<<32-Et(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=Ao++,0<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=S.createElement(i,{is:l.is}):(e=S.createElement(i),i==="select"&&(S=e,l.multiple?S.multiple=!0:l.size&&(S.size=l.size))):e=S.createElementNS(e,i),e[Cn]=n,e[Eo]=l,wf(e,n,!1,!1),n.stateNode=e;e:{switch(S=zn(i,l),i){case"dialog":We("cancel",e),We("close",e),f=l;break;case"iframe":case"object":case"embed":We("load",e),f=l;break;case"video":case"audio":for(f=0;fVi&&(n.flags|=128,l=!0,zo(g,!1),n.lanes=4194304)}else{if(!l)if(e=Fs(S),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),zo(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Xe)return Nt(n),null}else 2*Ve()-g.renderingStartTime>Vi&&i!==1073741824&&(n.flags|=128,l=!0,zo(g,!1),n.lanes=4194304);g.isBackwards?(S.sibling=n.child,n.child=S):(i=g.last,i!==null?i.sibling=S:n.child=S,g.last=S)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(Nt(n),null);case 22:case 23:return _u(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Gt&1073741824)!==0&&(Nt(n),n.subtreeFlags&6&&(n.flags|=8192)):Nt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function Iy(e,n){switch(Pa(n),n.tag){case 1:return Tt(n.type)&&Ms(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Oi(),Ue(Rt),Ue(St),Va(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Ha(n),null;case 13:if(Ue(qe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));Ai()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Oi(),null;case 10:return $a(n.type._context),null;case 22:case 23:return _u(),null;case 24:return null;default:return null}}var qs=!1,jt=!1,Ry=typeof WeakSet=="function"?WeakSet:Set,ye=null;function Hi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Ze(e,n,l)}else i.current=null}function uu(e,n,i){try{i()}catch(l){Ze(e,n,l)}}var kf=!1;function Ty(e,n){if(_a=gs,e=ed(),ha(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,g=l.focusNode;l=l.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var S=0,T=-1,O=-1,J=0,ae=0,ue=e,le=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=S+f),ue!==g||l!==0&&ue.nodeType!==3||(O=S+l),ue.nodeType===3&&(S+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)le=ue,ue=ge;for(;;){if(ue===e)break t;if(le===i&&++J===f&&(T=S),le===g&&++ae===l&&(O=S),(ge=ue.nextSibling)!==null)break;ue=le,le=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(Sa={focusedElem:e,selectionRange:i},gs=!1,ye=n;ye!==null;)if(n=ye,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ye=e;else for(;ye!==null;){n=ye;try{var xe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var we=xe.memoizedProps,et=xe.memoizedState,X=n.stateNode,H=X.getSnapshotBeforeUpdate(n.elementType===n.type?we:an(n.type,we),et);X.__reactInternalSnapshotBeforeUpdate=H}break;case 3:var K=n.stateNode.containerInfo;K.nodeType===1?K.textContent="":K.nodeType===9&&K.documentElement&&K.removeChild(K.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(ce){Ze(n,n.return,ce)}if(e=n.sibling,e!==null){e.return=n.return,ye=e;break}ye=n.return}return xe=kf,kf=!1,xe}function Do(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&e)===e){var g=f.destroy;f.destroy=void 0,g!==void 0&&uu(n,i,g)}f=f.next}while(f!==l)}}function Ks(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function cu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function Nf(e){var n=e.alternate;n!==null&&(e.alternate=null,Nf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[Cn],delete n[Eo],delete n[ba],delete n[gy],delete n[my])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function jf(e){return e.tag===5||e.tag===3||e.tag===4}function bf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||jf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function du(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=Es));else if(l!==4&&(e=e.child,e!==null))for(du(e,n,i),e=e.sibling;e!==null;)du(e,n,i),e=e.sibling}function fu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(fu(e,n,i),e=e.sibling;e!==null;)fu(e,n,i),e=e.sibling}var vt=null,un=!1;function kr(e,n,i){for(i=i.child;i!==null;)Ef(e,n,i),i=i.sibling}function Ef(e,n,i){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(Vn,i)}catch{}switch(i.tag){case 5:jt||Hi(i,n);case 6:var l=vt,f=un;vt=null,kr(e,n,i),vt=l,un=f,vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):vt.removeChild(i.stateNode));break;case 18:vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?ja(e.parentNode,i):e.nodeType===1&&ja(e,i),mo(e)):ja(vt,i.stateNode));break;case 4:l=vt,f=un,vt=i.stateNode.containerInfo,un=!0,kr(e,n,i),vt=l,un=f;break;case 0:case 11:case 14:case 15:if(!jt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var g=f,S=g.destroy;g=g.tag,S!==void 0&&((g&2)!==0||(g&4)!==0)&&uu(i,n,S),f=f.next}while(f!==l)}kr(e,n,i);break;case 1:if(!jt&&(Hi(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Ze(i,n,T)}kr(e,n,i);break;case 21:kr(e,n,i);break;case 22:i.mode&1?(jt=(l=jt)||i.memoizedState!==null,kr(e,n,i),jt=l):kr(e,n,i);break;default:kr(e,n,i)}}function Cf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Ry),n.forEach(function(l){var f=By.bind(null,e,l);i.has(l)||(i.add(l),l.then(f,f))})}}function cn(e,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=S),l&=~g}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Ay(l/1960))-l,10e?16:e,jr===null)var l=!1;else{if(e=jr,jr=null,tl=0,($e&6)!==0)throw Error(o(331));var f=$e;for($e|=4,ye=e.current;ye!==null;){var g=ye,S=g.child;if((ye.flags&16)!==0){var T=g.deletions;if(T!==null){for(var O=0;OVe()-gu?ii(e,0):pu|=i),$t(e,n)}function Hf(e,n){n===0&&((e.mode&1)===0?n=1:(n=Un,Un<<=1,(Un&130023424)===0&&(Un=4194304)));var i=Mt();e=Qn(e,n),e!==null&&(En(e,n,i),$t(e,i))}function Hy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Hf(e,i)}function By(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Hf(e,i)}var Bf;Bf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Rt.current)Lt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Lt=!1,My(e,n,i);Lt=(e.flags&131072)!==0}else Lt=!1,Xe&&(n.flags&1048576)!==0&&wd(n,Ts,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Xs(e,n),e=n.pendingProps;var f=Ri(n,St.current);Di(n,i),f=Ga(null,n,l,e,f,i);var g=Ya();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Tt(l)?(g=!0,Ps(n)):g=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Oa(n),f.updater=Gs,n.stateNode=f,f._reactInternals=n,Ja(n,l,e,i),n=ru(null,n,l,!0,g,i)):(n.tag=0,Xe&&g&&Ma(n),Ct(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Xs(e,n),e=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=Wy(l),e=an(l,e),f){case 0:n=nu(null,n,l,e,i);break e;case 1:n=pf(null,n,l,e,i);break e;case 11:n=uf(null,n,l,e,i);break e;case 14:n=cf(null,n,l,an(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),nu(e,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),pf(e,n,l,f,i);case 3:e:{if(gf(n),e===null)throw Error(o(387));l=n.pendingProps,g=n.memoizedState,f=g.element,Md(e,n),Os(n,l,null,i);var S=n.memoizedState;if(l=S.element,g.isDehydrated)if(g={element:l,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){f=Fi(Error(o(423)),n),n=mf(e,n,l,i,f);break e}else if(l!==f){f=Fi(Error(o(424)),n),n=mf(e,n,l,i,f);break e}else for(Ut=yr(n.stateNode.containerInfo.firstChild),Wt=n,Xe=!0,ln=null,i=Ed(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Ai(),l===f){n=Jn(e,n,i);break e}Ct(e,n,l,i)}n=n.child}return n;case 5:return Rd(n),e===null&&Ra(n),l=n.type,f=n.pendingProps,g=e!==null?e.memoizedProps:null,S=f.children,ka(l,f)?S=null:g!==null&&ka(l,g)&&(n.flags|=32),hf(e,n),Ct(e,n,S,i),n.child;case 6:return e===null&&Ra(n),null;case 13:return yf(e,n,i);case 4:return Fa(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=$i(n,null,l,i):Ct(e,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),uf(e,n,l,f,i);case 7:return Ct(e,n,n.pendingProps,i),n.child;case 8:return Ct(e,n,n.pendingProps.children,i),n.child;case 12:return Ct(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,g=n.memoizedProps,S=f.value,Be($s,l._currentValue),l._currentValue=S,g!==null)if(sn(g.value,S)){if(g.children===f.children&&!Rt.current){n=Jn(e,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var T=g.dependencies;if(T!==null){S=g.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(g.tag===1){O=Zn(-1,i&-i),O.tag=2;var J=g.updateQueue;if(J!==null){J=J.shared;var ae=J.pending;ae===null?O.next=O:(O.next=ae.next,ae.next=O),J.pending=O}}g.lanes|=i,O=g.alternate,O!==null&&(O.lanes|=i),za(g.return,i,n),T.lanes|=i;break}O=O.next}}else if(g.tag===10)S=g.type===n.type?null:g.child;else if(g.tag===18){if(S=g.return,S===null)throw Error(o(341));S.lanes|=i,T=S.alternate,T!==null&&(T.lanes|=i),za(S,i,n),S=g.sibling}else S=g.child;if(S!==null)S.return=g;else for(S=g;S!==null;){if(S===n){S=null;break}if(g=S.sibling,g!==null){g.return=S.return,S=g;break}S=S.return}g=S}Ct(e,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,Di(n,i),f=Zt(f),l=l(f),n.flags|=1,Ct(e,n,l,i),n.child;case 14:return l=n.type,f=an(l,n.pendingProps),f=an(l.type,f),cf(e,n,l,f,i);case 15:return df(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),Xs(e,n),n.tag=1,Tt(l)?(e=!0,Ps(n)):e=!1,Di(n,i),tf(n,l,f),Ja(n,l,f,i),ru(null,n,l,!0,e,i);case 19:return xf(e,n,i);case 22:return ff(e,n,i)}throw Error(o(156,n.tag))};function Vf(e,n){return Hr(e,n)}function Vy(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tn(e,n,i,l){return new Vy(e,n,i,l)}function ku(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Wy(e){if(typeof e=="function")return ku(e)?1:0;if(e!=null){if(e=e.$$typeof,e===te)return 11;if(e===V)return 14}return 2}function Cr(e,n){var i=e.alternate;return i===null?(i=tn(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function ol(e,n,i,l,f,g){var S=2;if(l=e,typeof e=="function")ku(e)&&(S=1);else if(typeof e=="string")S=5;else e:switch(e){case B:return si(i.children,f,g,n);case Y:S=8,f|=8;break;case Q:return e=tn(12,i,n,f|2),e.elementType=Q,e.lanes=g,e;case q:return e=tn(13,i,n,f),e.elementType=q,e.lanes=g,e;case C:return e=tn(19,i,n,f),e.elementType=C,e.lanes=g,e;case U:return sl(i,f,g,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ne:S=10;break e;case ee:S=9;break e;case te:S=11;break e;case V:S=14;break e;case W:S=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=tn(S,i,n,f),n.elementType=e,n.type=l,n.lanes=g,n}function si(e,n,i,l){return e=tn(7,e,l,n),e.lanes=i,e}function sl(e,n,i,l){return e=tn(22,e,l,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function Nu(e,n,i){return e=tn(6,e,null,n),e.lanes=i,e}function ju(e,n,i){return n=tn(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Uy(e,n,i,l,f){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Gn(0),this.expirationTimes=Gn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Gn(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function bu(e,n,i,l,f,g,S,T,O){return e=new Uy(e,n,i,T,O),n===1?(n=1,g===!0&&(n|=8)):n=0,g=tn(3,null,null,n),e.current=g,g.stateNode=e,g.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Oa(g),e}function Gy(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),Ru.exports=i0(),Ru.exports}var rh;function o0(){if(rh)return hl;rh=1;var t=kp();return hl.createRoot=t.createRoot,hl.hydrateRoot=t.hydrateRoot,hl}var s0=o0();function Np(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Te(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(Np(s,o.statusText||"Request failed"))}return o.json()}const l0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Pe={health:()=>Te("/api/health"),settings:()=>Te("/api/settings"),saveSettings:t=>{const r={...t};for(const o of l0)r[o]===""&&delete r[o];return Te("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Te("/api/repos"),browse:t=>Te(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Te(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Te("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Te(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Te(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:(t,r=!0)=>Te(`/api/architecture?repo_path=${encodeURIComponent(t)}&graph=${r?"1":"0"}`),architectureGraph:t=>Te(`/api/architecture/graph?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Te("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Te("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Te("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Te("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Te("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Te(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open",s)=>Te("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o,repo_path:s||null})}),scmRepos:t=>Te(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Te("/api/oauth/status"),githubOAuthStart:()=>Te("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Te("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Te("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Te("/api/oauth/gitlab/start"),oauthDisconnect:t=>Te("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Te("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})}),reviews:t=>Te(`/api/reviews?repo_path=${encodeURIComponent(t)}`),getReview:(t,r)=>Te(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(t)}`),reviewDiff:(t,r,o)=>Te(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(t)}&other=${encodeURIComponent(o)}`),config:t=>Te(`/api/config?repo_path=${encodeURIComponent(t)}`),saveConfig:(t,r)=>Te("/api/config",{method:"PUT",body:JSON.stringify({repo_path:t,...r})}),addWaiver:(t,r,o,s)=>Te("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:t,rule:r,node:o||null,reason:s||""})}),marks:(t,r)=>Te(`/api/marks?repo_path=${encodeURIComponent(t)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:t=>Te(`/api/architecture/health?repo_path=${encodeURIComponent(t)}`),workspaceStatus:t=>Te(`/api/workspace/status?repo_path=${encodeURIComponent(t)}`),openEditor:(t,r,o,s)=>Te("/api/open",{method:"POST",body:JSON.stringify({repo_path:t,path:r,line:o||null,editor:s||null})}),exportHtml:t=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:t})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(Np(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(t,r,o,s)=>Te("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:t,edges:r,source_id:o,target_id:s||null})})};function a0(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):t}function u0({open:t,actions:r,onClose:o}){const[s,a]=L.useState(""),[u,c]=L.useState(0),h=L.useRef(null),p=L.useMemo(()=>a0(r,s),[r,s]);if(L.useEffect(()=>{if(!t)return;a(""),c(0);const y=window.setTimeout(()=>{var m;return(m=h.current)==null?void 0:m.focus()},0);return()=>window.clearTimeout(y)},[t]),L.useEffect(()=>{c(0)},[s]),!t)return null;const v=p[u],x=y=>{y&&(o(),y.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:y=>{y.target===y.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:y=>a(y.target.value),onKeyDown:y=>{y.key==="Escape"?(y.preventDefault(),o()):y.key==="ArrowDown"?(y.preventDefault(),c(m=>Math.min(p.length-1,m+1))):y.key==="ArrowUp"?(y.preventDefault(),c(m=>Math.max(0,m-1))):y.key==="Enter"&&(y.preventDefault(),x(v))}}),d.jsxs("ul",{children:[p.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,p.slice(0,40).map((y,m)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:m===u?"active":"",onMouseEnter:()=>c(m),onClick:()=>x(y),children:[d.jsx("span",{children:y.label}),y.hint?d.jsx("span",{className:"muted",children:y.hint}):null]})},y.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function c0({config:t,busy:r,onSave:o,onWaiver:s}){const[a,u]=L.useState(t),[c,h]=L.useState(t.available_rules[0]||""),[p,v]=L.useState(""),[x,y]=L.useState("");L.useEffect(()=>{u(t)},[t]);const m=Object.entries(a.contexts||{}),_=(P,w,j)=>{const $=a.contexts[P];if(!$)return;const D=B=>B.split(",").map(Y=>Y.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[P]:{...$,[w]:w==="name"?j:D(j)}}})},k=(P,w)=>{const j=w.trim();if(!j||j===P)return;const{[P]:$,...D}=a.contexts;$&&u({...a,contexts:{...D,[j]:{...$,name:j}}})},b=()=>{let P=1;for(;a.contexts[`context-${P}`];)P+=1;const w=`context-${P}`;u({...a,contexts:{...a.contexts,[w]:{name:w,django_apps:[],react:[],public_api:[],owners:[]}}})},E=P=>{const{[P]:w,...j}=a.contexts;u({...a,contexts:j})},N=P=>{const w=a.rules.includes(P);u({...a,rules:w?a.rules.filter(j=>j!==P):[...a.rules,P]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),m.map(([P,w])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:P})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:P,"data-testid":`config-context-name-${P}`,onBlur:j=>k(P,j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(w.django_apps||[]).join(", "),onChange:j=>_(P,"django_apps",j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(w.react||[]).join(", "),onChange:j=>_(P,"react",j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(w.public_api||[]).join(", "),onChange:j=>_(P,"public_api",j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(w.owners||[]).join(", "),onChange:j=>_(P,"owners",j.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>E(P),children:"Remove context"})]},P)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:b,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(P=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(P),onChange:()=>N(P)}),P]},P))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((P,w)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:P.rule}),P.node?` · ${P.node}`:"",P.reason?` — ${P.reason}`:""]},`${P.rule}:${P.node}:${w}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:P=>h(P.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(P=>d.jsx("option",{value:P,children:P},P))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:P=>v(P.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:x,onChange:P=>y(P.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,x),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function Ko(t){return t.replaceAll("_"," ")}function d0(t){return t.replaceAll("_"," ")}function no(t){return t.split(".").pop()||t}function Qu(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function f0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Tr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function mi({className:t,children:r}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function h0({className:t}){return d.jsxs(mi,{className:t,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function p0({className:t}){return d.jsxs(mi,{className:t,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function g0({className:t}){return d.jsxs(mi,{className:t,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function m0({className:t}){return d.jsxs(mi,{className:t,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function y0({className:t}){return d.jsxs(mi,{className:t,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function jp({className:t}){return d.jsx(mi,{className:t,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function v0({className:t}){return d.jsx(mi,{className:t,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const x0="modulepreload",w0=function(t,r){return new URL(t,r).href},ih={},_0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(x){return Promise.all(x.map(y=>Promise.resolve(y).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),v=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(x=>{if(x=w0(x,s),x in ih)return;ih[x]=!0;const y=x.endsWith(".css"),m=y?'[rel="stylesheet"]':"";if(!!s)for(let b=h.length-1;b>=0;b--){const E=h[b];if(E.href===x&&(!y||E.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${x}"]${m}`))return;const k=document.createElement("link");if(k.rel=y?"stylesheet":x0,y||(k.as="script"),k.crossOrigin="",k.href=x,v&&k.setAttribute("nonce",v),document.head.appendChild(k),y)return new Promise((b,E)=>{k.addEventListener("load",b),k.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${x}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function nt(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Hl(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}jl.prototype=Hl.prototype={constructor:jl,on:function(t,r){var o=this._,s=k0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),sh.hasOwnProperty(r)?{space:sh[r],local:t}:t}function j0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===Zu&&r.documentElement.namespaceURI===Zu?r.createElement(t):r.createElementNS(o,t)}}function b0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function bp(t){var r=Bl(t);return(r.local?b0:j0)(r)}function E0(){}function pc(t){return t==null?E0:function(){return this.querySelector(t)}}function C0(t){typeof t!="function"&&(t=pc(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=w&&(w=P+1);!($=E[w])&&++w=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function J0(t){t||(t=ev);function r(y,m){return y&&m?t(y.__data__,m.__data__):!y-!m}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function tv(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function nv(){return Array.from(this)}function rv(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?pv:typeof r=="function"?mv:gv)(t,r,o??"")):qi(this.node(),t)}function qi(t,r){return t.style.getPropertyValue(r)||Ip(t).getComputedStyle(t,null).getPropertyValue(r)}function vv(t){return function(){delete this[t]}}function xv(t,r){return function(){this[t]=r}}function wv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function _v(t,r){return arguments.length>1?this.each((r==null?vv:typeof r=="function"?wv:xv)(t,r)):this.node()[t]}function Rp(t){return t.trim().split(/^|\s+/)}function gc(t){return t.classList||new Tp(t)}function Tp(t){this._node=t,this._names=Rp(t.getAttribute("class")||"")}Tp.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Lp(t,r){for(var o=gc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function qv(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function Ju(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:v,dispatch:x}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:v,enumerable:!0,configurable:!0},_:{value:x}})}Ju.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function ox(t){return!t.ctrlKey&&!t.button}function sx(){return this.parentNode}function lx(t,r){return r??{x:t.x,y:t.y}}function ax(){return navigator.maxTouchPoints||"ontouchstart"in this}function Fp(){var t=ox,r=sx,o=lx,s=ax,a={},u=Hl("start","drag","end"),c=0,h,p,v,x,y=0;function m(j){j.on("mousedown.drag",_).filter(s).on("touchstart.drag",E).on("touchmove.drag",N,ix).on("touchend.drag touchcancel.drag",P).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(j,$){if(!(x||!t.call(this,j,$))){var D=w(this,r.call(this,j,$),j,$,"mouse");D&&(Yt(j.view).on("mousemove.drag",k,Qo).on("mouseup.drag",b,Qo),Dp(j.view),Au(j),v=!1,h=j.clientX,p=j.clientY,D("start",j))}}function k(j){if(Yi(j),!v){var $=j.clientX-h,D=j.clientY-p;v=$*$+D*D>y}a.mouse("drag",j)}function b(j){Yt(j.view).on("mousemove.drag mouseup.drag",null),Op(j.view,v),Yi(j),a.mouse("end",j)}function E(j,$){if(t.call(this,j,$)){var D=j.changedTouches,B=r.call(this,j,$),Y=D.length,Q,ne;for(Q=0;Q>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?gl(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?gl(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=cx.exec(t))?new Dt(r[1],r[2],r[3],1):(r=dx.exec(t))?new Dt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=fx.exec(t))?gl(r[1],r[2],r[3],r[4]):(r=hx.exec(t))?gl(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=px.exec(t))?hh(r[1],r[2]/100,r[3]/100,1):(r=gx.exec(t))?hh(r[1],r[2]/100,r[3]/100,r[4]):lh.hasOwnProperty(t)?ch(lh[t]):t==="transparent"?new Dt(NaN,NaN,NaN,0):null}function ch(t){return new Dt(t>>16&255,t>>8&255,t&255,1)}function gl(t,r,o,s){return s<=0&&(t=r=o=NaN),new Dt(t,r,o,s)}function vx(t){return t instanceof us||(t=di(t)),t?(t=t.rgb(),new Dt(t.r,t.g,t.b,t.opacity)):new Dt}function ec(t,r,o,s){return arguments.length===1?vx(t):new Dt(t,r,o,s??1)}function Dt(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}mc(Dt,ec,Hp(us,{brighter(t){return t=t==null?Il:Math.pow(Il,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Zo:Math.pow(Zo,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Dt(ui(this.r),ui(this.g),ui(this.b),Rl(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:dh,formatHex:dh,formatHex8:xx,formatRgb:fh,toString:fh}));function dh(){return`#${ai(this.r)}${ai(this.g)}${ai(this.b)}`}function xx(){return`#${ai(this.r)}${ai(this.g)}${ai(this.b)}${ai((isNaN(this.opacity)?1:this.opacity)*255)}`}function fh(){const t=Rl(this.opacity);return`${t===1?"rgb(":"rgba("}${ui(this.r)}, ${ui(this.g)}, ${ui(this.b)}${t===1?")":`, ${t})`}`}function Rl(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ui(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ai(t){return t=ui(t),(t<16?"0":"")+t.toString(16)}function hh(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new hn(t,r,o,s)}function Bp(t){if(t instanceof hn)return new hn(t.h,t.s,t.l,t.opacity);if(t instanceof us||(t=di(t)),!t)return new hn;if(t instanceof hn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new hn(c,h,p,t.opacity)}function wx(t,r,o,s){return arguments.length===1?Bp(t):new hn(t,r,o,s??1)}function hn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}mc(hn,wx,Hp(us,{brighter(t){return t=t==null?Il:Math.pow(Il,t),new hn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Zo:Math.pow(Zo,t),new hn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Dt($u(t>=240?t-240:t+120,a,s),$u(t,a,s),$u(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new hn(ph(this.h),ml(this.s),ml(this.l),Rl(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 t=Rl(this.opacity);return`${t===1?"hsl(":"hsla("}${ph(this.h)}, ${ml(this.s)*100}%, ${ml(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ph(t){return t=(t||0)%360,t<0?t+360:t}function ml(t){return Math.max(0,Math.min(1,t||0))}function $u(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const yc=t=>()=>t;function _x(t,r){return function(o){return t+o*r}}function Sx(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function kx(t){return(t=+t)==1?Vp:function(r,o){return o-r?Sx(r,o,t):yc(isNaN(r)?o:r)}}function Vp(t,r){var o=r-t;return o?_x(t,o):yc(isNaN(t)?r:t)}const Tl=(function t(r){var o=kx(r);function s(a,u){var c=o((a=ec(a)).r,(u=ec(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),v=Vp(a.opacity,u.opacity);return function(x){return a.r=c(x),a.g=h(x),a.b=p(x),a.opacity=v(x),a+""}}return s.gamma=t,s})(1);function Nx(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:Rn(s,a)})),o=zu.lastIndex;return o180?x+=360:x-v>180&&(v+=360),m.push({i:y.push(a(y)+"rotate(",null,s)-2,x:Rn(v,x)})):x&&y.push(a(y)+"rotate("+x+s)}function h(v,x,y,m){v!==x?m.push({i:y.push(a(y)+"skewX(",null,s)-2,x:Rn(v,x)}):x&&y.push(a(y)+"skewX("+x+s)}function p(v,x,y,m,_,k){if(v!==y||x!==m){var b=_.push(a(_)+"scale(",null,",",null,")");k.push({i:b-4,x:Rn(v,y)},{i:b-2,x:Rn(x,m)})}else(y!==1||m!==1)&&_.push(a(_)+"scale("+y+","+m+")")}return function(v,x){var y=[],m=[];return v=t(v),x=t(x),u(v.translateX,v.translateY,x.translateX,x.translateY,y,m),c(v.rotate,x.rotate,y,m),h(v.skewX,x.skewX,y,m),p(v.scaleX,v.scaleY,x.scaleX,x.scaleY,y,m),v=x=null,function(_){for(var k=-1,b=m.length,E;++k=0&&t._call.call(void 0,r),t=t._next;--Ki}function yh(){fi=(Al=es.now())+Vl,Ki=Go=0;try{Ox()}finally{Ki=0,Hx(),fi=0}}function Fx(){var t=es.now(),r=t-Al;r>Yp&&(Vl-=r,Al=t)}function Hx(){for(var t,r=Ll,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:Ll=o);Yo=t,rc(s)}function rc(t){if(!Ki){Go&&(Go=clearTimeout(Go));var r=t-fi;r>24?(t<1/0&&(Go=setTimeout(yh,t-es.now()-Vl)),Wo&&(Wo=clearInterval(Wo))):(Wo||(Al=es.now(),Wo=setInterval(Fx,Yp)),Ki=1,Xp(yh))}}function vh(t,r,o){var s=new $l;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Bx=Hl("start","end","cancel","interrupt"),Vx=[],Kp=0,xh=1,ic=2,El=3,wh=4,oc=5,Cl=6;function Wl(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;Wx(t,o,{name:r,index:s,group:a,on:Bx,tween:Vx,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Kp})}function xc(t,r){var o=yn(t,r);if(o.state>Kp)throw new Error("too late; already scheduled");return o}function Ln(t,r){var o=yn(t,r);if(o.state>El)throw new Error("too late; already running");return o}function yn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Wx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=qp(u,0,o.time);function u(v){o.state=xh,o.timer.restart(c,o.delay,o.time),o.delay<=v&&c(v-o.delay)}function c(v){var x,y,m,_;if(o.state!==xh)return p();for(x in s)if(_=s[x],_.name===o.name){if(_.state===El)return vh(c);_.state===wh?(_.state=Cl,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete s[x]):+xic&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function ww(t,r,o){var s,a,u=xw(r)?xc:Ln;return function(){var c=u(this,t),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function _w(t,r){var o=this._id;return arguments.length<2?yn(this.node(),o).on.on(t):this.each(ww(o,t,r))}function Sw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function kw(){return this.on("end.remove",Sw(this._id))}function Nw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=pc(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function qw(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function nr(t,r,o){this.k=t,this.x=r,this.y=o}nr.prototype={constructor:nr,scale:function(t){return t===1?this:new nr(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new nr(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Ul=new nr(1,0,0);eg.prototype=nr.prototype;function eg(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Ul;return t.__zoom}function Du(t){t.stopImmediatePropagation()}function Uo(t){t.preventDefault(),t.stopImmediatePropagation()}function Kw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Qw(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function _h(){return this.__zoom||Ul}function Zw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Jw(){return navigator.maxTouchPoints||"ontouchstart"in this}function e1(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function tg(){var t=Kw,r=Qw,o=e1,s=Zw,a=Jw,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=bl,v=Hl("start","zoom","end"),x,y,m,_=500,k=150,b=0,E=10;function N(C){C.property("__zoom",_h).on("wheel.zoom",Y,{passive:!1}).on("mousedown.zoom",Q).on("dblclick.zoom",ne).filter(a).on("touchstart.zoom",ee).on("touchmove.zoom",te).on("touchend.zoom touchcancel.zoom",q).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}N.transform=function(C,V,W,U){var M=C.selection?C.selection():C;M.property("__zoom",_h),C!==M?$(C,V,W,U):M.interrupt().each(function(){D(this,arguments).event(U).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},N.scaleBy=function(C,V,W,U){N.scaleTo(C,function(){var M=this.__zoom.k,z=typeof V=="function"?V.apply(this,arguments):V;return M*z},W,U)},N.scaleTo=function(C,V,W,U){N.transform(C,function(){var M=r.apply(this,arguments),z=this.__zoom,F=W==null?j(M):typeof W=="function"?W.apply(this,arguments):W,R=z.invert(F),A=typeof V=="function"?V.apply(this,arguments):V;return o(w(P(z,A),F,R),M,c)},W,U)},N.translateBy=function(C,V,W,U){N.transform(C,function(){return o(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),r.apply(this,arguments),c)},null,U)},N.translateTo=function(C,V,W,U,M){N.transform(C,function(){var z=r.apply(this,arguments),F=this.__zoom,R=U==null?j(z):typeof U=="function"?U.apply(this,arguments):U;return o(Ul.translate(R[0],R[1]).scale(F.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),z,c)},U,M)};function P(C,V){return V=Math.max(u[0],Math.min(u[1],V)),V===C.k?C:new nr(V,C.x,C.y)}function w(C,V,W){var U=V[0]-W[0]*C.k,M=V[1]-W[1]*C.k;return U===C.x&&M===C.y?C:new nr(C.k,U,M)}function j(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function $(C,V,W,U){C.on("start.zoom",function(){D(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){D(this,arguments).event(U).end()}).tween("zoom",function(){var M=this,z=arguments,F=D(M,z).event(U),R=r.apply(M,z),A=W==null?j(R):typeof W=="function"?W.apply(M,z):W,ie=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),oe=M.__zoom,fe=typeof V=="function"?V.apply(M,z):V,he=p(oe.invert(A).concat(ie/oe.k),fe.invert(A).concat(ie/fe.k));return function(pe){if(pe===1)pe=fe;else{var Z=he(pe),se=ie/Z[2];pe=new nr(se,A[0]-Z[0]*se,A[1]-Z[1]*se)}F.zoom(null,pe)}})}function D(C,V,W){return!W&&C.__zooming||new B(C,V)}function B(C,V){this.that=C,this.args=V,this.active=0,this.sourceEvent=null,this.extent=r.apply(C,V),this.taps=0}B.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,V){return this.mouse&&C!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var V=Yt(this.that).datum();v.call(C,this.that,new qw(C,{sourceEvent:this.sourceEvent,target:N,transform:this.that.__zoom,dispatch:v}),V)}};function Y(C,...V){if(!t.apply(this,arguments))return;var W=D(this,V).event(C),U=this.__zoom,M=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,s.apply(this,arguments)))),z=fn(C);if(W.wheel)(W.mouse[0][0]!==z[0]||W.mouse[0][1]!==z[1])&&(W.mouse[1]=U.invert(W.mouse[0]=z)),clearTimeout(W.wheel);else{if(U.k===M)return;W.mouse=[z,U.invert(z)],Ml(this),W.start()}Uo(C),W.wheel=setTimeout(F,k),W.zoom("mouse",o(w(P(U,M),W.mouse[0],W.mouse[1]),W.extent,c));function F(){W.wheel=null,W.end()}}function Q(C,...V){if(m||!t.apply(this,arguments))return;var W=C.currentTarget,U=D(this,V,!0).event(C),M=Yt(C.view).on("mousemove.zoom",A,!0).on("mouseup.zoom",ie,!0),z=fn(C,W),F=C.clientX,R=C.clientY;Dp(C.view),Du(C),U.mouse=[z,this.__zoom.invert(z)],Ml(this),U.start();function A(oe){if(Uo(oe),!U.moved){var fe=oe.clientX-F,he=oe.clientY-R;U.moved=fe*fe+he*he>b}U.event(oe).zoom("mouse",o(w(U.that.__zoom,U.mouse[0]=fn(oe,W),U.mouse[1]),U.extent,c))}function ie(oe){M.on("mousemove.zoom mouseup.zoom",null),Op(oe.view,U.moved),Uo(oe),U.event(oe).end()}}function ne(C,...V){if(t.apply(this,arguments)){var W=this.__zoom,U=fn(C.changedTouches?C.changedTouches[0]:C,this),M=W.invert(U),z=W.k*(C.shiftKey?.5:2),F=o(w(P(W,z),U,M),r.apply(this,V),c);Uo(C),h>0?Yt(this).transition().duration(h).call($,F,U,C):Yt(this).call(N.transform,F,U,C)}}function ee(C,...V){if(t.apply(this,arguments)){var W=C.touches,U=W.length,M=D(this,V,C.changedTouches.length===U).event(C),z,F,R,A;for(Du(C),F=0;F`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},ts=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ng=["Enter"," ","Escape"],rg={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Qi;(function(t){t.Strict="strict",t.Loose="loose"})(Qi||(Qi={}));var ci;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(ci||(ci={}));var ns;(function(t){t.Partial="partial",t.Full="full"})(ns||(ns={}));const ig={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Lr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Lr||(Lr={}));var rs;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(rs||(rs={}));var ke;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(ke||(ke={}));const Sh={[ke.Left]:ke.Right,[ke.Right]:ke.Left,[ke.Top]:ke.Bottom,[ke.Bottom]:ke.Top};function og(t){return t===null?null:t?"valid":"invalid"}const sg=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,t1=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),_c=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),cs=(t,r=[0,0])=>{const{width:o,height:s}=vn(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},n1=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):_c(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,Gl(a,zl(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?Yl(s):{x:0,y:0,width:0,height:0}},ds=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=Gl(o,zl(a)),s=!0)}),s?Yl(o):{x:0,y:0,width:0,height:0}},Sc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,v=r.width/a,x=r.height/a,y=[];for(const m of t.values()){const{measured:_,selectable:k=!0,hidden:b=!1}=m;if(c&&!k||b)continue;const E=_.width??m.width??m.initialWidth??0,N=_.height??m.height??m.initialHeight??0,{x:P,y:w}=m.internals.positionAbsolute,j=cg(h,p,v,x,P,w,E,N),$=E*N,D=u&&j>0;(!m.internals.handleBounds||D||j>=$||m.dragging)&&y.push(m)}return y},r1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function i1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=vn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function o1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const h=i1(t,c),p=ds(h),v=Nc(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(v,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function lg({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),h=c.parentId?o.get(c.parentId):void 0,{x:p,y:v}=h?h.internals.positionAbsolute:{x:0,y:0},x=c.origin??s;let y=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",mn.error005());else{const{width:_,height:k}=vn(h);_&&k&&(y=[[p,v],[p+_,v+k]])}else h&&pi(c.extent)&&(y=[[c.extent[0][0]+p,c.extent[0][1]+v],[c.extent[1][0]+p,c.extent[1][1]+v]]);const m=pi(y)?hi(r,y,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",mn.error015())),{position:{x:m.x-p+(c.measured.width??0)*x[0],y:m.y-v+(c.measured.height??0)*x[1]},positionAbsolute:m}}async function s1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(m=>m.id)),c=[];for(const m of o){if(m.deletable===!1)continue;const _=u.has(m.id),k=!_&&m.parentId&&c.find(b=>b.id===m.parentId);(_||k)&&c.push(m)}const h=new Set(r.map(m=>m.id)),p=s.filter(m=>m.deletable!==!1),x=r1(c,p);for(const m of p)h.has(m.id)&&!x.find(k=>k.id===m.id)&&x.push(m);if(!a)return{edges:x,nodes:c};const y=await a({nodes:c,edges:x});return typeof y=="boolean"?y?{edges:x,nodes:c}:{edges:[],nodes:[]}:y}const Zi=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),hi=(t={x:0,y:0},r,o)=>({x:Zi(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:Zi(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function ag(t,r,o){const{width:s,height:a}=vn(o),{x:u,y:c}=o.internals.positionAbsolute;return hi(t,[[u,c],[u+s,c+a]],r)}const kh=(t,r,o)=>to?-Zi(Math.abs(t-o),1,r)/r:0,kc=(t,r,o=15,s=40)=>{const a=kh(t.x,s,r.width-s)*o,u=kh(t.y,s,r.height-s)*o;return[a,u]},Gl=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),sc=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),Yl=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),is=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:cs(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},zl=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:cs(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},ug=(t,r)=>Yl(Gl(sc(t),sc(r))),cg=(t,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),v=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*v)},Dl=(t,r)=>cg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),Nh=t=>pn(t.width)&&pn(t.height)&&pn(t.x)&&pn(t.y),pn=t=>!isNaN(t)&&isFinite(t),dg=(t,r)=>(o,s)=>{},fs=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),hs=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(t-o)/a,y:(r-s)/a};return u?fs(h,c):h},Ji=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Ui(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function l1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Ui(t,o),a=Ui(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Ui(t.top??t.y??0,o),a=Ui(t.bottom??t.y??0,o),u=Ui(t.left??t.x??0,r),c=Ui(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function a1(t,r,o,s,a,u){const{x:c,y:h}=Ji(t,[r,o,s]),{x:p,y:v}=Ji({x:t.x+t.width,y:t.y+t.height},[r,o,s]),x=a-p,y=u-v;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(x),bottom:Math.floor(y)}}const Nc=(t,r,o,s,a,u)=>{const c=l1(u,r,o),h=(r-c.x)/t.width,p=(o-c.y)/t.height,v=Math.min(h,p),x=Zi(v,s,a),y=t.x+t.width/2,m=t.y+t.height/2,_=r/2-y*x,k=o/2-m*x,b=a1(t,_,k,x,r,o),E={left:Math.min(b.left-c.left,0),top:Math.min(b.top-c.top,0),right:Math.min(b.right-c.right,0),bottom:Math.min(b.bottom-c.bottom,0)};return{x:_-E.left+E.right,y:k-E.top+E.bottom,zoom:x}},os=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function pi(t){return t!=null&&t!=="parent"}function vn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function fg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function hg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function jh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function u1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function c1(t){return{...rg,...t||{}}}function qo(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=gn(t),h=hs({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y:v}=o?fs(h,r):h;return{xSnapped:p,ySnapped:v,...h}}const jc=t=>({width:t.offsetWidth,height:t.offsetHeight}),pg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},d1=["INPUT","SELECT","TEXTAREA"];function gg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:d1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const mg=t=>"clientX"in t,gn=(t,r)=>{var u,c;const o=mg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},bh=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...jc(c)}})};function yg({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=t*.125+a*.375+c*.375+o*.125,v=r*.125+u*.375+h*.375+s*.125,x=Math.abs(p-t),y=Math.abs(v-r);return[p,v,x,y]}function xl(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function Eh({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case ke.Left:return[r-xl(r-s,u),o];case ke.Right:return[r+xl(s-r,u),o];case ke.Top:return[r,o-xl(o-a,u)];case ke.Bottom:return[r,o+xl(a-o,u)]}}function vg({sourceX:t,sourceY:r,sourcePosition:o=ke.Bottom,targetX:s,targetY:a,targetPosition:u=ke.Top,curvature:c=.25}){const[h,p]=Eh({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[v,x]=Eh({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[y,m,_,k]=yg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:v,targetControlY:x});return[`M${t},${r} C${h},${p} ${v},${x} ${s},${a}`,y,m,_,k]}function xg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const p1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,g1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),m1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",mn.error006()),r;const s=o.getEdgeId||p1;let a;return sg(t)?a={...t}:a={...t,id:s(t)},g1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function wg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=xg({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,h]}const Ch={[ke.Left]:{x:-1,y:0},[ke.Right]:{x:1,y:0},[ke.Top]:{x:0,y:-1},[ke.Bottom]:{x:0,y:1}},y1=({source:t,sourcePosition:r=ke.Bottom,target:o})=>r===ke.Left||r===ke.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function v1({source:t,sourcePosition:r=ke.Bottom,target:o,targetPosition:s=ke.Top,center:a,offset:u,stepPosition:c}){const h=Ch[r],p=Ch[s],v={x:t.x+h.x*u,y:t.y+h.y*u},x={x:o.x+p.x*u,y:o.y+p.y*u},y=y1({source:v,sourcePosition:r,target:x}),m=y.x!==0?"x":"y",_=y[m];let k=[],b,E;const N={x:0,y:0},P={x:0,y:0},[,,w,j]=xg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[m]*p[m]===-1){m==="x"?(b=a.x??v.x+(x.x-v.x)*c,E=a.y??(v.y+x.y)/2):(b=a.x??(v.x+x.x)/2,E=a.y??v.y+(x.y-v.y)*c);const Y=[{x:b,y:v.y},{x:b,y:x.y}],Q=[{x:v.x,y:E},{x:x.x,y:E}];h[m]===_?k=m==="x"?Y:Q:k=m==="x"?Q:Y}else{const Y=[{x:v.x,y:x.y}],Q=[{x:x.x,y:v.y}];if(m==="x"?k=h.x===_?Q:Y:k=h.y===_?Y:Q,r===s){const C=Math.abs(t[m]-o[m]);if(C<=u){const V=Math.min(u-1,u-C);h[m]===_?N[m]=(v[m]>t[m]?-1:1)*V:P[m]=(x[m]>o[m]?-1:1)*V}}if(r!==s){const C=m==="x"?"y":"x",V=h[m]===p[C],W=v[C]>x[C],U=v[C]=q?(b=(ne.x+ee.x)/2,E=k[0].y):(b=k[0].x,E=(ne.y+ee.y)/2)}const $={x:v.x+N.x,y:v.y+N.y},D={x:x.x+P.x,y:x.y+P.y};return[[t,...$.x!==k[0].x||$.y!==k[0].y?[$]:[],...k,...D.x!==k[k.length-1].x||D.y!==k[k.length-1].y?[D]:[],o],b,E,w,j]}function x1(t,r,o,s){const a=Math.min(Mh(t,r)/2,Mh(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const v=t.xo.id===r):t[0])||null}function ac(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function _1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const v=ac(p,r);u.has(v)||(c.push({id:v,color:p.color||o,...p}),u.add(v))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const _g=1e3,S1=10,bc={nodeOrigin:[0,0],nodeExtent:ts,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},k1={...bc,checkEquality:!0};function Ec(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function N1(t,r,o){const s=Ec(bc,o);for(const a of t.values())if(a.parentId)Mc(a,t,r,s);else{const u=cs(a,s.nodeOrigin),c=pi(a.extent)?a.extent:s.nodeExtent,h=hi(u,c,vn(a));a.internals.positionAbsolute=h}}function j1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function Cc(t){return t==="manual"}function uc(t,r,o,s={}){var x,y;const a=Ec(k1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!Cc(a.zIndexMode)?_g:0;let p=t.length>0,v=!1;r.clear(),o.clear();for(const m of t){let _=c.get(m.id);if(a.checkEquality&&m===(_==null?void 0:_.internals.userNode))r.set(m.id,_);else{const k=cs(m,a.nodeOrigin),b=pi(m.extent)?m.extent:a.nodeExtent,E=hi(k,b,vn(m));_={...a.defaults,...m,measured:{width:(x=m.measured)==null?void 0:x.width,height:(y=m.measured)==null?void 0:y.height},internals:{positionAbsolute:E,handleBounds:j1(m,_),z:Sg(m,h,a.zIndexMode),userNode:m}},r.set(m.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),m.parentId&&Mc(_,r,o,s,u),v||(v=m.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:v}}function b1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function Mc(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=Ec(bc,s),v=t.parentId,x=r.get(v);if(!x){console.warn(`Parent node ${v} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}b1(t,o),a&&!x.parentId&&x.internals.rootParentIndex===void 0&&p==="auto"&&(x.internals.rootParentIndex=++a.i,x.internals.z=x.internals.z+a.i*S1),a&&x.internals.rootParentIndex!==void 0&&(a.i=x.internals.rootParentIndex);const y=u&&!Cc(p)?_g:0,{x:m,y:_,z:k}=E1(t,x,c,h,y,p),{positionAbsolute:b}=t.internals,E=m!==b.x||_!==b.y;(E||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:E?{x:m,y:_}:b,z:k}})}function Sg(t,r,o){const s=pn(t.zIndex)?t.zIndex:0;return Cc(o)?s:s+(t.selected?r:0)}function E1(t,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=vn(t),v=cs(t,o),x=pi(t.extent)?hi(v,t.extent,p):v;let y=hi({x:c+x.x,y:h+x.y},s,p);t.extent==="parent"&&(y=ag(y,p,r));const m=Sg(t,a,u),_=r.internals.z??0;return{x:y.x,y:y.y,z:_>=m?_+1:m}}function Pc(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const v=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??is(p),x=ug(v,h.rect);u.set(h.parentId,{expandedRect:x,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},v)=>{var w;const x=p.internals.positionAbsolute,y=vn(p),m=p.origin??s,_=h.x0||k>0||N||P)&&(a.push({id:v,type:"position",position:{x:p.position.x-_+N,y:p.position.y-k+P}}),(w=o.get(v))==null||w.forEach(j=>{t.some($=>$.id===j.id)||a.push({id:j.id,type:"position",position:{x:j.position.x+_,y:j.position.y+k}})})),(y.width0){const _=Pc(m,r,o,a);v.push(..._)}return{changes:v,updatedInternals:p}}async function M1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Th(t,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${t}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${t}-${u}`;const v=s.get(c)||new Map;s.set(c,v.set(o,r))}}function kg(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},v=`${a}-${c}--${u}-${h}`,x=`${u}-${h}--${a}-${c}`;Th("source",p,x,t,a,c),Th("target",p,v,t,u,h),r.set(s.id,s)}}function Ng(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:Ng(o,r):!1}function Lh(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function P1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!Ng(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function Ou({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[v,x]of r){const y=(c=o.get(v))==null?void 0:c.internals.userNode;y&&a.push({...y,position:x.position,dragging:s})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function I1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=fs(u,r);return{x:c.x-u.x,y:c.y-u.y}}function R1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,v={x:0,y:0},x=null,y=!1,m=null,_=!1,k=!1,b=null;function E({noDragClassName:P,handleSelector:w,domNode:j,isSelectable:$,nodeId:D,nodeClickDistance:B=0}){m=Yt(j);function Y({x:te,y:q}){const{nodeLookup:C,nodeExtent:V,snapGrid:W,snapToGrid:U,nodeOrigin:M,onNodeDrag:z,onSelectionDrag:F,onError:R,updateNodePositions:A}=r();u={x:te,y:q};let ie=!1;const oe=h.size>1,fe=oe&&V?sc(ds(h)):null,he=oe&&U?I1({dragItems:h,snapGrid:W,x:te,y:q}):null;for(const[pe,Z]of h){if(!C.has(pe))continue;let se={x:te-Z.distance.x,y:q-Z.distance.y};U&&(se=he?{x:Math.round(se.x+he.x),y:Math.round(se.y+he.y)}:fs(se,W));let me=null;if(oe&&V&&!Z.extent&&fe){const{positionAbsolute:re}=Z.internals,je=re.x-fe.x+V[0][0],Me=re.x+Z.measured.width-fe.x2+V[1][0],Re=re.y-fe.y+V[0][1],Ae=re.y+Z.measured.height-fe.y2+V[1][1];me=[[je,Re],[Me,Ae]]}const{position:Ne,positionAbsolute:ve}=lg({nodeId:pe,nextPosition:se,nodeLookup:C,nodeExtent:me||V,nodeOrigin:M,onError:R});ie=ie||Z.position.x!==Ne.x||Z.position.y!==Ne.y,Z.position=Ne,Z.internals.positionAbsolute=ve}if(k=k||ie,!!ie&&(A(h,!0),b&&(s||z||!D&&F))){const[pe,Z]=Ou({nodeId:D,dragItems:h,nodeLookup:C});s==null||s(b,h,pe,Z),z==null||z(b,pe,Z),D||F==null||F(b,Z)}}async function Q(){if(!x)return;const{transform:te,panBy:q,autoPanSpeed:C,autoPanOnNodeDrag:V}=r();if(!V){p=!1,cancelAnimationFrame(c);return}const[W,U]=kc(v,x,C);(W!==0||U!==0)&&(u.x=(u.x??0)-W/te[2],u.y=(u.y??0)-U/te[2],await q({x:W,y:U})&&Y(u)),c=requestAnimationFrame(Q)}function ne(te){var oe;const{nodeLookup:q,multiSelectionActive:C,nodesDraggable:V,transform:W,snapGrid:U,snapToGrid:M,selectNodesOnDrag:z,onNodeDragStart:F,onSelectionDragStart:R,unselectNodesAndEdges:A}=r();y=!0,(!z||!$)&&!C&&D&&((oe=q.get(D))!=null&&oe.selected||A()),$&&z&&D&&(t==null||t(D));const ie=qo(te.sourceEvent,{transform:W,snapGrid:U,snapToGrid:M,containerBounds:x});if(u=ie,h=P1(q,V,ie,D),h.size>0&&(o||F||!D&&R)){const[fe,he]=Ou({nodeId:D,dragItems:h,nodeLookup:q});o==null||o(te.sourceEvent,h,fe,he),F==null||F(te.sourceEvent,fe,he),D||R==null||R(te.sourceEvent,he)}}const ee=Fp().clickDistance(B).on("start",te=>{const{domNode:q,nodeDragThreshold:C,transform:V,snapGrid:W,snapToGrid:U}=r();x=(q==null?void 0:q.getBoundingClientRect())||null,_=!1,k=!1,b=te.sourceEvent,C===0&&ne(te),u=qo(te.sourceEvent,{transform:V,snapGrid:W,snapToGrid:U,containerBounds:x}),v=gn(te.sourceEvent,x)}).on("drag",te=>{const{autoPanOnNodeDrag:q,transform:C,snapGrid:V,snapToGrid:W,nodeDragThreshold:U,nodeLookup:M}=r(),z=qo(te.sourceEvent,{transform:C,snapGrid:V,snapToGrid:W,containerBounds:x});if(b=te.sourceEvent,(te.sourceEvent.type==="touchmove"&&te.sourceEvent.touches.length>1||D&&!M.has(D))&&(_=!0),!_){if(!p&&q&&y&&(p=!0,Q()),!y){const F=gn(te.sourceEvent,x),R=F.x-v.x,A=F.y-v.y;Math.sqrt(R*R+A*A)>U&&ne(te)}(u.x!==z.xSnapped||u.y!==z.ySnapped)&&h&&y&&(v=gn(te.sourceEvent,x),Y(z))}}).on("end",te=>{if(!y||_){_&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,y=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:q,updateNodePositions:C,onNodeDragStop:V,onSelectionDragStop:W}=r();if(k&&(C(h,!1),k=!1),a||V||!D&&W){const[U,M]=Ou({nodeId:D,dragItems:h,nodeLookup:q,dragging:!1});a==null||a(te.sourceEvent,h,U,M),V==null||V(te.sourceEvent,U,M),D||W==null||W(te.sourceEvent,M)}}}).filter(te=>{const q=te.target;return!te.button&&(!P||!Lh(q,`.${P}`,j))&&(!w||Lh(q,w,j))});m.call(ee)}function N(){m==null||m.on(".drag",null)}return{update:E,destroy:N}}function T1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())Dl(a,is(u))>0&&s.push(u);return s}const L1=250;function A1(t,r,o,s){var h,p;let a=[],u=1/0;const c=T1(t,o,r+L1);for(const v of c){const x=[...((h=v.internals.handleBounds)==null?void 0:h.source)??[],...((p=v.internals.handleBounds)==null?void 0:p.target)??[]];for(const y of x){if(s.nodeId===y.nodeId&&s.type===y.type&&s.id===y.id)continue;const{x:m,y:_}=gi(v,y,y.position,!0),k=Math.sqrt(Math.pow(m-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const v=s.type==="source"?"target":"source";return a.find(x=>x.type===v)??a[0]}return a[0]}function jg(t,r,o,s,a,u=!1){var v,x,y;const c=s.get(t);if(!c)return null;const h=a==="strict"?(v=c.internals.handleBounds)==null?void 0:v[r]:[...((x=c.internals.handleBounds)==null?void 0:x.source)??[],...((y=c.internals.handleBounds)==null?void 0:y.target)??[]],p=(o?h==null?void 0:h.find(m=>m.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...gi(c,p,p.position,!0)}:p}function bg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function $1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const Eg=()=>!0;function z1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:v,autoPanOnConnect:x,flowId:y,panBy:m,cancelConnection:_,onConnectStart:k,onConnect:b,onConnectEnd:E,isValidConnection:N=Eg,onReconnectEnd:P,updateConnection:w,getTransform:j,getFromHandle:$,autoPanSpeed:D,dragThreshold:B=1,handleDomNode:Y}){const Q=pg(t.target);let ne=0,ee;const{x:te,y:q}=gn(t),C=bg(u,Y),V=h==null?void 0:h.getBoundingClientRect();let W=!1;if(!V||!C)return;const U=jg(a,C,s,p,r);if(!U)return;let M=gn(t,V),z=!1,F=null,R=!1,A=null;function ie(){if(!x||!V)return;const[Ne,ve]=kc(M,V,D);m({x:Ne,y:ve}),ne=requestAnimationFrame(ie)}const oe={...U,nodeId:a,type:C,position:U.position},fe=p.get(a);let pe={inProgress:!0,isValid:null,from:gi(fe,oe,ke.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:fe,to:M,toHandle:null,toPosition:Sh[oe.position],toNode:null,pointer:M};function Z(){W=!0,w(pe),k==null||k(t,{nodeId:a,handleId:s,handleType:C})}B===0&&Z();function se(Ne){if(!W){const{x:Ae,y:st}=gn(Ne),lt=Ae-te,at=st-q;if(!(lt*lt+at*at>B*B))return;Z()}if(!$()||!oe){me(Ne);return}const ve=j();M=gn(Ne,V),ee=A1(hs(M,ve,!1,[1,1]),o,p,oe),z||(ie(),z=!0);const re=Cg(Ne,{handle:ee,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:N,doc:Q,lib:v,flowId:y,nodeLookup:p});A=re.handleDomNode,F=re.connection,R=$1(!!ee,re.isValid);const je=p.get(a),Me=je?gi(je,oe,ke.Left,!0):pe.from,Re={...pe,from:Me,isValid:R,to:re.toHandle&&R?Ji({x:re.toHandle.x,y:re.toHandle.y},ve):M,toHandle:re.toHandle,toPosition:R&&re.toHandle?re.toHandle.position:Sh[oe.position],toNode:re.toHandle?p.get(re.toHandle.nodeId):null,pointer:M};w(Re),pe=Re}function me(Ne){if(!("touches"in Ne&&Ne.touches.length>0)){if(W){(ee||A)&&F&&R&&(b==null||b(F));const{inProgress:ve,...re}=pe,je={...re,toPosition:pe.toHandle?pe.toPosition:null};E==null||E(Ne,je),u&&(P==null||P(Ne,je))}_(),cancelAnimationFrame(ne),z=!1,R=!1,F=null,A=null,Q.removeEventListener("mousemove",se),Q.removeEventListener("mouseup",me),Q.removeEventListener("touchmove",se),Q.removeEventListener("touchend",me)}}Q.addEventListener("mousemove",se),Q.addEventListener("mouseup",me),Q.addEventListener("touchmove",se),Q.addEventListener("touchend",me)}function Cg(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:v=Eg,nodeLookup:x}){const y=u==="target",m=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=gn(t),b=c.elementFromPoint(_,k),E=b!=null&&b.classList.contains(`${h}-flow__handle`)?b:m,N={handleDomNode:E,isValid:!1,connection:null,toHandle:null};if(E){const P=bg(void 0,E),w=E.getAttribute("data-nodeid"),j=E.getAttribute("data-handleid"),$=E.classList.contains("connectable"),D=E.classList.contains("connectableend");if(!w||!P)return N;const B={source:y?w:s,sourceHandle:y?j:a,target:y?s:w,targetHandle:y?a:j};N.connection=B;const Q=$&&D&&(o===Qi.Strict?y&&P==="source"||!y&&P==="target":w!==s||j!==a);N.isValid=Q&&v(B),N.toHandle=jg(w,P,j,x,o,!0)}return N}const cc={onPointerDown:z1,isValid:Cg};function D1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Yt(t);function u({translateExtent:h,width:p,height:v,zoomStep:x=1,pannable:y=!0,zoomable:m=!0,inversePan:_=!1}){const k=w=>{if(w.sourceEvent.type!=="wheel"||!r)return;const j=o(),$=w.sourceEvent.ctrlKey&&os()?10:1,D=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*x,B=j[2]*Math.pow(2,D*$);r.scaleTo(B)};let b=[0,0];const E=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(b=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},N=w=>{const j=o();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!r)return;const $=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],D=[$[0]-b[0],$[1]-b[1]];b=$;const B=s()*Math.max(j[2],Math.log(j[2]))*(_?-1:1),Y={x:j[0]-D[0]*B,y:j[1]-D[1]*B},Q=[[0,0],[p,v]];r.setViewportConstrained({x:Y.x,y:Y.y,zoom:j[2]},Q,h)},P=tg().on("start",E).on("zoom",y?N:null).on("zoom.wheel",m?k:null);a.call(P,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:fn}}const Xl=t=>({x:t.x,y:t.y,zoom:t.k}),Fu=({x:t,y:r,zoom:o})=>Ul.translate(t,r).scale(o),Rr=(t,r)=>t.target.closest(`.${r}`),Mg=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),O1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Hu=(t,r=0,o=O1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Pg=t=>{const r=t.ctrlKey&&os()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function F1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:v}){return x=>{if(Rr(x,r))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const y=o.property("__zoom").k||1;if(x.ctrlKey&&c){const E=fn(x),N=Pg(x),P=y*Math.pow(2,N);s.scaleTo(o,P,E,x);return}const m=x.deltaMode===1?20:1;let _=a===ci.Vertical?0:x.deltaX*m,k=a===ci.Horizontal?0:x.deltaY*m;!os()&&x.shiftKey&&a!==ci.Vertical&&(_=x.deltaY*m,k=0),s.translateBy(o,-(_/y)*u,-(k/y)*u,{internal:!0});const b=Xl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(x,b):(t.isPanScrolling=!0,h==null||h(x,b)),t.panScrollTimeout=setTimeout(()=>{v==null||v(x,b),t.isPanScrolling=!1},150)}}function H1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=Rr(s,t);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function B1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=Xl(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function V1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;t.usedRightMouseButton=!!(o&&Mg(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,Xl(u.transform)))}}function W1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&Mg(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const p=Xl(c.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function U1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:v,lib:x,connectionInProgress:y}){return m=>{var N;const _=r||o,k=s&&m.ctrlKey,b=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(Rr(m,`${x}-flow__node`)||Rr(m,`${x}-flow__edge`)||Rr(m,`${x}-flow__selection`)||Rr(m,`${x}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!c&&!s||h||y&&!b||Rr(m,p)&&b||Rr(m,v)&&(!b||u&&b&&!r)||!s&&m.ctrlKey&&b)return!1;if(!s&&m.type==="touchstart"&&((N=m.touches)==null?void 0:N.length)>1)return m.preventDefault(),!1;if(!_&&!u&&!k&&b||!a&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(a)&&!a.includes(m.button)&&m.type==="mousedown")return!1;const E=Array.isArray(a)&&a.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||b||t)&&E}}function G1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const v={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=t.getBoundingClientRect();let y=[[0,0],[x.width,x.height]];const m=typeof ResizeObserver<"u"?new ResizeObserver(q=>{const C=q[0];C&&(y=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;m==null||m.observe(t);const _=tg().extent(()=>y).scaleExtent([r,o]).translateExtent(s),k=Yt(t).call(_);j({x:a.x,y:a.y,zoom:Zi(a.zoom,r,o)},[[0,0],[x.width,x.height]],s);const b=k.on("wheel.zoom"),E=k.on("dblclick.zoom");_.wheelDelta(Pg);async function N(q,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Xo:bl).transform(Hu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),q)}):!1}function P({noWheelClassName:q,noPanClassName:C,onPaneContextMenu:V,userSelectionActive:W,panOnScroll:U,panOnDrag:M,panOnScrollMode:z,panOnScrollSpeed:F,preventScrolling:R,zoomOnPinch:A,zoomOnScroll:ie,zoomOnDoubleClick:oe,panActivationKeyPressed:fe=!1,zoomActivationKeyPressed:he,lib:pe,onTransformChange:Z,connectionInProgress:se,paneClickDistance:me,selectionOnDrag:Ne}){W&&!v.isZoomingOrPanning&&w();const ve=U&&!he&&!W;_.clickDistance(Ne?1/0:!pn(me)||me<0?0:me);const re=ve?F1({zoomPanValues:v,noWheelClassName:q,d3Selection:k,d3Zoom:_,panOnScrollMode:z,panOnScrollSpeed:F,zoomOnPinch:A,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):H1({noWheelClassName:q,preventScrolling:R,d3ZoomHandler:b});k.on("wheel.zoom",re,{passive:!1});const je=B1({zoomPanValues:v,onDraggingChange:p,onPanZoomStart:c});_.on("start",je);const Me=V1({zoomPanValues:v,panOnDrag:M,onPaneContextMenu:!!V,onPanZoom:u,onTransformChange:Z});_.on("zoom",Me);const Re=W1({zoomPanValues:v,panOnDrag:M,panOnScroll:U,onPaneContextMenu:V,onPanZoomEnd:h,onDraggingChange:p});_.on("end",Re);const Ae=U1({panActivationKeyPressed:fe,zoomActivationKeyPressed:he,panOnDrag:M,zoomOnScroll:ie,panOnScroll:U,zoomOnDoubleClick:oe,zoomOnPinch:A,userSelectionActive:W,noPanClassName:C,noWheelClassName:q,lib:pe,connectionInProgress:se});_.filter(Ae),oe?k.on("dblclick.zoom",E):k.on("dblclick.zoom",null)}function w(){_.on("zoom",null)}async function j(q,C,V){const W=Fu(q),U=_==null?void 0:_.constrain()(W,C,V);return U&&await N(U),U}async function $(q,C){const V=Fu(q);return await N(V,C),V}function D(q){if(k){const C=Fu(q),V=k.property("__zoom");(V.k!==q.zoom||V.x!==q.x||V.y!==q.y)&&(_==null||_.transform(k,C,null,{sync:!0}))}}function B(){const q=k?eg(k.node()):{x:0,y:0,k:1};return{x:q.x,y:q.y,zoom:q.k}}async function Y(q,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Xo:bl).scaleTo(Hu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),q)}):!1}async function Q(q,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Xo:bl).scaleBy(Hu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),q)}):!1}function ne(q){_==null||_.scaleExtent(q)}function ee(q){_==null||_.translateExtent(q)}function te(q){const C=!pn(q)||q<0?0:q;_==null||_.clickDistance(C)}return{update:P,destroy:w,setViewport:$,setViewportConstrained:j,getViewport:B,scaleTo:Y,scaleBy:Q,setScaleExtent:ne,setTranslateExtent:ee,syncViewport:D,setClickDistance:te}}var eo;(function(t){t.Line="line",t.Handle="handle"})(eo||(eo={}));function Y1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function Ah(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function Pr(t,r){return Math.max(0,r-t)}function Ir(t,r){return Math.max(0,t-r)}function wl(t,r,o){return Math.max(0,r-t,t-o)}function $h(t,r){return t?!r:r}function X1(t,r,o,s,a,u,c,h){let{affectsX:p,affectsY:v}=r;const{isHorizontal:x,isVertical:y}=r,m=x&&y,{xSnapped:_,ySnapped:k}=o,{minWidth:b,maxWidth:E,minHeight:N,maxHeight:P}=s,{x:w,y:j,width:$,height:D,aspectRatio:B}=t;let Y=Math.floor(x?_-t.pointerX:0),Q=Math.floor(y?k-t.pointerY:0);const ne=$+(p?-Y:Y),ee=D+(v?-Q:Q),te=-u[0]*$,q=-u[1]*D;let C=wl(ne,b,E),V=wl(ee,N,P);if(c){let M=0,z=0;p&&Y<0?M=Pr(w+Y+te,c[0][0]):!p&&Y>0&&(M=Ir(w+ne+te,c[1][0])),v&&Q<0?z=Pr(j+Q+q,c[0][1]):!v&&Q>0&&(z=Ir(j+ee+q,c[1][1])),C=Math.max(C,M),V=Math.max(V,z)}if(h){let M=0,z=0;p&&Y>0?M=Ir(w+Y,h[0][0]):!p&&Y<0&&(M=Pr(w+ne,h[1][0])),v&&Q>0?z=Ir(j+Q,h[0][1]):!v&&Q<0&&(z=Pr(j+ee,h[1][1])),C=Math.max(C,M),V=Math.max(V,z)}if(a){if(x){const M=wl(ne/B,N,P)*B;if(C=Math.max(C,M),c){let z=0;!p&&!v||p&&!v&&m?z=Ir(j+q+ne/B,c[1][1])*B:z=Pr(j+q+(p?Y:-Y)/B,c[0][1])*B,C=Math.max(C,z)}if(h){let z=0;!p&&!v||p&&!v&&m?z=Pr(j+ne/B,h[1][1])*B:z=Ir(j+(p?Y:-Y)/B,h[0][1])*B,C=Math.max(C,z)}}if(y){const M=wl(ee*B,b,E)/B;if(V=Math.max(V,M),c){let z=0;!p&&!v||v&&!p&&m?z=Ir(w+ee*B+te,c[1][0])/B:z=Pr(w+(v?Q:-Q)*B+te,c[0][0])/B,V=Math.max(V,z)}if(h){let z=0;!p&&!v||v&&!p&&m?z=Pr(w+ee*B,h[1][0])/B:z=Ir(w+(v?Q:-Q)*B,h[0][0])/B,V=Math.max(V,z)}}}Q=Q+(Q<0?V:-V),Y=Y+(Y<0?C:-C),a&&(m?ne>ee*B?Q=($h(p,v)?-Y:Y)/B:Y=($h(p,v)?-Q:Q)*B:x?(Q=Y/B,v=p):(Y=Q*B,p=v));const W=p?w+Y:w,U=v?j+Q:j;return{width:$+(p?-Y:Y),height:D+(v?-Q:Q),x:u[0]*Y*(p?-1:1)+W,y:u[1]*Q*(v?-1:1)+U}}const Ig={width:0,height:0,x:0,y:0},q1={...Ig,pointerX:0,pointerY:0,aspectRatio:1};function K1(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function Q1({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Yt(t);let c={controlDirection:Ah("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:v,boundaries:x,keepAspectRatio:y,resizeDirection:m,onResizeStart:_,onResize:k,onResizeEnd:b,shouldResize:E}){let N={...Ig},P={...q1};c={boundaries:x,resizeDirection:m,keepAspectRatio:y,controlDirection:Ah(v)};let w,j=null,$=[],D,B,Y,Q=!1;const ne=Fp().on("start",ee=>{const{nodeLookup:te,transform:q,snapGrid:C,snapToGrid:V,nodeOrigin:W,paneDomNode:U}=o();if(w=te.get(r),!w)return;j=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:z}=qo(ee.sourceEvent,{transform:q,snapGrid:C,snapToGrid:V,containerBounds:j});N={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},P={...N,pointerX:M,pointerY:z,aspectRatio:N.width/N.height},D=void 0,B=pi(w.extent)?w.extent:void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&(D=te.get(w.parentId)),D&&w.extent==="parent"&&(B=[[0,0],[D.measured.width,D.measured.height]]),$=[],Y=void 0;for(const[F,R]of te)if(R.parentId===r&&($.push({id:F,position:{...R.position},extent:R.extent}),R.extent==="parent"||R.expandParent)){const A=K1(R,w,R.origin??W);Y?Y=[[Math.min(A[0][0],Y[0][0]),Math.min(A[0][1],Y[0][1])],[Math.max(A[1][0],Y[1][0]),Math.max(A[1][1],Y[1][1])]]:Y=A}_==null||_(ee,{...N})}).on("drag",ee=>{const{transform:te,snapGrid:q,snapToGrid:C,nodeOrigin:V}=o(),W=qo(ee.sourceEvent,{transform:te,snapGrid:q,snapToGrid:C,containerBounds:j}),U=[];if(!w)return;const{x:M,y:z,width:F,height:R}=N,A={},ie=w.origin??V,{width:oe,height:fe,x:he,y:pe}=X1(P,c.controlDirection,W,c.boundaries,c.keepAspectRatio,ie,B,Y),Z=oe!==F,se=fe!==R,me=he!==M&&Z,Ne=pe!==z&&se;if(!me&&!Ne&&!Z&&!se)return;if((me||Ne||ie[0]===1||ie[1]===1)&&(A.x=me?he:N.x,A.y=Ne?pe:N.y,N.x=A.x,N.y=A.y,$.length>0)){const Me=he-M,Re=pe-z;for(const Ae of $)Ae.position={x:Ae.position.x-Me+ie[0]*(oe-F),y:Ae.position.y-Re+ie[1]*(fe-R)},U.push(Ae)}if((Z||se)&&(A.width=Z&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:N.width,A.height=se&&(!c.resizeDirection||c.resizeDirection==="vertical")?fe:N.height,N.width=A.width,N.height=A.height),D&&w.expandParent){const Me=ie[0]*(A.width??0);A.x&&A.x{Q&&(b==null||b(ee,{...N}),a==null||a({...N}),Q=!1)});u.call(ne)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Bu={exports:{}},Vu={},Wu={exports:{}},Uu={};/** +`+g.stack}return{value:e,source:n,stack:f,digest:null}}function eu(e,n,i){return{value:e,source:null,stack:i??null,digest:n??null}}function tu(e,n){try{console.error(n.value)}catch(i){setTimeout(function(){throw i})}}var by=typeof WeakMap=="function"?WeakMap:Map;function rf(e,n,i){i=Jn(-1,i),i.tag=3,i.payload={element:null};var l=n.value;return i.callback=function(){el||(el=!0,mu=l),tu(e,n)},i}function of(e,n,i){i=Jn(-1,i),i.tag=3;var l=e.type.getDerivedStateFromError;if(typeof l=="function"){var f=n.value;i.payload=function(){return l(f)},i.callback=function(){tu(e,n)}}var g=e.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(i.callback=function(){tu(e,n),typeof l!="function"&&(Nr===null?Nr=new Set([this]):Nr.add(this));var S=n.stack;this.componentDidCatch(n.value,{componentStack:S!==null?S:""})}),i}function sf(e,n,i){var l=e.pingCache;if(l===null){l=e.pingCache=new by;var f=new Set;l.set(n,f)}else f=l.get(n),f===void 0&&(f=new Set,l.set(n,f));f.has(i)||(f.add(i),e=Fy.bind(null,e,n,i),n.then(e,e))}function lf(e){do{var n;if((n=e.tag===13)&&(n=e.memoizedState,n=n!==null?n.dehydrated!==null:!0),n)return e;e=e.return}while(e!==null);return null}function af(e,n,i,l,f){return(e.mode&1)===0?(e===n?e.flags|=65536:(e.flags|=128,i.flags|=131072,i.flags&=-52805,i.tag===1&&(i.alternate===null?i.tag=17:(n=Jn(-1,1),n.tag=2,Sr(i,n,1))),i.lanes|=1),e):(e.flags|=65536,e.lanes=f,e)}var Ey=j.ReactCurrentOwner,Lt=!1;function Ct(e,n,i,l){n.child=e===null?Ed(n,null,i,l):zi(n,e.child,i,l)}function uf(e,n,i,l,f){i=i.render;var g=n.ref;return Oi(n,f),l=Ga(e,n,i,l,g,f),i=Ya(),e!==null&&!Lt?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~f,er(e,n,f)):(Xe&&i&&Ma(n),n.flags|=1,Ct(e,n,l,f),n.child)}function cf(e,n,i,l,f){if(e===null){var g=i.type;return typeof g=="function"&&!ku(g)&&g.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(n.tag=15,n.type=g,df(e,n,g,l,f)):(e=sl(i.type,null,l,n,n.mode,f),e.ref=n.ref,e.return=n,n.child=e)}if(g=e.child,(e.lanes&f)===0){var S=g.memoizedProps;if(i=i.compare,i=i!==null?i:ko,i(S,l)&&e.ref===n.ref)return er(e,n,f)}return n.flags|=1,e=Cr(g,l),e.ref=n.ref,e.return=n,n.child=e}function df(e,n,i,l,f){if(e!==null){var g=e.memoizedProps;if(ko(g,l)&&e.ref===n.ref)if(Lt=!1,n.pendingProps=l=g,(e.lanes&f)!==0)(e.flags&131072)!==0&&(Lt=!0);else return n.lanes=e.lanes,er(e,n,f)}return nu(e,n,i,l,f)}function ff(e,n,i){var l=n.pendingProps,f=l.children,g=e!==null?e.memoizedState:null;if(l.mode==="hidden")if((n.mode&1)===0)n.memoizedState={baseLanes:0,cachePool:null,transitions:null},Be(Vi,Gt),Gt|=i;else{if((i&1073741824)===0)return e=g!==null?g.baseLanes|i:i,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:e,cachePool:null,transitions:null},n.updateQueue=null,Be(Vi,Gt),Gt|=e,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=g!==null?g.baseLanes:i,Be(Vi,Gt),Gt|=l}else g!==null?(l=g.baseLanes|i,n.memoizedState=null):l=i,Be(Vi,Gt),Gt|=l;return Ct(e,n,f,i),n.child}function hf(e,n){var i=n.ref;(e===null&&i!==null||e!==null&&e.ref!==i)&&(n.flags|=512,n.flags|=2097152)}function nu(e,n,i,l,f){var g=Tt(i)?Qr:St.current;return g=Ti(n,g),Oi(n,f),i=Ga(e,n,i,l,g,f),l=Ya(),e!==null&&!Lt?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~f,er(e,n,f)):(Xe&&l&&Ma(n),n.flags|=1,Ct(e,n,i,f),n.child)}function pf(e,n,i,l,f){if(Tt(i)){var g=!0;Is(n)}else g=!1;if(Oi(n,f),n.stateNode===null)qs(e,n),tf(n,i,l),Ja(n,i,l,f),l=!0;else if(e===null){var S=n.stateNode,T=n.memoizedProps;S.props=T;var O=S.context,J=i.contextType;typeof J=="object"&&J!==null?J=Zt(J):(J=Tt(i)?Qr:St.current,J=Ti(n,J));var ae=i.getDerivedStateFromProps,ue=typeof ae=="function"||typeof S.getSnapshotBeforeUpdate=="function";ue||typeof S.UNSAFE_componentWillReceiveProps!="function"&&typeof S.componentWillReceiveProps!="function"||(T!==l||O!==J)&&nf(n,S,l,J),_r=!1;var le=n.memoizedState;S.state=le,Fs(n,l,S,f),O=n.memoizedState,T!==l||le!==O||Rt.current||_r?(typeof ae=="function"&&(Za(n,i,ae,l),O=n.memoizedState),(T=_r||ef(n,i,T,l,le,O,J))?(ue||typeof S.UNSAFE_componentWillMount!="function"&&typeof S.componentWillMount!="function"||(typeof S.componentWillMount=="function"&&S.componentWillMount(),typeof S.UNSAFE_componentWillMount=="function"&&S.UNSAFE_componentWillMount()),typeof S.componentDidMount=="function"&&(n.flags|=4194308)):(typeof S.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=l,n.memoizedState=O),S.props=l,S.state=O,S.context=J,l=T):(typeof S.componentDidMount=="function"&&(n.flags|=4194308),l=!1)}else{S=n.stateNode,Md(e,n),T=n.memoizedProps,J=n.type===n.elementType?T:an(n.type,T),S.props=J,ue=n.pendingProps,le=S.context,O=i.contextType,typeof O=="object"&&O!==null?O=Zt(O):(O=Tt(i)?Qr:St.current,O=Ti(n,O));var ge=i.getDerivedStateFromProps;(ae=typeof ge=="function"||typeof S.getSnapshotBeforeUpdate=="function")||typeof S.UNSAFE_componentWillReceiveProps!="function"&&typeof S.componentWillReceiveProps!="function"||(T!==ue||le!==O)&&nf(n,S,l,O),_r=!1,le=n.memoizedState,S.state=le,Fs(n,l,S,f);var xe=n.memoizedState;T!==ue||le!==xe||Rt.current||_r?(typeof ge=="function"&&(Za(n,i,ge,l),xe=n.memoizedState),(J=_r||ef(n,i,J,l,le,xe,O)||!1)?(ae||typeof S.UNSAFE_componentWillUpdate!="function"&&typeof S.componentWillUpdate!="function"||(typeof S.componentWillUpdate=="function"&&S.componentWillUpdate(l,xe,O),typeof S.UNSAFE_componentWillUpdate=="function"&&S.UNSAFE_componentWillUpdate(l,xe,O)),typeof S.componentDidUpdate=="function"&&(n.flags|=4),typeof S.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof S.componentDidUpdate!="function"||T===e.memoizedProps&&le===e.memoizedState||(n.flags|=4),typeof S.getSnapshotBeforeUpdate!="function"||T===e.memoizedProps&&le===e.memoizedState||(n.flags|=1024),n.memoizedProps=l,n.memoizedState=xe),S.props=l,S.state=xe,S.context=O,l=J):(typeof S.componentDidUpdate!="function"||T===e.memoizedProps&&le===e.memoizedState||(n.flags|=4),typeof S.getSnapshotBeforeUpdate!="function"||T===e.memoizedProps&&le===e.memoizedState||(n.flags|=1024),l=!1)}return ru(e,n,i,l,g,f)}function ru(e,n,i,l,f,g){hf(e,n);var S=(n.flags&128)!==0;if(!l&&!S)return f&&vd(n,i,!1),er(e,n,g);l=n.stateNode,Ey.current=n;var T=S&&typeof i.getDerivedStateFromError!="function"?null:l.render();return n.flags|=1,e!==null&&S?(n.child=zi(n,e.child,null,g),n.child=zi(n,null,T,g)):Ct(e,n,T,g),n.memoizedState=l.state,f&&vd(n,i,!0),n.child}function gf(e){var n=e.stateNode;n.pendingContext?md(e,n.pendingContext,n.pendingContext!==n.context):n.context&&md(e,n.context,!1),Fa(e,n.containerInfo)}function mf(e,n,i,l,f){return $i(),Ta(f),n.flags|=256,Ct(e,n,i,l),n.child}var iu={dehydrated:null,treeContext:null,retryLane:0};function ou(e){return{baseLanes:e,cachePool:null,transitions:null}}function yf(e,n,i){var l=n.pendingProps,f=qe.current,g=!1,S=(n.flags&128)!==0,T;if((T=S)||(T=e!==null&&e.memoizedState===null?!1:(f&2)!==0),T?(g=!0,n.flags&=-129):(e===null||e.memoizedState!==null)&&(f|=1),Be(qe,f&1),e===null)return Ra(n),e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?((n.mode&1)===0?n.lanes=1:e.data==="$!"?n.lanes=8:n.lanes=1073741824,null):(S=l.children,e=l.fallback,g?(l=n.mode,g=n.child,S={mode:"hidden",children:S},(l&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=S):g=ll(S,l,0,null),e=li(e,l,i,null),g.return=n,e.return=n,g.sibling=e,n.child=g,n.child.memoizedState=ou(i),n.memoizedState=iu,e):su(n,S));if(f=e.memoizedState,f!==null&&(T=f.dehydrated,T!==null))return Cy(e,n,S,l,T,f,i);if(g){g=l.fallback,S=n.mode,f=e.child,T=f.sibling;var O={mode:"hidden",children:l.children};return(S&1)===0&&n.child!==f?(l=n.child,l.childLanes=0,l.pendingProps=O,n.deletions=null):(l=Cr(f,O),l.subtreeFlags=f.subtreeFlags&14680064),T!==null?g=Cr(T,g):(g=li(g,S,i,null),g.flags|=2),g.return=n,l.return=n,l.sibling=g,n.child=l,l=g,g=n.child,S=e.child.memoizedState,S=S===null?ou(i):{baseLanes:S.baseLanes|i,cachePool:null,transitions:S.transitions},g.memoizedState=S,g.childLanes=e.childLanes&~i,n.memoizedState=iu,l}return g=e.child,e=g.sibling,l=Cr(g,{mode:"visible",children:l.children}),(n.mode&1)===0&&(l.lanes=i),l.return=n,l.sibling=null,e!==null&&(i=n.deletions,i===null?(n.deletions=[e],n.flags|=16):i.push(e)),n.child=l,n.memoizedState=null,l}function su(e,n){return n=ll({mode:"visible",children:n},e.mode,0,null),n.return=e,e.child=n}function Xs(e,n,i,l){return l!==null&&Ta(l),zi(n,e.child,null,i),e=su(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Cy(e,n,i,l,f,g,S){if(i)return n.flags&256?(n.flags&=-257,l=eu(Error(o(422))),Xs(e,n,S,l)):n.memoizedState!==null?(n.child=e.child,n.flags|=128,null):(g=l.fallback,f=n.mode,l=ll({mode:"visible",children:l.children},f,0,null),g=li(g,f,S,null),g.flags|=2,l.return=n,g.return=n,l.sibling=g,n.child=l,(n.mode&1)!==0&&zi(n,e.child,null,S),n.child.memoizedState=ou(S),n.memoizedState=iu,g);if((n.mode&1)===0)return Xs(e,n,S,null);if(f.data==="$!"){if(l=f.nextSibling&&f.nextSibling.dataset,l)var T=l.dgst;return l=T,g=Error(o(419)),l=eu(g,l,void 0),Xs(e,n,S,l)}if(T=(S&e.childLanes)!==0,Lt||T){if(l=ht,l!==null){switch(S&-S){case 4:f=2;break;case 16:f=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:f=32;break;case 536870912:f=268435456;break;default:f=0}f=(f&(l.suspendedLanes|S))!==0?0:f,f!==0&&f!==g.retryLane&&(g.retryLane=f,Zn(e,f),dn(l,e,f,-1))}return Su(),l=eu(Error(o(421))),Xs(e,n,S,l)}return f.data==="$?"?(n.flags|=128,n.child=e.child,n=Hy.bind(null,e),f._reactRetry=n,null):(e=g.treeContext,Ut=yr(f.nextSibling),Wt=n,Xe=!0,ln=null,e!==null&&(Kt[Qt++]=Kn,Kt[Qt++]=Qn,Kt[Qt++]=Zr,Kn=e.id,Qn=e.overflow,Zr=n),n=su(n,l.children),n.flags|=4096,n)}function vf(e,n,i){e.lanes|=n;var l=e.alternate;l!==null&&(l.lanes|=n),za(e.return,n,i)}function lu(e,n,i,l,f){var g=e.memoizedState;g===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:l,tail:i,tailMode:f}:(g.isBackwards=n,g.rendering=null,g.renderingStartTime=0,g.last=l,g.tail=i,g.tailMode=f)}function xf(e,n,i){var l=n.pendingProps,f=l.revealOrder,g=l.tail;if(Ct(e,n,l.children,i),l=qe.current,(l&2)!==0)l=l&1|2,n.flags|=128;else{if(e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&vf(e,i,n);else if(e.tag===19)vf(e,i,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}l&=1}if(Be(qe,l),(n.mode&1)===0)n.memoizedState=null;else switch(f){case"forwards":for(i=n.child,f=null;i!==null;)e=i.alternate,e!==null&&Hs(e)===null&&(f=i),i=i.sibling;i=f,i===null?(f=n.child,n.child=null):(f=i.sibling,i.sibling=null),lu(n,!1,f,i,g);break;case"backwards":for(i=null,f=n.child,n.child=null;f!==null;){if(e=f.alternate,e!==null&&Hs(e)===null){n.child=f;break}e=f.sibling,f.sibling=i,i=f,f=e}lu(n,!0,i,null,g);break;case"together":lu(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function qs(e,n){(n.mode&1)===0&&e!==null&&(e.alternate=null,n.alternate=null,n.flags|=2)}function er(e,n,i){if(e!==null&&(n.dependencies=e.dependencies),ri|=n.lanes,(i&n.childLanes)===0)return null;if(e!==null&&n.child!==e.child)throw Error(o(153));if(n.child!==null){for(e=n.child,i=Cr(e,e.pendingProps),n.child=i,i.return=n;e.sibling!==null;)e=e.sibling,i=i.sibling=Cr(e,e.pendingProps),i.return=n;i.sibling=null}return n.child}function My(e,n,i){switch(n.tag){case 3:gf(n),$i();break;case 5:Rd(n);break;case 1:Tt(n.type)&&Is(n);break;case 4:Fa(n,n.stateNode.containerInfo);break;case 10:var l=n.type._context,f=n.memoizedProps.value;Be(zs,l._currentValue),l._currentValue=f;break;case 13:if(l=n.memoizedState,l!==null)return l.dehydrated!==null?(Be(qe,qe.current&1),n.flags|=128,null):(i&n.child.childLanes)!==0?yf(e,n,i):(Be(qe,qe.current&1),e=er(e,n,i),e!==null?e.sibling:null);Be(qe,qe.current&1);break;case 19:if(l=(i&n.childLanes)!==0,(e.flags&128)!==0){if(l)return xf(e,n,i);n.flags|=128}if(f=n.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),Be(qe,qe.current),l)break;return null;case 22:case 23:return n.lanes=0,ff(e,n,i)}return er(e,n,i)}var wf,au,_f,Sf;wf=function(e,n){for(var i=n.child;i!==null;){if(i.tag===5||i.tag===6)e.appendChild(i.stateNode);else if(i.tag!==4&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===n)break;for(;i.sibling===null;){if(i.return===null||i.return===n)return;i=i.return}i.sibling.return=i.return,i=i.sibling}},au=function(){},_f=function(e,n,i,l){var f=e.memoizedProps;if(f!==l){e=n.stateNode,ti(Mn.current);var g=null;switch(i){case"input":f=Ne(e,f),l=Ne(e,l),g=[];break;case"select":f=F({},f,{value:void 0}),l=F({},l,{value:void 0}),g=[];break;case"textarea":f=wt(e,f),l=wt(e,l),g=[];break;default:typeof f.onClick!="function"&&typeof l.onClick=="function"&&(e.onclick=Cs)}$r(i,l);var S;i=null;for(J in f)if(!l.hasOwnProperty(J)&&f.hasOwnProperty(J)&&f[J]!=null)if(J==="style"){var T=f[J];for(S in T)T.hasOwnProperty(S)&&(i||(i={}),i[S]="")}else J!=="dangerouslySetInnerHTML"&&J!=="children"&&J!=="suppressContentEditableWarning"&&J!=="suppressHydrationWarning"&&J!=="autoFocus"&&(a.hasOwnProperty(J)?g||(g=[]):(g=g||[]).push(J,null));for(J in l){var O=l[J];if(T=f!=null?f[J]:void 0,l.hasOwnProperty(J)&&O!==T&&(O!=null||T!=null))if(J==="style")if(T){for(S in T)!T.hasOwnProperty(S)||O&&O.hasOwnProperty(S)||(i||(i={}),i[S]="");for(S in O)O.hasOwnProperty(S)&&T[S]!==O[S]&&(i||(i={}),i[S]=O[S])}else i||(g||(g=[]),g.push(J,i)),i=O;else J==="dangerouslySetInnerHTML"?(O=O?O.__html:void 0,T=T?T.__html:void 0,O!=null&&T!==O&&(g=g||[]).push(J,O)):J==="children"?typeof O!="string"&&typeof O!="number"||(g=g||[]).push(J,""+O):J!=="suppressContentEditableWarning"&&J!=="suppressHydrationWarning"&&(a.hasOwnProperty(J)?(O!=null&&J==="onScroll"&&We("scroll",e),g||T===O||(g=[])):(g=g||[]).push(J,O))}i&&(g=g||[]).push("style",i);var J=g;(n.updateQueue=J)&&(n.flags|=4)}},Sf=function(e,n,i,l){i!==l&&(n.flags|=4)};function Do(e,n){if(!Xe)switch(e.tailMode){case"hidden":n=e.tail;for(var i=null;n!==null;)n.alternate!==null&&(i=n),n=n.sibling;i===null?e.tail=null:i.sibling=null;break;case"collapsed":i=e.tail;for(var l=null;i!==null;)i.alternate!==null&&(l=i),i=i.sibling;l===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function Nt(e){var n=e.alternate!==null&&e.alternate.child===e.child,i=0,l=0;if(n)for(var f=e.child;f!==null;)i|=f.lanes|f.childLanes,l|=f.subtreeFlags&14680064,l|=f.flags&14680064,f.return=e,f=f.sibling;else for(f=e.child;f!==null;)i|=f.lanes|f.childLanes,l|=f.subtreeFlags,l|=f.flags,f.return=e,f=f.sibling;return e.subtreeFlags|=l,e.childLanes=i,n}function Py(e,n,i){var l=n.pendingProps;switch(Pa(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Nt(n),null;case 1:return Tt(n.type)&&Ps(),Nt(n),null;case 3:return l=n.stateNode,Fi(),Ue(Rt),Ue(St),Va(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(As(n)?n.flags|=4:e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,ln!==null&&(xu(ln),ln=null))),au(e,n),Nt(n),null;case 5:Ha(n);var f=ti(To.current);if(i=n.type,e!==null&&n.stateNode!=null)_f(e,n,i,l,f),e.ref!==n.ref&&(n.flags|=512,n.flags|=2097152);else{if(!l){if(n.stateNode===null)throw Error(o(166));return Nt(n),null}if(e=ti(Mn.current),As(n)){l=n.stateNode,i=n.type;var g=n.memoizedProps;switch(l[Cn]=n,l[Co]=g,e=(n.mode&1)!==0,i){case"dialog":We("cancel",l),We("close",l);break;case"iframe":case"object":case"embed":We("load",l);break;case"video":case"audio":for(f=0;f<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=S.createElement(i,{is:l.is}):(e=S.createElement(i),i==="select"&&(S=e,l.multiple?S.multiple=!0:l.size&&(S.size=l.size))):e=S.createElementNS(e,i),e[Cn]=n,e[Co]=l,wf(e,n,!1,!1),n.stateNode=e;e:{switch(S=zn(i,l),i){case"dialog":We("cancel",e),We("close",e),f=l;break;case"iframe":case"object":case"embed":We("load",e),f=l;break;case"video":case"audio":for(f=0;fWi&&(n.flags|=128,l=!0,Do(g,!1),n.lanes=4194304)}else{if(!l)if(e=Hs(S),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Do(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Xe)return Nt(n),null}else 2*Ve()-g.renderingStartTime>Wi&&i!==1073741824&&(n.flags|=128,l=!0,Do(g,!1),n.lanes=4194304);g.isBackwards?(S.sibling=n.child,n.child=S):(i=g.last,i!==null?i.sibling=S:n.child=S,g.last=S)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(Nt(n),null);case 22:case 23:return _u(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Gt&1073741824)!==0&&(Nt(n),n.subtreeFlags&6&&(n.flags|=8192)):Nt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function Iy(e,n){switch(Pa(n),n.tag){case 1:return Tt(n.type)&&Ps(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Fi(),Ue(Rt),Ue(St),Va(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Ha(n),null;case 13:if(Ue(qe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));$i()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Fi(),null;case 10:return $a(n.type._context),null;case 22:case 23:return _u(),null;case 24:return null;default:return null}}var Ks=!1,jt=!1,Ry=typeof WeakSet=="function"?WeakSet:Set,ye=null;function Bi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Ze(e,n,l)}else i.current=null}function uu(e,n,i){try{i()}catch(l){Ze(e,n,l)}}var kf=!1;function Ty(e,n){if(_a=ms,e=ed(),ha(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,g=l.focusNode;l=l.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var S=0,T=-1,O=-1,J=0,ae=0,ue=e,le=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=S+f),ue!==g||l!==0&&ue.nodeType!==3||(O=S+l),ue.nodeType===3&&(S+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)le=ue,ue=ge;for(;;){if(ue===e)break t;if(le===i&&++J===f&&(T=S),le===g&&++ae===l&&(O=S),(ge=ue.nextSibling)!==null)break;ue=le,le=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(Sa={focusedElem:e,selectionRange:i},ms=!1,ye=n;ye!==null;)if(n=ye,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ye=e;else for(;ye!==null;){n=ye;try{var xe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var we=xe.memoizedProps,et=xe.memoizedState,X=n.stateNode,H=X.getSnapshotBeforeUpdate(n.elementType===n.type?we:an(n.type,we),et);X.__reactInternalSnapshotBeforeUpdate=H}break;case 3:var K=n.stateNode.containerInfo;K.nodeType===1?K.textContent="":K.nodeType===9&&K.documentElement&&K.removeChild(K.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(de){Ze(n,n.return,de)}if(e=n.sibling,e!==null){e.return=n.return,ye=e;break}ye=n.return}return xe=kf,kf=!1,xe}function Oo(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&e)===e){var g=f.destroy;f.destroy=void 0,g!==void 0&&uu(n,i,g)}f=f.next}while(f!==l)}}function Qs(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function cu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function Nf(e){var n=e.alternate;n!==null&&(e.alternate=null,Nf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[Cn],delete n[Co],delete n[ba],delete n[gy],delete n[my])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function jf(e){return e.tag===5||e.tag===3||e.tag===4}function bf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||jf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function du(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=Cs));else if(l!==4&&(e=e.child,e!==null))for(du(e,n,i),e=e.sibling;e!==null;)du(e,n,i),e=e.sibling}function fu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(fu(e,n,i),e=e.sibling;e!==null;)fu(e,n,i),e=e.sibling}var vt=null,un=!1;function kr(e,n,i){for(i=i.child;i!==null;)Ef(e,n,i),i=i.sibling}function Ef(e,n,i){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(Vn,i)}catch{}switch(i.tag){case 5:jt||Bi(i,n);case 6:var l=vt,f=un;vt=null,kr(e,n,i),vt=l,un=f,vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):vt.removeChild(i.stateNode));break;case 18:vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?ja(e.parentNode,i):e.nodeType===1&&ja(e,i),yo(e)):ja(vt,i.stateNode));break;case 4:l=vt,f=un,vt=i.stateNode.containerInfo,un=!0,kr(e,n,i),vt=l,un=f;break;case 0:case 11:case 14:case 15:if(!jt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var g=f,S=g.destroy;g=g.tag,S!==void 0&&((g&2)!==0||(g&4)!==0)&&uu(i,n,S),f=f.next}while(f!==l)}kr(e,n,i);break;case 1:if(!jt&&(Bi(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Ze(i,n,T)}kr(e,n,i);break;case 21:kr(e,n,i);break;case 22:i.mode&1?(jt=(l=jt)||i.memoizedState!==null,kr(e,n,i),jt=l):kr(e,n,i);break;default:kr(e,n,i)}}function Cf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Ry),n.forEach(function(l){var f=By.bind(null,e,l);i.has(l)||(i.add(l),l.then(f,f))})}}function cn(e,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=S),l&=~g}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Ay(l/1960))-l,10e?16:e,jr===null)var l=!1;else{if(e=jr,jr=null,nl=0,(ze&6)!==0)throw Error(o(331));var f=ze;for(ze|=4,ye=e.current;ye!==null;){var g=ye,S=g.child;if((ye.flags&16)!==0){var T=g.deletions;if(T!==null){for(var O=0;OVe()-gu?oi(e,0):pu|=i),$t(e,n)}function Hf(e,n){n===0&&((e.mode&1)===0?n=1:(n=Un,Un<<=1,(Un&130023424)===0&&(Un=4194304)));var i=Mt();e=Zn(e,n),e!==null&&(En(e,n,i),$t(e,i))}function Hy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Hf(e,i)}function By(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Hf(e,i)}var Bf;Bf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Rt.current)Lt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Lt=!1,My(e,n,i);Lt=(e.flags&131072)!==0}else Lt=!1,Xe&&(n.flags&1048576)!==0&&wd(n,Ls,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;qs(e,n),e=n.pendingProps;var f=Ti(n,St.current);Oi(n,i),f=Ga(null,n,l,e,f,i);var g=Ya();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Tt(l)?(g=!0,Is(n)):g=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Oa(n),f.updater=Ys,n.stateNode=f,f._reactInternals=n,Ja(n,l,e,i),n=ru(null,n,l,!0,g,i)):(n.tag=0,Xe&&g&&Ma(n),Ct(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(qs(e,n),e=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=Wy(l),e=an(l,e),f){case 0:n=nu(null,n,l,e,i);break e;case 1:n=pf(null,n,l,e,i);break e;case 11:n=uf(null,n,l,e,i);break e;case 14:n=cf(null,n,l,an(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),nu(e,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),pf(e,n,l,f,i);case 3:e:{if(gf(n),e===null)throw Error(o(387));l=n.pendingProps,g=n.memoizedState,f=g.element,Md(e,n),Fs(n,l,null,i);var S=n.memoizedState;if(l=S.element,g.isDehydrated)if(g={element:l,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){f=Hi(Error(o(423)),n),n=mf(e,n,l,i,f);break e}else if(l!==f){f=Hi(Error(o(424)),n),n=mf(e,n,l,i,f);break e}else for(Ut=yr(n.stateNode.containerInfo.firstChild),Wt=n,Xe=!0,ln=null,i=Ed(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if($i(),l===f){n=er(e,n,i);break e}Ct(e,n,l,i)}n=n.child}return n;case 5:return Rd(n),e===null&&Ra(n),l=n.type,f=n.pendingProps,g=e!==null?e.memoizedProps:null,S=f.children,ka(l,f)?S=null:g!==null&&ka(l,g)&&(n.flags|=32),hf(e,n),Ct(e,n,S,i),n.child;case 6:return e===null&&Ra(n),null;case 13:return yf(e,n,i);case 4:return Fa(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=zi(n,null,l,i):Ct(e,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),uf(e,n,l,f,i);case 7:return Ct(e,n,n.pendingProps,i),n.child;case 8:return Ct(e,n,n.pendingProps.children,i),n.child;case 12:return Ct(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,g=n.memoizedProps,S=f.value,Be(zs,l._currentValue),l._currentValue=S,g!==null)if(sn(g.value,S)){if(g.children===f.children&&!Rt.current){n=er(e,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var T=g.dependencies;if(T!==null){S=g.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(g.tag===1){O=Jn(-1,i&-i),O.tag=2;var J=g.updateQueue;if(J!==null){J=J.shared;var ae=J.pending;ae===null?O.next=O:(O.next=ae.next,ae.next=O),J.pending=O}}g.lanes|=i,O=g.alternate,O!==null&&(O.lanes|=i),za(g.return,i,n),T.lanes|=i;break}O=O.next}}else if(g.tag===10)S=g.type===n.type?null:g.child;else if(g.tag===18){if(S=g.return,S===null)throw Error(o(341));S.lanes|=i,T=S.alternate,T!==null&&(T.lanes|=i),za(S,i,n),S=g.sibling}else S=g.child;if(S!==null)S.return=g;else for(S=g;S!==null;){if(S===n){S=null;break}if(g=S.sibling,g!==null){g.return=S.return,S=g;break}S=S.return}g=S}Ct(e,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,Oi(n,i),f=Zt(f),l=l(f),n.flags|=1,Ct(e,n,l,i),n.child;case 14:return l=n.type,f=an(l,n.pendingProps),f=an(l.type,f),cf(e,n,l,f,i);case 15:return df(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),qs(e,n),n.tag=1,Tt(l)?(e=!0,Is(n)):e=!1,Oi(n,i),tf(n,l,f),Ja(n,l,f,i),ru(null,n,l,!0,e,i);case 19:return xf(e,n,i);case 22:return ff(e,n,i)}throw Error(o(156,n.tag))};function Vf(e,n){return Hr(e,n)}function Vy(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tn(e,n,i,l){return new Vy(e,n,i,l)}function ku(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Wy(e){if(typeof e=="function")return ku(e)?1:0;if(e!=null){if(e=e.$$typeof,e===te)return 11;if(e===V)return 14}return 2}function Cr(e,n){var i=e.alternate;return i===null?(i=tn(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function sl(e,n,i,l,f,g){var S=2;if(l=e,typeof e=="function")ku(e)&&(S=1);else if(typeof e=="string")S=5;else e:switch(e){case B:return li(i.children,f,g,n);case Y:S=8,f|=8;break;case Q:return e=tn(12,i,n,f|2),e.elementType=Q,e.lanes=g,e;case q:return e=tn(13,i,n,f),e.elementType=q,e.lanes=g,e;case C:return e=tn(19,i,n,f),e.elementType=C,e.lanes=g,e;case U:return ll(i,f,g,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ne:S=10;break e;case ee:S=9;break e;case te:S=11;break e;case V:S=14;break e;case W:S=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=tn(S,i,n,f),n.elementType=e,n.type=l,n.lanes=g,n}function li(e,n,i,l){return e=tn(7,e,l,n),e.lanes=i,e}function ll(e,n,i,l){return e=tn(22,e,l,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function Nu(e,n,i){return e=tn(6,e,null,n),e.lanes=i,e}function ju(e,n,i){return n=tn(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Uy(e,n,i,l,f){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Gn(0),this.expirationTimes=Gn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Gn(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function bu(e,n,i,l,f,g,S,T,O){return e=new Uy(e,n,i,T,O),n===1?(n=1,g===!0&&(n|=8)):n=0,g=tn(3,null,null,n),e.current=g,g.stateNode=e,g.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Oa(g),e}function Gy(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),Ru.exports=i0(),Ru.exports}var rh;function o0(){if(rh)return pl;rh=1;var t=kp();return pl.createRoot=t.createRoot,pl.hydrateRoot=t.hydrateRoot,pl}var s0=o0();function Np(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Ae(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(Np(s,o.statusText||"Request failed"))}return o.json()}const l0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Pe={health:()=>Ae("/api/health"),settings:()=>Ae("/api/settings"),saveSettings:t=>{const r={...t};for(const o of l0)r[o]===""&&delete r[o];return Ae("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ae("/api/repos"),browse:t=>Ae(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ae(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ae("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ae(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Ae(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:(t,r=!0)=>Ae(`/api/architecture?repo_path=${encodeURIComponent(t)}&graph=${r?"1":"0"}`),architectureGraph:t=>Ae(`/api/architecture/graph?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Ae("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Ae("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Ae("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Ae("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Ae("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Ae(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open",s)=>Ae("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o,repo_path:s||null})}),scmRepos:t=>Ae(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ae("/api/oauth/status"),githubOAuthStart:()=>Ae("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ae("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ae("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Ae("/api/oauth/gitlab/start"),oauthDisconnect:t=>Ae("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ae("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})}),reviews:t=>Ae(`/api/reviews?repo_path=${encodeURIComponent(t)}`),getReview:(t,r)=>Ae(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(t)}`),reviewDiff:(t,r,o)=>Ae(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(t)}&other=${encodeURIComponent(o)}`),config:t=>Ae(`/api/config?repo_path=${encodeURIComponent(t)}`),saveConfig:(t,r)=>Ae("/api/config",{method:"PUT",body:JSON.stringify({repo_path:t,...r})}),addWaiver:(t,r,o,s)=>Ae("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:t,rule:r,node:o||null,reason:s||""})}),marks:(t,r)=>Ae(`/api/marks?repo_path=${encodeURIComponent(t)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:t=>Ae(`/api/architecture/health?repo_path=${encodeURIComponent(t)}`),workspaceStatus:t=>Ae(`/api/workspace/status?repo_path=${encodeURIComponent(t)}`),openEditor:(t,r,o,s)=>Ae("/api/open",{method:"POST",body:JSON.stringify({repo_path:t,path:r,line:o||null,editor:s||null})}),exportHtml:t=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:t})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(Np(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(t,r,o,s)=>Ae("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:t,edges:r,source_id:o,target_id:s||null})})};function a0(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):t}function u0({open:t,actions:r,onClose:o}){const[s,a]=L.useState(""),[u,c]=L.useState(0),h=L.useRef(null),p=L.useMemo(()=>a0(r,s),[r,s]);if(L.useEffect(()=>{if(!t)return;a(""),c(0);const y=window.setTimeout(()=>{var m;return(m=h.current)==null?void 0:m.focus()},0);return()=>window.clearTimeout(y)},[t]),L.useEffect(()=>{c(0)},[s]),!t)return null;const v=p[u],x=y=>{y&&(o(),y.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:y=>{y.target===y.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:y=>a(y.target.value),onKeyDown:y=>{y.key==="Escape"?(y.preventDefault(),o()):y.key==="ArrowDown"?(y.preventDefault(),c(m=>Math.min(p.length-1,m+1))):y.key==="ArrowUp"?(y.preventDefault(),c(m=>Math.max(0,m-1))):y.key==="Enter"&&(y.preventDefault(),x(v))}}),d.jsxs("ul",{children:[p.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,p.slice(0,40).map((y,m)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:m===u?"active":"",onMouseEnter:()=>c(m),onClick:()=>x(y),children:[d.jsx("span",{children:y.label}),y.hint?d.jsx("span",{className:"muted",children:y.hint}):null]})},y.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function c0({config:t,busy:r,onSave:o,onWaiver:s}){const[a,u]=L.useState(t),[c,h]=L.useState(t.available_rules[0]||""),[p,v]=L.useState(""),[x,y]=L.useState("");L.useEffect(()=>{u(t)},[t]);const m=Object.entries(a.contexts||{}),_=(P,w,j)=>{const $=a.contexts[P];if(!$)return;const z=B=>B.split(",").map(Y=>Y.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[P]:{...$,[w]:w==="name"?j:z(j)}}})},k=(P,w)=>{const j=w.trim();if(!j||j===P)return;const{[P]:$,...z}=a.contexts;$&&u({...a,contexts:{...z,[j]:{...$,name:j}}})},b=()=>{let P=1;for(;a.contexts[`context-${P}`];)P+=1;const w=`context-${P}`;u({...a,contexts:{...a.contexts,[w]:{name:w,django_apps:[],react:[],public_api:[],owners:[]}}})},E=P=>{const{[P]:w,...j}=a.contexts;u({...a,contexts:j})},N=P=>{const w=a.rules.includes(P);u({...a,rules:w?a.rules.filter(j=>j!==P):[...a.rules,P]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),m.map(([P,w])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:P})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:P,"data-testid":`config-context-name-${P}`,onBlur:j=>k(P,j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(w.django_apps||[]).join(", "),onChange:j=>_(P,"django_apps",j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(w.react||[]).join(", "),onChange:j=>_(P,"react",j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(w.public_api||[]).join(", "),onChange:j=>_(P,"public_api",j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(w.owners||[]).join(", "),onChange:j=>_(P,"owners",j.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>E(P),children:"Remove context"})]},P)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:b,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(P=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(P),onChange:()=>N(P)}),P]},P))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((P,w)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:P.rule}),P.node?` · ${P.node}`:"",P.reason?` — ${P.reason}`:""]},`${P.rule}:${P.node}:${w}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:P=>h(P.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(P=>d.jsx("option",{value:P,children:P},P))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:P=>v(P.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:x,onChange:P=>y(P.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,x),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function Qo(t){return t.replaceAll("_"," ")}function d0(t){return t.replaceAll("_"," ")}function ro(t){return t.split(".").pop()||t}function Qu(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function f0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Tr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function yi({className:t,children:r}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function h0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function p0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function g0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function m0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function y0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function jp({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function v0({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const x0="modulepreload",w0=function(t,r){return new URL(t,r).href},ih={},_0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(x){return Promise.all(x.map(y=>Promise.resolve(y).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),v=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(x=>{if(x=w0(x,s),x in ih)return;ih[x]=!0;const y=x.endsWith(".css"),m=y?'[rel="stylesheet"]':"";if(!!s)for(let b=h.length-1;b>=0;b--){const E=h[b];if(E.href===x&&(!y||E.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${x}"]${m}`))return;const k=document.createElement("link");if(k.rel=y?"stylesheet":x0,y||(k.as="script"),k.crossOrigin="",k.href=x,v&&k.setAttribute("nonce",v),document.head.appendChild(k),y)return new Promise((b,E)=>{k.addEventListener("load",b),k.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${x}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function nt(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Bl(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}bl.prototype=Bl.prototype={constructor:bl,on:function(t,r){var o=this._,s=k0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),sh.hasOwnProperty(r)?{space:sh[r],local:t}:t}function j0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===Zu&&r.documentElement.namespaceURI===Zu?r.createElement(t):r.createElementNS(o,t)}}function b0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function bp(t){var r=Vl(t);return(r.local?b0:j0)(r)}function E0(){}function pc(t){return t==null?E0:function(){return this.querySelector(t)}}function C0(t){typeof t!="function"&&(t=pc(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=w&&(w=P+1);!($=E[w])&&++w=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function J0(t){t||(t=ev);function r(y,m){return y&&m?t(y.__data__,m.__data__):!y-!m}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function tv(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function nv(){return Array.from(this)}function rv(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?pv:typeof r=="function"?mv:gv)(t,r,o??"")):Ki(this.node(),t)}function Ki(t,r){return t.style.getPropertyValue(r)||Ip(t).getComputedStyle(t,null).getPropertyValue(r)}function vv(t){return function(){delete this[t]}}function xv(t,r){return function(){this[t]=r}}function wv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function _v(t,r){return arguments.length>1?this.each((r==null?vv:typeof r=="function"?wv:xv)(t,r)):this.node()[t]}function Rp(t){return t.trim().split(/^|\s+/)}function gc(t){return t.classList||new Tp(t)}function Tp(t){this._node=t,this._names=Rp(t.getAttribute("class")||"")}Tp.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Lp(t,r){for(var o=gc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function qv(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function Ju(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:v,dispatch:x}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:v,enumerable:!0,configurable:!0},_:{value:x}})}Ju.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function ox(t){return!t.ctrlKey&&!t.button}function sx(){return this.parentNode}function lx(t,r){return r??{x:t.x,y:t.y}}function ax(){return navigator.maxTouchPoints||"ontouchstart"in this}function Fp(){var t=ox,r=sx,o=lx,s=ax,a={},u=Bl("start","drag","end"),c=0,h,p,v,x,y=0;function m(j){j.on("mousedown.drag",_).filter(s).on("touchstart.drag",E).on("touchmove.drag",N,ix).on("touchend.drag touchcancel.drag",P).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(j,$){if(!(x||!t.call(this,j,$))){var z=w(this,r.call(this,j,$),j,$,"mouse");z&&(Yt(j.view).on("mousemove.drag",k,Zo).on("mouseup.drag",b,Zo),Dp(j.view),Au(j),v=!1,h=j.clientX,p=j.clientY,z("start",j))}}function k(j){if(Xi(j),!v){var $=j.clientX-h,z=j.clientY-p;v=$*$+z*z>y}a.mouse("drag",j)}function b(j){Yt(j.view).on("mousemove.drag mouseup.drag",null),Op(j.view,v),Xi(j),a.mouse("end",j)}function E(j,$){if(t.call(this,j,$)){var z=j.changedTouches,B=r.call(this,j,$),Y=z.length,Q,ne;for(Q=0;Q>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?ml(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?ml(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=cx.exec(t))?new Dt(r[1],r[2],r[3],1):(r=dx.exec(t))?new Dt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=fx.exec(t))?ml(r[1],r[2],r[3],r[4]):(r=hx.exec(t))?ml(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=px.exec(t))?hh(r[1],r[2]/100,r[3]/100,1):(r=gx.exec(t))?hh(r[1],r[2]/100,r[3]/100,r[4]):lh.hasOwnProperty(t)?ch(lh[t]):t==="transparent"?new Dt(NaN,NaN,NaN,0):null}function ch(t){return new Dt(t>>16&255,t>>8&255,t&255,1)}function ml(t,r,o,s){return s<=0&&(t=r=o=NaN),new Dt(t,r,o,s)}function vx(t){return t instanceof cs||(t=fi(t)),t?(t=t.rgb(),new Dt(t.r,t.g,t.b,t.opacity)):new Dt}function ec(t,r,o,s){return arguments.length===1?vx(t):new Dt(t,r,o,s??1)}function Dt(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}mc(Dt,ec,Hp(cs,{brighter(t){return t=t==null?Rl:Math.pow(Rl,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Jo:Math.pow(Jo,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Dt(ci(this.r),ci(this.g),ci(this.b),Tl(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:dh,formatHex:dh,formatHex8:xx,formatRgb:fh,toString:fh}));function dh(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}`}function xx(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}${ui((isNaN(this.opacity)?1:this.opacity)*255)}`}function fh(){const t=Tl(this.opacity);return`${t===1?"rgb(":"rgba("}${ci(this.r)}, ${ci(this.g)}, ${ci(this.b)}${t===1?")":`, ${t})`}`}function Tl(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ci(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ui(t){return t=ci(t),(t<16?"0":"")+t.toString(16)}function hh(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new hn(t,r,o,s)}function Bp(t){if(t instanceof hn)return new hn(t.h,t.s,t.l,t.opacity);if(t instanceof cs||(t=fi(t)),!t)return new hn;if(t instanceof hn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new hn(c,h,p,t.opacity)}function wx(t,r,o,s){return arguments.length===1?Bp(t):new hn(t,r,o,s??1)}function hn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}mc(hn,wx,Hp(cs,{brighter(t){return t=t==null?Rl:Math.pow(Rl,t),new hn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Jo:Math.pow(Jo,t),new hn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Dt($u(t>=240?t-240:t+120,a,s),$u(t,a,s),$u(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new hn(ph(this.h),yl(this.s),yl(this.l),Tl(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 t=Tl(this.opacity);return`${t===1?"hsl(":"hsla("}${ph(this.h)}, ${yl(this.s)*100}%, ${yl(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ph(t){return t=(t||0)%360,t<0?t+360:t}function yl(t){return Math.max(0,Math.min(1,t||0))}function $u(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const yc=t=>()=>t;function _x(t,r){return function(o){return t+o*r}}function Sx(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function kx(t){return(t=+t)==1?Vp:function(r,o){return o-r?Sx(r,o,t):yc(isNaN(r)?o:r)}}function Vp(t,r){var o=r-t;return o?_x(t,o):yc(isNaN(t)?r:t)}const Ll=(function t(r){var o=kx(r);function s(a,u){var c=o((a=ec(a)).r,(u=ec(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),v=Vp(a.opacity,u.opacity);return function(x){return a.r=c(x),a.g=h(x),a.b=p(x),a.opacity=v(x),a+""}}return s.gamma=t,s})(1);function Nx(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:Rn(s,a)})),o=zu.lastIndex;return o180?x+=360:x-v>180&&(v+=360),m.push({i:y.push(a(y)+"rotate(",null,s)-2,x:Rn(v,x)})):x&&y.push(a(y)+"rotate("+x+s)}function h(v,x,y,m){v!==x?m.push({i:y.push(a(y)+"skewX(",null,s)-2,x:Rn(v,x)}):x&&y.push(a(y)+"skewX("+x+s)}function p(v,x,y,m,_,k){if(v!==y||x!==m){var b=_.push(a(_)+"scale(",null,",",null,")");k.push({i:b-4,x:Rn(v,y)},{i:b-2,x:Rn(x,m)})}else(y!==1||m!==1)&&_.push(a(_)+"scale("+y+","+m+")")}return function(v,x){var y=[],m=[];return v=t(v),x=t(x),u(v.translateX,v.translateY,x.translateX,x.translateY,y,m),c(v.rotate,x.rotate,y,m),h(v.skewX,x.skewX,y,m),p(v.scaleX,v.scaleY,x.scaleX,x.scaleY,y,m),v=x=null,function(_){for(var k=-1,b=m.length,E;++k=0&&t._call.call(void 0,r),t=t._next;--Qi}function yh(){hi=($l=ts.now())+Wl,Qi=Yo=0;try{Ox()}finally{Qi=0,Hx(),hi=0}}function Fx(){var t=ts.now(),r=t-$l;r>Yp&&(Wl-=r,$l=t)}function Hx(){for(var t,r=Al,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:Al=o);Xo=t,rc(s)}function rc(t){if(!Qi){Yo&&(Yo=clearTimeout(Yo));var r=t-hi;r>24?(t<1/0&&(Yo=setTimeout(yh,t-ts.now()-Wl)),Uo&&(Uo=clearInterval(Uo))):(Uo||($l=ts.now(),Uo=setInterval(Fx,Yp)),Qi=1,Xp(yh))}}function vh(t,r,o){var s=new zl;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Bx=Bl("start","end","cancel","interrupt"),Vx=[],Kp=0,xh=1,ic=2,Cl=3,wh=4,oc=5,Ml=6;function Ul(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;Wx(t,o,{name:r,index:s,group:a,on:Bx,tween:Vx,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Kp})}function xc(t,r){var o=yn(t,r);if(o.state>Kp)throw new Error("too late; already scheduled");return o}function Ln(t,r){var o=yn(t,r);if(o.state>Cl)throw new Error("too late; already running");return o}function yn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Wx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=qp(u,0,o.time);function u(v){o.state=xh,o.timer.restart(c,o.delay,o.time),o.delay<=v&&c(v-o.delay)}function c(v){var x,y,m,_;if(o.state!==xh)return p();for(x in s)if(_=s[x],_.name===o.name){if(_.state===Cl)return vh(c);_.state===wh?(_.state=Ml,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete s[x]):+xic&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function ww(t,r,o){var s,a,u=xw(r)?xc:Ln;return function(){var c=u(this,t),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function _w(t,r){var o=this._id;return arguments.length<2?yn(this.node(),o).on.on(t):this.each(ww(o,t,r))}function Sw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function kw(){return this.on("end.remove",Sw(this._id))}function Nw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=pc(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function qw(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function rr(t,r,o){this.k=t,this.x=r,this.y=o}rr.prototype={constructor:rr,scale:function(t){return t===1?this:new rr(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new rr(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Gl=new rr(1,0,0);eg.prototype=rr.prototype;function eg(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Gl;return t.__zoom}function Du(t){t.stopImmediatePropagation()}function Go(t){t.preventDefault(),t.stopImmediatePropagation()}function Kw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Qw(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function _h(){return this.__zoom||Gl}function Zw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Jw(){return navigator.maxTouchPoints||"ontouchstart"in this}function e1(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function tg(){var t=Kw,r=Qw,o=e1,s=Zw,a=Jw,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=El,v=Bl("start","zoom","end"),x,y,m,_=500,k=150,b=0,E=10;function N(C){C.property("__zoom",_h).on("wheel.zoom",Y,{passive:!1}).on("mousedown.zoom",Q).on("dblclick.zoom",ne).filter(a).on("touchstart.zoom",ee).on("touchmove.zoom",te).on("touchend.zoom touchcancel.zoom",q).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}N.transform=function(C,V,W,U){var M=C.selection?C.selection():C;M.property("__zoom",_h),C!==M?$(C,V,W,U):M.interrupt().each(function(){z(this,arguments).event(U).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},N.scaleBy=function(C,V,W,U){N.scaleTo(C,function(){var M=this.__zoom.k,D=typeof V=="function"?V.apply(this,arguments):V;return M*D},W,U)},N.scaleTo=function(C,V,W,U){N.transform(C,function(){var M=r.apply(this,arguments),D=this.__zoom,F=W==null?j(M):typeof W=="function"?W.apply(this,arguments):W,R=D.invert(F),A=typeof V=="function"?V.apply(this,arguments):V;return o(w(P(D,A),F,R),M,c)},W,U)},N.translateBy=function(C,V,W,U){N.transform(C,function(){return o(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),r.apply(this,arguments),c)},null,U)},N.translateTo=function(C,V,W,U,M){N.transform(C,function(){var D=r.apply(this,arguments),F=this.__zoom,R=U==null?j(D):typeof U=="function"?U.apply(this,arguments):U;return o(Gl.translate(R[0],R[1]).scale(F.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),D,c)},U,M)};function P(C,V){return V=Math.max(u[0],Math.min(u[1],V)),V===C.k?C:new rr(V,C.x,C.y)}function w(C,V,W){var U=V[0]-W[0]*C.k,M=V[1]-W[1]*C.k;return U===C.x&&M===C.y?C:new rr(C.k,U,M)}function j(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function $(C,V,W,U){C.on("start.zoom",function(){z(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){z(this,arguments).event(U).end()}).tween("zoom",function(){var M=this,D=arguments,F=z(M,D).event(U),R=r.apply(M,D),A=W==null?j(R):typeof W=="function"?W.apply(M,D):W,ie=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),oe=M.__zoom,fe=typeof V=="function"?V.apply(M,D):V,he=p(oe.invert(A).concat(ie/oe.k),fe.invert(A).concat(ie/fe.k));return function(pe){if(pe===1)pe=fe;else{var Z=he(pe),se=ie/Z[2];pe=new rr(se,A[0]-Z[0]*se,A[1]-Z[1]*se)}F.zoom(null,pe)}})}function z(C,V,W){return!W&&C.__zooming||new B(C,V)}function B(C,V){this.that=C,this.args=V,this.active=0,this.sourceEvent=null,this.extent=r.apply(C,V),this.taps=0}B.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,V){return this.mouse&&C!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var V=Yt(this.that).datum();v.call(C,this.that,new qw(C,{sourceEvent:this.sourceEvent,target:N,transform:this.that.__zoom,dispatch:v}),V)}};function Y(C,...V){if(!t.apply(this,arguments))return;var W=z(this,V).event(C),U=this.__zoom,M=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,s.apply(this,arguments)))),D=fn(C);if(W.wheel)(W.mouse[0][0]!==D[0]||W.mouse[0][1]!==D[1])&&(W.mouse[1]=U.invert(W.mouse[0]=D)),clearTimeout(W.wheel);else{if(U.k===M)return;W.mouse=[D,U.invert(D)],Pl(this),W.start()}Go(C),W.wheel=setTimeout(F,k),W.zoom("mouse",o(w(P(U,M),W.mouse[0],W.mouse[1]),W.extent,c));function F(){W.wheel=null,W.end()}}function Q(C,...V){if(m||!t.apply(this,arguments))return;var W=C.currentTarget,U=z(this,V,!0).event(C),M=Yt(C.view).on("mousemove.zoom",A,!0).on("mouseup.zoom",ie,!0),D=fn(C,W),F=C.clientX,R=C.clientY;Dp(C.view),Du(C),U.mouse=[D,this.__zoom.invert(D)],Pl(this),U.start();function A(oe){if(Go(oe),!U.moved){var fe=oe.clientX-F,he=oe.clientY-R;U.moved=fe*fe+he*he>b}U.event(oe).zoom("mouse",o(w(U.that.__zoom,U.mouse[0]=fn(oe,W),U.mouse[1]),U.extent,c))}function ie(oe){M.on("mousemove.zoom mouseup.zoom",null),Op(oe.view,U.moved),Go(oe),U.event(oe).end()}}function ne(C,...V){if(t.apply(this,arguments)){var W=this.__zoom,U=fn(C.changedTouches?C.changedTouches[0]:C,this),M=W.invert(U),D=W.k*(C.shiftKey?.5:2),F=o(w(P(W,D),U,M),r.apply(this,V),c);Go(C),h>0?Yt(this).transition().duration(h).call($,F,U,C):Yt(this).call(N.transform,F,U,C)}}function ee(C,...V){if(t.apply(this,arguments)){var W=C.touches,U=W.length,M=z(this,V,C.changedTouches.length===U).event(C),D,F,R,A;for(Du(C),F=0;F`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},ns=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ng=["Enter"," ","Escape"],rg={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Zi;(function(t){t.Strict="strict",t.Loose="loose"})(Zi||(Zi={}));var di;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(di||(di={}));var rs;(function(t){t.Partial="partial",t.Full="full"})(rs||(rs={}));const ig={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Lr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Lr||(Lr={}));var is;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(is||(is={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const Sh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function og(t){return t===null?null:t?"valid":"invalid"}const sg=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,t1=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),_c=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),ds=(t,r=[0,0])=>{const{width:o,height:s}=vn(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},n1=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):_c(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,Yl(a,Dl(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?Xl(s):{x:0,y:0,width:0,height:0}},fs=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=Yl(o,Dl(a)),s=!0)}),s?Xl(o):{x:0,y:0,width:0,height:0}},Sc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,v=r.width/a,x=r.height/a,y=[];for(const m of t.values()){const{measured:_,selectable:k=!0,hidden:b=!1}=m;if(c&&!k||b)continue;const E=_.width??m.width??m.initialWidth??0,N=_.height??m.height??m.initialHeight??0,{x:P,y:w}=m.internals.positionAbsolute,j=cg(h,p,v,x,P,w,E,N),$=E*N,z=u&&j>0;(!m.internals.handleBounds||z||j>=$||m.dragging)&&y.push(m)}return y},r1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function i1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=vn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function o1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const h=i1(t,c),p=fs(h),v=Nc(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(v,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function lg({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),h=c.parentId?o.get(c.parentId):void 0,{x:p,y:v}=h?h.internals.positionAbsolute:{x:0,y:0},x=c.origin??s;let y=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",mn.error005());else{const{width:_,height:k}=vn(h);_&&k&&(y=[[p,v],[p+_,v+k]])}else h&&gi(c.extent)&&(y=[[c.extent[0][0]+p,c.extent[0][1]+v],[c.extent[1][0]+p,c.extent[1][1]+v]]);const m=gi(y)?pi(r,y,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",mn.error015())),{position:{x:m.x-p+(c.measured.width??0)*x[0],y:m.y-v+(c.measured.height??0)*x[1]},positionAbsolute:m}}async function s1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(m=>m.id)),c=[];for(const m of o){if(m.deletable===!1)continue;const _=u.has(m.id),k=!_&&m.parentId&&c.find(b=>b.id===m.parentId);(_||k)&&c.push(m)}const h=new Set(r.map(m=>m.id)),p=s.filter(m=>m.deletable!==!1),x=r1(c,p);for(const m of p)h.has(m.id)&&!x.find(k=>k.id===m.id)&&x.push(m);if(!a)return{edges:x,nodes:c};const y=await a({nodes:c,edges:x});return typeof y=="boolean"?y?{edges:x,nodes:c}:{edges:[],nodes:[]}:y}const Ji=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),pi=(t={x:0,y:0},r,o)=>({x:Ji(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:Ji(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function ag(t,r,o){const{width:s,height:a}=vn(o),{x:u,y:c}=o.internals.positionAbsolute;return pi(t,[[u,c],[u+s,c+a]],r)}const kh=(t,r,o)=>to?-Ji(Math.abs(t-o),1,r)/r:0,kc=(t,r,o=15,s=40)=>{const a=kh(t.x,s,r.width-s)*o,u=kh(t.y,s,r.height-s)*o;return[a,u]},Yl=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),sc=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),Xl=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),os=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:ds(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},Dl=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:ds(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},ug=(t,r)=>Xl(Yl(sc(t),sc(r))),cg=(t,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),v=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*v)},Ol=(t,r)=>cg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),Nh=t=>pn(t.width)&&pn(t.height)&&pn(t.x)&&pn(t.y),pn=t=>!isNaN(t)&&isFinite(t),dg=(t,r)=>(o,s)=>{},hs=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),ps=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(t-o)/a,y:(r-s)/a};return u?hs(h,c):h},eo=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Gi(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function l1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Gi(t,o),a=Gi(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Gi(t.top??t.y??0,o),a=Gi(t.bottom??t.y??0,o),u=Gi(t.left??t.x??0,r),c=Gi(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function a1(t,r,o,s,a,u){const{x:c,y:h}=eo(t,[r,o,s]),{x:p,y:v}=eo({x:t.x+t.width,y:t.y+t.height},[r,o,s]),x=a-p,y=u-v;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(x),bottom:Math.floor(y)}}const Nc=(t,r,o,s,a,u)=>{const c=l1(u,r,o),h=(r-c.x)/t.width,p=(o-c.y)/t.height,v=Math.min(h,p),x=Ji(v,s,a),y=t.x+t.width/2,m=t.y+t.height/2,_=r/2-y*x,k=o/2-m*x,b=a1(t,_,k,x,r,o),E={left:Math.min(b.left-c.left,0),top:Math.min(b.top-c.top,0),right:Math.min(b.right-c.right,0),bottom:Math.min(b.bottom-c.bottom,0)};return{x:_-E.left+E.right,y:k-E.top+E.bottom,zoom:x}},ss=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function gi(t){return t!=null&&t!=="parent"}function vn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function fg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function hg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function jh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function u1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function c1(t){return{...rg,...t||{}}}function Ko(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=gn(t),h=ps({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y:v}=o?hs(h,r):h;return{xSnapped:p,ySnapped:v,...h}}const jc=t=>({width:t.offsetWidth,height:t.offsetHeight}),pg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},d1=["INPUT","SELECT","TEXTAREA"];function gg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:d1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const mg=t=>"clientX"in t,gn=(t,r)=>{var u,c;const o=mg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},bh=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...jc(c)}})};function yg({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=t*.125+a*.375+c*.375+o*.125,v=r*.125+u*.375+h*.375+s*.125,x=Math.abs(p-t),y=Math.abs(v-r);return[p,v,x,y]}function wl(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function Eh({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case Se.Left:return[r-wl(r-s,u),o];case Se.Right:return[r+wl(s-r,u),o];case Se.Top:return[r,o-wl(o-a,u)];case Se.Bottom:return[r,o+wl(a-o,u)]}}function vg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top,curvature:c=.25}){const[h,p]=Eh({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[v,x]=Eh({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[y,m,_,k]=yg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:v,targetControlY:x});return[`M${t},${r} C${h},${p} ${v},${x} ${s},${a}`,y,m,_,k]}function xg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const p1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,g1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),m1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",mn.error006()),r;const s=o.getEdgeId||p1;let a;return sg(t)?a={...t}:a={...t,id:s(t)},g1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function wg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=xg({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,h]}const Ch={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},y1=({source:t,sourcePosition:r=Se.Bottom,target:o})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function v1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:s=Se.Top,center:a,offset:u,stepPosition:c}){const h=Ch[r],p=Ch[s],v={x:t.x+h.x*u,y:t.y+h.y*u},x={x:o.x+p.x*u,y:o.y+p.y*u},y=y1({source:v,sourcePosition:r,target:x}),m=y.x!==0?"x":"y",_=y[m];let k=[],b,E;const N={x:0,y:0},P={x:0,y:0},[,,w,j]=xg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[m]*p[m]===-1){m==="x"?(b=a.x??v.x+(x.x-v.x)*c,E=a.y??(v.y+x.y)/2):(b=a.x??(v.x+x.x)/2,E=a.y??v.y+(x.y-v.y)*c);const Y=[{x:b,y:v.y},{x:b,y:x.y}],Q=[{x:v.x,y:E},{x:x.x,y:E}];h[m]===_?k=m==="x"?Y:Q:k=m==="x"?Q:Y}else{const Y=[{x:v.x,y:x.y}],Q=[{x:x.x,y:v.y}];if(m==="x"?k=h.x===_?Q:Y:k=h.y===_?Y:Q,r===s){const C=Math.abs(t[m]-o[m]);if(C<=u){const V=Math.min(u-1,u-C);h[m]===_?N[m]=(v[m]>t[m]?-1:1)*V:P[m]=(x[m]>o[m]?-1:1)*V}}if(r!==s){const C=m==="x"?"y":"x",V=h[m]===p[C],W=v[C]>x[C],U=v[C]=q?(b=(ne.x+ee.x)/2,E=k[0].y):(b=k[0].x,E=(ne.y+ee.y)/2)}const $={x:v.x+N.x,y:v.y+N.y},z={x:x.x+P.x,y:x.y+P.y};return[[t,...$.x!==k[0].x||$.y!==k[0].y?[$]:[],...k,...z.x!==k[k.length-1].x||z.y!==k[k.length-1].y?[z]:[],o],b,E,w,j]}function x1(t,r,o,s){const a=Math.min(Mh(t,r)/2,Mh(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const v=t.xo.id===r):t[0])||null}function ac(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function _1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const v=ac(p,r);u.has(v)||(c.push({id:v,color:p.color||o,...p}),u.add(v))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const _g=1e3,S1=10,bc={nodeOrigin:[0,0],nodeExtent:ns,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},k1={...bc,checkEquality:!0};function Ec(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function N1(t,r,o){const s=Ec(bc,o);for(const a of t.values())if(a.parentId)Mc(a,t,r,s);else{const u=ds(a,s.nodeOrigin),c=gi(a.extent)?a.extent:s.nodeExtent,h=pi(u,c,vn(a));a.internals.positionAbsolute=h}}function j1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function Cc(t){return t==="manual"}function uc(t,r,o,s={}){var x,y;const a=Ec(k1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!Cc(a.zIndexMode)?_g:0;let p=t.length>0,v=!1;r.clear(),o.clear();for(const m of t){let _=c.get(m.id);if(a.checkEquality&&m===(_==null?void 0:_.internals.userNode))r.set(m.id,_);else{const k=ds(m,a.nodeOrigin),b=gi(m.extent)?m.extent:a.nodeExtent,E=pi(k,b,vn(m));_={...a.defaults,...m,measured:{width:(x=m.measured)==null?void 0:x.width,height:(y=m.measured)==null?void 0:y.height},internals:{positionAbsolute:E,handleBounds:j1(m,_),z:Sg(m,h,a.zIndexMode),userNode:m}},r.set(m.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),m.parentId&&Mc(_,r,o,s,u),v||(v=m.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:v}}function b1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function Mc(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=Ec(bc,s),v=t.parentId,x=r.get(v);if(!x){console.warn(`Parent node ${v} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}b1(t,o),a&&!x.parentId&&x.internals.rootParentIndex===void 0&&p==="auto"&&(x.internals.rootParentIndex=++a.i,x.internals.z=x.internals.z+a.i*S1),a&&x.internals.rootParentIndex!==void 0&&(a.i=x.internals.rootParentIndex);const y=u&&!Cc(p)?_g:0,{x:m,y:_,z:k}=E1(t,x,c,h,y,p),{positionAbsolute:b}=t.internals,E=m!==b.x||_!==b.y;(E||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:E?{x:m,y:_}:b,z:k}})}function Sg(t,r,o){const s=pn(t.zIndex)?t.zIndex:0;return Cc(o)?s:s+(t.selected?r:0)}function E1(t,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=vn(t),v=ds(t,o),x=gi(t.extent)?pi(v,t.extent,p):v;let y=pi({x:c+x.x,y:h+x.y},s,p);t.extent==="parent"&&(y=ag(y,p,r));const m=Sg(t,a,u),_=r.internals.z??0;return{x:y.x,y:y.y,z:_>=m?_+1:m}}function Pc(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const v=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??os(p),x=ug(v,h.rect);u.set(h.parentId,{expandedRect:x,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},v)=>{var w;const x=p.internals.positionAbsolute,y=vn(p),m=p.origin??s,_=h.x0||k>0||N||P)&&(a.push({id:v,type:"position",position:{x:p.position.x-_+N,y:p.position.y-k+P}}),(w=o.get(v))==null||w.forEach(j=>{t.some($=>$.id===j.id)||a.push({id:j.id,type:"position",position:{x:j.position.x+_,y:j.position.y+k}})})),(y.width0){const _=Pc(m,r,o,a);v.push(..._)}return{changes:v,updatedInternals:p}}async function M1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Th(t,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${t}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${t}-${u}`;const v=s.get(c)||new Map;s.set(c,v.set(o,r))}}function kg(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},v=`${a}-${c}--${u}-${h}`,x=`${u}-${h}--${a}-${c}`;Th("source",p,x,t,a,c),Th("target",p,v,t,u,h),r.set(s.id,s)}}function Ng(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:Ng(o,r):!1}function Lh(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function P1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!Ng(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function Ou({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[v,x]of r){const y=(c=o.get(v))==null?void 0:c.internals.userNode;y&&a.push({...y,position:x.position,dragging:s})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function I1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=hs(u,r);return{x:c.x-u.x,y:c.y-u.y}}function R1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,v={x:0,y:0},x=null,y=!1,m=null,_=!1,k=!1,b=null;function E({noDragClassName:P,handleSelector:w,domNode:j,isSelectable:$,nodeId:z,nodeClickDistance:B=0}){m=Yt(j);function Y({x:te,y:q}){const{nodeLookup:C,nodeExtent:V,snapGrid:W,snapToGrid:U,nodeOrigin:M,onNodeDrag:D,onSelectionDrag:F,onError:R,updateNodePositions:A}=r();u={x:te,y:q};let ie=!1;const oe=h.size>1,fe=oe&&V?sc(fs(h)):null,he=oe&&U?I1({dragItems:h,snapGrid:W,x:te,y:q}):null;for(const[pe,Z]of h){if(!C.has(pe))continue;let se={x:te-Z.distance.x,y:q-Z.distance.y};U&&(se=he?{x:Math.round(se.x+he.x),y:Math.round(se.y+he.y)}:hs(se,W));let me=null;if(oe&&V&&!Z.extent&&fe){const{positionAbsolute:re}=Z.internals,Ne=re.x-fe.x+V[0][0],Me=re.x+Z.measured.width-fe.x2+V[1][0],Te=re.y-fe.y+V[0][1],$e=re.y+Z.measured.height-fe.y2+V[1][1];me=[[Ne,Te],[Me,$e]]}const{position:ke,positionAbsolute:ve}=lg({nodeId:pe,nextPosition:se,nodeLookup:C,nodeExtent:me||V,nodeOrigin:M,onError:R});ie=ie||Z.position.x!==ke.x||Z.position.y!==ke.y,Z.position=ke,Z.internals.positionAbsolute=ve}if(k=k||ie,!!ie&&(A(h,!0),b&&(s||D||!z&&F))){const[pe,Z]=Ou({nodeId:z,dragItems:h,nodeLookup:C});s==null||s(b,h,pe,Z),D==null||D(b,pe,Z),z||F==null||F(b,Z)}}async function Q(){if(!x)return;const{transform:te,panBy:q,autoPanSpeed:C,autoPanOnNodeDrag:V}=r();if(!V){p=!1,cancelAnimationFrame(c);return}const[W,U]=kc(v,x,C);(W!==0||U!==0)&&(u.x=(u.x??0)-W/te[2],u.y=(u.y??0)-U/te[2],await q({x:W,y:U})&&Y(u)),c=requestAnimationFrame(Q)}function ne(te){var oe;const{nodeLookup:q,multiSelectionActive:C,nodesDraggable:V,transform:W,snapGrid:U,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:F,onSelectionDragStart:R,unselectNodesAndEdges:A}=r();y=!0,(!D||!$)&&!C&&z&&((oe=q.get(z))!=null&&oe.selected||A()),$&&D&&z&&(t==null||t(z));const ie=Ko(te.sourceEvent,{transform:W,snapGrid:U,snapToGrid:M,containerBounds:x});if(u=ie,h=P1(q,V,ie,z),h.size>0&&(o||F||!z&&R)){const[fe,he]=Ou({nodeId:z,dragItems:h,nodeLookup:q});o==null||o(te.sourceEvent,h,fe,he),F==null||F(te.sourceEvent,fe,he),z||R==null||R(te.sourceEvent,he)}}const ee=Fp().clickDistance(B).on("start",te=>{const{domNode:q,nodeDragThreshold:C,transform:V,snapGrid:W,snapToGrid:U}=r();x=(q==null?void 0:q.getBoundingClientRect())||null,_=!1,k=!1,b=te.sourceEvent,C===0&&ne(te),u=Ko(te.sourceEvent,{transform:V,snapGrid:W,snapToGrid:U,containerBounds:x}),v=gn(te.sourceEvent,x)}).on("drag",te=>{const{autoPanOnNodeDrag:q,transform:C,snapGrid:V,snapToGrid:W,nodeDragThreshold:U,nodeLookup:M}=r(),D=Ko(te.sourceEvent,{transform:C,snapGrid:V,snapToGrid:W,containerBounds:x});if(b=te.sourceEvent,(te.sourceEvent.type==="touchmove"&&te.sourceEvent.touches.length>1||z&&!M.has(z))&&(_=!0),!_){if(!p&&q&&y&&(p=!0,Q()),!y){const F=gn(te.sourceEvent,x),R=F.x-v.x,A=F.y-v.y;Math.sqrt(R*R+A*A)>U&&ne(te)}(u.x!==D.xSnapped||u.y!==D.ySnapped)&&h&&y&&(v=gn(te.sourceEvent,x),Y(D))}}).on("end",te=>{if(!y||_){_&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,y=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:q,updateNodePositions:C,onNodeDragStop:V,onSelectionDragStop:W}=r();if(k&&(C(h,!1),k=!1),a||V||!z&&W){const[U,M]=Ou({nodeId:z,dragItems:h,nodeLookup:q,dragging:!1});a==null||a(te.sourceEvent,h,U,M),V==null||V(te.sourceEvent,U,M),z||W==null||W(te.sourceEvent,M)}}}).filter(te=>{const q=te.target;return!te.button&&(!P||!Lh(q,`.${P}`,j))&&(!w||Lh(q,w,j))});m.call(ee)}function N(){m==null||m.on(".drag",null)}return{update:E,destroy:N}}function T1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())Ol(a,os(u))>0&&s.push(u);return s}const L1=250;function A1(t,r,o,s){var h,p;let a=[],u=1/0;const c=T1(t,o,r+L1);for(const v of c){const x=[...((h=v.internals.handleBounds)==null?void 0:h.source)??[],...((p=v.internals.handleBounds)==null?void 0:p.target)??[]];for(const y of x){if(s.nodeId===y.nodeId&&s.type===y.type&&s.id===y.id)continue;const{x:m,y:_}=mi(v,y,y.position,!0),k=Math.sqrt(Math.pow(m-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const v=s.type==="source"?"target":"source";return a.find(x=>x.type===v)??a[0]}return a[0]}function jg(t,r,o,s,a,u=!1){var v,x,y;const c=s.get(t);if(!c)return null;const h=a==="strict"?(v=c.internals.handleBounds)==null?void 0:v[r]:[...((x=c.internals.handleBounds)==null?void 0:x.source)??[],...((y=c.internals.handleBounds)==null?void 0:y.target)??[]],p=(o?h==null?void 0:h.find(m=>m.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...mi(c,p,p.position,!0)}:p}function bg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function $1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const Eg=()=>!0;function z1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:v,autoPanOnConnect:x,flowId:y,panBy:m,cancelConnection:_,onConnectStart:k,onConnect:b,onConnectEnd:E,isValidConnection:N=Eg,onReconnectEnd:P,updateConnection:w,getTransform:j,getFromHandle:$,autoPanSpeed:z,dragThreshold:B=1,handleDomNode:Y}){const Q=pg(t.target);let ne=0,ee;const{x:te,y:q}=gn(t),C=bg(u,Y),V=h==null?void 0:h.getBoundingClientRect();let W=!1;if(!V||!C)return;const U=jg(a,C,s,p,r);if(!U)return;let M=gn(t,V),D=!1,F=null,R=!1,A=null;function ie(){if(!x||!V)return;const[ke,ve]=kc(M,V,z);m({x:ke,y:ve}),ne=requestAnimationFrame(ie)}const oe={...U,nodeId:a,type:C,position:U.position},fe=p.get(a);let pe={inProgress:!0,isValid:null,from:mi(fe,oe,Se.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:fe,to:M,toHandle:null,toPosition:Sh[oe.position],toNode:null,pointer:M};function Z(){W=!0,w(pe),k==null||k(t,{nodeId:a,handleId:s,handleType:C})}B===0&&Z();function se(ke){if(!W){const{x:$e,y:st}=gn(ke),lt=$e-te,at=st-q;if(!(lt*lt+at*at>B*B))return;Z()}if(!$()||!oe){me(ke);return}const ve=j();M=gn(ke,V),ee=A1(ps(M,ve,!1,[1,1]),o,p,oe),D||(ie(),D=!0);const re=Cg(ke,{handle:ee,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:N,doc:Q,lib:v,flowId:y,nodeLookup:p});A=re.handleDomNode,F=re.connection,R=$1(!!ee,re.isValid);const Ne=p.get(a),Me=Ne?mi(Ne,oe,Se.Left,!0):pe.from,Te={...pe,from:Me,isValid:R,to:re.toHandle&&R?eo({x:re.toHandle.x,y:re.toHandle.y},ve):M,toHandle:re.toHandle,toPosition:R&&re.toHandle?re.toHandle.position:Sh[oe.position],toNode:re.toHandle?p.get(re.toHandle.nodeId):null,pointer:M};w(Te),pe=Te}function me(ke){if(!("touches"in ke&&ke.touches.length>0)){if(W){(ee||A)&&F&&R&&(b==null||b(F));const{inProgress:ve,...re}=pe,Ne={...re,toPosition:pe.toHandle?pe.toPosition:null};E==null||E(ke,Ne),u&&(P==null||P(ke,Ne))}_(),cancelAnimationFrame(ne),D=!1,R=!1,F=null,A=null,Q.removeEventListener("mousemove",se),Q.removeEventListener("mouseup",me),Q.removeEventListener("touchmove",se),Q.removeEventListener("touchend",me)}}Q.addEventListener("mousemove",se),Q.addEventListener("mouseup",me),Q.addEventListener("touchmove",se),Q.addEventListener("touchend",me)}function Cg(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:v=Eg,nodeLookup:x}){const y=u==="target",m=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=gn(t),b=c.elementFromPoint(_,k),E=b!=null&&b.classList.contains(`${h}-flow__handle`)?b:m,N={handleDomNode:E,isValid:!1,connection:null,toHandle:null};if(E){const P=bg(void 0,E),w=E.getAttribute("data-nodeid"),j=E.getAttribute("data-handleid"),$=E.classList.contains("connectable"),z=E.classList.contains("connectableend");if(!w||!P)return N;const B={source:y?w:s,sourceHandle:y?j:a,target:y?s:w,targetHandle:y?a:j};N.connection=B;const Q=$&&z&&(o===Zi.Strict?y&&P==="source"||!y&&P==="target":w!==s||j!==a);N.isValid=Q&&v(B),N.toHandle=jg(w,P,j,x,o,!0)}return N}const cc={onPointerDown:z1,isValid:Cg};function D1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Yt(t);function u({translateExtent:h,width:p,height:v,zoomStep:x=1,pannable:y=!0,zoomable:m=!0,inversePan:_=!1}){const k=w=>{if(w.sourceEvent.type!=="wheel"||!r)return;const j=o(),$=w.sourceEvent.ctrlKey&&ss()?10:1,z=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*x,B=j[2]*Math.pow(2,z*$);r.scaleTo(B)};let b=[0,0];const E=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(b=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},N=w=>{const j=o();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!r)return;const $=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],z=[$[0]-b[0],$[1]-b[1]];b=$;const B=s()*Math.max(j[2],Math.log(j[2]))*(_?-1:1),Y={x:j[0]-z[0]*B,y:j[1]-z[1]*B},Q=[[0,0],[p,v]];r.setViewportConstrained({x:Y.x,y:Y.y,zoom:j[2]},Q,h)},P=tg().on("start",E).on("zoom",y?N:null).on("zoom.wheel",m?k:null);a.call(P,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:fn}}const ql=t=>({x:t.x,y:t.y,zoom:t.k}),Fu=({x:t,y:r,zoom:o})=>Gl.translate(t,r).scale(o),Rr=(t,r)=>t.target.closest(`.${r}`),Mg=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),O1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Hu=(t,r=0,o=O1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Pg=t=>{const r=t.ctrlKey&&ss()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function F1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:v}){return x=>{if(Rr(x,r))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const y=o.property("__zoom").k||1;if(x.ctrlKey&&c){const E=fn(x),N=Pg(x),P=y*Math.pow(2,N);s.scaleTo(o,P,E,x);return}const m=x.deltaMode===1?20:1;let _=a===di.Vertical?0:x.deltaX*m,k=a===di.Horizontal?0:x.deltaY*m;!ss()&&x.shiftKey&&a!==di.Vertical&&(_=x.deltaY*m,k=0),s.translateBy(o,-(_/y)*u,-(k/y)*u,{internal:!0});const b=ql(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(x,b):(t.isPanScrolling=!0,h==null||h(x,b)),t.panScrollTimeout=setTimeout(()=>{v==null||v(x,b),t.isPanScrolling=!1},150)}}function H1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=Rr(s,t);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function B1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=ql(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function V1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;t.usedRightMouseButton=!!(o&&Mg(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,ql(u.transform)))}}function W1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&Mg(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const p=ql(c.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function U1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:v,lib:x,connectionInProgress:y}){return m=>{var N;const _=r||o,k=s&&m.ctrlKey,b=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(Rr(m,`${x}-flow__node`)||Rr(m,`${x}-flow__edge`)||Rr(m,`${x}-flow__selection`)||Rr(m,`${x}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!c&&!s||h||y&&!b||Rr(m,p)&&b||Rr(m,v)&&(!b||u&&b&&!r)||!s&&m.ctrlKey&&b)return!1;if(!s&&m.type==="touchstart"&&((N=m.touches)==null?void 0:N.length)>1)return m.preventDefault(),!1;if(!_&&!u&&!k&&b||!a&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(a)&&!a.includes(m.button)&&m.type==="mousedown")return!1;const E=Array.isArray(a)&&a.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||b||t)&&E}}function G1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const v={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=t.getBoundingClientRect();let y=[[0,0],[x.width,x.height]];const m=typeof ResizeObserver<"u"?new ResizeObserver(q=>{const C=q[0];C&&(y=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;m==null||m.observe(t);const _=tg().extent(()=>y).scaleExtent([r,o]).translateExtent(s),k=Yt(t).call(_);j({x:a.x,y:a.y,zoom:Ji(a.zoom,r,o)},[[0,0],[x.width,x.height]],s);const b=k.on("wheel.zoom"),E=k.on("dblclick.zoom");_.wheelDelta(Pg);async function N(q,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?qo:El).transform(Hu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),q)}):!1}function P({noWheelClassName:q,noPanClassName:C,onPaneContextMenu:V,userSelectionActive:W,panOnScroll:U,panOnDrag:M,panOnScrollMode:D,panOnScrollSpeed:F,preventScrolling:R,zoomOnPinch:A,zoomOnScroll:ie,zoomOnDoubleClick:oe,panActivationKeyPressed:fe=!1,zoomActivationKeyPressed:he,lib:pe,onTransformChange:Z,connectionInProgress:se,paneClickDistance:me,selectionOnDrag:ke}){W&&!v.isZoomingOrPanning&&w();const ve=U&&!he&&!W;_.clickDistance(ke?1/0:!pn(me)||me<0?0:me);const re=ve?F1({zoomPanValues:v,noWheelClassName:q,d3Selection:k,d3Zoom:_,panOnScrollMode:D,panOnScrollSpeed:F,zoomOnPinch:A,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):H1({noWheelClassName:q,preventScrolling:R,d3ZoomHandler:b});k.on("wheel.zoom",re,{passive:!1});const Ne=B1({zoomPanValues:v,onDraggingChange:p,onPanZoomStart:c});_.on("start",Ne);const Me=V1({zoomPanValues:v,panOnDrag:M,onPaneContextMenu:!!V,onPanZoom:u,onTransformChange:Z});_.on("zoom",Me);const Te=W1({zoomPanValues:v,panOnDrag:M,panOnScroll:U,onPaneContextMenu:V,onPanZoomEnd:h,onDraggingChange:p});_.on("end",Te);const $e=U1({panActivationKeyPressed:fe,zoomActivationKeyPressed:he,panOnDrag:M,zoomOnScroll:ie,panOnScroll:U,zoomOnDoubleClick:oe,zoomOnPinch:A,userSelectionActive:W,noPanClassName:C,noWheelClassName:q,lib:pe,connectionInProgress:se});_.filter($e),oe?k.on("dblclick.zoom",E):k.on("dblclick.zoom",null)}function w(){_.on("zoom",null)}async function j(q,C,V){const W=Fu(q),U=_==null?void 0:_.constrain()(W,C,V);return U&&await N(U),U}async function $(q,C){const V=Fu(q);return await N(V,C),V}function z(q){if(k){const C=Fu(q),V=k.property("__zoom");(V.k!==q.zoom||V.x!==q.x||V.y!==q.y)&&(_==null||_.transform(k,C,null,{sync:!0}))}}function B(){const q=k?eg(k.node()):{x:0,y:0,k:1};return{x:q.x,y:q.y,zoom:q.k}}async function Y(q,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?qo:El).scaleTo(Hu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),q)}):!1}async function Q(q,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?qo:El).scaleBy(Hu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),q)}):!1}function ne(q){_==null||_.scaleExtent(q)}function ee(q){_==null||_.translateExtent(q)}function te(q){const C=!pn(q)||q<0?0:q;_==null||_.clickDistance(C)}return{update:P,destroy:w,setViewport:$,setViewportConstrained:j,getViewport:B,scaleTo:Y,scaleBy:Q,setScaleExtent:ne,setTranslateExtent:ee,syncViewport:z,setClickDistance:te}}var to;(function(t){t.Line="line",t.Handle="handle"})(to||(to={}));function Y1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function Ah(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function Pr(t,r){return Math.max(0,r-t)}function Ir(t,r){return Math.max(0,t-r)}function _l(t,r,o){return Math.max(0,r-t,t-o)}function $h(t,r){return t?!r:r}function X1(t,r,o,s,a,u,c,h){let{affectsX:p,affectsY:v}=r;const{isHorizontal:x,isVertical:y}=r,m=x&&y,{xSnapped:_,ySnapped:k}=o,{minWidth:b,maxWidth:E,minHeight:N,maxHeight:P}=s,{x:w,y:j,width:$,height:z,aspectRatio:B}=t;let Y=Math.floor(x?_-t.pointerX:0),Q=Math.floor(y?k-t.pointerY:0);const ne=$+(p?-Y:Y),ee=z+(v?-Q:Q),te=-u[0]*$,q=-u[1]*z;let C=_l(ne,b,E),V=_l(ee,N,P);if(c){let M=0,D=0;p&&Y<0?M=Pr(w+Y+te,c[0][0]):!p&&Y>0&&(M=Ir(w+ne+te,c[1][0])),v&&Q<0?D=Pr(j+Q+q,c[0][1]):!v&&Q>0&&(D=Ir(j+ee+q,c[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(h){let M=0,D=0;p&&Y>0?M=Ir(w+Y,h[0][0]):!p&&Y<0&&(M=Pr(w+ne,h[1][0])),v&&Q>0?D=Ir(j+Q,h[0][1]):!v&&Q<0&&(D=Pr(j+ee,h[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(a){if(x){const M=_l(ne/B,N,P)*B;if(C=Math.max(C,M),c){let D=0;!p&&!v||p&&!v&&m?D=Ir(j+q+ne/B,c[1][1])*B:D=Pr(j+q+(p?Y:-Y)/B,c[0][1])*B,C=Math.max(C,D)}if(h){let D=0;!p&&!v||p&&!v&&m?D=Pr(j+ne/B,h[1][1])*B:D=Ir(j+(p?Y:-Y)/B,h[0][1])*B,C=Math.max(C,D)}}if(y){const M=_l(ee*B,b,E)/B;if(V=Math.max(V,M),c){let D=0;!p&&!v||v&&!p&&m?D=Ir(w+ee*B+te,c[1][0])/B:D=Pr(w+(v?Q:-Q)*B+te,c[0][0])/B,V=Math.max(V,D)}if(h){let D=0;!p&&!v||v&&!p&&m?D=Pr(w+ee*B,h[1][0])/B:D=Ir(w+(v?Q:-Q)*B,h[0][0])/B,V=Math.max(V,D)}}}Q=Q+(Q<0?V:-V),Y=Y+(Y<0?C:-C),a&&(m?ne>ee*B?Q=($h(p,v)?-Y:Y)/B:Y=($h(p,v)?-Q:Q)*B:x?(Q=Y/B,v=p):(Y=Q*B,p=v));const W=p?w+Y:w,U=v?j+Q:j;return{width:$+(p?-Y:Y),height:z+(v?-Q:Q),x:u[0]*Y*(p?-1:1)+W,y:u[1]*Q*(v?-1:1)+U}}const Ig={width:0,height:0,x:0,y:0},q1={...Ig,pointerX:0,pointerY:0,aspectRatio:1};function K1(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function Q1({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Yt(t);let c={controlDirection:Ah("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:v,boundaries:x,keepAspectRatio:y,resizeDirection:m,onResizeStart:_,onResize:k,onResizeEnd:b,shouldResize:E}){let N={...Ig},P={...q1};c={boundaries:x,resizeDirection:m,keepAspectRatio:y,controlDirection:Ah(v)};let w,j=null,$=[],z,B,Y,Q=!1;const ne=Fp().on("start",ee=>{const{nodeLookup:te,transform:q,snapGrid:C,snapToGrid:V,nodeOrigin:W,paneDomNode:U}=o();if(w=te.get(r),!w)return;j=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:D}=Ko(ee.sourceEvent,{transform:q,snapGrid:C,snapToGrid:V,containerBounds:j});N={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},P={...N,pointerX:M,pointerY:D,aspectRatio:N.width/N.height},z=void 0,B=gi(w.extent)?w.extent:void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&(z=te.get(w.parentId)),z&&w.extent==="parent"&&(B=[[0,0],[z.measured.width,z.measured.height]]),$=[],Y=void 0;for(const[F,R]of te)if(R.parentId===r&&($.push({id:F,position:{...R.position},extent:R.extent}),R.extent==="parent"||R.expandParent)){const A=K1(R,w,R.origin??W);Y?Y=[[Math.min(A[0][0],Y[0][0]),Math.min(A[0][1],Y[0][1])],[Math.max(A[1][0],Y[1][0]),Math.max(A[1][1],Y[1][1])]]:Y=A}_==null||_(ee,{...N})}).on("drag",ee=>{const{transform:te,snapGrid:q,snapToGrid:C,nodeOrigin:V}=o(),W=Ko(ee.sourceEvent,{transform:te,snapGrid:q,snapToGrid:C,containerBounds:j}),U=[];if(!w)return;const{x:M,y:D,width:F,height:R}=N,A={},ie=w.origin??V,{width:oe,height:fe,x:he,y:pe}=X1(P,c.controlDirection,W,c.boundaries,c.keepAspectRatio,ie,B,Y),Z=oe!==F,se=fe!==R,me=he!==M&&Z,ke=pe!==D&&se;if(!me&&!ke&&!Z&&!se)return;if((me||ke||ie[0]===1||ie[1]===1)&&(A.x=me?he:N.x,A.y=ke?pe:N.y,N.x=A.x,N.y=A.y,$.length>0)){const Me=he-M,Te=pe-D;for(const $e of $)$e.position={x:$e.position.x-Me+ie[0]*(oe-F),y:$e.position.y-Te+ie[1]*(fe-R)},U.push($e)}if((Z||se)&&(A.width=Z&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:N.width,A.height=se&&(!c.resizeDirection||c.resizeDirection==="vertical")?fe:N.height,N.width=A.width,N.height=A.height),z&&w.expandParent){const Me=ie[0]*(A.width??0);A.x&&A.x{Q&&(b==null||b(ee,{...N}),a==null||a({...N}),Q=!1)});u.call(ne)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Bu={exports:{}},Vu={},Wu={exports:{}},Uu={};/** * @license React * use-sync-external-store-shim.production.js * @@ -45,7 +45,7 @@ Error generating stack: `+g.message+` * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var zh;function Z1(){if(zh)return Uu;zh=1;var t=ls();function r(y,m){return y===m&&(y!==0||1/y===1/m)||y!==y&&m!==m}var o=typeof Object.is=="function"?Object.is:r,s=t.useState,a=t.useEffect,u=t.useLayoutEffect,c=t.useDebugValue;function h(y,m){var _=m(),k=s({inst:{value:_,getSnapshot:m}}),b=k[0].inst,E=k[1];return u(function(){b.value=_,b.getSnapshot=m,p(b)&&E({inst:b})},[y,_,m]),a(function(){return p(b)&&E({inst:b}),y(function(){p(b)&&E({inst:b})})},[y]),c(_),_}function p(y){var m=y.getSnapshot;y=y.value;try{var _=m();return!o(y,_)}catch{return!0}}function v(y,m){return m()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?v:h;return Uu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:x,Uu}var Dh;function J1(){return Dh||(Dh=1,Wu.exports=Z1()),Wu.exports}/** + */var zh;function Z1(){if(zh)return Uu;zh=1;var t=as();function r(y,m){return y===m&&(y!==0||1/y===1/m)||y!==y&&m!==m}var o=typeof Object.is=="function"?Object.is:r,s=t.useState,a=t.useEffect,u=t.useLayoutEffect,c=t.useDebugValue;function h(y,m){var _=m(),k=s({inst:{value:_,getSnapshot:m}}),b=k[0].inst,E=k[1];return u(function(){b.value=_,b.getSnapshot=m,p(b)&&E({inst:b})},[y,_,m]),a(function(){return p(b)&&E({inst:b}),y(function(){p(b)&&E({inst:b})})},[y]),c(_),_}function p(y){var m=y.getSnapshot;y=y.value;try{var _=m();return!o(y,_)}catch{return!0}}function v(y,m){return m()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?v:h;return Uu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:x,Uu}var Dh;function J1(){return Dh||(Dh=1,Wu.exports=Z1()),Wu.exports}/** * @license React * use-sync-external-store-shim/with-selector.production.js * @@ -53,10 +53,10 @@ Error generating stack: `+g.message+` * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Oh;function e_(){if(Oh)return Vu;Oh=1;var t=ls(),r=J1();function o(v,x){return v===x&&(v!==0||1/v===1/x)||v!==v&&x!==x}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Vu.useSyncExternalStoreWithSelector=function(v,x,y,m,_){var k=u(null);if(k.current===null){var b={hasValue:!1,value:null};k.current=b}else b=k.current;k=h(function(){function N(D){if(!P){if(P=!0,w=D,D=m(D),_!==void 0&&b.hasValue){var B=b.value;if(_(B,D))return j=B}return j=D}if(B=j,s(w,D))return B;var Y=m(D);return _!==void 0&&_(B,Y)?(w=D,B):(w=D,j=Y)}var P=!1,w,j,$=y===void 0?null:y;return[function(){return N(x())},$===null?void 0:function(){return N($())}]},[x,y,m,_]);var E=a(v,k[0],k[1]);return c(function(){b.hasValue=!0,b.value=E},[E]),p(E),E},Vu}var Fh;function t_(){return Fh||(Fh=1,Bu.exports=e_()),Bu.exports}var n_=t_();const r_=Sp(n_),i_={},Hh=t=>{let r;const o=new Set,s=(x,y)=>{const m=typeof x=="function"?x(r):x;if(!Object.is(m,r)){const _=r;r=y??(typeof m!="object"||m===null)?m:Object.assign({},r,m),o.forEach(k=>k(r,_))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>v,subscribe:x=>(o.add(x),()=>o.delete(x)),destroy:()=>{(i_?"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."),o.clear()}},v=r=t(s,a,p);return p},o_=t=>t?Hh(t):Hh,{useDebugValue:s_}=t0,{useSyncExternalStoreWithSelector:l_}=r_,a_=t=>t;function Rg(t,r=a_,o){const s=l_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return s_(s),s}const Bh=(t,r)=>{const o=o_(t),s=(a,u=r)=>Rg(o,a,u);return Object.assign(s,o),s},u_=(t,r)=>t?Bh(t,r):Bh;function Qe(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}kp();const ql=L.createContext(null),c_=ql.Provider,Tg=mn.error001("react");function ze(t,r){const o=L.useContext(ql);if(o===null)throw new Error(Tg);return Rg(o,t,r)}function Ge(){const t=L.useContext(ql);if(t===null)throw new Error(Tg);return L.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Vh={display:"none"},d_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Lg="react-flow__node-desc",Ag="react-flow__edge-desc",f_="react-flow__aria-live",h_=t=>t.ariaLiveMessage,p_=t=>t.ariaLabelConfig;function g_({rfId:t}){const r=ze(h_);return d.jsx("div",{id:`${f_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:d_,children:r})}function m_({rfId:t,disableKeyboardA11y:r}){const o=ze(p_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${Lg}-${t}`,style:Vh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${Ag}-${t}`,style:Vh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(g_,{rfId:t})]})}const Kl=L.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return d.jsx("div",{className:nt(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});Kl.displayName="Panel";const Wh="https://reactflow.dev?utm_source=attribution";function y_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:d.jsx(Kl,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Wh}`,children:d.jsx("a",{href:Wh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const v_=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},_l=t=>t.id;function x_(t,r){return Qe(t.selectedNodes.map(_l),r.selectedNodes.map(_l))&&Qe(t.selectedEdges.map(_l),r.selectedEdges.map(_l))}function w_({onSelectionChange:t}){const r=Ge(),{selectedNodes:o,selectedEdges:s}=ze(v_,x_);return L.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const __=t=>!!t.onSelectionChangeHandlers;function S_({onSelectionChange:t}){const r=ze(__);return t||r?d.jsx(w_,{onSelectionChange:t}):null}const $g=[0,0],k_={x:0,y:0,zoom:1},N_=["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"],Uh=[...N_,"rfId"],j_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Gh={translateExtent:ts,nodeOrigin:$g,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function b_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=ze(j_,Qe),v=Ge();L.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{x.current=Gh,h()}),[]);const x=L.useRef(Gh);return L.useEffect(()=>{for(const y of Uh){const m=t[y],_=x.current[y];m!==_&&(typeof t[y]>"u"||(y==="nodes"?r(m):y==="edges"?o(m):y==="minZoom"?s(m):y==="maxZoom"?a(m):y==="translateExtent"?u(m):y==="nodeExtent"?c(m):y==="ariaLabelConfig"?v.setState({ariaLabelConfig:c1(m)}):y==="fitView"?v.setState({fitViewQueued:m}):y==="fitViewOptions"?v.setState({fitViewOptions:m}):v.setState({[y]:m})))}x.current=t},Uh.map(y=>t[y])),null}function Yh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function E_(t){var s;const[r,o]=L.useState(t==="system"?null:t);return L.useEffect(()=>{if(t!=="system"){o(t);return}const a=Yh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=Yh())!=null&&s.matches?"dark":"light"}const Xh=typeof document<"u"?document:null;function ss(t=null,r={target:Xh,actInsideInputWithModifier:!0}){const[o,s]=L.useState(!1),a=L.useRef(!1),u=L.useRef(new Set([])),[c,h]=L.useMemo(()=>{if(t!==null){const v=(Array.isArray(t)?t:[t]).filter(y=>typeof y=="string").map(y=>y.replace(/\+/g,` + */var Oh;function e_(){if(Oh)return Vu;Oh=1;var t=as(),r=J1();function o(v,x){return v===x&&(v!==0||1/v===1/x)||v!==v&&x!==x}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Vu.useSyncExternalStoreWithSelector=function(v,x,y,m,_){var k=u(null);if(k.current===null){var b={hasValue:!1,value:null};k.current=b}else b=k.current;k=h(function(){function N(z){if(!P){if(P=!0,w=z,z=m(z),_!==void 0&&b.hasValue){var B=b.value;if(_(B,z))return j=B}return j=z}if(B=j,s(w,z))return B;var Y=m(z);return _!==void 0&&_(B,Y)?(w=z,B):(w=z,j=Y)}var P=!1,w,j,$=y===void 0?null:y;return[function(){return N(x())},$===null?void 0:function(){return N($())}]},[x,y,m,_]);var E=a(v,k[0],k[1]);return c(function(){b.hasValue=!0,b.value=E},[E]),p(E),E},Vu}var Fh;function t_(){return Fh||(Fh=1,Bu.exports=e_()),Bu.exports}var n_=t_();const r_=Sp(n_),i_={},Hh=t=>{let r;const o=new Set,s=(x,y)=>{const m=typeof x=="function"?x(r):x;if(!Object.is(m,r)){const _=r;r=y??(typeof m!="object"||m===null)?m:Object.assign({},r,m),o.forEach(k=>k(r,_))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>v,subscribe:x=>(o.add(x),()=>o.delete(x)),destroy:()=>{(i_?"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."),o.clear()}},v=r=t(s,a,p);return p},o_=t=>t?Hh(t):Hh,{useDebugValue:s_}=t0,{useSyncExternalStoreWithSelector:l_}=r_,a_=t=>t;function Rg(t,r=a_,o){const s=l_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return s_(s),s}const Bh=(t,r)=>{const o=o_(t),s=(a,u=r)=>Rg(o,a,u);return Object.assign(s,o),s},u_=(t,r)=>t?Bh(t,r):Bh;function Qe(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}kp();const Kl=L.createContext(null),c_=Kl.Provider,Tg=mn.error001("react");function De(t,r){const o=L.useContext(Kl);if(o===null)throw new Error(Tg);return Rg(o,t,r)}function Ge(){const t=L.useContext(Kl);if(t===null)throw new Error(Tg);return L.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Vh={display:"none"},d_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Lg="react-flow__node-desc",Ag="react-flow__edge-desc",f_="react-flow__aria-live",h_=t=>t.ariaLiveMessage,p_=t=>t.ariaLabelConfig;function g_({rfId:t}){const r=De(h_);return d.jsx("div",{id:`${f_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:d_,children:r})}function m_({rfId:t,disableKeyboardA11y:r}){const o=De(p_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${Lg}-${t}`,style:Vh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${Ag}-${t}`,style:Vh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(g_,{rfId:t})]})}const Ql=L.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return d.jsx("div",{className:nt(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});Ql.displayName="Panel";const Wh="https://reactflow.dev?utm_source=attribution";function y_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:d.jsx(Ql,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Wh}`,children:d.jsx("a",{href:Wh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const v_=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},Sl=t=>t.id;function x_(t,r){return Qe(t.selectedNodes.map(Sl),r.selectedNodes.map(Sl))&&Qe(t.selectedEdges.map(Sl),r.selectedEdges.map(Sl))}function w_({onSelectionChange:t}){const r=Ge(),{selectedNodes:o,selectedEdges:s}=De(v_,x_);return L.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const __=t=>!!t.onSelectionChangeHandlers;function S_({onSelectionChange:t}){const r=De(__);return t||r?d.jsx(w_,{onSelectionChange:t}):null}const $g=[0,0],k_={x:0,y:0,zoom:1},N_=["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"],Uh=[...N_,"rfId"],j_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Gh={translateExtent:ns,nodeOrigin:$g,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function b_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=De(j_,Qe),v=Ge();L.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{x.current=Gh,h()}),[]);const x=L.useRef(Gh);return L.useEffect(()=>{for(const y of Uh){const m=t[y],_=x.current[y];m!==_&&(typeof t[y]>"u"||(y==="nodes"?r(m):y==="edges"?o(m):y==="minZoom"?s(m):y==="maxZoom"?a(m):y==="translateExtent"?u(m):y==="nodeExtent"?c(m):y==="ariaLabelConfig"?v.setState({ariaLabelConfig:c1(m)}):y==="fitView"?v.setState({fitViewQueued:m}):y==="fitViewOptions"?v.setState({fitViewOptions:m}):v.setState({[y]:m})))}x.current=t},Uh.map(y=>t[y])),null}function Yh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function E_(t){var s;const[r,o]=L.useState(t==="system"?null:t);return L.useEffect(()=>{if(t!=="system"){o(t);return}const a=Yh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=Yh())!=null&&s.matches?"dark":"light"}const Xh=typeof document<"u"?document:null;function ls(t=null,r={target:Xh,actInsideInputWithModifier:!0}){const[o,s]=L.useState(!1),a=L.useRef(!1),u=L.useRef(new Set([])),[c,h]=L.useMemo(()=>{if(t!==null){const v=(Array.isArray(t)?t:[t]).filter(y=>typeof y=="string").map(y=>y.replace(/\+/g,` `).replace(` `,` +`).split(` -`)),x=v.reduce((y,m)=>y.concat(...m),[]);return[v,x]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Xh,v=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const x=_=>{var E,N;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!v)&&gg(_))return!1;const b=Kh(_.code,h);if(u.current.add(_[b]),qh(c,u.current,!1)){const P=((N=(E=_.composedPath)==null?void 0:E.call(_))==null?void 0:N[0])||_.target,w=(P==null?void 0:P.nodeName)==="BUTTON"||(P==null?void 0:P.nodeName)==="A";r.preventDefault!==!1&&(a.current||!w)&&_.preventDefault(),s(!0)}},y=_=>{const k=Kh(_.code,h);qh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},m=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",x),p==null||p.addEventListener("keyup",y),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{p==null||p.removeEventListener("keydown",x),p==null||p.removeEventListener("keyup",y),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,s]),o}function qh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Kh(t,r){return r.includes(t)?"code":"key"}const C_=()=>{const t=Ge();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=Nc(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),v={x:r.x-h,y:r.y-p},x=o.snapGrid??a,y=o.snapToGrid??u;return hs(v,s,y,x)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=Ji(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function zg(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)M_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function M_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function P_(t,r){return zg(t,r)}function I_(t,r){return zg(t,r)}function li(t,r){return{id:t,type:"select",selected:r}}function Gi(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(li(u.id,c)))}return s}function Qh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Zh(t){return{id:t.id,type:"remove"}}const R_=dg();function T_(t,r,o={}){return m1(t,r,{...o,onError:o.onError??R_})}const Jh=t=>t1(t),L_=t=>sg(t);function Dg(t){return L.forwardRef(t)}const Og=typeof window<"u"?L.useLayoutEffect:L.useEffect;function ep(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>A_(()=>o(a=>a+BigInt(1))));return Og(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function A_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Fg=L.createContext(null);function $_({children:t}){const r=Ge(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:v,hasDefaultNodes:x,onNodesChange:y,nodeLookup:m,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let b=p;for(const N of h)b=typeof N=="function"?N(b):N;let E=Qh({items:b,lookup:m});for(const N of k.values())E=N(E);x&&v(b),E.length>0?y==null||y(E):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:N,nodes:P,setNodes:w}=r.getState();N&&w(P)})},[]),s=ep(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:v,hasDefaultEdges:x,onEdgesChange:y,edgeLookup:m}=r.getState();let _=p;for(const k of h)_=typeof k=="function"?k(_):k;x?v(_):y&&y(Qh({items:_,lookup:m}))},[]),u=ep(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Fg.Provider,{value:c,children:t})}function z_(){const t=L.useContext(Fg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const D_=t=>!!t.panZoom;function Ql(){const t=C_(),r=Ge(),o=z_(),s=ze(D_),a=L.useMemo(()=>{const u=y=>r.getState().nodeLookup.get(y),c=y=>{o.nodeQueue.push(y)},h=y=>{o.edgeQueue.push(y)},p=y=>{var N,P;const{nodeLookup:m,nodeOrigin:_}=r.getState(),k=Jh(y)?y:m.get(y.id),b=k.parentId?hg(k.position,k.measured,k.parentId,m,_):k.position,E={...k,position:b,width:((N=k.measured)==null?void 0:N.width)??k.width,height:((P=k.measured)==null?void 0:P.height)??k.height};return is(E)},v=(y,m,_={replace:!1})=>{c(k=>k.map(b=>{if(b.id===y){const E=typeof m=="function"?m(b):m;return _.replace&&Jh(E)?E:{...b,...E}}return b}))},x=(y,m,_={replace:!1})=>{h(k=>k.map(b=>{if(b.id===y){const E=typeof m=="function"?m(b):m;return _.replace&&L_(E)?E:{...b,...E}}return b}))};return{getNodes:()=>r.getState().nodes.map(y=>({...y})),getNode:y=>{var m;return(m=u(y))==null?void 0:m.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:y=[]}=r.getState();return y.map(m=>({...m}))},getEdge:y=>r.getState().edgeLookup.get(y),setNodes:c,setEdges:h,addNodes:y=>{const m=Array.isArray(y)?y:[y];o.nodeQueue.push(_=>[..._,...m])},addEdges:y=>{const m=Array.isArray(y)?y:[y];o.edgeQueue.push(_=>[..._,...m])},toObject:()=>{const{nodes:y=[],edges:m=[],transform:_}=r.getState(),[k,b,E]=_;return{nodes:y.map(N=>({...N})),edges:m.map(N=>({...N})),viewport:{x:k,y:b,zoom:E}}},deleteElements:async({nodes:y=[],edges:m=[]})=>{const{nodes:_,edges:k,onNodesDelete:b,onEdgesDelete:E,triggerNodeChanges:N,triggerEdgeChanges:P,onDelete:w,onBeforeDelete:j}=r.getState(),{nodes:$,edges:D}=await s1({nodesToRemove:y,edgesToRemove:m,nodes:_,edges:k,onBeforeDelete:j}),B=D.length>0,Y=$.length>0;if(B){const Q=D.map(Zh);E==null||E(D),P(Q)}if(Y){const Q=$.map(Zh);b==null||b($),N(Q)}return(Y||B)&&(w==null||w({nodes:$,edges:D})),{deletedNodes:$,deletedEdges:D}},getIntersectingNodes:(y,m=!0,_)=>{const k=Nh(y),b=k?y:p(y),E=_!==void 0;return b?(_||r.getState().nodes).filter(N=>{const P=r.getState().nodeLookup.get(N.id);if(P&&!k&&(N.id===y.id||!P.internals.positionAbsolute))return!1;const w=is(E?N:P),j=Dl(w,b);return m&&j>0||j>=w.width*w.height||j>=b.width*b.height}):[]},isNodeIntersecting:(y,m,_=!0)=>{const b=Nh(y)?y:p(y);if(!b)return!1;const E=Dl(b,m);return _&&E>0||E>=m.width*m.height||E>=b.width*b.height},updateNode:v,updateNodeData:(y,m,_={replace:!1})=>{v(y,k=>{const b=typeof m=="function"?m(k):m;return _.replace?{...k,data:b}:{...k,data:{...k.data,...b}}},_)},updateEdge:x,updateEdgeData:(y,m,_={replace:!1})=>{x(y,k=>{const b=typeof m=="function"?m(k):m;return _.replace?{...k,data:b}:{...k,data:{...k.data,...b}}},_)},getNodesBounds:y=>{const{nodeLookup:m,nodeOrigin:_}=r.getState();return n1(y,{nodeLookup:m,nodeOrigin:_})},getHandleConnections:({type:y,id:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${y}${m?`-${m}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:y,handleId:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${y?m?`-${y}-${m}`:`-${y}`:""}`))==null?void 0:k.values())??[])},fitView:async y=>{const m=r.getState().fitViewResolver??u1();return r.setState({fitViewQueued:!0,fitViewOptions:y,fitViewResolver:m}),o.nodeQueue.push(_=>[..._]),m.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const tp=t=>t.selected,O_=typeof window<"u"?window:void 0;function F_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ge(),{deleteElements:s}=Ql(),a=ss(t,{actInsideInputWithModifier:!1}),u=ss(r,{target:O_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(tp),edges:c.filter(tp)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function H_(t){const r=Ge();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=jc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",mn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const Zl={position:"absolute",width:"100%",height:"100%",top:0,left:0},B_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function V_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=ci.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:v,translateExtent:x,minZoom:y,maxZoom:m,zoomActivationKeyCode:_,preventScrolling:k=!0,children:b,noWheelClassName:E,noPanClassName:N,onViewportChange:P,isControlledViewport:w,paneClickDistance:j,selectionOnDrag:$}){const D=Ge(),B=L.useRef(null),{userSelectionActive:Y,lib:Q,connectionInProgress:ne}=ze(B_,Qe),ee=ss(_),te=L.useRef();H_(B);const q=L.useCallback(C=>{P==null||P({x:C[0],y:C[1],zoom:C[2]}),w||D.setState({transform:C})},[P,w]);return L.useEffect(()=>{if(B.current){te.current=G1({domNode:B.current,minZoom:y,maxZoom:m,translateExtent:x,viewport:v,onDraggingChange:U=>D.setState(M=>M.paneDragging===U?M:{paneDragging:U}),onPanZoomStart:(U,M)=>{const{onViewportChangeStart:z,onMoveStart:F}=D.getState();F==null||F(U,M),z==null||z(M)},onPanZoom:(U,M)=>{const{onViewportChange:z,onMove:F}=D.getState();F==null||F(U,M),z==null||z(M)},onPanZoomEnd:(U,M)=>{const{onViewportChangeEnd:z,onMoveEnd:F}=D.getState();F==null||F(U,M),z==null||z(M)}});const{x:C,y:V,zoom:W}=te.current.getViewport();return D.setState({panZoom:te.current,transform:[C,V,W],domNode:B.current.closest(".react-flow")}),()=>{var U;(U=te.current)==null||U.destroy()}}},[]),L.useEffect(()=>{var C;(C=te.current)==null||C.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:ee,preventScrolling:k,noPanClassName:N,userSelectionActive:Y,noWheelClassName:E,lib:Q,onTransformChange:q,connectionInProgress:ne,selectionOnDrag:$,paneClickDistance:j})},[t,r,o,s,a,u,c,h,p,ee,k,N,Y,E,Q,q,ne,$,j]),d.jsx("div",{className:"react-flow__renderer",ref:B,style:Zl,children:b})}const W_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function U_(){const{userSelectionActive:t,userSelectionRect:r}=ze(W_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const Gu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},G_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function Y_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=ns.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:v,onPaneContextMenu:x,onPaneScroll:y,onPaneMouseEnter:m,onPaneMouseMove:_,onPaneMouseLeave:k,children:b}){const E=L.useRef(0),N=Ge(),{userSelectionActive:P,elementsSelectable:w,dragging:j,panBy:$,autoPanSpeed:D}=ze(G_,Qe),B=w&&(t||P),Y=L.useRef(null),Q=L.useRef(),ne=L.useRef(new Set),ee=L.useRef(new Set),te=L.useRef(!1),q=L.useRef(!1),C=L.useRef({x:0,y:0}),V=L.useRef(!1),W=Z=>{if(q.current||te.current||N.getState().connection.inProgress){q.current=!1,te.current=!1;return}v==null||v(Z),N.getState().resetSelectedElements(),N.setState({nodesSelectionActive:!1})},U=Z=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Z.preventDefault();return}x==null||x(Z)},M=y?Z=>y(Z):void 0,z=Z=>{q.current&&(Z.stopPropagation(),q.current=!1)},F=Z=>{var Ae,st;if(Z.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:se,transform:me}=N.getState();if(Q.current=se==null?void 0:se.getBoundingClientRect(),!Q.current)return;const Ne=Z.target===Y.current;if(!Ne&&!!Z.target.closest(".nokey")||!t||!(c&&Ne||r)||Z.button!==0||!Z.isPrimary)return;(st=(Ae=Z.target)==null?void 0:Ae.setPointerCapture)==null||st.call(Ae,Z.pointerId),q.current=!1;const{x:je,y:Me}=gn(Z.nativeEvent,Q.current),Re=hs({x:je,y:Me},me);N.setState({userSelectionRect:{width:0,height:0,startX:Re.x,startY:Re.y,x:je,y:Me}}),Ne||(Z.stopPropagation(),Z.preventDefault())};function R(Z,se){const{userSelectionRect:me}=N.getState();if(!me)return;const{transform:Ne,nodeLookup:ve,edgeLookup:re,connectionLookup:je,triggerNodeChanges:Me,triggerEdgeChanges:Re,defaultEdgeOptions:Ae}=N.getState(),st={x:me.startX,y:me.startY},{x:lt,y:at}=Ji(st,Ne),Ye={startX:st.x,startY:st.y,x:Zmt.id)),ee.current=new Set;const gt=(Ae==null?void 0:Ae.selectable)??!0;for(const mt of ne.current){const Pt=je.get(mt);if(Pt)for(const{edgeId:ut}of Pt.values()){const Je=re.get(ut);Je&&(Je.selectable??gt)&&ee.current.add(ut)}}if(!jh(wt,ne.current)){const mt=Gi(ve,ne.current,!0);Me(mt)}if(!jh(qt,ee.current)){const mt=Gi(re,ee.current);Re(mt)}N.setState({userSelectionRect:Ye,userSelectionActive:!0,nodesSelectionActive:!1})}function A(){if(!a||!Q.current)return;const[Z,se]=kc(C.current,Q.current,D);$({x:Z,y:se}).then(me=>{if(!q.current||!me){E.current=requestAnimationFrame(A);return}const{x:Ne,y:ve}=C.current;R(Ne,ve),E.current=requestAnimationFrame(A)})}const ie=()=>{cancelAnimationFrame(E.current),E.current=0,V.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=Z=>{const{userSelectionRect:se,transform:me,resetSelectedElements:Ne}=N.getState();if(!Q.current||!se)return;const{x:ve,y:re}=gn(Z.nativeEvent,Q.current);C.current={x:ve,y:re};const je=Ji({x:se.startX,y:se.startY},me);if(!q.current){const Me=r?0:u;if(Math.hypot(ve-je.x,re-je.y)<=Me)return;Ne(),h==null||h(Z)}q.current=!0,V.current||(A(),V.current=!0),R(ve,re)},fe=Z=>{var se,me;if(!B){Z.target===Y.current&&N.getState().connection.inProgress&&(te.current=!0);return}Z.button===0&&((me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),!P&&Z.target===Y.current&&N.getState().userSelectionRect&&(W==null||W(Z)),N.setState({userSelectionActive:!1,userSelectionRect:null}),q.current&&(p==null||p(Z),N.setState({nodesSelectionActive:ne.current.size>0})),ie())},he=Z=>{var se,me;(me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),ie()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:nt(["react-flow__pane",{draggable:pe,dragging:j,selection:t}]),onClick:B?void 0:Gu(W,Y),onContextMenu:Gu(U,Y),onWheel:Gu(M,Y),onPointerEnter:B?void 0:m,onPointerMove:B?oe:_,onPointerUp:fe,onPointerCancel:B?he:void 0,onPointerDownCapture:B?F:void 0,onClickCapture:B?z:void 0,onPointerLeave:k,ref:Y,style:Zl,children:[b,d.jsx(U_,{})]})}function dc({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),v=h.get(t);if(!v){p==null||p("012",mn.error012(t));return}r.setState({nodesSelectionActive:!1}),v.selected?(o||v.selected&&c)&&(u({nodes:[v],edges:[]}),requestAnimationFrame(()=>{var x;return(x=s==null?void 0:s.current)==null?void 0:x.blur()})):a([t])}function Hg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ge(),[p,v]=L.useState(!1),x=L.useRef();return L.useEffect(()=>{if(!r)return x.current=R1({getStoreItems:()=>h.getState(),onNodeMouseDown:y=>{dc({id:y,store:h,nodeRef:t})},onDragStart:()=>{v(!0)},onDragStop:()=>{v(!1)}}),()=>{var y;(y=x.current)==null||y.destroy(),x.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!x.current||x.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const X_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Bg(){const t=Ge();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:v,nodeOrigin:x}=t.getState(),y=new Map,m=X_(c),_=a?u[0]:5,k=a?u[1]:5,b=o.direction.x*_*o.factor,E=o.direction.y*k*o.factor;for(const[,N]of v){if(!m(N))continue;let P={x:N.internals.positionAbsolute.x+b,y:N.internals.positionAbsolute.y+E};a&&(P=fs(P,u));const{position:w,positionAbsolute:j}=lg({nodeId:N.id,nextPosition:P,nodeLookup:v,nodeExtent:s,nodeOrigin:x,onError:h});N.position=w,N.internals.positionAbsolute=j,y.set(N.id,N)}p(y)},[])}const Ic=L.createContext(null),q_=Ic.Provider;Ic.Consumer;const Vg=()=>L.useContext(Ic),K_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Wg=L.createContext(null);function Q_({children:t}){const r=ze(K_,Qe);return d.jsx(Wg.Provider,{value:r,children:t})}function Z_(){const t=L.useContext(Wg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const J_={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},eS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:v}=c;if(!h&&!a)return J_;const x=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:x,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Qi.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:x&&v}};function tS({type:t="source",position:r=ke.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:v,onMouseDown:x,onTouchStart:y,...m},_){var V,W;const k=c||null,b=t==="target",E=Ge(),N=Vg(),{connectOnClick:P,noPanClassName:w,rfId:j}=Z_(),{connectingFrom:$,connectingTo:D,clickConnecting:B,isPossibleEndHandle:Y,connectionInProcess:Q,clickConnectionInProcess:ne,valid:ee}=ze(eS(N,k,t),Qe);N||(W=(V=E.getState()).onError)==null||W.call(V,"010",mn.error010());const te=U=>{const{defaultEdgeOptions:M,onConnect:z,hasDefaultEdges:F}=E.getState(),R={...M,...U};if(F){const{edges:A,setEdges:ie,onError:oe}=E.getState();ie(T_(R,A,{onError:oe}))}z==null||z(R),h==null||h(R)},q=U=>{if(!N)return;const M=mg(U.nativeEvent);if(a&&(M&&U.button===0||!M)){const z=E.getState();cc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:z.autoPanOnConnect,connectionMode:z.connectionMode,connectionRadius:z.connectionRadius,domNode:z.domNode,nodeLookup:z.nodeLookup,lib:z.lib,isTarget:b,handleId:k,nodeId:N,flowId:z.rfId,panBy:z.panBy,cancelConnection:z.cancelConnection,onConnectStart:z.onConnectStart,onConnectEnd:(...F)=>{var R,A;return(A=(R=E.getState()).onConnectEnd)==null?void 0:A.call(R,...F)},updateConnection:z.updateConnection,onConnect:te,isValidConnection:o||((...F)=>{var R,A;return((A=(R=E.getState()).isValidConnection)==null?void 0:A.call(R,...F))??!0}),getTransform:()=>E.getState().transform,getFromHandle:()=>E.getState().connection.fromHandle,autoPanSpeed:z.autoPanSpeed,dragThreshold:z.connectionDragThreshold})}M?x==null||x(U):y==null||y(U)},C=U=>{const{onClickConnectStart:M,onClickConnectEnd:z,connectionClickStartHandle:F,connectionMode:R,isValidConnection:A,lib:ie,rfId:oe,nodeLookup:fe,connection:he}=E.getState();if(!N||!F&&!a)return;if(!F){M==null||M(U.nativeEvent,{nodeId:N,handleId:k,handleType:t}),E.setState({connectionClickStartHandle:{nodeId:N,type:t,id:k}});return}const pe=pg(U.target),Z=o||A,{connection:se,isValid:me}=cc.isValid(U.nativeEvent,{handle:{nodeId:N,id:k,type:t},connectionMode:R,fromNodeId:F.nodeId,fromHandleId:F.id||null,fromType:F.type,isValidConnection:Z,flowId:oe,doc:pe,lib:ie,nodeLookup:fe});me&&se&&te(se);const Ne=structuredClone(he);delete Ne.inProgress,Ne.toPosition=Ne.toHandle?Ne.toHandle.position:null,z==null||z(U,Ne),E.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":k,"data-nodeid":N,"data-handlepos":r,"data-id":`${j}-${N}-${k}-${t}`,className:nt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",w,v,{source:!b,target:b,connectable:s,connectablestart:a,connectableend:u,clickconnecting:B,connectingfrom:$,connectingto:D,valid:ee,connectionindicator:s&&(!Q||Y)&&(Q||ne?u:a)}]),onMouseDown:q,onTouchStart:q,onClick:P?C:void 0,ref:_,...m,children:p})}const to=L.memo(Dg(tS));function nS({data:t,isConnectable:r,sourcePosition:o=ke.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(to,{type:"source",position:o,isConnectable:r})]})}function rS({data:t,isConnectable:r,targetPosition:o=ke.Top,sourcePosition:s=ke.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(to,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(to,{type:"source",position:s,isConnectable:r})]})}function iS(){return null}function oS({data:t,isConnectable:r,targetPosition:o=ke.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(to,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const Ol={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},np={input:nS,default:rS,output:oS,group:iS};function sS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const lS=t=>{const{width:r,height:o,x:s,y:a}=ds(t.nodeLookup,{filter:u=>!!u.selected});return{width:pn(r)?r:null,height:pn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function aS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ge(),{width:a,height:u,transformString:c,userSelectionActive:h}=ze(lS,Qe),p=Bg(),v=L.useRef(null);L.useEffect(()=>{var _;o||(_=v.current)==null||_.focus({preventScroll:!0})},[o]);const x=!h&&a!==null&&u!==null;if(Hg({nodeRef:v,disabled:!x}),!x)return null;const y=t?_=>{const k=s.getState().nodes.filter(b=>b.selected);t(_,k)}:void 0,m=_=>{Object.prototype.hasOwnProperty.call(Ol,_.key)&&(_.preventDefault(),p({direction:Ol[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:nt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:v,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:o?void 0:-1,onKeyDown:o?void 0:m,style:{width:a,height:u}})})}const rp=typeof window<"u"?window:void 0,uS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Ug({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:v,selectionOnDrag:x,selectionMode:y,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:b,zoomActivationKeyCode:E,elementsSelectable:N,zoomOnScroll:P,zoomOnPinch:w,panOnScroll:j,panOnScrollSpeed:$,panOnScrollMode:D,zoomOnDoubleClick:B,panOnDrag:Y,autoPanOnSelection:Q,defaultViewport:ne,translateExtent:ee,minZoom:te,maxZoom:q,preventScrolling:C,onSelectionContextMenu:V,noWheelClassName:W,noPanClassName:U,disableKeyboardA11y:M,onViewportChange:z,isControlledViewport:F}){const{nodesSelectionActive:R,userSelectionActive:A}=ze(uS,Qe),ie=ss(v,{target:rp}),oe=ss(b,{target:rp}),fe=oe||Y,he=oe||j,pe=x&&fe!==!0,Z=ie||A||pe;return F_({deleteKeyCode:p,multiSelectionKeyCode:k}),d.jsx(V_,{onPaneContextMenu:u,elementsSelectable:N,zoomOnScroll:P,zoomOnPinch:w,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:$,panOnScrollMode:D,zoomOnDoubleClick:B,panOnDrag:!ie&&fe,defaultViewport:ne,translateExtent:ee,minZoom:te,maxZoom:q,zoomActivationKeyCode:E,preventScrolling:C,noWheelClassName:W,noPanClassName:U,onViewportChange:z,isControlledViewport:F,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(Y_,{onSelectionStart:m,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:Q,isSelecting:!!Z,selectionMode:y,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:pe,children:[t,R&&d.jsx(aS,{onSelectionContextMenu:V,noPanClassName:U,disableKeyboardA11y:M})]})})}Ug.displayName="FlowRenderer";const cS=L.memo(Ug),dS=t=>r=>t?Sc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function fS(t){return ze(L.useCallback(dS(t),[t]),Qe)}const hS=t=>t.updateNodeInternals;function pS(){const t=ze(hS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function gS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ge(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),v=L.useRef(r),x=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!x||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[x,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const y=v.current!==r,m=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(y||m||_)&&(v.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function mS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:v,nodesFocusable:x,resizeObserver:y,noDragClassName:m,noPanClassName:_,disableKeyboardA11y:k,rfId:b,nodeTypes:E,nodeClickDistance:N,onError:P}){const{node:w,internals:j,isParent:$}=ze(Z=>{const se=Z.nodeLookup.get(t),me=Z.parentLookup.has(t);return{node:se,internals:se.internals,isParent:me}},Qe);let D=w.type||"default",B=(E==null?void 0:E[D])||np[D];B===void 0&&(P==null||P("003",mn.error003(D)),D="default",B=(E==null?void 0:E.default)||np.default);const Y=!!(w.draggable||h&&typeof w.draggable>"u"),Q=!!(w.selectable||p&&typeof w.selectable>"u"),ne=!!(w.connectable||v&&typeof w.connectable>"u"),ee=!!(w.focusable||x&&typeof w.focusable>"u"),te=Ge(),q=fg(w),C=gS({node:w,nodeType:D,hasDimensions:q,resizeObserver:y}),V=Hg({nodeRef:C,disabled:w.hidden||!Y,noDragClassName:m,handleSelector:w.dragHandle,nodeId:t,isSelectable:Q,nodeClickDistance:N}),W=Bg();if(w.hidden)return null;const U=vn(w),M=sS(w),z=Q||Y||r||o||s||a,F=o?Z=>o(Z,{...j.userNode}):void 0,R=s?Z=>s(Z,{...j.userNode}):void 0,A=a?Z=>a(Z,{...j.userNode}):void 0,ie=u?Z=>u(Z,{...j.userNode}):void 0,oe=c?Z=>c(Z,{...j.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:se,nodeDragThreshold:me}=te.getState();Q&&(!se||!Y||me>0)&&dc({id:t,store:te,nodeRef:C}),r&&r(Z,{...j.userNode})},he=Z=>{if(!(gg(Z.nativeEvent)||k)){if(ng.includes(Z.key)&&Q){const se=Z.key==="Escape";dc({id:t,store:te,unselect:se,nodeRef:C})}else if(Y&&w.selected&&Object.prototype.hasOwnProperty.call(Ol,Z.key)){Z.preventDefault();const{ariaLabelConfig:se}=te.getState();te.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),W({direction:Ol[Z.key],factor:Z.shiftKey?4:1})}}},pe=()=>{var je;if(k||!((je=C.current)!=null&&je.matches(":focus-visible")))return;const{transform:Z,width:se,height:me,autoPanOnNodeFocus:Ne,setCenter:ve}=te.getState();if(!Ne)return;Sc(new Map([[t,w]]),{x:0,y:0,width:se,height:me},Z,!0).length>0||ve(w.position.x+U.width/2,w.position.y+U.height/2,{zoom:Z[2]})};return d.jsx("div",{className:nt(["react-flow__node",`react-flow__node-${D}`,{[_]:Y},w.className,{selected:w.selected,selectable:Q,parent:$,draggable:Y,dragging:V}]),ref:C,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:z?"all":"none",visibility:q?"visible":"hidden",...w.style,...M},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:F,onMouseMove:R,onMouseLeave:A,onContextMenu:ie,onClick:fe,onDoubleClick:oe,onKeyDown:ee?he:void 0,tabIndex:ee?0:void 0,onFocus:ee?pe:void 0,role:w.ariaRole??(ee?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${Lg}-${b}`,"aria-label":w.ariaLabel,...w.domAttributes,children:d.jsx(q_,{value:t,children:d.jsx(B,{id:t,data:w.data,type:D,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:w.selected??!1,selectable:Q,draggable:Y,deletable:w.deletable??!0,isConnectable:ne,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:V,dragHandle:w.dragHandle,zIndex:j.z,parentId:w.parentId,...U})})})}var yS=L.memo(mS);const vS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Gg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=ze(vS,Qe),u=fS(t.onlyRenderVisibleElements),c=pS();return d.jsx("div",{className:"react-flow__nodes",style:Zl,children:u.map(h=>d.jsx(yS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Gg.displayName="NodeRenderer";const xS=L.memo(Gg);function wS(t){return ze(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&h1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const _S=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},SS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ip={[rs.Arrow]:_S,[rs.ArrowClosed]:SS};function kS(t){const r=Ge();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(ip,t)?ip[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",mn.error009(t)),null)},[t])}const NS=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=kS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},Yg=({defaultColor:t,rfId:r})=>{const o=ze(u=>u.edges),s=ze(u=>u.defaultEdgeOptions),a=L.useMemo(()=>_1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(NS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Yg.displayName="MarkerDefinitions";var jS=L.memo(Yg);function Xg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:v,...x}){const[y,m]=L.useState({x:1,y:0,width:0,height:0}),_=nt(["react-flow__edge-textwrapper",v]),k=L.useRef(null);return L.useEffect(()=>{if(k.current){const b=k.current.getBBox();m({x:b.x,y:b.y,width:b.width,height:b.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-y.width/2} ${r-y.height/2})`,className:_,visibility:y.width?"visible":"hidden",...x,children:[a&&d.jsx("rect",{width:y.width+2*c[0],x:-c[0],y:-c[1],height:y.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:k,style:s,children:o}),p]}):null}Xg.displayName="EdgeText";const bS=L.memo(Xg);function Jl({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:v=20,...x}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...x,d:t,fill:"none",className:nt(["react-flow__edge-path",x.className])}),v?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:v,className:"react-flow__edge-interaction"}):null,s&&pn(r)&&pn(o)?d.jsx(bS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function op({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===ke.Left||t===ke.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function qg({sourceX:t,sourceY:r,sourcePosition:o=ke.Bottom,targetX:s,targetY:a,targetPosition:u=ke.Top}){const[c,h]=op({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,v]=op({pos:u,x1:s,y1:a,x2:t,y2:r}),[x,y,m,_]=yg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:v});return[`M${t},${r} C${c},${h} ${p},${v} ${s},${a}`,x,y,m,_]}function Kg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,interactionWidth:N})=>{const[P,w,j]=qg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),$=t.isInternal?void 0:r;return d.jsx(Jl,{id:$,path:P,labelX:w,labelY:j,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,interactionWidth:N})})}const ES=Kg({isInternal:!1}),Qg=Kg({isInternal:!0});ES.displayName="SimpleBezierEdge";Qg.displayName="SimpleBezierEdgeInternal";function Zg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,sourcePosition:_=ke.Bottom,targetPosition:k=ke.Top,markerEnd:b,markerStart:E,pathOptions:N,interactionWidth:P})=>{const[w,j,$]=lc({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:N==null?void 0:N.borderRadius,offset:N==null?void 0:N.offset,stepPosition:N==null?void 0:N.stepPosition}),D=t.isInternal?void 0:r;return d.jsx(Jl,{id:D,path:w,labelX:j,labelY:$,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:b,markerStart:E,interactionWidth:P})})}const Jg=Zg({isInternal:!1}),em=Zg({isInternal:!0});Jg.displayName="SmoothStepEdge";em.displayName="SmoothStepEdgeInternal";function tm(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(Jg,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const CS=tm({isInternal:!1}),nm=tm({isInternal:!0});CS.displayName="StepEdge";nm.displayName="StepEdgeInternal";function rm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:b})=>{const[E,N,P]=wg({sourceX:o,sourceY:s,targetX:a,targetY:u}),w=t.isInternal?void 0:r;return d.jsx(Jl,{id:w,path:E,labelX:N,labelY:P,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:b})})}const MS=rm({isInternal:!1}),im=rm({isInternal:!0});MS.displayName="StraightEdge";im.displayName="StraightEdgeInternal";function om(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=ke.Bottom,targetPosition:h=ke.Top,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,pathOptions:N,interactionWidth:P})=>{const[w,j,$]=vg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:N==null?void 0:N.curvature}),D=t.isInternal?void 0:r;return d.jsx(Jl,{id:D,path:w,labelX:j,labelY:$,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,interactionWidth:P})})}const PS=om({isInternal:!1}),sm=om({isInternal:!0});PS.displayName="BezierEdge";sm.displayName="BezierEdgeInternal";const sp={default:sm,straight:im,step:nm,smoothstep:em,simplebezier:Qg},lp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},IS=(t,r,o)=>o===ke.Left?t-r:o===ke.Right?t+r:t,RS=(t,r,o)=>o===ke.Top?t-r:o===ke.Bottom?t+r:t,ap="react-flow__edgeupdater";function up({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:nt([ap,`${ap}-${h}`]),cx:IS(r,s,t),cy:RS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function TS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:v,onReconnectStart:x,onReconnectEnd:y,setReconnecting:m,setUpdateHover:_}){const k=Ge(),b=(j,$)=>{if(j.button!==0)return;const{autoPanOnConnect:D,domNode:B,connectionMode:Y,connectionRadius:Q,lib:ne,onConnectStart:ee,cancelConnection:te,nodeLookup:q,rfId:C,panBy:V,updateConnection:W}=k.getState(),U=$.type==="target",M=(R,A)=>{m(!1),y==null||y(R,o,$.type,A)},z=R=>v==null?void 0:v(o,R),F=(R,A)=>{m(!0),x==null||x(j,o,$.type),ee==null||ee(R,A)};cc.onPointerDown(j.nativeEvent,{autoPanOnConnect:D,connectionMode:Y,connectionRadius:Q,domNode:B,handleId:$.id,nodeId:$.nodeId,nodeLookup:q,isTarget:U,edgeUpdaterType:$.type,lib:ne,flowId:C,cancelConnection:te,panBy:V,isValidConnection:(...R)=>{var A,ie;return((ie=(A=k.getState()).isValidConnection)==null?void 0:ie.call(A,...R))??!0},onConnect:z,onConnectStart:F,onConnectEnd:(...R)=>{var A,ie;return(ie=(A=k.getState()).onConnectEnd)==null?void 0:ie.call(A,...R)},onReconnectEnd:M,updateConnection:W,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},E=j=>b(j,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),N=j=>b(j,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),P=()=>_(!0),w=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(up,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:E,onMouseEnter:P,onMouseOut:w,type:"source"}),(t===!0||t==="target")&&d.jsx(up,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:N,onMouseEnter:P,onMouseOut:w,type:"target"})]})}function LS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,rfId:k,edgeTypes:b,noPanClassName:E,onError:N,disableKeyboardA11y:P}){let w=ze(ve=>ve.edgeLookup.get(t));const j=ze(ve=>ve.defaultEdgeOptions);w=j?{...j,...w}:w;let $=w.type||"default",D=(b==null?void 0:b[$])||sp[$];D===void 0&&(N==null||N("011",mn.error011($)),$="default",D=(b==null?void 0:b.default)||sp.default);const B=!!(w.focusable||r&&typeof w.focusable>"u"),Y=typeof y<"u"&&(w.reconnectable||o&&typeof w.reconnectable>"u"),Q=!!(w.selectable||s&&typeof w.selectable>"u"),ne=L.useRef(null),[ee,te]=L.useState(!1),[q,C]=L.useState(!1),V=Ge(),{zIndex:W=w.zIndex,sourceX:U,sourceY:M,targetX:z,targetY:F,sourcePosition:R,targetPosition:A}=ze(L.useCallback(ve=>{const re=ve.nodeLookup.get(w.source),je=ve.nodeLookup.get(w.target);if(!re||!je)return lp;const Me=w1({id:t,sourceNode:re,targetNode:je,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:ve.connectionMode,onError:N}),Re=f1({selected:w.selected,zIndex:w.zIndex,sourceNode:re,targetNode:je,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||lp,zIndex:Re}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex,N]),Qe),ie=L.useMemo(()=>w.markerStart?`url('#${ac(w.markerStart,k)}')`:void 0,[w.markerStart,k]),oe=L.useMemo(()=>w.markerEnd?`url('#${ac(w.markerEnd,k)}')`:void 0,[w.markerEnd,k]);if(w.hidden||U===null||M===null||z===null||F===null)return null;const fe=ve=>{var Re;const{addSelectedEdges:re,unselectNodesAndEdges:je,multiSelectionActive:Me}=V.getState();Q&&(V.setState({nodesSelectionActive:!1}),w.selected&&Me?(je({nodes:[],edges:[w]}),(Re=ne.current)==null||Re.blur()):re([t])),a&&a(ve,w)},he=u?ve=>{u(ve,{...w})}:void 0,pe=c?ve=>{c(ve,{...w})}:void 0,Z=h?ve=>{h(ve,{...w})}:void 0,se=p?ve=>{p(ve,{...w})}:void 0,me=v?ve=>{v(ve,{...w})}:void 0,Ne=ve=>{var re;if(!P&&ng.includes(ve.key)&&Q){const{unselectNodesAndEdges:je,addSelectedEdges:Me}=V.getState();ve.key==="Escape"?((re=ne.current)==null||re.blur(),je({edges:[w]})):Me([t])}};return d.jsx("svg",{style:{zIndex:W},children:d.jsxs("g",{className:nt(["react-flow__edge",`react-flow__edge-${$}`,w.className,E,{selected:w.selected,animated:w.animated,inactive:!Q&&!a,updating:ee,selectable:Q}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:Z,onMouseMove:se,onMouseLeave:me,onKeyDown:B?Ne:void 0,tabIndex:B?0:void 0,role:w.ariaRole??(B?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":B?`${Ag}-${k}`:void 0,ref:ne,...w.domAttributes,children:[!q&&d.jsx(D,{id:t,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:Q,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:U,sourceY:M,targetX:z,targetY:F,sourcePosition:R,targetPosition:A,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),Y&&d.jsx(TS,{edge:w,isReconnectable:Y,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,sourceX:U,sourceY:M,targetX:z,targetY:F,sourcePosition:R,targetPosition:A,setUpdateHover:te,setReconnecting:C})]})})}var AS=L.memo(LS);const $S=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function lm({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:v,onEdgeClick:x,reconnectRadius:y,onEdgeDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:b}){const{edgesFocusable:E,edgesReconnectable:N,elementsSelectable:P,onError:w}=ze($S,Qe),j=wS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(jS,{defaultColor:t,rfId:o}),j.map($=>d.jsx(AS,{id:$,edgesFocusable:E,edgesReconnectable:N,elementsSelectable:P,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,onClick:x,reconnectRadius:y,onDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:w,edgeTypes:s,disableKeyboardA11y:b},$))]})}lm.displayName="EdgeRenderer";const zS=L.memo(lm),cp=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function DS({children:t}){const r=Ge(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return Og(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=cp(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:cp(s)},children:t})}function OS(t){const r=Ql(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const FS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function HS(t){const r=ze(FS),o=Ge();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function BS(t){return t.connection.inProgress?{...t.connection,to:hs(t.connection.to,t.transform)}:{...t.connection}}function VS(t){return BS}function WS(t){const r=VS();return ze(r,Qe)}const US=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function GS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=ze(US,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:nt(["react-flow__connection",og(h)]),children:d.jsx(am,{style:r,type:o,CustomComponent:s,isValid:h})})})}const am=({style:t,type:r=Lr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:v,toNode:x,toHandle:y,toPosition:m,pointer:_}=WS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:v.x,toY:v.y,fromPosition:p,toPosition:m,connectionStatus:og(s),toNode:x,toHandle:y,pointer:_});let k="";const b={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:v.x,targetY:v.y,targetPosition:m};switch(r){case Lr.Bezier:[k]=vg(b);break;case Lr.SimpleBezier:[k]=qg(b);break;case Lr.Step:[k]=lc({...b,borderRadius:0});break;case Lr.SmoothStep:[k]=lc(b);break;default:[k]=wg(b)}return d.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};am.displayName="ConnectionLine";const YS={};function dp(t=YS){L.useRef(t),Ge(),L.useEffect(()=>{},[t])}function XS(){Ge(),L.useRef(!1),L.useEffect(()=>{},[])}function um({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,onSelectionContextMenu:y,onSelectionStart:m,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:b,connectionLineComponent:E,connectionLineContainerStyle:N,selectionKeyCode:P,selectionOnDrag:w,selectionMode:j,multiSelectionKeyCode:$,panActivationKeyCode:D,zoomActivationKeyCode:B,deleteKeyCode:Y,onlyRenderVisibleElements:Q,elementsSelectable:ne,defaultViewport:ee,translateExtent:te,minZoom:q,maxZoom:C,preventScrolling:V,defaultMarkerColor:W,zoomOnScroll:U,zoomOnPinch:M,panOnScroll:z,panOnScrollSpeed:F,panOnScrollMode:R,zoomOnDoubleClick:A,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneScroll:se,onPaneContextMenu:me,paneClickDistance:Ne,nodeClickDistance:ve,onEdgeContextMenu:re,onEdgeMouseEnter:je,onEdgeMouseMove:Me,onEdgeMouseLeave:Re,reconnectRadius:Ae,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,noDragClassName:Ye,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,viewport:ut,onViewportChange:Je,nodesDraggable:An}){return dp(t),dp(r),XS(),OS(o),HS(ut),d.jsx(cS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneContextMenu:me,onPaneScroll:se,paneClickDistance:Ne,deleteKeyCode:Y,selectionKeyCode:P,selectionOnDrag:w,selectionMode:j,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:$,panActivationKeyCode:D,zoomActivationKeyCode:B,elementsSelectable:ne,zoomOnScroll:U,zoomOnPinch:M,zoomOnDoubleClick:A,panOnScroll:z,panOnScrollSpeed:F,panOnScrollMode:R,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:ee,translateExtent:te,minZoom:q,maxZoom:C,onSelectionContextMenu:y,preventScrolling:V,noDragClassName:Ye,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,onViewportChange:Je,isControlledViewport:!!ut,children:d.jsxs(DS,{children:[d.jsx(zS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,onlyRenderVisibleElements:Q,onEdgeContextMenu:re,onEdgeMouseEnter:je,onEdgeMouseMove:Me,onEdgeMouseLeave:Re,reconnectRadius:Ae,defaultMarkerColor:W,noPanClassName:qt,disableKeyboardA11y:gt,rfId:Pt}),d.jsx(GS,{style:b,type:k,component:E,containerStyle:N}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(xS,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,nodeClickDistance:ve,onlyRenderVisibleElements:Q,noPanClassName:qt,noDragClassName:Ye,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,nodesDraggable:An}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}um.displayName="GraphView";const qS=L.memo(um),KS=dg(),fp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:v=2,nodeOrigin:x,nodeExtent:y,zIndexMode:m="basic"}={})=>{const _=new Map,k=new Map,b=new Map,E=new Map,N=s??r??[],P=o??t??[],w=x??[0,0],j=y??ts;kg(b,E,N);const{nodesInitialized:$}=uc(P,_,k,{nodeOrigin:w,nodeExtent:j,zIndexMode:m});let D=[0,0,1];if(c&&a&&u){const B=ds(_,{filter:ee=>!!((ee.width||ee.initialWidth)&&(ee.height||ee.initialHeight))}),{x:Y,y:Q,zoom:ne}=Nc(B,a,u,p,v,(h==null?void 0:h.padding)??.1);D=[Y,Q,ne]}return{rfId:"1",width:a??0,height:u??0,transform:D,nodes:P,nodesInitialized:$,nodeLookup:_,parentLookup:k,edges:N,edgeLookup:E,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:v,translateExtent:ts,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Qi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...ig},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:KS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:rg,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},QS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m})=>u_((_,k)=>{async function b(){const{nodeLookup:E,panZoom:N,fitViewOptions:P,fitViewResolver:w,width:j,height:$,minZoom:D,maxZoom:B}=k();N&&(await o1({nodes:E,width:j,height:$,panZoom:N,minZoom:D,maxZoom:B},P),w==null||w.resolve(!0),_({fitViewResolver:null}))}return{...fp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,defaultNodes:o,defaultEdges:s,zIndexMode:m}),setNodes:E=>{const{nodeLookup:N,parentLookup:P,nodeOrigin:w,nodeExtent:j,elevateNodesOnSelect:$,fitViewQueued:D,zIndexMode:B,nodesSelectionActive:Y}=k(),{nodesInitialized:Q,hasSelectedNodes:ne}=uc(E,N,P,{nodeOrigin:w,nodeExtent:j,elevateNodesOnSelect:$,checkEquality:!0,zIndexMode:B}),ee=Y&≠D&&Q?(b(),_({nodes:E,nodesInitialized:Q,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:ee})):_({nodes:E,nodesInitialized:Q,nodesSelectionActive:ee})},setEdges:E=>{const{connectionLookup:N,edgeLookup:P}=k();kg(N,P,E),_({edges:E})},setDefaultNodesAndEdges:(E,N)=>{if(E){const{setNodes:P}=k();P(E),_({hasDefaultNodes:!0})}if(N){const{setEdges:P}=k();P(N),_({hasDefaultEdges:!0})}},updateNodeInternals:E=>{const{triggerNodeChanges:N,nodeLookup:P,parentLookup:w,domNode:j,nodeOrigin:$,nodeExtent:D,debug:B,fitViewQueued:Y,zIndexMode:Q}=k(),{changes:ne,updatedInternals:ee}=C1(E,P,w,j,$,D,Q);ee&&(N1(P,w,{nodeOrigin:$,nodeExtent:D,zIndexMode:Q}),Y?(b(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(ne==null?void 0:ne.length)>0&&(B&&console.log("React Flow: trigger node changes",ne),N==null||N(ne)))},updateNodePositions:(E,N=!1)=>{const P=[];let w=[];const{nodeLookup:j,triggerNodeChanges:$,connection:D,updateConnection:B,onNodesChangeMiddlewareMap:Y}=k();for(const[Q,ne]of E){const ee=j.get(Q),te=!!(ee!=null&&ee.expandParent&&(ee!=null&&ee.parentId)&&(ne!=null&&ne.position)),q={id:Q,type:"position",position:te?{x:Math.max(0,ne.position.x),y:Math.max(0,ne.position.y)}:ne.position,dragging:N};if(ee&&D.inProgress&&D.fromNode.id===ee.id){const C=gi(ee,D.fromHandle,ke.Left,!0);B({...D,from:C})}te&&ee.parentId&&P.push({id:Q,parentId:ee.parentId,rect:{...ne.internals.positionAbsolute,width:ne.measured.width??0,height:ne.measured.height??0}}),w.push(q)}if(P.length>0){const{parentLookup:Q,nodeOrigin:ne}=k(),ee=Pc(P,j,Q,ne);w.push(...ee)}for(const Q of Y.values())w=Q(w);$(w)},triggerNodeChanges:E=>{const{onNodesChange:N,setNodes:P,nodes:w,hasDefaultNodes:j,debug:$}=k();if(E!=null&&E.length){if(j){const D=P_(E,w);P(D)}$&&console.log("React Flow: trigger node changes",E),N==null||N(E)}},triggerEdgeChanges:E=>{const{onEdgesChange:N,setEdges:P,edges:w,hasDefaultEdges:j,debug:$}=k();if(E!=null&&E.length){if(j){const D=I_(E,w);P(D)}$&&console.log("React Flow: trigger edge changes",E),N==null||N(E)}},addSelectedNodes:E=>{const{multiSelectionActive:N,edgeLookup:P,nodeLookup:w,triggerNodeChanges:j,triggerEdgeChanges:$}=k();if(N){const D=E.map(B=>li(B,!0));j(D);return}j(Gi(w,new Set([...E]),!0)),$(Gi(P))},addSelectedEdges:E=>{const{multiSelectionActive:N,edgeLookup:P,nodeLookup:w,triggerNodeChanges:j,triggerEdgeChanges:$}=k();if(N){const D=E.map(B=>li(B,!0));$(D);return}$(Gi(P,new Set([...E]))),j(Gi(w,new Set,!0))},unselectNodesAndEdges:({nodes:E,edges:N}={})=>{const{edges:P,nodes:w,nodeLookup:j,triggerNodeChanges:$,triggerEdgeChanges:D}=k(),B=E||w,Y=N||P,Q=[];for(const ee of B){if(!ee.selected)continue;const te=j.get(ee.id);te&&(te.selected=!1),Q.push(li(ee.id,!1))}const ne=[];for(const ee of Y)ee.selected&&ne.push(li(ee.id,!1));$(Q),D(ne)},setMinZoom:E=>{const{panZoom:N,maxZoom:P}=k();N==null||N.setScaleExtent([E,P]),_({minZoom:E})},setMaxZoom:E=>{const{panZoom:N,minZoom:P}=k();N==null||N.setScaleExtent([P,E]),_({maxZoom:E})},setTranslateExtent:E=>{var N;(N=k().panZoom)==null||N.setTranslateExtent(E),_({translateExtent:E})},resetSelectedElements:()=>{const{edges:E,nodes:N,triggerNodeChanges:P,triggerEdgeChanges:w,elementsSelectable:j}=k();if(!j)return;const $=N.reduce((B,Y)=>Y.selected?[...B,li(Y.id,!1)]:B,[]),D=E.reduce((B,Y)=>Y.selected?[...B,li(Y.id,!1)]:B,[]);P($),w(D)},setNodeExtent:E=>{const{nodes:N,nodeLookup:P,parentLookup:w,nodeOrigin:j,elevateNodesOnSelect:$,nodeExtent:D,zIndexMode:B}=k();E[0][0]===D[0][0]&&E[0][1]===D[0][1]&&E[1][0]===D[1][0]&&E[1][1]===D[1][1]||(uc(N,P,w,{nodeOrigin:j,nodeExtent:E,elevateNodesOnSelect:$,checkEquality:!1,zIndexMode:B}),_({nodeExtent:E}))},panBy:E=>{const{transform:N,width:P,height:w,panZoom:j,translateExtent:$}=k();return M1({delta:E,panZoom:j,transform:N,translateExtent:$,width:P,height:w})},setCenter:async(E,N,P)=>{const{width:w,height:j,maxZoom:$,panZoom:D}=k();if(!D)return!1;const B=typeof(P==null?void 0:P.zoom)<"u"?P.zoom:$;return await D.setViewport({x:w/2-E*B,y:j/2-N*B,zoom:B},{duration:P==null?void 0:P.duration,ease:P==null?void 0:P.ease,interpolate:P==null?void 0:P.interpolate}),!0},cancelConnection:()=>{_({connection:{...ig}})},updateConnection:E=>{_({connection:E})},reset:()=>_({...fp()})}},Object.is);function cm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m,children:_}){const[k]=L.useState(()=>QS({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:v,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:x,nodeExtent:y,zIndexMode:m}));return d.jsx(c_,{value:k,children:d.jsx($_,{children:d.jsx(Q_,{children:_})})})}function ZS({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:v,maxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_}){return L.useContext(ql)?d.jsx(d.Fragment,{children:t}):d.jsx(cm,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:v,initialMaxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_,children:t})}const JS={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function ek({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:v,onMove:x,onMoveStart:y,onMoveEnd:m,onConnect:_,onConnectStart:k,onConnectEnd:b,onClickConnectStart:E,onClickConnectEnd:N,onNodeMouseEnter:P,onNodeMouseMove:w,onNodeMouseLeave:j,onNodeContextMenu:$,onNodeDoubleClick:D,onNodeDragStart:B,onNodeDrag:Y,onNodeDragStop:Q,onNodesDelete:ne,onEdgesDelete:ee,onDelete:te,onSelectionChange:q,onSelectionDragStart:C,onSelectionDrag:V,onSelectionDragStop:W,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:z,onBeforeDelete:F,connectionMode:R,connectionLineType:A=Lr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:Z=!1,selectionMode:se=ns.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:Ne=os()?"Meta":"Control",zoomActivationKeyCode:ve=os()?"Meta":"Control",snapToGrid:re,snapGrid:je,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Re,nodesDraggable:Ae,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,nodeOrigin:Ye=$g,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt=!0,defaultViewport:mt=k_,minZoom:Pt=.5,maxZoom:ut=2,translateExtent:Je=ts,preventScrolling:An=!0,nodeExtent:Ot,defaultMarkerColor:xn="#b1b1b7",zoomOnScroll:ro=!0,zoomOnPinch:$n=!0,panOnScroll:yi=!1,panOnScrollSpeed:ir=.5,panOnScrollMode:$r=ci.Free,zoomOnDoubleClick:zn=!0,panOnDrag:zr=!0,onPaneClick:or,onPaneMouseEnter:sr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn=1,nodeClickDistance:Fn=0,children:_n,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:lr,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn=10,onNodesChange:Ht,onEdgesChange:Or,noDragClassName:nn="nodrag",noWheelClassName:Fr="nowheel",noPanClassName:yt="nopan",fitView:Hn,fitViewOptions:ar,connectOnClick:io,attributionPosition:It,proOptions:Bn,defaultEdgeOptions:Hr,elevateNodesOnSelect:jn=!0,elevateEdgesOnSelect:Br=!1,disableKeyboardA11y:vi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:oo,autoPanOnSelection:Vr=!0,autoPanSpeed:xi,connectionRadius:ur,isValidConnection:so,onError:cr,style:Vn,id:bt,nodeDragThreshold:Wr,connectionDragThreshold:Et,viewport:lo,onViewportChange:Ur,width:Gr,height:Wn,colorMode:Un="light",debug:bn,onScroll:Bt,ariaLabelConfig:wi,zIndexMode:Yr="basic",...dr},fr){const Gn=bt||"1",En=E_(Un),ao=L.useCallback(hr=>{hr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Bt==null||Bt(hr)},[Bt]);return d.jsx("div",{"data-testid":"rf__wrapper",...dr,onScroll:ao,style:{...Vn,...JS},ref:fr,className:nt(["react-flow",a,En]),id:bt,role:"application",children:d.jsxs(ZS,{nodes:t,edges:r,width:Gr,height:Wn,fitView:Hn,fitViewOptions:ar,minZoom:Pt,maxZoom:ut,nodeOrigin:Ye,nodeExtent:Ot,zIndexMode:Yr,children:[d.jsx(b_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:k,onConnectEnd:b,onClickConnectStart:E,onClickConnectEnd:N,nodesDraggable:Ae,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt,elevateNodesOnSelect:jn,elevateEdgesOnSelect:Br,minZoom:Pt,maxZoom:ut,nodeExtent:Ot,onNodesChange:Ht,onEdgesChange:Or,snapToGrid:re,snapGrid:je,connectionMode:R,translateExtent:Je,connectOnClick:io,defaultEdgeOptions:Hr,fitView:Hn,fitViewOptions:ar,onNodesDelete:ne,onEdgesDelete:ee,onDelete:te,onNodeDragStart:B,onNodeDrag:Y,onNodeDragStop:Q,onSelectionDrag:V,onSelectionDragStart:C,onSelectionDragStop:W,onMove:x,onMoveStart:y,onMoveEnd:m,noPanClassName:yt,nodeOrigin:Ye,rfId:Gn,autoPanOnConnect:Ve,autoPanOnNodeDrag:oo,autoPanSpeed:xi,onError:cr,connectionRadius:ur,isValidConnection:so,selectNodesOnDrag:Re,nodeDragThreshold:Wr,connectionDragThreshold:Et,onBeforeDelete:F,debug:bn,ariaLabelConfig:wi,zIndexMode:Yr}),d.jsx(qS,{onInit:v,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:P,onNodeMouseMove:w,onNodeMouseLeave:j,onNodeContextMenu:$,onNodeDoubleClick:D,nodeTypes:u,edgeTypes:c,connectionLineType:A,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:Z,selectionMode:se,deleteKeyCode:he,multiSelectionKeyCode:Ne,panActivationKeyCode:me,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:mt,translateExtent:Je,minZoom:Pt,maxZoom:ut,preventScrolling:An,zoomOnScroll:ro,zoomOnPinch:$n,zoomOnDoubleClick:zn,panOnScroll:yi,panOnScrollSpeed:ir,panOnScrollMode:$r,panOnDrag:zr,autoPanOnSelection:Vr,onPaneClick:or,onPaneMouseEnter:sr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn,nodeClickDistance:Fn,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:z,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:lr,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn,defaultMarkerColor:xn,noDragClassName:nn,noWheelClassName:Fr,noPanClassName:yt,rfId:Gn,disableKeyboardA11y:vi,nodeExtent:Ot,viewport:lo,onViewportChange:Ur,nodesDraggable:Ae}),d.jsx(S_,{onSelectionChange:q}),_n,d.jsx(y_,{proOptions:Bn,position:It}),d.jsx(m_,{rfId:Gn,disableKeyboardA11y:vi})]})})}var tk=Dg(ek);function nk({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:nt(["react-flow__background-pattern",o,s])})}function rk({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:nt(["react-flow__background-pattern","dots",r])})}var Ar;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Ar||(Ar={}));const ik={[Ar.Dots]:1,[Ar.Lines]:1,[Ar.Cross]:6},ok=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function dm({id:t,variant:r=Ar.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:v,patternClassName:x}){const y=L.useRef(null),{transform:m,patternId:_}=ze(ok,Qe),k=s||ik[r],b=r===Ar.Dots,E=r===Ar.Cross,N=Array.isArray(o)?o:[o,o],P=[N[0]*m[2]||1,N[1]*m[2]||1],w=k*m[2],j=Array.isArray(u)?u:[u,u],$=E?[w,w]:P,D=[j[0]*m[2]+$[0]/2,j[1]*m[2]+$[1]/2],B=`${_}${t||""}`;return d.jsxs("svg",{className:nt(["react-flow__background",v]),style:{...p,...Zl,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:y,"data-testid":"rf__background",children:[d.jsx("pattern",{id:B,x:m[0]%P[0],y:m[1]%P[1],width:P[0],height:P[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${D[0]},-${D[1]})`,children:b?d.jsx(rk,{radius:w/2,className:x}):d.jsx(nk,{dimensions:$,lineWidth:a,variant:r,className:x})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${B})`})]})}dm.displayName="Background";const sk=L.memo(dm);function lk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ak(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function uk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 ck(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 Sl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:nt(["react-flow__controls-button",r]),...o,children:t})}const fk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function fm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:v,children:x,position:y="bottom-left",orientation:m="vertical","aria-label":_}){const k=Ge(),{isInteractive:b,minZoomReached:E,maxZoomReached:N,ariaLabelConfig:P}=ze(fk,Qe),{zoomIn:w,zoomOut:j,fitView:$}=Ql(),D=()=>{w(),u==null||u()},B=()=>{j(),c==null||c()},Y=()=>{$(a),h==null||h()},Q=()=>{k.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),p==null||p(!b)},ne=m==="horizontal"?"horizontal":"vertical";return d.jsxs(Kl,{className:nt(["react-flow__controls",ne,v]),position:y,style:t,"data-testid":"rf__controls","aria-label":_??P["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(Sl,{onClick:D,className:"react-flow__controls-zoomin",title:P["controls.zoomIn.ariaLabel"],"aria-label":P["controls.zoomIn.ariaLabel"],disabled:N,children:d.jsx(lk,{})}),d.jsx(Sl,{onClick:B,className:"react-flow__controls-zoomout",title:P["controls.zoomOut.ariaLabel"],"aria-label":P["controls.zoomOut.ariaLabel"],disabled:E,children:d.jsx(ak,{})})]}),o&&d.jsx(Sl,{className:"react-flow__controls-fitview",onClick:Y,title:P["controls.fitView.ariaLabel"],"aria-label":P["controls.fitView.ariaLabel"],children:d.jsx(uk,{})}),s&&d.jsx(Sl,{className:"react-flow__controls-interactive",onClick:Q,title:P["controls.interactive.ariaLabel"],"aria-label":P["controls.interactive.ariaLabel"],children:b?d.jsx(dk,{}):d.jsx(ck,{})}),x]})}fm.displayName="Controls";const hk=L.memo(fm);function pk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:v,borderRadius:x,shapeRendering:y,selected:m,onClick:_}){const{background:k,backgroundColor:b}=u||{},E=c||k||b;return d.jsx("rect",{className:nt(["react-flow__minimap-node",{selected:m},v]),x:r,y:o,rx:x,ry:x,width:s,height:a,style:{fill:E,stroke:h,strokeWidth:p},shapeRendering:y,onClick:_?N=>_(N,t):void 0})}const gk=L.memo(pk),mk=t=>t.nodes.map(r=>r.id),Yu=t=>t instanceof Function?t:()=>t;function yk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=gk,onClick:c}){const h=ze(mk,Qe),p=Yu(r),v=Yu(t),x=Yu(o),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(m=>d.jsx(xk,{id:m,nodeColorFunc:p,nodeStrokeColorFunc:v,nodeClassNameFunc:x,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:y},m))})}function vk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:v,x,y,width:m,height:_}=ze(k=>{const b=k.nodeLookup.get(t);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const E=b.internals.userNode,{x:N,y:P}=b.internals.positionAbsolute,{width:w,height:j}=vn(E);return{node:E,x:N,y:P,width:w,height:j}},Qe);return!v||v.hidden||!fg(v)?null:d.jsx(h,{x,y,width:m,height:_,style:v.style,selected:!!v.selected,className:s(v),color:r(v),borderRadius:a,strokeColor:o(v),strokeWidth:u,shapeRendering:c,onClick:p,id:v.id})}const xk=L.memo(vk);var wk=L.memo(yk);const _k=200,Sk=150,kk=t=>!t.hidden,Nk=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?ug(ds(t.nodeLookup,{filter:kk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},hp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,jk=(t,r)=>hp(t.viewBB,r.viewBB)&&hp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,bk="react-flow__minimap-desc";function hm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:v,maskStrokeColor:x,maskStrokeWidth:y,position:m="bottom-right",onClick:_,onNodeClick:k,pannable:b=!1,zoomable:E=!1,ariaLabel:N,inversePan:P,zoomStep:w=1,offsetScale:j=5}){const $=Ge(),D=L.useRef(null),{boundingRect:B,viewBB:Y,rfId:Q,panZoom:ne,translateExtent:ee,flowWidth:te,flowHeight:q,ariaLabelConfig:C}=ze(Nk,jk),V=(t==null?void 0:t.width)??_k,W=(t==null?void 0:t.height)??Sk,U=B.width/V,M=B.height/W,z=Math.max(U,M),F=z*V,R=z*W,A=j*z,ie=B.x-(F-B.width)/2-A,oe=B.y-(R-B.height)/2-A,fe=F+A*2,he=R+A*2,pe=`${bk}-${Q}`,Z=L.useRef(0),se=L.useRef();Z.current=z,L.useEffect(()=>{if(D.current&&ne)return se.current=D1({domNode:D.current,panZoom:ne,getTransform:()=>$.getState().transform,getViewScale:()=>Z.current}),()=>{var re;(re=se.current)==null||re.destroy()}},[ne]),L.useEffect(()=>{var re;(re=se.current)==null||re.update({translateExtent:ee,width:te,height:q,inversePan:P,pannable:b,zoomStep:w,zoomable:E})},[b,E,P,w,ee,te,q]);const me=_?re=>{var Re;const[je,Me]=((Re=se.current)==null?void 0:Re.pointer(re))||[0,0];_(re,{x:je,y:Me})}:void 0,Ne=k?L.useCallback((re,je)=>{const Me=$.getState().nodeLookup.get(je).internals.userNode;k(re,Me)},[]):void 0,ve=N??C["minimap.ariaLabel"];return d.jsx(Kl,{position:m,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof v=="string"?v:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof y=="number"?y*z:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:nt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:V,height:W,viewBox:`${ie} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:D,onClick:me,children:[ve&&d.jsx("title",{id:pe,children:ve}),d.jsx(wk,{onClick:Ne,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-A},${oe-A}h${fe+A*2}v${he+A*2}h${-fe-A*2}z - M${Y.x},${Y.y}h${Y.width}v${Y.height}h${-Y.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}hm.displayName="MiniMap";const Ek=L.memo(hm),Ck=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Mk={[eo.Line]:"right",[eo.Handle]:"bottom-right"};function Pk({nodeId:t,position:r,variant:o=eo.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:v=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:y=!1,resizeDirection:m,autoScale:_=!0,shouldResize:k,onResizeStart:b,onResize:E,onResizeEnd:N}){const P=Vg(),w=typeof t=="string"?t:P,j=Ge(),$=L.useRef(null),D=o===eo.Handle,B=ze(L.useCallback(Ck(D&&_),[D,_]),Qe),Y=L.useRef(null),Q=r??Mk[o];L.useEffect(()=>{if(!(!$.current||!w))return Y.current||(Y.current=Q1({domNode:$.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:ee,transform:te,snapGrid:q,snapToGrid:C,nodeOrigin:V,domNode:W}=j.getState();return{nodeLookup:ee,transform:te,snapGrid:q,snapToGrid:C,nodeOrigin:V,paneDomNode:W}},onChange:(ee,te)=>{const{triggerNodeChanges:q,nodeLookup:C,parentLookup:V,nodeOrigin:W}=j.getState(),U=[],M={x:ee.x,y:ee.y},z=C.get(w);if(z&&z.expandParent&&z.parentId){const F=z.origin??W,R=ee.width??z.measured.width??0,A=ee.height??z.measured.height??0,ie={id:z.id,parentId:z.parentId,rect:{width:R,height:A,...hg({x:ee.x??z.position.x,y:ee.y??z.position.y},{width:R,height:A},z.parentId,C,F)}},oe=Pc([ie],C,V,W);U.push(...oe),M.x=ee.x?Math.max(F[0]*R,ee.x):void 0,M.y=ee.y?Math.max(F[1]*A,ee.y):void 0}if(M.x!==void 0&&M.y!==void 0){const F={id:w,type:"position",position:{...M}};U.push(F)}if(ee.width!==void 0&&ee.height!==void 0){const R={id:w,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:ee.width,height:ee.height}};U.push(R)}for(const F of te){const R={...F,type:"position"};U.push(R)}q(U)},onEnd:({width:ee,height:te})=>{const q={id:w,type:"dimensions",resizing:!1,dimensions:{width:ee,height:te}};j.getState().triggerNodeChanges([q])}})),Y.current.update({controlPosition:Q,boundaries:{minWidth:h,minHeight:p,maxWidth:v,maxHeight:x},keepAspectRatio:y,resizeDirection:m,onResizeStart:b,onResize:E,onResizeEnd:N,shouldResize:k}),()=>{var ee;(ee=Y.current)==null||ee.destroy()}},[Q,h,p,v,x,y,b,E,N,k]);const ne=Q.split("-");return d.jsx("div",{className:nt(["react-flow__resize-control","nodrag",...ne,o,s]),ref:$,style:{...a,scale:B,...c&&{[D?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Pk);const Ik={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function ea(t){return Ik[t]??8}const fc=208,hc=64,Rk=88,Tk=28,Lk=8;function Ak(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function $k(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const N of t){const P=ea(N.type),w=s.get(P)??[];w.push(N),s.set(P,w)}const u=[...s.keys()].sort((N,P)=>N-P).map(N=>[...s.get(N)??[]].sort((P,w)=>P.name.localeCompare(w.name)||P.id.localeCompare(w.id))),c=new Set(t.map(N=>N.id)),h=new Map,p=new Map;for(const N of t)h.set(N.id,[]),p.set(N.id,[]);for(const N of r)!c.has(N.src)||!c.has(N.dst)||N.src===N.dst||(p.get(N.src).push(N.dst),h.get(N.dst).push(N.src));const v=new Map;u.forEach((N,P)=>{for(const w of N)v.set(w.id,P)});const x=new Map,y=()=>{for(const N of u)N.forEach((P,w)=>x.set(P.id,w))};y();const m=(N,P)=>{const w=N.map((j,$)=>{const D=P(j.id).map(Y=>x.get(Y)).filter(Y=>Y!==void 0),B=Ak(D);return{n:j,bary:Number.isNaN(B)?$:B,name:j.name,id:j.id}});return w.sort((j,$)=>j.bary-$.bary||j.name.localeCompare($.name)||j.id.localeCompare($.id)),w.map(j=>j.n)},_=N=>P=>v.get(P)===N;for(let N=0;N(h.get(w)??[]).filter(_(P-1))),y();for(let P=u.length-2;P>=0;P--)u[P]=m(u[P],w=>(p.get(w)??[]).filter(_(P+1))),y()}const k=fc+Rk,b=hc+Tk,E=Math.max(...u.map(N=>N.length),1);return u.forEach((N,P)=>{const w=(E-N.length)*b/2;N.forEach((j,$)=>{o.set(j.id,{x:P*k,y:w+$*b})})}),o}const zk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),pm=90,Dk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),pp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Ok=Math.PI*(3-Math.sqrt(5)),gm=220,Fk=26,Hk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function mm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function PN(t){return pp[t]?pp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Bk(t){return t>=pm?"3d":"2d"}function Vk(t){return t>=pm?"overview":"full"}function Wk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(mm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Dk.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Wk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Gk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function Yk(t,r,o,s){const a=new Set(t.map(b=>b.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const b of r){if(!a.has(b.src)||!a.has(b.dst))continue;const E=u.get(b.src)??[];E.push({dst:b.dst,id:b.id}),u.set(b.src,E);const N=c.get(b.dst)??[];N.push({src:b.src,id:b.id}),c.set(b.dst,N)}const h=new Set(t.filter(b=>zk.has(b.type)).map(b=>b.id)),p=h.size?h:a,v=new Set,x=[o];for(;x.length;){const b=x.pop();if(!v.has(b)){v.add(b);for(const E of u.get(b)??[])v.has(E.dst)||x.push(E.dst)}}const y=new Set([o]),m=[...p].filter(b=>v.has(b)),_=new Set(m);for(;m.length;){const b=m.pop();y.add(b);for(const E of c.get(b)??[])v.has(E.src)&&!_.has(E.src)&&(_.add(E.src),m.push(E.src))}const k=new Set;for(const b of r)y.has(b.src)&&y.has(b.dst)&&k.add(b.id);return{nodeIds:y,edgeIds:k}}function IN(t){const r=new Map;for(const s of t){const a=ea(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*gm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Fk*Math.sqrt(h+1),v=h*Ok;o.set(c.id,{x:u,y:p*Math.cos(v),z:p*Math.sin(v)})})}return o}function RN(t){const r=new Map;for(const o of t){const s=ea(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*gm,count:s}))}const kl=16,Xk=12,qk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Kk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),gp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Qk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},mp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],yp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Zk=new Set(["looks_idempotent_on_pk","null","blank"]),Jk=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function eN(t){return gp[t]?gp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function tN(t,r,o){const s=new Map(r.map(m=>[m.id,m])),a=[];qk.has(t.type)&&a.push("sink"),Kk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(m=>m.dst===t.id),h=o.filter(m=>m.src===t.id),p=c.slice(0,kl).map(m=>Nl(m,s,m.src)),v=h.slice(0,kl).map(m=>Nl(m,s,m.dst)),x=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,y={type:t.type,typeLabel:Ko(no(t.type)),layer:Hk[ea(t.type)]??"other",purpose:eN(t.type),name:t.name,qualifiedName:t.qualified_name,file:x,context:t.context,roles:a,facts:rN(u).filter(m=>!(m.key==="app"&&m.value===t.context)),inputs:p,outputs:v,extraInputs:Math.max(0,c.length-kl),extraOutputs:Math.max(0,h.length-kl),degreeIn:c.length,degreeOut:h.length,inputKinds:vp(c.map(m=>Nl(m,s,m.src))),outputKinds:vp(h.map(m=>Nl(m,s,m.dst))),pathSummary:""};return y.pathSummary=nN(y),y}function vp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function nN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function Nl(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Ko(no(s.type)):"",edgeType:t.type,edgeLabel:Ko(t.type),inferred:t.confidence<.8}}function rN(t){const r=[...mp.filter(a=>a in t),...Object.keys(t).filter(a=>!mp.includes(a)&&!yp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||yp.has(a)||Jk.has(a))continue;s.add(a);const u=iN(a,t[a]);u!=null&&o.push({key:a,label:Qk[a]??Ko(a),value:u})}return o}function iN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Zk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return oN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Xk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function oN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const sN=new Set,lN=L.lazy(()=>_0(()=>import("./LayeredGraph3D-BnhN-wUA.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),aN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function uN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(to,{type:"target",position:ke.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:no(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Tr(t.name)}),d.jsx(to,{type:"source",position:ke.Right,isConnectable:!1})]})}const cN={load:uN},dN=new Set(["django","react","stitch","arch"]);function fN({topologyKey:t}){const{fitView:r}=Ql();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function hN(t,r,o=null,s={}){const a=new Map(t.map(p=>[p.id,p])),u=$k(t,r),c=t.map(p=>{var y;const v=((y=s.roles)==null?void 0:y[p.id])||[],x=!!s.testOverlay&&!v.includes("tested")&&!v.includes("untested")&&!v.includes("test")&&!v.includes("seed");return{id:p.id,type:"load",position:u.get(p.id)??{x:0,y:0},data:{name:p.name,type:p.type,file:p.file_path,roles:v,dim:x},selected:o===p.id,sourcePosition:ke.Right,targetPosition:ke.Left,width:fc,height:hc,style:{width:fc,height:hc}}}),h=r.filter(p=>a.has(p.src)&&a.has(p.dst)).map(p=>{const v=aN[p.weight]||"var(--edge-cheap)",x=!!(o&&(p.src===o||p.dst===o));return{id:p.id,source:p.src,target:p.dst,type:"smoothstep",animated:p.weight==="critical",style:{stroke:v,strokeWidth:p.weight==="critical"?2.4:1.2,strokeDasharray:p.confidence<.8?"6 4":void 0},markerEnd:{type:rs.ArrowClosed,width:14,height:14,color:v},label:x?p.type.replaceAll("_"," "):void 0,labelStyle:x?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:x?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:x?[3,5]:void 0,labelBgBorderRadius:x?4:void 0}});return{rfNodes:c,rfEdges:h}}function pN({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:v}){const x=tN(t,r,o);return L.useEffect(()=>{const y=m=>{m.key==="Escape"&&s()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:x.typeLabel}),d.jsx("div",{className:"inspector-roles",children:x.roles.map(y=>d.jsx("span",{className:"inspector-chip",children:y},y))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Tr(x.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:x.purpose}),x.context?d.jsx("div",{className:"muted",children:Tr(x.context)}):null,x.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Tr(x.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Tr(x.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",x.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[x.degreeIn," in · ",x.degreeOut," out"]}),x.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:x.pathSummary}):null,x.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:x.facts.map(y=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:y.label}),d.jsx("dd",{children:Tr(y.value)})]},y.key))}):null,d.jsx(xp,{title:"Inputs",testId:"graph-inspector-inputs",links:x.inputs,extra:x.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(xp,{title:"Outputs",testId:"graph-inspector-outputs",links:x.outputs,extra:x.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),a?d.jsx("p",{className:"whatif-hint","data-testid":"whatif-hint",children:v?"Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map.":"Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."}):null,d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",title:"Start a hypothetical walk from this node. Does not use Base/Head.",onClick:()=>a(t.id),children:"What if this changes"}):null,v?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",title:"Hide nodes that are not on a path from here to a sink. Does not start a new walk.",onClick:()=>v(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function xp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Xu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:v,repoPath:x,onOpenFile:y,pinnedId:m,onPin:_}){const[k,b]=L.useState(null),E=a!==void 0?a:k,N=re=>{a===void 0&&b(re),u==null||u(re)},[P,w]=L.useState(null),[j,$]=L.useState(null),[D,B]=L.useState(new Set(dN)),[Y,Q]=L.useState(!1),[ne,ee]=L.useState(""),[te,q]=L.useState(!1),C=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,V=P??Bk(t.length),W=j??Vk(t.length),U=Y?E:null,M=L.useMemo(()=>p?Yk(t,r,p):null,[t,r,p]),z=M?t.filter(re=>M.nodeIds.has(re.id)):t,F=M?r.filter(re=>M.edgeIds.has(re.id)):r,R=L.useMemo(()=>Uk(z,F,{detail:W,families:D,focusId:U,neighborhoodOnly:!!U}),[z,F,W,D,U]),A=L.useMemo(()=>`${R.nodes.map(re=>re.id).join("\0")}|${R.edges.map(re=>re.id).join("\0")}`,[R.nodes,R.edges]),ie=E?t.find(re=>re.id===E)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const re=hN(R.nodes,R.edges,E,{roles:c,testOverlay:h});return C&&(re.rfEdges=re.rfEdges.map(je=>({...je,animated:!1}))),re},[R.nodes,R.edges,E,C,c,h]);L.useEffect(()=>{if(!s)return;const re=t.find(je=>je.file_path===s);re&&N(re.id)},[s,t]);const he=L.useMemo(()=>Gk(t,ne),[t,ne]),pe=(re,je)=>{N(je.id)},Z=()=>{N(null),Q(!1)},se=ie?d.jsx(pN,{node:ie,nodes:t,edges:r,onClose:Z,onWhatIf:o,onSelect:N,onOpenFile:y,pinned:m===ie.id,onPin:_,onIsolate:v?re=>{v(p===re?null:re)}:void 0}):null,me=re=>{B(je=>{const Me=new Set(je);if(Me.has(re)){if(Me.size===1)return je;Me.delete(re)}else Me.add(re);return Me})},Ne=L.useMemo(()=>{const re=new Set;for(const je of t)re.add(mm(je.type));return re},[t]),ve=t.length-R.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:V==="2d"?"active":"","aria-pressed":V==="2d",onClick:()=>w("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:V==="3d"?"active":"","aria-pressed":V==="3d",onClick:()=>w("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:W==="overview"?"active":"","aria-pressed":W==="overview",onClick:()=>$("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:W==="full"?"active":"","aria-pressed":W==="full",onClick:()=>$("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(re=>Ne.has(re)).map(re=>d.jsx("button",{type:"button","data-testid":`graph-family-${re}`,className:D.has(re)?"active":"","aria-pressed":D.has(re),onClick:()=>me(re),children:re},re))}),d.jsx("button",{type:"button",className:Y?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!E,onClick:()=>Q(re=>!re),children:Y?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>v==null?void 0:v(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:ne,onChange:re=>{ee(re.target.value),q(!0)},onFocus:()=>q(!0),onBlur:()=>window.setTimeout(()=>q(!1),150)}),te&&ne.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(re=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:je=>je.preventDefault(),onClick:()=>{N(re.id),ee(""),q(!1)},children:[re.name,d.jsx("span",{className:"muted",children:no(re.type)})]})},re.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[R.nodes.length," nodes · ",R.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:V==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(lN,{nodes:R.nodes,edges:R.edges,selectedId:E,neighborIds:U?R.neighborIds:sN,onSelect:re=>{N(re),re||Q(!1)}})}),se]}):d.jsxs(cm,{children:[d.jsxs(tk,{nodes:oe,edges:fe,nodeTypes:cN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:Z,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(fN,{topologyKey:A}),d.jsx(sk,{}),d.jsx(Ek,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(hk,{})]}),se]})})]})}function ym(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function gN(t){localStorage.setItem("loadpath.editor",t)}async function mN(t,r,o,s=ym()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const wp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],yN=["preset","branch","tag","commit"];function vN(t){var a;if(!(t!=null&&t.git))return[...wp];const r=((a=t.presets)!=null&&a.length?t.presets:wp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function xN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function wN(t){return yN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function _N(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function _p({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[v,x]=L.useState(!1),[y,m]=L.useState(null),[_,k]=L.useState(0),b=L.useMemo(()=>{const j=vN(u);return y===null?j:xN(j,y)},[u,y]),E=L.useMemo(()=>wN(b),[b]);L.useEffect(()=>{v&&c()},[v,c]),L.useEffect(()=>{k(0)},[y,v]);const N=()=>{x(!1),m(null)},P=j=>{r(j.value),N()},w=j=>{if(j.key==="ArrowDown"){if(j.preventDefault(),!v){x(!0);return}k($=>Math.min($+1,Math.max(b.length-1,0)))}else if(j.key==="ArrowUp"){if(j.preventDefault(),!v)return;k($=>Math.max($-1,0))}else if(j.key==="Enter"&&v){j.preventDefault();const $=b[_];$&&P($)}else j.key==="Escape"&&v&&(j.preventDefault(),N())};return d.jsxs("div",{className:"combo",ref:p,onBlur:j=>{j.currentTarget.contains(j.relatedTarget)||N()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":v,"aria-controls":h,"aria-autocomplete":"list",onChange:j=>{r(j.target.value),v&&m(j.target.value)},onKeyDown:w}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":v,onMouseDown:j=>j.preventDefault(),onClick:()=>v?N():x(!0),children:d.jsx(v0,{})})]}),v?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:E.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):E.map(j=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:_N(j.group)}),j.items.map($=>{const D=b.indexOf($);return d.jsxs("button",{type:"button",role:"option","aria-selected":D===_,className:D===_?"combo-option active":"combo-option","data-testid":`ref-option-${$.group}`,onMouseDown:B=>B.preventDefault(),onMouseEnter:()=>k(D),onClick:()=>P($),children:[d.jsx("span",{className:"combo-label",children:$.label}),$.detail?d.jsx("span",{className:"combo-detail",children:$.detail}):null]},`${$.group}:${$.value}`)})]},j.group))}):null]})}function SN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[v,x]=L.useState(""),[y,m]=L.useState(!1),_=L.useRef(null),k=L.useRef(0),b=async w=>{const j=k.current+1;k.current=j,m(!0);try{const $=await Pe.browse(w);if(k.current!==j)return;a($),c($.path),p($.is_git?$.path:null),x("")}catch($){if(k.current!==j)return;x($ instanceof Error?$.message:String($))}finally{k.current===j&&m(!1)}};L.useEffect(()=>{var w,j;b(t),(w=_.current)==null||w.focus(),(j=_.current)==null||j.select()},[t]);const E=h||(s==null?void 0:s.path)||u,N=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",P=w=>{w.key==="Escape"&&(w.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:P,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:w=>w.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:w=>{w.preventDefault(),b(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:w=>c(w.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void b(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void b(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),v?d.jsx("div",{className:"error",role:"alert",children:v}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":y,children:s!=null&&s.entries.length?s.entries.map(w=>{const j=h===w.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":j,className:j?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":w.path,onClick:()=>p(w.path),onDoubleClick:()=>void b(w.path),children:[d.jsx(jp,{}),d.jsx("span",{className:"explorer-name",children:w.name}),w.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},w.path)}):d.jsx("div",{className:"muted explorer-empty",children:y?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:E,children:E}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!E,onClick:()=>E&&r(E),children:["Use ",N]})]})]})})}const Fl=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],kN="obsidian",vm="loadpath.theme";function NN(t){return Fl.some(r=>r.id===t)}function xm(){try{const t=localStorage.getItem(vm)||"";if(NN(t))return t}catch{}return kN}function jN(t){var r;return((r=Fl.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function wm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=jN(t);try{localStorage.setItem(vm,t)}catch{}}const qu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:h0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:p0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:g0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:m0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:y0}];function bN(t){const r=t.total||0;return r<=0?null:Math.min(100,Math.round(100*(t.done||0)/r))}function Ku(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function EN(){var uo,co,_i,fo,ho,po,Si,Xr,rn,on;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,v]=L.useState(null),[x,y]=L.useState(null),[m,_]=L.useState(null),[k,b]=L.useState([]),[E,N]=L.useState("review"),[P,w]=L.useState(""),[j,$]=L.useState(""),[D,B]=L.useState(null),[Y,Q]=L.useState(!1),[ne,ee]=L.useState(!1),[te,q]=L.useState(""),[C,V]=L.useState({}),[W,U]=L.useState([]),[M,z]=L.useState([]),[F,R]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[A,ie]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[oe,fe]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[he,pe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[Z,se]=L.useState(0),[me,Ne]=L.useState(""),[ve,re]=L.useState(xm),[je,Me]=L.useState(!1),[Re,Ae]=L.useState(!1),[st,lt]=L.useState(!1),[at,Ye]=L.useState(null),[wt,qt]=L.useState(null),[gt,mt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[Pt,ut]=L.useState(null),[Je,An]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[Ot,xn]=L.useState([]),[ro,$n]=L.useState(null),[yi,ir]=L.useState(null),[$r,zn]=L.useState(null),[zr,or]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[sr,Ft]=L.useState(null),[ct,Dn]=L.useState(null),[On,wn]=L.useState(!1),[Fn,_n]=L.useState(!1),rt=L.useRef(o);rt.current=o;const Dr=L.useRef(!1);Dr.current=Re;const _t=L.useRef(""),lr=L.useRef(""),Sn=I=>{re(I),wm(I)},dt=L.useRef(""),He=I=>{dt.current=I,$(I)},kn=I=>{const G=()=>{Pe.indexProgress(I).then(Se=>{dt.current&&(Se.phase&&Se.phase!=="idle"&&Se.message&&He(Se.message),B(Se.phase&&Se.phase!=="idle"?bN(Se):null))}).catch(()=>{})};G();const de=window.setInterval(G,250);return()=>{window.clearInterval(de),B(null)}};L.useEffect(()=>{Pe.settings().then(V).catch(()=>{}).finally(()=>Me(!0)),Pe.repos().then(I=>b(I.repos)).catch(()=>{})},[]);const Nn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const I=o;let G=!1;return lr.current!==I&&Bn(I),Pe.config(I).then(de=>{!G&&rt.current===I&&ir(de)}).catch(()=>{}),Pe.architectureHealth(I).then(de=>{!G&&rt.current===I&&zn(de)}).catch(()=>{}),()=>{G=!0}},[t,o]);const Ht=I=>{rt.current=I,s(I),localStorage.setItem("loadpath.repo",I),I.trim()!==_t.current&&(_t.current="",Ft(null))},Or=L.useCallback(I=>{const G=(I??rt.current).trim();return!G||_t.current===G?Promise.resolve():(_t.current=G,Pe.gitRefs(G).then(de=>{rt.current.trim()===G&&Ft(de)}).catch(()=>{_t.current===G&&(_t.current="",Ft(null))}))},[]),nn=(I,G)=>{u(I),h(G),localStorage.setItem("loadpath.base",I),localStorage.setItem("loadpath.head",G)},Fr=(I,G,de)=>{ie(I),R(G),localStorage.setItem("loadpath.provider",I),localStorage.setItem("loadpath.scmRepo",G),de!==void 0&&(fe(de),localStorage.setItem("loadpath.prNumber",de))},yt=I=>{v(I),se(0),Ye(wt&&I.nodes.some(G=>G.id===wt)?wt:null),ut(null),$n(null),I.what_if||(y(I),I.id&&localStorage.setItem("loadpath.lastReviewId",I.id))},Hn=async I=>{try{const G=await Pe.reviews(I);xn(G.reviews)}catch{xn([])}},ar=async I=>{try{zn(await Pe.architectureHealth(I))}catch{zn(null)}},io=I=>I==="github"?!!C.github_token_set:I==="gitlab"?!!C.gitlab_token_set:!!C.bitbucket_token_set,It=L.useCallback(async(I=A)=>{var G;try{const de=await Pe.scmRepos(I);z(de.repos),(G=de.user)!=null&&G.login&&V(Se=>({...Se,...I==="github"?{github_user:de.user.login}:I==="gitlab"?{gitlab_user:de.user.login}:{bitbucket_user:de.user.login}}))}catch{z([])}},[A]);L.useEffect(()=>{if(t!=="prs")return;let I=!1;return It(A).catch(()=>{I||z([])}),()=>{I=!0}},[t,A,It]),L.useEffect(()=>{if(!ct)return;let I=!1,G=0;const de=async()=>{try{const Se=await Pe.githubOAuthPoll(ct.flow_id);if(I)return;if(Se.status==="complete"){Dn(null);const Le=await Pe.settings();V(Le),q(Se.user?`Signed in to GitHub as ${Se.user}`:"Signed in to GitHub"),It("github");return}if(Se.status==="pending"||Se.status==="slow_down"){G=window.setTimeout(de,Math.max(Se.interval||ct.interval,5)*1e3);return}Dn(null),w(Se.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(Se){if(I)return;Dn(null),w(Se instanceof Error?Se.message:String(Se))}};return G=window.setTimeout(de,Math.max(ct.interval,5)*1e3),()=>{I=!0,window.clearTimeout(G)}},[ct,It]),L.useEffect(()=>{if(!On)return;let I=!1,G=0;const de=Date.now(),Se=async()=>{try{const Le=await Pe.oauthStatus();if(I)return;if(Le.bitbucket.connected){wn(!1);const De=await Pe.settings();V(De),q(Le.bitbucket.user?`Signed in to Bitbucket as ${Le.bitbucket.user}`:"Signed in to Bitbucket"),It("bitbucket");return}if(Date.now()-de>18e4){wn(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}G=window.setTimeout(Se,1500)}catch(Le){if(I)return;wn(!1),w(Le instanceof Error?Le.message:String(Le))}};return G=window.setTimeout(Se,1500),()=>{I=!0,window.clearTimeout(G)}},[On,It]),L.useEffect(()=>{if(!Fn)return;let I=!1,G=0;const de=Date.now(),Se=async()=>{try{const Le=await Pe.oauthStatus();if(I)return;if(Le.gitlab.connected){_n(!1);const De=await Pe.settings();V(De),q(Le.gitlab.user?`Signed in to GitLab as ${Le.gitlab.user}`:"Signed in to GitLab"),It("gitlab");return}if(Date.now()-de>18e4){_n(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}G=window.setTimeout(Se,1500)}catch(Le){if(I)return;_n(!1),w(Le instanceof Error?Le.message:String(Le))}};return G=window.setTimeout(Se,1500),()=>{I=!0,window.clearTimeout(G)}},[Fn,It]);const Bn=async(I=o,G=!1)=>{if(!I.trim())return null;lr.current=I,ee(!0);try{const de=await Pe.architecture(I,!1);rt.current===I&&_(de);const Se=Pe.architectureGraph(I).then(Le=>{rt.current===I&&_(De=>De&&{...De,nodes:Le.nodes,edges:Le.edges,graph_pending:!1})});return Se.catch(()=>{}).finally(()=>{rt.current===I&&ee(!1)}),G&&await Se,de}catch(de){throw rt.current===I&&ee(!1),de}},Hr=async I=>{const G=I.trim();if(!(!G||G===rt.current)){if(dt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),q(""),v(null),y(null),_(null),N("architecture"),Ht(G),Q(!0),He(`Loading ${f0(G)}…`);try{await Promise.all([Bn(G),Or(G)])}catch(de){rt.current===G&&w(de instanceof Error?de.message:String(de))}finally{rt.current===G&&(He(""),Q(!1))}}},jn=async()=>{if(dt.current||!Nn())return;w(""),q(""),He("Tracing load path…"),Ht(o),nn(a,c);const I=kn(o);try{const G=await Pe.review(o,a,c,!0,he);yt(G),N("review"),r("review"),await Pe.repos().then(de=>b(de.repos)).catch(()=>{}),await Promise.all([Bn(o),Hn(o),ar(o)])}catch(G){w(G instanceof Error?G.message:String(G))}finally{I(),He("")}},Br=async(I=!0)=>{if(dt.current||!Nn())return;w(""),q(""),He(I?"Indexing…":"Full reindex…"),Ht(o);const G=kn(o);try{await Pe.index(o,I);const de=await Bn(o);await Pe.repos().then(Se=>b(Se.repos)).catch(()=>{}),de!=null&&de.indexed&&(N("architecture"),r("architecture"))}catch(de){w(de instanceof Error?de.message:String(de))}finally{G(),He("")}},vi=async()=>{if(!dt.current&&Nn()){w(""),q(""),He("Detecting layout…"),Ht(o);try{const I=await Pe.init(o);q(I.message),await Pe.repos().then(G=>b(G.repos)).catch(()=>{})}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},Ve=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),q("Copied markdown brief")}catch(I){w(I instanceof Error?I.message:String(I))}},oo=async()=>{if(!dt.current){if(p!=null&&p.what_if){w("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first.");return}if(!(p!=null&&p.markdown)||!F||!oe){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const I=await Pe.postComment(A,F,Number(oe),p.markdown);q(I.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},Vr=async()=>{if(!dt.current){w(""),He("Fetching pull requests…");try{const I=await Pe.prs(A,F,"open",o.trim()||void 0);U(I.pull_requests);const G=M.find(de=>de.slug.toLowerCase()===F.trim().toLowerCase());G!=null&&G.local_path&&Ht(G.local_path)}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},xi=async()=>{w("");try{const I=await Pe.githubOAuthStart();Dn(I),Ku(I.verification_uri_complete,"github.com","/login/device")}catch(I){w(I instanceof Error?I.message:String(I))}},ur=async()=>{w("");try{const I=await Pe.bitbucketOAuthStart();wn(!0),Ku(I.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(I){wn(!1),w(I instanceof Error?I.message:String(I))}},so=async()=>{w("");try{const I=await Pe.gitlabOAuthStart();_n(!0),Ku(I.authorize_url,new URL(I.authorize_url).hostname,"/oauth/authorize")}catch(I){_n(!1),w(I instanceof Error?I.message:String(I))}},cr=async I=>{if(!(dt.current||!o.trim())){w(""),He("Walking what-if path…");try{const G=await Pe.whatIf(o,I);q(`${G.title} — ${G.confidence.level} · ${(G.sinks||[]).length} sinks`),yt({...G,markdown:G.markdown||"",index:G.index||(p==null?void 0:p.index),workspace:G.workspace||(p==null?void 0:p.workspace)}),N("review"),r("review")}catch(G){w(G instanceof Error?G.message:String(G))}finally{He("")}}},Vn=()=>{if(x){yt(x),N("review"),r("review"),q("Restored the last git-range walk");return}v(null),se(0),Ye(null),ut(null),$n(null),N("architecture"),r("architecture"),q("")},bt=async I=>{var Le;if(dt.current)return;Fr(I.provider,I.repo,String(I.number));const G=M.find(De=>De.slug.toLowerCase()===I.repo.toLowerCase());G!=null&&G.local_path&&Ht(G.local_path),w(""),He(`Fetching ${I.provider} #${I.number}…`);const de=(G==null?void 0:G.local_path)||o,Se=de?kn(de):()=>{};try{const De=await Pe.reviewPr(I.provider,I.repo,I.number,(G==null?void 0:G.local_path)||o||void 0);yt(De),De.pull_request&&typeof De.pull_request.repo_path=="string"&&Ht(De.pull_request.repo_path),nn(String(De.base||I.target_branch),String(De.head||I.source_branch)),N("review"),r("review"),typeof((Le=De.pull_request)==null?void 0:Le.repo_path)=="string"&&Hn(De.pull_request.repo_path)}catch(De){nn(I.base_sha||I.target_branch,I.head_sha||I.source_branch),r("review"),w(De instanceof Error?De.message:String(De))}finally{Se(),He("")}},Wr=async I=>{w("");try{V(await Pe.oauthDisconnect(I)),A===I&&z([]),q(`Disconnected ${I}`)}catch(G){w(G instanceof Error?G.message:String(G))}},Et=async I=>{I.preventDefault();const G=new FormData(I.currentTarget),de={github_token:String(G.get("github_token")||""),github_oauth_client_id:String(G.get("github_oauth_client_id")||""),github_host:String(G.get("github_host")||""),gitlab_token:String(G.get("gitlab_token")||""),gitlab_host:String(G.get("gitlab_host")||""),gitlab_oauth_client_id:String(G.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(G.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(G.get("bitbucket_token")||""),bitbucket_username:String(G.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(G.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(G.get("bitbucket_oauth_client_secret")||""),ai_provider:String(G.get("ai_provider")||"none"),ai_api_key:String(G.get("ai_api_key")||""),ai_model:String(G.get("ai_model")||""),ai_base_url:String(G.get("ai_base_url")||"")},Se=k.length?{...de,workspaces:k.map(Le=>({path:Le.path,name:Le.name}))}:de;try{V(await Pe.saveSettings(Se)),q("Settings saved on this machine")}catch(Le){w(Le instanceof Error?Le.message:String(Le))}},lo=async()=>{if(!(!p||dt.current)){He("Residual analysis…");try{const I=await Pe.residual(p);Ne(I.note)}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},Ur=L.useRef(jn);Ur.current=jn;const Gr=L.useRef(t);Gr.current=t;const Wn=L.useRef(!1);Wn.current=st;const Un=L.useRef(p);Un.current=p;const bn=L.useRef(Z);bn.current=Z,L.useEffect(()=>{const I=localStorage.getItem("loadpath.lastReviewId"),G=(localStorage.getItem("loadpath.repo")||"").trim();if(!I||!G){or(!1);return}let de=!1;return Pe.getReview(G,I).then(Se=>{de||(yt(Se),nn(Se.base||localStorage.getItem("loadpath.base")||"HEAD~1",Se.head||localStorage.getItem("loadpath.head")||"HEAD"),Hn(G),ar(G))}).catch(()=>{}).finally(()=>{de||or(!1)}),()=>{de=!0}},[]);const Bt=L.useRef("");L.useEffect(()=>{if(!Je||!o.trim())return;let I=!1;const G=async()=>{try{const Se=await Pe.workspaceStatus(o);if(I)return;Bt.current&&Se.fingerprint!==Bt.current&&!dt.current&&(pe(!0),localStorage.setItem("loadpath.dirty","1"),Ur.current()),Bt.current=Se.fingerprint}catch{}};G();const de=window.setInterval(G,2e3);return()=>{I=!0,window.clearInterval(de)}},[Je,o]),L.useEffect(()=>{const I=G=>{var Le;if((G.metaKey||G.ctrlKey)&&G.key.toLowerCase()==="k"){G.preventDefault(),lt(De=>!De);return}if(Wn.current){G.key==="Escape"&&(G.preventDefault(),lt(!1));return}if(Dr.current){G.key==="Escape"&&(G.preventDefault(),Ae(!1));return}const de=G.target;if(de&&(de.tagName==="INPUT"||de.tagName==="TEXTAREA"||de.tagName==="SELECT"||de.isContentEditable)){G.key==="Escape"&&de.blur();return}if(G.key==="Escape"){w(""),q(""),Ye(wt),ut(null);return}if(G.key==="j"||G.key==="k"){const De=((Le=Un.current)==null?void 0:Le.read_order)||[];if(!De.length)return;G.preventDefault();const pr=bn.current,ta=G.key==="j"?Math.min(De.length-1,pr+1):Math.max(0,pr-1);se(ta);return}const Se=qu.find(De=>De.shortcut===G.key);if(Se&&!G.metaKey&&!G.ctrlKey&&!G.altKey&&r(Se.id),(G.metaKey||G.ctrlKey)&&G.key==="Enter"){if(Gr.current==="settings"||Gr.current==="prs"||dt.current)return;G.preventDefault(),Ur.current()}};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[wt]);const wi=async(I,G)=>{if(!o.trim())return;const de=await mN(o,I,G);de.ok?q(de.message):w(de.message)},Yr=async()=>{if(p)try{const I=await Pe.exportHtml(p),G=URL.createObjectURL(I),de=document.createElement("a");de.href=G,de.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,de.click(),URL.revokeObjectURL(G),q("Saved HTML brief")}catch(I){w(I instanceof Error?I.message:String(I))}},dr=async I=>{if(o.trim()){He("Loading stored review…");try{const G=await Pe.getReview(o,I);yt(G),nn(G.base||a,G.head||c),N("review"),r("review");const de=Ot.find(Se=>Se.id!==I);if(de)try{$n(await Pe.reviewDiff(o,I,de.id))}catch{$n(null)}}catch(G){w(G instanceof Error?G.message:String(G))}finally{He("")}}},fr={selectedId:at,onSelect:Ye,nodeRoles:p==null?void 0:p.node_roles,testOverlay:gt,isolateSource:Pt,onIsolate:ut,repoPath:o,onOpenFile:wi,pinnedId:wt,onPin:qt},Gn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},...p!=null&&p.what_if?[{id:"exit-whatif",group:"Review",label:x?"Back to git-range walk":"Exit what-if walk",run:Vn}]:[],{id:"index",group:"Run",label:"Index repository",run:()=>void Br(!0)},{id:"watch",group:"Run",label:Je?"Stop watching working tree":"Watch working tree",run:()=>{const I=!Je;An(I),localStorage.setItem("loadpath.watch",I?"1":"0")}},{id:"tests",group:"Graph",label:gt?"Hide test overlay":"Show test overlay",run:()=>{const I=!gt;mt(I),localStorage.setItem("loadpath.testOverlay",I?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Yr()},...qu.map(I=>({id:`tab-${I.id}`,group:"Tabs",label:`Go to ${I.label}`,hint:I.shortcut,run:()=>r(I.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(I=>({id:`node-${I.id}`,group:"Nodes",label:I.name,hint:no(I.type),run:()=>{Ye(I.id),r("graph")}})),...Ot.slice(0,12).map(I=>({id:`hist-${I.id}`,group:"History",label:I.title||I.id,hint:`${I.level||""} ${I.created_at||""}`.trim(),run:()=>void dr(I.id)}))],En=L.useMemo(()=>E==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[E,m,p]),ao=L.useMemo(()=>E==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[E,m,p]),hr=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Fe=((p==null?void 0:p.findings)||[]).filter(I=>!I.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),qu.map(I=>{const G=I.icon,de=t===I.id;return d.jsxs("button",{type:"button","data-testid":I.testId,className:de?"nav-item active":"nav-item","aria-current":de?"page":void 0,"aria-label":I.label,onClick:()=>r(I.id),children:[d.jsx(G,{}),d.jsx("span",{children:I.label})]},I.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:ve,onChange:I=>Sn(I.target.value),children:["dark","light"].map(I=>d.jsx("optgroup",{label:I==="dark"?"Dark":"Light",children:Fl.filter(G=>G.group===I).map(G=>d.jsx("option",{value:G.id,children:G.label},G.id))},I))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:j||hr}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[j?d.jsxs("div",{className:D!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","data-testid":"progress",children:[d.jsx("i",{style:D!=null?{width:`${D}%`}:void 0}),d.jsx("span",{className:"sr-only",children:j})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[k.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:k.some(I=>I.path===o)?o:"",disabled:!!j,"aria-busy":Y,onChange:I=>{I.target.value&&Hr(I.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),k.map(I=>d.jsxs("option",{value:I.path,children:[I.name,I.indexed?` (${I.counts.nodes})`:""]},I.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:I=>{const G=I.target.value;s(G),G.trim()!==_t.current&&(_t.current="",Ft(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>Ae(!0),children:d.jsx(jp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(_p,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:I=>nn(I,c),placeholder:"base",refs:sr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(_p,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:I=>nn(a,I),placeholder:"head",refs:sr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:he?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":he,onClick:()=>{const I=!he;pe(I),localStorage.setItem("loadpath.dirty",I?"1":"0")},children:he?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:Je?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":Je,onClick:()=>{const I=!Je;An(I),localStorage.setItem("loadpath.watch",I?"1":"0")},children:Je?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.what_if?"what-if · ":"",p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!j,onClick:vi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!j,onClick:()=>Br(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!j,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[P?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:P}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,te?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:te}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>q(""),"aria-label":"Dismiss",children:"×"})]}):null,((uo=p==null?void 0:p.index)!=null&&uo.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((co=p==null?void 0:p.index)==null?void 0:co.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((_i=p==null?void 0:p.index)==null?void 0:_i.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(fo=p==null?void 0:p.workspace)!=null&&fo.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,p!=null&&p.what_if?d.jsxs("div",{className:"banner whatif","data-testid":"whatif-banner",children:[d.jsxs("span",{children:["Hypothetical walk from"," ",d.jsx("strong",{children:((ho=p.node)==null?void 0:ho.name)||"this node"}),". Loadpath ignored Base/Head and asked which sinks would feel this node change — not a filter of the current map."]}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-exit-whatif",onClick:Vn,children:x?"Back to git range":"Back to architecture"})]}):null,Y?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:j||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":Y||ne,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(CN,{review:p,findings:Fe,aiNote:me,busy:!!j,tourIndex:Z,onTour:se,onAskAi:lo,onCopy:Ve,onPost:oo,onSelect:Ye,onOpenFile:wi,onExport:Yr,history:Ot,diff:ro,onReopen:dr,onWaiver:(I,G)=>{o.trim()&&Pe.addWaiver(o,I,G||void 0,"from review").then(de=>{ir(de),q(`Waived ${I} in loadpath.yml`)})}}):zr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Xu,{nodes:p.nodes,edges:p.edges,onWhatIf:cr,focusPath:(po=p.read_order[Z])==null?void 0:po.path,...fr}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(MN,{architecture:m,busy:!!j,onReindex:()=>Br(!1),onReview:jn,onSelect:Ye,config:yi,health:$r,onSaveConfig:I=>{Pe.saveConfig(o,I).then(G=>{ir(G),q("Wrote loadpath.yml")})},onWaiver:(I,G,de)=>{Pe.addWaiver(o,I,G,de).then(Se=>{ir(Se),q(`Waived ${I}`)})}}):Y?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(ne||m!=null&&m.graph_pending)&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(Si=m==null?void 0:m.counts)!=null&&Si.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Xu,{nodes:m.nodes,edges:m.edges,onWhatIf:cr,...fr,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":E==="review","data-testid":"graph-mode-review",className:E==="review"?"active":"",onClick:()=>N("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":E==="architecture","data-testid":"graph-mode-architecture",className:E==="architecture"?"active":"",onClick:()=>N("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:gt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":gt,onClick:()=>{const I=!gt;mt(I),localStorage.setItem("loadpath.testOverlay",I?"1":"0")},children:"Tests"})]}),En.length?d.jsx(Xu,{nodes:En,edges:ao,onWhatIf:cr,...fr}):ne||m!=null&&m.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:A,onChange:I=>Fr(I.target.value,F,oe),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:M.length?"Search your repos":"owner/repo",value:F,onChange:I=>Fr(A,I.target.value,oe),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:M.map(I=>d.jsxs("option",{value:I.slug,children:[I.private?"private":"public",I.local_path?" · local":""]},I.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!j||!io(A),onClick:()=>{It(A)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!j,onClick:Vr,children:"List PRs"})]}),M.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[M.length," ",A," repositor",M.length===1?"y":"ies",A==="github"&&C.github_user?` · @${String(C.github_user)}`:"",A==="gitlab"&&C.gitlab_user?` · @${String(C.gitlab_user)}`:"",A==="bitbucket"&&C.bitbucket_user?` · ${String(C.bitbucket_user)}`:""]}):null,W.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):W.map(I=>{var G;return d.jsxs("article",{className:"pr","data-testid":`pr-${I.number}`,children:[d.jsxs("h3",{children:["#",I.number," ",I.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${I.draft?"":"open"}`,children:I.draft?"draft":I.state}),d.jsx("span",{children:I.author}),d.jsxs("span",{children:[I.source_branch," → ",I.target_branch]}),I.loadpath?d.jsxs("span",{className:`chip ${I.loadpath.level||""}`,"data-testid":`pr-loadpath-${I.number}`,children:[((G=I.loadpath.level)==null?void 0:G.toUpperCase())||"REVIEWED",I.loadpath.contract_break&&I.loadpath.contract_break!=="none"?` · ${I.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:I.url,target:"_blank",rel:"noreferrer",children:["Open on ",I.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${I.number}`,onClick:()=>void bt(I),children:"Review this PR"})]})]},`${I.provider}-${I.number}`)})]}),t==="settings"&&je&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Et,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Fl.map(I=>d.jsxs("button",{type:"button","data-theme":I.id,className:ve===I.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${I.id}`,onClick:()=>Sn(I.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:I.label}),d.jsx("div",{className:"group",children:I.group})]},I.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:ym(),onChange:I=>gN(I.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:C.github_token_set?C.github_user?`Signed in as @${String(C.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void Wr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!ct||!C.github_oauth_ready,onClick:()=>void xi(),children:ct?"Waiting for GitHub…":"Sign in with GitHub"})})]}),ct?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:ct.user_code})," at GitHub if the browser did not fill it in."]}):null,C.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(C.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(C.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:C.gitlab_token_set?C.gitlab_user?`Signed in as @${String(C.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void Wr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Fn||!C.gitlab_oauth_ready,onClick:()=>void so(),children:Fn?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(C.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(C.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:C.bitbucket_token_set?C.bitbucket_user?`Signed in as ${String(C.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void Wr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:On||!C.bitbucket_oauth_ready,onClick:()=>void ur(),children:On?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),C.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(C.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(C.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((Xr=C.ai)==null?void 0:Xr.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((rn=C.ai)==null?void 0:rn.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((on=C.ai)==null?void 0:on.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(u0,{open:st,actions:Gn,onClose:()=>lt(!1)}),Re?d.jsx(SN,{initialPath:o,onClose:()=>Ae(!1),onSelect:I=>{if(dt.current){w("Wait for the current job to finish before switching workspace.");return}Ae(!1),Hr(I)}}):null]})}function CN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:v,onOpenFile:x,onExport:y,history:m,diff:_,onReopen:k,onWaiver:b}){var N,P,w,j,$,D,B,Y,Q,ne,ee,te,q,C,V,W,U;const E=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),E.length?d.jsx("ul",{className:"reasons",children:E.map(M=>d.jsx("li",{children:M},M))}):null,t.what_if?d.jsx("span",{className:"chip whatif","data-testid":"whatif-chip",children:"what-if"}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Ko(M)},M)),(N=t.contract_break)!=null&&N.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>b(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(P=t.workspace)!=null&&P.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,z)=>d.jsxs("div",{className:z===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(z),children:[z+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>x(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(_m,{cards:t.deepening}),(j=(w=t.contract_break)==null?void 0:w.reasons)!=null&&j.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),(D=($=t.contract_break.sides)==null?void 0:$.rows)!=null&&D.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(B=t.auth)!=null&&B.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(Y=t.suggested_tests)==null?void 0:Y.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(Q=t.trend)!=null&&Q.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",Qu(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),m.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:m.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,m.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>k(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?Qu(M.created_at):""})]},M.id))]}):null,(ee=(ne=t.evolution)==null?void 0:ne.notes)!=null&&ee.length||(q=(te=t.evolution)==null?void 0:te.hotspots)!=null&&q.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((C=t.evolution)==null?void 0:C.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((V=t.evolution)==null?void 0:V.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:y,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",disabled:s||!!t.what_if,title:t.what_if?"Hypothetical walks are not posted to a pull request":void 0,onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(W=t.codeowners_reviewers)!=null&&W.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function MN({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var x;const v=t.findings.filter(y=>!y.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${Qu(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(y=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y.name})," — ",(y.django_apps||[]).join(", ")||"no apps"," ·"," ",(y.owners||[]).join(", ")||"unowned"]},y.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(y=>d.jsx("div",{className:"muted",children:y},y))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:v.length})]}),v.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):v.map(y=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>y.node_id&&a(y.node_id),children:[d.jsx("span",{className:`chip ${y.severity}`,children:y.severity}),y.message]})},y.rule+y.message))]}),d.jsx(_m,{cards:t.deepening}),(x=c==null?void 0:c.points)!=null&&x.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(y=>d.jsx("i",{className:y.level||"",title:`${y.level} · ${y.findings} findings`,style:{height:`${8+Math.min(24,(y.findings||0)*4)}px`}},y.id||y.created_at))}),Object.entries(c.contexts).map(([y,m])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y})," — last ",((_=m[m.length-1])==null?void 0:_.findings)??0," findings"]},y)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(c0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((y,m)=>m[1]-y[1]).slice(0,12).map(([y,m])=>d.jsxs("tr",{children:[d.jsx("td",{children:no(y)}),d.jsx("td",{children:m})]},y))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function _m({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:d0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}wm(xm());s0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(EN,{})}));export{Hk as L,RN as a,PN as c,d as j,IN as l,L as r,no as t}; +`)),x=v.reduce((y,m)=>y.concat(...m),[]);return[v,x]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Xh,v=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const x=_=>{var E,N;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!v)&&gg(_))return!1;const b=Kh(_.code,h);if(u.current.add(_[b]),qh(c,u.current,!1)){const P=((N=(E=_.composedPath)==null?void 0:E.call(_))==null?void 0:N[0])||_.target,w=(P==null?void 0:P.nodeName)==="BUTTON"||(P==null?void 0:P.nodeName)==="A";r.preventDefault!==!1&&(a.current||!w)&&_.preventDefault(),s(!0)}},y=_=>{const k=Kh(_.code,h);qh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},m=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",x),p==null||p.addEventListener("keyup",y),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{p==null||p.removeEventListener("keydown",x),p==null||p.removeEventListener("keyup",y),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,s]),o}function qh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Kh(t,r){return r.includes(t)?"code":"key"}const C_=()=>{const t=Ge();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=Nc(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),v={x:r.x-h,y:r.y-p},x=o.snapGrid??a,y=o.snapToGrid??u;return ps(v,s,y,x)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=eo(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function zg(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)M_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function M_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function P_(t,r){return zg(t,r)}function I_(t,r){return zg(t,r)}function ai(t,r){return{id:t,type:"select",selected:r}}function Yi(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(ai(u.id,c)))}return s}function Qh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Zh(t){return{id:t.id,type:"remove"}}const R_=dg();function T_(t,r,o={}){return m1(t,r,{...o,onError:o.onError??R_})}const Jh=t=>t1(t),L_=t=>sg(t);function Dg(t){return L.forwardRef(t)}const Og=typeof window<"u"?L.useLayoutEffect:L.useEffect;function ep(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>A_(()=>o(a=>a+BigInt(1))));return Og(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function A_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Fg=L.createContext(null);function $_({children:t}){const r=Ge(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:v,hasDefaultNodes:x,onNodesChange:y,nodeLookup:m,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let b=p;for(const N of h)b=typeof N=="function"?N(b):N;let E=Qh({items:b,lookup:m});for(const N of k.values())E=N(E);x&&v(b),E.length>0?y==null||y(E):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:N,nodes:P,setNodes:w}=r.getState();N&&w(P)})},[]),s=ep(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:v,hasDefaultEdges:x,onEdgesChange:y,edgeLookup:m}=r.getState();let _=p;for(const k of h)_=typeof k=="function"?k(_):k;x?v(_):y&&y(Qh({items:_,lookup:m}))},[]),u=ep(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Fg.Provider,{value:c,children:t})}function z_(){const t=L.useContext(Fg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const D_=t=>!!t.panZoom;function Zl(){const t=C_(),r=Ge(),o=z_(),s=De(D_),a=L.useMemo(()=>{const u=y=>r.getState().nodeLookup.get(y),c=y=>{o.nodeQueue.push(y)},h=y=>{o.edgeQueue.push(y)},p=y=>{var N,P;const{nodeLookup:m,nodeOrigin:_}=r.getState(),k=Jh(y)?y:m.get(y.id),b=k.parentId?hg(k.position,k.measured,k.parentId,m,_):k.position,E={...k,position:b,width:((N=k.measured)==null?void 0:N.width)??k.width,height:((P=k.measured)==null?void 0:P.height)??k.height};return os(E)},v=(y,m,_={replace:!1})=>{c(k=>k.map(b=>{if(b.id===y){const E=typeof m=="function"?m(b):m;return _.replace&&Jh(E)?E:{...b,...E}}return b}))},x=(y,m,_={replace:!1})=>{h(k=>k.map(b=>{if(b.id===y){const E=typeof m=="function"?m(b):m;return _.replace&&L_(E)?E:{...b,...E}}return b}))};return{getNodes:()=>r.getState().nodes.map(y=>({...y})),getNode:y=>{var m;return(m=u(y))==null?void 0:m.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:y=[]}=r.getState();return y.map(m=>({...m}))},getEdge:y=>r.getState().edgeLookup.get(y),setNodes:c,setEdges:h,addNodes:y=>{const m=Array.isArray(y)?y:[y];o.nodeQueue.push(_=>[..._,...m])},addEdges:y=>{const m=Array.isArray(y)?y:[y];o.edgeQueue.push(_=>[..._,...m])},toObject:()=>{const{nodes:y=[],edges:m=[],transform:_}=r.getState(),[k,b,E]=_;return{nodes:y.map(N=>({...N})),edges:m.map(N=>({...N})),viewport:{x:k,y:b,zoom:E}}},deleteElements:async({nodes:y=[],edges:m=[]})=>{const{nodes:_,edges:k,onNodesDelete:b,onEdgesDelete:E,triggerNodeChanges:N,triggerEdgeChanges:P,onDelete:w,onBeforeDelete:j}=r.getState(),{nodes:$,edges:z}=await s1({nodesToRemove:y,edgesToRemove:m,nodes:_,edges:k,onBeforeDelete:j}),B=z.length>0,Y=$.length>0;if(B){const Q=z.map(Zh);E==null||E(z),P(Q)}if(Y){const Q=$.map(Zh);b==null||b($),N(Q)}return(Y||B)&&(w==null||w({nodes:$,edges:z})),{deletedNodes:$,deletedEdges:z}},getIntersectingNodes:(y,m=!0,_)=>{const k=Nh(y),b=k?y:p(y),E=_!==void 0;return b?(_||r.getState().nodes).filter(N=>{const P=r.getState().nodeLookup.get(N.id);if(P&&!k&&(N.id===y.id||!P.internals.positionAbsolute))return!1;const w=os(E?N:P),j=Ol(w,b);return m&&j>0||j>=w.width*w.height||j>=b.width*b.height}):[]},isNodeIntersecting:(y,m,_=!0)=>{const b=Nh(y)?y:p(y);if(!b)return!1;const E=Ol(b,m);return _&&E>0||E>=m.width*m.height||E>=b.width*b.height},updateNode:v,updateNodeData:(y,m,_={replace:!1})=>{v(y,k=>{const b=typeof m=="function"?m(k):m;return _.replace?{...k,data:b}:{...k,data:{...k.data,...b}}},_)},updateEdge:x,updateEdgeData:(y,m,_={replace:!1})=>{x(y,k=>{const b=typeof m=="function"?m(k):m;return _.replace?{...k,data:b}:{...k,data:{...k.data,...b}}},_)},getNodesBounds:y=>{const{nodeLookup:m,nodeOrigin:_}=r.getState();return n1(y,{nodeLookup:m,nodeOrigin:_})},getHandleConnections:({type:y,id:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${y}${m?`-${m}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:y,handleId:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${y?m?`-${y}-${m}`:`-${y}`:""}`))==null?void 0:k.values())??[])},fitView:async y=>{const m=r.getState().fitViewResolver??u1();return r.setState({fitViewQueued:!0,fitViewOptions:y,fitViewResolver:m}),o.nodeQueue.push(_=>[..._]),m.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const tp=t=>t.selected,O_=typeof window<"u"?window:void 0;function F_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ge(),{deleteElements:s}=Zl(),a=ls(t,{actInsideInputWithModifier:!1}),u=ls(r,{target:O_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(tp),edges:c.filter(tp)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function H_(t){const r=Ge();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=jc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",mn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const Jl={position:"absolute",width:"100%",height:"100%",top:0,left:0},B_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function V_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=di.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:v,translateExtent:x,minZoom:y,maxZoom:m,zoomActivationKeyCode:_,preventScrolling:k=!0,children:b,noWheelClassName:E,noPanClassName:N,onViewportChange:P,isControlledViewport:w,paneClickDistance:j,selectionOnDrag:$}){const z=Ge(),B=L.useRef(null),{userSelectionActive:Y,lib:Q,connectionInProgress:ne}=De(B_,Qe),ee=ls(_),te=L.useRef();H_(B);const q=L.useCallback(C=>{P==null||P({x:C[0],y:C[1],zoom:C[2]}),w||z.setState({transform:C})},[P,w]);return L.useEffect(()=>{if(B.current){te.current=G1({domNode:B.current,minZoom:y,maxZoom:m,translateExtent:x,viewport:v,onDraggingChange:U=>z.setState(M=>M.paneDragging===U?M:{paneDragging:U}),onPanZoomStart:(U,M)=>{const{onViewportChangeStart:D,onMoveStart:F}=z.getState();F==null||F(U,M),D==null||D(M)},onPanZoom:(U,M)=>{const{onViewportChange:D,onMove:F}=z.getState();F==null||F(U,M),D==null||D(M)},onPanZoomEnd:(U,M)=>{const{onViewportChangeEnd:D,onMoveEnd:F}=z.getState();F==null||F(U,M),D==null||D(M)}});const{x:C,y:V,zoom:W}=te.current.getViewport();return z.setState({panZoom:te.current,transform:[C,V,W],domNode:B.current.closest(".react-flow")}),()=>{var U;(U=te.current)==null||U.destroy()}}},[]),L.useEffect(()=>{var C;(C=te.current)==null||C.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:ee,preventScrolling:k,noPanClassName:N,userSelectionActive:Y,noWheelClassName:E,lib:Q,onTransformChange:q,connectionInProgress:ne,selectionOnDrag:$,paneClickDistance:j})},[t,r,o,s,a,u,c,h,p,ee,k,N,Y,E,Q,q,ne,$,j]),d.jsx("div",{className:"react-flow__renderer",ref:B,style:Jl,children:b})}const W_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function U_(){const{userSelectionActive:t,userSelectionRect:r}=De(W_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const Gu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},G_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function Y_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=rs.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:v,onPaneContextMenu:x,onPaneScroll:y,onPaneMouseEnter:m,onPaneMouseMove:_,onPaneMouseLeave:k,children:b}){const E=L.useRef(0),N=Ge(),{userSelectionActive:P,elementsSelectable:w,dragging:j,panBy:$,autoPanSpeed:z}=De(G_,Qe),B=w&&(t||P),Y=L.useRef(null),Q=L.useRef(),ne=L.useRef(new Set),ee=L.useRef(new Set),te=L.useRef(!1),q=L.useRef(!1),C=L.useRef({x:0,y:0}),V=L.useRef(!1),W=Z=>{if(q.current||te.current||N.getState().connection.inProgress){q.current=!1,te.current=!1;return}v==null||v(Z),N.getState().resetSelectedElements(),N.setState({nodesSelectionActive:!1})},U=Z=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Z.preventDefault();return}x==null||x(Z)},M=y?Z=>y(Z):void 0,D=Z=>{q.current&&(Z.stopPropagation(),q.current=!1)},F=Z=>{var $e,st;if(Z.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:se,transform:me}=N.getState();if(Q.current=se==null?void 0:se.getBoundingClientRect(),!Q.current)return;const ke=Z.target===Y.current;if(!ke&&!!Z.target.closest(".nokey")||!t||!(c&&ke||r)||Z.button!==0||!Z.isPrimary)return;(st=($e=Z.target)==null?void 0:$e.setPointerCapture)==null||st.call($e,Z.pointerId),q.current=!1;const{x:Ne,y:Me}=gn(Z.nativeEvent,Q.current),Te=ps({x:Ne,y:Me},me);N.setState({userSelectionRect:{width:0,height:0,startX:Te.x,startY:Te.y,x:Ne,y:Me}}),ke||(Z.stopPropagation(),Z.preventDefault())};function R(Z,se){const{userSelectionRect:me}=N.getState();if(!me)return;const{transform:ke,nodeLookup:ve,edgeLookup:re,connectionLookup:Ne,triggerNodeChanges:Me,triggerEdgeChanges:Te,defaultEdgeOptions:$e}=N.getState(),st={x:me.startX,y:me.startY},{x:lt,y:at}=eo(st,ke),Ye={startX:st.x,startY:st.y,x:Zmt.id)),ee.current=new Set;const gt=($e==null?void 0:$e.selectable)??!0;for(const mt of ne.current){const Pt=Ne.get(mt);if(Pt)for(const{edgeId:ut}of Pt.values()){const Je=re.get(ut);Je&&(Je.selectable??gt)&&ee.current.add(ut)}}if(!jh(wt,ne.current)){const mt=Yi(ve,ne.current,!0);Me(mt)}if(!jh(qt,ee.current)){const mt=Yi(re,ee.current);Te(mt)}N.setState({userSelectionRect:Ye,userSelectionActive:!0,nodesSelectionActive:!1})}function A(){if(!a||!Q.current)return;const[Z,se]=kc(C.current,Q.current,z);$({x:Z,y:se}).then(me=>{if(!q.current||!me){E.current=requestAnimationFrame(A);return}const{x:ke,y:ve}=C.current;R(ke,ve),E.current=requestAnimationFrame(A)})}const ie=()=>{cancelAnimationFrame(E.current),E.current=0,V.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=Z=>{const{userSelectionRect:se,transform:me,resetSelectedElements:ke}=N.getState();if(!Q.current||!se)return;const{x:ve,y:re}=gn(Z.nativeEvent,Q.current);C.current={x:ve,y:re};const Ne=eo({x:se.startX,y:se.startY},me);if(!q.current){const Me=r?0:u;if(Math.hypot(ve-Ne.x,re-Ne.y)<=Me)return;ke(),h==null||h(Z)}q.current=!0,V.current||(A(),V.current=!0),R(ve,re)},fe=Z=>{var se,me;if(!B){Z.target===Y.current&&N.getState().connection.inProgress&&(te.current=!0);return}Z.button===0&&((me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),!P&&Z.target===Y.current&&N.getState().userSelectionRect&&(W==null||W(Z)),N.setState({userSelectionActive:!1,userSelectionRect:null}),q.current&&(p==null||p(Z),N.setState({nodesSelectionActive:ne.current.size>0})),ie())},he=Z=>{var se,me;(me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),ie()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:nt(["react-flow__pane",{draggable:pe,dragging:j,selection:t}]),onClick:B?void 0:Gu(W,Y),onContextMenu:Gu(U,Y),onWheel:Gu(M,Y),onPointerEnter:B?void 0:m,onPointerMove:B?oe:_,onPointerUp:fe,onPointerCancel:B?he:void 0,onPointerDownCapture:B?F:void 0,onClickCapture:B?D:void 0,onPointerLeave:k,ref:Y,style:Jl,children:[b,d.jsx(U_,{})]})}function dc({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),v=h.get(t);if(!v){p==null||p("012",mn.error012(t));return}r.setState({nodesSelectionActive:!1}),v.selected?(o||v.selected&&c)&&(u({nodes:[v],edges:[]}),requestAnimationFrame(()=>{var x;return(x=s==null?void 0:s.current)==null?void 0:x.blur()})):a([t])}function Hg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ge(),[p,v]=L.useState(!1),x=L.useRef();return L.useEffect(()=>{if(!r)return x.current=R1({getStoreItems:()=>h.getState(),onNodeMouseDown:y=>{dc({id:y,store:h,nodeRef:t})},onDragStart:()=>{v(!0)},onDragStop:()=>{v(!1)}}),()=>{var y;(y=x.current)==null||y.destroy(),x.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!x.current||x.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const X_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Bg(){const t=Ge();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:v,nodeOrigin:x}=t.getState(),y=new Map,m=X_(c),_=a?u[0]:5,k=a?u[1]:5,b=o.direction.x*_*o.factor,E=o.direction.y*k*o.factor;for(const[,N]of v){if(!m(N))continue;let P={x:N.internals.positionAbsolute.x+b,y:N.internals.positionAbsolute.y+E};a&&(P=hs(P,u));const{position:w,positionAbsolute:j}=lg({nodeId:N.id,nextPosition:P,nodeLookup:v,nodeExtent:s,nodeOrigin:x,onError:h});N.position=w,N.internals.positionAbsolute=j,y.set(N.id,N)}p(y)},[])}const Ic=L.createContext(null),q_=Ic.Provider;Ic.Consumer;const Vg=()=>L.useContext(Ic),K_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Wg=L.createContext(null);function Q_({children:t}){const r=De(K_,Qe);return d.jsx(Wg.Provider,{value:r,children:t})}function Z_(){const t=L.useContext(Wg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const J_={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},eS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:v}=c;if(!h&&!a)return J_;const x=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:x,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Zi.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:x&&v}};function tS({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:v,onMouseDown:x,onTouchStart:y,...m},_){var V,W;const k=c||null,b=t==="target",E=Ge(),N=Vg(),{connectOnClick:P,noPanClassName:w,rfId:j}=Z_(),{connectingFrom:$,connectingTo:z,clickConnecting:B,isPossibleEndHandle:Y,connectionInProcess:Q,clickConnectionInProcess:ne,valid:ee}=De(eS(N,k,t),Qe);N||(W=(V=E.getState()).onError)==null||W.call(V,"010",mn.error010());const te=U=>{const{defaultEdgeOptions:M,onConnect:D,hasDefaultEdges:F}=E.getState(),R={...M,...U};if(F){const{edges:A,setEdges:ie,onError:oe}=E.getState();ie(T_(R,A,{onError:oe}))}D==null||D(R),h==null||h(R)},q=U=>{if(!N)return;const M=mg(U.nativeEvent);if(a&&(M&&U.button===0||!M)){const D=E.getState();cc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:b,handleId:k,nodeId:N,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...F)=>{var R,A;return(A=(R=E.getState()).onConnectEnd)==null?void 0:A.call(R,...F)},updateConnection:D.updateConnection,onConnect:te,isValidConnection:o||((...F)=>{var R,A;return((A=(R=E.getState()).isValidConnection)==null?void 0:A.call(R,...F))??!0}),getTransform:()=>E.getState().transform,getFromHandle:()=>E.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}M?x==null||x(U):y==null||y(U)},C=U=>{const{onClickConnectStart:M,onClickConnectEnd:D,connectionClickStartHandle:F,connectionMode:R,isValidConnection:A,lib:ie,rfId:oe,nodeLookup:fe,connection:he}=E.getState();if(!N||!F&&!a)return;if(!F){M==null||M(U.nativeEvent,{nodeId:N,handleId:k,handleType:t}),E.setState({connectionClickStartHandle:{nodeId:N,type:t,id:k}});return}const pe=pg(U.target),Z=o||A,{connection:se,isValid:me}=cc.isValid(U.nativeEvent,{handle:{nodeId:N,id:k,type:t},connectionMode:R,fromNodeId:F.nodeId,fromHandleId:F.id||null,fromType:F.type,isValidConnection:Z,flowId:oe,doc:pe,lib:ie,nodeLookup:fe});me&&se&&te(se);const ke=structuredClone(he);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,D==null||D(U,ke),E.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":k,"data-nodeid":N,"data-handlepos":r,"data-id":`${j}-${N}-${k}-${t}`,className:nt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",w,v,{source:!b,target:b,connectable:s,connectablestart:a,connectableend:u,clickconnecting:B,connectingfrom:$,connectingto:z,valid:ee,connectionindicator:s&&(!Q||Y)&&(Q||ne?u:a)}]),onMouseDown:q,onTouchStart:q,onClick:P?C:void 0,ref:_,...m,children:p})}const no=L.memo(Dg(tS));function nS({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(no,{type:"source",position:o,isConnectable:r})]})}function rS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:s=Se.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(no,{type:"source",position:s,isConnectable:r})]})}function iS(){return null}function oS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const Fl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},np={input:nS,default:rS,output:oS,group:iS};function sS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const lS=t=>{const{width:r,height:o,x:s,y:a}=fs(t.nodeLookup,{filter:u=>!!u.selected});return{width:pn(r)?r:null,height:pn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function aS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ge(),{width:a,height:u,transformString:c,userSelectionActive:h}=De(lS,Qe),p=Bg(),v=L.useRef(null);L.useEffect(()=>{var _;o||(_=v.current)==null||_.focus({preventScroll:!0})},[o]);const x=!h&&a!==null&&u!==null;if(Hg({nodeRef:v,disabled:!x}),!x)return null;const y=t?_=>{const k=s.getState().nodes.filter(b=>b.selected);t(_,k)}:void 0,m=_=>{Object.prototype.hasOwnProperty.call(Fl,_.key)&&(_.preventDefault(),p({direction:Fl[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:nt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:v,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:o?void 0:-1,onKeyDown:o?void 0:m,style:{width:a,height:u}})})}const rp=typeof window<"u"?window:void 0,uS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Ug({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:v,selectionOnDrag:x,selectionMode:y,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:b,zoomActivationKeyCode:E,elementsSelectable:N,zoomOnScroll:P,zoomOnPinch:w,panOnScroll:j,panOnScrollSpeed:$,panOnScrollMode:z,zoomOnDoubleClick:B,panOnDrag:Y,autoPanOnSelection:Q,defaultViewport:ne,translateExtent:ee,minZoom:te,maxZoom:q,preventScrolling:C,onSelectionContextMenu:V,noWheelClassName:W,noPanClassName:U,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:F}){const{nodesSelectionActive:R,userSelectionActive:A}=De(uS,Qe),ie=ls(v,{target:rp}),oe=ls(b,{target:rp}),fe=oe||Y,he=oe||j,pe=x&&fe!==!0,Z=ie||A||pe;return F_({deleteKeyCode:p,multiSelectionKeyCode:k}),d.jsx(V_,{onPaneContextMenu:u,elementsSelectable:N,zoomOnScroll:P,zoomOnPinch:w,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:$,panOnScrollMode:z,zoomOnDoubleClick:B,panOnDrag:!ie&&fe,defaultViewport:ne,translateExtent:ee,minZoom:te,maxZoom:q,zoomActivationKeyCode:E,preventScrolling:C,noWheelClassName:W,noPanClassName:U,onViewportChange:D,isControlledViewport:F,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(Y_,{onSelectionStart:m,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:Q,isSelecting:!!Z,selectionMode:y,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:pe,children:[t,R&&d.jsx(aS,{onSelectionContextMenu:V,noPanClassName:U,disableKeyboardA11y:M})]})})}Ug.displayName="FlowRenderer";const cS=L.memo(Ug),dS=t=>r=>t?Sc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function fS(t){return De(L.useCallback(dS(t),[t]),Qe)}const hS=t=>t.updateNodeInternals;function pS(){const t=De(hS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function gS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ge(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),v=L.useRef(r),x=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!x||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[x,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const y=v.current!==r,m=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(y||m||_)&&(v.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function mS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:v,nodesFocusable:x,resizeObserver:y,noDragClassName:m,noPanClassName:_,disableKeyboardA11y:k,rfId:b,nodeTypes:E,nodeClickDistance:N,onError:P}){const{node:w,internals:j,isParent:$}=De(Z=>{const se=Z.nodeLookup.get(t),me=Z.parentLookup.has(t);return{node:se,internals:se.internals,isParent:me}},Qe);let z=w.type||"default",B=(E==null?void 0:E[z])||np[z];B===void 0&&(P==null||P("003",mn.error003(z)),z="default",B=(E==null?void 0:E.default)||np.default);const Y=!!(w.draggable||h&&typeof w.draggable>"u"),Q=!!(w.selectable||p&&typeof w.selectable>"u"),ne=!!(w.connectable||v&&typeof w.connectable>"u"),ee=!!(w.focusable||x&&typeof w.focusable>"u"),te=Ge(),q=fg(w),C=gS({node:w,nodeType:z,hasDimensions:q,resizeObserver:y}),V=Hg({nodeRef:C,disabled:w.hidden||!Y,noDragClassName:m,handleSelector:w.dragHandle,nodeId:t,isSelectable:Q,nodeClickDistance:N}),W=Bg();if(w.hidden)return null;const U=vn(w),M=sS(w),D=Q||Y||r||o||s||a,F=o?Z=>o(Z,{...j.userNode}):void 0,R=s?Z=>s(Z,{...j.userNode}):void 0,A=a?Z=>a(Z,{...j.userNode}):void 0,ie=u?Z=>u(Z,{...j.userNode}):void 0,oe=c?Z=>c(Z,{...j.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:se,nodeDragThreshold:me}=te.getState();Q&&(!se||!Y||me>0)&&dc({id:t,store:te,nodeRef:C}),r&&r(Z,{...j.userNode})},he=Z=>{if(!(gg(Z.nativeEvent)||k)){if(ng.includes(Z.key)&&Q){const se=Z.key==="Escape";dc({id:t,store:te,unselect:se,nodeRef:C})}else if(Y&&w.selected&&Object.prototype.hasOwnProperty.call(Fl,Z.key)){Z.preventDefault();const{ariaLabelConfig:se}=te.getState();te.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),W({direction:Fl[Z.key],factor:Z.shiftKey?4:1})}}},pe=()=>{var Ne;if(k||!((Ne=C.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:Z,width:se,height:me,autoPanOnNodeFocus:ke,setCenter:ve}=te.getState();if(!ke)return;Sc(new Map([[t,w]]),{x:0,y:0,width:se,height:me},Z,!0).length>0||ve(w.position.x+U.width/2,w.position.y+U.height/2,{zoom:Z[2]})};return d.jsx("div",{className:nt(["react-flow__node",`react-flow__node-${z}`,{[_]:Y},w.className,{selected:w.selected,selectable:Q,parent:$,draggable:Y,dragging:V}]),ref:C,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:q?"visible":"hidden",...w.style,...M},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:F,onMouseMove:R,onMouseLeave:A,onContextMenu:ie,onClick:fe,onDoubleClick:oe,onKeyDown:ee?he:void 0,tabIndex:ee?0:void 0,onFocus:ee?pe:void 0,role:w.ariaRole??(ee?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${Lg}-${b}`,"aria-label":w.ariaLabel,...w.domAttributes,children:d.jsx(q_,{value:t,children:d.jsx(B,{id:t,data:w.data,type:z,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:w.selected??!1,selectable:Q,draggable:Y,deletable:w.deletable??!0,isConnectable:ne,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:V,dragHandle:w.dragHandle,zIndex:j.z,parentId:w.parentId,...U})})})}var yS=L.memo(mS);const vS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Gg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=De(vS,Qe),u=fS(t.onlyRenderVisibleElements),c=pS();return d.jsx("div",{className:"react-flow__nodes",style:Jl,children:u.map(h=>d.jsx(yS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Gg.displayName="NodeRenderer";const xS=L.memo(Gg);function wS(t){return De(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&h1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const _S=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},SS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ip={[is.Arrow]:_S,[is.ArrowClosed]:SS};function kS(t){const r=Ge();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(ip,t)?ip[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",mn.error009(t)),null)},[t])}const NS=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=kS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},Yg=({defaultColor:t,rfId:r})=>{const o=De(u=>u.edges),s=De(u=>u.defaultEdgeOptions),a=L.useMemo(()=>_1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(NS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Yg.displayName="MarkerDefinitions";var jS=L.memo(Yg);function Xg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:v,...x}){const[y,m]=L.useState({x:1,y:0,width:0,height:0}),_=nt(["react-flow__edge-textwrapper",v]),k=L.useRef(null);return L.useEffect(()=>{if(k.current){const b=k.current.getBBox();m({x:b.x,y:b.y,width:b.width,height:b.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-y.width/2} ${r-y.height/2})`,className:_,visibility:y.width?"visible":"hidden",...x,children:[a&&d.jsx("rect",{width:y.width+2*c[0],x:-c[0],y:-c[1],height:y.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:k,style:s,children:o}),p]}):null}Xg.displayName="EdgeText";const bS=L.memo(Xg);function ea({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:v=20,...x}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...x,d:t,fill:"none",className:nt(["react-flow__edge-path",x.className])}),v?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:v,className:"react-flow__edge-interaction"}):null,s&&pn(r)&&pn(o)?d.jsx(bS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function op({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function qg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top}){const[c,h]=op({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,v]=op({pos:u,x1:s,y1:a,x2:t,y2:r}),[x,y,m,_]=yg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:v});return[`M${t},${r} C${c},${h} ${p},${v} ${s},${a}`,x,y,m,_]}function Kg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,interactionWidth:N})=>{const[P,w,j]=qg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),$=t.isInternal?void 0:r;return d.jsx(ea,{id:$,path:P,labelX:w,labelY:j,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,interactionWidth:N})})}const ES=Kg({isInternal:!1}),Qg=Kg({isInternal:!0});ES.displayName="SimpleBezierEdge";Qg.displayName="SimpleBezierEdgeInternal";function Zg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,sourcePosition:_=Se.Bottom,targetPosition:k=Se.Top,markerEnd:b,markerStart:E,pathOptions:N,interactionWidth:P})=>{const[w,j,$]=lc({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:N==null?void 0:N.borderRadius,offset:N==null?void 0:N.offset,stepPosition:N==null?void 0:N.stepPosition}),z=t.isInternal?void 0:r;return d.jsx(ea,{id:z,path:w,labelX:j,labelY:$,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:b,markerStart:E,interactionWidth:P})})}const Jg=Zg({isInternal:!1}),em=Zg({isInternal:!0});Jg.displayName="SmoothStepEdge";em.displayName="SmoothStepEdgeInternal";function tm(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(Jg,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const CS=tm({isInternal:!1}),nm=tm({isInternal:!0});CS.displayName="StepEdge";nm.displayName="StepEdgeInternal";function rm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:b})=>{const[E,N,P]=wg({sourceX:o,sourceY:s,targetX:a,targetY:u}),w=t.isInternal?void 0:r;return d.jsx(ea,{id:w,path:E,labelX:N,labelY:P,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:b})})}const MS=rm({isInternal:!1}),im=rm({isInternal:!0});MS.displayName="StraightEdge";im.displayName="StraightEdgeInternal";function om(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,pathOptions:N,interactionWidth:P})=>{const[w,j,$]=vg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:N==null?void 0:N.curvature}),z=t.isInternal?void 0:r;return d.jsx(ea,{id:z,path:w,labelX:j,labelY:$,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,interactionWidth:P})})}const PS=om({isInternal:!1}),sm=om({isInternal:!0});PS.displayName="BezierEdge";sm.displayName="BezierEdgeInternal";const sp={default:sm,straight:im,step:nm,smoothstep:em,simplebezier:Qg},lp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},IS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,RS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,ap="react-flow__edgeupdater";function up({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:nt([ap,`${ap}-${h}`]),cx:IS(r,s,t),cy:RS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function TS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:v,onReconnectStart:x,onReconnectEnd:y,setReconnecting:m,setUpdateHover:_}){const k=Ge(),b=(j,$)=>{if(j.button!==0)return;const{autoPanOnConnect:z,domNode:B,connectionMode:Y,connectionRadius:Q,lib:ne,onConnectStart:ee,cancelConnection:te,nodeLookup:q,rfId:C,panBy:V,updateConnection:W}=k.getState(),U=$.type==="target",M=(R,A)=>{m(!1),y==null||y(R,o,$.type,A)},D=R=>v==null?void 0:v(o,R),F=(R,A)=>{m(!0),x==null||x(j,o,$.type),ee==null||ee(R,A)};cc.onPointerDown(j.nativeEvent,{autoPanOnConnect:z,connectionMode:Y,connectionRadius:Q,domNode:B,handleId:$.id,nodeId:$.nodeId,nodeLookup:q,isTarget:U,edgeUpdaterType:$.type,lib:ne,flowId:C,cancelConnection:te,panBy:V,isValidConnection:(...R)=>{var A,ie;return((ie=(A=k.getState()).isValidConnection)==null?void 0:ie.call(A,...R))??!0},onConnect:D,onConnectStart:F,onConnectEnd:(...R)=>{var A,ie;return(ie=(A=k.getState()).onConnectEnd)==null?void 0:ie.call(A,...R)},onReconnectEnd:M,updateConnection:W,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},E=j=>b(j,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),N=j=>b(j,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),P=()=>_(!0),w=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(up,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:E,onMouseEnter:P,onMouseOut:w,type:"source"}),(t===!0||t==="target")&&d.jsx(up,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:N,onMouseEnter:P,onMouseOut:w,type:"target"})]})}function LS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,rfId:k,edgeTypes:b,noPanClassName:E,onError:N,disableKeyboardA11y:P}){let w=De(ve=>ve.edgeLookup.get(t));const j=De(ve=>ve.defaultEdgeOptions);w=j?{...j,...w}:w;let $=w.type||"default",z=(b==null?void 0:b[$])||sp[$];z===void 0&&(N==null||N("011",mn.error011($)),$="default",z=(b==null?void 0:b.default)||sp.default);const B=!!(w.focusable||r&&typeof w.focusable>"u"),Y=typeof y<"u"&&(w.reconnectable||o&&typeof w.reconnectable>"u"),Q=!!(w.selectable||s&&typeof w.selectable>"u"),ne=L.useRef(null),[ee,te]=L.useState(!1),[q,C]=L.useState(!1),V=Ge(),{zIndex:W=w.zIndex,sourceX:U,sourceY:M,targetX:D,targetY:F,sourcePosition:R,targetPosition:A}=De(L.useCallback(ve=>{const re=ve.nodeLookup.get(w.source),Ne=ve.nodeLookup.get(w.target);if(!re||!Ne)return lp;const Me=w1({id:t,sourceNode:re,targetNode:Ne,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:ve.connectionMode,onError:N}),Te=f1({selected:w.selected,zIndex:w.zIndex,sourceNode:re,targetNode:Ne,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||lp,zIndex:Te}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex,N]),Qe),ie=L.useMemo(()=>w.markerStart?`url('#${ac(w.markerStart,k)}')`:void 0,[w.markerStart,k]),oe=L.useMemo(()=>w.markerEnd?`url('#${ac(w.markerEnd,k)}')`:void 0,[w.markerEnd,k]);if(w.hidden||U===null||M===null||D===null||F===null)return null;const fe=ve=>{var Te;const{addSelectedEdges:re,unselectNodesAndEdges:Ne,multiSelectionActive:Me}=V.getState();Q&&(V.setState({nodesSelectionActive:!1}),w.selected&&Me?(Ne({nodes:[],edges:[w]}),(Te=ne.current)==null||Te.blur()):re([t])),a&&a(ve,w)},he=u?ve=>{u(ve,{...w})}:void 0,pe=c?ve=>{c(ve,{...w})}:void 0,Z=h?ve=>{h(ve,{...w})}:void 0,se=p?ve=>{p(ve,{...w})}:void 0,me=v?ve=>{v(ve,{...w})}:void 0,ke=ve=>{var re;if(!P&&ng.includes(ve.key)&&Q){const{unselectNodesAndEdges:Ne,addSelectedEdges:Me}=V.getState();ve.key==="Escape"?((re=ne.current)==null||re.blur(),Ne({edges:[w]})):Me([t])}};return d.jsx("svg",{style:{zIndex:W},children:d.jsxs("g",{className:nt(["react-flow__edge",`react-flow__edge-${$}`,w.className,E,{selected:w.selected,animated:w.animated,inactive:!Q&&!a,updating:ee,selectable:Q}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:Z,onMouseMove:se,onMouseLeave:me,onKeyDown:B?ke:void 0,tabIndex:B?0:void 0,role:w.ariaRole??(B?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":B?`${Ag}-${k}`:void 0,ref:ne,...w.domAttributes,children:[!q&&d.jsx(z,{id:t,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:Q,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:U,sourceY:M,targetX:D,targetY:F,sourcePosition:R,targetPosition:A,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),Y&&d.jsx(TS,{edge:w,isReconnectable:Y,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,sourceX:U,sourceY:M,targetX:D,targetY:F,sourcePosition:R,targetPosition:A,setUpdateHover:te,setReconnecting:C})]})})}var AS=L.memo(LS);const $S=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function lm({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:v,onEdgeClick:x,reconnectRadius:y,onEdgeDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:b}){const{edgesFocusable:E,edgesReconnectable:N,elementsSelectable:P,onError:w}=De($S,Qe),j=wS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(jS,{defaultColor:t,rfId:o}),j.map($=>d.jsx(AS,{id:$,edgesFocusable:E,edgesReconnectable:N,elementsSelectable:P,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,onClick:x,reconnectRadius:y,onDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:w,edgeTypes:s,disableKeyboardA11y:b},$))]})}lm.displayName="EdgeRenderer";const zS=L.memo(lm),cp=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function DS({children:t}){const r=Ge(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return Og(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=cp(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:cp(s)},children:t})}function OS(t){const r=Zl(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const FS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function HS(t){const r=De(FS),o=Ge();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function BS(t){return t.connection.inProgress?{...t.connection,to:ps(t.connection.to,t.transform)}:{...t.connection}}function VS(t){return BS}function WS(t){const r=VS();return De(r,Qe)}const US=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function GS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=De(US,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:nt(["react-flow__connection",og(h)]),children:d.jsx(am,{style:r,type:o,CustomComponent:s,isValid:h})})})}const am=({style:t,type:r=Lr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:v,toNode:x,toHandle:y,toPosition:m,pointer:_}=WS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:v.x,toY:v.y,fromPosition:p,toPosition:m,connectionStatus:og(s),toNode:x,toHandle:y,pointer:_});let k="";const b={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:v.x,targetY:v.y,targetPosition:m};switch(r){case Lr.Bezier:[k]=vg(b);break;case Lr.SimpleBezier:[k]=qg(b);break;case Lr.Step:[k]=lc({...b,borderRadius:0});break;case Lr.SmoothStep:[k]=lc(b);break;default:[k]=wg(b)}return d.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};am.displayName="ConnectionLine";const YS={};function dp(t=YS){L.useRef(t),Ge(),L.useEffect(()=>{},[t])}function XS(){Ge(),L.useRef(!1),L.useEffect(()=>{},[])}function um({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,onSelectionContextMenu:y,onSelectionStart:m,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:b,connectionLineComponent:E,connectionLineContainerStyle:N,selectionKeyCode:P,selectionOnDrag:w,selectionMode:j,multiSelectionKeyCode:$,panActivationKeyCode:z,zoomActivationKeyCode:B,deleteKeyCode:Y,onlyRenderVisibleElements:Q,elementsSelectable:ne,defaultViewport:ee,translateExtent:te,minZoom:q,maxZoom:C,preventScrolling:V,defaultMarkerColor:W,zoomOnScroll:U,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:F,panOnScrollMode:R,zoomOnDoubleClick:A,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneScroll:se,onPaneContextMenu:me,paneClickDistance:ke,nodeClickDistance:ve,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,noDragClassName:Ye,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,viewport:ut,onViewportChange:Je,nodesDraggable:An}){return dp(t),dp(r),XS(),OS(o),HS(ut),d.jsx(cS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneContextMenu:me,onPaneScroll:se,paneClickDistance:ke,deleteKeyCode:Y,selectionKeyCode:P,selectionOnDrag:w,selectionMode:j,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:$,panActivationKeyCode:z,zoomActivationKeyCode:B,elementsSelectable:ne,zoomOnScroll:U,zoomOnPinch:M,zoomOnDoubleClick:A,panOnScroll:D,panOnScrollSpeed:F,panOnScrollMode:R,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:ee,translateExtent:te,minZoom:q,maxZoom:C,onSelectionContextMenu:y,preventScrolling:V,noDragClassName:Ye,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,onViewportChange:Je,isControlledViewport:!!ut,children:d.jsxs(DS,{children:[d.jsx(zS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,onlyRenderVisibleElements:Q,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,defaultMarkerColor:W,noPanClassName:qt,disableKeyboardA11y:gt,rfId:Pt}),d.jsx(GS,{style:b,type:k,component:E,containerStyle:N}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(xS,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,nodeClickDistance:ve,onlyRenderVisibleElements:Q,noPanClassName:qt,noDragClassName:Ye,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,nodesDraggable:An}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}um.displayName="GraphView";const qS=L.memo(um),KS=dg(),fp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:v=2,nodeOrigin:x,nodeExtent:y,zIndexMode:m="basic"}={})=>{const _=new Map,k=new Map,b=new Map,E=new Map,N=s??r??[],P=o??t??[],w=x??[0,0],j=y??ns;kg(b,E,N);const{nodesInitialized:$}=uc(P,_,k,{nodeOrigin:w,nodeExtent:j,zIndexMode:m});let z=[0,0,1];if(c&&a&&u){const B=fs(_,{filter:ee=>!!((ee.width||ee.initialWidth)&&(ee.height||ee.initialHeight))}),{x:Y,y:Q,zoom:ne}=Nc(B,a,u,p,v,(h==null?void 0:h.padding)??.1);z=[Y,Q,ne]}return{rfId:"1",width:a??0,height:u??0,transform:z,nodes:P,nodesInitialized:$,nodeLookup:_,parentLookup:k,edges:N,edgeLookup:E,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:v,translateExtent:ns,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Zi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...ig},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:KS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:rg,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},QS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m})=>u_((_,k)=>{async function b(){const{nodeLookup:E,panZoom:N,fitViewOptions:P,fitViewResolver:w,width:j,height:$,minZoom:z,maxZoom:B}=k();N&&(await o1({nodes:E,width:j,height:$,panZoom:N,minZoom:z,maxZoom:B},P),w==null||w.resolve(!0),_({fitViewResolver:null}))}return{...fp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,defaultNodes:o,defaultEdges:s,zIndexMode:m}),setNodes:E=>{const{nodeLookup:N,parentLookup:P,nodeOrigin:w,nodeExtent:j,elevateNodesOnSelect:$,fitViewQueued:z,zIndexMode:B,nodesSelectionActive:Y}=k(),{nodesInitialized:Q,hasSelectedNodes:ne}=uc(E,N,P,{nodeOrigin:w,nodeExtent:j,elevateNodesOnSelect:$,checkEquality:!0,zIndexMode:B}),ee=Y&≠z&&Q?(b(),_({nodes:E,nodesInitialized:Q,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:ee})):_({nodes:E,nodesInitialized:Q,nodesSelectionActive:ee})},setEdges:E=>{const{connectionLookup:N,edgeLookup:P}=k();kg(N,P,E),_({edges:E})},setDefaultNodesAndEdges:(E,N)=>{if(E){const{setNodes:P}=k();P(E),_({hasDefaultNodes:!0})}if(N){const{setEdges:P}=k();P(N),_({hasDefaultEdges:!0})}},updateNodeInternals:E=>{const{triggerNodeChanges:N,nodeLookup:P,parentLookup:w,domNode:j,nodeOrigin:$,nodeExtent:z,debug:B,fitViewQueued:Y,zIndexMode:Q}=k(),{changes:ne,updatedInternals:ee}=C1(E,P,w,j,$,z,Q);ee&&(N1(P,w,{nodeOrigin:$,nodeExtent:z,zIndexMode:Q}),Y?(b(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(ne==null?void 0:ne.length)>0&&(B&&console.log("React Flow: trigger node changes",ne),N==null||N(ne)))},updateNodePositions:(E,N=!1)=>{const P=[];let w=[];const{nodeLookup:j,triggerNodeChanges:$,connection:z,updateConnection:B,onNodesChangeMiddlewareMap:Y}=k();for(const[Q,ne]of E){const ee=j.get(Q),te=!!(ee!=null&&ee.expandParent&&(ee!=null&&ee.parentId)&&(ne!=null&&ne.position)),q={id:Q,type:"position",position:te?{x:Math.max(0,ne.position.x),y:Math.max(0,ne.position.y)}:ne.position,dragging:N};if(ee&&z.inProgress&&z.fromNode.id===ee.id){const C=mi(ee,z.fromHandle,Se.Left,!0);B({...z,from:C})}te&&ee.parentId&&P.push({id:Q,parentId:ee.parentId,rect:{...ne.internals.positionAbsolute,width:ne.measured.width??0,height:ne.measured.height??0}}),w.push(q)}if(P.length>0){const{parentLookup:Q,nodeOrigin:ne}=k(),ee=Pc(P,j,Q,ne);w.push(...ee)}for(const Q of Y.values())w=Q(w);$(w)},triggerNodeChanges:E=>{const{onNodesChange:N,setNodes:P,nodes:w,hasDefaultNodes:j,debug:$}=k();if(E!=null&&E.length){if(j){const z=P_(E,w);P(z)}$&&console.log("React Flow: trigger node changes",E),N==null||N(E)}},triggerEdgeChanges:E=>{const{onEdgesChange:N,setEdges:P,edges:w,hasDefaultEdges:j,debug:$}=k();if(E!=null&&E.length){if(j){const z=I_(E,w);P(z)}$&&console.log("React Flow: trigger edge changes",E),N==null||N(E)}},addSelectedNodes:E=>{const{multiSelectionActive:N,edgeLookup:P,nodeLookup:w,triggerNodeChanges:j,triggerEdgeChanges:$}=k();if(N){const z=E.map(B=>ai(B,!0));j(z);return}j(Yi(w,new Set([...E]),!0)),$(Yi(P))},addSelectedEdges:E=>{const{multiSelectionActive:N,edgeLookup:P,nodeLookup:w,triggerNodeChanges:j,triggerEdgeChanges:$}=k();if(N){const z=E.map(B=>ai(B,!0));$(z);return}$(Yi(P,new Set([...E]))),j(Yi(w,new Set,!0))},unselectNodesAndEdges:({nodes:E,edges:N}={})=>{const{edges:P,nodes:w,nodeLookup:j,triggerNodeChanges:$,triggerEdgeChanges:z}=k(),B=E||w,Y=N||P,Q=[];for(const ee of B){if(!ee.selected)continue;const te=j.get(ee.id);te&&(te.selected=!1),Q.push(ai(ee.id,!1))}const ne=[];for(const ee of Y)ee.selected&&ne.push(ai(ee.id,!1));$(Q),z(ne)},setMinZoom:E=>{const{panZoom:N,maxZoom:P}=k();N==null||N.setScaleExtent([E,P]),_({minZoom:E})},setMaxZoom:E=>{const{panZoom:N,minZoom:P}=k();N==null||N.setScaleExtent([P,E]),_({maxZoom:E})},setTranslateExtent:E=>{var N;(N=k().panZoom)==null||N.setTranslateExtent(E),_({translateExtent:E})},resetSelectedElements:()=>{const{edges:E,nodes:N,triggerNodeChanges:P,triggerEdgeChanges:w,elementsSelectable:j}=k();if(!j)return;const $=N.reduce((B,Y)=>Y.selected?[...B,ai(Y.id,!1)]:B,[]),z=E.reduce((B,Y)=>Y.selected?[...B,ai(Y.id,!1)]:B,[]);P($),w(z)},setNodeExtent:E=>{const{nodes:N,nodeLookup:P,parentLookup:w,nodeOrigin:j,elevateNodesOnSelect:$,nodeExtent:z,zIndexMode:B}=k();E[0][0]===z[0][0]&&E[0][1]===z[0][1]&&E[1][0]===z[1][0]&&E[1][1]===z[1][1]||(uc(N,P,w,{nodeOrigin:j,nodeExtent:E,elevateNodesOnSelect:$,checkEquality:!1,zIndexMode:B}),_({nodeExtent:E}))},panBy:E=>{const{transform:N,width:P,height:w,panZoom:j,translateExtent:$}=k();return M1({delta:E,panZoom:j,transform:N,translateExtent:$,width:P,height:w})},setCenter:async(E,N,P)=>{const{width:w,height:j,maxZoom:$,panZoom:z}=k();if(!z)return!1;const B=typeof(P==null?void 0:P.zoom)<"u"?P.zoom:$;return await z.setViewport({x:w/2-E*B,y:j/2-N*B,zoom:B},{duration:P==null?void 0:P.duration,ease:P==null?void 0:P.ease,interpolate:P==null?void 0:P.interpolate}),!0},cancelConnection:()=>{_({connection:{...ig}})},updateConnection:E=>{_({connection:E})},reset:()=>_({...fp()})}},Object.is);function cm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m,children:_}){const[k]=L.useState(()=>QS({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:v,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:x,nodeExtent:y,zIndexMode:m}));return d.jsx(c_,{value:k,children:d.jsx($_,{children:d.jsx(Q_,{children:_})})})}function ZS({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:v,maxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_}){return L.useContext(Kl)?d.jsx(d.Fragment,{children:t}):d.jsx(cm,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:v,initialMaxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_,children:t})}const JS={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function ek({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:v,onMove:x,onMoveStart:y,onMoveEnd:m,onConnect:_,onConnectStart:k,onConnectEnd:b,onClickConnectStart:E,onClickConnectEnd:N,onNodeMouseEnter:P,onNodeMouseMove:w,onNodeMouseLeave:j,onNodeContextMenu:$,onNodeDoubleClick:z,onNodeDragStart:B,onNodeDrag:Y,onNodeDragStop:Q,onNodesDelete:ne,onEdgesDelete:ee,onDelete:te,onSelectionChange:q,onSelectionDragStart:C,onSelectionDrag:V,onSelectionDragStop:W,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:F,connectionMode:R,connectionLineType:A=Lr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:Z=!1,selectionMode:se=rs.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:ke=ss()?"Meta":"Control",zoomActivationKeyCode:ve=ss()?"Meta":"Control",snapToGrid:re,snapGrid:Ne,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Te,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,nodeOrigin:Ye=$g,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt=!0,defaultViewport:mt=k_,minZoom:Pt=.5,maxZoom:ut=2,translateExtent:Je=ns,preventScrolling:An=!0,nodeExtent:Ot,defaultMarkerColor:xn="#b1b1b7",zoomOnScroll:io=!0,zoomOnPinch:$n=!0,panOnScroll:vi=!1,panOnScrollSpeed:or=.5,panOnScrollMode:$r=di.Free,zoomOnDoubleClick:zn=!0,panOnDrag:zr=!0,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn=1,nodeClickDistance:Fn=0,children:_n,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn=10,onNodesChange:Ht,onEdgesChange:Or,noDragClassName:nn="nodrag",noWheelClassName:Fr="nowheel",noPanClassName:yt="nopan",fitView:Hn,fitViewOptions:ur,connectOnClick:oo,attributionPosition:It,proOptions:Bn,defaultEdgeOptions:Hr,elevateNodesOnSelect:jn=!0,elevateEdgesOnSelect:Br=!1,disableKeyboardA11y:xi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:so,autoPanOnSelection:Vr=!0,autoPanSpeed:wi,connectionRadius:cr,isValidConnection:lo,onError:dr,style:Vn,id:bt,nodeDragThreshold:Wr,connectionDragThreshold:Et,viewport:ao,onViewportChange:Ur,width:Gr,height:Wn,colorMode:Un="light",debug:bn,onScroll:Bt,ariaLabelConfig:_i,zIndexMode:Yr="basic",...fr},hr){const Gn=bt||"1",En=E_(Un),uo=L.useCallback(pr=>{pr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Bt==null||Bt(pr)},[Bt]);return d.jsx("div",{"data-testid":"rf__wrapper",...fr,onScroll:uo,style:{...Vn,...JS},ref:hr,className:nt(["react-flow",a,En]),id:bt,role:"application",children:d.jsxs(ZS,{nodes:t,edges:r,width:Gr,height:Wn,fitView:Hn,fitViewOptions:ur,minZoom:Pt,maxZoom:ut,nodeOrigin:Ye,nodeExtent:Ot,zIndexMode:Yr,children:[d.jsx(b_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:k,onConnectEnd:b,onClickConnectStart:E,onClickConnectEnd:N,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt,elevateNodesOnSelect:jn,elevateEdgesOnSelect:Br,minZoom:Pt,maxZoom:ut,nodeExtent:Ot,onNodesChange:Ht,onEdgesChange:Or,snapToGrid:re,snapGrid:Ne,connectionMode:R,translateExtent:Je,connectOnClick:oo,defaultEdgeOptions:Hr,fitView:Hn,fitViewOptions:ur,onNodesDelete:ne,onEdgesDelete:ee,onDelete:te,onNodeDragStart:B,onNodeDrag:Y,onNodeDragStop:Q,onSelectionDrag:V,onSelectionDragStart:C,onSelectionDragStop:W,onMove:x,onMoveStart:y,onMoveEnd:m,noPanClassName:yt,nodeOrigin:Ye,rfId:Gn,autoPanOnConnect:Ve,autoPanOnNodeDrag:so,autoPanSpeed:wi,onError:dr,connectionRadius:cr,isValidConnection:lo,selectNodesOnDrag:Te,nodeDragThreshold:Wr,connectionDragThreshold:Et,onBeforeDelete:F,debug:bn,ariaLabelConfig:_i,zIndexMode:Yr}),d.jsx(qS,{onInit:v,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:P,onNodeMouseMove:w,onNodeMouseLeave:j,onNodeContextMenu:$,onNodeDoubleClick:z,nodeTypes:u,edgeTypes:c,connectionLineType:A,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:Z,selectionMode:se,deleteKeyCode:he,multiSelectionKeyCode:ke,panActivationKeyCode:me,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:mt,translateExtent:Je,minZoom:Pt,maxZoom:ut,preventScrolling:An,zoomOnScroll:io,zoomOnPinch:$n,zoomOnDoubleClick:zn,panOnScroll:vi,panOnScrollSpeed:or,panOnScrollMode:$r,panOnDrag:zr,autoPanOnSelection:Vr,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn,nodeClickDistance:Fn,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn,defaultMarkerColor:xn,noDragClassName:nn,noWheelClassName:Fr,noPanClassName:yt,rfId:Gn,disableKeyboardA11y:xi,nodeExtent:Ot,viewport:ao,onViewportChange:Ur,nodesDraggable:$e}),d.jsx(S_,{onSelectionChange:q}),_n,d.jsx(y_,{proOptions:Bn,position:It}),d.jsx(m_,{rfId:Gn,disableKeyboardA11y:xi})]})})}var tk=Dg(ek);function nk({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:nt(["react-flow__background-pattern",o,s])})}function rk({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:nt(["react-flow__background-pattern","dots",r])})}var Ar;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Ar||(Ar={}));const ik={[Ar.Dots]:1,[Ar.Lines]:1,[Ar.Cross]:6},ok=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function dm({id:t,variant:r=Ar.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:v,patternClassName:x}){const y=L.useRef(null),{transform:m,patternId:_}=De(ok,Qe),k=s||ik[r],b=r===Ar.Dots,E=r===Ar.Cross,N=Array.isArray(o)?o:[o,o],P=[N[0]*m[2]||1,N[1]*m[2]||1],w=k*m[2],j=Array.isArray(u)?u:[u,u],$=E?[w,w]:P,z=[j[0]*m[2]+$[0]/2,j[1]*m[2]+$[1]/2],B=`${_}${t||""}`;return d.jsxs("svg",{className:nt(["react-flow__background",v]),style:{...p,...Jl,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:y,"data-testid":"rf__background",children:[d.jsx("pattern",{id:B,x:m[0]%P[0],y:m[1]%P[1],width:P[0],height:P[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${z[0]},-${z[1]})`,children:b?d.jsx(rk,{radius:w/2,className:x}):d.jsx(nk,{dimensions:$,lineWidth:a,variant:r,className:x})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${B})`})]})}dm.displayName="Background";const sk=L.memo(dm);function lk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ak(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function uk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 ck(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 kl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:nt(["react-flow__controls-button",r]),...o,children:t})}const fk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function fm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:v,children:x,position:y="bottom-left",orientation:m="vertical","aria-label":_}){const k=Ge(),{isInteractive:b,minZoomReached:E,maxZoomReached:N,ariaLabelConfig:P}=De(fk,Qe),{zoomIn:w,zoomOut:j,fitView:$}=Zl(),z=()=>{w(),u==null||u()},B=()=>{j(),c==null||c()},Y=()=>{$(a),h==null||h()},Q=()=>{k.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),p==null||p(!b)},ne=m==="horizontal"?"horizontal":"vertical";return d.jsxs(Ql,{className:nt(["react-flow__controls",ne,v]),position:y,style:t,"data-testid":"rf__controls","aria-label":_??P["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(kl,{onClick:z,className:"react-flow__controls-zoomin",title:P["controls.zoomIn.ariaLabel"],"aria-label":P["controls.zoomIn.ariaLabel"],disabled:N,children:d.jsx(lk,{})}),d.jsx(kl,{onClick:B,className:"react-flow__controls-zoomout",title:P["controls.zoomOut.ariaLabel"],"aria-label":P["controls.zoomOut.ariaLabel"],disabled:E,children:d.jsx(ak,{})})]}),o&&d.jsx(kl,{className:"react-flow__controls-fitview",onClick:Y,title:P["controls.fitView.ariaLabel"],"aria-label":P["controls.fitView.ariaLabel"],children:d.jsx(uk,{})}),s&&d.jsx(kl,{className:"react-flow__controls-interactive",onClick:Q,title:P["controls.interactive.ariaLabel"],"aria-label":P["controls.interactive.ariaLabel"],children:b?d.jsx(dk,{}):d.jsx(ck,{})}),x]})}fm.displayName="Controls";const hk=L.memo(fm);function pk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:v,borderRadius:x,shapeRendering:y,selected:m,onClick:_}){const{background:k,backgroundColor:b}=u||{},E=c||k||b;return d.jsx("rect",{className:nt(["react-flow__minimap-node",{selected:m},v]),x:r,y:o,rx:x,ry:x,width:s,height:a,style:{fill:E,stroke:h,strokeWidth:p},shapeRendering:y,onClick:_?N=>_(N,t):void 0})}const gk=L.memo(pk),mk=t=>t.nodes.map(r=>r.id),Yu=t=>t instanceof Function?t:()=>t;function yk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=gk,onClick:c}){const h=De(mk,Qe),p=Yu(r),v=Yu(t),x=Yu(o),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(m=>d.jsx(xk,{id:m,nodeColorFunc:p,nodeStrokeColorFunc:v,nodeClassNameFunc:x,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:y},m))})}function vk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:v,x,y,width:m,height:_}=De(k=>{const b=k.nodeLookup.get(t);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const E=b.internals.userNode,{x:N,y:P}=b.internals.positionAbsolute,{width:w,height:j}=vn(E);return{node:E,x:N,y:P,width:w,height:j}},Qe);return!v||v.hidden||!fg(v)?null:d.jsx(h,{x,y,width:m,height:_,style:v.style,selected:!!v.selected,className:s(v),color:r(v),borderRadius:a,strokeColor:o(v),strokeWidth:u,shapeRendering:c,onClick:p,id:v.id})}const xk=L.memo(vk);var wk=L.memo(yk);const _k=200,Sk=150,kk=t=>!t.hidden,Nk=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?ug(fs(t.nodeLookup,{filter:kk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},hp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,jk=(t,r)=>hp(t.viewBB,r.viewBB)&&hp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,bk="react-flow__minimap-desc";function hm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:v,maskStrokeColor:x,maskStrokeWidth:y,position:m="bottom-right",onClick:_,onNodeClick:k,pannable:b=!1,zoomable:E=!1,ariaLabel:N,inversePan:P,zoomStep:w=1,offsetScale:j=5}){const $=Ge(),z=L.useRef(null),{boundingRect:B,viewBB:Y,rfId:Q,panZoom:ne,translateExtent:ee,flowWidth:te,flowHeight:q,ariaLabelConfig:C}=De(Nk,jk),V=(t==null?void 0:t.width)??_k,W=(t==null?void 0:t.height)??Sk,U=B.width/V,M=B.height/W,D=Math.max(U,M),F=D*V,R=D*W,A=j*D,ie=B.x-(F-B.width)/2-A,oe=B.y-(R-B.height)/2-A,fe=F+A*2,he=R+A*2,pe=`${bk}-${Q}`,Z=L.useRef(0),se=L.useRef();Z.current=D,L.useEffect(()=>{if(z.current&&ne)return se.current=D1({domNode:z.current,panZoom:ne,getTransform:()=>$.getState().transform,getViewScale:()=>Z.current}),()=>{var re;(re=se.current)==null||re.destroy()}},[ne]),L.useEffect(()=>{var re;(re=se.current)==null||re.update({translateExtent:ee,width:te,height:q,inversePan:P,pannable:b,zoomStep:w,zoomable:E})},[b,E,P,w,ee,te,q]);const me=_?re=>{var Te;const[Ne,Me]=((Te=se.current)==null?void 0:Te.pointer(re))||[0,0];_(re,{x:Ne,y:Me})}:void 0,ke=k?L.useCallback((re,Ne)=>{const Me=$.getState().nodeLookup.get(Ne).internals.userNode;k(re,Me)},[]):void 0,ve=N??C["minimap.ariaLabel"];return d.jsx(Ql,{position:m,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof v=="string"?v:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof y=="number"?y*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:nt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:V,height:W,viewBox:`${ie} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:z,onClick:me,children:[ve&&d.jsx("title",{id:pe,children:ve}),d.jsx(wk,{onClick:ke,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-A},${oe-A}h${fe+A*2}v${he+A*2}h${-fe-A*2}z + M${Y.x},${Y.y}h${Y.width}v${Y.height}h${-Y.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}hm.displayName="MiniMap";const Ek=L.memo(hm),Ck=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Mk={[to.Line]:"right",[to.Handle]:"bottom-right"};function Pk({nodeId:t,position:r,variant:o=to.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:v=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:y=!1,resizeDirection:m,autoScale:_=!0,shouldResize:k,onResizeStart:b,onResize:E,onResizeEnd:N}){const P=Vg(),w=typeof t=="string"?t:P,j=Ge(),$=L.useRef(null),z=o===to.Handle,B=De(L.useCallback(Ck(z&&_),[z,_]),Qe),Y=L.useRef(null),Q=r??Mk[o];L.useEffect(()=>{if(!(!$.current||!w))return Y.current||(Y.current=Q1({domNode:$.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:ee,transform:te,snapGrid:q,snapToGrid:C,nodeOrigin:V,domNode:W}=j.getState();return{nodeLookup:ee,transform:te,snapGrid:q,snapToGrid:C,nodeOrigin:V,paneDomNode:W}},onChange:(ee,te)=>{const{triggerNodeChanges:q,nodeLookup:C,parentLookup:V,nodeOrigin:W}=j.getState(),U=[],M={x:ee.x,y:ee.y},D=C.get(w);if(D&&D.expandParent&&D.parentId){const F=D.origin??W,R=ee.width??D.measured.width??0,A=ee.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:R,height:A,...hg({x:ee.x??D.position.x,y:ee.y??D.position.y},{width:R,height:A},D.parentId,C,F)}},oe=Pc([ie],C,V,W);U.push(...oe),M.x=ee.x?Math.max(F[0]*R,ee.x):void 0,M.y=ee.y?Math.max(F[1]*A,ee.y):void 0}if(M.x!==void 0&&M.y!==void 0){const F={id:w,type:"position",position:{...M}};U.push(F)}if(ee.width!==void 0&&ee.height!==void 0){const R={id:w,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:ee.width,height:ee.height}};U.push(R)}for(const F of te){const R={...F,type:"position"};U.push(R)}q(U)},onEnd:({width:ee,height:te})=>{const q={id:w,type:"dimensions",resizing:!1,dimensions:{width:ee,height:te}};j.getState().triggerNodeChanges([q])}})),Y.current.update({controlPosition:Q,boundaries:{minWidth:h,minHeight:p,maxWidth:v,maxHeight:x},keepAspectRatio:y,resizeDirection:m,onResizeStart:b,onResize:E,onResizeEnd:N,shouldResize:k}),()=>{var ee;(ee=Y.current)==null||ee.destroy()}},[Q,h,p,v,x,y,b,E,N,k]);const ne=Q.split("-");return d.jsx("div",{className:nt(["react-flow__resize-control","nodrag",...ne,o,s]),ref:$,style:{...a,scale:B,...c&&{[z?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Pk);const Ik={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function ta(t){return Ik[t]??8}const fc=208,hc=64,Rk=88,Tk=28,Lk=8;function Ak(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function $k(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const N of t){const P=ta(N.type),w=s.get(P)??[];w.push(N),s.set(P,w)}const u=[...s.keys()].sort((N,P)=>N-P).map(N=>[...s.get(N)??[]].sort((P,w)=>P.name.localeCompare(w.name)||P.id.localeCompare(w.id))),c=new Set(t.map(N=>N.id)),h=new Map,p=new Map;for(const N of t)h.set(N.id,[]),p.set(N.id,[]);for(const N of r)!c.has(N.src)||!c.has(N.dst)||N.src===N.dst||(p.get(N.src).push(N.dst),h.get(N.dst).push(N.src));const v=new Map;u.forEach((N,P)=>{for(const w of N)v.set(w.id,P)});const x=new Map,y=()=>{for(const N of u)N.forEach((P,w)=>x.set(P.id,w))};y();const m=(N,P)=>{const w=N.map((j,$)=>{const z=P(j.id).map(Y=>x.get(Y)).filter(Y=>Y!==void 0),B=Ak(z);return{n:j,bary:Number.isNaN(B)?$:B,name:j.name,id:j.id}});return w.sort((j,$)=>j.bary-$.bary||j.name.localeCompare($.name)||j.id.localeCompare($.id)),w.map(j=>j.n)},_=N=>P=>v.get(P)===N;for(let N=0;N(h.get(w)??[]).filter(_(P-1))),y();for(let P=u.length-2;P>=0;P--)u[P]=m(u[P],w=>(p.get(w)??[]).filter(_(P+1))),y()}const k=fc+Rk,b=hc+Tk,E=Math.max(...u.map(N=>N.length),1);return u.forEach((N,P)=>{const w=(E-N.length)*b/2;N.forEach((j,$)=>{o.set(j.id,{x:P*k,y:w+$*b})})}),o}const zk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),pm=90,Dk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),pp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Ok=Math.PI*(3-Math.sqrt(5)),gm=220,Fk=26,Hk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function mm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function TN(t){return pp[t]?pp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Bk(t){return t>=pm?"3d":"2d"}function Vk(t){return t>=pm?"overview":"full"}function Wk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(mm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Dk.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Wk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Gk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function Yk(t,r,o,s){const a=new Set(t.map(b=>b.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const b of r){if(!a.has(b.src)||!a.has(b.dst))continue;const E=u.get(b.src)??[];E.push({dst:b.dst,id:b.id}),u.set(b.src,E);const N=c.get(b.dst)??[];N.push({src:b.src,id:b.id}),c.set(b.dst,N)}const h=new Set(t.filter(b=>zk.has(b.type)).map(b=>b.id)),p=h.size?h:a,v=new Set,x=[o];for(;x.length;){const b=x.pop();if(!v.has(b)){v.add(b);for(const E of u.get(b)??[])v.has(E.dst)||x.push(E.dst)}}const y=new Set([o]),m=[...p].filter(b=>v.has(b)),_=new Set(m);for(;m.length;){const b=m.pop();y.add(b);for(const E of c.get(b)??[])v.has(E.src)&&!_.has(E.src)&&(_.add(E.src),m.push(E.src))}const k=new Set;for(const b of r)y.has(b.src)&&y.has(b.dst)&&k.add(b.id);return{nodeIds:y,edgeIds:k}}function LN(t){const r=new Map;for(const s of t){const a=ta(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*gm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Fk*Math.sqrt(h+1),v=h*Ok;o.set(c.id,{x:u,y:p*Math.cos(v),z:p*Math.sin(v)})})}return o}function AN(t){const r=new Map;for(const o of t){const s=ta(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*gm,count:s}))}const Nl=16,Xk=12,qk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Kk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),gp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Qk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},mp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],yp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Zk=new Set(["looks_idempotent_on_pk","null","blank"]),Jk=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function eN(t){return gp[t]?gp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function tN(t,r,o){const s=new Map(r.map(m=>[m.id,m])),a=[];qk.has(t.type)&&a.push("sink"),Kk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(m=>m.dst===t.id),h=o.filter(m=>m.src===t.id),p=c.slice(0,Nl).map(m=>jl(m,s,m.src)),v=h.slice(0,Nl).map(m=>jl(m,s,m.dst)),x=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,y={type:t.type,typeLabel:Qo(ro(t.type)),layer:Hk[ta(t.type)]??"other",purpose:eN(t.type),name:t.name,qualifiedName:t.qualified_name,file:x,context:t.context,roles:a,facts:rN(u).filter(m=>!(m.key==="app"&&m.value===t.context)),inputs:p,outputs:v,extraInputs:Math.max(0,c.length-Nl),extraOutputs:Math.max(0,h.length-Nl),degreeIn:c.length,degreeOut:h.length,inputKinds:vp(c.map(m=>jl(m,s,m.src))),outputKinds:vp(h.map(m=>jl(m,s,m.dst))),pathSummary:""};return y.pathSummary=nN(y),y}function vp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function nN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function jl(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Qo(ro(s.type)):"",edgeType:t.type,edgeLabel:Qo(t.type),inferred:t.confidence<.8}}function rN(t){const r=[...mp.filter(a=>a in t),...Object.keys(t).filter(a=>!mp.includes(a)&&!yp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||yp.has(a)||Jk.has(a))continue;s.add(a);const u=iN(a,t[a]);u!=null&&o.push({key:a,label:Qk[a]??Qo(a),value:u})}return o}function iN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Zk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return oN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Xk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function oN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const sN=new Set,lN=L.lazy(()=>_0(()=>import("./LayeredGraph3D-D_cvtTgT.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),aN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function uN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(no,{type:"target",position:Se.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:ro(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Tr(t.name)}),d.jsx(no,{type:"source",position:Se.Right,isConnectable:!1})]})}const cN={load:uN},dN=new Set(["django","react","stitch","arch"]);function fN({topologyKey:t}){const{fitView:r}=Zl();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function hN(t,r,o=null,s={}){const a=new Map(t.map(p=>[p.id,p])),u=$k(t,r),c=t.map(p=>{var y;const v=((y=s.roles)==null?void 0:y[p.id])||[],x=!!s.testOverlay&&!v.includes("tested")&&!v.includes("untested")&&!v.includes("test")&&!v.includes("seed");return{id:p.id,type:"load",position:u.get(p.id)??{x:0,y:0},data:{name:p.name,type:p.type,file:p.file_path,roles:v,dim:x},selected:o===p.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:fc,height:hc,style:{width:fc,height:hc}}}),h=r.filter(p=>a.has(p.src)&&a.has(p.dst)).map(p=>{const v=aN[p.weight]||"var(--edge-cheap)",x=!!(o&&(p.src===o||p.dst===o));return{id:p.id,source:p.src,target:p.dst,type:"smoothstep",animated:p.weight==="critical",style:{stroke:v,strokeWidth:p.weight==="critical"?2.4:1.2,strokeDasharray:p.confidence<.8?"6 4":void 0},markerEnd:{type:is.ArrowClosed,width:14,height:14,color:v},label:x?p.type.replaceAll("_"," "):void 0,labelStyle:x?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:x?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:x?[3,5]:void 0,labelBgBorderRadius:x?4:void 0}});return{rfNodes:c,rfEdges:h}}function pN({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:v}){const x=tN(t,r,o);return L.useEffect(()=>{const y=m=>{m.key==="Escape"&&s()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:x.typeLabel}),d.jsx("div",{className:"inspector-roles",children:x.roles.map(y=>d.jsx("span",{className:"inspector-chip",children:y},y))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Tr(x.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:x.purpose}),x.context?d.jsx("div",{className:"muted",children:Tr(x.context)}):null,x.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Tr(x.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Tr(x.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",x.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[x.degreeIn," in · ",x.degreeOut," out"]}),x.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:x.pathSummary}):null,x.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:x.facts.map(y=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:y.label}),d.jsx("dd",{children:Tr(y.value)})]},y.key))}):null,d.jsx(xp,{title:"Inputs",testId:"graph-inspector-inputs",links:x.inputs,extra:x.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(xp,{title:"Outputs",testId:"graph-inspector-outputs",links:x.outputs,extra:x.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),a?d.jsx("p",{className:"whatif-hint","data-testid":"whatif-hint",children:v?"Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map.":"Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."}):null,d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",title:"Start a hypothetical walk from this node. Does not use Base/Head.",onClick:()=>a(t.id),children:"What if this changes"}):null,v?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",title:"Hide nodes that are not on a path from here to a sink. Does not start a new walk.",onClick:()=>v(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function xp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Xu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:v,repoPath:x,onOpenFile:y,pinnedId:m,onPin:_}){const[k,b]=L.useState(null),E=a!==void 0?a:k,N=re=>{a===void 0&&b(re),u==null||u(re)},[P,w]=L.useState(null),[j,$]=L.useState(null),[z,B]=L.useState(new Set(dN)),[Y,Q]=L.useState(!1),[ne,ee]=L.useState(""),[te,q]=L.useState(!1),C=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,V=P??Bk(t.length),W=j??Vk(t.length),U=Y?E:null,M=L.useMemo(()=>p?Yk(t,r,p):null,[t,r,p]),D=M?t.filter(re=>M.nodeIds.has(re.id)):t,F=M?r.filter(re=>M.edgeIds.has(re.id)):r,R=L.useMemo(()=>Uk(D,F,{detail:W,families:z,focusId:U,neighborhoodOnly:!!U}),[D,F,W,z,U]),A=L.useMemo(()=>`${R.nodes.map(re=>re.id).join("\0")}|${R.edges.map(re=>re.id).join("\0")}`,[R.nodes,R.edges]),ie=E?t.find(re=>re.id===E)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const re=hN(R.nodes,R.edges,E,{roles:c,testOverlay:h});return C&&(re.rfEdges=re.rfEdges.map(Ne=>({...Ne,animated:!1}))),re},[R.nodes,R.edges,E,C,c,h]);L.useEffect(()=>{if(!s)return;const re=t.find(Ne=>Ne.file_path===s);re&&N(re.id)},[s,t]);const he=L.useMemo(()=>Gk(t,ne),[t,ne]),pe=(re,Ne)=>{N(Ne.id)},Z=()=>{N(null),Q(!1)},se=ie?d.jsx(pN,{node:ie,nodes:t,edges:r,onClose:Z,onWhatIf:o,onSelect:N,onOpenFile:y,pinned:m===ie.id,onPin:_,onIsolate:v?re=>{v(p===re?null:re)}:void 0}):null,me=re=>{B(Ne=>{const Me=new Set(Ne);if(Me.has(re)){if(Me.size===1)return Ne;Me.delete(re)}else Me.add(re);return Me})},ke=L.useMemo(()=>{const re=new Set;for(const Ne of t)re.add(mm(Ne.type));return re},[t]),ve=t.length-R.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:V==="2d"?"active":"","aria-pressed":V==="2d",onClick:()=>w("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:V==="3d"?"active":"","aria-pressed":V==="3d",onClick:()=>w("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:W==="overview"?"active":"","aria-pressed":W==="overview",onClick:()=>$("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:W==="full"?"active":"","aria-pressed":W==="full",onClick:()=>$("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(re=>ke.has(re)).map(re=>d.jsx("button",{type:"button","data-testid":`graph-family-${re}`,className:z.has(re)?"active":"","aria-pressed":z.has(re),onClick:()=>me(re),children:re},re))}),d.jsx("button",{type:"button",className:Y?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!E,onClick:()=>Q(re=>!re),children:Y?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>v==null?void 0:v(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:ne,onChange:re=>{ee(re.target.value),q(!0)},onFocus:()=>q(!0),onBlur:()=>window.setTimeout(()=>q(!1),150)}),te&&ne.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(re=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:Ne=>Ne.preventDefault(),onClick:()=>{N(re.id),ee(""),q(!1)},children:[re.name,d.jsx("span",{className:"muted",children:ro(re.type)})]})},re.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[R.nodes.length," nodes · ",R.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:V==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(lN,{nodes:R.nodes,edges:R.edges,selectedId:E,neighborIds:U?R.neighborIds:sN,onSelect:re=>{N(re),re||Q(!1)}})}),se]}):d.jsxs(cm,{children:[d.jsxs(tk,{nodes:oe,edges:fe,nodeTypes:cN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:Z,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(fN,{topologyKey:A}),d.jsx(sk,{}),d.jsx(Ek,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(hk,{})]}),se]})})]})}function ym(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function gN(t){localStorage.setItem("loadpath.editor",t)}async function mN(t,r,o,s=ym()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const wp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],yN=["preset","branch","tag","commit"];function vN(t){var a;if(!(t!=null&&t.git))return[...wp];const r=((a=t.presets)!=null&&a.length?t.presets:wp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function xN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function wN(t){return yN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function _N(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function _p({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[v,x]=L.useState(!1),[y,m]=L.useState(null),[_,k]=L.useState(0),b=L.useMemo(()=>{const j=vN(u);return y===null?j:xN(j,y)},[u,y]),E=L.useMemo(()=>wN(b),[b]);L.useEffect(()=>{v&&c()},[v,c]),L.useEffect(()=>{k(0)},[y,v]);const N=()=>{x(!1),m(null)},P=j=>{r(j.value),N()},w=j=>{if(j.key==="ArrowDown"){if(j.preventDefault(),!v){x(!0);return}k($=>Math.min($+1,Math.max(b.length-1,0)))}else if(j.key==="ArrowUp"){if(j.preventDefault(),!v)return;k($=>Math.max($-1,0))}else if(j.key==="Enter"&&v){j.preventDefault();const $=b[_];$&&P($)}else j.key==="Escape"&&v&&(j.preventDefault(),N())};return d.jsxs("div",{className:"combo",ref:p,onBlur:j=>{j.currentTarget.contains(j.relatedTarget)||N()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":v,"aria-controls":h,"aria-autocomplete":"list",onChange:j=>{r(j.target.value),v&&m(j.target.value)},onKeyDown:w}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":v,onMouseDown:j=>j.preventDefault(),onClick:()=>v?N():x(!0),children:d.jsx(v0,{})})]}),v?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:E.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):E.map(j=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:_N(j.group)}),j.items.map($=>{const z=b.indexOf($);return d.jsxs("button",{type:"button",role:"option","aria-selected":z===_,className:z===_?"combo-option active":"combo-option","data-testid":`ref-option-${$.group}`,onMouseDown:B=>B.preventDefault(),onMouseEnter:()=>k(z),onClick:()=>P($),children:[d.jsx("span",{className:"combo-label",children:$.label}),$.detail?d.jsx("span",{className:"combo-detail",children:$.detail}):null]},`${$.group}:${$.value}`)})]},j.group))}):null]})}function SN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[v,x]=L.useState(""),[y,m]=L.useState(!1),_=L.useRef(null),k=L.useRef(0),b=async w=>{const j=k.current+1;k.current=j,m(!0);try{const $=await Pe.browse(w);if(k.current!==j)return;a($),c($.path),p($.is_git?$.path:null),x("")}catch($){if(k.current!==j)return;x($ instanceof Error?$.message:String($))}finally{k.current===j&&m(!1)}};L.useEffect(()=>{var w,j;b(t),(w=_.current)==null||w.focus(),(j=_.current)==null||j.select()},[t]);const E=h||(s==null?void 0:s.path)||u,N=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",P=w=>{w.key==="Escape"&&(w.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:P,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:w=>w.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:w=>{w.preventDefault(),b(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:w=>c(w.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void b(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void b(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),v?d.jsx("div",{className:"error",role:"alert",children:v}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":y,children:s!=null&&s.entries.length?s.entries.map(w=>{const j=h===w.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":j,className:j?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":w.path,onClick:()=>p(w.path),onDoubleClick:()=>void b(w.path),children:[d.jsx(jp,{}),d.jsx("span",{className:"explorer-name",children:w.name}),w.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},w.path)}):d.jsx("div",{className:"muted explorer-empty",children:y?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:E,children:E}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!E,onClick:()=>E&&r(E),children:["Use ",N]})]})]})})}const kN={scan:{start:0,end:20},extract:{start:20,end:88},boot:{start:88,end:94},stitch:{start:94,end:99},skipped:{start:100,end:100},done:{start:100,end:100}},NN=new Set(["scan","extract","boot","stitch"]);function jN(t){const r=t.phase||"";if(!r||r==="idle")return null;const o=kN[r];if(!o)return null;if(o.start===o.end)return o.end;const s=t.total||0;if(s<=0)return o.start;const a=Math.min(1,Math.max(0,(t.done||0)/s));return Math.round(o.start+(o.end-o.start)*a)}function bN(t){return!t.phase||t.phase==="idle"?null:typeof t.percent=="number"&&Number.isFinite(t.percent)?Math.max(0,Math.min(100,Math.round(t.percent))):jN(t)}const Hl=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],EN="obsidian",vm="loadpath.theme";function CN(t){return Hl.some(r=>r.id===t)}function xm(){try{const t=localStorage.getItem(vm)||"";if(CN(t))return t}catch{}return EN}function MN(t){var r;return((r=Hl.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function wm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=MN(t);try{localStorage.setItem(vm,t)}catch{}}const qu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:h0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:p0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:g0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:m0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:y0}];function Ku(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function PN(){var co,fo,Si,ho,po,go,ki,Xr,rn,on;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,v]=L.useState(null),[x,y]=L.useState(null),[m,_]=L.useState(null),[k,b]=L.useState([]),[E,N]=L.useState("review"),[P,w]=L.useState(""),[j,$]=L.useState(""),[z,B]=L.useState(null),[Y,Q]=L.useState(!1),[ne,ee]=L.useState(!1),[te,q]=L.useState(""),[C,V]=L.useState({}),[W,U]=L.useState([]),[M,D]=L.useState([]),[F,R]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[A,ie]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[oe,fe]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[he,pe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[Z,se]=L.useState(0),[me,ke]=L.useState(""),[ve,re]=L.useState(xm),[Ne,Me]=L.useState(!1),[Te,$e]=L.useState(!1),[st,lt]=L.useState(!1),[at,Ye]=L.useState(null),[wt,qt]=L.useState(null),[gt,mt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[Pt,ut]=L.useState(null),[Je,An]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[Ot,xn]=L.useState([]),[io,$n]=L.useState(null),[vi,or]=L.useState(null),[$r,zn]=L.useState(null),[zr,sr]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[lr,Ft]=L.useState(null),[ct,Dn]=L.useState(null),[On,wn]=L.useState(!1),[Fn,_n]=L.useState(!1),rt=L.useRef(o);rt.current=o;const Dr=L.useRef(!1);Dr.current=Te;const _t=L.useRef(""),ar=L.useRef(""),Sn=I=>{re(I),wm(I)},dt=L.useRef(""),He=I=>{dt.current=I,$(I)},kn=I=>{let G=0,ce=!1;B(0);const je=()=>{Pe.indexProgress(I).then(Ie=>{if(!dt.current)return;if(Ie.phase&&Ie.phase!=="idle"&&Ie.message&&He(Ie.message),NN.has(Ie.phase))ce=!0;else if(!ce)return;const qr=bN(Ie);qr!=null&&(Ie.phase==="scan"&&!Ie.done?G=qr:G=Math.max(G,qr),B(G))}).catch(()=>{})};je();const Le=window.setInterval(je,250);return()=>{window.clearInterval(Le),B(null)}};L.useEffect(()=>{Pe.settings().then(V).catch(()=>{}).finally(()=>Me(!0)),Pe.repos().then(I=>b(I.repos)).catch(()=>{})},[]);const Nn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const I=o;let G=!1;return ar.current!==I&&Bn(I),Pe.config(I).then(ce=>{!G&&rt.current===I&&or(ce)}).catch(()=>{}),Pe.architectureHealth(I).then(ce=>{!G&&rt.current===I&&zn(ce)}).catch(()=>{}),()=>{G=!0}},[t,o]);const Ht=I=>{rt.current=I,s(I),localStorage.setItem("loadpath.repo",I),I.trim()!==_t.current&&(_t.current="",Ft(null))},Or=L.useCallback(I=>{const G=(I??rt.current).trim();return!G||_t.current===G?Promise.resolve():(_t.current=G,Pe.gitRefs(G).then(ce=>{rt.current.trim()===G&&Ft(ce)}).catch(()=>{_t.current===G&&(_t.current="",Ft(null))}))},[]),nn=(I,G)=>{u(I),h(G),localStorage.setItem("loadpath.base",I),localStorage.setItem("loadpath.head",G)},Fr=(I,G,ce)=>{ie(I),R(G),localStorage.setItem("loadpath.provider",I),localStorage.setItem("loadpath.scmRepo",G),ce!==void 0&&(fe(ce),localStorage.setItem("loadpath.prNumber",ce))},yt=I=>{v(I),se(0),Ye(wt&&I.nodes.some(G=>G.id===wt)?wt:null),ut(null),$n(null),I.what_if||(y(I),I.id&&localStorage.setItem("loadpath.lastReviewId",I.id))},Hn=async I=>{try{const G=await Pe.reviews(I);xn(G.reviews)}catch{xn([])}},ur=async I=>{try{zn(await Pe.architectureHealth(I))}catch{zn(null)}},oo=I=>I==="github"?!!C.github_token_set:I==="gitlab"?!!C.gitlab_token_set:!!C.bitbucket_token_set,It=L.useCallback(async(I=A)=>{var G;try{const ce=await Pe.scmRepos(I);D(ce.repos),(G=ce.user)!=null&&G.login&&V(je=>({...je,...I==="github"?{github_user:ce.user.login}:I==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{D([])}},[A]);L.useEffect(()=>{if(t!=="prs")return;let I=!1;return It(A).catch(()=>{I||D([])}),()=>{I=!0}},[t,A,It]),L.useEffect(()=>{if(!ct)return;let I=!1,G=0;const ce=async()=>{try{const je=await Pe.githubOAuthPoll(ct.flow_id);if(I)return;if(je.status==="complete"){Dn(null);const Le=await Pe.settings();V(Le),q(je.user?`Signed in to GitHub as ${je.user}`:"Signed in to GitHub"),It("github");return}if(je.status==="pending"||je.status==="slow_down"){G=window.setTimeout(ce,Math.max(je.interval||ct.interval,5)*1e3);return}Dn(null),w(je.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(je){if(I)return;Dn(null),w(je instanceof Error?je.message:String(je))}};return G=window.setTimeout(ce,Math.max(ct.interval,5)*1e3),()=>{I=!0,window.clearTimeout(G)}},[ct,It]),L.useEffect(()=>{if(!On)return;let I=!1,G=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(I)return;if(Le.bitbucket.connected){wn(!1);const Ie=await Pe.settings();V(Ie),q(Le.bitbucket.user?`Signed in to Bitbucket as ${Le.bitbucket.user}`:"Signed in to Bitbucket"),It("bitbucket");return}if(Date.now()-ce>18e4){wn(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}G=window.setTimeout(je,1500)}catch(Le){if(I)return;wn(!1),w(Le instanceof Error?Le.message:String(Le))}};return G=window.setTimeout(je,1500),()=>{I=!0,window.clearTimeout(G)}},[On,It]),L.useEffect(()=>{if(!Fn)return;let I=!1,G=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(I)return;if(Le.gitlab.connected){_n(!1);const Ie=await Pe.settings();V(Ie),q(Le.gitlab.user?`Signed in to GitLab as ${Le.gitlab.user}`:"Signed in to GitLab"),It("gitlab");return}if(Date.now()-ce>18e4){_n(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}G=window.setTimeout(je,1500)}catch(Le){if(I)return;_n(!1),w(Le instanceof Error?Le.message:String(Le))}};return G=window.setTimeout(je,1500),()=>{I=!0,window.clearTimeout(G)}},[Fn,It]);const Bn=async(I=o,G=!1)=>{if(!I.trim())return null;ar.current=I,ee(!0);try{const ce=await Pe.architecture(I,!1);rt.current===I&&_(ce);const je=Pe.architectureGraph(I).then(Le=>{rt.current===I&&_(Ie=>Ie&&{...Ie,nodes:Le.nodes,edges:Le.edges,graph_pending:!1})});return je.catch(()=>{}).finally(()=>{rt.current===I&&ee(!1)}),G&&await je,ce}catch(ce){throw rt.current===I&&ee(!1),ce}},Hr=async I=>{const G=I.trim();if(!(!G||G===rt.current)){if(dt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),q(""),v(null),y(null),_(null),N("architecture"),Ht(G),Q(!0),He(`Loading ${f0(G)}…`);try{await Promise.all([Bn(G),Or(G)])}catch(ce){rt.current===G&&w(ce instanceof Error?ce.message:String(ce))}finally{rt.current===G&&(He(""),Q(!1))}}},jn=async()=>{if(dt.current||!Nn())return;w(""),q(""),He("Tracing load path…"),Ht(o),nn(a,c);const I=kn(o);try{const G=await Pe.review(o,a,c,!0,he);yt(G),N("review"),r("review"),await Pe.repos().then(ce=>b(ce.repos)).catch(()=>{}),await Promise.all([Bn(o),Hn(o),ur(o)])}catch(G){w(G instanceof Error?G.message:String(G))}finally{I(),He("")}},Br=async(I=!0)=>{if(dt.current||!Nn())return;w(""),q(""),He(I?"Indexing…":"Full reindex…"),Ht(o);const G=kn(o);try{await Pe.index(o,I);const ce=await Bn(o);await Pe.repos().then(je=>b(je.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(N("architecture"),r("architecture"))}catch(ce){w(ce instanceof Error?ce.message:String(ce))}finally{G(),He("")}},xi=async()=>{if(!dt.current&&Nn()){w(""),q(""),He("Detecting layout…"),Ht(o);try{const I=await Pe.init(o);q(I.message),await Pe.repos().then(G=>b(G.repos)).catch(()=>{})}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},Ve=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),q("Copied markdown brief")}catch(I){w(I instanceof Error?I.message:String(I))}},so=async()=>{if(!dt.current){if(p!=null&&p.what_if){w("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first.");return}if(!(p!=null&&p.markdown)||!F||!oe){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const I=await Pe.postComment(A,F,Number(oe),p.markdown);q(I.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},Vr=async()=>{if(!dt.current){w(""),He("Fetching pull requests…");try{const I=await Pe.prs(A,F,"open",o.trim()||void 0);U(I.pull_requests);const G=M.find(ce=>ce.slug.toLowerCase()===F.trim().toLowerCase());G!=null&&G.local_path&&Ht(G.local_path)}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},wi=async()=>{w("");try{const I=await Pe.githubOAuthStart();Dn(I),Ku(I.verification_uri_complete,"github.com","/login/device")}catch(I){w(I instanceof Error?I.message:String(I))}},cr=async()=>{w("");try{const I=await Pe.bitbucketOAuthStart();wn(!0),Ku(I.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(I){wn(!1),w(I instanceof Error?I.message:String(I))}},lo=async()=>{w("");try{const I=await Pe.gitlabOAuthStart();_n(!0),Ku(I.authorize_url,new URL(I.authorize_url).hostname,"/oauth/authorize")}catch(I){_n(!1),w(I instanceof Error?I.message:String(I))}},dr=async I=>{if(!(dt.current||!o.trim())){w(""),He("Walking what-if path…");try{const G=await Pe.whatIf(o,I);q(`${G.title} — ${G.confidence.level} · ${(G.sinks||[]).length} sinks`),yt({...G,markdown:G.markdown||"",index:G.index||(p==null?void 0:p.index),workspace:G.workspace||(p==null?void 0:p.workspace)}),N("review"),r("review")}catch(G){w(G instanceof Error?G.message:String(G))}finally{He("")}}},Vn=()=>{if(x){yt(x),N("review"),r("review"),q("Restored the last git-range walk");return}v(null),se(0),Ye(null),ut(null),$n(null),N("architecture"),r("architecture"),q("")},bt=async I=>{var Le;if(dt.current)return;Fr(I.provider,I.repo,String(I.number));const G=M.find(Ie=>Ie.slug.toLowerCase()===I.repo.toLowerCase());G!=null&&G.local_path&&Ht(G.local_path),w(""),He(`Fetching ${I.provider} #${I.number}…`);const ce=(G==null?void 0:G.local_path)||o,je=ce?kn(ce):()=>{};try{const Ie=await Pe.reviewPr(I.provider,I.repo,I.number,(G==null?void 0:G.local_path)||o||void 0);yt(Ie),Ie.pull_request&&typeof Ie.pull_request.repo_path=="string"&&Ht(Ie.pull_request.repo_path),nn(String(Ie.base||I.target_branch),String(Ie.head||I.source_branch)),N("review"),r("review"),typeof((Le=Ie.pull_request)==null?void 0:Le.repo_path)=="string"&&Hn(Ie.pull_request.repo_path)}catch(Ie){nn(I.base_sha||I.target_branch,I.head_sha||I.source_branch),r("review"),w(Ie instanceof Error?Ie.message:String(Ie))}finally{je(),He("")}},Wr=async I=>{w("");try{V(await Pe.oauthDisconnect(I)),A===I&&D([]),q(`Disconnected ${I}`)}catch(G){w(G instanceof Error?G.message:String(G))}},Et=async I=>{I.preventDefault();const G=new FormData(I.currentTarget),ce={github_token:String(G.get("github_token")||""),github_oauth_client_id:String(G.get("github_oauth_client_id")||""),github_host:String(G.get("github_host")||""),gitlab_token:String(G.get("gitlab_token")||""),gitlab_host:String(G.get("gitlab_host")||""),gitlab_oauth_client_id:String(G.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(G.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(G.get("bitbucket_token")||""),bitbucket_username:String(G.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(G.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(G.get("bitbucket_oauth_client_secret")||""),ai_provider:String(G.get("ai_provider")||"none"),ai_api_key:String(G.get("ai_api_key")||""),ai_model:String(G.get("ai_model")||""),ai_base_url:String(G.get("ai_base_url")||"")},je=k.length?{...ce,workspaces:k.map(Le=>({path:Le.path,name:Le.name}))}:ce;try{V(await Pe.saveSettings(je)),q("Settings saved on this machine")}catch(Le){w(Le instanceof Error?Le.message:String(Le))}},ao=async()=>{if(!(!p||dt.current)){He("Residual analysis…");try{const I=await Pe.residual(p);ke(I.note)}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},Ur=L.useRef(jn);Ur.current=jn;const Gr=L.useRef(t);Gr.current=t;const Wn=L.useRef(!1);Wn.current=st;const Un=L.useRef(p);Un.current=p;const bn=L.useRef(Z);bn.current=Z,L.useEffect(()=>{const I=localStorage.getItem("loadpath.lastReviewId"),G=(localStorage.getItem("loadpath.repo")||"").trim();if(!I||!G){sr(!1);return}let ce=!1;return Pe.getReview(G,I).then(je=>{ce||(yt(je),nn(je.base||localStorage.getItem("loadpath.base")||"HEAD~1",je.head||localStorage.getItem("loadpath.head")||"HEAD"),Hn(G),ur(G))}).catch(()=>{}).finally(()=>{ce||sr(!1)}),()=>{ce=!0}},[]);const Bt=L.useRef("");L.useEffect(()=>{if(!Je||!o.trim())return;let I=!1;const G=async()=>{try{const je=await Pe.workspaceStatus(o);if(I)return;Bt.current&&je.fingerprint!==Bt.current&&!dt.current&&(pe(!0),localStorage.setItem("loadpath.dirty","1"),Ur.current()),Bt.current=je.fingerprint}catch{}};G();const ce=window.setInterval(G,2e3);return()=>{I=!0,window.clearInterval(ce)}},[Je,o]),L.useEffect(()=>{const I=G=>{var Le;if((G.metaKey||G.ctrlKey)&&G.key.toLowerCase()==="k"){G.preventDefault(),lt(Ie=>!Ie);return}if(Wn.current){G.key==="Escape"&&(G.preventDefault(),lt(!1));return}if(Dr.current){G.key==="Escape"&&(G.preventDefault(),$e(!1));return}const ce=G.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){G.key==="Escape"&&ce.blur();return}if(G.key==="Escape"){w(""),q(""),Ye(wt),ut(null);return}if(G.key==="j"||G.key==="k"){const Ie=((Le=Un.current)==null?void 0:Le.read_order)||[];if(!Ie.length)return;G.preventDefault();const Yn=bn.current,qr=G.key==="j"?Math.min(Ie.length-1,Yn+1):Math.max(0,Yn-1);se(qr);return}const je=qu.find(Ie=>Ie.shortcut===G.key);if(je&&!G.metaKey&&!G.ctrlKey&&!G.altKey&&r(je.id),(G.metaKey||G.ctrlKey)&&G.key==="Enter"){if(Gr.current==="settings"||Gr.current==="prs"||dt.current)return;G.preventDefault(),Ur.current()}};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[wt]);const _i=async(I,G)=>{if(!o.trim())return;const ce=await mN(o,I,G);ce.ok?q(ce.message):w(ce.message)},Yr=async()=>{if(p)try{const I=await Pe.exportHtml(p),G=URL.createObjectURL(I),ce=document.createElement("a");ce.href=G,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(G),q("Saved HTML brief")}catch(I){w(I instanceof Error?I.message:String(I))}},fr=async I=>{if(o.trim()){He("Loading stored review…");try{const G=await Pe.getReview(o,I);yt(G),nn(G.base||a,G.head||c),N("review"),r("review");const ce=Ot.find(je=>je.id!==I);if(ce)try{$n(await Pe.reviewDiff(o,I,ce.id))}catch{$n(null)}}catch(G){w(G instanceof Error?G.message:String(G))}finally{He("")}}},hr={selectedId:at,onSelect:Ye,nodeRoles:p==null?void 0:p.node_roles,testOverlay:gt,isolateSource:Pt,onIsolate:ut,repoPath:o,onOpenFile:_i,pinnedId:wt,onPin:qt},Gn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},...p!=null&&p.what_if?[{id:"exit-whatif",group:"Review",label:x?"Back to git-range walk":"Exit what-if walk",run:Vn}]:[],{id:"index",group:"Run",label:"Index repository",run:()=>void Br(!0)},{id:"watch",group:"Run",label:Je?"Stop watching working tree":"Watch working tree",run:()=>{const I=!Je;An(I),localStorage.setItem("loadpath.watch",I?"1":"0")}},{id:"tests",group:"Graph",label:gt?"Hide test overlay":"Show test overlay",run:()=>{const I=!gt;mt(I),localStorage.setItem("loadpath.testOverlay",I?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Yr()},...qu.map(I=>({id:`tab-${I.id}`,group:"Tabs",label:`Go to ${I.label}`,hint:I.shortcut,run:()=>r(I.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(I=>({id:`node-${I.id}`,group:"Nodes",label:I.name,hint:ro(I.type),run:()=>{Ye(I.id),r("graph")}})),...Ot.slice(0,12).map(I=>({id:`hist-${I.id}`,group:"History",label:I.title||I.id,hint:`${I.level||""} ${I.created_at||""}`.trim(),run:()=>void fr(I.id)}))],En=L.useMemo(()=>E==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[E,m,p]),uo=L.useMemo(()=>E==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[E,m,p]),pr=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Fe=((p==null?void 0:p.findings)||[]).filter(I=>!I.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),qu.map(I=>{const G=I.icon,ce=t===I.id;return d.jsxs("button",{type:"button","data-testid":I.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":I.label,onClick:()=>r(I.id),children:[d.jsx(G,{}),d.jsx("span",{children:I.label})]},I.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:ve,onChange:I=>Sn(I.target.value),children:["dark","light"].map(I=>d.jsx("optgroup",{label:I==="dark"?"Dark":"Light",children:Hl.filter(G=>G.group===I).map(G=>d.jsx("option",{value:G.id,children:G.label},G.id))},I))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:j||pr}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[j?d.jsxs("div",{className:z!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","aria-valuemin":z!=null?0:void 0,"aria-valuemax":z!=null?100:void 0,"aria-valuenow":z??void 0,"data-testid":"progress",children:[d.jsx("i",{style:z!=null?{width:`${z}%`}:void 0}),d.jsx("span",{className:"sr-only",children:j})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[k.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:k.some(I=>I.path===o)?o:"",disabled:!!j,"aria-busy":Y,onChange:I=>{I.target.value&&Hr(I.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),k.map(I=>d.jsxs("option",{value:I.path,children:[I.name,I.indexed?` (${I.counts.nodes})`:""]},I.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:I=>{const G=I.target.value;s(G),G.trim()!==_t.current&&(_t.current="",Ft(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>$e(!0),children:d.jsx(jp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(_p,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:I=>nn(I,c),placeholder:"base",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(_p,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:I=>nn(a,I),placeholder:"head",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:he?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":he,onClick:()=>{const I=!he;pe(I),localStorage.setItem("loadpath.dirty",I?"1":"0")},children:he?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:Je?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":Je,onClick:()=>{const I=!Je;An(I),localStorage.setItem("loadpath.watch",I?"1":"0")},children:Je?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.what_if?"what-if · ":"",p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!j,onClick:xi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!j,onClick:()=>Br(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!j,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[P?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:P}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,te?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:te}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>q(""),"aria-label":"Dismiss",children:"×"})]}):null,((co=p==null?void 0:p.index)!=null&&co.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((fo=p==null?void 0:p.index)==null?void 0:fo.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Si=p==null?void 0:p.index)==null?void 0:Si.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(ho=p==null?void 0:p.workspace)!=null&&ho.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,p!=null&&p.what_if?d.jsxs("div",{className:"banner whatif","data-testid":"whatif-banner",children:[d.jsxs("span",{children:["Hypothetical walk from"," ",d.jsx("strong",{children:((po=p.node)==null?void 0:po.name)||"this node"}),". Loadpath ignored Base/Head and asked which sinks would feel this node change — not a filter of the current map."]}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-exit-whatif",onClick:Vn,children:x?"Back to git range":"Back to architecture"})]}):null,Y?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:j||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":Y||ne,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(IN,{review:p,findings:Fe,aiNote:me,busy:!!j,tourIndex:Z,onTour:se,onAskAi:ao,onCopy:Ve,onPost:so,onSelect:Ye,onOpenFile:_i,onExport:Yr,history:Ot,diff:io,onReopen:fr,onWaiver:(I,G)=>{o.trim()&&Pe.addWaiver(o,I,G||void 0,"from review").then(ce=>{or(ce),q(`Waived ${I} in loadpath.yml`)})}}):zr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Xu,{nodes:p.nodes,edges:p.edges,onWhatIf:dr,focusPath:(go=p.read_order[Z])==null?void 0:go.path,...hr}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(RN,{architecture:m,busy:!!j,onReindex:()=>Br(!1),onReview:jn,onSelect:Ye,config:vi,health:$r,onSaveConfig:I=>{Pe.saveConfig(o,I).then(G=>{or(G),q("Wrote loadpath.yml")})},onWaiver:(I,G,ce)=>{Pe.addWaiver(o,I,G,ce).then(je=>{or(je),q(`Waived ${I}`)})}}):Y?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(ne||m!=null&&m.graph_pending)&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(ki=m==null?void 0:m.counts)!=null&&ki.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Xu,{nodes:m.nodes,edges:m.edges,onWhatIf:dr,...hr,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":E==="review","data-testid":"graph-mode-review",className:E==="review"?"active":"",onClick:()=>N("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":E==="architecture","data-testid":"graph-mode-architecture",className:E==="architecture"?"active":"",onClick:()=>N("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:gt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":gt,onClick:()=>{const I=!gt;mt(I),localStorage.setItem("loadpath.testOverlay",I?"1":"0")},children:"Tests"})]}),En.length?d.jsx(Xu,{nodes:En,edges:uo,onWhatIf:dr,...hr}):ne||m!=null&&m.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:A,onChange:I=>Fr(I.target.value,F,oe),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:M.length?"Search your repos":"owner/repo",value:F,onChange:I=>Fr(A,I.target.value,oe),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:M.map(I=>d.jsxs("option",{value:I.slug,children:[I.private?"private":"public",I.local_path?" · local":""]},I.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!j||!oo(A),onClick:()=>{It(A)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!j,onClick:Vr,children:"List PRs"})]}),M.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[M.length," ",A," repositor",M.length===1?"y":"ies",A==="github"&&C.github_user?` · @${String(C.github_user)}`:"",A==="gitlab"&&C.gitlab_user?` · @${String(C.gitlab_user)}`:"",A==="bitbucket"&&C.bitbucket_user?` · ${String(C.bitbucket_user)}`:""]}):null,W.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):W.map(I=>{var G;return d.jsxs("article",{className:"pr","data-testid":`pr-${I.number}`,children:[d.jsxs("h3",{children:["#",I.number," ",I.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${I.draft?"":"open"}`,children:I.draft?"draft":I.state}),d.jsx("span",{children:I.author}),d.jsxs("span",{children:[I.source_branch," → ",I.target_branch]}),I.loadpath?d.jsxs("span",{className:`chip ${I.loadpath.level||""}`,"data-testid":`pr-loadpath-${I.number}`,children:[((G=I.loadpath.level)==null?void 0:G.toUpperCase())||"REVIEWED",I.loadpath.contract_break&&I.loadpath.contract_break!=="none"?` · ${I.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:I.url,target:"_blank",rel:"noreferrer",children:["Open on ",I.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${I.number}`,onClick:()=>void bt(I),children:"Review this PR"})]})]},`${I.provider}-${I.number}`)})]}),t==="settings"&&Ne&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Et,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Hl.map(I=>d.jsxs("button",{type:"button","data-theme":I.id,className:ve===I.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${I.id}`,onClick:()=>Sn(I.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:I.label}),d.jsx("div",{className:"group",children:I.group})]},I.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:ym(),onChange:I=>gN(I.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:C.github_token_set?C.github_user?`Signed in as @${String(C.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void Wr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!ct||!C.github_oauth_ready,onClick:()=>void wi(),children:ct?"Waiting for GitHub…":"Sign in with GitHub"})})]}),ct?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:ct.user_code})," at GitHub if the browser did not fill it in."]}):null,C.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(C.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(C.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:C.gitlab_token_set?C.gitlab_user?`Signed in as @${String(C.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void Wr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Fn||!C.gitlab_oauth_ready,onClick:()=>void lo(),children:Fn?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(C.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(C.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:C.bitbucket_token_set?C.bitbucket_user?`Signed in as ${String(C.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void Wr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:On||!C.bitbucket_oauth_ready,onClick:()=>void cr(),children:On?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),C.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(C.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(C.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((Xr=C.ai)==null?void 0:Xr.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((rn=C.ai)==null?void 0:rn.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((on=C.ai)==null?void 0:on.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(u0,{open:st,actions:Gn,onClose:()=>lt(!1)}),Te?d.jsx(SN,{initialPath:o,onClose:()=>$e(!1),onSelect:I=>{if(dt.current){w("Wait for the current job to finish before switching workspace.");return}$e(!1),Hr(I)}}):null]})}function IN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:v,onOpenFile:x,onExport:y,history:m,diff:_,onReopen:k,onWaiver:b}){var N,P,w,j,$,z,B,Y,Q,ne,ee,te,q,C,V,W,U;const E=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),E.length?d.jsx("ul",{className:"reasons",children:E.map(M=>d.jsx("li",{children:M},M))}):null,t.what_if?d.jsx("span",{className:"chip whatif","data-testid":"whatif-chip",children:"what-if"}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Qo(M)},M)),(N=t.contract_break)!=null&&N.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>b(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(P=t.workspace)!=null&&P.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>x(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(_m,{cards:t.deepening}),(j=(w=t.contract_break)==null?void 0:w.reasons)!=null&&j.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),(z=($=t.contract_break.sides)==null?void 0:$.rows)!=null&&z.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(B=t.auth)!=null&&B.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(Y=t.suggested_tests)==null?void 0:Y.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(Q=t.trend)!=null&&Q.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",Qu(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),m.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:m.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,m.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>k(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?Qu(M.created_at):""})]},M.id))]}):null,(ee=(ne=t.evolution)==null?void 0:ne.notes)!=null&&ee.length||(q=(te=t.evolution)==null?void 0:te.hotspots)!=null&&q.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((C=t.evolution)==null?void 0:C.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((V=t.evolution)==null?void 0:V.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:y,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",disabled:s||!!t.what_if,title:t.what_if?"Hypothetical walks are not posted to a pull request":void 0,onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(W=t.codeowners_reviewers)!=null&&W.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function RN({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var x;const v=t.findings.filter(y=>!y.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${Qu(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(y=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y.name})," — ",(y.django_apps||[]).join(", ")||"no apps"," ·"," ",(y.owners||[]).join(", ")||"unowned"]},y.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(y=>d.jsx("div",{className:"muted",children:y},y))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:v.length})]}),v.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):v.map(y=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>y.node_id&&a(y.node_id),children:[d.jsx("span",{className:`chip ${y.severity}`,children:y.severity}),y.message]})},y.rule+y.message))]}),d.jsx(_m,{cards:t.deepening}),(x=c==null?void 0:c.points)!=null&&x.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(y=>d.jsx("i",{className:y.level||"",title:`${y.level} · ${y.findings} findings`,style:{height:`${8+Math.min(24,(y.findings||0)*4)}px`}},y.id||y.created_at))}),Object.entries(c.contexts).map(([y,m])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y})," — last ",((_=m[m.length-1])==null?void 0:_.findings)??0," findings"]},y)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(c0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((y,m)=>m[1]-y[1]).slice(0,12).map(([y,m])=>d.jsxs("tr",{children:[d.jsx("td",{children:ro(y)}),d.jsx("td",{children:m})]},y))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function _m({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:d0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}wm(xm());s0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(PN,{})}));export{Hk as L,AN as a,TN as c,d as j,LN as l,L as r,ro as t}; diff --git a/src/loadpath/static/index.html b/src/loadpath/static/index.html index 880ba77..cdcb187 100644 --- a/src/loadpath/static/index.html +++ b/src/loadpath/static/index.html @@ -17,7 +17,7 @@ - + diff --git a/tests/e2e/test_ui_flows.py b/tests/e2e/test_ui_flows.py index d44096d..a3f5b60 100644 --- a/tests/e2e/test_ui_flows.py +++ b/tests/e2e/test_ui_flows.py @@ -228,6 +228,67 @@ def on_route(route): page.screenshot(path="/opt/cursor/artifacts/index_complete_architecture.png") +@pytest.mark.playwright +def test_ui_index_progress_bar_does_not_jump_backwards(live_app, browser_page): + base_url, repo = live_app + page = browser_page + page.goto(base_url, wait_until="networkidle") + _wait_fonts(page) + page.get_by_test_id("repo-path").fill(str(repo)) + sequence = [ + {"phase": "scan", "done": 50, "total": 100, "percent": 10, "message": "Hashed 50/100 files"}, + {"phase": "scan", "done": 100, "total": 100, "percent": 20, "message": "Hashed 100/100 files"}, + {"phase": "extract", "done": 0, "total": 80, "percent": 20, "message": "Extracting 80 of 100 files"}, + {"phase": "extract", "done": 40, "total": 80, "percent": 54, "message": "Extracted foo.py (40/80)"}, + {"phase": "extract", "done": 80, "total": 80, "percent": 88, "message": "Extracted bar.py (80/80)"}, + {"phase": "boot", "done": 0, "total": 1, "percent": 88, "message": "Booting Django models (optional)"}, + {"phase": "stitch", "done": 0, "total": 1, "percent": 94, "message": "Stitching contracts"}, + {"phase": "done", "done": 5, "total": 100, "percent": 100, "message": "Indexed 5 files"}, + ] + page.evaluate( + """(sequence) => { + let n = 0; + const orig = window.fetch; + window.fetch = async (input, init) => { + const url = String(typeof input === "string" ? input : input.url); + const method = (init && init.method) || "GET"; + if (url.includes("/api/index/progress")) { + const body = sequence[Math.min(n, sequence.length - 1)]; + n += 1; + return new Response(JSON.stringify(body), { + headers: { "Content-Type": "application/json" }, + }); + } + if (method === "POST" && url.includes("/api/index") && !url.includes("progress")) { + await new Promise((resolve) => setTimeout(resolve, 2200)); + return orig.call(window, input, init); + } + return orig.call(window, input, init); + }; + }""", + sequence, + ) + page.get_by_test_id("btn-index").click() + page.get_by_test_id("progress").wait_for(timeout=5_000) + samples: list[int] = [] + deadline = time.time() + 2.0 + while time.time() < deadline: + bar = page.get_by_test_id("progress") + if bar.count(): + raw = bar.get_attribute("aria-valuenow") + if raw is not None and raw != "": + samples.append(int(raw)) + page.wait_for_timeout(150) + assert samples, "expected determinate progress samples" + assert samples[-1] >= samples[0] + for earlier, later in zip(samples, samples[1:]): + assert later >= earlier, samples + assert max(samples) >= 20 + assert min(samples) < 100 + # Extract starting at 0/80 must not rewind the bar to empty. + assert not any(samples[i] >= 15 and samples[i + 1] < 10 for i in range(len(samples) - 1)) + + @pytest.mark.playwright def test_ui_settings_preserve_model_and_theme(live_app, browser_page): base_url, _repo = live_app diff --git a/tests/unit/test_index_progress.py b/tests/unit/test_index_progress.py index 3071483..c412b35 100644 --- a/tests/unit/test_index_progress.py +++ b/tests/unit/test_index_progress.py @@ -4,6 +4,7 @@ from fastapi.testclient import TestClient +from loadpath.progress import begin_progress, overall_percent, progress_callback, progress_key, read_progress from loadpath.index import index_repo from loadpath.server.app import create_app from tests.conftest import FIXTURE_ROOT as FIXTURE, prepare_review_repo @@ -89,6 +90,58 @@ def test_api_index_progress_idle_then_done(tmp_path, monkeypatch): assert body["phase"] == "done" assert body["message"] assert "elapsed_ms" in body + assert body["percent"] == 100 + + +def test_overall_percent_never_goes_backwards_across_phases(): + floor = 0 + percents = [] + events = [ + {"phase": "scan", "done": 0, "total": 0}, + {"phase": "scan", "done": 50, "total": 100}, + {"phase": "scan", "done": 100, "total": 100}, + {"phase": "extract", "done": 0, "total": 80}, + {"phase": "extract", "done": 40, "total": 80}, + {"phase": "extract", "done": 80, "total": 80}, + {"phase": "boot", "done": 0, "total": 1}, + {"phase": "stitch", "done": 0, "total": 1}, + {"phase": "done", "done": 5, "total": 100}, + ] + for event in events: + floor = overall_percent(event, floor=floor) + percents.append(floor) + assert percents == sorted(percents) + assert percents[0] == 0 + assert percents[2] == percents[3] == 20 + assert percents[-1] == 100 + naive_extract_start = 0 + assert percents[3] > naive_extract_start + + +def test_recorded_index_percent_is_monotonic(tmp_path): + repo = prepare_review_repo(tmp_path) + begin_progress(repo) + percents: list[int] = [] + + inner = progress_callback(repo) + + def _cb(event): + inner(event) + percents.append(int(read_progress(repo)["percent"])) + + store = index_repo(repo, incremental=False, workers=1, progress=_cb) + store.close() + assert percents + assert percents == sorted(percents) + assert percents[-1] == 100 + assert percents[0] < 50 + leftover = read_progress(repo) + begin_progress(repo) + reset = read_progress(repo) + assert leftover["percent"] == 100 + assert reset["percent"] == 0 + assert reset["phase"] == "scan" + assert progress_key(repo) == reset["repo_path"] def test_default_workers_stays_sequential_on_small_trees(monkeypatch): diff --git a/ui/src/App.tsx b/ui/src/App.tsx index 95de1f4..597c179 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -8,6 +8,7 @@ import { ImpactGraph } from "./ImpactGraph"; import { openInEditor, persistEditorPreference, editorPreference } from "./openEditor"; import { RefCombobox } from "./RefCombobox"; import { RepoExplorer } from "./RepoExplorer"; +import { LIVE_INDEX_PHASES, progressPercent } from "./indexProgress"; import { THEMES, applyTheme, readTheme, type ThemeId } from "./themes"; import type { ArchitectureHealth, @@ -15,7 +16,6 @@ import type { DeepeningCandidate, GitRefs, IndexedRepo, - IndexProgress, LoadpathConfigDoc, PullRequest, RemoteRepo, @@ -35,12 +35,6 @@ const TABS: { id: Tab; label: string; testId: string; shortcut: string; icon: ty { id: "settings", label: "Settings", testId: "tab-settings", shortcut: "5", icon: IconSettings }, ]; -function progressPercent(p: IndexProgress): number | null { - const total = p.total || 0; - if (total <= 0) return null; - return Math.min(100, Math.round((100 * (p.done || 0)) / total)); -} - function openOAuthUrl(url: string, host: string, pathPrefix: string) { let parsed: URL; try { @@ -127,13 +121,23 @@ export function App() { setBusy(msg); }; const watchIndex = (repoPath: string) => { + let peak = 0; + let seenLive = false; + setIndexPct(0); const tick = () => { api .indexProgress(repoPath) .then((p) => { if (!busyRef.current) return; if (p.phase && p.phase !== "idle" && p.message) markBusy(p.message); - setIndexPct(p.phase && p.phase !== "idle" ? progressPercent(p) : null); + const live = LIVE_INDEX_PHASES.has(p.phase); + if (live) seenLive = true; + else if (!seenLive) return; + const raw = progressPercent(p); + if (raw == null) return; + if (p.phase === "scan" && !(p.done || 0)) peak = raw; + else peak = Math.max(peak, raw); + setIndexPct(peak); }) .catch(() => undefined); }; @@ -1054,6 +1058,9 @@ export function App() { role="status" aria-live="polite" aria-busy="true" + aria-valuemin={indexPct != null ? 0 : undefined} + aria-valuemax={indexPct != null ? 100 : undefined} + aria-valuenow={indexPct ?? undefined} data-testid="progress" > diff --git a/ui/src/indexProgress.test.ts b/ui/src/indexProgress.test.ts new file mode 100644 index 0000000..d3e1fa5 --- /dev/null +++ b/ui/src/indexProgress.test.ts @@ -0,0 +1,50 @@ +import { describe, expect, it } from "vitest"; +import { LIVE_INDEX_PHASES, phasePercent, progressPercent } from "./indexProgress"; + +describe("phasePercent", () => { + it("maps each phase onto one 0–100 scale so extract does not restart at 0", () => { + const scanHalf = phasePercent({ phase: "scan", done: 50, total: 100 }); + const scanDone = phasePercent({ phase: "scan", done: 100, total: 100 }); + const extractStart = phasePercent({ phase: "extract", done: 0, total: 80 }); + const extractHalf = phasePercent({ phase: "extract", done: 40, total: 80 }); + const extractDone = phasePercent({ phase: "extract", done: 80, total: 80 }); + const boot = phasePercent({ phase: "boot", done: 0, total: 1 }); + const stitch = phasePercent({ phase: "stitch", done: 0, total: 1 }); + const done = phasePercent({ phase: "done", done: 5, total: 100 }); + + expect(scanHalf).toBe(10); + expect(scanDone).toBe(20); + expect(extractStart).toBe(20); + expect(extractHalf).toBe(54); + expect(extractDone).toBe(88); + expect(boot).toBe(88); + expect(stitch).toBe(94); + expect(done).toBe(100); + + const seq = [scanHalf, scanDone, extractStart, extractHalf, extractDone, boot, stitch, done]; + for (let i = 1; i < seq.length; i++) { + expect(seq[i]).toBeGreaterThanOrEqual(seq[i - 1]!); + } + }); + + it("treats an unknown total as the start of the current phase, not 100%", () => { + expect(phasePercent({ phase: "scan", done: 0, total: 0 })).toBe(0); + expect(phasePercent({ phase: "extract", done: 0, total: 0 })).toBe(20); + }); + + it("returns null while idle", () => { + expect(phasePercent({ phase: "idle", done: 0, total: 0 })).toBeNull(); + expect(progressPercent({ phase: "idle" })).toBeNull(); + }); + + it("prefers the server percent when present", () => { + expect(progressPercent({ phase: "extract", done: 0, total: 80, percent: 41 })).toBe(41); + }); +}); + +describe("LIVE_INDEX_PHASES", () => { + it("does not treat a leftover done payload as an in-flight run", () => { + expect(LIVE_INDEX_PHASES.has("done")).toBe(false); + expect(LIVE_INDEX_PHASES.has("scan")).toBe(true); + }); +}); diff --git a/ui/src/indexProgress.ts b/ui/src/indexProgress.ts new file mode 100644 index 0000000..a3e6aeb --- /dev/null +++ b/ui/src/indexProgress.ts @@ -0,0 +1,33 @@ +import type { IndexProgress } from "./types"; + +/** Overall bar spans. Keep in sync with `loadpath.progress.PHASE_SPANS`. */ +export const PHASE_SPANS: Record = { + scan: { start: 0, end: 20 }, + extract: { start: 20, end: 88 }, + boot: { start: 88, end: 94 }, + stitch: { start: 94, end: 99 }, + skipped: { start: 100, end: 100 }, + done: { start: 100, end: 100 }, +}; + +export const LIVE_INDEX_PHASES = new Set(["scan", "extract", "boot", "stitch"]); + +export function phasePercent(p: Pick): number | null { + const phase = p.phase || ""; + if (!phase || phase === "idle") return null; + const span = PHASE_SPANS[phase]; + if (!span) return null; + if (span.start === span.end) return span.end; + const total = p.total || 0; + if (total <= 0) return span.start; + const ratio = Math.min(1, Math.max(0, (p.done || 0) / total)); + return Math.round(span.start + (span.end - span.start) * ratio); +} + +export function progressPercent(p: IndexProgress): number | null { + if (!p.phase || p.phase === "idle") return null; + if (typeof p.percent === "number" && Number.isFinite(p.percent)) { + return Math.max(0, Math.min(100, Math.round(p.percent))); + } + return phasePercent(p); +} diff --git a/ui/src/types.ts b/ui/src/types.ts index 7b0b0b5..8247b8e 100644 --- a/ui/src/types.ts +++ b/ui/src/types.ts @@ -173,6 +173,7 @@ export type IndexProgress = { phase: string; done?: number; total?: number; + percent?: number; current?: string; workers?: number; skipped?: number; From bb2b251522fe0cd052906048810ff497f5a507e4 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 16 Aug 2026 00:21:27 +0000 Subject: [PATCH 08/16] Stagger overlapping graph edges so parallel routes stay distinct. Smooth-step edges all bent at the same midpoint, so vertical segments stacked into one line. Overlapping edges in a column gap now get different bend positions. Co-authored-by: zord.lack.net --- ...D_cvtTgT.js => LayeredGraph3D-C3jIpw-r.js} | 2 +- src/loadpath/static/assets/index-B1t9Uvme.js | 62 --------------- src/loadpath/static/assets/index-CUH75ocM.js | 62 +++++++++++++++ src/loadpath/static/index.html | 2 +- ui/src/ImpactGraph.test.ts | 2 + ui/src/ImpactGraph.tsx | 3 + ui/src/graphEdges.test.ts | 53 +++++++++++++ ui/src/graphEdges.ts | 76 +++++++++++++++++++ 8 files changed, 198 insertions(+), 64 deletions(-) rename src/loadpath/static/assets/{LayeredGraph3D-D_cvtTgT.js => LayeredGraph3D-C3jIpw-r.js} (99%) delete mode 100644 src/loadpath/static/assets/index-B1t9Uvme.js create mode 100644 src/loadpath/static/assets/index-CUH75ocM.js create mode 100644 ui/src/graphEdges.test.ts create mode 100644 ui/src/graphEdges.ts diff --git a/src/loadpath/static/assets/LayeredGraph3D-D_cvtTgT.js b/src/loadpath/static/assets/LayeredGraph3D-C3jIpw-r.js similarity index 99% rename from src/loadpath/static/assets/LayeredGraph3D-D_cvtTgT.js rename to src/loadpath/static/assets/LayeredGraph3D-C3jIpw-r.js index 379607c..6192bdb 100644 --- a/src/loadpath/static/assets/LayeredGraph3D-D_cvtTgT.js +++ b/src/loadpath/static/assets/LayeredGraph3D-C3jIpw-r.js @@ -1,4 +1,4 @@ -import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-B1t9Uvme.js";/** +import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-CUH75ocM.js";/** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT diff --git a/src/loadpath/static/assets/index-B1t9Uvme.js b/src/loadpath/static/assets/index-B1t9Uvme.js deleted file mode 100644 index ea04700..0000000 --- a/src/loadpath/static/assets/index-B1t9Uvme.js +++ /dev/null @@ -1,62 +0,0 @@ -(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function Sp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Pu={exports:{}},Wo={},Iu={exports:{}},Re={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var qf;function Zy(){if(qf)return Re;qf=1;var t=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),v=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),y=Symbol.iterator;function m(R){return R===null||typeof R!="object"?null:(R=y&&R[y]||R["@@iterator"],typeof R=="function"?R:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,b={};function E(R,A,ie){this.props=R,this.context=A,this.refs=b,this.updater=ie||_}E.prototype.isReactComponent={},E.prototype.setState=function(R,A){if(typeof R!="object"&&typeof R!="function"&&R!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,R,A,"setState")},E.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function N(){}N.prototype=E.prototype;function P(R,A,ie){this.props=R,this.context=A,this.refs=b,this.updater=ie||_}var w=P.prototype=new N;w.constructor=P,k(w,E.prototype),w.isPureReactComponent=!0;var j=Array.isArray,$=Object.prototype.hasOwnProperty,z={current:null},B={key:!0,ref:!0,__self:!0,__source:!0};function Y(R,A,ie){var oe,fe={},he=null,pe=null;if(A!=null)for(oe in A.ref!==void 0&&(pe=A.ref),A.key!==void 0&&(he=""+A.key),A)$.call(A,oe)&&!B.hasOwnProperty(oe)&&(fe[oe]=A[oe]);var Z=arguments.length-2;if(Z===1)fe.children=ie;else if(1>>1,A=M[R];if(0>>1;Ra(fe,F))hea(pe,fe)?(M[R]=pe,M[he]=F,R=he):(M[R]=fe,M[oe]=F,R=oe);else if(hea(pe,F))M[R]=pe,M[he]=F,R=he;else break e}}return D}function a(M,D){var F=M.sortIndex-D.sortIndex;return F!==0?F:M.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,h=c.now();t.unstable_now=function(){return c.now()-h}}var p=[],v=[],x=1,y=null,m=3,_=!1,k=!1,b=!1,E=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,P=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(M){for(var D=o(v);D!==null;){if(D.callback===null)s(v);else if(D.startTime<=M)s(v),D.sortIndex=D.expirationTime,r(p,D);else break;D=o(v)}}function j(M){if(b=!1,w(M),!k)if(o(p)!==null)k=!0,W($);else{var D=o(v);D!==null&&U(j,D.startTime-M)}}function $(M,D){k=!1,b&&(b=!1,N(Y),Y=-1),_=!0;var F=m;try{for(w(D),y=o(p);y!==null&&(!(y.expirationTime>D)||M&&!ee());){var R=y.callback;if(typeof R=="function"){y.callback=null,m=y.priorityLevel;var A=R(y.expirationTime<=D);D=t.unstable_now(),typeof A=="function"?y.callback=A:y===o(p)&&s(p),w(D)}else s(p);y=o(p)}if(y!==null)var ie=!0;else{var oe=o(v);oe!==null&&U(j,oe.startTime-D),ie=!1}return ie}finally{y=null,m=F,_=!1}}var z=!1,B=null,Y=-1,Q=5,ne=-1;function ee(){return!(t.unstable_now()-neM||125R?(M.sortIndex=F,r(v,M),o(p)===null&&M===o(v)&&(b?(N(Y),Y=-1):b=!0,U(j,F-R))):(M.sortIndex=A,r(p,M),k||_||(k=!0,W($))),M},t.unstable_shouldYield=ee,t.unstable_wrapCallback=function(M){var D=m;return function(){var F=m;m=D;try{return M.apply(this,arguments)}finally{m=F}}}})(Lu)),Lu}var eh;function r0(){return eh||(eh=1,Tu.exports=n0()),Tu.exports}/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var th;function i0(){if(th)return zt;th=1;var t=as(),r=r0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,v=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,x={},y={};function m(e){return p.call(y,e)?!0:p.call(x,e)?!1:v.test(e)?y[e]=!0:(x[e]=!0,!1)}function _(e,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function k(e,n,i,l){if(n===null||typeof n>"u"||_(e,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function b(e,n,i,l,f,g,S){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=f,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=g,this.removeEmptyString=S}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){E[e]=new b(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];E[n]=new b(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){E[e]=new b(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){E[e]=new b(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){E[e]=new b(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){E[e]=new b(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){E[e]=new b(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){E[e]=new b(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){E[e]=new b(e,5,!1,e.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function P(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(N,P);E[n]=new b(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(N,P);E[n]=new b(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(N,P);E[n]=new b(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){E[e]=new b(e,1,!1,e.toLowerCase(),null,!1,!1)}),E.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){E[e]=new b(e,1,!1,e.toLowerCase(),null,!0,!0)});function w(e,n,i,l){var f=E.hasOwnProperty(n)?E[n]:null;(f!==null?f.type!==0:l||!(2T||f[S]!==g[T]){var O=` -`+f[S].replace(" at new "," at ");return e.displayName&&O.includes("")&&(O=O.replace("",e.displayName)),O}while(1<=S&&0<=T);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?A(e):""}function fe(e){switch(e.tag){case 5:return A(e.type);case 16:return A("Lazy");case 13:return A("Suspense");case 19:return A("SuspenseList");case 0:case 2:case 15:return e=oe(e.type,!1),e;case 11:return e=oe(e.type.render,!1),e;case 1:return e=oe(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case B:return"Fragment";case z:return"Portal";case Q:return"Profiler";case Y:return"StrictMode";case q:return"Suspense";case C:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ee:return(e.displayName||"Context")+".Consumer";case ne:return(e._context.displayName||"Context")+".Provider";case te:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case W:n=e._payload,e=e._init;try{return he(e(n))}catch{}}return null}function pe(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===Y?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Z(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=se(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function ke(e){e._valueTracker||(e._valueTracker=me(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=se(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function re(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return F({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Z(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Te(e,n){n=n.checked,n!=null&&w(e,"checked",n,!1)}function $e(e,n){Te(e,n);var i=Z(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?lt(e,n.type,i):n.hasOwnProperty("defaultValue")&<(e,n.type,Z(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function st(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function lt(e,n,i){(n!=="number"||re(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var at=Array.isArray;function Ye(e,n,i,l){if(e=e.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=Je.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ot(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var xn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},io=["Webkit","ms","Moz","O"];Object.keys(xn).forEach(function(e){io.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),xn[n]=xn[e]})});function $n(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||xn.hasOwnProperty(e)&&xn[e]?(""+n).trim():n+"px"}function vi(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=$n(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,f):e[i]=f}}var or=F({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function $r(e,n){if(n){if(or[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function zn(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var zr=null;function sr(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var lr=null,Ft=null,ct=null;function Dn(e){if(e=Mo(e)){if(typeof lr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=Ms(n),lr(e.stateNode,e.type,n))}}function On(e){Ft?ct?ct.push(e):ct=[e]:Ft=e}function wn(){if(Ft){var e=Ft,n=ct;if(ct=Ft=null,Dn(e),n)for(e=0;e>>=0,e===0?32:31-(ao(e)/Ur|0)|0}var Wn=64,Un=4194304;function bn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Bt(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,f=e.suspendedLanes,g=e.pingedLanes,S=i&268435455;if(S!==0){var T=S&~f;T!==0?l=bn(T):(g&=S,g!==0&&(l=bn(g)))}else S=i&~f,S!==0?l=bn(S):g!==0&&(l=bn(g));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,g=n&-n,f>=g||f===16&&(g&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function En(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Et(n),e[n]=i}function uo(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=wo),Hc=" ",Bc=!1;function Vc(e,n){switch(e){case"keyup":return Ym.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var bi=!1;function qm(e,n){switch(e){case"compositionend":return Wc(n);case"keypress":return n.which!==32?null:(Bc=!0,Hc);case"textInput":return e=n.data,e===Hc&&Bc?null:e;default:return null}}function Km(e,n){if(bi)return e==="compositionend"||!ca&&Vc(e,n)?(e=Ac(),vs=ia=gr=null,bi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Qc(i)}}function Jc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Jc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function ed(){for(var e=window,n=re();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=re(e.document)}return n}function ha(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function oy(e){var n=ed(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Jc(i.ownerDocument.documentElement,i)){if(l!==null&&ha(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var f=i.textContent.length,g=Math.min(l.start,f);l=l.end===void 0?g:Math.min(l.end,f),!e.extend&&g>l&&(f=l,l=g,g=f),f=Zc(i,g);var S=Zc(i,l);f&&S&&(e.rangeCount!==1||e.anchorNode!==f.node||e.anchorOffset!==f.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),e.removeAllRanges(),g>l?(e.addRange(n),e.extend(S.node,S.offset)):(n.setEnd(S.node,S.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,Ei=null,pa=null,No=null,ga=!1;function td(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;ga||Ei==null||Ei!==re(l)||(l=Ei,"selectionStart"in l&&ha(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),No&&ko(No,l)||(No=l,l=bs(pa,"onSelect"),0Ri||(e.current=Ea[Ri],Ea[Ri]=null,Ri--)}function Be(e,n){Ri++,Ea[Ri]=e.current,e.current=n}var xr={},St=vr(xr),Rt=vr(!1),Qr=xr;function Ti(e,n){var i=e.type.contextTypes;if(!i)return xr;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in i)f[g]=n[g];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=f),f}function Tt(e){return e=e.childContextTypes,e!=null}function Ps(){Ue(Rt),Ue(St)}function md(e,n,i){if(St.current!==xr)throw Error(o(168));Be(St,n),Be(Rt,i)}function yd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,pe(e)||"Unknown",f));return F({},i,l)}function Is(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||xr,Qr=St.current,Be(St,e),Be(Rt,Rt.current),!0}function vd(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=yd(e,n,Qr),l.__reactInternalMemoizedMergedChildContext=e,Ue(Rt),Ue(St),Be(St,e)):Ue(Rt),Be(Rt,i)}var qn=null,Rs=!1,Ca=!1;function xd(e){qn===null?qn=[e]:qn.push(e)}function yy(e){Rs=!0,xd(e)}function wr(){if(!Ca&&qn!==null){Ca=!0;var e=0,n=Fe;try{var i=qn;for(Fe=1;e>=S,f-=S,Kn=1<<32-Et(n)+f|i<Ce?(pt=Ee,Ee=null):pt=Ee.sibling;var Oe=le(X,Ee,K[Ce],de);if(Oe===null){Ee===null&&(Ee=pt);break}e&&Ee&&Oe.alternate===null&&n(X,Ee),H=g(Oe,H,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe,Ee=pt}if(Ce===K.length)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;CeCe?(pt=Ee,Ee=null):pt=Ee.sibling;var Mr=le(X,Ee,Oe.value,de);if(Mr===null){Ee===null&&(Ee=pt);break}e&&Ee&&Mr.alternate===null&&n(X,Ee),H=g(Mr,H,Ce),be===null?_e=Mr:be.sibling=Mr,be=Mr,Ee=pt}if(Oe.done)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;!Oe.done;Ce++,Oe=K.next())Oe=ue(X,Oe.value,de),Oe!==null&&(H=g(Oe,H,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return Xe&&Jr(X,Ce),_e}for(Ee=l(X,Ee);!Oe.done;Ce++,Oe=K.next())Oe=ge(Ee,X,Ce,Oe.value,de),Oe!==null&&(e&&Oe.alternate!==null&&Ee.delete(Oe.key===null?Ce:Oe.key),H=g(Oe,H,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return e&&Ee.forEach(function(Qy){return n(X,Qy)}),Xe&&Jr(X,Ce),_e}function et(X,H,K,de){if(typeof K=="object"&&K!==null&&K.type===B&&K.key===null&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case $:e:{for(var _e=K.key,be=H;be!==null;){if(be.key===_e){if(_e=K.type,_e===B){if(be.tag===7){i(X,be.sibling),H=f(be,K.props.children),H.return=X,X=H;break e}}else if(be.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===W&&jd(_e)===be.type){i(X,be.sibling),H=f(be,K.props),H.ref=Po(X,be,K),H.return=X,X=H;break e}i(X,be);break}else n(X,be);be=be.sibling}K.type===B?(H=li(K.props.children,X.mode,de,K.key),H.return=X,X=H):(de=sl(K.type,K.key,K.props,null,X.mode,de),de.ref=Po(X,H,K),de.return=X,X=de)}return S(X);case z:e:{for(be=K.key;H!==null;){if(H.key===be)if(H.tag===4&&H.stateNode.containerInfo===K.containerInfo&&H.stateNode.implementation===K.implementation){i(X,H.sibling),H=f(H,K.children||[]),H.return=X,X=H;break e}else{i(X,H);break}else n(X,H);H=H.sibling}H=ju(K,X.mode,de),H.return=X,X=H}return S(X);case W:return be=K._init,et(X,H,be(K._payload),de)}if(at(K))return xe(X,H,K,de);if(D(K))return we(X,H,K,de);$s(X,K)}return typeof K=="string"&&K!==""||typeof K=="number"?(K=""+K,H!==null&&H.tag===6?(i(X,H.sibling),H=f(H,K),H.return=X,X=H):(i(X,H),H=Nu(K,X.mode,de),H.return=X,X=H),S(X)):i(X,H)}return et}var zi=bd(!0),Ed=bd(!1),zs=vr(null),Ds=null,Di=null,La=null;function Aa(){La=Di=Ds=null}function $a(e){var n=zs.current;Ue(zs),e._currentValue=n}function za(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function Oi(e,n){Ds=e,La=Di=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Lt=!0),e.firstContext=null)}function Zt(e){var n=e._currentValue;if(La!==e)if(e={context:e,memoizedValue:n,next:null},Di===null){if(Ds===null)throw Error(o(308));Di=e,Ds.dependencies={lanes:0,firstContext:e}}else Di=Di.next=e;return n}var ei=null;function Da(e){ei===null?ei=[e]:ei.push(e)}function Cd(e,n,i,l){var f=n.interleaved;return f===null?(i.next=i,Da(n)):(i.next=f.next,f.next=i),n.interleaved=i,Zn(e,l)}function Zn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var _r=!1;function Oa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Md(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Jn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Sr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(ze&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,Zn(e,i)}return f=l.interleaved,f===null?(n.next=n,Da(l)):(n.next=f.next,f.next=n),l.interleaved=n,Zn(e,i)}function Os(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}function Pd(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var S={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?f=g=S:g=g.next=S,i=i.next}while(i!==null);g===null?f=g=n:g=g.next=n}else f=g=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function Fs(e,n,i,l){var f=e.updateQueue;_r=!1;var g=f.firstBaseUpdate,S=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,J=O.next;O.next=null,S===null?g=J:S.next=J,S=O;var ae=e.alternate;ae!==null&&(ae=ae.updateQueue,T=ae.lastBaseUpdate,T!==S&&(T===null?ae.firstBaseUpdate=J:T.next=J,ae.lastBaseUpdate=O))}if(g!==null){var ue=f.baseState;S=0,ae=J=O=null,T=g;do{var le=T.lane,ge=T.eventTime;if((l&le)===le){ae!==null&&(ae=ae.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var xe=e,we=T;switch(le=n,ge=i,we.tag){case 1:if(xe=we.payload,typeof xe=="function"){ue=xe.call(ge,ue,le);break e}ue=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=we.payload,le=typeof xe=="function"?xe.call(ge,ue,le):xe,le==null)break e;ue=F({},ue,le);break e;case 2:_r=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,le=f.effects,le===null?f.effects=[T]:le.push(T))}else ge={eventTime:ge,lane:le,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ae===null?(J=ae=ge,O=ue):ae=ae.next=ge,S|=le;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;le=T,T=le.next,le.next=null,f.lastBaseUpdate=le,f.shared.pending=null}}while(!0);if(ae===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=J,f.lastBaseUpdate=ae,n=f.shared.interleaved,n!==null){f=n;do S|=f.lane,f=f.next;while(f!==n)}else g===null&&(f.shared.lanes=0);ri|=S,e.lanes=S,e.memoizedState=ue}}function Id(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=Wa.transition;Wa.transition={};try{e(!1),n()}finally{Fe=i,Wa.transition=l}}function Kd(){return Jt().memoizedState}function _y(e,n,i){var l=br(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},Qd(e))Zd(n,i);else if(i=Cd(e,n,i,l),i!==null){var f=Mt();dn(i,e,l,f),Jd(i,n,l)}}function Sy(e,n,i){var l=br(e),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(Qd(e))Zd(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,T=g(S,i);if(f.hasEagerState=!0,f.eagerState=T,sn(T,S)){var O=n.interleaved;O===null?(f.next=f,Da(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=Cd(e,n,f,l),i!==null&&(f=Mt(),dn(i,e,l,f),Jd(i,n,l))}}function Qd(e){var n=e.alternate;return e===Ke||n!==null&&n===Ke}function Zd(e,n){Lo=Vs=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Jd(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}var Gs={readContext:Zt,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},ky={readContext:Zt,useCallback:function(e,n){return Pn().memoizedState=[e,n===void 0?null:n],e},useContext:Zt,useEffect:Bd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Ws(4194308,4,Ud.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Ws(4194308,4,e,n)},useInsertionEffect:function(e,n){return Ws(4,2,e,n)},useMemo:function(e,n){var i=Pn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=Pn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=_y.bind(null,Ke,e),[l.memoizedState,e]},useRef:function(e){var n=Pn();return e={current:e},n.memoizedState=e},useState:Fd,useDebugValue:Qa,useDeferredValue:function(e){return Pn().memoizedState=e},useTransition:function(){var e=Fd(!1),n=e[0];return e=wy.bind(null,e[1]),Pn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=Ke,f=Pn();if(Xe){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ht===null)throw Error(o(349));(ni&30)!==0||Ad(l,n,i)}f.memoizedState=i;var g={value:i,getSnapshot:n};return f.queue=g,Bd(zd.bind(null,l,g,e),[e]),l.flags|=2048,zo(9,$d.bind(null,l,g,i,n),void 0,null),i},useId:function(){var e=Pn(),n=ht.identifierPrefix;if(Xe){var i=Qn,l=Kn;i=(l&~(1<<32-Et(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=Ao++,0<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=S.createElement(i,{is:l.is}):(e=S.createElement(i),i==="select"&&(S=e,l.multiple?S.multiple=!0:l.size&&(S.size=l.size))):e=S.createElementNS(e,i),e[Cn]=n,e[Co]=l,wf(e,n,!1,!1),n.stateNode=e;e:{switch(S=zn(i,l),i){case"dialog":We("cancel",e),We("close",e),f=l;break;case"iframe":case"object":case"embed":We("load",e),f=l;break;case"video":case"audio":for(f=0;fWi&&(n.flags|=128,l=!0,Do(g,!1),n.lanes=4194304)}else{if(!l)if(e=Hs(S),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Do(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Xe)return Nt(n),null}else 2*Ve()-g.renderingStartTime>Wi&&i!==1073741824&&(n.flags|=128,l=!0,Do(g,!1),n.lanes=4194304);g.isBackwards?(S.sibling=n.child,n.child=S):(i=g.last,i!==null?i.sibling=S:n.child=S,g.last=S)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(Nt(n),null);case 22:case 23:return _u(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Gt&1073741824)!==0&&(Nt(n),n.subtreeFlags&6&&(n.flags|=8192)):Nt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function Iy(e,n){switch(Pa(n),n.tag){case 1:return Tt(n.type)&&Ps(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Fi(),Ue(Rt),Ue(St),Va(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Ha(n),null;case 13:if(Ue(qe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));$i()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Fi(),null;case 10:return $a(n.type._context),null;case 22:case 23:return _u(),null;case 24:return null;default:return null}}var Ks=!1,jt=!1,Ry=typeof WeakSet=="function"?WeakSet:Set,ye=null;function Bi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Ze(e,n,l)}else i.current=null}function uu(e,n,i){try{i()}catch(l){Ze(e,n,l)}}var kf=!1;function Ty(e,n){if(_a=ms,e=ed(),ha(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,g=l.focusNode;l=l.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var S=0,T=-1,O=-1,J=0,ae=0,ue=e,le=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=S+f),ue!==g||l!==0&&ue.nodeType!==3||(O=S+l),ue.nodeType===3&&(S+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)le=ue,ue=ge;for(;;){if(ue===e)break t;if(le===i&&++J===f&&(T=S),le===g&&++ae===l&&(O=S),(ge=ue.nextSibling)!==null)break;ue=le,le=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(Sa={focusedElem:e,selectionRange:i},ms=!1,ye=n;ye!==null;)if(n=ye,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ye=e;else for(;ye!==null;){n=ye;try{var xe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var we=xe.memoizedProps,et=xe.memoizedState,X=n.stateNode,H=X.getSnapshotBeforeUpdate(n.elementType===n.type?we:an(n.type,we),et);X.__reactInternalSnapshotBeforeUpdate=H}break;case 3:var K=n.stateNode.containerInfo;K.nodeType===1?K.textContent="":K.nodeType===9&&K.documentElement&&K.removeChild(K.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(de){Ze(n,n.return,de)}if(e=n.sibling,e!==null){e.return=n.return,ye=e;break}ye=n.return}return xe=kf,kf=!1,xe}function Oo(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&e)===e){var g=f.destroy;f.destroy=void 0,g!==void 0&&uu(n,i,g)}f=f.next}while(f!==l)}}function Qs(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function cu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function Nf(e){var n=e.alternate;n!==null&&(e.alternate=null,Nf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[Cn],delete n[Co],delete n[ba],delete n[gy],delete n[my])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function jf(e){return e.tag===5||e.tag===3||e.tag===4}function bf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||jf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function du(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=Cs));else if(l!==4&&(e=e.child,e!==null))for(du(e,n,i),e=e.sibling;e!==null;)du(e,n,i),e=e.sibling}function fu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(fu(e,n,i),e=e.sibling;e!==null;)fu(e,n,i),e=e.sibling}var vt=null,un=!1;function kr(e,n,i){for(i=i.child;i!==null;)Ef(e,n,i),i=i.sibling}function Ef(e,n,i){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(Vn,i)}catch{}switch(i.tag){case 5:jt||Bi(i,n);case 6:var l=vt,f=un;vt=null,kr(e,n,i),vt=l,un=f,vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):vt.removeChild(i.stateNode));break;case 18:vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?ja(e.parentNode,i):e.nodeType===1&&ja(e,i),yo(e)):ja(vt,i.stateNode));break;case 4:l=vt,f=un,vt=i.stateNode.containerInfo,un=!0,kr(e,n,i),vt=l,un=f;break;case 0:case 11:case 14:case 15:if(!jt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var g=f,S=g.destroy;g=g.tag,S!==void 0&&((g&2)!==0||(g&4)!==0)&&uu(i,n,S),f=f.next}while(f!==l)}kr(e,n,i);break;case 1:if(!jt&&(Bi(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Ze(i,n,T)}kr(e,n,i);break;case 21:kr(e,n,i);break;case 22:i.mode&1?(jt=(l=jt)||i.memoizedState!==null,kr(e,n,i),jt=l):kr(e,n,i);break;default:kr(e,n,i)}}function Cf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Ry),n.forEach(function(l){var f=By.bind(null,e,l);i.has(l)||(i.add(l),l.then(f,f))})}}function cn(e,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=S),l&=~g}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Ay(l/1960))-l,10e?16:e,jr===null)var l=!1;else{if(e=jr,jr=null,nl=0,(ze&6)!==0)throw Error(o(331));var f=ze;for(ze|=4,ye=e.current;ye!==null;){var g=ye,S=g.child;if((ye.flags&16)!==0){var T=g.deletions;if(T!==null){for(var O=0;OVe()-gu?oi(e,0):pu|=i),$t(e,n)}function Hf(e,n){n===0&&((e.mode&1)===0?n=1:(n=Un,Un<<=1,(Un&130023424)===0&&(Un=4194304)));var i=Mt();e=Zn(e,n),e!==null&&(En(e,n,i),$t(e,i))}function Hy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Hf(e,i)}function By(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Hf(e,i)}var Bf;Bf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Rt.current)Lt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Lt=!1,My(e,n,i);Lt=(e.flags&131072)!==0}else Lt=!1,Xe&&(n.flags&1048576)!==0&&wd(n,Ls,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;qs(e,n),e=n.pendingProps;var f=Ti(n,St.current);Oi(n,i),f=Ga(null,n,l,e,f,i);var g=Ya();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Tt(l)?(g=!0,Is(n)):g=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Oa(n),f.updater=Ys,n.stateNode=f,f._reactInternals=n,Ja(n,l,e,i),n=ru(null,n,l,!0,g,i)):(n.tag=0,Xe&&g&&Ma(n),Ct(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(qs(e,n),e=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=Wy(l),e=an(l,e),f){case 0:n=nu(null,n,l,e,i);break e;case 1:n=pf(null,n,l,e,i);break e;case 11:n=uf(null,n,l,e,i);break e;case 14:n=cf(null,n,l,an(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),nu(e,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),pf(e,n,l,f,i);case 3:e:{if(gf(n),e===null)throw Error(o(387));l=n.pendingProps,g=n.memoizedState,f=g.element,Md(e,n),Fs(n,l,null,i);var S=n.memoizedState;if(l=S.element,g.isDehydrated)if(g={element:l,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){f=Hi(Error(o(423)),n),n=mf(e,n,l,i,f);break e}else if(l!==f){f=Hi(Error(o(424)),n),n=mf(e,n,l,i,f);break e}else for(Ut=yr(n.stateNode.containerInfo.firstChild),Wt=n,Xe=!0,ln=null,i=Ed(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if($i(),l===f){n=er(e,n,i);break e}Ct(e,n,l,i)}n=n.child}return n;case 5:return Rd(n),e===null&&Ra(n),l=n.type,f=n.pendingProps,g=e!==null?e.memoizedProps:null,S=f.children,ka(l,f)?S=null:g!==null&&ka(l,g)&&(n.flags|=32),hf(e,n),Ct(e,n,S,i),n.child;case 6:return e===null&&Ra(n),null;case 13:return yf(e,n,i);case 4:return Fa(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=zi(n,null,l,i):Ct(e,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),uf(e,n,l,f,i);case 7:return Ct(e,n,n.pendingProps,i),n.child;case 8:return Ct(e,n,n.pendingProps.children,i),n.child;case 12:return Ct(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,g=n.memoizedProps,S=f.value,Be(zs,l._currentValue),l._currentValue=S,g!==null)if(sn(g.value,S)){if(g.children===f.children&&!Rt.current){n=er(e,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var T=g.dependencies;if(T!==null){S=g.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(g.tag===1){O=Jn(-1,i&-i),O.tag=2;var J=g.updateQueue;if(J!==null){J=J.shared;var ae=J.pending;ae===null?O.next=O:(O.next=ae.next,ae.next=O),J.pending=O}}g.lanes|=i,O=g.alternate,O!==null&&(O.lanes|=i),za(g.return,i,n),T.lanes|=i;break}O=O.next}}else if(g.tag===10)S=g.type===n.type?null:g.child;else if(g.tag===18){if(S=g.return,S===null)throw Error(o(341));S.lanes|=i,T=S.alternate,T!==null&&(T.lanes|=i),za(S,i,n),S=g.sibling}else S=g.child;if(S!==null)S.return=g;else for(S=g;S!==null;){if(S===n){S=null;break}if(g=S.sibling,g!==null){g.return=S.return,S=g;break}S=S.return}g=S}Ct(e,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,Oi(n,i),f=Zt(f),l=l(f),n.flags|=1,Ct(e,n,l,i),n.child;case 14:return l=n.type,f=an(l,n.pendingProps),f=an(l.type,f),cf(e,n,l,f,i);case 15:return df(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),qs(e,n),n.tag=1,Tt(l)?(e=!0,Is(n)):e=!1,Oi(n,i),tf(n,l,f),Ja(n,l,f,i),ru(null,n,l,!0,e,i);case 19:return xf(e,n,i);case 22:return ff(e,n,i)}throw Error(o(156,n.tag))};function Vf(e,n){return Hr(e,n)}function Vy(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tn(e,n,i,l){return new Vy(e,n,i,l)}function ku(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Wy(e){if(typeof e=="function")return ku(e)?1:0;if(e!=null){if(e=e.$$typeof,e===te)return 11;if(e===V)return 14}return 2}function Cr(e,n){var i=e.alternate;return i===null?(i=tn(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function sl(e,n,i,l,f,g){var S=2;if(l=e,typeof e=="function")ku(e)&&(S=1);else if(typeof e=="string")S=5;else e:switch(e){case B:return li(i.children,f,g,n);case Y:S=8,f|=8;break;case Q:return e=tn(12,i,n,f|2),e.elementType=Q,e.lanes=g,e;case q:return e=tn(13,i,n,f),e.elementType=q,e.lanes=g,e;case C:return e=tn(19,i,n,f),e.elementType=C,e.lanes=g,e;case U:return ll(i,f,g,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ne:S=10;break e;case ee:S=9;break e;case te:S=11;break e;case V:S=14;break e;case W:S=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=tn(S,i,n,f),n.elementType=e,n.type=l,n.lanes=g,n}function li(e,n,i,l){return e=tn(7,e,l,n),e.lanes=i,e}function ll(e,n,i,l){return e=tn(22,e,l,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function Nu(e,n,i){return e=tn(6,e,null,n),e.lanes=i,e}function ju(e,n,i){return n=tn(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Uy(e,n,i,l,f){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Gn(0),this.expirationTimes=Gn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Gn(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function bu(e,n,i,l,f,g,S,T,O){return e=new Uy(e,n,i,T,O),n===1?(n=1,g===!0&&(n|=8)):n=0,g=tn(3,null,null,n),e.current=g,g.stateNode=e,g.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Oa(g),e}function Gy(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),Ru.exports=i0(),Ru.exports}var rh;function o0(){if(rh)return pl;rh=1;var t=kp();return pl.createRoot=t.createRoot,pl.hydrateRoot=t.hydrateRoot,pl}var s0=o0();function Np(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Ae(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(Np(s,o.statusText||"Request failed"))}return o.json()}const l0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Pe={health:()=>Ae("/api/health"),settings:()=>Ae("/api/settings"),saveSettings:t=>{const r={...t};for(const o of l0)r[o]===""&&delete r[o];return Ae("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ae("/api/repos"),browse:t=>Ae(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ae(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ae("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ae(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Ae(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:(t,r=!0)=>Ae(`/api/architecture?repo_path=${encodeURIComponent(t)}&graph=${r?"1":"0"}`),architectureGraph:t=>Ae(`/api/architecture/graph?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Ae("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Ae("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Ae("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Ae("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Ae("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Ae(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open",s)=>Ae("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o,repo_path:s||null})}),scmRepos:t=>Ae(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ae("/api/oauth/status"),githubOAuthStart:()=>Ae("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ae("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ae("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Ae("/api/oauth/gitlab/start"),oauthDisconnect:t=>Ae("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ae("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})}),reviews:t=>Ae(`/api/reviews?repo_path=${encodeURIComponent(t)}`),getReview:(t,r)=>Ae(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(t)}`),reviewDiff:(t,r,o)=>Ae(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(t)}&other=${encodeURIComponent(o)}`),config:t=>Ae(`/api/config?repo_path=${encodeURIComponent(t)}`),saveConfig:(t,r)=>Ae("/api/config",{method:"PUT",body:JSON.stringify({repo_path:t,...r})}),addWaiver:(t,r,o,s)=>Ae("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:t,rule:r,node:o||null,reason:s||""})}),marks:(t,r)=>Ae(`/api/marks?repo_path=${encodeURIComponent(t)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:t=>Ae(`/api/architecture/health?repo_path=${encodeURIComponent(t)}`),workspaceStatus:t=>Ae(`/api/workspace/status?repo_path=${encodeURIComponent(t)}`),openEditor:(t,r,o,s)=>Ae("/api/open",{method:"POST",body:JSON.stringify({repo_path:t,path:r,line:o||null,editor:s||null})}),exportHtml:t=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:t})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(Np(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(t,r,o,s)=>Ae("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:t,edges:r,source_id:o,target_id:s||null})})};function a0(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):t}function u0({open:t,actions:r,onClose:o}){const[s,a]=L.useState(""),[u,c]=L.useState(0),h=L.useRef(null),p=L.useMemo(()=>a0(r,s),[r,s]);if(L.useEffect(()=>{if(!t)return;a(""),c(0);const y=window.setTimeout(()=>{var m;return(m=h.current)==null?void 0:m.focus()},0);return()=>window.clearTimeout(y)},[t]),L.useEffect(()=>{c(0)},[s]),!t)return null;const v=p[u],x=y=>{y&&(o(),y.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:y=>{y.target===y.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:y=>a(y.target.value),onKeyDown:y=>{y.key==="Escape"?(y.preventDefault(),o()):y.key==="ArrowDown"?(y.preventDefault(),c(m=>Math.min(p.length-1,m+1))):y.key==="ArrowUp"?(y.preventDefault(),c(m=>Math.max(0,m-1))):y.key==="Enter"&&(y.preventDefault(),x(v))}}),d.jsxs("ul",{children:[p.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,p.slice(0,40).map((y,m)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:m===u?"active":"",onMouseEnter:()=>c(m),onClick:()=>x(y),children:[d.jsx("span",{children:y.label}),y.hint?d.jsx("span",{className:"muted",children:y.hint}):null]})},y.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function c0({config:t,busy:r,onSave:o,onWaiver:s}){const[a,u]=L.useState(t),[c,h]=L.useState(t.available_rules[0]||""),[p,v]=L.useState(""),[x,y]=L.useState("");L.useEffect(()=>{u(t)},[t]);const m=Object.entries(a.contexts||{}),_=(P,w,j)=>{const $=a.contexts[P];if(!$)return;const z=B=>B.split(",").map(Y=>Y.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[P]:{...$,[w]:w==="name"?j:z(j)}}})},k=(P,w)=>{const j=w.trim();if(!j||j===P)return;const{[P]:$,...z}=a.contexts;$&&u({...a,contexts:{...z,[j]:{...$,name:j}}})},b=()=>{let P=1;for(;a.contexts[`context-${P}`];)P+=1;const w=`context-${P}`;u({...a,contexts:{...a.contexts,[w]:{name:w,django_apps:[],react:[],public_api:[],owners:[]}}})},E=P=>{const{[P]:w,...j}=a.contexts;u({...a,contexts:j})},N=P=>{const w=a.rules.includes(P);u({...a,rules:w?a.rules.filter(j=>j!==P):[...a.rules,P]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),m.map(([P,w])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:P})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:P,"data-testid":`config-context-name-${P}`,onBlur:j=>k(P,j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(w.django_apps||[]).join(", "),onChange:j=>_(P,"django_apps",j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(w.react||[]).join(", "),onChange:j=>_(P,"react",j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(w.public_api||[]).join(", "),onChange:j=>_(P,"public_api",j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(w.owners||[]).join(", "),onChange:j=>_(P,"owners",j.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>E(P),children:"Remove context"})]},P)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:b,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(P=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(P),onChange:()=>N(P)}),P]},P))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((P,w)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:P.rule}),P.node?` · ${P.node}`:"",P.reason?` — ${P.reason}`:""]},`${P.rule}:${P.node}:${w}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:P=>h(P.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(P=>d.jsx("option",{value:P,children:P},P))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:P=>v(P.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:x,onChange:P=>y(P.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,x),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function Qo(t){return t.replaceAll("_"," ")}function d0(t){return t.replaceAll("_"," ")}function ro(t){return t.split(".").pop()||t}function Qu(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function f0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Tr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function yi({className:t,children:r}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function h0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function p0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function g0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function m0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function y0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function jp({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function v0({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const x0="modulepreload",w0=function(t,r){return new URL(t,r).href},ih={},_0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(x){return Promise.all(x.map(y=>Promise.resolve(y).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),v=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(x=>{if(x=w0(x,s),x in ih)return;ih[x]=!0;const y=x.endsWith(".css"),m=y?'[rel="stylesheet"]':"";if(!!s)for(let b=h.length-1;b>=0;b--){const E=h[b];if(E.href===x&&(!y||E.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${x}"]${m}`))return;const k=document.createElement("link");if(k.rel=y?"stylesheet":x0,y||(k.as="script"),k.crossOrigin="",k.href=x,v&&k.setAttribute("nonce",v),document.head.appendChild(k),y)return new Promise((b,E)=>{k.addEventListener("load",b),k.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${x}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function nt(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Bl(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}bl.prototype=Bl.prototype={constructor:bl,on:function(t,r){var o=this._,s=k0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),sh.hasOwnProperty(r)?{space:sh[r],local:t}:t}function j0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===Zu&&r.documentElement.namespaceURI===Zu?r.createElement(t):r.createElementNS(o,t)}}function b0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function bp(t){var r=Vl(t);return(r.local?b0:j0)(r)}function E0(){}function pc(t){return t==null?E0:function(){return this.querySelector(t)}}function C0(t){typeof t!="function"&&(t=pc(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=w&&(w=P+1);!($=E[w])&&++w=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function J0(t){t||(t=ev);function r(y,m){return y&&m?t(y.__data__,m.__data__):!y-!m}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function tv(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function nv(){return Array.from(this)}function rv(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?pv:typeof r=="function"?mv:gv)(t,r,o??"")):Ki(this.node(),t)}function Ki(t,r){return t.style.getPropertyValue(r)||Ip(t).getComputedStyle(t,null).getPropertyValue(r)}function vv(t){return function(){delete this[t]}}function xv(t,r){return function(){this[t]=r}}function wv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function _v(t,r){return arguments.length>1?this.each((r==null?vv:typeof r=="function"?wv:xv)(t,r)):this.node()[t]}function Rp(t){return t.trim().split(/^|\s+/)}function gc(t){return t.classList||new Tp(t)}function Tp(t){this._node=t,this._names=Rp(t.getAttribute("class")||"")}Tp.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Lp(t,r){for(var o=gc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function qv(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function Ju(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:v,dispatch:x}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:v,enumerable:!0,configurable:!0},_:{value:x}})}Ju.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function ox(t){return!t.ctrlKey&&!t.button}function sx(){return this.parentNode}function lx(t,r){return r??{x:t.x,y:t.y}}function ax(){return navigator.maxTouchPoints||"ontouchstart"in this}function Fp(){var t=ox,r=sx,o=lx,s=ax,a={},u=Bl("start","drag","end"),c=0,h,p,v,x,y=0;function m(j){j.on("mousedown.drag",_).filter(s).on("touchstart.drag",E).on("touchmove.drag",N,ix).on("touchend.drag touchcancel.drag",P).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(j,$){if(!(x||!t.call(this,j,$))){var z=w(this,r.call(this,j,$),j,$,"mouse");z&&(Yt(j.view).on("mousemove.drag",k,Zo).on("mouseup.drag",b,Zo),Dp(j.view),Au(j),v=!1,h=j.clientX,p=j.clientY,z("start",j))}}function k(j){if(Xi(j),!v){var $=j.clientX-h,z=j.clientY-p;v=$*$+z*z>y}a.mouse("drag",j)}function b(j){Yt(j.view).on("mousemove.drag mouseup.drag",null),Op(j.view,v),Xi(j),a.mouse("end",j)}function E(j,$){if(t.call(this,j,$)){var z=j.changedTouches,B=r.call(this,j,$),Y=z.length,Q,ne;for(Q=0;Q>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?ml(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?ml(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=cx.exec(t))?new Dt(r[1],r[2],r[3],1):(r=dx.exec(t))?new Dt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=fx.exec(t))?ml(r[1],r[2],r[3],r[4]):(r=hx.exec(t))?ml(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=px.exec(t))?hh(r[1],r[2]/100,r[3]/100,1):(r=gx.exec(t))?hh(r[1],r[2]/100,r[3]/100,r[4]):lh.hasOwnProperty(t)?ch(lh[t]):t==="transparent"?new Dt(NaN,NaN,NaN,0):null}function ch(t){return new Dt(t>>16&255,t>>8&255,t&255,1)}function ml(t,r,o,s){return s<=0&&(t=r=o=NaN),new Dt(t,r,o,s)}function vx(t){return t instanceof cs||(t=fi(t)),t?(t=t.rgb(),new Dt(t.r,t.g,t.b,t.opacity)):new Dt}function ec(t,r,o,s){return arguments.length===1?vx(t):new Dt(t,r,o,s??1)}function Dt(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}mc(Dt,ec,Hp(cs,{brighter(t){return t=t==null?Rl:Math.pow(Rl,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Jo:Math.pow(Jo,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Dt(ci(this.r),ci(this.g),ci(this.b),Tl(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:dh,formatHex:dh,formatHex8:xx,formatRgb:fh,toString:fh}));function dh(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}`}function xx(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}${ui((isNaN(this.opacity)?1:this.opacity)*255)}`}function fh(){const t=Tl(this.opacity);return`${t===1?"rgb(":"rgba("}${ci(this.r)}, ${ci(this.g)}, ${ci(this.b)}${t===1?")":`, ${t})`}`}function Tl(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ci(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ui(t){return t=ci(t),(t<16?"0":"")+t.toString(16)}function hh(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new hn(t,r,o,s)}function Bp(t){if(t instanceof hn)return new hn(t.h,t.s,t.l,t.opacity);if(t instanceof cs||(t=fi(t)),!t)return new hn;if(t instanceof hn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new hn(c,h,p,t.opacity)}function wx(t,r,o,s){return arguments.length===1?Bp(t):new hn(t,r,o,s??1)}function hn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}mc(hn,wx,Hp(cs,{brighter(t){return t=t==null?Rl:Math.pow(Rl,t),new hn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Jo:Math.pow(Jo,t),new hn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Dt($u(t>=240?t-240:t+120,a,s),$u(t,a,s),$u(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new hn(ph(this.h),yl(this.s),yl(this.l),Tl(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 t=Tl(this.opacity);return`${t===1?"hsl(":"hsla("}${ph(this.h)}, ${yl(this.s)*100}%, ${yl(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ph(t){return t=(t||0)%360,t<0?t+360:t}function yl(t){return Math.max(0,Math.min(1,t||0))}function $u(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const yc=t=>()=>t;function _x(t,r){return function(o){return t+o*r}}function Sx(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function kx(t){return(t=+t)==1?Vp:function(r,o){return o-r?Sx(r,o,t):yc(isNaN(r)?o:r)}}function Vp(t,r){var o=r-t;return o?_x(t,o):yc(isNaN(t)?r:t)}const Ll=(function t(r){var o=kx(r);function s(a,u){var c=o((a=ec(a)).r,(u=ec(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),v=Vp(a.opacity,u.opacity);return function(x){return a.r=c(x),a.g=h(x),a.b=p(x),a.opacity=v(x),a+""}}return s.gamma=t,s})(1);function Nx(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:Rn(s,a)})),o=zu.lastIndex;return o180?x+=360:x-v>180&&(v+=360),m.push({i:y.push(a(y)+"rotate(",null,s)-2,x:Rn(v,x)})):x&&y.push(a(y)+"rotate("+x+s)}function h(v,x,y,m){v!==x?m.push({i:y.push(a(y)+"skewX(",null,s)-2,x:Rn(v,x)}):x&&y.push(a(y)+"skewX("+x+s)}function p(v,x,y,m,_,k){if(v!==y||x!==m){var b=_.push(a(_)+"scale(",null,",",null,")");k.push({i:b-4,x:Rn(v,y)},{i:b-2,x:Rn(x,m)})}else(y!==1||m!==1)&&_.push(a(_)+"scale("+y+","+m+")")}return function(v,x){var y=[],m=[];return v=t(v),x=t(x),u(v.translateX,v.translateY,x.translateX,x.translateY,y,m),c(v.rotate,x.rotate,y,m),h(v.skewX,x.skewX,y,m),p(v.scaleX,v.scaleY,x.scaleX,x.scaleY,y,m),v=x=null,function(_){for(var k=-1,b=m.length,E;++k=0&&t._call.call(void 0,r),t=t._next;--Qi}function yh(){hi=($l=ts.now())+Wl,Qi=Yo=0;try{Ox()}finally{Qi=0,Hx(),hi=0}}function Fx(){var t=ts.now(),r=t-$l;r>Yp&&(Wl-=r,$l=t)}function Hx(){for(var t,r=Al,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:Al=o);Xo=t,rc(s)}function rc(t){if(!Qi){Yo&&(Yo=clearTimeout(Yo));var r=t-hi;r>24?(t<1/0&&(Yo=setTimeout(yh,t-ts.now()-Wl)),Uo&&(Uo=clearInterval(Uo))):(Uo||($l=ts.now(),Uo=setInterval(Fx,Yp)),Qi=1,Xp(yh))}}function vh(t,r,o){var s=new zl;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Bx=Bl("start","end","cancel","interrupt"),Vx=[],Kp=0,xh=1,ic=2,Cl=3,wh=4,oc=5,Ml=6;function Ul(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;Wx(t,o,{name:r,index:s,group:a,on:Bx,tween:Vx,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Kp})}function xc(t,r){var o=yn(t,r);if(o.state>Kp)throw new Error("too late; already scheduled");return o}function Ln(t,r){var o=yn(t,r);if(o.state>Cl)throw new Error("too late; already running");return o}function yn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Wx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=qp(u,0,o.time);function u(v){o.state=xh,o.timer.restart(c,o.delay,o.time),o.delay<=v&&c(v-o.delay)}function c(v){var x,y,m,_;if(o.state!==xh)return p();for(x in s)if(_=s[x],_.name===o.name){if(_.state===Cl)return vh(c);_.state===wh?(_.state=Ml,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete s[x]):+xic&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function ww(t,r,o){var s,a,u=xw(r)?xc:Ln;return function(){var c=u(this,t),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function _w(t,r){var o=this._id;return arguments.length<2?yn(this.node(),o).on.on(t):this.each(ww(o,t,r))}function Sw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function kw(){return this.on("end.remove",Sw(this._id))}function Nw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=pc(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function qw(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function rr(t,r,o){this.k=t,this.x=r,this.y=o}rr.prototype={constructor:rr,scale:function(t){return t===1?this:new rr(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new rr(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Gl=new rr(1,0,0);eg.prototype=rr.prototype;function eg(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Gl;return t.__zoom}function Du(t){t.stopImmediatePropagation()}function Go(t){t.preventDefault(),t.stopImmediatePropagation()}function Kw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Qw(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function _h(){return this.__zoom||Gl}function Zw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Jw(){return navigator.maxTouchPoints||"ontouchstart"in this}function e1(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function tg(){var t=Kw,r=Qw,o=e1,s=Zw,a=Jw,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=El,v=Bl("start","zoom","end"),x,y,m,_=500,k=150,b=0,E=10;function N(C){C.property("__zoom",_h).on("wheel.zoom",Y,{passive:!1}).on("mousedown.zoom",Q).on("dblclick.zoom",ne).filter(a).on("touchstart.zoom",ee).on("touchmove.zoom",te).on("touchend.zoom touchcancel.zoom",q).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}N.transform=function(C,V,W,U){var M=C.selection?C.selection():C;M.property("__zoom",_h),C!==M?$(C,V,W,U):M.interrupt().each(function(){z(this,arguments).event(U).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},N.scaleBy=function(C,V,W,U){N.scaleTo(C,function(){var M=this.__zoom.k,D=typeof V=="function"?V.apply(this,arguments):V;return M*D},W,U)},N.scaleTo=function(C,V,W,U){N.transform(C,function(){var M=r.apply(this,arguments),D=this.__zoom,F=W==null?j(M):typeof W=="function"?W.apply(this,arguments):W,R=D.invert(F),A=typeof V=="function"?V.apply(this,arguments):V;return o(w(P(D,A),F,R),M,c)},W,U)},N.translateBy=function(C,V,W,U){N.transform(C,function(){return o(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),r.apply(this,arguments),c)},null,U)},N.translateTo=function(C,V,W,U,M){N.transform(C,function(){var D=r.apply(this,arguments),F=this.__zoom,R=U==null?j(D):typeof U=="function"?U.apply(this,arguments):U;return o(Gl.translate(R[0],R[1]).scale(F.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),D,c)},U,M)};function P(C,V){return V=Math.max(u[0],Math.min(u[1],V)),V===C.k?C:new rr(V,C.x,C.y)}function w(C,V,W){var U=V[0]-W[0]*C.k,M=V[1]-W[1]*C.k;return U===C.x&&M===C.y?C:new rr(C.k,U,M)}function j(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function $(C,V,W,U){C.on("start.zoom",function(){z(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){z(this,arguments).event(U).end()}).tween("zoom",function(){var M=this,D=arguments,F=z(M,D).event(U),R=r.apply(M,D),A=W==null?j(R):typeof W=="function"?W.apply(M,D):W,ie=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),oe=M.__zoom,fe=typeof V=="function"?V.apply(M,D):V,he=p(oe.invert(A).concat(ie/oe.k),fe.invert(A).concat(ie/fe.k));return function(pe){if(pe===1)pe=fe;else{var Z=he(pe),se=ie/Z[2];pe=new rr(se,A[0]-Z[0]*se,A[1]-Z[1]*se)}F.zoom(null,pe)}})}function z(C,V,W){return!W&&C.__zooming||new B(C,V)}function B(C,V){this.that=C,this.args=V,this.active=0,this.sourceEvent=null,this.extent=r.apply(C,V),this.taps=0}B.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,V){return this.mouse&&C!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var V=Yt(this.that).datum();v.call(C,this.that,new qw(C,{sourceEvent:this.sourceEvent,target:N,transform:this.that.__zoom,dispatch:v}),V)}};function Y(C,...V){if(!t.apply(this,arguments))return;var W=z(this,V).event(C),U=this.__zoom,M=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,s.apply(this,arguments)))),D=fn(C);if(W.wheel)(W.mouse[0][0]!==D[0]||W.mouse[0][1]!==D[1])&&(W.mouse[1]=U.invert(W.mouse[0]=D)),clearTimeout(W.wheel);else{if(U.k===M)return;W.mouse=[D,U.invert(D)],Pl(this),W.start()}Go(C),W.wheel=setTimeout(F,k),W.zoom("mouse",o(w(P(U,M),W.mouse[0],W.mouse[1]),W.extent,c));function F(){W.wheel=null,W.end()}}function Q(C,...V){if(m||!t.apply(this,arguments))return;var W=C.currentTarget,U=z(this,V,!0).event(C),M=Yt(C.view).on("mousemove.zoom",A,!0).on("mouseup.zoom",ie,!0),D=fn(C,W),F=C.clientX,R=C.clientY;Dp(C.view),Du(C),U.mouse=[D,this.__zoom.invert(D)],Pl(this),U.start();function A(oe){if(Go(oe),!U.moved){var fe=oe.clientX-F,he=oe.clientY-R;U.moved=fe*fe+he*he>b}U.event(oe).zoom("mouse",o(w(U.that.__zoom,U.mouse[0]=fn(oe,W),U.mouse[1]),U.extent,c))}function ie(oe){M.on("mousemove.zoom mouseup.zoom",null),Op(oe.view,U.moved),Go(oe),U.event(oe).end()}}function ne(C,...V){if(t.apply(this,arguments)){var W=this.__zoom,U=fn(C.changedTouches?C.changedTouches[0]:C,this),M=W.invert(U),D=W.k*(C.shiftKey?.5:2),F=o(w(P(W,D),U,M),r.apply(this,V),c);Go(C),h>0?Yt(this).transition().duration(h).call($,F,U,C):Yt(this).call(N.transform,F,U,C)}}function ee(C,...V){if(t.apply(this,arguments)){var W=C.touches,U=W.length,M=z(this,V,C.changedTouches.length===U).event(C),D,F,R,A;for(Du(C),F=0;F`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},ns=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ng=["Enter"," ","Escape"],rg={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Zi;(function(t){t.Strict="strict",t.Loose="loose"})(Zi||(Zi={}));var di;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(di||(di={}));var rs;(function(t){t.Partial="partial",t.Full="full"})(rs||(rs={}));const ig={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Lr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Lr||(Lr={}));var is;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(is||(is={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const Sh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function og(t){return t===null?null:t?"valid":"invalid"}const sg=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,t1=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),_c=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),ds=(t,r=[0,0])=>{const{width:o,height:s}=vn(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},n1=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):_c(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,Yl(a,Dl(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?Xl(s):{x:0,y:0,width:0,height:0}},fs=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=Yl(o,Dl(a)),s=!0)}),s?Xl(o):{x:0,y:0,width:0,height:0}},Sc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,v=r.width/a,x=r.height/a,y=[];for(const m of t.values()){const{measured:_,selectable:k=!0,hidden:b=!1}=m;if(c&&!k||b)continue;const E=_.width??m.width??m.initialWidth??0,N=_.height??m.height??m.initialHeight??0,{x:P,y:w}=m.internals.positionAbsolute,j=cg(h,p,v,x,P,w,E,N),$=E*N,z=u&&j>0;(!m.internals.handleBounds||z||j>=$||m.dragging)&&y.push(m)}return y},r1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function i1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=vn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function o1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const h=i1(t,c),p=fs(h),v=Nc(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(v,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function lg({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),h=c.parentId?o.get(c.parentId):void 0,{x:p,y:v}=h?h.internals.positionAbsolute:{x:0,y:0},x=c.origin??s;let y=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",mn.error005());else{const{width:_,height:k}=vn(h);_&&k&&(y=[[p,v],[p+_,v+k]])}else h&&gi(c.extent)&&(y=[[c.extent[0][0]+p,c.extent[0][1]+v],[c.extent[1][0]+p,c.extent[1][1]+v]]);const m=gi(y)?pi(r,y,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",mn.error015())),{position:{x:m.x-p+(c.measured.width??0)*x[0],y:m.y-v+(c.measured.height??0)*x[1]},positionAbsolute:m}}async function s1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(m=>m.id)),c=[];for(const m of o){if(m.deletable===!1)continue;const _=u.has(m.id),k=!_&&m.parentId&&c.find(b=>b.id===m.parentId);(_||k)&&c.push(m)}const h=new Set(r.map(m=>m.id)),p=s.filter(m=>m.deletable!==!1),x=r1(c,p);for(const m of p)h.has(m.id)&&!x.find(k=>k.id===m.id)&&x.push(m);if(!a)return{edges:x,nodes:c};const y=await a({nodes:c,edges:x});return typeof y=="boolean"?y?{edges:x,nodes:c}:{edges:[],nodes:[]}:y}const Ji=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),pi=(t={x:0,y:0},r,o)=>({x:Ji(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:Ji(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function ag(t,r,o){const{width:s,height:a}=vn(o),{x:u,y:c}=o.internals.positionAbsolute;return pi(t,[[u,c],[u+s,c+a]],r)}const kh=(t,r,o)=>to?-Ji(Math.abs(t-o),1,r)/r:0,kc=(t,r,o=15,s=40)=>{const a=kh(t.x,s,r.width-s)*o,u=kh(t.y,s,r.height-s)*o;return[a,u]},Yl=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),sc=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),Xl=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),os=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:ds(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},Dl=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:ds(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},ug=(t,r)=>Xl(Yl(sc(t),sc(r))),cg=(t,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),v=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*v)},Ol=(t,r)=>cg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),Nh=t=>pn(t.width)&&pn(t.height)&&pn(t.x)&&pn(t.y),pn=t=>!isNaN(t)&&isFinite(t),dg=(t,r)=>(o,s)=>{},hs=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),ps=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(t-o)/a,y:(r-s)/a};return u?hs(h,c):h},eo=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Gi(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function l1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Gi(t,o),a=Gi(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Gi(t.top??t.y??0,o),a=Gi(t.bottom??t.y??0,o),u=Gi(t.left??t.x??0,r),c=Gi(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function a1(t,r,o,s,a,u){const{x:c,y:h}=eo(t,[r,o,s]),{x:p,y:v}=eo({x:t.x+t.width,y:t.y+t.height},[r,o,s]),x=a-p,y=u-v;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(x),bottom:Math.floor(y)}}const Nc=(t,r,o,s,a,u)=>{const c=l1(u,r,o),h=(r-c.x)/t.width,p=(o-c.y)/t.height,v=Math.min(h,p),x=Ji(v,s,a),y=t.x+t.width/2,m=t.y+t.height/2,_=r/2-y*x,k=o/2-m*x,b=a1(t,_,k,x,r,o),E={left:Math.min(b.left-c.left,0),top:Math.min(b.top-c.top,0),right:Math.min(b.right-c.right,0),bottom:Math.min(b.bottom-c.bottom,0)};return{x:_-E.left+E.right,y:k-E.top+E.bottom,zoom:x}},ss=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function gi(t){return t!=null&&t!=="parent"}function vn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function fg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function hg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function jh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function u1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function c1(t){return{...rg,...t||{}}}function Ko(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=gn(t),h=ps({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y:v}=o?hs(h,r):h;return{xSnapped:p,ySnapped:v,...h}}const jc=t=>({width:t.offsetWidth,height:t.offsetHeight}),pg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},d1=["INPUT","SELECT","TEXTAREA"];function gg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:d1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const mg=t=>"clientX"in t,gn=(t,r)=>{var u,c;const o=mg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},bh=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...jc(c)}})};function yg({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=t*.125+a*.375+c*.375+o*.125,v=r*.125+u*.375+h*.375+s*.125,x=Math.abs(p-t),y=Math.abs(v-r);return[p,v,x,y]}function wl(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function Eh({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case Se.Left:return[r-wl(r-s,u),o];case Se.Right:return[r+wl(s-r,u),o];case Se.Top:return[r,o-wl(o-a,u)];case Se.Bottom:return[r,o+wl(a-o,u)]}}function vg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top,curvature:c=.25}){const[h,p]=Eh({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[v,x]=Eh({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[y,m,_,k]=yg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:v,targetControlY:x});return[`M${t},${r} C${h},${p} ${v},${x} ${s},${a}`,y,m,_,k]}function xg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const p1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,g1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),m1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",mn.error006()),r;const s=o.getEdgeId||p1;let a;return sg(t)?a={...t}:a={...t,id:s(t)},g1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function wg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=xg({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,h]}const Ch={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},y1=({source:t,sourcePosition:r=Se.Bottom,target:o})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function v1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:s=Se.Top,center:a,offset:u,stepPosition:c}){const h=Ch[r],p=Ch[s],v={x:t.x+h.x*u,y:t.y+h.y*u},x={x:o.x+p.x*u,y:o.y+p.y*u},y=y1({source:v,sourcePosition:r,target:x}),m=y.x!==0?"x":"y",_=y[m];let k=[],b,E;const N={x:0,y:0},P={x:0,y:0},[,,w,j]=xg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[m]*p[m]===-1){m==="x"?(b=a.x??v.x+(x.x-v.x)*c,E=a.y??(v.y+x.y)/2):(b=a.x??(v.x+x.x)/2,E=a.y??v.y+(x.y-v.y)*c);const Y=[{x:b,y:v.y},{x:b,y:x.y}],Q=[{x:v.x,y:E},{x:x.x,y:E}];h[m]===_?k=m==="x"?Y:Q:k=m==="x"?Q:Y}else{const Y=[{x:v.x,y:x.y}],Q=[{x:x.x,y:v.y}];if(m==="x"?k=h.x===_?Q:Y:k=h.y===_?Y:Q,r===s){const C=Math.abs(t[m]-o[m]);if(C<=u){const V=Math.min(u-1,u-C);h[m]===_?N[m]=(v[m]>t[m]?-1:1)*V:P[m]=(x[m]>o[m]?-1:1)*V}}if(r!==s){const C=m==="x"?"y":"x",V=h[m]===p[C],W=v[C]>x[C],U=v[C]=q?(b=(ne.x+ee.x)/2,E=k[0].y):(b=k[0].x,E=(ne.y+ee.y)/2)}const $={x:v.x+N.x,y:v.y+N.y},z={x:x.x+P.x,y:x.y+P.y};return[[t,...$.x!==k[0].x||$.y!==k[0].y?[$]:[],...k,...z.x!==k[k.length-1].x||z.y!==k[k.length-1].y?[z]:[],o],b,E,w,j]}function x1(t,r,o,s){const a=Math.min(Mh(t,r)/2,Mh(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const v=t.xo.id===r):t[0])||null}function ac(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function _1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const v=ac(p,r);u.has(v)||(c.push({id:v,color:p.color||o,...p}),u.add(v))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const _g=1e3,S1=10,bc={nodeOrigin:[0,0],nodeExtent:ns,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},k1={...bc,checkEquality:!0};function Ec(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function N1(t,r,o){const s=Ec(bc,o);for(const a of t.values())if(a.parentId)Mc(a,t,r,s);else{const u=ds(a,s.nodeOrigin),c=gi(a.extent)?a.extent:s.nodeExtent,h=pi(u,c,vn(a));a.internals.positionAbsolute=h}}function j1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function Cc(t){return t==="manual"}function uc(t,r,o,s={}){var x,y;const a=Ec(k1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!Cc(a.zIndexMode)?_g:0;let p=t.length>0,v=!1;r.clear(),o.clear();for(const m of t){let _=c.get(m.id);if(a.checkEquality&&m===(_==null?void 0:_.internals.userNode))r.set(m.id,_);else{const k=ds(m,a.nodeOrigin),b=gi(m.extent)?m.extent:a.nodeExtent,E=pi(k,b,vn(m));_={...a.defaults,...m,measured:{width:(x=m.measured)==null?void 0:x.width,height:(y=m.measured)==null?void 0:y.height},internals:{positionAbsolute:E,handleBounds:j1(m,_),z:Sg(m,h,a.zIndexMode),userNode:m}},r.set(m.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),m.parentId&&Mc(_,r,o,s,u),v||(v=m.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:v}}function b1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function Mc(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=Ec(bc,s),v=t.parentId,x=r.get(v);if(!x){console.warn(`Parent node ${v} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}b1(t,o),a&&!x.parentId&&x.internals.rootParentIndex===void 0&&p==="auto"&&(x.internals.rootParentIndex=++a.i,x.internals.z=x.internals.z+a.i*S1),a&&x.internals.rootParentIndex!==void 0&&(a.i=x.internals.rootParentIndex);const y=u&&!Cc(p)?_g:0,{x:m,y:_,z:k}=E1(t,x,c,h,y,p),{positionAbsolute:b}=t.internals,E=m!==b.x||_!==b.y;(E||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:E?{x:m,y:_}:b,z:k}})}function Sg(t,r,o){const s=pn(t.zIndex)?t.zIndex:0;return Cc(o)?s:s+(t.selected?r:0)}function E1(t,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=vn(t),v=ds(t,o),x=gi(t.extent)?pi(v,t.extent,p):v;let y=pi({x:c+x.x,y:h+x.y},s,p);t.extent==="parent"&&(y=ag(y,p,r));const m=Sg(t,a,u),_=r.internals.z??0;return{x:y.x,y:y.y,z:_>=m?_+1:m}}function Pc(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const v=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??os(p),x=ug(v,h.rect);u.set(h.parentId,{expandedRect:x,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},v)=>{var w;const x=p.internals.positionAbsolute,y=vn(p),m=p.origin??s,_=h.x0||k>0||N||P)&&(a.push({id:v,type:"position",position:{x:p.position.x-_+N,y:p.position.y-k+P}}),(w=o.get(v))==null||w.forEach(j=>{t.some($=>$.id===j.id)||a.push({id:j.id,type:"position",position:{x:j.position.x+_,y:j.position.y+k}})})),(y.width0){const _=Pc(m,r,o,a);v.push(..._)}return{changes:v,updatedInternals:p}}async function M1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Th(t,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${t}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${t}-${u}`;const v=s.get(c)||new Map;s.set(c,v.set(o,r))}}function kg(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},v=`${a}-${c}--${u}-${h}`,x=`${u}-${h}--${a}-${c}`;Th("source",p,x,t,a,c),Th("target",p,v,t,u,h),r.set(s.id,s)}}function Ng(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:Ng(o,r):!1}function Lh(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function P1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!Ng(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function Ou({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[v,x]of r){const y=(c=o.get(v))==null?void 0:c.internals.userNode;y&&a.push({...y,position:x.position,dragging:s})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function I1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=hs(u,r);return{x:c.x-u.x,y:c.y-u.y}}function R1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,v={x:0,y:0},x=null,y=!1,m=null,_=!1,k=!1,b=null;function E({noDragClassName:P,handleSelector:w,domNode:j,isSelectable:$,nodeId:z,nodeClickDistance:B=0}){m=Yt(j);function Y({x:te,y:q}){const{nodeLookup:C,nodeExtent:V,snapGrid:W,snapToGrid:U,nodeOrigin:M,onNodeDrag:D,onSelectionDrag:F,onError:R,updateNodePositions:A}=r();u={x:te,y:q};let ie=!1;const oe=h.size>1,fe=oe&&V?sc(fs(h)):null,he=oe&&U?I1({dragItems:h,snapGrid:W,x:te,y:q}):null;for(const[pe,Z]of h){if(!C.has(pe))continue;let se={x:te-Z.distance.x,y:q-Z.distance.y};U&&(se=he?{x:Math.round(se.x+he.x),y:Math.round(se.y+he.y)}:hs(se,W));let me=null;if(oe&&V&&!Z.extent&&fe){const{positionAbsolute:re}=Z.internals,Ne=re.x-fe.x+V[0][0],Me=re.x+Z.measured.width-fe.x2+V[1][0],Te=re.y-fe.y+V[0][1],$e=re.y+Z.measured.height-fe.y2+V[1][1];me=[[Ne,Te],[Me,$e]]}const{position:ke,positionAbsolute:ve}=lg({nodeId:pe,nextPosition:se,nodeLookup:C,nodeExtent:me||V,nodeOrigin:M,onError:R});ie=ie||Z.position.x!==ke.x||Z.position.y!==ke.y,Z.position=ke,Z.internals.positionAbsolute=ve}if(k=k||ie,!!ie&&(A(h,!0),b&&(s||D||!z&&F))){const[pe,Z]=Ou({nodeId:z,dragItems:h,nodeLookup:C});s==null||s(b,h,pe,Z),D==null||D(b,pe,Z),z||F==null||F(b,Z)}}async function Q(){if(!x)return;const{transform:te,panBy:q,autoPanSpeed:C,autoPanOnNodeDrag:V}=r();if(!V){p=!1,cancelAnimationFrame(c);return}const[W,U]=kc(v,x,C);(W!==0||U!==0)&&(u.x=(u.x??0)-W/te[2],u.y=(u.y??0)-U/te[2],await q({x:W,y:U})&&Y(u)),c=requestAnimationFrame(Q)}function ne(te){var oe;const{nodeLookup:q,multiSelectionActive:C,nodesDraggable:V,transform:W,snapGrid:U,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:F,onSelectionDragStart:R,unselectNodesAndEdges:A}=r();y=!0,(!D||!$)&&!C&&z&&((oe=q.get(z))!=null&&oe.selected||A()),$&&D&&z&&(t==null||t(z));const ie=Ko(te.sourceEvent,{transform:W,snapGrid:U,snapToGrid:M,containerBounds:x});if(u=ie,h=P1(q,V,ie,z),h.size>0&&(o||F||!z&&R)){const[fe,he]=Ou({nodeId:z,dragItems:h,nodeLookup:q});o==null||o(te.sourceEvent,h,fe,he),F==null||F(te.sourceEvent,fe,he),z||R==null||R(te.sourceEvent,he)}}const ee=Fp().clickDistance(B).on("start",te=>{const{domNode:q,nodeDragThreshold:C,transform:V,snapGrid:W,snapToGrid:U}=r();x=(q==null?void 0:q.getBoundingClientRect())||null,_=!1,k=!1,b=te.sourceEvent,C===0&&ne(te),u=Ko(te.sourceEvent,{transform:V,snapGrid:W,snapToGrid:U,containerBounds:x}),v=gn(te.sourceEvent,x)}).on("drag",te=>{const{autoPanOnNodeDrag:q,transform:C,snapGrid:V,snapToGrid:W,nodeDragThreshold:U,nodeLookup:M}=r(),D=Ko(te.sourceEvent,{transform:C,snapGrid:V,snapToGrid:W,containerBounds:x});if(b=te.sourceEvent,(te.sourceEvent.type==="touchmove"&&te.sourceEvent.touches.length>1||z&&!M.has(z))&&(_=!0),!_){if(!p&&q&&y&&(p=!0,Q()),!y){const F=gn(te.sourceEvent,x),R=F.x-v.x,A=F.y-v.y;Math.sqrt(R*R+A*A)>U&&ne(te)}(u.x!==D.xSnapped||u.y!==D.ySnapped)&&h&&y&&(v=gn(te.sourceEvent,x),Y(D))}}).on("end",te=>{if(!y||_){_&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,y=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:q,updateNodePositions:C,onNodeDragStop:V,onSelectionDragStop:W}=r();if(k&&(C(h,!1),k=!1),a||V||!z&&W){const[U,M]=Ou({nodeId:z,dragItems:h,nodeLookup:q,dragging:!1});a==null||a(te.sourceEvent,h,U,M),V==null||V(te.sourceEvent,U,M),z||W==null||W(te.sourceEvent,M)}}}).filter(te=>{const q=te.target;return!te.button&&(!P||!Lh(q,`.${P}`,j))&&(!w||Lh(q,w,j))});m.call(ee)}function N(){m==null||m.on(".drag",null)}return{update:E,destroy:N}}function T1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())Ol(a,os(u))>0&&s.push(u);return s}const L1=250;function A1(t,r,o,s){var h,p;let a=[],u=1/0;const c=T1(t,o,r+L1);for(const v of c){const x=[...((h=v.internals.handleBounds)==null?void 0:h.source)??[],...((p=v.internals.handleBounds)==null?void 0:p.target)??[]];for(const y of x){if(s.nodeId===y.nodeId&&s.type===y.type&&s.id===y.id)continue;const{x:m,y:_}=mi(v,y,y.position,!0),k=Math.sqrt(Math.pow(m-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const v=s.type==="source"?"target":"source";return a.find(x=>x.type===v)??a[0]}return a[0]}function jg(t,r,o,s,a,u=!1){var v,x,y;const c=s.get(t);if(!c)return null;const h=a==="strict"?(v=c.internals.handleBounds)==null?void 0:v[r]:[...((x=c.internals.handleBounds)==null?void 0:x.source)??[],...((y=c.internals.handleBounds)==null?void 0:y.target)??[]],p=(o?h==null?void 0:h.find(m=>m.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...mi(c,p,p.position,!0)}:p}function bg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function $1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const Eg=()=>!0;function z1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:v,autoPanOnConnect:x,flowId:y,panBy:m,cancelConnection:_,onConnectStart:k,onConnect:b,onConnectEnd:E,isValidConnection:N=Eg,onReconnectEnd:P,updateConnection:w,getTransform:j,getFromHandle:$,autoPanSpeed:z,dragThreshold:B=1,handleDomNode:Y}){const Q=pg(t.target);let ne=0,ee;const{x:te,y:q}=gn(t),C=bg(u,Y),V=h==null?void 0:h.getBoundingClientRect();let W=!1;if(!V||!C)return;const U=jg(a,C,s,p,r);if(!U)return;let M=gn(t,V),D=!1,F=null,R=!1,A=null;function ie(){if(!x||!V)return;const[ke,ve]=kc(M,V,z);m({x:ke,y:ve}),ne=requestAnimationFrame(ie)}const oe={...U,nodeId:a,type:C,position:U.position},fe=p.get(a);let pe={inProgress:!0,isValid:null,from:mi(fe,oe,Se.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:fe,to:M,toHandle:null,toPosition:Sh[oe.position],toNode:null,pointer:M};function Z(){W=!0,w(pe),k==null||k(t,{nodeId:a,handleId:s,handleType:C})}B===0&&Z();function se(ke){if(!W){const{x:$e,y:st}=gn(ke),lt=$e-te,at=st-q;if(!(lt*lt+at*at>B*B))return;Z()}if(!$()||!oe){me(ke);return}const ve=j();M=gn(ke,V),ee=A1(ps(M,ve,!1,[1,1]),o,p,oe),D||(ie(),D=!0);const re=Cg(ke,{handle:ee,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:N,doc:Q,lib:v,flowId:y,nodeLookup:p});A=re.handleDomNode,F=re.connection,R=$1(!!ee,re.isValid);const Ne=p.get(a),Me=Ne?mi(Ne,oe,Se.Left,!0):pe.from,Te={...pe,from:Me,isValid:R,to:re.toHandle&&R?eo({x:re.toHandle.x,y:re.toHandle.y},ve):M,toHandle:re.toHandle,toPosition:R&&re.toHandle?re.toHandle.position:Sh[oe.position],toNode:re.toHandle?p.get(re.toHandle.nodeId):null,pointer:M};w(Te),pe=Te}function me(ke){if(!("touches"in ke&&ke.touches.length>0)){if(W){(ee||A)&&F&&R&&(b==null||b(F));const{inProgress:ve,...re}=pe,Ne={...re,toPosition:pe.toHandle?pe.toPosition:null};E==null||E(ke,Ne),u&&(P==null||P(ke,Ne))}_(),cancelAnimationFrame(ne),D=!1,R=!1,F=null,A=null,Q.removeEventListener("mousemove",se),Q.removeEventListener("mouseup",me),Q.removeEventListener("touchmove",se),Q.removeEventListener("touchend",me)}}Q.addEventListener("mousemove",se),Q.addEventListener("mouseup",me),Q.addEventListener("touchmove",se),Q.addEventListener("touchend",me)}function Cg(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:v=Eg,nodeLookup:x}){const y=u==="target",m=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=gn(t),b=c.elementFromPoint(_,k),E=b!=null&&b.classList.contains(`${h}-flow__handle`)?b:m,N={handleDomNode:E,isValid:!1,connection:null,toHandle:null};if(E){const P=bg(void 0,E),w=E.getAttribute("data-nodeid"),j=E.getAttribute("data-handleid"),$=E.classList.contains("connectable"),z=E.classList.contains("connectableend");if(!w||!P)return N;const B={source:y?w:s,sourceHandle:y?j:a,target:y?s:w,targetHandle:y?a:j};N.connection=B;const Q=$&&z&&(o===Zi.Strict?y&&P==="source"||!y&&P==="target":w!==s||j!==a);N.isValid=Q&&v(B),N.toHandle=jg(w,P,j,x,o,!0)}return N}const cc={onPointerDown:z1,isValid:Cg};function D1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Yt(t);function u({translateExtent:h,width:p,height:v,zoomStep:x=1,pannable:y=!0,zoomable:m=!0,inversePan:_=!1}){const k=w=>{if(w.sourceEvent.type!=="wheel"||!r)return;const j=o(),$=w.sourceEvent.ctrlKey&&ss()?10:1,z=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*x,B=j[2]*Math.pow(2,z*$);r.scaleTo(B)};let b=[0,0];const E=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(b=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},N=w=>{const j=o();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!r)return;const $=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],z=[$[0]-b[0],$[1]-b[1]];b=$;const B=s()*Math.max(j[2],Math.log(j[2]))*(_?-1:1),Y={x:j[0]-z[0]*B,y:j[1]-z[1]*B},Q=[[0,0],[p,v]];r.setViewportConstrained({x:Y.x,y:Y.y,zoom:j[2]},Q,h)},P=tg().on("start",E).on("zoom",y?N:null).on("zoom.wheel",m?k:null);a.call(P,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:fn}}const ql=t=>({x:t.x,y:t.y,zoom:t.k}),Fu=({x:t,y:r,zoom:o})=>Gl.translate(t,r).scale(o),Rr=(t,r)=>t.target.closest(`.${r}`),Mg=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),O1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Hu=(t,r=0,o=O1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Pg=t=>{const r=t.ctrlKey&&ss()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function F1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:v}){return x=>{if(Rr(x,r))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const y=o.property("__zoom").k||1;if(x.ctrlKey&&c){const E=fn(x),N=Pg(x),P=y*Math.pow(2,N);s.scaleTo(o,P,E,x);return}const m=x.deltaMode===1?20:1;let _=a===di.Vertical?0:x.deltaX*m,k=a===di.Horizontal?0:x.deltaY*m;!ss()&&x.shiftKey&&a!==di.Vertical&&(_=x.deltaY*m,k=0),s.translateBy(o,-(_/y)*u,-(k/y)*u,{internal:!0});const b=ql(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(x,b):(t.isPanScrolling=!0,h==null||h(x,b)),t.panScrollTimeout=setTimeout(()=>{v==null||v(x,b),t.isPanScrolling=!1},150)}}function H1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=Rr(s,t);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function B1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=ql(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function V1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;t.usedRightMouseButton=!!(o&&Mg(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,ql(u.transform)))}}function W1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&Mg(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const p=ql(c.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function U1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:v,lib:x,connectionInProgress:y}){return m=>{var N;const _=r||o,k=s&&m.ctrlKey,b=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(Rr(m,`${x}-flow__node`)||Rr(m,`${x}-flow__edge`)||Rr(m,`${x}-flow__selection`)||Rr(m,`${x}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!c&&!s||h||y&&!b||Rr(m,p)&&b||Rr(m,v)&&(!b||u&&b&&!r)||!s&&m.ctrlKey&&b)return!1;if(!s&&m.type==="touchstart"&&((N=m.touches)==null?void 0:N.length)>1)return m.preventDefault(),!1;if(!_&&!u&&!k&&b||!a&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(a)&&!a.includes(m.button)&&m.type==="mousedown")return!1;const E=Array.isArray(a)&&a.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||b||t)&&E}}function G1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const v={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=t.getBoundingClientRect();let y=[[0,0],[x.width,x.height]];const m=typeof ResizeObserver<"u"?new ResizeObserver(q=>{const C=q[0];C&&(y=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;m==null||m.observe(t);const _=tg().extent(()=>y).scaleExtent([r,o]).translateExtent(s),k=Yt(t).call(_);j({x:a.x,y:a.y,zoom:Ji(a.zoom,r,o)},[[0,0],[x.width,x.height]],s);const b=k.on("wheel.zoom"),E=k.on("dblclick.zoom");_.wheelDelta(Pg);async function N(q,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?qo:El).transform(Hu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),q)}):!1}function P({noWheelClassName:q,noPanClassName:C,onPaneContextMenu:V,userSelectionActive:W,panOnScroll:U,panOnDrag:M,panOnScrollMode:D,panOnScrollSpeed:F,preventScrolling:R,zoomOnPinch:A,zoomOnScroll:ie,zoomOnDoubleClick:oe,panActivationKeyPressed:fe=!1,zoomActivationKeyPressed:he,lib:pe,onTransformChange:Z,connectionInProgress:se,paneClickDistance:me,selectionOnDrag:ke}){W&&!v.isZoomingOrPanning&&w();const ve=U&&!he&&!W;_.clickDistance(ke?1/0:!pn(me)||me<0?0:me);const re=ve?F1({zoomPanValues:v,noWheelClassName:q,d3Selection:k,d3Zoom:_,panOnScrollMode:D,panOnScrollSpeed:F,zoomOnPinch:A,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):H1({noWheelClassName:q,preventScrolling:R,d3ZoomHandler:b});k.on("wheel.zoom",re,{passive:!1});const Ne=B1({zoomPanValues:v,onDraggingChange:p,onPanZoomStart:c});_.on("start",Ne);const Me=V1({zoomPanValues:v,panOnDrag:M,onPaneContextMenu:!!V,onPanZoom:u,onTransformChange:Z});_.on("zoom",Me);const Te=W1({zoomPanValues:v,panOnDrag:M,panOnScroll:U,onPaneContextMenu:V,onPanZoomEnd:h,onDraggingChange:p});_.on("end",Te);const $e=U1({panActivationKeyPressed:fe,zoomActivationKeyPressed:he,panOnDrag:M,zoomOnScroll:ie,panOnScroll:U,zoomOnDoubleClick:oe,zoomOnPinch:A,userSelectionActive:W,noPanClassName:C,noWheelClassName:q,lib:pe,connectionInProgress:se});_.filter($e),oe?k.on("dblclick.zoom",E):k.on("dblclick.zoom",null)}function w(){_.on("zoom",null)}async function j(q,C,V){const W=Fu(q),U=_==null?void 0:_.constrain()(W,C,V);return U&&await N(U),U}async function $(q,C){const V=Fu(q);return await N(V,C),V}function z(q){if(k){const C=Fu(q),V=k.property("__zoom");(V.k!==q.zoom||V.x!==q.x||V.y!==q.y)&&(_==null||_.transform(k,C,null,{sync:!0}))}}function B(){const q=k?eg(k.node()):{x:0,y:0,k:1};return{x:q.x,y:q.y,zoom:q.k}}async function Y(q,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?qo:El).scaleTo(Hu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),q)}):!1}async function Q(q,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?qo:El).scaleBy(Hu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),q)}):!1}function ne(q){_==null||_.scaleExtent(q)}function ee(q){_==null||_.translateExtent(q)}function te(q){const C=!pn(q)||q<0?0:q;_==null||_.clickDistance(C)}return{update:P,destroy:w,setViewport:$,setViewportConstrained:j,getViewport:B,scaleTo:Y,scaleBy:Q,setScaleExtent:ne,setTranslateExtent:ee,syncViewport:z,setClickDistance:te}}var to;(function(t){t.Line="line",t.Handle="handle"})(to||(to={}));function Y1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function Ah(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function Pr(t,r){return Math.max(0,r-t)}function Ir(t,r){return Math.max(0,t-r)}function _l(t,r,o){return Math.max(0,r-t,t-o)}function $h(t,r){return t?!r:r}function X1(t,r,o,s,a,u,c,h){let{affectsX:p,affectsY:v}=r;const{isHorizontal:x,isVertical:y}=r,m=x&&y,{xSnapped:_,ySnapped:k}=o,{minWidth:b,maxWidth:E,minHeight:N,maxHeight:P}=s,{x:w,y:j,width:$,height:z,aspectRatio:B}=t;let Y=Math.floor(x?_-t.pointerX:0),Q=Math.floor(y?k-t.pointerY:0);const ne=$+(p?-Y:Y),ee=z+(v?-Q:Q),te=-u[0]*$,q=-u[1]*z;let C=_l(ne,b,E),V=_l(ee,N,P);if(c){let M=0,D=0;p&&Y<0?M=Pr(w+Y+te,c[0][0]):!p&&Y>0&&(M=Ir(w+ne+te,c[1][0])),v&&Q<0?D=Pr(j+Q+q,c[0][1]):!v&&Q>0&&(D=Ir(j+ee+q,c[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(h){let M=0,D=0;p&&Y>0?M=Ir(w+Y,h[0][0]):!p&&Y<0&&(M=Pr(w+ne,h[1][0])),v&&Q>0?D=Ir(j+Q,h[0][1]):!v&&Q<0&&(D=Pr(j+ee,h[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(a){if(x){const M=_l(ne/B,N,P)*B;if(C=Math.max(C,M),c){let D=0;!p&&!v||p&&!v&&m?D=Ir(j+q+ne/B,c[1][1])*B:D=Pr(j+q+(p?Y:-Y)/B,c[0][1])*B,C=Math.max(C,D)}if(h){let D=0;!p&&!v||p&&!v&&m?D=Pr(j+ne/B,h[1][1])*B:D=Ir(j+(p?Y:-Y)/B,h[0][1])*B,C=Math.max(C,D)}}if(y){const M=_l(ee*B,b,E)/B;if(V=Math.max(V,M),c){let D=0;!p&&!v||v&&!p&&m?D=Ir(w+ee*B+te,c[1][0])/B:D=Pr(w+(v?Q:-Q)*B+te,c[0][0])/B,V=Math.max(V,D)}if(h){let D=0;!p&&!v||v&&!p&&m?D=Pr(w+ee*B,h[1][0])/B:D=Ir(w+(v?Q:-Q)*B,h[0][0])/B,V=Math.max(V,D)}}}Q=Q+(Q<0?V:-V),Y=Y+(Y<0?C:-C),a&&(m?ne>ee*B?Q=($h(p,v)?-Y:Y)/B:Y=($h(p,v)?-Q:Q)*B:x?(Q=Y/B,v=p):(Y=Q*B,p=v));const W=p?w+Y:w,U=v?j+Q:j;return{width:$+(p?-Y:Y),height:z+(v?-Q:Q),x:u[0]*Y*(p?-1:1)+W,y:u[1]*Q*(v?-1:1)+U}}const Ig={width:0,height:0,x:0,y:0},q1={...Ig,pointerX:0,pointerY:0,aspectRatio:1};function K1(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function Q1({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Yt(t);let c={controlDirection:Ah("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:v,boundaries:x,keepAspectRatio:y,resizeDirection:m,onResizeStart:_,onResize:k,onResizeEnd:b,shouldResize:E}){let N={...Ig},P={...q1};c={boundaries:x,resizeDirection:m,keepAspectRatio:y,controlDirection:Ah(v)};let w,j=null,$=[],z,B,Y,Q=!1;const ne=Fp().on("start",ee=>{const{nodeLookup:te,transform:q,snapGrid:C,snapToGrid:V,nodeOrigin:W,paneDomNode:U}=o();if(w=te.get(r),!w)return;j=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:D}=Ko(ee.sourceEvent,{transform:q,snapGrid:C,snapToGrid:V,containerBounds:j});N={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},P={...N,pointerX:M,pointerY:D,aspectRatio:N.width/N.height},z=void 0,B=gi(w.extent)?w.extent:void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&(z=te.get(w.parentId)),z&&w.extent==="parent"&&(B=[[0,0],[z.measured.width,z.measured.height]]),$=[],Y=void 0;for(const[F,R]of te)if(R.parentId===r&&($.push({id:F,position:{...R.position},extent:R.extent}),R.extent==="parent"||R.expandParent)){const A=K1(R,w,R.origin??W);Y?Y=[[Math.min(A[0][0],Y[0][0]),Math.min(A[0][1],Y[0][1])],[Math.max(A[1][0],Y[1][0]),Math.max(A[1][1],Y[1][1])]]:Y=A}_==null||_(ee,{...N})}).on("drag",ee=>{const{transform:te,snapGrid:q,snapToGrid:C,nodeOrigin:V}=o(),W=Ko(ee.sourceEvent,{transform:te,snapGrid:q,snapToGrid:C,containerBounds:j}),U=[];if(!w)return;const{x:M,y:D,width:F,height:R}=N,A={},ie=w.origin??V,{width:oe,height:fe,x:he,y:pe}=X1(P,c.controlDirection,W,c.boundaries,c.keepAspectRatio,ie,B,Y),Z=oe!==F,se=fe!==R,me=he!==M&&Z,ke=pe!==D&&se;if(!me&&!ke&&!Z&&!se)return;if((me||ke||ie[0]===1||ie[1]===1)&&(A.x=me?he:N.x,A.y=ke?pe:N.y,N.x=A.x,N.y=A.y,$.length>0)){const Me=he-M,Te=pe-D;for(const $e of $)$e.position={x:$e.position.x-Me+ie[0]*(oe-F),y:$e.position.y-Te+ie[1]*(fe-R)},U.push($e)}if((Z||se)&&(A.width=Z&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:N.width,A.height=se&&(!c.resizeDirection||c.resizeDirection==="vertical")?fe:N.height,N.width=A.width,N.height=A.height),z&&w.expandParent){const Me=ie[0]*(A.width??0);A.x&&A.x{Q&&(b==null||b(ee,{...N}),a==null||a({...N}),Q=!1)});u.call(ne)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Bu={exports:{}},Vu={},Wu={exports:{}},Uu={};/** - * @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 zh;function Z1(){if(zh)return Uu;zh=1;var t=as();function r(y,m){return y===m&&(y!==0||1/y===1/m)||y!==y&&m!==m}var o=typeof Object.is=="function"?Object.is:r,s=t.useState,a=t.useEffect,u=t.useLayoutEffect,c=t.useDebugValue;function h(y,m){var _=m(),k=s({inst:{value:_,getSnapshot:m}}),b=k[0].inst,E=k[1];return u(function(){b.value=_,b.getSnapshot=m,p(b)&&E({inst:b})},[y,_,m]),a(function(){return p(b)&&E({inst:b}),y(function(){p(b)&&E({inst:b})})},[y]),c(_),_}function p(y){var m=y.getSnapshot;y=y.value;try{var _=m();return!o(y,_)}catch{return!0}}function v(y,m){return m()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?v:h;return Uu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:x,Uu}var Dh;function J1(){return Dh||(Dh=1,Wu.exports=Z1()),Wu.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 Oh;function e_(){if(Oh)return Vu;Oh=1;var t=as(),r=J1();function o(v,x){return v===x&&(v!==0||1/v===1/x)||v!==v&&x!==x}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Vu.useSyncExternalStoreWithSelector=function(v,x,y,m,_){var k=u(null);if(k.current===null){var b={hasValue:!1,value:null};k.current=b}else b=k.current;k=h(function(){function N(z){if(!P){if(P=!0,w=z,z=m(z),_!==void 0&&b.hasValue){var B=b.value;if(_(B,z))return j=B}return j=z}if(B=j,s(w,z))return B;var Y=m(z);return _!==void 0&&_(B,Y)?(w=z,B):(w=z,j=Y)}var P=!1,w,j,$=y===void 0?null:y;return[function(){return N(x())},$===null?void 0:function(){return N($())}]},[x,y,m,_]);var E=a(v,k[0],k[1]);return c(function(){b.hasValue=!0,b.value=E},[E]),p(E),E},Vu}var Fh;function t_(){return Fh||(Fh=1,Bu.exports=e_()),Bu.exports}var n_=t_();const r_=Sp(n_),i_={},Hh=t=>{let r;const o=new Set,s=(x,y)=>{const m=typeof x=="function"?x(r):x;if(!Object.is(m,r)){const _=r;r=y??(typeof m!="object"||m===null)?m:Object.assign({},r,m),o.forEach(k=>k(r,_))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>v,subscribe:x=>(o.add(x),()=>o.delete(x)),destroy:()=>{(i_?"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."),o.clear()}},v=r=t(s,a,p);return p},o_=t=>t?Hh(t):Hh,{useDebugValue:s_}=t0,{useSyncExternalStoreWithSelector:l_}=r_,a_=t=>t;function Rg(t,r=a_,o){const s=l_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return s_(s),s}const Bh=(t,r)=>{const o=o_(t),s=(a,u=r)=>Rg(o,a,u);return Object.assign(s,o),s},u_=(t,r)=>t?Bh(t,r):Bh;function Qe(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}kp();const Kl=L.createContext(null),c_=Kl.Provider,Tg=mn.error001("react");function De(t,r){const o=L.useContext(Kl);if(o===null)throw new Error(Tg);return Rg(o,t,r)}function Ge(){const t=L.useContext(Kl);if(t===null)throw new Error(Tg);return L.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Vh={display:"none"},d_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Lg="react-flow__node-desc",Ag="react-flow__edge-desc",f_="react-flow__aria-live",h_=t=>t.ariaLiveMessage,p_=t=>t.ariaLabelConfig;function g_({rfId:t}){const r=De(h_);return d.jsx("div",{id:`${f_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:d_,children:r})}function m_({rfId:t,disableKeyboardA11y:r}){const o=De(p_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${Lg}-${t}`,style:Vh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${Ag}-${t}`,style:Vh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(g_,{rfId:t})]})}const Ql=L.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return d.jsx("div",{className:nt(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});Ql.displayName="Panel";const Wh="https://reactflow.dev?utm_source=attribution";function y_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:d.jsx(Ql,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Wh}`,children:d.jsx("a",{href:Wh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const v_=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},Sl=t=>t.id;function x_(t,r){return Qe(t.selectedNodes.map(Sl),r.selectedNodes.map(Sl))&&Qe(t.selectedEdges.map(Sl),r.selectedEdges.map(Sl))}function w_({onSelectionChange:t}){const r=Ge(),{selectedNodes:o,selectedEdges:s}=De(v_,x_);return L.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const __=t=>!!t.onSelectionChangeHandlers;function S_({onSelectionChange:t}){const r=De(__);return t||r?d.jsx(w_,{onSelectionChange:t}):null}const $g=[0,0],k_={x:0,y:0,zoom:1},N_=["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"],Uh=[...N_,"rfId"],j_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Gh={translateExtent:ns,nodeOrigin:$g,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function b_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=De(j_,Qe),v=Ge();L.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{x.current=Gh,h()}),[]);const x=L.useRef(Gh);return L.useEffect(()=>{for(const y of Uh){const m=t[y],_=x.current[y];m!==_&&(typeof t[y]>"u"||(y==="nodes"?r(m):y==="edges"?o(m):y==="minZoom"?s(m):y==="maxZoom"?a(m):y==="translateExtent"?u(m):y==="nodeExtent"?c(m):y==="ariaLabelConfig"?v.setState({ariaLabelConfig:c1(m)}):y==="fitView"?v.setState({fitViewQueued:m}):y==="fitViewOptions"?v.setState({fitViewOptions:m}):v.setState({[y]:m})))}x.current=t},Uh.map(y=>t[y])),null}function Yh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function E_(t){var s;const[r,o]=L.useState(t==="system"?null:t);return L.useEffect(()=>{if(t!=="system"){o(t);return}const a=Yh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=Yh())!=null&&s.matches?"dark":"light"}const Xh=typeof document<"u"?document:null;function ls(t=null,r={target:Xh,actInsideInputWithModifier:!0}){const[o,s]=L.useState(!1),a=L.useRef(!1),u=L.useRef(new Set([])),[c,h]=L.useMemo(()=>{if(t!==null){const v=(Array.isArray(t)?t:[t]).filter(y=>typeof y=="string").map(y=>y.replace(/\+/g,` -`).replace(` - -`,` -+`).split(` -`)),x=v.reduce((y,m)=>y.concat(...m),[]);return[v,x]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Xh,v=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const x=_=>{var E,N;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!v)&&gg(_))return!1;const b=Kh(_.code,h);if(u.current.add(_[b]),qh(c,u.current,!1)){const P=((N=(E=_.composedPath)==null?void 0:E.call(_))==null?void 0:N[0])||_.target,w=(P==null?void 0:P.nodeName)==="BUTTON"||(P==null?void 0:P.nodeName)==="A";r.preventDefault!==!1&&(a.current||!w)&&_.preventDefault(),s(!0)}},y=_=>{const k=Kh(_.code,h);qh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},m=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",x),p==null||p.addEventListener("keyup",y),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{p==null||p.removeEventListener("keydown",x),p==null||p.removeEventListener("keyup",y),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,s]),o}function qh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Kh(t,r){return r.includes(t)?"code":"key"}const C_=()=>{const t=Ge();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=Nc(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),v={x:r.x-h,y:r.y-p},x=o.snapGrid??a,y=o.snapToGrid??u;return ps(v,s,y,x)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=eo(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function zg(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)M_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function M_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function P_(t,r){return zg(t,r)}function I_(t,r){return zg(t,r)}function ai(t,r){return{id:t,type:"select",selected:r}}function Yi(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(ai(u.id,c)))}return s}function Qh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Zh(t){return{id:t.id,type:"remove"}}const R_=dg();function T_(t,r,o={}){return m1(t,r,{...o,onError:o.onError??R_})}const Jh=t=>t1(t),L_=t=>sg(t);function Dg(t){return L.forwardRef(t)}const Og=typeof window<"u"?L.useLayoutEffect:L.useEffect;function ep(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>A_(()=>o(a=>a+BigInt(1))));return Og(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function A_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Fg=L.createContext(null);function $_({children:t}){const r=Ge(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:v,hasDefaultNodes:x,onNodesChange:y,nodeLookup:m,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let b=p;for(const N of h)b=typeof N=="function"?N(b):N;let E=Qh({items:b,lookup:m});for(const N of k.values())E=N(E);x&&v(b),E.length>0?y==null||y(E):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:N,nodes:P,setNodes:w}=r.getState();N&&w(P)})},[]),s=ep(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:v,hasDefaultEdges:x,onEdgesChange:y,edgeLookup:m}=r.getState();let _=p;for(const k of h)_=typeof k=="function"?k(_):k;x?v(_):y&&y(Qh({items:_,lookup:m}))},[]),u=ep(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Fg.Provider,{value:c,children:t})}function z_(){const t=L.useContext(Fg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const D_=t=>!!t.panZoom;function Zl(){const t=C_(),r=Ge(),o=z_(),s=De(D_),a=L.useMemo(()=>{const u=y=>r.getState().nodeLookup.get(y),c=y=>{o.nodeQueue.push(y)},h=y=>{o.edgeQueue.push(y)},p=y=>{var N,P;const{nodeLookup:m,nodeOrigin:_}=r.getState(),k=Jh(y)?y:m.get(y.id),b=k.parentId?hg(k.position,k.measured,k.parentId,m,_):k.position,E={...k,position:b,width:((N=k.measured)==null?void 0:N.width)??k.width,height:((P=k.measured)==null?void 0:P.height)??k.height};return os(E)},v=(y,m,_={replace:!1})=>{c(k=>k.map(b=>{if(b.id===y){const E=typeof m=="function"?m(b):m;return _.replace&&Jh(E)?E:{...b,...E}}return b}))},x=(y,m,_={replace:!1})=>{h(k=>k.map(b=>{if(b.id===y){const E=typeof m=="function"?m(b):m;return _.replace&&L_(E)?E:{...b,...E}}return b}))};return{getNodes:()=>r.getState().nodes.map(y=>({...y})),getNode:y=>{var m;return(m=u(y))==null?void 0:m.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:y=[]}=r.getState();return y.map(m=>({...m}))},getEdge:y=>r.getState().edgeLookup.get(y),setNodes:c,setEdges:h,addNodes:y=>{const m=Array.isArray(y)?y:[y];o.nodeQueue.push(_=>[..._,...m])},addEdges:y=>{const m=Array.isArray(y)?y:[y];o.edgeQueue.push(_=>[..._,...m])},toObject:()=>{const{nodes:y=[],edges:m=[],transform:_}=r.getState(),[k,b,E]=_;return{nodes:y.map(N=>({...N})),edges:m.map(N=>({...N})),viewport:{x:k,y:b,zoom:E}}},deleteElements:async({nodes:y=[],edges:m=[]})=>{const{nodes:_,edges:k,onNodesDelete:b,onEdgesDelete:E,triggerNodeChanges:N,triggerEdgeChanges:P,onDelete:w,onBeforeDelete:j}=r.getState(),{nodes:$,edges:z}=await s1({nodesToRemove:y,edgesToRemove:m,nodes:_,edges:k,onBeforeDelete:j}),B=z.length>0,Y=$.length>0;if(B){const Q=z.map(Zh);E==null||E(z),P(Q)}if(Y){const Q=$.map(Zh);b==null||b($),N(Q)}return(Y||B)&&(w==null||w({nodes:$,edges:z})),{deletedNodes:$,deletedEdges:z}},getIntersectingNodes:(y,m=!0,_)=>{const k=Nh(y),b=k?y:p(y),E=_!==void 0;return b?(_||r.getState().nodes).filter(N=>{const P=r.getState().nodeLookup.get(N.id);if(P&&!k&&(N.id===y.id||!P.internals.positionAbsolute))return!1;const w=os(E?N:P),j=Ol(w,b);return m&&j>0||j>=w.width*w.height||j>=b.width*b.height}):[]},isNodeIntersecting:(y,m,_=!0)=>{const b=Nh(y)?y:p(y);if(!b)return!1;const E=Ol(b,m);return _&&E>0||E>=m.width*m.height||E>=b.width*b.height},updateNode:v,updateNodeData:(y,m,_={replace:!1})=>{v(y,k=>{const b=typeof m=="function"?m(k):m;return _.replace?{...k,data:b}:{...k,data:{...k.data,...b}}},_)},updateEdge:x,updateEdgeData:(y,m,_={replace:!1})=>{x(y,k=>{const b=typeof m=="function"?m(k):m;return _.replace?{...k,data:b}:{...k,data:{...k.data,...b}}},_)},getNodesBounds:y=>{const{nodeLookup:m,nodeOrigin:_}=r.getState();return n1(y,{nodeLookup:m,nodeOrigin:_})},getHandleConnections:({type:y,id:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${y}${m?`-${m}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:y,handleId:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${y?m?`-${y}-${m}`:`-${y}`:""}`))==null?void 0:k.values())??[])},fitView:async y=>{const m=r.getState().fitViewResolver??u1();return r.setState({fitViewQueued:!0,fitViewOptions:y,fitViewResolver:m}),o.nodeQueue.push(_=>[..._]),m.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const tp=t=>t.selected,O_=typeof window<"u"?window:void 0;function F_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ge(),{deleteElements:s}=Zl(),a=ls(t,{actInsideInputWithModifier:!1}),u=ls(r,{target:O_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(tp),edges:c.filter(tp)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function H_(t){const r=Ge();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=jc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",mn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const Jl={position:"absolute",width:"100%",height:"100%",top:0,left:0},B_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function V_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=di.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:v,translateExtent:x,minZoom:y,maxZoom:m,zoomActivationKeyCode:_,preventScrolling:k=!0,children:b,noWheelClassName:E,noPanClassName:N,onViewportChange:P,isControlledViewport:w,paneClickDistance:j,selectionOnDrag:$}){const z=Ge(),B=L.useRef(null),{userSelectionActive:Y,lib:Q,connectionInProgress:ne}=De(B_,Qe),ee=ls(_),te=L.useRef();H_(B);const q=L.useCallback(C=>{P==null||P({x:C[0],y:C[1],zoom:C[2]}),w||z.setState({transform:C})},[P,w]);return L.useEffect(()=>{if(B.current){te.current=G1({domNode:B.current,minZoom:y,maxZoom:m,translateExtent:x,viewport:v,onDraggingChange:U=>z.setState(M=>M.paneDragging===U?M:{paneDragging:U}),onPanZoomStart:(U,M)=>{const{onViewportChangeStart:D,onMoveStart:F}=z.getState();F==null||F(U,M),D==null||D(M)},onPanZoom:(U,M)=>{const{onViewportChange:D,onMove:F}=z.getState();F==null||F(U,M),D==null||D(M)},onPanZoomEnd:(U,M)=>{const{onViewportChangeEnd:D,onMoveEnd:F}=z.getState();F==null||F(U,M),D==null||D(M)}});const{x:C,y:V,zoom:W}=te.current.getViewport();return z.setState({panZoom:te.current,transform:[C,V,W],domNode:B.current.closest(".react-flow")}),()=>{var U;(U=te.current)==null||U.destroy()}}},[]),L.useEffect(()=>{var C;(C=te.current)==null||C.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:ee,preventScrolling:k,noPanClassName:N,userSelectionActive:Y,noWheelClassName:E,lib:Q,onTransformChange:q,connectionInProgress:ne,selectionOnDrag:$,paneClickDistance:j})},[t,r,o,s,a,u,c,h,p,ee,k,N,Y,E,Q,q,ne,$,j]),d.jsx("div",{className:"react-flow__renderer",ref:B,style:Jl,children:b})}const W_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function U_(){const{userSelectionActive:t,userSelectionRect:r}=De(W_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const Gu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},G_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function Y_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=rs.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:v,onPaneContextMenu:x,onPaneScroll:y,onPaneMouseEnter:m,onPaneMouseMove:_,onPaneMouseLeave:k,children:b}){const E=L.useRef(0),N=Ge(),{userSelectionActive:P,elementsSelectable:w,dragging:j,panBy:$,autoPanSpeed:z}=De(G_,Qe),B=w&&(t||P),Y=L.useRef(null),Q=L.useRef(),ne=L.useRef(new Set),ee=L.useRef(new Set),te=L.useRef(!1),q=L.useRef(!1),C=L.useRef({x:0,y:0}),V=L.useRef(!1),W=Z=>{if(q.current||te.current||N.getState().connection.inProgress){q.current=!1,te.current=!1;return}v==null||v(Z),N.getState().resetSelectedElements(),N.setState({nodesSelectionActive:!1})},U=Z=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Z.preventDefault();return}x==null||x(Z)},M=y?Z=>y(Z):void 0,D=Z=>{q.current&&(Z.stopPropagation(),q.current=!1)},F=Z=>{var $e,st;if(Z.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:se,transform:me}=N.getState();if(Q.current=se==null?void 0:se.getBoundingClientRect(),!Q.current)return;const ke=Z.target===Y.current;if(!ke&&!!Z.target.closest(".nokey")||!t||!(c&&ke||r)||Z.button!==0||!Z.isPrimary)return;(st=($e=Z.target)==null?void 0:$e.setPointerCapture)==null||st.call($e,Z.pointerId),q.current=!1;const{x:Ne,y:Me}=gn(Z.nativeEvent,Q.current),Te=ps({x:Ne,y:Me},me);N.setState({userSelectionRect:{width:0,height:0,startX:Te.x,startY:Te.y,x:Ne,y:Me}}),ke||(Z.stopPropagation(),Z.preventDefault())};function R(Z,se){const{userSelectionRect:me}=N.getState();if(!me)return;const{transform:ke,nodeLookup:ve,edgeLookup:re,connectionLookup:Ne,triggerNodeChanges:Me,triggerEdgeChanges:Te,defaultEdgeOptions:$e}=N.getState(),st={x:me.startX,y:me.startY},{x:lt,y:at}=eo(st,ke),Ye={startX:st.x,startY:st.y,x:Zmt.id)),ee.current=new Set;const gt=($e==null?void 0:$e.selectable)??!0;for(const mt of ne.current){const Pt=Ne.get(mt);if(Pt)for(const{edgeId:ut}of Pt.values()){const Je=re.get(ut);Je&&(Je.selectable??gt)&&ee.current.add(ut)}}if(!jh(wt,ne.current)){const mt=Yi(ve,ne.current,!0);Me(mt)}if(!jh(qt,ee.current)){const mt=Yi(re,ee.current);Te(mt)}N.setState({userSelectionRect:Ye,userSelectionActive:!0,nodesSelectionActive:!1})}function A(){if(!a||!Q.current)return;const[Z,se]=kc(C.current,Q.current,z);$({x:Z,y:se}).then(me=>{if(!q.current||!me){E.current=requestAnimationFrame(A);return}const{x:ke,y:ve}=C.current;R(ke,ve),E.current=requestAnimationFrame(A)})}const ie=()=>{cancelAnimationFrame(E.current),E.current=0,V.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=Z=>{const{userSelectionRect:se,transform:me,resetSelectedElements:ke}=N.getState();if(!Q.current||!se)return;const{x:ve,y:re}=gn(Z.nativeEvent,Q.current);C.current={x:ve,y:re};const Ne=eo({x:se.startX,y:se.startY},me);if(!q.current){const Me=r?0:u;if(Math.hypot(ve-Ne.x,re-Ne.y)<=Me)return;ke(),h==null||h(Z)}q.current=!0,V.current||(A(),V.current=!0),R(ve,re)},fe=Z=>{var se,me;if(!B){Z.target===Y.current&&N.getState().connection.inProgress&&(te.current=!0);return}Z.button===0&&((me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),!P&&Z.target===Y.current&&N.getState().userSelectionRect&&(W==null||W(Z)),N.setState({userSelectionActive:!1,userSelectionRect:null}),q.current&&(p==null||p(Z),N.setState({nodesSelectionActive:ne.current.size>0})),ie())},he=Z=>{var se,me;(me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),ie()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:nt(["react-flow__pane",{draggable:pe,dragging:j,selection:t}]),onClick:B?void 0:Gu(W,Y),onContextMenu:Gu(U,Y),onWheel:Gu(M,Y),onPointerEnter:B?void 0:m,onPointerMove:B?oe:_,onPointerUp:fe,onPointerCancel:B?he:void 0,onPointerDownCapture:B?F:void 0,onClickCapture:B?D:void 0,onPointerLeave:k,ref:Y,style:Jl,children:[b,d.jsx(U_,{})]})}function dc({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),v=h.get(t);if(!v){p==null||p("012",mn.error012(t));return}r.setState({nodesSelectionActive:!1}),v.selected?(o||v.selected&&c)&&(u({nodes:[v],edges:[]}),requestAnimationFrame(()=>{var x;return(x=s==null?void 0:s.current)==null?void 0:x.blur()})):a([t])}function Hg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ge(),[p,v]=L.useState(!1),x=L.useRef();return L.useEffect(()=>{if(!r)return x.current=R1({getStoreItems:()=>h.getState(),onNodeMouseDown:y=>{dc({id:y,store:h,nodeRef:t})},onDragStart:()=>{v(!0)},onDragStop:()=>{v(!1)}}),()=>{var y;(y=x.current)==null||y.destroy(),x.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!x.current||x.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const X_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Bg(){const t=Ge();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:v,nodeOrigin:x}=t.getState(),y=new Map,m=X_(c),_=a?u[0]:5,k=a?u[1]:5,b=o.direction.x*_*o.factor,E=o.direction.y*k*o.factor;for(const[,N]of v){if(!m(N))continue;let P={x:N.internals.positionAbsolute.x+b,y:N.internals.positionAbsolute.y+E};a&&(P=hs(P,u));const{position:w,positionAbsolute:j}=lg({nodeId:N.id,nextPosition:P,nodeLookup:v,nodeExtent:s,nodeOrigin:x,onError:h});N.position=w,N.internals.positionAbsolute=j,y.set(N.id,N)}p(y)},[])}const Ic=L.createContext(null),q_=Ic.Provider;Ic.Consumer;const Vg=()=>L.useContext(Ic),K_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Wg=L.createContext(null);function Q_({children:t}){const r=De(K_,Qe);return d.jsx(Wg.Provider,{value:r,children:t})}function Z_(){const t=L.useContext(Wg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const J_={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},eS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:v}=c;if(!h&&!a)return J_;const x=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:x,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Zi.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:x&&v}};function tS({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:v,onMouseDown:x,onTouchStart:y,...m},_){var V,W;const k=c||null,b=t==="target",E=Ge(),N=Vg(),{connectOnClick:P,noPanClassName:w,rfId:j}=Z_(),{connectingFrom:$,connectingTo:z,clickConnecting:B,isPossibleEndHandle:Y,connectionInProcess:Q,clickConnectionInProcess:ne,valid:ee}=De(eS(N,k,t),Qe);N||(W=(V=E.getState()).onError)==null||W.call(V,"010",mn.error010());const te=U=>{const{defaultEdgeOptions:M,onConnect:D,hasDefaultEdges:F}=E.getState(),R={...M,...U};if(F){const{edges:A,setEdges:ie,onError:oe}=E.getState();ie(T_(R,A,{onError:oe}))}D==null||D(R),h==null||h(R)},q=U=>{if(!N)return;const M=mg(U.nativeEvent);if(a&&(M&&U.button===0||!M)){const D=E.getState();cc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:b,handleId:k,nodeId:N,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...F)=>{var R,A;return(A=(R=E.getState()).onConnectEnd)==null?void 0:A.call(R,...F)},updateConnection:D.updateConnection,onConnect:te,isValidConnection:o||((...F)=>{var R,A;return((A=(R=E.getState()).isValidConnection)==null?void 0:A.call(R,...F))??!0}),getTransform:()=>E.getState().transform,getFromHandle:()=>E.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}M?x==null||x(U):y==null||y(U)},C=U=>{const{onClickConnectStart:M,onClickConnectEnd:D,connectionClickStartHandle:F,connectionMode:R,isValidConnection:A,lib:ie,rfId:oe,nodeLookup:fe,connection:he}=E.getState();if(!N||!F&&!a)return;if(!F){M==null||M(U.nativeEvent,{nodeId:N,handleId:k,handleType:t}),E.setState({connectionClickStartHandle:{nodeId:N,type:t,id:k}});return}const pe=pg(U.target),Z=o||A,{connection:se,isValid:me}=cc.isValid(U.nativeEvent,{handle:{nodeId:N,id:k,type:t},connectionMode:R,fromNodeId:F.nodeId,fromHandleId:F.id||null,fromType:F.type,isValidConnection:Z,flowId:oe,doc:pe,lib:ie,nodeLookup:fe});me&&se&&te(se);const ke=structuredClone(he);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,D==null||D(U,ke),E.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":k,"data-nodeid":N,"data-handlepos":r,"data-id":`${j}-${N}-${k}-${t}`,className:nt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",w,v,{source:!b,target:b,connectable:s,connectablestart:a,connectableend:u,clickconnecting:B,connectingfrom:$,connectingto:z,valid:ee,connectionindicator:s&&(!Q||Y)&&(Q||ne?u:a)}]),onMouseDown:q,onTouchStart:q,onClick:P?C:void 0,ref:_,...m,children:p})}const no=L.memo(Dg(tS));function nS({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(no,{type:"source",position:o,isConnectable:r})]})}function rS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:s=Se.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(no,{type:"source",position:s,isConnectable:r})]})}function iS(){return null}function oS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const Fl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},np={input:nS,default:rS,output:oS,group:iS};function sS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const lS=t=>{const{width:r,height:o,x:s,y:a}=fs(t.nodeLookup,{filter:u=>!!u.selected});return{width:pn(r)?r:null,height:pn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function aS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ge(),{width:a,height:u,transformString:c,userSelectionActive:h}=De(lS,Qe),p=Bg(),v=L.useRef(null);L.useEffect(()=>{var _;o||(_=v.current)==null||_.focus({preventScroll:!0})},[o]);const x=!h&&a!==null&&u!==null;if(Hg({nodeRef:v,disabled:!x}),!x)return null;const y=t?_=>{const k=s.getState().nodes.filter(b=>b.selected);t(_,k)}:void 0,m=_=>{Object.prototype.hasOwnProperty.call(Fl,_.key)&&(_.preventDefault(),p({direction:Fl[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:nt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:v,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:o?void 0:-1,onKeyDown:o?void 0:m,style:{width:a,height:u}})})}const rp=typeof window<"u"?window:void 0,uS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Ug({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:v,selectionOnDrag:x,selectionMode:y,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:b,zoomActivationKeyCode:E,elementsSelectable:N,zoomOnScroll:P,zoomOnPinch:w,panOnScroll:j,panOnScrollSpeed:$,panOnScrollMode:z,zoomOnDoubleClick:B,panOnDrag:Y,autoPanOnSelection:Q,defaultViewport:ne,translateExtent:ee,minZoom:te,maxZoom:q,preventScrolling:C,onSelectionContextMenu:V,noWheelClassName:W,noPanClassName:U,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:F}){const{nodesSelectionActive:R,userSelectionActive:A}=De(uS,Qe),ie=ls(v,{target:rp}),oe=ls(b,{target:rp}),fe=oe||Y,he=oe||j,pe=x&&fe!==!0,Z=ie||A||pe;return F_({deleteKeyCode:p,multiSelectionKeyCode:k}),d.jsx(V_,{onPaneContextMenu:u,elementsSelectable:N,zoomOnScroll:P,zoomOnPinch:w,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:$,panOnScrollMode:z,zoomOnDoubleClick:B,panOnDrag:!ie&&fe,defaultViewport:ne,translateExtent:ee,minZoom:te,maxZoom:q,zoomActivationKeyCode:E,preventScrolling:C,noWheelClassName:W,noPanClassName:U,onViewportChange:D,isControlledViewport:F,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(Y_,{onSelectionStart:m,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:Q,isSelecting:!!Z,selectionMode:y,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:pe,children:[t,R&&d.jsx(aS,{onSelectionContextMenu:V,noPanClassName:U,disableKeyboardA11y:M})]})})}Ug.displayName="FlowRenderer";const cS=L.memo(Ug),dS=t=>r=>t?Sc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function fS(t){return De(L.useCallback(dS(t),[t]),Qe)}const hS=t=>t.updateNodeInternals;function pS(){const t=De(hS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function gS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ge(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),v=L.useRef(r),x=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!x||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[x,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const y=v.current!==r,m=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(y||m||_)&&(v.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function mS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:v,nodesFocusable:x,resizeObserver:y,noDragClassName:m,noPanClassName:_,disableKeyboardA11y:k,rfId:b,nodeTypes:E,nodeClickDistance:N,onError:P}){const{node:w,internals:j,isParent:$}=De(Z=>{const se=Z.nodeLookup.get(t),me=Z.parentLookup.has(t);return{node:se,internals:se.internals,isParent:me}},Qe);let z=w.type||"default",B=(E==null?void 0:E[z])||np[z];B===void 0&&(P==null||P("003",mn.error003(z)),z="default",B=(E==null?void 0:E.default)||np.default);const Y=!!(w.draggable||h&&typeof w.draggable>"u"),Q=!!(w.selectable||p&&typeof w.selectable>"u"),ne=!!(w.connectable||v&&typeof w.connectable>"u"),ee=!!(w.focusable||x&&typeof w.focusable>"u"),te=Ge(),q=fg(w),C=gS({node:w,nodeType:z,hasDimensions:q,resizeObserver:y}),V=Hg({nodeRef:C,disabled:w.hidden||!Y,noDragClassName:m,handleSelector:w.dragHandle,nodeId:t,isSelectable:Q,nodeClickDistance:N}),W=Bg();if(w.hidden)return null;const U=vn(w),M=sS(w),D=Q||Y||r||o||s||a,F=o?Z=>o(Z,{...j.userNode}):void 0,R=s?Z=>s(Z,{...j.userNode}):void 0,A=a?Z=>a(Z,{...j.userNode}):void 0,ie=u?Z=>u(Z,{...j.userNode}):void 0,oe=c?Z=>c(Z,{...j.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:se,nodeDragThreshold:me}=te.getState();Q&&(!se||!Y||me>0)&&dc({id:t,store:te,nodeRef:C}),r&&r(Z,{...j.userNode})},he=Z=>{if(!(gg(Z.nativeEvent)||k)){if(ng.includes(Z.key)&&Q){const se=Z.key==="Escape";dc({id:t,store:te,unselect:se,nodeRef:C})}else if(Y&&w.selected&&Object.prototype.hasOwnProperty.call(Fl,Z.key)){Z.preventDefault();const{ariaLabelConfig:se}=te.getState();te.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),W({direction:Fl[Z.key],factor:Z.shiftKey?4:1})}}},pe=()=>{var Ne;if(k||!((Ne=C.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:Z,width:se,height:me,autoPanOnNodeFocus:ke,setCenter:ve}=te.getState();if(!ke)return;Sc(new Map([[t,w]]),{x:0,y:0,width:se,height:me},Z,!0).length>0||ve(w.position.x+U.width/2,w.position.y+U.height/2,{zoom:Z[2]})};return d.jsx("div",{className:nt(["react-flow__node",`react-flow__node-${z}`,{[_]:Y},w.className,{selected:w.selected,selectable:Q,parent:$,draggable:Y,dragging:V}]),ref:C,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:q?"visible":"hidden",...w.style,...M},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:F,onMouseMove:R,onMouseLeave:A,onContextMenu:ie,onClick:fe,onDoubleClick:oe,onKeyDown:ee?he:void 0,tabIndex:ee?0:void 0,onFocus:ee?pe:void 0,role:w.ariaRole??(ee?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${Lg}-${b}`,"aria-label":w.ariaLabel,...w.domAttributes,children:d.jsx(q_,{value:t,children:d.jsx(B,{id:t,data:w.data,type:z,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:w.selected??!1,selectable:Q,draggable:Y,deletable:w.deletable??!0,isConnectable:ne,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:V,dragHandle:w.dragHandle,zIndex:j.z,parentId:w.parentId,...U})})})}var yS=L.memo(mS);const vS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Gg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=De(vS,Qe),u=fS(t.onlyRenderVisibleElements),c=pS();return d.jsx("div",{className:"react-flow__nodes",style:Jl,children:u.map(h=>d.jsx(yS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Gg.displayName="NodeRenderer";const xS=L.memo(Gg);function wS(t){return De(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&h1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const _S=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},SS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ip={[is.Arrow]:_S,[is.ArrowClosed]:SS};function kS(t){const r=Ge();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(ip,t)?ip[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",mn.error009(t)),null)},[t])}const NS=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=kS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},Yg=({defaultColor:t,rfId:r})=>{const o=De(u=>u.edges),s=De(u=>u.defaultEdgeOptions),a=L.useMemo(()=>_1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(NS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Yg.displayName="MarkerDefinitions";var jS=L.memo(Yg);function Xg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:v,...x}){const[y,m]=L.useState({x:1,y:0,width:0,height:0}),_=nt(["react-flow__edge-textwrapper",v]),k=L.useRef(null);return L.useEffect(()=>{if(k.current){const b=k.current.getBBox();m({x:b.x,y:b.y,width:b.width,height:b.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-y.width/2} ${r-y.height/2})`,className:_,visibility:y.width?"visible":"hidden",...x,children:[a&&d.jsx("rect",{width:y.width+2*c[0],x:-c[0],y:-c[1],height:y.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:k,style:s,children:o}),p]}):null}Xg.displayName="EdgeText";const bS=L.memo(Xg);function ea({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:v=20,...x}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...x,d:t,fill:"none",className:nt(["react-flow__edge-path",x.className])}),v?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:v,className:"react-flow__edge-interaction"}):null,s&&pn(r)&&pn(o)?d.jsx(bS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function op({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function qg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top}){const[c,h]=op({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,v]=op({pos:u,x1:s,y1:a,x2:t,y2:r}),[x,y,m,_]=yg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:v});return[`M${t},${r} C${c},${h} ${p},${v} ${s},${a}`,x,y,m,_]}function Kg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,interactionWidth:N})=>{const[P,w,j]=qg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),$=t.isInternal?void 0:r;return d.jsx(ea,{id:$,path:P,labelX:w,labelY:j,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,interactionWidth:N})})}const ES=Kg({isInternal:!1}),Qg=Kg({isInternal:!0});ES.displayName="SimpleBezierEdge";Qg.displayName="SimpleBezierEdgeInternal";function Zg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,sourcePosition:_=Se.Bottom,targetPosition:k=Se.Top,markerEnd:b,markerStart:E,pathOptions:N,interactionWidth:P})=>{const[w,j,$]=lc({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:N==null?void 0:N.borderRadius,offset:N==null?void 0:N.offset,stepPosition:N==null?void 0:N.stepPosition}),z=t.isInternal?void 0:r;return d.jsx(ea,{id:z,path:w,labelX:j,labelY:$,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:b,markerStart:E,interactionWidth:P})})}const Jg=Zg({isInternal:!1}),em=Zg({isInternal:!0});Jg.displayName="SmoothStepEdge";em.displayName="SmoothStepEdgeInternal";function tm(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(Jg,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const CS=tm({isInternal:!1}),nm=tm({isInternal:!0});CS.displayName="StepEdge";nm.displayName="StepEdgeInternal";function rm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:b})=>{const[E,N,P]=wg({sourceX:o,sourceY:s,targetX:a,targetY:u}),w=t.isInternal?void 0:r;return d.jsx(ea,{id:w,path:E,labelX:N,labelY:P,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:b})})}const MS=rm({isInternal:!1}),im=rm({isInternal:!0});MS.displayName="StraightEdge";im.displayName="StraightEdgeInternal";function om(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,pathOptions:N,interactionWidth:P})=>{const[w,j,$]=vg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:N==null?void 0:N.curvature}),z=t.isInternal?void 0:r;return d.jsx(ea,{id:z,path:w,labelX:j,labelY:$,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,interactionWidth:P})})}const PS=om({isInternal:!1}),sm=om({isInternal:!0});PS.displayName="BezierEdge";sm.displayName="BezierEdgeInternal";const sp={default:sm,straight:im,step:nm,smoothstep:em,simplebezier:Qg},lp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},IS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,RS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,ap="react-flow__edgeupdater";function up({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:nt([ap,`${ap}-${h}`]),cx:IS(r,s,t),cy:RS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function TS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:v,onReconnectStart:x,onReconnectEnd:y,setReconnecting:m,setUpdateHover:_}){const k=Ge(),b=(j,$)=>{if(j.button!==0)return;const{autoPanOnConnect:z,domNode:B,connectionMode:Y,connectionRadius:Q,lib:ne,onConnectStart:ee,cancelConnection:te,nodeLookup:q,rfId:C,panBy:V,updateConnection:W}=k.getState(),U=$.type==="target",M=(R,A)=>{m(!1),y==null||y(R,o,$.type,A)},D=R=>v==null?void 0:v(o,R),F=(R,A)=>{m(!0),x==null||x(j,o,$.type),ee==null||ee(R,A)};cc.onPointerDown(j.nativeEvent,{autoPanOnConnect:z,connectionMode:Y,connectionRadius:Q,domNode:B,handleId:$.id,nodeId:$.nodeId,nodeLookup:q,isTarget:U,edgeUpdaterType:$.type,lib:ne,flowId:C,cancelConnection:te,panBy:V,isValidConnection:(...R)=>{var A,ie;return((ie=(A=k.getState()).isValidConnection)==null?void 0:ie.call(A,...R))??!0},onConnect:D,onConnectStart:F,onConnectEnd:(...R)=>{var A,ie;return(ie=(A=k.getState()).onConnectEnd)==null?void 0:ie.call(A,...R)},onReconnectEnd:M,updateConnection:W,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},E=j=>b(j,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),N=j=>b(j,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),P=()=>_(!0),w=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(up,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:E,onMouseEnter:P,onMouseOut:w,type:"source"}),(t===!0||t==="target")&&d.jsx(up,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:N,onMouseEnter:P,onMouseOut:w,type:"target"})]})}function LS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,rfId:k,edgeTypes:b,noPanClassName:E,onError:N,disableKeyboardA11y:P}){let w=De(ve=>ve.edgeLookup.get(t));const j=De(ve=>ve.defaultEdgeOptions);w=j?{...j,...w}:w;let $=w.type||"default",z=(b==null?void 0:b[$])||sp[$];z===void 0&&(N==null||N("011",mn.error011($)),$="default",z=(b==null?void 0:b.default)||sp.default);const B=!!(w.focusable||r&&typeof w.focusable>"u"),Y=typeof y<"u"&&(w.reconnectable||o&&typeof w.reconnectable>"u"),Q=!!(w.selectable||s&&typeof w.selectable>"u"),ne=L.useRef(null),[ee,te]=L.useState(!1),[q,C]=L.useState(!1),V=Ge(),{zIndex:W=w.zIndex,sourceX:U,sourceY:M,targetX:D,targetY:F,sourcePosition:R,targetPosition:A}=De(L.useCallback(ve=>{const re=ve.nodeLookup.get(w.source),Ne=ve.nodeLookup.get(w.target);if(!re||!Ne)return lp;const Me=w1({id:t,sourceNode:re,targetNode:Ne,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:ve.connectionMode,onError:N}),Te=f1({selected:w.selected,zIndex:w.zIndex,sourceNode:re,targetNode:Ne,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||lp,zIndex:Te}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex,N]),Qe),ie=L.useMemo(()=>w.markerStart?`url('#${ac(w.markerStart,k)}')`:void 0,[w.markerStart,k]),oe=L.useMemo(()=>w.markerEnd?`url('#${ac(w.markerEnd,k)}')`:void 0,[w.markerEnd,k]);if(w.hidden||U===null||M===null||D===null||F===null)return null;const fe=ve=>{var Te;const{addSelectedEdges:re,unselectNodesAndEdges:Ne,multiSelectionActive:Me}=V.getState();Q&&(V.setState({nodesSelectionActive:!1}),w.selected&&Me?(Ne({nodes:[],edges:[w]}),(Te=ne.current)==null||Te.blur()):re([t])),a&&a(ve,w)},he=u?ve=>{u(ve,{...w})}:void 0,pe=c?ve=>{c(ve,{...w})}:void 0,Z=h?ve=>{h(ve,{...w})}:void 0,se=p?ve=>{p(ve,{...w})}:void 0,me=v?ve=>{v(ve,{...w})}:void 0,ke=ve=>{var re;if(!P&&ng.includes(ve.key)&&Q){const{unselectNodesAndEdges:Ne,addSelectedEdges:Me}=V.getState();ve.key==="Escape"?((re=ne.current)==null||re.blur(),Ne({edges:[w]})):Me([t])}};return d.jsx("svg",{style:{zIndex:W},children:d.jsxs("g",{className:nt(["react-flow__edge",`react-flow__edge-${$}`,w.className,E,{selected:w.selected,animated:w.animated,inactive:!Q&&!a,updating:ee,selectable:Q}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:Z,onMouseMove:se,onMouseLeave:me,onKeyDown:B?ke:void 0,tabIndex:B?0:void 0,role:w.ariaRole??(B?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":B?`${Ag}-${k}`:void 0,ref:ne,...w.domAttributes,children:[!q&&d.jsx(z,{id:t,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:Q,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:U,sourceY:M,targetX:D,targetY:F,sourcePosition:R,targetPosition:A,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),Y&&d.jsx(TS,{edge:w,isReconnectable:Y,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,sourceX:U,sourceY:M,targetX:D,targetY:F,sourcePosition:R,targetPosition:A,setUpdateHover:te,setReconnecting:C})]})})}var AS=L.memo(LS);const $S=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function lm({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:v,onEdgeClick:x,reconnectRadius:y,onEdgeDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:b}){const{edgesFocusable:E,edgesReconnectable:N,elementsSelectable:P,onError:w}=De($S,Qe),j=wS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(jS,{defaultColor:t,rfId:o}),j.map($=>d.jsx(AS,{id:$,edgesFocusable:E,edgesReconnectable:N,elementsSelectable:P,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,onClick:x,reconnectRadius:y,onDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:w,edgeTypes:s,disableKeyboardA11y:b},$))]})}lm.displayName="EdgeRenderer";const zS=L.memo(lm),cp=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function DS({children:t}){const r=Ge(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return Og(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=cp(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:cp(s)},children:t})}function OS(t){const r=Zl(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const FS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function HS(t){const r=De(FS),o=Ge();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function BS(t){return t.connection.inProgress?{...t.connection,to:ps(t.connection.to,t.transform)}:{...t.connection}}function VS(t){return BS}function WS(t){const r=VS();return De(r,Qe)}const US=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function GS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=De(US,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:nt(["react-flow__connection",og(h)]),children:d.jsx(am,{style:r,type:o,CustomComponent:s,isValid:h})})})}const am=({style:t,type:r=Lr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:v,toNode:x,toHandle:y,toPosition:m,pointer:_}=WS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:v.x,toY:v.y,fromPosition:p,toPosition:m,connectionStatus:og(s),toNode:x,toHandle:y,pointer:_});let k="";const b={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:v.x,targetY:v.y,targetPosition:m};switch(r){case Lr.Bezier:[k]=vg(b);break;case Lr.SimpleBezier:[k]=qg(b);break;case Lr.Step:[k]=lc({...b,borderRadius:0});break;case Lr.SmoothStep:[k]=lc(b);break;default:[k]=wg(b)}return d.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};am.displayName="ConnectionLine";const YS={};function dp(t=YS){L.useRef(t),Ge(),L.useEffect(()=>{},[t])}function XS(){Ge(),L.useRef(!1),L.useEffect(()=>{},[])}function um({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,onSelectionContextMenu:y,onSelectionStart:m,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:b,connectionLineComponent:E,connectionLineContainerStyle:N,selectionKeyCode:P,selectionOnDrag:w,selectionMode:j,multiSelectionKeyCode:$,panActivationKeyCode:z,zoomActivationKeyCode:B,deleteKeyCode:Y,onlyRenderVisibleElements:Q,elementsSelectable:ne,defaultViewport:ee,translateExtent:te,minZoom:q,maxZoom:C,preventScrolling:V,defaultMarkerColor:W,zoomOnScroll:U,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:F,panOnScrollMode:R,zoomOnDoubleClick:A,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneScroll:se,onPaneContextMenu:me,paneClickDistance:ke,nodeClickDistance:ve,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,noDragClassName:Ye,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,viewport:ut,onViewportChange:Je,nodesDraggable:An}){return dp(t),dp(r),XS(),OS(o),HS(ut),d.jsx(cS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneContextMenu:me,onPaneScroll:se,paneClickDistance:ke,deleteKeyCode:Y,selectionKeyCode:P,selectionOnDrag:w,selectionMode:j,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:$,panActivationKeyCode:z,zoomActivationKeyCode:B,elementsSelectable:ne,zoomOnScroll:U,zoomOnPinch:M,zoomOnDoubleClick:A,panOnScroll:D,panOnScrollSpeed:F,panOnScrollMode:R,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:ee,translateExtent:te,minZoom:q,maxZoom:C,onSelectionContextMenu:y,preventScrolling:V,noDragClassName:Ye,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,onViewportChange:Je,isControlledViewport:!!ut,children:d.jsxs(DS,{children:[d.jsx(zS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,onlyRenderVisibleElements:Q,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,defaultMarkerColor:W,noPanClassName:qt,disableKeyboardA11y:gt,rfId:Pt}),d.jsx(GS,{style:b,type:k,component:E,containerStyle:N}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(xS,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,nodeClickDistance:ve,onlyRenderVisibleElements:Q,noPanClassName:qt,noDragClassName:Ye,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,nodesDraggable:An}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}um.displayName="GraphView";const qS=L.memo(um),KS=dg(),fp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:v=2,nodeOrigin:x,nodeExtent:y,zIndexMode:m="basic"}={})=>{const _=new Map,k=new Map,b=new Map,E=new Map,N=s??r??[],P=o??t??[],w=x??[0,0],j=y??ns;kg(b,E,N);const{nodesInitialized:$}=uc(P,_,k,{nodeOrigin:w,nodeExtent:j,zIndexMode:m});let z=[0,0,1];if(c&&a&&u){const B=fs(_,{filter:ee=>!!((ee.width||ee.initialWidth)&&(ee.height||ee.initialHeight))}),{x:Y,y:Q,zoom:ne}=Nc(B,a,u,p,v,(h==null?void 0:h.padding)??.1);z=[Y,Q,ne]}return{rfId:"1",width:a??0,height:u??0,transform:z,nodes:P,nodesInitialized:$,nodeLookup:_,parentLookup:k,edges:N,edgeLookup:E,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:v,translateExtent:ns,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Zi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...ig},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:KS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:rg,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},QS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m})=>u_((_,k)=>{async function b(){const{nodeLookup:E,panZoom:N,fitViewOptions:P,fitViewResolver:w,width:j,height:$,minZoom:z,maxZoom:B}=k();N&&(await o1({nodes:E,width:j,height:$,panZoom:N,minZoom:z,maxZoom:B},P),w==null||w.resolve(!0),_({fitViewResolver:null}))}return{...fp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,defaultNodes:o,defaultEdges:s,zIndexMode:m}),setNodes:E=>{const{nodeLookup:N,parentLookup:P,nodeOrigin:w,nodeExtent:j,elevateNodesOnSelect:$,fitViewQueued:z,zIndexMode:B,nodesSelectionActive:Y}=k(),{nodesInitialized:Q,hasSelectedNodes:ne}=uc(E,N,P,{nodeOrigin:w,nodeExtent:j,elevateNodesOnSelect:$,checkEquality:!0,zIndexMode:B}),ee=Y&≠z&&Q?(b(),_({nodes:E,nodesInitialized:Q,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:ee})):_({nodes:E,nodesInitialized:Q,nodesSelectionActive:ee})},setEdges:E=>{const{connectionLookup:N,edgeLookup:P}=k();kg(N,P,E),_({edges:E})},setDefaultNodesAndEdges:(E,N)=>{if(E){const{setNodes:P}=k();P(E),_({hasDefaultNodes:!0})}if(N){const{setEdges:P}=k();P(N),_({hasDefaultEdges:!0})}},updateNodeInternals:E=>{const{triggerNodeChanges:N,nodeLookup:P,parentLookup:w,domNode:j,nodeOrigin:$,nodeExtent:z,debug:B,fitViewQueued:Y,zIndexMode:Q}=k(),{changes:ne,updatedInternals:ee}=C1(E,P,w,j,$,z,Q);ee&&(N1(P,w,{nodeOrigin:$,nodeExtent:z,zIndexMode:Q}),Y?(b(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(ne==null?void 0:ne.length)>0&&(B&&console.log("React Flow: trigger node changes",ne),N==null||N(ne)))},updateNodePositions:(E,N=!1)=>{const P=[];let w=[];const{nodeLookup:j,triggerNodeChanges:$,connection:z,updateConnection:B,onNodesChangeMiddlewareMap:Y}=k();for(const[Q,ne]of E){const ee=j.get(Q),te=!!(ee!=null&&ee.expandParent&&(ee!=null&&ee.parentId)&&(ne!=null&&ne.position)),q={id:Q,type:"position",position:te?{x:Math.max(0,ne.position.x),y:Math.max(0,ne.position.y)}:ne.position,dragging:N};if(ee&&z.inProgress&&z.fromNode.id===ee.id){const C=mi(ee,z.fromHandle,Se.Left,!0);B({...z,from:C})}te&&ee.parentId&&P.push({id:Q,parentId:ee.parentId,rect:{...ne.internals.positionAbsolute,width:ne.measured.width??0,height:ne.measured.height??0}}),w.push(q)}if(P.length>0){const{parentLookup:Q,nodeOrigin:ne}=k(),ee=Pc(P,j,Q,ne);w.push(...ee)}for(const Q of Y.values())w=Q(w);$(w)},triggerNodeChanges:E=>{const{onNodesChange:N,setNodes:P,nodes:w,hasDefaultNodes:j,debug:$}=k();if(E!=null&&E.length){if(j){const z=P_(E,w);P(z)}$&&console.log("React Flow: trigger node changes",E),N==null||N(E)}},triggerEdgeChanges:E=>{const{onEdgesChange:N,setEdges:P,edges:w,hasDefaultEdges:j,debug:$}=k();if(E!=null&&E.length){if(j){const z=I_(E,w);P(z)}$&&console.log("React Flow: trigger edge changes",E),N==null||N(E)}},addSelectedNodes:E=>{const{multiSelectionActive:N,edgeLookup:P,nodeLookup:w,triggerNodeChanges:j,triggerEdgeChanges:$}=k();if(N){const z=E.map(B=>ai(B,!0));j(z);return}j(Yi(w,new Set([...E]),!0)),$(Yi(P))},addSelectedEdges:E=>{const{multiSelectionActive:N,edgeLookup:P,nodeLookup:w,triggerNodeChanges:j,triggerEdgeChanges:$}=k();if(N){const z=E.map(B=>ai(B,!0));$(z);return}$(Yi(P,new Set([...E]))),j(Yi(w,new Set,!0))},unselectNodesAndEdges:({nodes:E,edges:N}={})=>{const{edges:P,nodes:w,nodeLookup:j,triggerNodeChanges:$,triggerEdgeChanges:z}=k(),B=E||w,Y=N||P,Q=[];for(const ee of B){if(!ee.selected)continue;const te=j.get(ee.id);te&&(te.selected=!1),Q.push(ai(ee.id,!1))}const ne=[];for(const ee of Y)ee.selected&&ne.push(ai(ee.id,!1));$(Q),z(ne)},setMinZoom:E=>{const{panZoom:N,maxZoom:P}=k();N==null||N.setScaleExtent([E,P]),_({minZoom:E})},setMaxZoom:E=>{const{panZoom:N,minZoom:P}=k();N==null||N.setScaleExtent([P,E]),_({maxZoom:E})},setTranslateExtent:E=>{var N;(N=k().panZoom)==null||N.setTranslateExtent(E),_({translateExtent:E})},resetSelectedElements:()=>{const{edges:E,nodes:N,triggerNodeChanges:P,triggerEdgeChanges:w,elementsSelectable:j}=k();if(!j)return;const $=N.reduce((B,Y)=>Y.selected?[...B,ai(Y.id,!1)]:B,[]),z=E.reduce((B,Y)=>Y.selected?[...B,ai(Y.id,!1)]:B,[]);P($),w(z)},setNodeExtent:E=>{const{nodes:N,nodeLookup:P,parentLookup:w,nodeOrigin:j,elevateNodesOnSelect:$,nodeExtent:z,zIndexMode:B}=k();E[0][0]===z[0][0]&&E[0][1]===z[0][1]&&E[1][0]===z[1][0]&&E[1][1]===z[1][1]||(uc(N,P,w,{nodeOrigin:j,nodeExtent:E,elevateNodesOnSelect:$,checkEquality:!1,zIndexMode:B}),_({nodeExtent:E}))},panBy:E=>{const{transform:N,width:P,height:w,panZoom:j,translateExtent:$}=k();return M1({delta:E,panZoom:j,transform:N,translateExtent:$,width:P,height:w})},setCenter:async(E,N,P)=>{const{width:w,height:j,maxZoom:$,panZoom:z}=k();if(!z)return!1;const B=typeof(P==null?void 0:P.zoom)<"u"?P.zoom:$;return await z.setViewport({x:w/2-E*B,y:j/2-N*B,zoom:B},{duration:P==null?void 0:P.duration,ease:P==null?void 0:P.ease,interpolate:P==null?void 0:P.interpolate}),!0},cancelConnection:()=>{_({connection:{...ig}})},updateConnection:E=>{_({connection:E})},reset:()=>_({...fp()})}},Object.is);function cm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m,children:_}){const[k]=L.useState(()=>QS({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:v,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:x,nodeExtent:y,zIndexMode:m}));return d.jsx(c_,{value:k,children:d.jsx($_,{children:d.jsx(Q_,{children:_})})})}function ZS({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:v,maxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_}){return L.useContext(Kl)?d.jsx(d.Fragment,{children:t}):d.jsx(cm,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:v,initialMaxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_,children:t})}const JS={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function ek({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:v,onMove:x,onMoveStart:y,onMoveEnd:m,onConnect:_,onConnectStart:k,onConnectEnd:b,onClickConnectStart:E,onClickConnectEnd:N,onNodeMouseEnter:P,onNodeMouseMove:w,onNodeMouseLeave:j,onNodeContextMenu:$,onNodeDoubleClick:z,onNodeDragStart:B,onNodeDrag:Y,onNodeDragStop:Q,onNodesDelete:ne,onEdgesDelete:ee,onDelete:te,onSelectionChange:q,onSelectionDragStart:C,onSelectionDrag:V,onSelectionDragStop:W,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:F,connectionMode:R,connectionLineType:A=Lr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:Z=!1,selectionMode:se=rs.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:ke=ss()?"Meta":"Control",zoomActivationKeyCode:ve=ss()?"Meta":"Control",snapToGrid:re,snapGrid:Ne,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Te,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,nodeOrigin:Ye=$g,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt=!0,defaultViewport:mt=k_,minZoom:Pt=.5,maxZoom:ut=2,translateExtent:Je=ns,preventScrolling:An=!0,nodeExtent:Ot,defaultMarkerColor:xn="#b1b1b7",zoomOnScroll:io=!0,zoomOnPinch:$n=!0,panOnScroll:vi=!1,panOnScrollSpeed:or=.5,panOnScrollMode:$r=di.Free,zoomOnDoubleClick:zn=!0,panOnDrag:zr=!0,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn=1,nodeClickDistance:Fn=0,children:_n,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn=10,onNodesChange:Ht,onEdgesChange:Or,noDragClassName:nn="nodrag",noWheelClassName:Fr="nowheel",noPanClassName:yt="nopan",fitView:Hn,fitViewOptions:ur,connectOnClick:oo,attributionPosition:It,proOptions:Bn,defaultEdgeOptions:Hr,elevateNodesOnSelect:jn=!0,elevateEdgesOnSelect:Br=!1,disableKeyboardA11y:xi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:so,autoPanOnSelection:Vr=!0,autoPanSpeed:wi,connectionRadius:cr,isValidConnection:lo,onError:dr,style:Vn,id:bt,nodeDragThreshold:Wr,connectionDragThreshold:Et,viewport:ao,onViewportChange:Ur,width:Gr,height:Wn,colorMode:Un="light",debug:bn,onScroll:Bt,ariaLabelConfig:_i,zIndexMode:Yr="basic",...fr},hr){const Gn=bt||"1",En=E_(Un),uo=L.useCallback(pr=>{pr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Bt==null||Bt(pr)},[Bt]);return d.jsx("div",{"data-testid":"rf__wrapper",...fr,onScroll:uo,style:{...Vn,...JS},ref:hr,className:nt(["react-flow",a,En]),id:bt,role:"application",children:d.jsxs(ZS,{nodes:t,edges:r,width:Gr,height:Wn,fitView:Hn,fitViewOptions:ur,minZoom:Pt,maxZoom:ut,nodeOrigin:Ye,nodeExtent:Ot,zIndexMode:Yr,children:[d.jsx(b_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:k,onConnectEnd:b,onClickConnectStart:E,onClickConnectEnd:N,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt,elevateNodesOnSelect:jn,elevateEdgesOnSelect:Br,minZoom:Pt,maxZoom:ut,nodeExtent:Ot,onNodesChange:Ht,onEdgesChange:Or,snapToGrid:re,snapGrid:Ne,connectionMode:R,translateExtent:Je,connectOnClick:oo,defaultEdgeOptions:Hr,fitView:Hn,fitViewOptions:ur,onNodesDelete:ne,onEdgesDelete:ee,onDelete:te,onNodeDragStart:B,onNodeDrag:Y,onNodeDragStop:Q,onSelectionDrag:V,onSelectionDragStart:C,onSelectionDragStop:W,onMove:x,onMoveStart:y,onMoveEnd:m,noPanClassName:yt,nodeOrigin:Ye,rfId:Gn,autoPanOnConnect:Ve,autoPanOnNodeDrag:so,autoPanSpeed:wi,onError:dr,connectionRadius:cr,isValidConnection:lo,selectNodesOnDrag:Te,nodeDragThreshold:Wr,connectionDragThreshold:Et,onBeforeDelete:F,debug:bn,ariaLabelConfig:_i,zIndexMode:Yr}),d.jsx(qS,{onInit:v,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:P,onNodeMouseMove:w,onNodeMouseLeave:j,onNodeContextMenu:$,onNodeDoubleClick:z,nodeTypes:u,edgeTypes:c,connectionLineType:A,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:Z,selectionMode:se,deleteKeyCode:he,multiSelectionKeyCode:ke,panActivationKeyCode:me,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:mt,translateExtent:Je,minZoom:Pt,maxZoom:ut,preventScrolling:An,zoomOnScroll:io,zoomOnPinch:$n,zoomOnDoubleClick:zn,panOnScroll:vi,panOnScrollSpeed:or,panOnScrollMode:$r,panOnDrag:zr,autoPanOnSelection:Vr,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn,nodeClickDistance:Fn,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn,defaultMarkerColor:xn,noDragClassName:nn,noWheelClassName:Fr,noPanClassName:yt,rfId:Gn,disableKeyboardA11y:xi,nodeExtent:Ot,viewport:ao,onViewportChange:Ur,nodesDraggable:$e}),d.jsx(S_,{onSelectionChange:q}),_n,d.jsx(y_,{proOptions:Bn,position:It}),d.jsx(m_,{rfId:Gn,disableKeyboardA11y:xi})]})})}var tk=Dg(ek);function nk({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:nt(["react-flow__background-pattern",o,s])})}function rk({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:nt(["react-flow__background-pattern","dots",r])})}var Ar;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Ar||(Ar={}));const ik={[Ar.Dots]:1,[Ar.Lines]:1,[Ar.Cross]:6},ok=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function dm({id:t,variant:r=Ar.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:v,patternClassName:x}){const y=L.useRef(null),{transform:m,patternId:_}=De(ok,Qe),k=s||ik[r],b=r===Ar.Dots,E=r===Ar.Cross,N=Array.isArray(o)?o:[o,o],P=[N[0]*m[2]||1,N[1]*m[2]||1],w=k*m[2],j=Array.isArray(u)?u:[u,u],$=E?[w,w]:P,z=[j[0]*m[2]+$[0]/2,j[1]*m[2]+$[1]/2],B=`${_}${t||""}`;return d.jsxs("svg",{className:nt(["react-flow__background",v]),style:{...p,...Jl,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:y,"data-testid":"rf__background",children:[d.jsx("pattern",{id:B,x:m[0]%P[0],y:m[1]%P[1],width:P[0],height:P[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${z[0]},-${z[1]})`,children:b?d.jsx(rk,{radius:w/2,className:x}):d.jsx(nk,{dimensions:$,lineWidth:a,variant:r,className:x})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${B})`})]})}dm.displayName="Background";const sk=L.memo(dm);function lk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ak(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function uk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 ck(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 kl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:nt(["react-flow__controls-button",r]),...o,children:t})}const fk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function fm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:v,children:x,position:y="bottom-left",orientation:m="vertical","aria-label":_}){const k=Ge(),{isInteractive:b,minZoomReached:E,maxZoomReached:N,ariaLabelConfig:P}=De(fk,Qe),{zoomIn:w,zoomOut:j,fitView:$}=Zl(),z=()=>{w(),u==null||u()},B=()=>{j(),c==null||c()},Y=()=>{$(a),h==null||h()},Q=()=>{k.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),p==null||p(!b)},ne=m==="horizontal"?"horizontal":"vertical";return d.jsxs(Ql,{className:nt(["react-flow__controls",ne,v]),position:y,style:t,"data-testid":"rf__controls","aria-label":_??P["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(kl,{onClick:z,className:"react-flow__controls-zoomin",title:P["controls.zoomIn.ariaLabel"],"aria-label":P["controls.zoomIn.ariaLabel"],disabled:N,children:d.jsx(lk,{})}),d.jsx(kl,{onClick:B,className:"react-flow__controls-zoomout",title:P["controls.zoomOut.ariaLabel"],"aria-label":P["controls.zoomOut.ariaLabel"],disabled:E,children:d.jsx(ak,{})})]}),o&&d.jsx(kl,{className:"react-flow__controls-fitview",onClick:Y,title:P["controls.fitView.ariaLabel"],"aria-label":P["controls.fitView.ariaLabel"],children:d.jsx(uk,{})}),s&&d.jsx(kl,{className:"react-flow__controls-interactive",onClick:Q,title:P["controls.interactive.ariaLabel"],"aria-label":P["controls.interactive.ariaLabel"],children:b?d.jsx(dk,{}):d.jsx(ck,{})}),x]})}fm.displayName="Controls";const hk=L.memo(fm);function pk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:v,borderRadius:x,shapeRendering:y,selected:m,onClick:_}){const{background:k,backgroundColor:b}=u||{},E=c||k||b;return d.jsx("rect",{className:nt(["react-flow__minimap-node",{selected:m},v]),x:r,y:o,rx:x,ry:x,width:s,height:a,style:{fill:E,stroke:h,strokeWidth:p},shapeRendering:y,onClick:_?N=>_(N,t):void 0})}const gk=L.memo(pk),mk=t=>t.nodes.map(r=>r.id),Yu=t=>t instanceof Function?t:()=>t;function yk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=gk,onClick:c}){const h=De(mk,Qe),p=Yu(r),v=Yu(t),x=Yu(o),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(m=>d.jsx(xk,{id:m,nodeColorFunc:p,nodeStrokeColorFunc:v,nodeClassNameFunc:x,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:y},m))})}function vk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:v,x,y,width:m,height:_}=De(k=>{const b=k.nodeLookup.get(t);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const E=b.internals.userNode,{x:N,y:P}=b.internals.positionAbsolute,{width:w,height:j}=vn(E);return{node:E,x:N,y:P,width:w,height:j}},Qe);return!v||v.hidden||!fg(v)?null:d.jsx(h,{x,y,width:m,height:_,style:v.style,selected:!!v.selected,className:s(v),color:r(v),borderRadius:a,strokeColor:o(v),strokeWidth:u,shapeRendering:c,onClick:p,id:v.id})}const xk=L.memo(vk);var wk=L.memo(yk);const _k=200,Sk=150,kk=t=>!t.hidden,Nk=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?ug(fs(t.nodeLookup,{filter:kk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},hp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,jk=(t,r)=>hp(t.viewBB,r.viewBB)&&hp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,bk="react-flow__minimap-desc";function hm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:v,maskStrokeColor:x,maskStrokeWidth:y,position:m="bottom-right",onClick:_,onNodeClick:k,pannable:b=!1,zoomable:E=!1,ariaLabel:N,inversePan:P,zoomStep:w=1,offsetScale:j=5}){const $=Ge(),z=L.useRef(null),{boundingRect:B,viewBB:Y,rfId:Q,panZoom:ne,translateExtent:ee,flowWidth:te,flowHeight:q,ariaLabelConfig:C}=De(Nk,jk),V=(t==null?void 0:t.width)??_k,W=(t==null?void 0:t.height)??Sk,U=B.width/V,M=B.height/W,D=Math.max(U,M),F=D*V,R=D*W,A=j*D,ie=B.x-(F-B.width)/2-A,oe=B.y-(R-B.height)/2-A,fe=F+A*2,he=R+A*2,pe=`${bk}-${Q}`,Z=L.useRef(0),se=L.useRef();Z.current=D,L.useEffect(()=>{if(z.current&&ne)return se.current=D1({domNode:z.current,panZoom:ne,getTransform:()=>$.getState().transform,getViewScale:()=>Z.current}),()=>{var re;(re=se.current)==null||re.destroy()}},[ne]),L.useEffect(()=>{var re;(re=se.current)==null||re.update({translateExtent:ee,width:te,height:q,inversePan:P,pannable:b,zoomStep:w,zoomable:E})},[b,E,P,w,ee,te,q]);const me=_?re=>{var Te;const[Ne,Me]=((Te=se.current)==null?void 0:Te.pointer(re))||[0,0];_(re,{x:Ne,y:Me})}:void 0,ke=k?L.useCallback((re,Ne)=>{const Me=$.getState().nodeLookup.get(Ne).internals.userNode;k(re,Me)},[]):void 0,ve=N??C["minimap.ariaLabel"];return d.jsx(Ql,{position:m,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof v=="string"?v:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof y=="number"?y*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:nt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:V,height:W,viewBox:`${ie} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:z,onClick:me,children:[ve&&d.jsx("title",{id:pe,children:ve}),d.jsx(wk,{onClick:ke,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-A},${oe-A}h${fe+A*2}v${he+A*2}h${-fe-A*2}z - M${Y.x},${Y.y}h${Y.width}v${Y.height}h${-Y.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}hm.displayName="MiniMap";const Ek=L.memo(hm),Ck=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Mk={[to.Line]:"right",[to.Handle]:"bottom-right"};function Pk({nodeId:t,position:r,variant:o=to.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:v=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:y=!1,resizeDirection:m,autoScale:_=!0,shouldResize:k,onResizeStart:b,onResize:E,onResizeEnd:N}){const P=Vg(),w=typeof t=="string"?t:P,j=Ge(),$=L.useRef(null),z=o===to.Handle,B=De(L.useCallback(Ck(z&&_),[z,_]),Qe),Y=L.useRef(null),Q=r??Mk[o];L.useEffect(()=>{if(!(!$.current||!w))return Y.current||(Y.current=Q1({domNode:$.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:ee,transform:te,snapGrid:q,snapToGrid:C,nodeOrigin:V,domNode:W}=j.getState();return{nodeLookup:ee,transform:te,snapGrid:q,snapToGrid:C,nodeOrigin:V,paneDomNode:W}},onChange:(ee,te)=>{const{triggerNodeChanges:q,nodeLookup:C,parentLookup:V,nodeOrigin:W}=j.getState(),U=[],M={x:ee.x,y:ee.y},D=C.get(w);if(D&&D.expandParent&&D.parentId){const F=D.origin??W,R=ee.width??D.measured.width??0,A=ee.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:R,height:A,...hg({x:ee.x??D.position.x,y:ee.y??D.position.y},{width:R,height:A},D.parentId,C,F)}},oe=Pc([ie],C,V,W);U.push(...oe),M.x=ee.x?Math.max(F[0]*R,ee.x):void 0,M.y=ee.y?Math.max(F[1]*A,ee.y):void 0}if(M.x!==void 0&&M.y!==void 0){const F={id:w,type:"position",position:{...M}};U.push(F)}if(ee.width!==void 0&&ee.height!==void 0){const R={id:w,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:ee.width,height:ee.height}};U.push(R)}for(const F of te){const R={...F,type:"position"};U.push(R)}q(U)},onEnd:({width:ee,height:te})=>{const q={id:w,type:"dimensions",resizing:!1,dimensions:{width:ee,height:te}};j.getState().triggerNodeChanges([q])}})),Y.current.update({controlPosition:Q,boundaries:{minWidth:h,minHeight:p,maxWidth:v,maxHeight:x},keepAspectRatio:y,resizeDirection:m,onResizeStart:b,onResize:E,onResizeEnd:N,shouldResize:k}),()=>{var ee;(ee=Y.current)==null||ee.destroy()}},[Q,h,p,v,x,y,b,E,N,k]);const ne=Q.split("-");return d.jsx("div",{className:nt(["react-flow__resize-control","nodrag",...ne,o,s]),ref:$,style:{...a,scale:B,...c&&{[z?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Pk);const Ik={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function ta(t){return Ik[t]??8}const fc=208,hc=64,Rk=88,Tk=28,Lk=8;function Ak(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function $k(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const N of t){const P=ta(N.type),w=s.get(P)??[];w.push(N),s.set(P,w)}const u=[...s.keys()].sort((N,P)=>N-P).map(N=>[...s.get(N)??[]].sort((P,w)=>P.name.localeCompare(w.name)||P.id.localeCompare(w.id))),c=new Set(t.map(N=>N.id)),h=new Map,p=new Map;for(const N of t)h.set(N.id,[]),p.set(N.id,[]);for(const N of r)!c.has(N.src)||!c.has(N.dst)||N.src===N.dst||(p.get(N.src).push(N.dst),h.get(N.dst).push(N.src));const v=new Map;u.forEach((N,P)=>{for(const w of N)v.set(w.id,P)});const x=new Map,y=()=>{for(const N of u)N.forEach((P,w)=>x.set(P.id,w))};y();const m=(N,P)=>{const w=N.map((j,$)=>{const z=P(j.id).map(Y=>x.get(Y)).filter(Y=>Y!==void 0),B=Ak(z);return{n:j,bary:Number.isNaN(B)?$:B,name:j.name,id:j.id}});return w.sort((j,$)=>j.bary-$.bary||j.name.localeCompare($.name)||j.id.localeCompare($.id)),w.map(j=>j.n)},_=N=>P=>v.get(P)===N;for(let N=0;N(h.get(w)??[]).filter(_(P-1))),y();for(let P=u.length-2;P>=0;P--)u[P]=m(u[P],w=>(p.get(w)??[]).filter(_(P+1))),y()}const k=fc+Rk,b=hc+Tk,E=Math.max(...u.map(N=>N.length),1);return u.forEach((N,P)=>{const w=(E-N.length)*b/2;N.forEach((j,$)=>{o.set(j.id,{x:P*k,y:w+$*b})})}),o}const zk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),pm=90,Dk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),pp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Ok=Math.PI*(3-Math.sqrt(5)),gm=220,Fk=26,Hk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function mm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function TN(t){return pp[t]?pp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Bk(t){return t>=pm?"3d":"2d"}function Vk(t){return t>=pm?"overview":"full"}function Wk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(mm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Dk.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Wk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Gk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function Yk(t,r,o,s){const a=new Set(t.map(b=>b.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const b of r){if(!a.has(b.src)||!a.has(b.dst))continue;const E=u.get(b.src)??[];E.push({dst:b.dst,id:b.id}),u.set(b.src,E);const N=c.get(b.dst)??[];N.push({src:b.src,id:b.id}),c.set(b.dst,N)}const h=new Set(t.filter(b=>zk.has(b.type)).map(b=>b.id)),p=h.size?h:a,v=new Set,x=[o];for(;x.length;){const b=x.pop();if(!v.has(b)){v.add(b);for(const E of u.get(b)??[])v.has(E.dst)||x.push(E.dst)}}const y=new Set([o]),m=[...p].filter(b=>v.has(b)),_=new Set(m);for(;m.length;){const b=m.pop();y.add(b);for(const E of c.get(b)??[])v.has(E.src)&&!_.has(E.src)&&(_.add(E.src),m.push(E.src))}const k=new Set;for(const b of r)y.has(b.src)&&y.has(b.dst)&&k.add(b.id);return{nodeIds:y,edgeIds:k}}function LN(t){const r=new Map;for(const s of t){const a=ta(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*gm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Fk*Math.sqrt(h+1),v=h*Ok;o.set(c.id,{x:u,y:p*Math.cos(v),z:p*Math.sin(v)})})}return o}function AN(t){const r=new Map;for(const o of t){const s=ta(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*gm,count:s}))}const Nl=16,Xk=12,qk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Kk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),gp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Qk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},mp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],yp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Zk=new Set(["looks_idempotent_on_pk","null","blank"]),Jk=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function eN(t){return gp[t]?gp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function tN(t,r,o){const s=new Map(r.map(m=>[m.id,m])),a=[];qk.has(t.type)&&a.push("sink"),Kk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(m=>m.dst===t.id),h=o.filter(m=>m.src===t.id),p=c.slice(0,Nl).map(m=>jl(m,s,m.src)),v=h.slice(0,Nl).map(m=>jl(m,s,m.dst)),x=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,y={type:t.type,typeLabel:Qo(ro(t.type)),layer:Hk[ta(t.type)]??"other",purpose:eN(t.type),name:t.name,qualifiedName:t.qualified_name,file:x,context:t.context,roles:a,facts:rN(u).filter(m=>!(m.key==="app"&&m.value===t.context)),inputs:p,outputs:v,extraInputs:Math.max(0,c.length-Nl),extraOutputs:Math.max(0,h.length-Nl),degreeIn:c.length,degreeOut:h.length,inputKinds:vp(c.map(m=>jl(m,s,m.src))),outputKinds:vp(h.map(m=>jl(m,s,m.dst))),pathSummary:""};return y.pathSummary=nN(y),y}function vp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function nN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function jl(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Qo(ro(s.type)):"",edgeType:t.type,edgeLabel:Qo(t.type),inferred:t.confidence<.8}}function rN(t){const r=[...mp.filter(a=>a in t),...Object.keys(t).filter(a=>!mp.includes(a)&&!yp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||yp.has(a)||Jk.has(a))continue;s.add(a);const u=iN(a,t[a]);u!=null&&o.push({key:a,label:Qk[a]??Qo(a),value:u})}return o}function iN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Zk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return oN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Xk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function oN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const sN=new Set,lN=L.lazy(()=>_0(()=>import("./LayeredGraph3D-D_cvtTgT.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),aN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function uN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(no,{type:"target",position:Se.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:ro(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Tr(t.name)}),d.jsx(no,{type:"source",position:Se.Right,isConnectable:!1})]})}const cN={load:uN},dN=new Set(["django","react","stitch","arch"]);function fN({topologyKey:t}){const{fitView:r}=Zl();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function hN(t,r,o=null,s={}){const a=new Map(t.map(p=>[p.id,p])),u=$k(t,r),c=t.map(p=>{var y;const v=((y=s.roles)==null?void 0:y[p.id])||[],x=!!s.testOverlay&&!v.includes("tested")&&!v.includes("untested")&&!v.includes("test")&&!v.includes("seed");return{id:p.id,type:"load",position:u.get(p.id)??{x:0,y:0},data:{name:p.name,type:p.type,file:p.file_path,roles:v,dim:x},selected:o===p.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:fc,height:hc,style:{width:fc,height:hc}}}),h=r.filter(p=>a.has(p.src)&&a.has(p.dst)).map(p=>{const v=aN[p.weight]||"var(--edge-cheap)",x=!!(o&&(p.src===o||p.dst===o));return{id:p.id,source:p.src,target:p.dst,type:"smoothstep",animated:p.weight==="critical",style:{stroke:v,strokeWidth:p.weight==="critical"?2.4:1.2,strokeDasharray:p.confidence<.8?"6 4":void 0},markerEnd:{type:is.ArrowClosed,width:14,height:14,color:v},label:x?p.type.replaceAll("_"," "):void 0,labelStyle:x?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:x?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:x?[3,5]:void 0,labelBgBorderRadius:x?4:void 0}});return{rfNodes:c,rfEdges:h}}function pN({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:v}){const x=tN(t,r,o);return L.useEffect(()=>{const y=m=>{m.key==="Escape"&&s()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:x.typeLabel}),d.jsx("div",{className:"inspector-roles",children:x.roles.map(y=>d.jsx("span",{className:"inspector-chip",children:y},y))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Tr(x.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:x.purpose}),x.context?d.jsx("div",{className:"muted",children:Tr(x.context)}):null,x.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Tr(x.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Tr(x.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",x.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[x.degreeIn," in · ",x.degreeOut," out"]}),x.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:x.pathSummary}):null,x.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:x.facts.map(y=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:y.label}),d.jsx("dd",{children:Tr(y.value)})]},y.key))}):null,d.jsx(xp,{title:"Inputs",testId:"graph-inspector-inputs",links:x.inputs,extra:x.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(xp,{title:"Outputs",testId:"graph-inspector-outputs",links:x.outputs,extra:x.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),a?d.jsx("p",{className:"whatif-hint","data-testid":"whatif-hint",children:v?"Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map.":"Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."}):null,d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",title:"Start a hypothetical walk from this node. Does not use Base/Head.",onClick:()=>a(t.id),children:"What if this changes"}):null,v?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",title:"Hide nodes that are not on a path from here to a sink. Does not start a new walk.",onClick:()=>v(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function xp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Xu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:v,repoPath:x,onOpenFile:y,pinnedId:m,onPin:_}){const[k,b]=L.useState(null),E=a!==void 0?a:k,N=re=>{a===void 0&&b(re),u==null||u(re)},[P,w]=L.useState(null),[j,$]=L.useState(null),[z,B]=L.useState(new Set(dN)),[Y,Q]=L.useState(!1),[ne,ee]=L.useState(""),[te,q]=L.useState(!1),C=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,V=P??Bk(t.length),W=j??Vk(t.length),U=Y?E:null,M=L.useMemo(()=>p?Yk(t,r,p):null,[t,r,p]),D=M?t.filter(re=>M.nodeIds.has(re.id)):t,F=M?r.filter(re=>M.edgeIds.has(re.id)):r,R=L.useMemo(()=>Uk(D,F,{detail:W,families:z,focusId:U,neighborhoodOnly:!!U}),[D,F,W,z,U]),A=L.useMemo(()=>`${R.nodes.map(re=>re.id).join("\0")}|${R.edges.map(re=>re.id).join("\0")}`,[R.nodes,R.edges]),ie=E?t.find(re=>re.id===E)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const re=hN(R.nodes,R.edges,E,{roles:c,testOverlay:h});return C&&(re.rfEdges=re.rfEdges.map(Ne=>({...Ne,animated:!1}))),re},[R.nodes,R.edges,E,C,c,h]);L.useEffect(()=>{if(!s)return;const re=t.find(Ne=>Ne.file_path===s);re&&N(re.id)},[s,t]);const he=L.useMemo(()=>Gk(t,ne),[t,ne]),pe=(re,Ne)=>{N(Ne.id)},Z=()=>{N(null),Q(!1)},se=ie?d.jsx(pN,{node:ie,nodes:t,edges:r,onClose:Z,onWhatIf:o,onSelect:N,onOpenFile:y,pinned:m===ie.id,onPin:_,onIsolate:v?re=>{v(p===re?null:re)}:void 0}):null,me=re=>{B(Ne=>{const Me=new Set(Ne);if(Me.has(re)){if(Me.size===1)return Ne;Me.delete(re)}else Me.add(re);return Me})},ke=L.useMemo(()=>{const re=new Set;for(const Ne of t)re.add(mm(Ne.type));return re},[t]),ve=t.length-R.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:V==="2d"?"active":"","aria-pressed":V==="2d",onClick:()=>w("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:V==="3d"?"active":"","aria-pressed":V==="3d",onClick:()=>w("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:W==="overview"?"active":"","aria-pressed":W==="overview",onClick:()=>$("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:W==="full"?"active":"","aria-pressed":W==="full",onClick:()=>$("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(re=>ke.has(re)).map(re=>d.jsx("button",{type:"button","data-testid":`graph-family-${re}`,className:z.has(re)?"active":"","aria-pressed":z.has(re),onClick:()=>me(re),children:re},re))}),d.jsx("button",{type:"button",className:Y?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!E,onClick:()=>Q(re=>!re),children:Y?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>v==null?void 0:v(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:ne,onChange:re=>{ee(re.target.value),q(!0)},onFocus:()=>q(!0),onBlur:()=>window.setTimeout(()=>q(!1),150)}),te&&ne.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(re=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:Ne=>Ne.preventDefault(),onClick:()=>{N(re.id),ee(""),q(!1)},children:[re.name,d.jsx("span",{className:"muted",children:ro(re.type)})]})},re.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[R.nodes.length," nodes · ",R.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:V==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(lN,{nodes:R.nodes,edges:R.edges,selectedId:E,neighborIds:U?R.neighborIds:sN,onSelect:re=>{N(re),re||Q(!1)}})}),se]}):d.jsxs(cm,{children:[d.jsxs(tk,{nodes:oe,edges:fe,nodeTypes:cN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:Z,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(fN,{topologyKey:A}),d.jsx(sk,{}),d.jsx(Ek,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(hk,{})]}),se]})})]})}function ym(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function gN(t){localStorage.setItem("loadpath.editor",t)}async function mN(t,r,o,s=ym()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const wp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],yN=["preset","branch","tag","commit"];function vN(t){var a;if(!(t!=null&&t.git))return[...wp];const r=((a=t.presets)!=null&&a.length?t.presets:wp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function xN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function wN(t){return yN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function _N(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function _p({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[v,x]=L.useState(!1),[y,m]=L.useState(null),[_,k]=L.useState(0),b=L.useMemo(()=>{const j=vN(u);return y===null?j:xN(j,y)},[u,y]),E=L.useMemo(()=>wN(b),[b]);L.useEffect(()=>{v&&c()},[v,c]),L.useEffect(()=>{k(0)},[y,v]);const N=()=>{x(!1),m(null)},P=j=>{r(j.value),N()},w=j=>{if(j.key==="ArrowDown"){if(j.preventDefault(),!v){x(!0);return}k($=>Math.min($+1,Math.max(b.length-1,0)))}else if(j.key==="ArrowUp"){if(j.preventDefault(),!v)return;k($=>Math.max($-1,0))}else if(j.key==="Enter"&&v){j.preventDefault();const $=b[_];$&&P($)}else j.key==="Escape"&&v&&(j.preventDefault(),N())};return d.jsxs("div",{className:"combo",ref:p,onBlur:j=>{j.currentTarget.contains(j.relatedTarget)||N()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":v,"aria-controls":h,"aria-autocomplete":"list",onChange:j=>{r(j.target.value),v&&m(j.target.value)},onKeyDown:w}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":v,onMouseDown:j=>j.preventDefault(),onClick:()=>v?N():x(!0),children:d.jsx(v0,{})})]}),v?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:E.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):E.map(j=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:_N(j.group)}),j.items.map($=>{const z=b.indexOf($);return d.jsxs("button",{type:"button",role:"option","aria-selected":z===_,className:z===_?"combo-option active":"combo-option","data-testid":`ref-option-${$.group}`,onMouseDown:B=>B.preventDefault(),onMouseEnter:()=>k(z),onClick:()=>P($),children:[d.jsx("span",{className:"combo-label",children:$.label}),$.detail?d.jsx("span",{className:"combo-detail",children:$.detail}):null]},`${$.group}:${$.value}`)})]},j.group))}):null]})}function SN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[v,x]=L.useState(""),[y,m]=L.useState(!1),_=L.useRef(null),k=L.useRef(0),b=async w=>{const j=k.current+1;k.current=j,m(!0);try{const $=await Pe.browse(w);if(k.current!==j)return;a($),c($.path),p($.is_git?$.path:null),x("")}catch($){if(k.current!==j)return;x($ instanceof Error?$.message:String($))}finally{k.current===j&&m(!1)}};L.useEffect(()=>{var w,j;b(t),(w=_.current)==null||w.focus(),(j=_.current)==null||j.select()},[t]);const E=h||(s==null?void 0:s.path)||u,N=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",P=w=>{w.key==="Escape"&&(w.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:P,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:w=>w.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:w=>{w.preventDefault(),b(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:w=>c(w.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void b(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void b(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),v?d.jsx("div",{className:"error",role:"alert",children:v}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":y,children:s!=null&&s.entries.length?s.entries.map(w=>{const j=h===w.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":j,className:j?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":w.path,onClick:()=>p(w.path),onDoubleClick:()=>void b(w.path),children:[d.jsx(jp,{}),d.jsx("span",{className:"explorer-name",children:w.name}),w.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},w.path)}):d.jsx("div",{className:"muted explorer-empty",children:y?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:E,children:E}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!E,onClick:()=>E&&r(E),children:["Use ",N]})]})]})})}const kN={scan:{start:0,end:20},extract:{start:20,end:88},boot:{start:88,end:94},stitch:{start:94,end:99},skipped:{start:100,end:100},done:{start:100,end:100}},NN=new Set(["scan","extract","boot","stitch"]);function jN(t){const r=t.phase||"";if(!r||r==="idle")return null;const o=kN[r];if(!o)return null;if(o.start===o.end)return o.end;const s=t.total||0;if(s<=0)return o.start;const a=Math.min(1,Math.max(0,(t.done||0)/s));return Math.round(o.start+(o.end-o.start)*a)}function bN(t){return!t.phase||t.phase==="idle"?null:typeof t.percent=="number"&&Number.isFinite(t.percent)?Math.max(0,Math.min(100,Math.round(t.percent))):jN(t)}const Hl=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],EN="obsidian",vm="loadpath.theme";function CN(t){return Hl.some(r=>r.id===t)}function xm(){try{const t=localStorage.getItem(vm)||"";if(CN(t))return t}catch{}return EN}function MN(t){var r;return((r=Hl.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function wm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=MN(t);try{localStorage.setItem(vm,t)}catch{}}const qu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:h0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:p0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:g0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:m0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:y0}];function Ku(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function PN(){var co,fo,Si,ho,po,go,ki,Xr,rn,on;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,v]=L.useState(null),[x,y]=L.useState(null),[m,_]=L.useState(null),[k,b]=L.useState([]),[E,N]=L.useState("review"),[P,w]=L.useState(""),[j,$]=L.useState(""),[z,B]=L.useState(null),[Y,Q]=L.useState(!1),[ne,ee]=L.useState(!1),[te,q]=L.useState(""),[C,V]=L.useState({}),[W,U]=L.useState([]),[M,D]=L.useState([]),[F,R]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[A,ie]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[oe,fe]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[he,pe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[Z,se]=L.useState(0),[me,ke]=L.useState(""),[ve,re]=L.useState(xm),[Ne,Me]=L.useState(!1),[Te,$e]=L.useState(!1),[st,lt]=L.useState(!1),[at,Ye]=L.useState(null),[wt,qt]=L.useState(null),[gt,mt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[Pt,ut]=L.useState(null),[Je,An]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[Ot,xn]=L.useState([]),[io,$n]=L.useState(null),[vi,or]=L.useState(null),[$r,zn]=L.useState(null),[zr,sr]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[lr,Ft]=L.useState(null),[ct,Dn]=L.useState(null),[On,wn]=L.useState(!1),[Fn,_n]=L.useState(!1),rt=L.useRef(o);rt.current=o;const Dr=L.useRef(!1);Dr.current=Te;const _t=L.useRef(""),ar=L.useRef(""),Sn=I=>{re(I),wm(I)},dt=L.useRef(""),He=I=>{dt.current=I,$(I)},kn=I=>{let G=0,ce=!1;B(0);const je=()=>{Pe.indexProgress(I).then(Ie=>{if(!dt.current)return;if(Ie.phase&&Ie.phase!=="idle"&&Ie.message&&He(Ie.message),NN.has(Ie.phase))ce=!0;else if(!ce)return;const qr=bN(Ie);qr!=null&&(Ie.phase==="scan"&&!Ie.done?G=qr:G=Math.max(G,qr),B(G))}).catch(()=>{})};je();const Le=window.setInterval(je,250);return()=>{window.clearInterval(Le),B(null)}};L.useEffect(()=>{Pe.settings().then(V).catch(()=>{}).finally(()=>Me(!0)),Pe.repos().then(I=>b(I.repos)).catch(()=>{})},[]);const Nn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const I=o;let G=!1;return ar.current!==I&&Bn(I),Pe.config(I).then(ce=>{!G&&rt.current===I&&or(ce)}).catch(()=>{}),Pe.architectureHealth(I).then(ce=>{!G&&rt.current===I&&zn(ce)}).catch(()=>{}),()=>{G=!0}},[t,o]);const Ht=I=>{rt.current=I,s(I),localStorage.setItem("loadpath.repo",I),I.trim()!==_t.current&&(_t.current="",Ft(null))},Or=L.useCallback(I=>{const G=(I??rt.current).trim();return!G||_t.current===G?Promise.resolve():(_t.current=G,Pe.gitRefs(G).then(ce=>{rt.current.trim()===G&&Ft(ce)}).catch(()=>{_t.current===G&&(_t.current="",Ft(null))}))},[]),nn=(I,G)=>{u(I),h(G),localStorage.setItem("loadpath.base",I),localStorage.setItem("loadpath.head",G)},Fr=(I,G,ce)=>{ie(I),R(G),localStorage.setItem("loadpath.provider",I),localStorage.setItem("loadpath.scmRepo",G),ce!==void 0&&(fe(ce),localStorage.setItem("loadpath.prNumber",ce))},yt=I=>{v(I),se(0),Ye(wt&&I.nodes.some(G=>G.id===wt)?wt:null),ut(null),$n(null),I.what_if||(y(I),I.id&&localStorage.setItem("loadpath.lastReviewId",I.id))},Hn=async I=>{try{const G=await Pe.reviews(I);xn(G.reviews)}catch{xn([])}},ur=async I=>{try{zn(await Pe.architectureHealth(I))}catch{zn(null)}},oo=I=>I==="github"?!!C.github_token_set:I==="gitlab"?!!C.gitlab_token_set:!!C.bitbucket_token_set,It=L.useCallback(async(I=A)=>{var G;try{const ce=await Pe.scmRepos(I);D(ce.repos),(G=ce.user)!=null&&G.login&&V(je=>({...je,...I==="github"?{github_user:ce.user.login}:I==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{D([])}},[A]);L.useEffect(()=>{if(t!=="prs")return;let I=!1;return It(A).catch(()=>{I||D([])}),()=>{I=!0}},[t,A,It]),L.useEffect(()=>{if(!ct)return;let I=!1,G=0;const ce=async()=>{try{const je=await Pe.githubOAuthPoll(ct.flow_id);if(I)return;if(je.status==="complete"){Dn(null);const Le=await Pe.settings();V(Le),q(je.user?`Signed in to GitHub as ${je.user}`:"Signed in to GitHub"),It("github");return}if(je.status==="pending"||je.status==="slow_down"){G=window.setTimeout(ce,Math.max(je.interval||ct.interval,5)*1e3);return}Dn(null),w(je.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(je){if(I)return;Dn(null),w(je instanceof Error?je.message:String(je))}};return G=window.setTimeout(ce,Math.max(ct.interval,5)*1e3),()=>{I=!0,window.clearTimeout(G)}},[ct,It]),L.useEffect(()=>{if(!On)return;let I=!1,G=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(I)return;if(Le.bitbucket.connected){wn(!1);const Ie=await Pe.settings();V(Ie),q(Le.bitbucket.user?`Signed in to Bitbucket as ${Le.bitbucket.user}`:"Signed in to Bitbucket"),It("bitbucket");return}if(Date.now()-ce>18e4){wn(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}G=window.setTimeout(je,1500)}catch(Le){if(I)return;wn(!1),w(Le instanceof Error?Le.message:String(Le))}};return G=window.setTimeout(je,1500),()=>{I=!0,window.clearTimeout(G)}},[On,It]),L.useEffect(()=>{if(!Fn)return;let I=!1,G=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(I)return;if(Le.gitlab.connected){_n(!1);const Ie=await Pe.settings();V(Ie),q(Le.gitlab.user?`Signed in to GitLab as ${Le.gitlab.user}`:"Signed in to GitLab"),It("gitlab");return}if(Date.now()-ce>18e4){_n(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}G=window.setTimeout(je,1500)}catch(Le){if(I)return;_n(!1),w(Le instanceof Error?Le.message:String(Le))}};return G=window.setTimeout(je,1500),()=>{I=!0,window.clearTimeout(G)}},[Fn,It]);const Bn=async(I=o,G=!1)=>{if(!I.trim())return null;ar.current=I,ee(!0);try{const ce=await Pe.architecture(I,!1);rt.current===I&&_(ce);const je=Pe.architectureGraph(I).then(Le=>{rt.current===I&&_(Ie=>Ie&&{...Ie,nodes:Le.nodes,edges:Le.edges,graph_pending:!1})});return je.catch(()=>{}).finally(()=>{rt.current===I&&ee(!1)}),G&&await je,ce}catch(ce){throw rt.current===I&&ee(!1),ce}},Hr=async I=>{const G=I.trim();if(!(!G||G===rt.current)){if(dt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),q(""),v(null),y(null),_(null),N("architecture"),Ht(G),Q(!0),He(`Loading ${f0(G)}…`);try{await Promise.all([Bn(G),Or(G)])}catch(ce){rt.current===G&&w(ce instanceof Error?ce.message:String(ce))}finally{rt.current===G&&(He(""),Q(!1))}}},jn=async()=>{if(dt.current||!Nn())return;w(""),q(""),He("Tracing load path…"),Ht(o),nn(a,c);const I=kn(o);try{const G=await Pe.review(o,a,c,!0,he);yt(G),N("review"),r("review"),await Pe.repos().then(ce=>b(ce.repos)).catch(()=>{}),await Promise.all([Bn(o),Hn(o),ur(o)])}catch(G){w(G instanceof Error?G.message:String(G))}finally{I(),He("")}},Br=async(I=!0)=>{if(dt.current||!Nn())return;w(""),q(""),He(I?"Indexing…":"Full reindex…"),Ht(o);const G=kn(o);try{await Pe.index(o,I);const ce=await Bn(o);await Pe.repos().then(je=>b(je.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(N("architecture"),r("architecture"))}catch(ce){w(ce instanceof Error?ce.message:String(ce))}finally{G(),He("")}},xi=async()=>{if(!dt.current&&Nn()){w(""),q(""),He("Detecting layout…"),Ht(o);try{const I=await Pe.init(o);q(I.message),await Pe.repos().then(G=>b(G.repos)).catch(()=>{})}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},Ve=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),q("Copied markdown brief")}catch(I){w(I instanceof Error?I.message:String(I))}},so=async()=>{if(!dt.current){if(p!=null&&p.what_if){w("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first.");return}if(!(p!=null&&p.markdown)||!F||!oe){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const I=await Pe.postComment(A,F,Number(oe),p.markdown);q(I.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},Vr=async()=>{if(!dt.current){w(""),He("Fetching pull requests…");try{const I=await Pe.prs(A,F,"open",o.trim()||void 0);U(I.pull_requests);const G=M.find(ce=>ce.slug.toLowerCase()===F.trim().toLowerCase());G!=null&&G.local_path&&Ht(G.local_path)}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},wi=async()=>{w("");try{const I=await Pe.githubOAuthStart();Dn(I),Ku(I.verification_uri_complete,"github.com","/login/device")}catch(I){w(I instanceof Error?I.message:String(I))}},cr=async()=>{w("");try{const I=await Pe.bitbucketOAuthStart();wn(!0),Ku(I.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(I){wn(!1),w(I instanceof Error?I.message:String(I))}},lo=async()=>{w("");try{const I=await Pe.gitlabOAuthStart();_n(!0),Ku(I.authorize_url,new URL(I.authorize_url).hostname,"/oauth/authorize")}catch(I){_n(!1),w(I instanceof Error?I.message:String(I))}},dr=async I=>{if(!(dt.current||!o.trim())){w(""),He("Walking what-if path…");try{const G=await Pe.whatIf(o,I);q(`${G.title} — ${G.confidence.level} · ${(G.sinks||[]).length} sinks`),yt({...G,markdown:G.markdown||"",index:G.index||(p==null?void 0:p.index),workspace:G.workspace||(p==null?void 0:p.workspace)}),N("review"),r("review")}catch(G){w(G instanceof Error?G.message:String(G))}finally{He("")}}},Vn=()=>{if(x){yt(x),N("review"),r("review"),q("Restored the last git-range walk");return}v(null),se(0),Ye(null),ut(null),$n(null),N("architecture"),r("architecture"),q("")},bt=async I=>{var Le;if(dt.current)return;Fr(I.provider,I.repo,String(I.number));const G=M.find(Ie=>Ie.slug.toLowerCase()===I.repo.toLowerCase());G!=null&&G.local_path&&Ht(G.local_path),w(""),He(`Fetching ${I.provider} #${I.number}…`);const ce=(G==null?void 0:G.local_path)||o,je=ce?kn(ce):()=>{};try{const Ie=await Pe.reviewPr(I.provider,I.repo,I.number,(G==null?void 0:G.local_path)||o||void 0);yt(Ie),Ie.pull_request&&typeof Ie.pull_request.repo_path=="string"&&Ht(Ie.pull_request.repo_path),nn(String(Ie.base||I.target_branch),String(Ie.head||I.source_branch)),N("review"),r("review"),typeof((Le=Ie.pull_request)==null?void 0:Le.repo_path)=="string"&&Hn(Ie.pull_request.repo_path)}catch(Ie){nn(I.base_sha||I.target_branch,I.head_sha||I.source_branch),r("review"),w(Ie instanceof Error?Ie.message:String(Ie))}finally{je(),He("")}},Wr=async I=>{w("");try{V(await Pe.oauthDisconnect(I)),A===I&&D([]),q(`Disconnected ${I}`)}catch(G){w(G instanceof Error?G.message:String(G))}},Et=async I=>{I.preventDefault();const G=new FormData(I.currentTarget),ce={github_token:String(G.get("github_token")||""),github_oauth_client_id:String(G.get("github_oauth_client_id")||""),github_host:String(G.get("github_host")||""),gitlab_token:String(G.get("gitlab_token")||""),gitlab_host:String(G.get("gitlab_host")||""),gitlab_oauth_client_id:String(G.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(G.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(G.get("bitbucket_token")||""),bitbucket_username:String(G.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(G.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(G.get("bitbucket_oauth_client_secret")||""),ai_provider:String(G.get("ai_provider")||"none"),ai_api_key:String(G.get("ai_api_key")||""),ai_model:String(G.get("ai_model")||""),ai_base_url:String(G.get("ai_base_url")||"")},je=k.length?{...ce,workspaces:k.map(Le=>({path:Le.path,name:Le.name}))}:ce;try{V(await Pe.saveSettings(je)),q("Settings saved on this machine")}catch(Le){w(Le instanceof Error?Le.message:String(Le))}},ao=async()=>{if(!(!p||dt.current)){He("Residual analysis…");try{const I=await Pe.residual(p);ke(I.note)}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},Ur=L.useRef(jn);Ur.current=jn;const Gr=L.useRef(t);Gr.current=t;const Wn=L.useRef(!1);Wn.current=st;const Un=L.useRef(p);Un.current=p;const bn=L.useRef(Z);bn.current=Z,L.useEffect(()=>{const I=localStorage.getItem("loadpath.lastReviewId"),G=(localStorage.getItem("loadpath.repo")||"").trim();if(!I||!G){sr(!1);return}let ce=!1;return Pe.getReview(G,I).then(je=>{ce||(yt(je),nn(je.base||localStorage.getItem("loadpath.base")||"HEAD~1",je.head||localStorage.getItem("loadpath.head")||"HEAD"),Hn(G),ur(G))}).catch(()=>{}).finally(()=>{ce||sr(!1)}),()=>{ce=!0}},[]);const Bt=L.useRef("");L.useEffect(()=>{if(!Je||!o.trim())return;let I=!1;const G=async()=>{try{const je=await Pe.workspaceStatus(o);if(I)return;Bt.current&&je.fingerprint!==Bt.current&&!dt.current&&(pe(!0),localStorage.setItem("loadpath.dirty","1"),Ur.current()),Bt.current=je.fingerprint}catch{}};G();const ce=window.setInterval(G,2e3);return()=>{I=!0,window.clearInterval(ce)}},[Je,o]),L.useEffect(()=>{const I=G=>{var Le;if((G.metaKey||G.ctrlKey)&&G.key.toLowerCase()==="k"){G.preventDefault(),lt(Ie=>!Ie);return}if(Wn.current){G.key==="Escape"&&(G.preventDefault(),lt(!1));return}if(Dr.current){G.key==="Escape"&&(G.preventDefault(),$e(!1));return}const ce=G.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){G.key==="Escape"&&ce.blur();return}if(G.key==="Escape"){w(""),q(""),Ye(wt),ut(null);return}if(G.key==="j"||G.key==="k"){const Ie=((Le=Un.current)==null?void 0:Le.read_order)||[];if(!Ie.length)return;G.preventDefault();const Yn=bn.current,qr=G.key==="j"?Math.min(Ie.length-1,Yn+1):Math.max(0,Yn-1);se(qr);return}const je=qu.find(Ie=>Ie.shortcut===G.key);if(je&&!G.metaKey&&!G.ctrlKey&&!G.altKey&&r(je.id),(G.metaKey||G.ctrlKey)&&G.key==="Enter"){if(Gr.current==="settings"||Gr.current==="prs"||dt.current)return;G.preventDefault(),Ur.current()}};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[wt]);const _i=async(I,G)=>{if(!o.trim())return;const ce=await mN(o,I,G);ce.ok?q(ce.message):w(ce.message)},Yr=async()=>{if(p)try{const I=await Pe.exportHtml(p),G=URL.createObjectURL(I),ce=document.createElement("a");ce.href=G,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(G),q("Saved HTML brief")}catch(I){w(I instanceof Error?I.message:String(I))}},fr=async I=>{if(o.trim()){He("Loading stored review…");try{const G=await Pe.getReview(o,I);yt(G),nn(G.base||a,G.head||c),N("review"),r("review");const ce=Ot.find(je=>je.id!==I);if(ce)try{$n(await Pe.reviewDiff(o,I,ce.id))}catch{$n(null)}}catch(G){w(G instanceof Error?G.message:String(G))}finally{He("")}}},hr={selectedId:at,onSelect:Ye,nodeRoles:p==null?void 0:p.node_roles,testOverlay:gt,isolateSource:Pt,onIsolate:ut,repoPath:o,onOpenFile:_i,pinnedId:wt,onPin:qt},Gn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},...p!=null&&p.what_if?[{id:"exit-whatif",group:"Review",label:x?"Back to git-range walk":"Exit what-if walk",run:Vn}]:[],{id:"index",group:"Run",label:"Index repository",run:()=>void Br(!0)},{id:"watch",group:"Run",label:Je?"Stop watching working tree":"Watch working tree",run:()=>{const I=!Je;An(I),localStorage.setItem("loadpath.watch",I?"1":"0")}},{id:"tests",group:"Graph",label:gt?"Hide test overlay":"Show test overlay",run:()=>{const I=!gt;mt(I),localStorage.setItem("loadpath.testOverlay",I?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Yr()},...qu.map(I=>({id:`tab-${I.id}`,group:"Tabs",label:`Go to ${I.label}`,hint:I.shortcut,run:()=>r(I.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(I=>({id:`node-${I.id}`,group:"Nodes",label:I.name,hint:ro(I.type),run:()=>{Ye(I.id),r("graph")}})),...Ot.slice(0,12).map(I=>({id:`hist-${I.id}`,group:"History",label:I.title||I.id,hint:`${I.level||""} ${I.created_at||""}`.trim(),run:()=>void fr(I.id)}))],En=L.useMemo(()=>E==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[E,m,p]),uo=L.useMemo(()=>E==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[E,m,p]),pr=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Fe=((p==null?void 0:p.findings)||[]).filter(I=>!I.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),qu.map(I=>{const G=I.icon,ce=t===I.id;return d.jsxs("button",{type:"button","data-testid":I.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":I.label,onClick:()=>r(I.id),children:[d.jsx(G,{}),d.jsx("span",{children:I.label})]},I.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:ve,onChange:I=>Sn(I.target.value),children:["dark","light"].map(I=>d.jsx("optgroup",{label:I==="dark"?"Dark":"Light",children:Hl.filter(G=>G.group===I).map(G=>d.jsx("option",{value:G.id,children:G.label},G.id))},I))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:j||pr}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[j?d.jsxs("div",{className:z!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","aria-valuemin":z!=null?0:void 0,"aria-valuemax":z!=null?100:void 0,"aria-valuenow":z??void 0,"data-testid":"progress",children:[d.jsx("i",{style:z!=null?{width:`${z}%`}:void 0}),d.jsx("span",{className:"sr-only",children:j})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[k.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:k.some(I=>I.path===o)?o:"",disabled:!!j,"aria-busy":Y,onChange:I=>{I.target.value&&Hr(I.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),k.map(I=>d.jsxs("option",{value:I.path,children:[I.name,I.indexed?` (${I.counts.nodes})`:""]},I.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:I=>{const G=I.target.value;s(G),G.trim()!==_t.current&&(_t.current="",Ft(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>$e(!0),children:d.jsx(jp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(_p,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:I=>nn(I,c),placeholder:"base",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(_p,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:I=>nn(a,I),placeholder:"head",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:he?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":he,onClick:()=>{const I=!he;pe(I),localStorage.setItem("loadpath.dirty",I?"1":"0")},children:he?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:Je?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":Je,onClick:()=>{const I=!Je;An(I),localStorage.setItem("loadpath.watch",I?"1":"0")},children:Je?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.what_if?"what-if · ":"",p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!j,onClick:xi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!j,onClick:()=>Br(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!j,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[P?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:P}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,te?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:te}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>q(""),"aria-label":"Dismiss",children:"×"})]}):null,((co=p==null?void 0:p.index)!=null&&co.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((fo=p==null?void 0:p.index)==null?void 0:fo.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Si=p==null?void 0:p.index)==null?void 0:Si.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(ho=p==null?void 0:p.workspace)!=null&&ho.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,p!=null&&p.what_if?d.jsxs("div",{className:"banner whatif","data-testid":"whatif-banner",children:[d.jsxs("span",{children:["Hypothetical walk from"," ",d.jsx("strong",{children:((po=p.node)==null?void 0:po.name)||"this node"}),". Loadpath ignored Base/Head and asked which sinks would feel this node change — not a filter of the current map."]}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-exit-whatif",onClick:Vn,children:x?"Back to git range":"Back to architecture"})]}):null,Y?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:j||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":Y||ne,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(IN,{review:p,findings:Fe,aiNote:me,busy:!!j,tourIndex:Z,onTour:se,onAskAi:ao,onCopy:Ve,onPost:so,onSelect:Ye,onOpenFile:_i,onExport:Yr,history:Ot,diff:io,onReopen:fr,onWaiver:(I,G)=>{o.trim()&&Pe.addWaiver(o,I,G||void 0,"from review").then(ce=>{or(ce),q(`Waived ${I} in loadpath.yml`)})}}):zr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Xu,{nodes:p.nodes,edges:p.edges,onWhatIf:dr,focusPath:(go=p.read_order[Z])==null?void 0:go.path,...hr}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(RN,{architecture:m,busy:!!j,onReindex:()=>Br(!1),onReview:jn,onSelect:Ye,config:vi,health:$r,onSaveConfig:I=>{Pe.saveConfig(o,I).then(G=>{or(G),q("Wrote loadpath.yml")})},onWaiver:(I,G,ce)=>{Pe.addWaiver(o,I,G,ce).then(je=>{or(je),q(`Waived ${I}`)})}}):Y?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(ne||m!=null&&m.graph_pending)&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(ki=m==null?void 0:m.counts)!=null&&ki.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Xu,{nodes:m.nodes,edges:m.edges,onWhatIf:dr,...hr,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":E==="review","data-testid":"graph-mode-review",className:E==="review"?"active":"",onClick:()=>N("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":E==="architecture","data-testid":"graph-mode-architecture",className:E==="architecture"?"active":"",onClick:()=>N("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:gt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":gt,onClick:()=>{const I=!gt;mt(I),localStorage.setItem("loadpath.testOverlay",I?"1":"0")},children:"Tests"})]}),En.length?d.jsx(Xu,{nodes:En,edges:uo,onWhatIf:dr,...hr}):ne||m!=null&&m.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:A,onChange:I=>Fr(I.target.value,F,oe),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:M.length?"Search your repos":"owner/repo",value:F,onChange:I=>Fr(A,I.target.value,oe),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:M.map(I=>d.jsxs("option",{value:I.slug,children:[I.private?"private":"public",I.local_path?" · local":""]},I.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!j||!oo(A),onClick:()=>{It(A)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!j,onClick:Vr,children:"List PRs"})]}),M.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[M.length," ",A," repositor",M.length===1?"y":"ies",A==="github"&&C.github_user?` · @${String(C.github_user)}`:"",A==="gitlab"&&C.gitlab_user?` · @${String(C.gitlab_user)}`:"",A==="bitbucket"&&C.bitbucket_user?` · ${String(C.bitbucket_user)}`:""]}):null,W.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):W.map(I=>{var G;return d.jsxs("article",{className:"pr","data-testid":`pr-${I.number}`,children:[d.jsxs("h3",{children:["#",I.number," ",I.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${I.draft?"":"open"}`,children:I.draft?"draft":I.state}),d.jsx("span",{children:I.author}),d.jsxs("span",{children:[I.source_branch," → ",I.target_branch]}),I.loadpath?d.jsxs("span",{className:`chip ${I.loadpath.level||""}`,"data-testid":`pr-loadpath-${I.number}`,children:[((G=I.loadpath.level)==null?void 0:G.toUpperCase())||"REVIEWED",I.loadpath.contract_break&&I.loadpath.contract_break!=="none"?` · ${I.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:I.url,target:"_blank",rel:"noreferrer",children:["Open on ",I.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${I.number}`,onClick:()=>void bt(I),children:"Review this PR"})]})]},`${I.provider}-${I.number}`)})]}),t==="settings"&&Ne&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Et,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Hl.map(I=>d.jsxs("button",{type:"button","data-theme":I.id,className:ve===I.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${I.id}`,onClick:()=>Sn(I.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:I.label}),d.jsx("div",{className:"group",children:I.group})]},I.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:ym(),onChange:I=>gN(I.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:C.github_token_set?C.github_user?`Signed in as @${String(C.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void Wr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!ct||!C.github_oauth_ready,onClick:()=>void wi(),children:ct?"Waiting for GitHub…":"Sign in with GitHub"})})]}),ct?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:ct.user_code})," at GitHub if the browser did not fill it in."]}):null,C.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(C.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(C.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:C.gitlab_token_set?C.gitlab_user?`Signed in as @${String(C.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void Wr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Fn||!C.gitlab_oauth_ready,onClick:()=>void lo(),children:Fn?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(C.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(C.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:C.bitbucket_token_set?C.bitbucket_user?`Signed in as ${String(C.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void Wr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:On||!C.bitbucket_oauth_ready,onClick:()=>void cr(),children:On?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),C.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(C.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(C.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((Xr=C.ai)==null?void 0:Xr.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((rn=C.ai)==null?void 0:rn.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((on=C.ai)==null?void 0:on.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(u0,{open:st,actions:Gn,onClose:()=>lt(!1)}),Te?d.jsx(SN,{initialPath:o,onClose:()=>$e(!1),onSelect:I=>{if(dt.current){w("Wait for the current job to finish before switching workspace.");return}$e(!1),Hr(I)}}):null]})}function IN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:v,onOpenFile:x,onExport:y,history:m,diff:_,onReopen:k,onWaiver:b}){var N,P,w,j,$,z,B,Y,Q,ne,ee,te,q,C,V,W,U;const E=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),E.length?d.jsx("ul",{className:"reasons",children:E.map(M=>d.jsx("li",{children:M},M))}):null,t.what_if?d.jsx("span",{className:"chip whatif","data-testid":"whatif-chip",children:"what-if"}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Qo(M)},M)),(N=t.contract_break)!=null&&N.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>b(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(P=t.workspace)!=null&&P.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>x(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(_m,{cards:t.deepening}),(j=(w=t.contract_break)==null?void 0:w.reasons)!=null&&j.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),(z=($=t.contract_break.sides)==null?void 0:$.rows)!=null&&z.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(B=t.auth)!=null&&B.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(Y=t.suggested_tests)==null?void 0:Y.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(Q=t.trend)!=null&&Q.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",Qu(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),m.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:m.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,m.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>k(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?Qu(M.created_at):""})]},M.id))]}):null,(ee=(ne=t.evolution)==null?void 0:ne.notes)!=null&&ee.length||(q=(te=t.evolution)==null?void 0:te.hotspots)!=null&&q.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((C=t.evolution)==null?void 0:C.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((V=t.evolution)==null?void 0:V.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:y,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",disabled:s||!!t.what_if,title:t.what_if?"Hypothetical walks are not posted to a pull request":void 0,onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(W=t.codeowners_reviewers)!=null&&W.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function RN({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var x;const v=t.findings.filter(y=>!y.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${Qu(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(y=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y.name})," — ",(y.django_apps||[]).join(", ")||"no apps"," ·"," ",(y.owners||[]).join(", ")||"unowned"]},y.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(y=>d.jsx("div",{className:"muted",children:y},y))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:v.length})]}),v.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):v.map(y=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>y.node_id&&a(y.node_id),children:[d.jsx("span",{className:`chip ${y.severity}`,children:y.severity}),y.message]})},y.rule+y.message))]}),d.jsx(_m,{cards:t.deepening}),(x=c==null?void 0:c.points)!=null&&x.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(y=>d.jsx("i",{className:y.level||"",title:`${y.level} · ${y.findings} findings`,style:{height:`${8+Math.min(24,(y.findings||0)*4)}px`}},y.id||y.created_at))}),Object.entries(c.contexts).map(([y,m])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y})," — last ",((_=m[m.length-1])==null?void 0:_.findings)??0," findings"]},y)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(c0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((y,m)=>m[1]-y[1]).slice(0,12).map(([y,m])=>d.jsxs("tr",{children:[d.jsx("td",{children:ro(y)}),d.jsx("td",{children:m})]},y))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function _m({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:d0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}wm(xm());s0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(PN,{})}));export{Hk as L,AN as a,TN as c,d as j,LN as l,L as r,ro as t}; diff --git a/src/loadpath/static/assets/index-CUH75ocM.js b/src/loadpath/static/assets/index-CUH75ocM.js new file mode 100644 index 0000000..15709c8 --- /dev/null +++ b/src/loadpath/static/assets/index-CUH75ocM.js @@ -0,0 +1,62 @@ +(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function Np(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ru={exports:{}},Wo={},Tu={exports:{}},Re={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var qf;function t0(){if(qf)return Re;qf=1;var t=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),v=Symbol.iterator;function m(R){return R===null||typeof R!="object"?null:(R=v&&R[v]||R["@@iterator"],typeof R=="function"?R:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,b={};function E(R,A,ie){this.props=R,this.context=A,this.refs=b,this.updater=ie||_}E.prototype.isReactComponent={},E.prototype.setState=function(R,A){if(typeof R!="object"&&typeof R!="function"&&R!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,R,A,"setState")},E.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function N(){}N.prototype=E.prototype;function P(R,A,ie){this.props=R,this.context=A,this.refs=b,this.updater=ie||_}var w=P.prototype=new N;w.constructor=P,k(w,E.prototype),w.isPureReactComponent=!0;var j=Array.isArray,$=Object.prototype.hasOwnProperty,z={current:null},B={key:!0,ref:!0,__self:!0,__source:!0};function G(R,A,ie){var oe,fe={},he=null,pe=null;if(A!=null)for(oe in A.ref!==void 0&&(pe=A.ref),A.key!==void 0&&(he=""+A.key),A)$.call(A,oe)&&!B.hasOwnProperty(oe)&&(fe[oe]=A[oe]);var Z=arguments.length-2;if(Z===1)fe.children=ie;else if(1>>1,A=M[R];if(0>>1;Ra(fe,F))hea(pe,fe)?(M[R]=pe,M[he]=F,R=he):(M[R]=fe,M[oe]=F,R=oe);else if(hea(pe,F))M[R]=pe,M[he]=F,R=he;else break e}}return D}function a(M,D){var F=M.sortIndex-D.sortIndex;return F!==0?F:M.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,h=c.now();t.unstable_now=function(){return c.now()-h}}var p=[],y=[],x=1,v=null,m=3,_=!1,k=!1,b=!1,E=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,P=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(M){for(var D=o(y);D!==null;){if(D.callback===null)s(y);else if(D.startTime<=M)s(y),D.sortIndex=D.expirationTime,r(p,D);else break;D=o(y)}}function j(M){if(b=!1,w(M),!k)if(o(p)!==null)k=!0,W($);else{var D=o(y);D!==null&&U(j,D.startTime-M)}}function $(M,D){k=!1,b&&(b=!1,N(G),G=-1),_=!0;var F=m;try{for(w(D),v=o(p);v!==null&&(!(v.expirationTime>D)||M&&!ee());){var R=v.callback;if(typeof R=="function"){v.callback=null,m=v.priorityLevel;var A=R(v.expirationTime<=D);D=t.unstable_now(),typeof A=="function"?v.callback=A:v===o(p)&&s(p),w(D)}else s(p);v=o(p)}if(v!==null)var ie=!0;else{var oe=o(y);oe!==null&&U(j,oe.startTime-D),ie=!1}return ie}finally{v=null,m=F,_=!1}}var z=!1,B=null,G=-1,Q=5,ne=-1;function ee(){return!(t.unstable_now()-neM||125R?(M.sortIndex=F,r(y,M),o(p)===null&&M===o(y)&&(b?(N(G),G=-1):b=!0,U(j,F-R))):(M.sortIndex=A,r(p,M),k||_||(k=!0,W($))),M},t.unstable_shouldYield=ee,t.unstable_wrapCallback=function(M){var D=m;return function(){var F=m;m=D;try{return M.apply(this,arguments)}finally{m=F}}}})($u)),$u}var eh;function s0(){return eh||(eh=1,Au.exports=o0()),Au.exports}/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var th;function l0(){if(th)return zt;th=1;var t=us(),r=s0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,y=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,x={},v={};function m(e){return p.call(v,e)?!0:p.call(x,e)?!1:y.test(e)?v[e]=!0:(x[e]=!0,!1)}function _(e,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function k(e,n,i,l){if(n===null||typeof n>"u"||_(e,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function b(e,n,i,l,f,g,S){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=f,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=g,this.removeEmptyString=S}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){E[e]=new b(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];E[n]=new b(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){E[e]=new b(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){E[e]=new b(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){E[e]=new b(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){E[e]=new b(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){E[e]=new b(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){E[e]=new b(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){E[e]=new b(e,5,!1,e.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function P(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(N,P);E[n]=new b(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(N,P);E[n]=new b(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(N,P);E[n]=new b(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){E[e]=new b(e,1,!1,e.toLowerCase(),null,!1,!1)}),E.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){E[e]=new b(e,1,!1,e.toLowerCase(),null,!0,!0)});function w(e,n,i,l){var f=E.hasOwnProperty(n)?E[n]:null;(f!==null?f.type!==0:l||!(2T||f[S]!==g[T]){var O=` +`+f[S].replace(" at new "," at ");return e.displayName&&O.includes("")&&(O=O.replace("",e.displayName)),O}while(1<=S&&0<=T);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?A(e):""}function fe(e){switch(e.tag){case 5:return A(e.type);case 16:return A("Lazy");case 13:return A("Suspense");case 19:return A("SuspenseList");case 0:case 2:case 15:return e=oe(e.type,!1),e;case 11:return e=oe(e.type.render,!1),e;case 1:return e=oe(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case B:return"Fragment";case z:return"Portal";case Q:return"Profiler";case G:return"StrictMode";case q:return"Suspense";case C:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ee:return(e.displayName||"Context")+".Consumer";case ne:return(e._context.displayName||"Context")+".Provider";case te:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case W:n=e._payload,e=e._init;try{return he(e(n))}catch{}}return null}function pe(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===G?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Z(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=se(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function ke(e){e._valueTracker||(e._valueTracker=me(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=se(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function re(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return F({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Z(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Te(e,n){n=n.checked,n!=null&&w(e,"checked",n,!1)}function $e(e,n){Te(e,n);var i=Z(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?lt(e,n.type,i):n.hasOwnProperty("defaultValue")&<(e,n.type,Z(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function st(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function lt(e,n,i){(n!=="number"||re(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var at=Array.isArray;function Ge(e,n,i,l){if(e=e.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=Je.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ot(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var xn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},io=["Webkit","ms","Moz","O"];Object.keys(xn).forEach(function(e){io.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),xn[n]=xn[e]})});function $n(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||xn.hasOwnProperty(e)&&xn[e]?(""+n).trim():n+"px"}function vi(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=$n(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,f):e[i]=f}}var or=F({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function $r(e,n){if(n){if(or[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function zn(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var zr=null;function sr(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var lr=null,Ft=null,ct=null;function Dn(e){if(e=Mo(e)){if(typeof lr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=Ps(n),lr(e.stateNode,e.type,n))}}function On(e){Ft?ct?ct.push(e):ct=[e]:Ft=e}function wn(){if(Ft){var e=Ft,n=ct;if(ct=Ft=null,Dn(e),n)for(e=0;e>>=0,e===0?32:31-(ao(e)/Ur|0)|0}var Wn=64,Un=4194304;function bn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Bt(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,f=e.suspendedLanes,g=e.pingedLanes,S=i&268435455;if(S!==0){var T=S&~f;T!==0?l=bn(T):(g&=S,g!==0&&(l=bn(g)))}else S=i&~f,S!==0?l=bn(S):g!==0&&(l=bn(g));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,g=n&-n,f>=g||f===16&&(g&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function En(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Et(n),e[n]=i}function uo(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=wo),Hc=" ",Bc=!1;function Vc(e,n){switch(e){case"keyup":return Km.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var bi=!1;function Zm(e,n){switch(e){case"compositionend":return Wc(n);case"keypress":return n.which!==32?null:(Bc=!0,Hc);case"textInput":return e=n.data,e===Hc&&Bc?null:e;default:return null}}function Jm(e,n){if(bi)return e==="compositionend"||!fa&&Vc(e,n)?(e=Ac(),xs=sa=gr=null,bi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Qc(i)}}function Jc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Jc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function ed(){for(var e=window,n=re();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=re(e.document)}return n}function ga(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function ay(e){var n=ed(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Jc(i.ownerDocument.documentElement,i)){if(l!==null&&ga(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var f=i.textContent.length,g=Math.min(l.start,f);l=l.end===void 0?g:Math.min(l.end,f),!e.extend&&g>l&&(f=l,l=g,g=f),f=Zc(i,g);var S=Zc(i,l);f&&S&&(e.rangeCount!==1||e.anchorNode!==f.node||e.anchorOffset!==f.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),e.removeAllRanges(),g>l?(e.addRange(n),e.extend(S.node,S.offset)):(n.setEnd(S.node,S.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,Ei=null,ma=null,No=null,ya=!1;function td(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;ya||Ei==null||Ei!==re(l)||(l=Ei,"selectionStart"in l&&ga(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),No&&ko(No,l)||(No=l,l=Es(ma,"onSelect"),0Ri||(e.current=Ma[Ri],Ma[Ri]=null,Ri--)}function Be(e,n){Ri++,Ma[Ri]=e.current,e.current=n}var xr={},St=vr(xr),Rt=vr(!1),Qr=xr;function Ti(e,n){var i=e.type.contextTypes;if(!i)return xr;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in i)f[g]=n[g];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=f),f}function Tt(e){return e=e.childContextTypes,e!=null}function Is(){Ue(Rt),Ue(St)}function md(e,n,i){if(St.current!==xr)throw Error(o(168));Be(St,n),Be(Rt,i)}function yd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,pe(e)||"Unknown",f));return F({},i,l)}function Rs(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||xr,Qr=St.current,Be(St,e),Be(Rt,Rt.current),!0}function vd(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=yd(e,n,Qr),l.__reactInternalMemoizedMergedChildContext=e,Ue(Rt),Ue(St),Be(St,e)):Ue(Rt),Be(Rt,i)}var qn=null,Ts=!1,Pa=!1;function xd(e){qn===null?qn=[e]:qn.push(e)}function wy(e){Ts=!0,xd(e)}function wr(){if(!Pa&&qn!==null){Pa=!0;var e=0,n=Fe;try{var i=qn;for(Fe=1;e>=S,f-=S,Kn=1<<32-Et(n)+f|i<Ce?(pt=Ee,Ee=null):pt=Ee.sibling;var Oe=le(X,Ee,K[Ce],de);if(Oe===null){Ee===null&&(Ee=pt);break}e&&Ee&&Oe.alternate===null&&n(X,Ee),H=g(Oe,H,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe,Ee=pt}if(Ce===K.length)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;CeCe?(pt=Ee,Ee=null):pt=Ee.sibling;var Mr=le(X,Ee,Oe.value,de);if(Mr===null){Ee===null&&(Ee=pt);break}e&&Ee&&Mr.alternate===null&&n(X,Ee),H=g(Mr,H,Ce),be===null?_e=Mr:be.sibling=Mr,be=Mr,Ee=pt}if(Oe.done)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;!Oe.done;Ce++,Oe=K.next())Oe=ue(X,Oe.value,de),Oe!==null&&(H=g(Oe,H,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return Xe&&Jr(X,Ce),_e}for(Ee=l(X,Ee);!Oe.done;Ce++,Oe=K.next())Oe=ge(Ee,X,Ce,Oe.value,de),Oe!==null&&(e&&Oe.alternate!==null&&Ee.delete(Oe.key===null?Ce:Oe.key),H=g(Oe,H,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return e&&Ee.forEach(function(e0){return n(X,e0)}),Xe&&Jr(X,Ce),_e}function et(X,H,K,de){if(typeof K=="object"&&K!==null&&K.type===B&&K.key===null&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case $:e:{for(var _e=K.key,be=H;be!==null;){if(be.key===_e){if(_e=K.type,_e===B){if(be.tag===7){i(X,be.sibling),H=f(be,K.props.children),H.return=X,X=H;break e}}else if(be.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===W&&jd(_e)===be.type){i(X,be.sibling),H=f(be,K.props),H.ref=Po(X,be,K),H.return=X,X=H;break e}i(X,be);break}else n(X,be);be=be.sibling}K.type===B?(H=li(K.props.children,X.mode,de,K.key),H.return=X,X=H):(de=ll(K.type,K.key,K.props,null,X.mode,de),de.ref=Po(X,H,K),de.return=X,X=de)}return S(X);case z:e:{for(be=K.key;H!==null;){if(H.key===be)if(H.tag===4&&H.stateNode.containerInfo===K.containerInfo&&H.stateNode.implementation===K.implementation){i(X,H.sibling),H=f(H,K.children||[]),H.return=X,X=H;break e}else{i(X,H);break}else n(X,H);H=H.sibling}H=Eu(K,X.mode,de),H.return=X,X=H}return S(X);case W:return be=K._init,et(X,H,be(K._payload),de)}if(at(K))return xe(X,H,K,de);if(D(K))return we(X,H,K,de);zs(X,K)}return typeof K=="string"&&K!==""||typeof K=="number"?(K=""+K,H!==null&&H.tag===6?(i(X,H.sibling),H=f(H,K),H.return=X,X=H):(i(X,H),H=bu(K,X.mode,de),H.return=X,X=H),S(X)):i(X,H)}return et}var zi=bd(!0),Ed=bd(!1),Ds=vr(null),Os=null,Di=null,$a=null;function za(){$a=Di=Os=null}function Da(e){var n=Ds.current;Ue(Ds),e._currentValue=n}function Oa(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function Oi(e,n){Os=e,$a=Di=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Lt=!0),e.firstContext=null)}function Zt(e){var n=e._currentValue;if($a!==e)if(e={context:e,memoizedValue:n,next:null},Di===null){if(Os===null)throw Error(o(308));Di=e,Os.dependencies={lanes:0,firstContext:e}}else Di=Di.next=e;return n}var ei=null;function Fa(e){ei===null?ei=[e]:ei.push(e)}function Cd(e,n,i,l){var f=n.interleaved;return f===null?(i.next=i,Fa(n)):(i.next=f.next,f.next=i),n.interleaved=i,Zn(e,l)}function Zn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var _r=!1;function Ha(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Md(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Jn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Sr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(ze&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,Zn(e,i)}return f=l.interleaved,f===null?(n.next=n,Fa(l)):(n.next=f.next,f.next=n),l.interleaved=n,Zn(e,i)}function Fs(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}function Pd(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var S={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?f=g=S:g=g.next=S,i=i.next}while(i!==null);g===null?f=g=n:g=g.next=n}else f=g=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function Hs(e,n,i,l){var f=e.updateQueue;_r=!1;var g=f.firstBaseUpdate,S=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,J=O.next;O.next=null,S===null?g=J:S.next=J,S=O;var ae=e.alternate;ae!==null&&(ae=ae.updateQueue,T=ae.lastBaseUpdate,T!==S&&(T===null?ae.firstBaseUpdate=J:T.next=J,ae.lastBaseUpdate=O))}if(g!==null){var ue=f.baseState;S=0,ae=J=O=null,T=g;do{var le=T.lane,ge=T.eventTime;if((l&le)===le){ae!==null&&(ae=ae.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var xe=e,we=T;switch(le=n,ge=i,we.tag){case 1:if(xe=we.payload,typeof xe=="function"){ue=xe.call(ge,ue,le);break e}ue=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=we.payload,le=typeof xe=="function"?xe.call(ge,ue,le):xe,le==null)break e;ue=F({},ue,le);break e;case 2:_r=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,le=f.effects,le===null?f.effects=[T]:le.push(T))}else ge={eventTime:ge,lane:le,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ae===null?(J=ae=ge,O=ue):ae=ae.next=ge,S|=le;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;le=T,T=le.next,le.next=null,f.lastBaseUpdate=le,f.shared.pending=null}}while(!0);if(ae===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=J,f.lastBaseUpdate=ae,n=f.shared.interleaved,n!==null){f=n;do S|=f.lane,f=f.next;while(f!==n)}else g===null&&(f.shared.lanes=0);ri|=S,e.lanes=S,e.memoizedState=ue}}function Id(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=Ya.transition;Ya.transition={};try{e(!1),n()}finally{Fe=i,Ya.transition=l}}function Kd(){return Jt().memoizedState}function Ny(e,n,i){var l=br(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},Qd(e))Zd(n,i);else if(i=Cd(e,n,i,l),i!==null){var f=Mt();dn(i,e,l,f),Jd(i,n,l)}}function jy(e,n,i){var l=br(e),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(Qd(e))Zd(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,T=g(S,i);if(f.hasEagerState=!0,f.eagerState=T,sn(T,S)){var O=n.interleaved;O===null?(f.next=f,Fa(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=Cd(e,n,f,l),i!==null&&(f=Mt(),dn(i,e,l,f),Jd(i,n,l))}}function Qd(e){var n=e.alternate;return e===Ke||n!==null&&n===Ke}function Zd(e,n){Lo=Ws=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Jd(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}var Gs={readContext:Zt,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},by={readContext:Zt,useCallback:function(e,n){return Pn().memoizedState=[e,n===void 0?null:n],e},useContext:Zt,useEffect:Bd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Us(4194308,4,Ud.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Us(4194308,4,e,n)},useInsertionEffect:function(e,n){return Us(4,2,e,n)},useMemo:function(e,n){var i=Pn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=Pn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=Ny.bind(null,Ke,e),[l.memoizedState,e]},useRef:function(e){var n=Pn();return e={current:e},n.memoizedState=e},useState:Fd,useDebugValue:Ja,useDeferredValue:function(e){return Pn().memoizedState=e},useTransition:function(){var e=Fd(!1),n=e[0];return e=ky.bind(null,e[1]),Pn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=Ke,f=Pn();if(Xe){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ht===null)throw Error(o(349));(ni&30)!==0||Ad(l,n,i)}f.memoizedState=i;var g={value:i,getSnapshot:n};return f.queue=g,Bd(zd.bind(null,l,g,e),[e]),l.flags|=2048,zo(9,$d.bind(null,l,g,i,n),void 0,null),i},useId:function(){var e=Pn(),n=ht.identifierPrefix;if(Xe){var i=Qn,l=Kn;i=(l&~(1<<32-Et(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=Ao++,0<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=S.createElement(i,{is:l.is}):(e=S.createElement(i),i==="select"&&(S=e,l.multiple?S.multiple=!0:l.size&&(S.size=l.size))):e=S.createElementNS(e,i),e[Cn]=n,e[Co]=l,wf(e,n,!1,!1),n.stateNode=e;e:{switch(S=zn(i,l),i){case"dialog":We("cancel",e),We("close",e),f=l;break;case"iframe":case"object":case"embed":We("load",e),f=l;break;case"video":case"audio":for(f=0;fWi&&(n.flags|=128,l=!0,Do(g,!1),n.lanes=4194304)}else{if(!l)if(e=Bs(S),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Do(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Xe)return Nt(n),null}else 2*Ve()-g.renderingStartTime>Wi&&i!==1073741824&&(n.flags|=128,l=!0,Do(g,!1),n.lanes=4194304);g.isBackwards?(S.sibling=n.child,n.child=S):(i=g.last,i!==null?i.sibling=S:n.child=S,g.last=S)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(Nt(n),null);case 22:case 23:return ku(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Yt&1073741824)!==0&&(Nt(n),n.subtreeFlags&6&&(n.flags|=8192)):Nt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function Ly(e,n){switch(Ra(n),n.tag){case 1:return Tt(n.type)&&Is(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Fi(),Ue(Rt),Ue(St),Ua(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Va(n),null;case 13:if(Ue(qe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));$i()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Fi(),null;case 10:return Da(n.type._context),null;case 22:case 23:return ku(),null;case 24:return null;default:return null}}var Qs=!1,jt=!1,Ay=typeof WeakSet=="function"?WeakSet:Set,ye=null;function Bi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Ze(e,n,l)}else i.current=null}function du(e,n,i){try{i()}catch(l){Ze(e,n,l)}}var kf=!1;function $y(e,n){if(ka=ys,e=ed(),ga(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,g=l.focusNode;l=l.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var S=0,T=-1,O=-1,J=0,ae=0,ue=e,le=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=S+f),ue!==g||l!==0&&ue.nodeType!==3||(O=S+l),ue.nodeType===3&&(S+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)le=ue,ue=ge;for(;;){if(ue===e)break t;if(le===i&&++J===f&&(T=S),le===g&&++ae===l&&(O=S),(ge=ue.nextSibling)!==null)break;ue=le,le=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(Na={focusedElem:e,selectionRange:i},ys=!1,ye=n;ye!==null;)if(n=ye,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ye=e;else for(;ye!==null;){n=ye;try{var xe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var we=xe.memoizedProps,et=xe.memoizedState,X=n.stateNode,H=X.getSnapshotBeforeUpdate(n.elementType===n.type?we:an(n.type,we),et);X.__reactInternalSnapshotBeforeUpdate=H}break;case 3:var K=n.stateNode.containerInfo;K.nodeType===1?K.textContent="":K.nodeType===9&&K.documentElement&&K.removeChild(K.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(de){Ze(n,n.return,de)}if(e=n.sibling,e!==null){e.return=n.return,ye=e;break}ye=n.return}return xe=kf,kf=!1,xe}function Oo(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&e)===e){var g=f.destroy;f.destroy=void 0,g!==void 0&&du(n,i,g)}f=f.next}while(f!==l)}}function Zs(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function fu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function Nf(e){var n=e.alternate;n!==null&&(e.alternate=null,Nf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[Cn],delete n[Co],delete n[Ca],delete n[vy],delete n[xy])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function jf(e){return e.tag===5||e.tag===3||e.tag===4}function bf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||jf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function hu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=Ms));else if(l!==4&&(e=e.child,e!==null))for(hu(e,n,i),e=e.sibling;e!==null;)hu(e,n,i),e=e.sibling}function pu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(pu(e,n,i),e=e.sibling;e!==null;)pu(e,n,i),e=e.sibling}var vt=null,un=!1;function kr(e,n,i){for(i=i.child;i!==null;)Ef(e,n,i),i=i.sibling}function Ef(e,n,i){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(Vn,i)}catch{}switch(i.tag){case 5:jt||Bi(i,n);case 6:var l=vt,f=un;vt=null,kr(e,n,i),vt=l,un=f,vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):vt.removeChild(i.stateNode));break;case 18:vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?Ea(e.parentNode,i):e.nodeType===1&&Ea(e,i),yo(e)):Ea(vt,i.stateNode));break;case 4:l=vt,f=un,vt=i.stateNode.containerInfo,un=!0,kr(e,n,i),vt=l,un=f;break;case 0:case 11:case 14:case 15:if(!jt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var g=f,S=g.destroy;g=g.tag,S!==void 0&&((g&2)!==0||(g&4)!==0)&&du(i,n,S),f=f.next}while(f!==l)}kr(e,n,i);break;case 1:if(!jt&&(Bi(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Ze(i,n,T)}kr(e,n,i);break;case 21:kr(e,n,i);break;case 22:i.mode&1?(jt=(l=jt)||i.memoizedState!==null,kr(e,n,i),jt=l):kr(e,n,i);break;default:kr(e,n,i)}}function Cf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Ay),n.forEach(function(l){var f=Uy.bind(null,e,l);i.has(l)||(i.add(l),l.then(f,f))})}}function cn(e,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=S),l&=~g}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Dy(l/1960))-l,10e?16:e,jr===null)var l=!1;else{if(e=jr,jr=null,rl=0,(ze&6)!==0)throw Error(o(331));var f=ze;for(ze|=4,ye=e.current;ye!==null;){var g=ye,S=g.child;if((ye.flags&16)!==0){var T=g.deletions;if(T!==null){for(var O=0;OVe()-yu?oi(e,0):mu|=i),$t(e,n)}function Hf(e,n){n===0&&((e.mode&1)===0?n=1:(n=Un,Un<<=1,(Un&130023424)===0&&(Un=4194304)));var i=Mt();e=Zn(e,n),e!==null&&(En(e,n,i),$t(e,i))}function Wy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Hf(e,i)}function Uy(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Hf(e,i)}var Bf;Bf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Rt.current)Lt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Lt=!1,Ry(e,n,i);Lt=(e.flags&131072)!==0}else Lt=!1,Xe&&(n.flags&1048576)!==0&&wd(n,As,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Ks(e,n),e=n.pendingProps;var f=Ti(n,St.current);Oi(n,i),f=Xa(null,n,l,e,f,i);var g=qa();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Tt(l)?(g=!0,Rs(n)):g=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Ha(n),f.updater=Xs,n.stateNode=f,f._reactInternals=n,tu(n,l,e,i),n=ou(null,n,l,!0,g,i)):(n.tag=0,Xe&&g&&Ia(n),Ct(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Ks(e,n),e=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=Gy(l),e=an(l,e),f){case 0:n=iu(null,n,l,e,i);break e;case 1:n=pf(null,n,l,e,i);break e;case 11:n=uf(null,n,l,e,i);break e;case 14:n=cf(null,n,l,an(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),iu(e,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),pf(e,n,l,f,i);case 3:e:{if(gf(n),e===null)throw Error(o(387));l=n.pendingProps,g=n.memoizedState,f=g.element,Md(e,n),Hs(n,l,null,i);var S=n.memoizedState;if(l=S.element,g.isDehydrated)if(g={element:l,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){f=Hi(Error(o(423)),n),n=mf(e,n,l,i,f);break e}else if(l!==f){f=Hi(Error(o(424)),n),n=mf(e,n,l,i,f);break e}else for(Ut=yr(n.stateNode.containerInfo.firstChild),Wt=n,Xe=!0,ln=null,i=Ed(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if($i(),l===f){n=er(e,n,i);break e}Ct(e,n,l,i)}n=n.child}return n;case 5:return Rd(n),e===null&&La(n),l=n.type,f=n.pendingProps,g=e!==null?e.memoizedProps:null,S=f.children,ja(l,f)?S=null:g!==null&&ja(l,g)&&(n.flags|=32),hf(e,n),Ct(e,n,S,i),n.child;case 6:return e===null&&La(n),null;case 13:return yf(e,n,i);case 4:return Ba(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=zi(n,null,l,i):Ct(e,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),uf(e,n,l,f,i);case 7:return Ct(e,n,n.pendingProps,i),n.child;case 8:return Ct(e,n,n.pendingProps.children,i),n.child;case 12:return Ct(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,g=n.memoizedProps,S=f.value,Be(Ds,l._currentValue),l._currentValue=S,g!==null)if(sn(g.value,S)){if(g.children===f.children&&!Rt.current){n=er(e,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var T=g.dependencies;if(T!==null){S=g.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(g.tag===1){O=Jn(-1,i&-i),O.tag=2;var J=g.updateQueue;if(J!==null){J=J.shared;var ae=J.pending;ae===null?O.next=O:(O.next=ae.next,ae.next=O),J.pending=O}}g.lanes|=i,O=g.alternate,O!==null&&(O.lanes|=i),Oa(g.return,i,n),T.lanes|=i;break}O=O.next}}else if(g.tag===10)S=g.type===n.type?null:g.child;else if(g.tag===18){if(S=g.return,S===null)throw Error(o(341));S.lanes|=i,T=S.alternate,T!==null&&(T.lanes|=i),Oa(S,i,n),S=g.sibling}else S=g.child;if(S!==null)S.return=g;else for(S=g;S!==null;){if(S===n){S=null;break}if(g=S.sibling,g!==null){g.return=S.return,S=g;break}S=S.return}g=S}Ct(e,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,Oi(n,i),f=Zt(f),l=l(f),n.flags|=1,Ct(e,n,l,i),n.child;case 14:return l=n.type,f=an(l,n.pendingProps),f=an(l.type,f),cf(e,n,l,f,i);case 15:return df(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),Ks(e,n),n.tag=1,Tt(l)?(e=!0,Rs(n)):e=!1,Oi(n,i),tf(n,l,f),tu(n,l,f,i),ou(null,n,l,!0,e,i);case 19:return xf(e,n,i);case 22:return ff(e,n,i)}throw Error(o(156,n.tag))};function Vf(e,n){return Hr(e,n)}function Yy(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tn(e,n,i,l){return new Yy(e,n,i,l)}function ju(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Gy(e){if(typeof e=="function")return ju(e)?1:0;if(e!=null){if(e=e.$$typeof,e===te)return 11;if(e===V)return 14}return 2}function Cr(e,n){var i=e.alternate;return i===null?(i=tn(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function ll(e,n,i,l,f,g){var S=2;if(l=e,typeof e=="function")ju(e)&&(S=1);else if(typeof e=="string")S=5;else e:switch(e){case B:return li(i.children,f,g,n);case G:S=8,f|=8;break;case Q:return e=tn(12,i,n,f|2),e.elementType=Q,e.lanes=g,e;case q:return e=tn(13,i,n,f),e.elementType=q,e.lanes=g,e;case C:return e=tn(19,i,n,f),e.elementType=C,e.lanes=g,e;case U:return al(i,f,g,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ne:S=10;break e;case ee:S=9;break e;case te:S=11;break e;case V:S=14;break e;case W:S=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=tn(S,i,n,f),n.elementType=e,n.type=l,n.lanes=g,n}function li(e,n,i,l){return e=tn(7,e,l,n),e.lanes=i,e}function al(e,n,i,l){return e=tn(22,e,l,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function bu(e,n,i){return e=tn(6,e,null,n),e.lanes=i,e}function Eu(e,n,i){return n=tn(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Xy(e,n,i,l,f){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Yn(0),this.expirationTimes=Yn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Yn(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Cu(e,n,i,l,f,g,S,T,O){return e=new Xy(e,n,i,T,O),n===1?(n=1,g===!0&&(n|=8)):n=0,g=tn(3,null,null,n),e.current=g,g.stateNode=e,g.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ha(g),e}function qy(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),Lu.exports=l0(),Lu.exports}var rh;function a0(){if(rh)return gl;rh=1;var t=jp();return gl.createRoot=t.createRoot,gl.hydrateRoot=t.hydrateRoot,gl}var u0=a0();function bp(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Ae(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(bp(s,o.statusText||"Request failed"))}return o.json()}const c0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Pe={health:()=>Ae("/api/health"),settings:()=>Ae("/api/settings"),saveSettings:t=>{const r={...t};for(const o of c0)r[o]===""&&delete r[o];return Ae("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ae("/api/repos"),browse:t=>Ae(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ae(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ae("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ae(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Ae(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:(t,r=!0)=>Ae(`/api/architecture?repo_path=${encodeURIComponent(t)}&graph=${r?"1":"0"}`),architectureGraph:t=>Ae(`/api/architecture/graph?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Ae("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Ae("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Ae("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Ae("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Ae("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Ae(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open",s)=>Ae("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o,repo_path:s||null})}),scmRepos:t=>Ae(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ae("/api/oauth/status"),githubOAuthStart:()=>Ae("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ae("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ae("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Ae("/api/oauth/gitlab/start"),oauthDisconnect:t=>Ae("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ae("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})}),reviews:t=>Ae(`/api/reviews?repo_path=${encodeURIComponent(t)}`),getReview:(t,r)=>Ae(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(t)}`),reviewDiff:(t,r,o)=>Ae(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(t)}&other=${encodeURIComponent(o)}`),config:t=>Ae(`/api/config?repo_path=${encodeURIComponent(t)}`),saveConfig:(t,r)=>Ae("/api/config",{method:"PUT",body:JSON.stringify({repo_path:t,...r})}),addWaiver:(t,r,o,s)=>Ae("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:t,rule:r,node:o||null,reason:s||""})}),marks:(t,r)=>Ae(`/api/marks?repo_path=${encodeURIComponent(t)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:t=>Ae(`/api/architecture/health?repo_path=${encodeURIComponent(t)}`),workspaceStatus:t=>Ae(`/api/workspace/status?repo_path=${encodeURIComponent(t)}`),openEditor:(t,r,o,s)=>Ae("/api/open",{method:"POST",body:JSON.stringify({repo_path:t,path:r,line:o||null,editor:s||null})}),exportHtml:t=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:t})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(bp(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(t,r,o,s)=>Ae("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:t,edges:r,source_id:o,target_id:s||null})})};function d0(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):t}function f0({open:t,actions:r,onClose:o}){const[s,a]=L.useState(""),[u,c]=L.useState(0),h=L.useRef(null),p=L.useMemo(()=>d0(r,s),[r,s]);if(L.useEffect(()=>{if(!t)return;a(""),c(0);const v=window.setTimeout(()=>{var m;return(m=h.current)==null?void 0:m.focus()},0);return()=>window.clearTimeout(v)},[t]),L.useEffect(()=>{c(0)},[s]),!t)return null;const y=p[u],x=v=>{v&&(o(),v.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:v=>{v.target===v.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:v=>a(v.target.value),onKeyDown:v=>{v.key==="Escape"?(v.preventDefault(),o()):v.key==="ArrowDown"?(v.preventDefault(),c(m=>Math.min(p.length-1,m+1))):v.key==="ArrowUp"?(v.preventDefault(),c(m=>Math.max(0,m-1))):v.key==="Enter"&&(v.preventDefault(),x(y))}}),d.jsxs("ul",{children:[p.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,p.slice(0,40).map((v,m)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:m===u?"active":"",onMouseEnter:()=>c(m),onClick:()=>x(v),children:[d.jsx("span",{children:v.label}),v.hint?d.jsx("span",{className:"muted",children:v.hint}):null]})},v.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function h0({config:t,busy:r,onSave:o,onWaiver:s}){const[a,u]=L.useState(t),[c,h]=L.useState(t.available_rules[0]||""),[p,y]=L.useState(""),[x,v]=L.useState("");L.useEffect(()=>{u(t)},[t]);const m=Object.entries(a.contexts||{}),_=(P,w,j)=>{const $=a.contexts[P];if(!$)return;const z=B=>B.split(",").map(G=>G.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[P]:{...$,[w]:w==="name"?j:z(j)}}})},k=(P,w)=>{const j=w.trim();if(!j||j===P)return;const{[P]:$,...z}=a.contexts;$&&u({...a,contexts:{...z,[j]:{...$,name:j}}})},b=()=>{let P=1;for(;a.contexts[`context-${P}`];)P+=1;const w=`context-${P}`;u({...a,contexts:{...a.contexts,[w]:{name:w,django_apps:[],react:[],public_api:[],owners:[]}}})},E=P=>{const{[P]:w,...j}=a.contexts;u({...a,contexts:j})},N=P=>{const w=a.rules.includes(P);u({...a,rules:w?a.rules.filter(j=>j!==P):[...a.rules,P]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),m.map(([P,w])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:P})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:P,"data-testid":`config-context-name-${P}`,onBlur:j=>k(P,j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(w.django_apps||[]).join(", "),onChange:j=>_(P,"django_apps",j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(w.react||[]).join(", "),onChange:j=>_(P,"react",j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(w.public_api||[]).join(", "),onChange:j=>_(P,"public_api",j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(w.owners||[]).join(", "),onChange:j=>_(P,"owners",j.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>E(P),children:"Remove context"})]},P)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:b,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(P=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(P),onChange:()=>N(P)}),P]},P))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((P,w)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:P.rule}),P.node?` · ${P.node}`:"",P.reason?` — ${P.reason}`:""]},`${P.rule}:${P.node}:${w}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:P=>h(P.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(P=>d.jsx("option",{value:P,children:P},P))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:P=>y(P.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:x,onChange:P=>v(P.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,x),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function Qo(t){return t.replaceAll("_"," ")}function p0(t){return t.replaceAll("_"," ")}function ro(t){return t.split(".").pop()||t}function Ju(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function g0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Tr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function yi({className:t,children:r}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function m0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function y0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function v0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function x0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function w0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function Ep({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function _0({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const S0="modulepreload",k0=function(t,r){return new URL(t,r).href},ih={},N0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(x){return Promise.all(x.map(v=>Promise.resolve(v).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),y=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(x=>{if(x=k0(x,s),x in ih)return;ih[x]=!0;const v=x.endsWith(".css"),m=v?'[rel="stylesheet"]':"";if(!!s)for(let b=h.length-1;b>=0;b--){const E=h[b];if(E.href===x&&(!v||E.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${x}"]${m}`))return;const k=document.createElement("link");if(k.rel=v?"stylesheet":S0,v||(k.as="script"),k.crossOrigin="",k.href=x,y&&k.setAttribute("nonce",y),document.head.appendChild(k),v)return new Promise((b,E)=>{k.addEventListener("load",b),k.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${x}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function nt(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Wl(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}El.prototype=Wl.prototype={constructor:El,on:function(t,r){var o=this._,s=b0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),sh.hasOwnProperty(r)?{space:sh[r],local:t}:t}function C0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===ec&&r.documentElement.namespaceURI===ec?r.createElement(t):r.createElementNS(o,t)}}function M0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Cp(t){var r=Ul(t);return(r.local?M0:C0)(r)}function P0(){}function pc(t){return t==null?P0:function(){return this.querySelector(t)}}function I0(t){typeof t!="function"&&(t=pc(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=w&&(w=P+1);!($=E[w])&&++w=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function nv(t){t||(t=rv);function r(v,m){return v&&m?t(v.__data__,m.__data__):!v-!m}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function iv(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function ov(){return Array.from(this)}function sv(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?yv:typeof r=="function"?xv:vv)(t,r,o??"")):Ki(this.node(),t)}function Ki(t,r){return t.style.getPropertyValue(r)||Tp(t).getComputedStyle(t,null).getPropertyValue(r)}function _v(t){return function(){delete this[t]}}function Sv(t,r){return function(){this[t]=r}}function kv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function Nv(t,r){return arguments.length>1?this.each((r==null?_v:typeof r=="function"?kv:Sv)(t,r)):this.node()[t]}function Lp(t){return t.trim().split(/^|\s+/)}function gc(t){return t.classList||new Ap(t)}function Ap(t){this._node=t,this._names=Lp(t.getAttribute("class")||"")}Ap.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function $p(t,r){for(var o=gc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function Zv(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function tc(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:y,dispatch:x}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:y,enumerable:!0,configurable:!0},_:{value:x}})}tc.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function ax(t){return!t.ctrlKey&&!t.button}function ux(){return this.parentNode}function cx(t,r){return r??{x:t.x,y:t.y}}function dx(){return navigator.maxTouchPoints||"ontouchstart"in this}function Bp(){var t=ax,r=ux,o=cx,s=dx,a={},u=Wl("start","drag","end"),c=0,h,p,y,x,v=0;function m(j){j.on("mousedown.drag",_).filter(s).on("touchstart.drag",E).on("touchmove.drag",N,lx).on("touchend.drag touchcancel.drag",P).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(j,$){if(!(x||!t.call(this,j,$))){var z=w(this,r.call(this,j,$),j,$,"mouse");z&&(Gt(j.view).on("mousemove.drag",k,Zo).on("mouseup.drag",b,Zo),Fp(j.view),zu(j),y=!1,h=j.clientX,p=j.clientY,z("start",j))}}function k(j){if(Xi(j),!y){var $=j.clientX-h,z=j.clientY-p;y=$*$+z*z>v}a.mouse("drag",j)}function b(j){Gt(j.view).on("mousemove.drag mouseup.drag",null),Hp(j.view,y),Xi(j),a.mouse("end",j)}function E(j,$){if(t.call(this,j,$)){var z=j.changedTouches,B=r.call(this,j,$),G=z.length,Q,ne;for(Q=0;Q>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?yl(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?yl(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=hx.exec(t))?new Dt(r[1],r[2],r[3],1):(r=px.exec(t))?new Dt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=gx.exec(t))?yl(r[1],r[2],r[3],r[4]):(r=mx.exec(t))?yl(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=yx.exec(t))?hh(r[1],r[2]/100,r[3]/100,1):(r=vx.exec(t))?hh(r[1],r[2]/100,r[3]/100,r[4]):lh.hasOwnProperty(t)?ch(lh[t]):t==="transparent"?new Dt(NaN,NaN,NaN,0):null}function ch(t){return new Dt(t>>16&255,t>>8&255,t&255,1)}function yl(t,r,o,s){return s<=0&&(t=r=o=NaN),new Dt(t,r,o,s)}function _x(t){return t instanceof ds||(t=fi(t)),t?(t=t.rgb(),new Dt(t.r,t.g,t.b,t.opacity)):new Dt}function nc(t,r,o,s){return arguments.length===1?_x(t):new Dt(t,r,o,s??1)}function Dt(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}mc(Dt,nc,Vp(ds,{brighter(t){return t=t==null?Tl:Math.pow(Tl,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Jo:Math.pow(Jo,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Dt(ci(this.r),ci(this.g),ci(this.b),Ll(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:dh,formatHex:dh,formatHex8:Sx,formatRgb:fh,toString:fh}));function dh(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}`}function Sx(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}${ui((isNaN(this.opacity)?1:this.opacity)*255)}`}function fh(){const t=Ll(this.opacity);return`${t===1?"rgb(":"rgba("}${ci(this.r)}, ${ci(this.g)}, ${ci(this.b)}${t===1?")":`, ${t})`}`}function Ll(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ci(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ui(t){return t=ci(t),(t<16?"0":"")+t.toString(16)}function hh(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new hn(t,r,o,s)}function Wp(t){if(t instanceof hn)return new hn(t.h,t.s,t.l,t.opacity);if(t instanceof ds||(t=fi(t)),!t)return new hn;if(t instanceof hn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new hn(c,h,p,t.opacity)}function kx(t,r,o,s){return arguments.length===1?Wp(t):new hn(t,r,o,s??1)}function hn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}mc(hn,kx,Vp(ds,{brighter(t){return t=t==null?Tl:Math.pow(Tl,t),new hn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Jo:Math.pow(Jo,t),new hn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Dt(Du(t>=240?t-240:t+120,a,s),Du(t,a,s),Du(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new hn(ph(this.h),vl(this.s),vl(this.l),Ll(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 t=Ll(this.opacity);return`${t===1?"hsl(":"hsla("}${ph(this.h)}, ${vl(this.s)*100}%, ${vl(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ph(t){return t=(t||0)%360,t<0?t+360:t}function vl(t){return Math.max(0,Math.min(1,t||0))}function Du(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const yc=t=>()=>t;function Nx(t,r){return function(o){return t+o*r}}function jx(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function bx(t){return(t=+t)==1?Up:function(r,o){return o-r?jx(r,o,t):yc(isNaN(r)?o:r)}}function Up(t,r){var o=r-t;return o?Nx(t,o):yc(isNaN(t)?r:t)}const Al=(function t(r){var o=bx(r);function s(a,u){var c=o((a=nc(a)).r,(u=nc(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),y=Up(a.opacity,u.opacity);return function(x){return a.r=c(x),a.g=h(x),a.b=p(x),a.opacity=y(x),a+""}}return s.gamma=t,s})(1);function Ex(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:Rn(s,a)})),o=Ou.lastIndex;return o180?x+=360:x-y>180&&(y+=360),m.push({i:v.push(a(v)+"rotate(",null,s)-2,x:Rn(y,x)})):x&&v.push(a(v)+"rotate("+x+s)}function h(y,x,v,m){y!==x?m.push({i:v.push(a(v)+"skewX(",null,s)-2,x:Rn(y,x)}):x&&v.push(a(v)+"skewX("+x+s)}function p(y,x,v,m,_,k){if(y!==v||x!==m){var b=_.push(a(_)+"scale(",null,",",null,")");k.push({i:b-4,x:Rn(y,v)},{i:b-2,x:Rn(x,m)})}else(v!==1||m!==1)&&_.push(a(_)+"scale("+v+","+m+")")}return function(y,x){var v=[],m=[];return y=t(y),x=t(x),u(y.translateX,y.translateY,x.translateX,x.translateY,v,m),c(y.rotate,x.rotate,v,m),h(y.skewX,x.skewX,v,m),p(y.scaleX,y.scaleY,x.scaleX,x.scaleY,v,m),y=x=null,function(_){for(var k=-1,b=m.length,E;++k=0&&t._call.call(void 0,r),t=t._next;--Qi}function yh(){hi=(zl=ts.now())+Yl,Qi=Go=0;try{Bx()}finally{Qi=0,Wx(),hi=0}}function Vx(){var t=ts.now(),r=t-zl;r>qp&&(Yl-=r,zl=t)}function Wx(){for(var t,r=$l,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:$l=o);Xo=t,oc(s)}function oc(t){if(!Qi){Go&&(Go=clearTimeout(Go));var r=t-hi;r>24?(t<1/0&&(Go=setTimeout(yh,t-ts.now()-Yl)),Uo&&(Uo=clearInterval(Uo))):(Uo||(zl=ts.now(),Uo=setInterval(Vx,qp)),Qi=1,Kp(yh))}}function vh(t,r,o){var s=new Dl;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Ux=Wl("start","end","cancel","interrupt"),Yx=[],Zp=0,xh=1,sc=2,Ml=3,wh=4,lc=5,Pl=6;function Gl(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;Gx(t,o,{name:r,index:s,group:a,on:Ux,tween:Yx,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Zp})}function xc(t,r){var o=yn(t,r);if(o.state>Zp)throw new Error("too late; already scheduled");return o}function Ln(t,r){var o=yn(t,r);if(o.state>Ml)throw new Error("too late; already running");return o}function yn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Gx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=Qp(u,0,o.time);function u(y){o.state=xh,o.timer.restart(c,o.delay,o.time),o.delay<=y&&c(y-o.delay)}function c(y){var x,v,m,_;if(o.state!==xh)return p();for(x in s)if(_=s[x],_.name===o.name){if(_.state===Ml)return vh(c);_.state===wh?(_.state=Pl,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete s[x]):+xsc&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function kw(t,r,o){var s,a,u=Sw(r)?xc:Ln;return function(){var c=u(this,t),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function Nw(t,r){var o=this._id;return arguments.length<2?yn(this.node(),o).on.on(t):this.each(kw(o,t,r))}function jw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function bw(){return this.on("end.remove",jw(this._id))}function Ew(t){var r=this._name,o=this._id;typeof t!="function"&&(t=pc(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function Zw(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function rr(t,r,o){this.k=t,this.x=r,this.y=o}rr.prototype={constructor:rr,scale:function(t){return t===1?this:new rr(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new rr(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Xl=new rr(1,0,0);ng.prototype=rr.prototype;function ng(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Xl;return t.__zoom}function Fu(t){t.stopImmediatePropagation()}function Yo(t){t.preventDefault(),t.stopImmediatePropagation()}function Jw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function e1(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function _h(){return this.__zoom||Xl}function t1(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function n1(){return navigator.maxTouchPoints||"ontouchstart"in this}function r1(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function rg(){var t=Jw,r=e1,o=r1,s=t1,a=n1,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=Cl,y=Wl("start","zoom","end"),x,v,m,_=500,k=150,b=0,E=10;function N(C){C.property("__zoom",_h).on("wheel.zoom",G,{passive:!1}).on("mousedown.zoom",Q).on("dblclick.zoom",ne).filter(a).on("touchstart.zoom",ee).on("touchmove.zoom",te).on("touchend.zoom touchcancel.zoom",q).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}N.transform=function(C,V,W,U){var M=C.selection?C.selection():C;M.property("__zoom",_h),C!==M?$(C,V,W,U):M.interrupt().each(function(){z(this,arguments).event(U).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},N.scaleBy=function(C,V,W,U){N.scaleTo(C,function(){var M=this.__zoom.k,D=typeof V=="function"?V.apply(this,arguments):V;return M*D},W,U)},N.scaleTo=function(C,V,W,U){N.transform(C,function(){var M=r.apply(this,arguments),D=this.__zoom,F=W==null?j(M):typeof W=="function"?W.apply(this,arguments):W,R=D.invert(F),A=typeof V=="function"?V.apply(this,arguments):V;return o(w(P(D,A),F,R),M,c)},W,U)},N.translateBy=function(C,V,W,U){N.transform(C,function(){return o(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),r.apply(this,arguments),c)},null,U)},N.translateTo=function(C,V,W,U,M){N.transform(C,function(){var D=r.apply(this,arguments),F=this.__zoom,R=U==null?j(D):typeof U=="function"?U.apply(this,arguments):U;return o(Xl.translate(R[0],R[1]).scale(F.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),D,c)},U,M)};function P(C,V){return V=Math.max(u[0],Math.min(u[1],V)),V===C.k?C:new rr(V,C.x,C.y)}function w(C,V,W){var U=V[0]-W[0]*C.k,M=V[1]-W[1]*C.k;return U===C.x&&M===C.y?C:new rr(C.k,U,M)}function j(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function $(C,V,W,U){C.on("start.zoom",function(){z(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){z(this,arguments).event(U).end()}).tween("zoom",function(){var M=this,D=arguments,F=z(M,D).event(U),R=r.apply(M,D),A=W==null?j(R):typeof W=="function"?W.apply(M,D):W,ie=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),oe=M.__zoom,fe=typeof V=="function"?V.apply(M,D):V,he=p(oe.invert(A).concat(ie/oe.k),fe.invert(A).concat(ie/fe.k));return function(pe){if(pe===1)pe=fe;else{var Z=he(pe),se=ie/Z[2];pe=new rr(se,A[0]-Z[0]*se,A[1]-Z[1]*se)}F.zoom(null,pe)}})}function z(C,V,W){return!W&&C.__zooming||new B(C,V)}function B(C,V){this.that=C,this.args=V,this.active=0,this.sourceEvent=null,this.extent=r.apply(C,V),this.taps=0}B.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,V){return this.mouse&&C!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var V=Gt(this.that).datum();y.call(C,this.that,new Zw(C,{sourceEvent:this.sourceEvent,target:N,transform:this.that.__zoom,dispatch:y}),V)}};function G(C,...V){if(!t.apply(this,arguments))return;var W=z(this,V).event(C),U=this.__zoom,M=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,s.apply(this,arguments)))),D=fn(C);if(W.wheel)(W.mouse[0][0]!==D[0]||W.mouse[0][1]!==D[1])&&(W.mouse[1]=U.invert(W.mouse[0]=D)),clearTimeout(W.wheel);else{if(U.k===M)return;W.mouse=[D,U.invert(D)],Il(this),W.start()}Yo(C),W.wheel=setTimeout(F,k),W.zoom("mouse",o(w(P(U,M),W.mouse[0],W.mouse[1]),W.extent,c));function F(){W.wheel=null,W.end()}}function Q(C,...V){if(m||!t.apply(this,arguments))return;var W=C.currentTarget,U=z(this,V,!0).event(C),M=Gt(C.view).on("mousemove.zoom",A,!0).on("mouseup.zoom",ie,!0),D=fn(C,W),F=C.clientX,R=C.clientY;Fp(C.view),Fu(C),U.mouse=[D,this.__zoom.invert(D)],Il(this),U.start();function A(oe){if(Yo(oe),!U.moved){var fe=oe.clientX-F,he=oe.clientY-R;U.moved=fe*fe+he*he>b}U.event(oe).zoom("mouse",o(w(U.that.__zoom,U.mouse[0]=fn(oe,W),U.mouse[1]),U.extent,c))}function ie(oe){M.on("mousemove.zoom mouseup.zoom",null),Hp(oe.view,U.moved),Yo(oe),U.event(oe).end()}}function ne(C,...V){if(t.apply(this,arguments)){var W=this.__zoom,U=fn(C.changedTouches?C.changedTouches[0]:C,this),M=W.invert(U),D=W.k*(C.shiftKey?.5:2),F=o(w(P(W,D),U,M),r.apply(this,V),c);Yo(C),h>0?Gt(this).transition().duration(h).call($,F,U,C):Gt(this).call(N.transform,F,U,C)}}function ee(C,...V){if(t.apply(this,arguments)){var W=C.touches,U=W.length,M=z(this,V,C.changedTouches.length===U).event(C),D,F,R,A;for(Fu(C),F=0;F`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},ns=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ig=["Enter"," ","Escape"],og={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Zi;(function(t){t.Strict="strict",t.Loose="loose"})(Zi||(Zi={}));var di;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(di||(di={}));var rs;(function(t){t.Partial="partial",t.Full="full"})(rs||(rs={}));const sg={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Lr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Lr||(Lr={}));var is;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(is||(is={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const Sh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function lg(t){return t===null?null:t?"valid":"invalid"}const ag=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,i1=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),_c=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),fs=(t,r=[0,0])=>{const{width:o,height:s}=vn(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},o1=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):_c(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,ql(a,Ol(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?Kl(s):{x:0,y:0,width:0,height:0}},hs=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=ql(o,Ol(a)),s=!0)}),s?Kl(o):{x:0,y:0,width:0,height:0}},Sc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,y=r.width/a,x=r.height/a,v=[];for(const m of t.values()){const{measured:_,selectable:k=!0,hidden:b=!1}=m;if(c&&!k||b)continue;const E=_.width??m.width??m.initialWidth??0,N=_.height??m.height??m.initialHeight??0,{x:P,y:w}=m.internals.positionAbsolute,j=fg(h,p,y,x,P,w,E,N),$=E*N,z=u&&j>0;(!m.internals.handleBounds||z||j>=$||m.dragging)&&v.push(m)}return v},s1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function l1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=vn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function a1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const h=l1(t,c),p=hs(h),y=Nc(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(y,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function ug({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),h=c.parentId?o.get(c.parentId):void 0,{x:p,y}=h?h.internals.positionAbsolute:{x:0,y:0},x=c.origin??s;let v=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",mn.error005());else{const{width:_,height:k}=vn(h);_&&k&&(v=[[p,y],[p+_,y+k]])}else h&&gi(c.extent)&&(v=[[c.extent[0][0]+p,c.extent[0][1]+y],[c.extent[1][0]+p,c.extent[1][1]+y]]);const m=gi(v)?pi(r,v,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",mn.error015())),{position:{x:m.x-p+(c.measured.width??0)*x[0],y:m.y-y+(c.measured.height??0)*x[1]},positionAbsolute:m}}async function u1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(m=>m.id)),c=[];for(const m of o){if(m.deletable===!1)continue;const _=u.has(m.id),k=!_&&m.parentId&&c.find(b=>b.id===m.parentId);(_||k)&&c.push(m)}const h=new Set(r.map(m=>m.id)),p=s.filter(m=>m.deletable!==!1),x=s1(c,p);for(const m of p)h.has(m.id)&&!x.find(k=>k.id===m.id)&&x.push(m);if(!a)return{edges:x,nodes:c};const v=await a({nodes:c,edges:x});return typeof v=="boolean"?v?{edges:x,nodes:c}:{edges:[],nodes:[]}:v}const Ji=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),pi=(t={x:0,y:0},r,o)=>({x:Ji(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:Ji(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function cg(t,r,o){const{width:s,height:a}=vn(o),{x:u,y:c}=o.internals.positionAbsolute;return pi(t,[[u,c],[u+s,c+a]],r)}const kh=(t,r,o)=>to?-Ji(Math.abs(t-o),1,r)/r:0,kc=(t,r,o=15,s=40)=>{const a=kh(t.x,s,r.width-s)*o,u=kh(t.y,s,r.height-s)*o;return[a,u]},ql=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),ac=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),Kl=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),os=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:fs(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},Ol=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:fs(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},dg=(t,r)=>Kl(ql(ac(t),ac(r))),fg=(t,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),y=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*y)},Fl=(t,r)=>fg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),Nh=t=>pn(t.width)&&pn(t.height)&&pn(t.x)&&pn(t.y),pn=t=>!isNaN(t)&&isFinite(t),hg=(t,r)=>(o,s)=>{},ps=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),gs=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(t-o)/a,y:(r-s)/a};return u?ps(h,c):h},eo=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Yi(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function c1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Yi(t,o),a=Yi(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Yi(t.top??t.y??0,o),a=Yi(t.bottom??t.y??0,o),u=Yi(t.left??t.x??0,r),c=Yi(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function d1(t,r,o,s,a,u){const{x:c,y:h}=eo(t,[r,o,s]),{x:p,y}=eo({x:t.x+t.width,y:t.y+t.height},[r,o,s]),x=a-p,v=u-y;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(x),bottom:Math.floor(v)}}const Nc=(t,r,o,s,a,u)=>{const c=c1(u,r,o),h=(r-c.x)/t.width,p=(o-c.y)/t.height,y=Math.min(h,p),x=Ji(y,s,a),v=t.x+t.width/2,m=t.y+t.height/2,_=r/2-v*x,k=o/2-m*x,b=d1(t,_,k,x,r,o),E={left:Math.min(b.left-c.left,0),top:Math.min(b.top-c.top,0),right:Math.min(b.right-c.right,0),bottom:Math.min(b.bottom-c.bottom,0)};return{x:_-E.left+E.right,y:k-E.top+E.bottom,zoom:x}},ss=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function gi(t){return t!=null&&t!=="parent"}function vn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function pg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function gg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function jh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function f1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function h1(t){return{...og,...t||{}}}function Ko(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=gn(t),h=gs({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y}=o?ps(h,r):h;return{xSnapped:p,ySnapped:y,...h}}const jc=t=>({width:t.offsetWidth,height:t.offsetHeight}),mg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},p1=["INPUT","SELECT","TEXTAREA"];function yg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:p1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const vg=t=>"clientX"in t,gn=(t,r)=>{var u,c;const o=vg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},bh=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...jc(c)}})};function xg({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=t*.125+a*.375+c*.375+o*.125,y=r*.125+u*.375+h*.375+s*.125,x=Math.abs(p-t),v=Math.abs(y-r);return[p,y,x,v]}function _l(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function Eh({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case Se.Left:return[r-_l(r-s,u),o];case Se.Right:return[r+_l(s-r,u),o];case Se.Top:return[r,o-_l(o-a,u)];case Se.Bottom:return[r,o+_l(a-o,u)]}}function wg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top,curvature:c=.25}){const[h,p]=Eh({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[y,x]=Eh({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[v,m,_,k]=xg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:y,targetControlY:x});return[`M${t},${r} C${h},${p} ${y},${x} ${s},${a}`,v,m,_,k]}function _g({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const y1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,v1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),x1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",mn.error006()),r;const s=o.getEdgeId||y1;let a;return ag(t)?a={...t}:a={...t,id:s(t)},v1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function Sg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=_g({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,h]}const Ch={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},w1=({source:t,sourcePosition:r=Se.Bottom,target:o})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function _1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:s=Se.Top,center:a,offset:u,stepPosition:c}){const h=Ch[r],p=Ch[s],y={x:t.x+h.x*u,y:t.y+h.y*u},x={x:o.x+p.x*u,y:o.y+p.y*u},v=w1({source:y,sourcePosition:r,target:x}),m=v.x!==0?"x":"y",_=v[m];let k=[],b,E;const N={x:0,y:0},P={x:0,y:0},[,,w,j]=_g({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[m]*p[m]===-1){m==="x"?(b=a.x??y.x+(x.x-y.x)*c,E=a.y??(y.y+x.y)/2):(b=a.x??(y.x+x.x)/2,E=a.y??y.y+(x.y-y.y)*c);const G=[{x:b,y:y.y},{x:b,y:x.y}],Q=[{x:y.x,y:E},{x:x.x,y:E}];h[m]===_?k=m==="x"?G:Q:k=m==="x"?Q:G}else{const G=[{x:y.x,y:x.y}],Q=[{x:x.x,y:y.y}];if(m==="x"?k=h.x===_?Q:G:k=h.y===_?G:Q,r===s){const C=Math.abs(t[m]-o[m]);if(C<=u){const V=Math.min(u-1,u-C);h[m]===_?N[m]=(y[m]>t[m]?-1:1)*V:P[m]=(x[m]>o[m]?-1:1)*V}}if(r!==s){const C=m==="x"?"y":"x",V=h[m]===p[C],W=y[C]>x[C],U=y[C]=q?(b=(ne.x+ee.x)/2,E=k[0].y):(b=k[0].x,E=(ne.y+ee.y)/2)}const $={x:y.x+N.x,y:y.y+N.y},z={x:x.x+P.x,y:x.y+P.y};return[[t,...$.x!==k[0].x||$.y!==k[0].y?[$]:[],...k,...z.x!==k[k.length-1].x||z.y!==k[k.length-1].y?[z]:[],o],b,E,w,j]}function S1(t,r,o,s){const a=Math.min(Mh(t,r)/2,Mh(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const y=t.xo.id===r):t[0])||null}function cc(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function N1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const y=cc(p,r);u.has(y)||(c.push({id:y,color:p.color||o,...p}),u.add(y))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const kg=1e3,j1=10,bc={nodeOrigin:[0,0],nodeExtent:ns,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},b1={...bc,checkEquality:!0};function Ec(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function E1(t,r,o){const s=Ec(bc,o);for(const a of t.values())if(a.parentId)Mc(a,t,r,s);else{const u=fs(a,s.nodeOrigin),c=gi(a.extent)?a.extent:s.nodeExtent,h=pi(u,c,vn(a));a.internals.positionAbsolute=h}}function C1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function Cc(t){return t==="manual"}function dc(t,r,o,s={}){var x,v;const a=Ec(b1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!Cc(a.zIndexMode)?kg:0;let p=t.length>0,y=!1;r.clear(),o.clear();for(const m of t){let _=c.get(m.id);if(a.checkEquality&&m===(_==null?void 0:_.internals.userNode))r.set(m.id,_);else{const k=fs(m,a.nodeOrigin),b=gi(m.extent)?m.extent:a.nodeExtent,E=pi(k,b,vn(m));_={...a.defaults,...m,measured:{width:(x=m.measured)==null?void 0:x.width,height:(v=m.measured)==null?void 0:v.height},internals:{positionAbsolute:E,handleBounds:C1(m,_),z:Ng(m,h,a.zIndexMode),userNode:m}},r.set(m.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),m.parentId&&Mc(_,r,o,s,u),y||(y=m.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:y}}function M1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function Mc(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=Ec(bc,s),y=t.parentId,x=r.get(y);if(!x){console.warn(`Parent node ${y} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}M1(t,o),a&&!x.parentId&&x.internals.rootParentIndex===void 0&&p==="auto"&&(x.internals.rootParentIndex=++a.i,x.internals.z=x.internals.z+a.i*j1),a&&x.internals.rootParentIndex!==void 0&&(a.i=x.internals.rootParentIndex);const v=u&&!Cc(p)?kg:0,{x:m,y:_,z:k}=P1(t,x,c,h,v,p),{positionAbsolute:b}=t.internals,E=m!==b.x||_!==b.y;(E||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:E?{x:m,y:_}:b,z:k}})}function Ng(t,r,o){const s=pn(t.zIndex)?t.zIndex:0;return Cc(o)?s:s+(t.selected?r:0)}function P1(t,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=vn(t),y=fs(t,o),x=gi(t.extent)?pi(y,t.extent,p):y;let v=pi({x:c+x.x,y:h+x.y},s,p);t.extent==="parent"&&(v=cg(v,p,r));const m=Ng(t,a,u),_=r.internals.z??0;return{x:v.x,y:v.y,z:_>=m?_+1:m}}function Pc(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const y=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??os(p),x=dg(y,h.rect);u.set(h.parentId,{expandedRect:x,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},y)=>{var w;const x=p.internals.positionAbsolute,v=vn(p),m=p.origin??s,_=h.x0||k>0||N||P)&&(a.push({id:y,type:"position",position:{x:p.position.x-_+N,y:p.position.y-k+P}}),(w=o.get(y))==null||w.forEach(j=>{t.some($=>$.id===j.id)||a.push({id:j.id,type:"position",position:{x:j.position.x+_,y:j.position.y+k}})})),(v.width0){const _=Pc(m,r,o,a);y.push(..._)}return{changes:y,updatedInternals:p}}async function R1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Th(t,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${t}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${t}-${u}`;const y=s.get(c)||new Map;s.set(c,y.set(o,r))}}function jg(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},y=`${a}-${c}--${u}-${h}`,x=`${u}-${h}--${a}-${c}`;Th("source",p,x,t,a,c),Th("target",p,y,t,u,h),r.set(s.id,s)}}function bg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:bg(o,r):!1}function Lh(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function T1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!bg(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function Hu({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[y,x]of r){const v=(c=o.get(y))==null?void 0:c.internals.userNode;v&&a.push({...v,position:x.position,dragging:s})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function L1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=ps(u,r);return{x:c.x-u.x,y:c.y-u.y}}function A1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,y={x:0,y:0},x=null,v=!1,m=null,_=!1,k=!1,b=null;function E({noDragClassName:P,handleSelector:w,domNode:j,isSelectable:$,nodeId:z,nodeClickDistance:B=0}){m=Gt(j);function G({x:te,y:q}){const{nodeLookup:C,nodeExtent:V,snapGrid:W,snapToGrid:U,nodeOrigin:M,onNodeDrag:D,onSelectionDrag:F,onError:R,updateNodePositions:A}=r();u={x:te,y:q};let ie=!1;const oe=h.size>1,fe=oe&&V?ac(hs(h)):null,he=oe&&U?L1({dragItems:h,snapGrid:W,x:te,y:q}):null;for(const[pe,Z]of h){if(!C.has(pe))continue;let se={x:te-Z.distance.x,y:q-Z.distance.y};U&&(se=he?{x:Math.round(se.x+he.x),y:Math.round(se.y+he.y)}:ps(se,W));let me=null;if(oe&&V&&!Z.extent&&fe){const{positionAbsolute:re}=Z.internals,Ne=re.x-fe.x+V[0][0],Me=re.x+Z.measured.width-fe.x2+V[1][0],Te=re.y-fe.y+V[0][1],$e=re.y+Z.measured.height-fe.y2+V[1][1];me=[[Ne,Te],[Me,$e]]}const{position:ke,positionAbsolute:ve}=ug({nodeId:pe,nextPosition:se,nodeLookup:C,nodeExtent:me||V,nodeOrigin:M,onError:R});ie=ie||Z.position.x!==ke.x||Z.position.y!==ke.y,Z.position=ke,Z.internals.positionAbsolute=ve}if(k=k||ie,!!ie&&(A(h,!0),b&&(s||D||!z&&F))){const[pe,Z]=Hu({nodeId:z,dragItems:h,nodeLookup:C});s==null||s(b,h,pe,Z),D==null||D(b,pe,Z),z||F==null||F(b,Z)}}async function Q(){if(!x)return;const{transform:te,panBy:q,autoPanSpeed:C,autoPanOnNodeDrag:V}=r();if(!V){p=!1,cancelAnimationFrame(c);return}const[W,U]=kc(y,x,C);(W!==0||U!==0)&&(u.x=(u.x??0)-W/te[2],u.y=(u.y??0)-U/te[2],await q({x:W,y:U})&&G(u)),c=requestAnimationFrame(Q)}function ne(te){var oe;const{nodeLookup:q,multiSelectionActive:C,nodesDraggable:V,transform:W,snapGrid:U,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:F,onSelectionDragStart:R,unselectNodesAndEdges:A}=r();v=!0,(!D||!$)&&!C&&z&&((oe=q.get(z))!=null&&oe.selected||A()),$&&D&&z&&(t==null||t(z));const ie=Ko(te.sourceEvent,{transform:W,snapGrid:U,snapToGrid:M,containerBounds:x});if(u=ie,h=T1(q,V,ie,z),h.size>0&&(o||F||!z&&R)){const[fe,he]=Hu({nodeId:z,dragItems:h,nodeLookup:q});o==null||o(te.sourceEvent,h,fe,he),F==null||F(te.sourceEvent,fe,he),z||R==null||R(te.sourceEvent,he)}}const ee=Bp().clickDistance(B).on("start",te=>{const{domNode:q,nodeDragThreshold:C,transform:V,snapGrid:W,snapToGrid:U}=r();x=(q==null?void 0:q.getBoundingClientRect())||null,_=!1,k=!1,b=te.sourceEvent,C===0&&ne(te),u=Ko(te.sourceEvent,{transform:V,snapGrid:W,snapToGrid:U,containerBounds:x}),y=gn(te.sourceEvent,x)}).on("drag",te=>{const{autoPanOnNodeDrag:q,transform:C,snapGrid:V,snapToGrid:W,nodeDragThreshold:U,nodeLookup:M}=r(),D=Ko(te.sourceEvent,{transform:C,snapGrid:V,snapToGrid:W,containerBounds:x});if(b=te.sourceEvent,(te.sourceEvent.type==="touchmove"&&te.sourceEvent.touches.length>1||z&&!M.has(z))&&(_=!0),!_){if(!p&&q&&v&&(p=!0,Q()),!v){const F=gn(te.sourceEvent,x),R=F.x-y.x,A=F.y-y.y;Math.sqrt(R*R+A*A)>U&&ne(te)}(u.x!==D.xSnapped||u.y!==D.ySnapped)&&h&&v&&(y=gn(te.sourceEvent,x),G(D))}}).on("end",te=>{if(!v||_){_&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,v=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:q,updateNodePositions:C,onNodeDragStop:V,onSelectionDragStop:W}=r();if(k&&(C(h,!1),k=!1),a||V||!z&&W){const[U,M]=Hu({nodeId:z,dragItems:h,nodeLookup:q,dragging:!1});a==null||a(te.sourceEvent,h,U,M),V==null||V(te.sourceEvent,U,M),z||W==null||W(te.sourceEvent,M)}}}).filter(te=>{const q=te.target;return!te.button&&(!P||!Lh(q,`.${P}`,j))&&(!w||Lh(q,w,j))});m.call(ee)}function N(){m==null||m.on(".drag",null)}return{update:E,destroy:N}}function $1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())Fl(a,os(u))>0&&s.push(u);return s}const z1=250;function D1(t,r,o,s){var h,p;let a=[],u=1/0;const c=$1(t,o,r+z1);for(const y of c){const x=[...((h=y.internals.handleBounds)==null?void 0:h.source)??[],...((p=y.internals.handleBounds)==null?void 0:p.target)??[]];for(const v of x){if(s.nodeId===v.nodeId&&s.type===v.type&&s.id===v.id)continue;const{x:m,y:_}=mi(y,v,v.position,!0),k=Math.sqrt(Math.pow(m-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const y=s.type==="source"?"target":"source";return a.find(x=>x.type===y)??a[0]}return a[0]}function Eg(t,r,o,s,a,u=!1){var y,x,v;const c=s.get(t);if(!c)return null;const h=a==="strict"?(y=c.internals.handleBounds)==null?void 0:y[r]:[...((x=c.internals.handleBounds)==null?void 0:x.source)??[],...((v=c.internals.handleBounds)==null?void 0:v.target)??[]],p=(o?h==null?void 0:h.find(m=>m.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...mi(c,p,p.position,!0)}:p}function Cg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function O1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const Mg=()=>!0;function F1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:y,autoPanOnConnect:x,flowId:v,panBy:m,cancelConnection:_,onConnectStart:k,onConnect:b,onConnectEnd:E,isValidConnection:N=Mg,onReconnectEnd:P,updateConnection:w,getTransform:j,getFromHandle:$,autoPanSpeed:z,dragThreshold:B=1,handleDomNode:G}){const Q=mg(t.target);let ne=0,ee;const{x:te,y:q}=gn(t),C=Cg(u,G),V=h==null?void 0:h.getBoundingClientRect();let W=!1;if(!V||!C)return;const U=Eg(a,C,s,p,r);if(!U)return;let M=gn(t,V),D=!1,F=null,R=!1,A=null;function ie(){if(!x||!V)return;const[ke,ve]=kc(M,V,z);m({x:ke,y:ve}),ne=requestAnimationFrame(ie)}const oe={...U,nodeId:a,type:C,position:U.position},fe=p.get(a);let pe={inProgress:!0,isValid:null,from:mi(fe,oe,Se.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:fe,to:M,toHandle:null,toPosition:Sh[oe.position],toNode:null,pointer:M};function Z(){W=!0,w(pe),k==null||k(t,{nodeId:a,handleId:s,handleType:C})}B===0&&Z();function se(ke){if(!W){const{x:$e,y:st}=gn(ke),lt=$e-te,at=st-q;if(!(lt*lt+at*at>B*B))return;Z()}if(!$()||!oe){me(ke);return}const ve=j();M=gn(ke,V),ee=D1(gs(M,ve,!1,[1,1]),o,p,oe),D||(ie(),D=!0);const re=Pg(ke,{handle:ee,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:N,doc:Q,lib:y,flowId:v,nodeLookup:p});A=re.handleDomNode,F=re.connection,R=O1(!!ee,re.isValid);const Ne=p.get(a),Me=Ne?mi(Ne,oe,Se.Left,!0):pe.from,Te={...pe,from:Me,isValid:R,to:re.toHandle&&R?eo({x:re.toHandle.x,y:re.toHandle.y},ve):M,toHandle:re.toHandle,toPosition:R&&re.toHandle?re.toHandle.position:Sh[oe.position],toNode:re.toHandle?p.get(re.toHandle.nodeId):null,pointer:M};w(Te),pe=Te}function me(ke){if(!("touches"in ke&&ke.touches.length>0)){if(W){(ee||A)&&F&&R&&(b==null||b(F));const{inProgress:ve,...re}=pe,Ne={...re,toPosition:pe.toHandle?pe.toPosition:null};E==null||E(ke,Ne),u&&(P==null||P(ke,Ne))}_(),cancelAnimationFrame(ne),D=!1,R=!1,F=null,A=null,Q.removeEventListener("mousemove",se),Q.removeEventListener("mouseup",me),Q.removeEventListener("touchmove",se),Q.removeEventListener("touchend",me)}}Q.addEventListener("mousemove",se),Q.addEventListener("mouseup",me),Q.addEventListener("touchmove",se),Q.addEventListener("touchend",me)}function Pg(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:y=Mg,nodeLookup:x}){const v=u==="target",m=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=gn(t),b=c.elementFromPoint(_,k),E=b!=null&&b.classList.contains(`${h}-flow__handle`)?b:m,N={handleDomNode:E,isValid:!1,connection:null,toHandle:null};if(E){const P=Cg(void 0,E),w=E.getAttribute("data-nodeid"),j=E.getAttribute("data-handleid"),$=E.classList.contains("connectable"),z=E.classList.contains("connectableend");if(!w||!P)return N;const B={source:v?w:s,sourceHandle:v?j:a,target:v?s:w,targetHandle:v?a:j};N.connection=B;const Q=$&&z&&(o===Zi.Strict?v&&P==="source"||!v&&P==="target":w!==s||j!==a);N.isValid=Q&&y(B),N.toHandle=Eg(w,P,j,x,o,!0)}return N}const fc={onPointerDown:F1,isValid:Pg};function H1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Gt(t);function u({translateExtent:h,width:p,height:y,zoomStep:x=1,pannable:v=!0,zoomable:m=!0,inversePan:_=!1}){const k=w=>{if(w.sourceEvent.type!=="wheel"||!r)return;const j=o(),$=w.sourceEvent.ctrlKey&&ss()?10:1,z=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*x,B=j[2]*Math.pow(2,z*$);r.scaleTo(B)};let b=[0,0];const E=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(b=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},N=w=>{const j=o();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!r)return;const $=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],z=[$[0]-b[0],$[1]-b[1]];b=$;const B=s()*Math.max(j[2],Math.log(j[2]))*(_?-1:1),G={x:j[0]-z[0]*B,y:j[1]-z[1]*B},Q=[[0,0],[p,y]];r.setViewportConstrained({x:G.x,y:G.y,zoom:j[2]},Q,h)},P=rg().on("start",E).on("zoom",v?N:null).on("zoom.wheel",m?k:null);a.call(P,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:fn}}const Ql=t=>({x:t.x,y:t.y,zoom:t.k}),Bu=({x:t,y:r,zoom:o})=>Xl.translate(t,r).scale(o),Rr=(t,r)=>t.target.closest(`.${r}`),Ig=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),B1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Vu=(t,r=0,o=B1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Rg=t=>{const r=t.ctrlKey&&ss()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function V1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:y}){return x=>{if(Rr(x,r))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const v=o.property("__zoom").k||1;if(x.ctrlKey&&c){const E=fn(x),N=Rg(x),P=v*Math.pow(2,N);s.scaleTo(o,P,E,x);return}const m=x.deltaMode===1?20:1;let _=a===di.Vertical?0:x.deltaX*m,k=a===di.Horizontal?0:x.deltaY*m;!ss()&&x.shiftKey&&a!==di.Vertical&&(_=x.deltaY*m,k=0),s.translateBy(o,-(_/v)*u,-(k/v)*u,{internal:!0});const b=Ql(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(x,b):(t.isPanScrolling=!0,h==null||h(x,b)),t.panScrollTimeout=setTimeout(()=>{y==null||y(x,b),t.isPanScrolling=!1},150)}}function W1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=Rr(s,t);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function U1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=Ql(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function Y1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;t.usedRightMouseButton=!!(o&&Ig(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,Ql(u.transform)))}}function G1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&Ig(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const p=Ql(c.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function X1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:y,lib:x,connectionInProgress:v}){return m=>{var N;const _=r||o,k=s&&m.ctrlKey,b=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(Rr(m,`${x}-flow__node`)||Rr(m,`${x}-flow__edge`)||Rr(m,`${x}-flow__selection`)||Rr(m,`${x}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!c&&!s||h||v&&!b||Rr(m,p)&&b||Rr(m,y)&&(!b||u&&b&&!r)||!s&&m.ctrlKey&&b)return!1;if(!s&&m.type==="touchstart"&&((N=m.touches)==null?void 0:N.length)>1)return m.preventDefault(),!1;if(!_&&!u&&!k&&b||!a&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(a)&&!a.includes(m.button)&&m.type==="mousedown")return!1;const E=Array.isArray(a)&&a.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||b||t)&&E}}function q1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const y={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=t.getBoundingClientRect();let v=[[0,0],[x.width,x.height]];const m=typeof ResizeObserver<"u"?new ResizeObserver(q=>{const C=q[0];C&&(v=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;m==null||m.observe(t);const _=rg().extent(()=>v).scaleExtent([r,o]).translateExtent(s),k=Gt(t).call(_);j({x:a.x,y:a.y,zoom:Ji(a.zoom,r,o)},[[0,0],[x.width,x.height]],s);const b=k.on("wheel.zoom"),E=k.on("dblclick.zoom");_.wheelDelta(Rg);async function N(q,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?qo:Cl).transform(Vu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),q)}):!1}function P({noWheelClassName:q,noPanClassName:C,onPaneContextMenu:V,userSelectionActive:W,panOnScroll:U,panOnDrag:M,panOnScrollMode:D,panOnScrollSpeed:F,preventScrolling:R,zoomOnPinch:A,zoomOnScroll:ie,zoomOnDoubleClick:oe,panActivationKeyPressed:fe=!1,zoomActivationKeyPressed:he,lib:pe,onTransformChange:Z,connectionInProgress:se,paneClickDistance:me,selectionOnDrag:ke}){W&&!y.isZoomingOrPanning&&w();const ve=U&&!he&&!W;_.clickDistance(ke?1/0:!pn(me)||me<0?0:me);const re=ve?V1({zoomPanValues:y,noWheelClassName:q,d3Selection:k,d3Zoom:_,panOnScrollMode:D,panOnScrollSpeed:F,zoomOnPinch:A,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):W1({noWheelClassName:q,preventScrolling:R,d3ZoomHandler:b});k.on("wheel.zoom",re,{passive:!1});const Ne=U1({zoomPanValues:y,onDraggingChange:p,onPanZoomStart:c});_.on("start",Ne);const Me=Y1({zoomPanValues:y,panOnDrag:M,onPaneContextMenu:!!V,onPanZoom:u,onTransformChange:Z});_.on("zoom",Me);const Te=G1({zoomPanValues:y,panOnDrag:M,panOnScroll:U,onPaneContextMenu:V,onPanZoomEnd:h,onDraggingChange:p});_.on("end",Te);const $e=X1({panActivationKeyPressed:fe,zoomActivationKeyPressed:he,panOnDrag:M,zoomOnScroll:ie,panOnScroll:U,zoomOnDoubleClick:oe,zoomOnPinch:A,userSelectionActive:W,noPanClassName:C,noWheelClassName:q,lib:pe,connectionInProgress:se});_.filter($e),oe?k.on("dblclick.zoom",E):k.on("dblclick.zoom",null)}function w(){_.on("zoom",null)}async function j(q,C,V){const W=Bu(q),U=_==null?void 0:_.constrain()(W,C,V);return U&&await N(U),U}async function $(q,C){const V=Bu(q);return await N(V,C),V}function z(q){if(k){const C=Bu(q),V=k.property("__zoom");(V.k!==q.zoom||V.x!==q.x||V.y!==q.y)&&(_==null||_.transform(k,C,null,{sync:!0}))}}function B(){const q=k?ng(k.node()):{x:0,y:0,k:1};return{x:q.x,y:q.y,zoom:q.k}}async function G(q,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?qo:Cl).scaleTo(Vu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),q)}):!1}async function Q(q,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?qo:Cl).scaleBy(Vu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),q)}):!1}function ne(q){_==null||_.scaleExtent(q)}function ee(q){_==null||_.translateExtent(q)}function te(q){const C=!pn(q)||q<0?0:q;_==null||_.clickDistance(C)}return{update:P,destroy:w,setViewport:$,setViewportConstrained:j,getViewport:B,scaleTo:G,scaleBy:Q,setScaleExtent:ne,setTranslateExtent:ee,syncViewport:z,setClickDistance:te}}var to;(function(t){t.Line="line",t.Handle="handle"})(to||(to={}));function K1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function Ah(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function Pr(t,r){return Math.max(0,r-t)}function Ir(t,r){return Math.max(0,t-r)}function Sl(t,r,o){return Math.max(0,r-t,t-o)}function $h(t,r){return t?!r:r}function Q1(t,r,o,s,a,u,c,h){let{affectsX:p,affectsY:y}=r;const{isHorizontal:x,isVertical:v}=r,m=x&&v,{xSnapped:_,ySnapped:k}=o,{minWidth:b,maxWidth:E,minHeight:N,maxHeight:P}=s,{x:w,y:j,width:$,height:z,aspectRatio:B}=t;let G=Math.floor(x?_-t.pointerX:0),Q=Math.floor(v?k-t.pointerY:0);const ne=$+(p?-G:G),ee=z+(y?-Q:Q),te=-u[0]*$,q=-u[1]*z;let C=Sl(ne,b,E),V=Sl(ee,N,P);if(c){let M=0,D=0;p&&G<0?M=Pr(w+G+te,c[0][0]):!p&&G>0&&(M=Ir(w+ne+te,c[1][0])),y&&Q<0?D=Pr(j+Q+q,c[0][1]):!y&&Q>0&&(D=Ir(j+ee+q,c[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(h){let M=0,D=0;p&&G>0?M=Ir(w+G,h[0][0]):!p&&G<0&&(M=Pr(w+ne,h[1][0])),y&&Q>0?D=Ir(j+Q,h[0][1]):!y&&Q<0&&(D=Pr(j+ee,h[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(a){if(x){const M=Sl(ne/B,N,P)*B;if(C=Math.max(C,M),c){let D=0;!p&&!y||p&&!y&&m?D=Ir(j+q+ne/B,c[1][1])*B:D=Pr(j+q+(p?G:-G)/B,c[0][1])*B,C=Math.max(C,D)}if(h){let D=0;!p&&!y||p&&!y&&m?D=Pr(j+ne/B,h[1][1])*B:D=Ir(j+(p?G:-G)/B,h[0][1])*B,C=Math.max(C,D)}}if(v){const M=Sl(ee*B,b,E)/B;if(V=Math.max(V,M),c){let D=0;!p&&!y||y&&!p&&m?D=Ir(w+ee*B+te,c[1][0])/B:D=Pr(w+(y?Q:-Q)*B+te,c[0][0])/B,V=Math.max(V,D)}if(h){let D=0;!p&&!y||y&&!p&&m?D=Pr(w+ee*B,h[1][0])/B:D=Ir(w+(y?Q:-Q)*B,h[0][0])/B,V=Math.max(V,D)}}}Q=Q+(Q<0?V:-V),G=G+(G<0?C:-C),a&&(m?ne>ee*B?Q=($h(p,y)?-G:G)/B:G=($h(p,y)?-Q:Q)*B:x?(Q=G/B,y=p):(G=Q*B,p=y));const W=p?w+G:w,U=y?j+Q:j;return{width:$+(p?-G:G),height:z+(y?-Q:Q),x:u[0]*G*(p?-1:1)+W,y:u[1]*Q*(y?-1:1)+U}}const Tg={width:0,height:0,x:0,y:0},Z1={...Tg,pointerX:0,pointerY:0,aspectRatio:1};function J1(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function e_({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Gt(t);let c={controlDirection:Ah("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:y,boundaries:x,keepAspectRatio:v,resizeDirection:m,onResizeStart:_,onResize:k,onResizeEnd:b,shouldResize:E}){let N={...Tg},P={...Z1};c={boundaries:x,resizeDirection:m,keepAspectRatio:v,controlDirection:Ah(y)};let w,j=null,$=[],z,B,G,Q=!1;const ne=Bp().on("start",ee=>{const{nodeLookup:te,transform:q,snapGrid:C,snapToGrid:V,nodeOrigin:W,paneDomNode:U}=o();if(w=te.get(r),!w)return;j=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:D}=Ko(ee.sourceEvent,{transform:q,snapGrid:C,snapToGrid:V,containerBounds:j});N={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},P={...N,pointerX:M,pointerY:D,aspectRatio:N.width/N.height},z=void 0,B=gi(w.extent)?w.extent:void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&(z=te.get(w.parentId)),z&&w.extent==="parent"&&(B=[[0,0],[z.measured.width,z.measured.height]]),$=[],G=void 0;for(const[F,R]of te)if(R.parentId===r&&($.push({id:F,position:{...R.position},extent:R.extent}),R.extent==="parent"||R.expandParent)){const A=J1(R,w,R.origin??W);G?G=[[Math.min(A[0][0],G[0][0]),Math.min(A[0][1],G[0][1])],[Math.max(A[1][0],G[1][0]),Math.max(A[1][1],G[1][1])]]:G=A}_==null||_(ee,{...N})}).on("drag",ee=>{const{transform:te,snapGrid:q,snapToGrid:C,nodeOrigin:V}=o(),W=Ko(ee.sourceEvent,{transform:te,snapGrid:q,snapToGrid:C,containerBounds:j}),U=[];if(!w)return;const{x:M,y:D,width:F,height:R}=N,A={},ie=w.origin??V,{width:oe,height:fe,x:he,y:pe}=Q1(P,c.controlDirection,W,c.boundaries,c.keepAspectRatio,ie,B,G),Z=oe!==F,se=fe!==R,me=he!==M&&Z,ke=pe!==D&&se;if(!me&&!ke&&!Z&&!se)return;if((me||ke||ie[0]===1||ie[1]===1)&&(A.x=me?he:N.x,A.y=ke?pe:N.y,N.x=A.x,N.y=A.y,$.length>0)){const Me=he-M,Te=pe-D;for(const $e of $)$e.position={x:$e.position.x-Me+ie[0]*(oe-F),y:$e.position.y-Te+ie[1]*(fe-R)},U.push($e)}if((Z||se)&&(A.width=Z&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:N.width,A.height=se&&(!c.resizeDirection||c.resizeDirection==="vertical")?fe:N.height,N.width=A.width,N.height=A.height),z&&w.expandParent){const Me=ie[0]*(A.width??0);A.x&&A.x{Q&&(b==null||b(ee,{...N}),a==null||a({...N}),Q=!1)});u.call(ne)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Wu={exports:{}},Uu={},Yu={exports:{}},Gu={};/** + * @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 zh;function t_(){if(zh)return Gu;zh=1;var t=us();function r(v,m){return v===m&&(v!==0||1/v===1/m)||v!==v&&m!==m}var o=typeof Object.is=="function"?Object.is:r,s=t.useState,a=t.useEffect,u=t.useLayoutEffect,c=t.useDebugValue;function h(v,m){var _=m(),k=s({inst:{value:_,getSnapshot:m}}),b=k[0].inst,E=k[1];return u(function(){b.value=_,b.getSnapshot=m,p(b)&&E({inst:b})},[v,_,m]),a(function(){return p(b)&&E({inst:b}),v(function(){p(b)&&E({inst:b})})},[v]),c(_),_}function p(v){var m=v.getSnapshot;v=v.value;try{var _=m();return!o(v,_)}catch{return!0}}function y(v,m){return m()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:h;return Gu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:x,Gu}var Dh;function n_(){return Dh||(Dh=1,Yu.exports=t_()),Yu.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 Oh;function r_(){if(Oh)return Uu;Oh=1;var t=us(),r=n_();function o(y,x){return y===x&&(y!==0||1/y===1/x)||y!==y&&x!==x}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Uu.useSyncExternalStoreWithSelector=function(y,x,v,m,_){var k=u(null);if(k.current===null){var b={hasValue:!1,value:null};k.current=b}else b=k.current;k=h(function(){function N(z){if(!P){if(P=!0,w=z,z=m(z),_!==void 0&&b.hasValue){var B=b.value;if(_(B,z))return j=B}return j=z}if(B=j,s(w,z))return B;var G=m(z);return _!==void 0&&_(B,G)?(w=z,B):(w=z,j=G)}var P=!1,w,j,$=v===void 0?null:v;return[function(){return N(x())},$===null?void 0:function(){return N($())}]},[x,v,m,_]);var E=a(y,k[0],k[1]);return c(function(){b.hasValue=!0,b.value=E},[E]),p(E),E},Uu}var Fh;function i_(){return Fh||(Fh=1,Wu.exports=r_()),Wu.exports}var o_=i_();const s_=Np(o_),l_={},Hh=t=>{let r;const o=new Set,s=(x,v)=>{const m=typeof x=="function"?x(r):x;if(!Object.is(m,r)){const _=r;r=v??(typeof m!="object"||m===null)?m:Object.assign({},r,m),o.forEach(k=>k(r,_))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>y,subscribe:x=>(o.add(x),()=>o.delete(x)),destroy:()=>{(l_?"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."),o.clear()}},y=r=t(s,a,p);return p},a_=t=>t?Hh(t):Hh,{useDebugValue:u_}=i0,{useSyncExternalStoreWithSelector:c_}=s_,d_=t=>t;function Lg(t,r=d_,o){const s=c_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return u_(s),s}const Bh=(t,r)=>{const o=a_(t),s=(a,u=r)=>Lg(o,a,u);return Object.assign(s,o),s},f_=(t,r)=>t?Bh(t,r):Bh;function Qe(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}jp();const Zl=L.createContext(null),h_=Zl.Provider,Ag=mn.error001("react");function De(t,r){const o=L.useContext(Zl);if(o===null)throw new Error(Ag);return Lg(o,t,r)}function Ye(){const t=L.useContext(Zl);if(t===null)throw new Error(Ag);return L.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Vh={display:"none"},p_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},$g="react-flow__node-desc",zg="react-flow__edge-desc",g_="react-flow__aria-live",m_=t=>t.ariaLiveMessage,y_=t=>t.ariaLabelConfig;function v_({rfId:t}){const r=De(m_);return d.jsx("div",{id:`${g_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:p_,children:r})}function x_({rfId:t,disableKeyboardA11y:r}){const o=De(y_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${$g}-${t}`,style:Vh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${zg}-${t}`,style:Vh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(v_,{rfId:t})]})}const Jl=L.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return d.jsx("div",{className:nt(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});Jl.displayName="Panel";const Wh="https://reactflow.dev?utm_source=attribution";function w_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:d.jsx(Jl,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Wh}`,children:d.jsx("a",{href:Wh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const __=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},kl=t=>t.id;function S_(t,r){return Qe(t.selectedNodes.map(kl),r.selectedNodes.map(kl))&&Qe(t.selectedEdges.map(kl),r.selectedEdges.map(kl))}function k_({onSelectionChange:t}){const r=Ye(),{selectedNodes:o,selectedEdges:s}=De(__,S_);return L.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const N_=t=>!!t.onSelectionChangeHandlers;function j_({onSelectionChange:t}){const r=De(N_);return t||r?d.jsx(k_,{onSelectionChange:t}):null}const Dg=[0,0],b_={x:0,y:0,zoom:1},E_=["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"],Uh=[...E_,"rfId"],C_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Yh={translateExtent:ns,nodeOrigin:Dg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function M_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=De(C_,Qe),y=Ye();L.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{x.current=Yh,h()}),[]);const x=L.useRef(Yh);return L.useEffect(()=>{for(const v of Uh){const m=t[v],_=x.current[v];m!==_&&(typeof t[v]>"u"||(v==="nodes"?r(m):v==="edges"?o(m):v==="minZoom"?s(m):v==="maxZoom"?a(m):v==="translateExtent"?u(m):v==="nodeExtent"?c(m):v==="ariaLabelConfig"?y.setState({ariaLabelConfig:h1(m)}):v==="fitView"?y.setState({fitViewQueued:m}):v==="fitViewOptions"?y.setState({fitViewOptions:m}):y.setState({[v]:m})))}x.current=t},Uh.map(v=>t[v])),null}function Gh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function P_(t){var s;const[r,o]=L.useState(t==="system"?null:t);return L.useEffect(()=>{if(t!=="system"){o(t);return}const a=Gh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=Gh())!=null&&s.matches?"dark":"light"}const Xh=typeof document<"u"?document:null;function ls(t=null,r={target:Xh,actInsideInputWithModifier:!0}){const[o,s]=L.useState(!1),a=L.useRef(!1),u=L.useRef(new Set([])),[c,h]=L.useMemo(()=>{if(t!==null){const y=(Array.isArray(t)?t:[t]).filter(v=>typeof v=="string").map(v=>v.replace(/\+/g,` +`).replace(` + +`,` ++`).split(` +`)),x=y.reduce((v,m)=>v.concat(...m),[]);return[y,x]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Xh,y=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const x=_=>{var E,N;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!y)&&yg(_))return!1;const b=Kh(_.code,h);if(u.current.add(_[b]),qh(c,u.current,!1)){const P=((N=(E=_.composedPath)==null?void 0:E.call(_))==null?void 0:N[0])||_.target,w=(P==null?void 0:P.nodeName)==="BUTTON"||(P==null?void 0:P.nodeName)==="A";r.preventDefault!==!1&&(a.current||!w)&&_.preventDefault(),s(!0)}},v=_=>{const k=Kh(_.code,h);qh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},m=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",x),p==null||p.addEventListener("keyup",v),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{p==null||p.removeEventListener("keydown",x),p==null||p.removeEventListener("keyup",v),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,s]),o}function qh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Kh(t,r){return r.includes(t)?"code":"key"}const I_=()=>{const t=Ye();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=Nc(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),y={x:r.x-h,y:r.y-p},x=o.snapGrid??a,v=o.snapToGrid??u;return gs(y,s,v,x)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=eo(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function Og(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)R_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function R_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function T_(t,r){return Og(t,r)}function L_(t,r){return Og(t,r)}function ai(t,r){return{id:t,type:"select",selected:r}}function Gi(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(ai(u.id,c)))}return s}function Qh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Zh(t){return{id:t.id,type:"remove"}}const A_=hg();function $_(t,r,o={}){return x1(t,r,{...o,onError:o.onError??A_})}const Jh=t=>i1(t),z_=t=>ag(t);function Fg(t){return L.forwardRef(t)}const Hg=typeof window<"u"?L.useLayoutEffect:L.useEffect;function ep(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>D_(()=>o(a=>a+BigInt(1))));return Hg(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function D_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Bg=L.createContext(null);function O_({children:t}){const r=Ye(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:y,hasDefaultNodes:x,onNodesChange:v,nodeLookup:m,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let b=p;for(const N of h)b=typeof N=="function"?N(b):N;let E=Qh({items:b,lookup:m});for(const N of k.values())E=N(E);x&&y(b),E.length>0?v==null||v(E):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:N,nodes:P,setNodes:w}=r.getState();N&&w(P)})},[]),s=ep(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:y,hasDefaultEdges:x,onEdgesChange:v,edgeLookup:m}=r.getState();let _=p;for(const k of h)_=typeof k=="function"?k(_):k;x?y(_):v&&v(Qh({items:_,lookup:m}))},[]),u=ep(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Bg.Provider,{value:c,children:t})}function F_(){const t=L.useContext(Bg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const H_=t=>!!t.panZoom;function ea(){const t=I_(),r=Ye(),o=F_(),s=De(H_),a=L.useMemo(()=>{const u=v=>r.getState().nodeLookup.get(v),c=v=>{o.nodeQueue.push(v)},h=v=>{o.edgeQueue.push(v)},p=v=>{var N,P;const{nodeLookup:m,nodeOrigin:_}=r.getState(),k=Jh(v)?v:m.get(v.id),b=k.parentId?gg(k.position,k.measured,k.parentId,m,_):k.position,E={...k,position:b,width:((N=k.measured)==null?void 0:N.width)??k.width,height:((P=k.measured)==null?void 0:P.height)??k.height};return os(E)},y=(v,m,_={replace:!1})=>{c(k=>k.map(b=>{if(b.id===v){const E=typeof m=="function"?m(b):m;return _.replace&&Jh(E)?E:{...b,...E}}return b}))},x=(v,m,_={replace:!1})=>{h(k=>k.map(b=>{if(b.id===v){const E=typeof m=="function"?m(b):m;return _.replace&&z_(E)?E:{...b,...E}}return b}))};return{getNodes:()=>r.getState().nodes.map(v=>({...v})),getNode:v=>{var m;return(m=u(v))==null?void 0:m.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:v=[]}=r.getState();return v.map(m=>({...m}))},getEdge:v=>r.getState().edgeLookup.get(v),setNodes:c,setEdges:h,addNodes:v=>{const m=Array.isArray(v)?v:[v];o.nodeQueue.push(_=>[..._,...m])},addEdges:v=>{const m=Array.isArray(v)?v:[v];o.edgeQueue.push(_=>[..._,...m])},toObject:()=>{const{nodes:v=[],edges:m=[],transform:_}=r.getState(),[k,b,E]=_;return{nodes:v.map(N=>({...N})),edges:m.map(N=>({...N})),viewport:{x:k,y:b,zoom:E}}},deleteElements:async({nodes:v=[],edges:m=[]})=>{const{nodes:_,edges:k,onNodesDelete:b,onEdgesDelete:E,triggerNodeChanges:N,triggerEdgeChanges:P,onDelete:w,onBeforeDelete:j}=r.getState(),{nodes:$,edges:z}=await u1({nodesToRemove:v,edgesToRemove:m,nodes:_,edges:k,onBeforeDelete:j}),B=z.length>0,G=$.length>0;if(B){const Q=z.map(Zh);E==null||E(z),P(Q)}if(G){const Q=$.map(Zh);b==null||b($),N(Q)}return(G||B)&&(w==null||w({nodes:$,edges:z})),{deletedNodes:$,deletedEdges:z}},getIntersectingNodes:(v,m=!0,_)=>{const k=Nh(v),b=k?v:p(v),E=_!==void 0;return b?(_||r.getState().nodes).filter(N=>{const P=r.getState().nodeLookup.get(N.id);if(P&&!k&&(N.id===v.id||!P.internals.positionAbsolute))return!1;const w=os(E?N:P),j=Fl(w,b);return m&&j>0||j>=w.width*w.height||j>=b.width*b.height}):[]},isNodeIntersecting:(v,m,_=!0)=>{const b=Nh(v)?v:p(v);if(!b)return!1;const E=Fl(b,m);return _&&E>0||E>=m.width*m.height||E>=b.width*b.height},updateNode:y,updateNodeData:(v,m,_={replace:!1})=>{y(v,k=>{const b=typeof m=="function"?m(k):m;return _.replace?{...k,data:b}:{...k,data:{...k.data,...b}}},_)},updateEdge:x,updateEdgeData:(v,m,_={replace:!1})=>{x(v,k=>{const b=typeof m=="function"?m(k):m;return _.replace?{...k,data:b}:{...k,data:{...k.data,...b}}},_)},getNodesBounds:v=>{const{nodeLookup:m,nodeOrigin:_}=r.getState();return o1(v,{nodeLookup:m,nodeOrigin:_})},getHandleConnections:({type:v,id:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${v}${m?`-${m}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:v,handleId:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${v?m?`-${v}-${m}`:`-${v}`:""}`))==null?void 0:k.values())??[])},fitView:async v=>{const m=r.getState().fitViewResolver??f1();return r.setState({fitViewQueued:!0,fitViewOptions:v,fitViewResolver:m}),o.nodeQueue.push(_=>[..._]),m.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const tp=t=>t.selected,B_=typeof window<"u"?window:void 0;function V_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ye(),{deleteElements:s}=ea(),a=ls(t,{actInsideInputWithModifier:!1}),u=ls(r,{target:B_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(tp),edges:c.filter(tp)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function W_(t){const r=Ye();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=jc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",mn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const ta={position:"absolute",width:"100%",height:"100%",top:0,left:0},U_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function Y_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=di.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:y,translateExtent:x,minZoom:v,maxZoom:m,zoomActivationKeyCode:_,preventScrolling:k=!0,children:b,noWheelClassName:E,noPanClassName:N,onViewportChange:P,isControlledViewport:w,paneClickDistance:j,selectionOnDrag:$}){const z=Ye(),B=L.useRef(null),{userSelectionActive:G,lib:Q,connectionInProgress:ne}=De(U_,Qe),ee=ls(_),te=L.useRef();W_(B);const q=L.useCallback(C=>{P==null||P({x:C[0],y:C[1],zoom:C[2]}),w||z.setState({transform:C})},[P,w]);return L.useEffect(()=>{if(B.current){te.current=q1({domNode:B.current,minZoom:v,maxZoom:m,translateExtent:x,viewport:y,onDraggingChange:U=>z.setState(M=>M.paneDragging===U?M:{paneDragging:U}),onPanZoomStart:(U,M)=>{const{onViewportChangeStart:D,onMoveStart:F}=z.getState();F==null||F(U,M),D==null||D(M)},onPanZoom:(U,M)=>{const{onViewportChange:D,onMove:F}=z.getState();F==null||F(U,M),D==null||D(M)},onPanZoomEnd:(U,M)=>{const{onViewportChangeEnd:D,onMoveEnd:F}=z.getState();F==null||F(U,M),D==null||D(M)}});const{x:C,y:V,zoom:W}=te.current.getViewport();return z.setState({panZoom:te.current,transform:[C,V,W],domNode:B.current.closest(".react-flow")}),()=>{var U;(U=te.current)==null||U.destroy()}}},[]),L.useEffect(()=>{var C;(C=te.current)==null||C.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:ee,preventScrolling:k,noPanClassName:N,userSelectionActive:G,noWheelClassName:E,lib:Q,onTransformChange:q,connectionInProgress:ne,selectionOnDrag:$,paneClickDistance:j})},[t,r,o,s,a,u,c,h,p,ee,k,N,G,E,Q,q,ne,$,j]),d.jsx("div",{className:"react-flow__renderer",ref:B,style:ta,children:b})}const G_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function X_(){const{userSelectionActive:t,userSelectionRect:r}=De(G_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const Xu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},q_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function K_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=rs.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:y,onPaneContextMenu:x,onPaneScroll:v,onPaneMouseEnter:m,onPaneMouseMove:_,onPaneMouseLeave:k,children:b}){const E=L.useRef(0),N=Ye(),{userSelectionActive:P,elementsSelectable:w,dragging:j,panBy:$,autoPanSpeed:z}=De(q_,Qe),B=w&&(t||P),G=L.useRef(null),Q=L.useRef(),ne=L.useRef(new Set),ee=L.useRef(new Set),te=L.useRef(!1),q=L.useRef(!1),C=L.useRef({x:0,y:0}),V=L.useRef(!1),W=Z=>{if(q.current||te.current||N.getState().connection.inProgress){q.current=!1,te.current=!1;return}y==null||y(Z),N.getState().resetSelectedElements(),N.setState({nodesSelectionActive:!1})},U=Z=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Z.preventDefault();return}x==null||x(Z)},M=v?Z=>v(Z):void 0,D=Z=>{q.current&&(Z.stopPropagation(),q.current=!1)},F=Z=>{var $e,st;if(Z.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:se,transform:me}=N.getState();if(Q.current=se==null?void 0:se.getBoundingClientRect(),!Q.current)return;const ke=Z.target===G.current;if(!ke&&!!Z.target.closest(".nokey")||!t||!(c&&ke||r)||Z.button!==0||!Z.isPrimary)return;(st=($e=Z.target)==null?void 0:$e.setPointerCapture)==null||st.call($e,Z.pointerId),q.current=!1;const{x:Ne,y:Me}=gn(Z.nativeEvent,Q.current),Te=gs({x:Ne,y:Me},me);N.setState({userSelectionRect:{width:0,height:0,startX:Te.x,startY:Te.y,x:Ne,y:Me}}),ke||(Z.stopPropagation(),Z.preventDefault())};function R(Z,se){const{userSelectionRect:me}=N.getState();if(!me)return;const{transform:ke,nodeLookup:ve,edgeLookup:re,connectionLookup:Ne,triggerNodeChanges:Me,triggerEdgeChanges:Te,defaultEdgeOptions:$e}=N.getState(),st={x:me.startX,y:me.startY},{x:lt,y:at}=eo(st,ke),Ge={startX:st.x,startY:st.y,x:Zmt.id)),ee.current=new Set;const gt=($e==null?void 0:$e.selectable)??!0;for(const mt of ne.current){const Pt=Ne.get(mt);if(Pt)for(const{edgeId:ut}of Pt.values()){const Je=re.get(ut);Je&&(Je.selectable??gt)&&ee.current.add(ut)}}if(!jh(wt,ne.current)){const mt=Gi(ve,ne.current,!0);Me(mt)}if(!jh(qt,ee.current)){const mt=Gi(re,ee.current);Te(mt)}N.setState({userSelectionRect:Ge,userSelectionActive:!0,nodesSelectionActive:!1})}function A(){if(!a||!Q.current)return;const[Z,se]=kc(C.current,Q.current,z);$({x:Z,y:se}).then(me=>{if(!q.current||!me){E.current=requestAnimationFrame(A);return}const{x:ke,y:ve}=C.current;R(ke,ve),E.current=requestAnimationFrame(A)})}const ie=()=>{cancelAnimationFrame(E.current),E.current=0,V.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=Z=>{const{userSelectionRect:se,transform:me,resetSelectedElements:ke}=N.getState();if(!Q.current||!se)return;const{x:ve,y:re}=gn(Z.nativeEvent,Q.current);C.current={x:ve,y:re};const Ne=eo({x:se.startX,y:se.startY},me);if(!q.current){const Me=r?0:u;if(Math.hypot(ve-Ne.x,re-Ne.y)<=Me)return;ke(),h==null||h(Z)}q.current=!0,V.current||(A(),V.current=!0),R(ve,re)},fe=Z=>{var se,me;if(!B){Z.target===G.current&&N.getState().connection.inProgress&&(te.current=!0);return}Z.button===0&&((me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),!P&&Z.target===G.current&&N.getState().userSelectionRect&&(W==null||W(Z)),N.setState({userSelectionActive:!1,userSelectionRect:null}),q.current&&(p==null||p(Z),N.setState({nodesSelectionActive:ne.current.size>0})),ie())},he=Z=>{var se,me;(me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),ie()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:nt(["react-flow__pane",{draggable:pe,dragging:j,selection:t}]),onClick:B?void 0:Xu(W,G),onContextMenu:Xu(U,G),onWheel:Xu(M,G),onPointerEnter:B?void 0:m,onPointerMove:B?oe:_,onPointerUp:fe,onPointerCancel:B?he:void 0,onPointerDownCapture:B?F:void 0,onClickCapture:B?D:void 0,onPointerLeave:k,ref:G,style:ta,children:[b,d.jsx(X_,{})]})}function hc({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),y=h.get(t);if(!y){p==null||p("012",mn.error012(t));return}r.setState({nodesSelectionActive:!1}),y.selected?(o||y.selected&&c)&&(u({nodes:[y],edges:[]}),requestAnimationFrame(()=>{var x;return(x=s==null?void 0:s.current)==null?void 0:x.blur()})):a([t])}function Vg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ye(),[p,y]=L.useState(!1),x=L.useRef();return L.useEffect(()=>{if(!r)return x.current=A1({getStoreItems:()=>h.getState(),onNodeMouseDown:v=>{hc({id:v,store:h,nodeRef:t})},onDragStart:()=>{y(!0)},onDragStop:()=>{y(!1)}}),()=>{var v;(v=x.current)==null||v.destroy(),x.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!x.current||x.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const Q_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Wg(){const t=Ye();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:y,nodeOrigin:x}=t.getState(),v=new Map,m=Q_(c),_=a?u[0]:5,k=a?u[1]:5,b=o.direction.x*_*o.factor,E=o.direction.y*k*o.factor;for(const[,N]of y){if(!m(N))continue;let P={x:N.internals.positionAbsolute.x+b,y:N.internals.positionAbsolute.y+E};a&&(P=ps(P,u));const{position:w,positionAbsolute:j}=ug({nodeId:N.id,nextPosition:P,nodeLookup:y,nodeExtent:s,nodeOrigin:x,onError:h});N.position=w,N.internals.positionAbsolute=j,v.set(N.id,N)}p(v)},[])}const Ic=L.createContext(null),Z_=Ic.Provider;Ic.Consumer;const Ug=()=>L.useContext(Ic),J_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Yg=L.createContext(null);function eS({children:t}){const r=De(J_,Qe);return d.jsx(Yg.Provider,{value:r,children:t})}function tS(){const t=L.useContext(Yg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const nS={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},rS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:y}=c;if(!h&&!a)return nS;const x=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:x,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Zi.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:x&&y}};function iS({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:y,onMouseDown:x,onTouchStart:v,...m},_){var V,W;const k=c||null,b=t==="target",E=Ye(),N=Ug(),{connectOnClick:P,noPanClassName:w,rfId:j}=tS(),{connectingFrom:$,connectingTo:z,clickConnecting:B,isPossibleEndHandle:G,connectionInProcess:Q,clickConnectionInProcess:ne,valid:ee}=De(rS(N,k,t),Qe);N||(W=(V=E.getState()).onError)==null||W.call(V,"010",mn.error010());const te=U=>{const{defaultEdgeOptions:M,onConnect:D,hasDefaultEdges:F}=E.getState(),R={...M,...U};if(F){const{edges:A,setEdges:ie,onError:oe}=E.getState();ie($_(R,A,{onError:oe}))}D==null||D(R),h==null||h(R)},q=U=>{if(!N)return;const M=vg(U.nativeEvent);if(a&&(M&&U.button===0||!M)){const D=E.getState();fc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:b,handleId:k,nodeId:N,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...F)=>{var R,A;return(A=(R=E.getState()).onConnectEnd)==null?void 0:A.call(R,...F)},updateConnection:D.updateConnection,onConnect:te,isValidConnection:o||((...F)=>{var R,A;return((A=(R=E.getState()).isValidConnection)==null?void 0:A.call(R,...F))??!0}),getTransform:()=>E.getState().transform,getFromHandle:()=>E.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}M?x==null||x(U):v==null||v(U)},C=U=>{const{onClickConnectStart:M,onClickConnectEnd:D,connectionClickStartHandle:F,connectionMode:R,isValidConnection:A,lib:ie,rfId:oe,nodeLookup:fe,connection:he}=E.getState();if(!N||!F&&!a)return;if(!F){M==null||M(U.nativeEvent,{nodeId:N,handleId:k,handleType:t}),E.setState({connectionClickStartHandle:{nodeId:N,type:t,id:k}});return}const pe=mg(U.target),Z=o||A,{connection:se,isValid:me}=fc.isValid(U.nativeEvent,{handle:{nodeId:N,id:k,type:t},connectionMode:R,fromNodeId:F.nodeId,fromHandleId:F.id||null,fromType:F.type,isValidConnection:Z,flowId:oe,doc:pe,lib:ie,nodeLookup:fe});me&&se&&te(se);const ke=structuredClone(he);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,D==null||D(U,ke),E.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":k,"data-nodeid":N,"data-handlepos":r,"data-id":`${j}-${N}-${k}-${t}`,className:nt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",w,y,{source:!b,target:b,connectable:s,connectablestart:a,connectableend:u,clickconnecting:B,connectingfrom:$,connectingto:z,valid:ee,connectionindicator:s&&(!Q||G)&&(Q||ne?u:a)}]),onMouseDown:q,onTouchStart:q,onClick:P?C:void 0,ref:_,...m,children:p})}const no=L.memo(Fg(iS));function oS({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(no,{type:"source",position:o,isConnectable:r})]})}function sS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:s=Se.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(no,{type:"source",position:s,isConnectable:r})]})}function lS(){return null}function aS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const Hl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},np={input:oS,default:sS,output:aS,group:lS};function uS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const cS=t=>{const{width:r,height:o,x:s,y:a}=hs(t.nodeLookup,{filter:u=>!!u.selected});return{width:pn(r)?r:null,height:pn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function dS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ye(),{width:a,height:u,transformString:c,userSelectionActive:h}=De(cS,Qe),p=Wg(),y=L.useRef(null);L.useEffect(()=>{var _;o||(_=y.current)==null||_.focus({preventScroll:!0})},[o]);const x=!h&&a!==null&&u!==null;if(Vg({nodeRef:y,disabled:!x}),!x)return null;const v=t?_=>{const k=s.getState().nodes.filter(b=>b.selected);t(_,k)}:void 0,m=_=>{Object.prototype.hasOwnProperty.call(Hl,_.key)&&(_.preventDefault(),p({direction:Hl[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:nt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:y,className:"react-flow__nodesselection-rect",onContextMenu:v,tabIndex:o?void 0:-1,onKeyDown:o?void 0:m,style:{width:a,height:u}})})}const rp=typeof window<"u"?window:void 0,fS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Gg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:y,selectionOnDrag:x,selectionMode:v,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:b,zoomActivationKeyCode:E,elementsSelectable:N,zoomOnScroll:P,zoomOnPinch:w,panOnScroll:j,panOnScrollSpeed:$,panOnScrollMode:z,zoomOnDoubleClick:B,panOnDrag:G,autoPanOnSelection:Q,defaultViewport:ne,translateExtent:ee,minZoom:te,maxZoom:q,preventScrolling:C,onSelectionContextMenu:V,noWheelClassName:W,noPanClassName:U,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:F}){const{nodesSelectionActive:R,userSelectionActive:A}=De(fS,Qe),ie=ls(y,{target:rp}),oe=ls(b,{target:rp}),fe=oe||G,he=oe||j,pe=x&&fe!==!0,Z=ie||A||pe;return V_({deleteKeyCode:p,multiSelectionKeyCode:k}),d.jsx(Y_,{onPaneContextMenu:u,elementsSelectable:N,zoomOnScroll:P,zoomOnPinch:w,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:$,panOnScrollMode:z,zoomOnDoubleClick:B,panOnDrag:!ie&&fe,defaultViewport:ne,translateExtent:ee,minZoom:te,maxZoom:q,zoomActivationKeyCode:E,preventScrolling:C,noWheelClassName:W,noPanClassName:U,onViewportChange:D,isControlledViewport:F,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(K_,{onSelectionStart:m,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:Q,isSelecting:!!Z,selectionMode:v,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:pe,children:[t,R&&d.jsx(dS,{onSelectionContextMenu:V,noPanClassName:U,disableKeyboardA11y:M})]})})}Gg.displayName="FlowRenderer";const hS=L.memo(Gg),pS=t=>r=>t?Sc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function gS(t){return De(L.useCallback(pS(t),[t]),Qe)}const mS=t=>t.updateNodeInternals;function yS(){const t=De(mS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function vS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ye(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),y=L.useRef(r),x=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!x||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[x,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const v=y.current!==r,m=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(v||m||_)&&(y.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function xS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:y,nodesFocusable:x,resizeObserver:v,noDragClassName:m,noPanClassName:_,disableKeyboardA11y:k,rfId:b,nodeTypes:E,nodeClickDistance:N,onError:P}){const{node:w,internals:j,isParent:$}=De(Z=>{const se=Z.nodeLookup.get(t),me=Z.parentLookup.has(t);return{node:se,internals:se.internals,isParent:me}},Qe);let z=w.type||"default",B=(E==null?void 0:E[z])||np[z];B===void 0&&(P==null||P("003",mn.error003(z)),z="default",B=(E==null?void 0:E.default)||np.default);const G=!!(w.draggable||h&&typeof w.draggable>"u"),Q=!!(w.selectable||p&&typeof w.selectable>"u"),ne=!!(w.connectable||y&&typeof w.connectable>"u"),ee=!!(w.focusable||x&&typeof w.focusable>"u"),te=Ye(),q=pg(w),C=vS({node:w,nodeType:z,hasDimensions:q,resizeObserver:v}),V=Vg({nodeRef:C,disabled:w.hidden||!G,noDragClassName:m,handleSelector:w.dragHandle,nodeId:t,isSelectable:Q,nodeClickDistance:N}),W=Wg();if(w.hidden)return null;const U=vn(w),M=uS(w),D=Q||G||r||o||s||a,F=o?Z=>o(Z,{...j.userNode}):void 0,R=s?Z=>s(Z,{...j.userNode}):void 0,A=a?Z=>a(Z,{...j.userNode}):void 0,ie=u?Z=>u(Z,{...j.userNode}):void 0,oe=c?Z=>c(Z,{...j.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:se,nodeDragThreshold:me}=te.getState();Q&&(!se||!G||me>0)&&hc({id:t,store:te,nodeRef:C}),r&&r(Z,{...j.userNode})},he=Z=>{if(!(yg(Z.nativeEvent)||k)){if(ig.includes(Z.key)&&Q){const se=Z.key==="Escape";hc({id:t,store:te,unselect:se,nodeRef:C})}else if(G&&w.selected&&Object.prototype.hasOwnProperty.call(Hl,Z.key)){Z.preventDefault();const{ariaLabelConfig:se}=te.getState();te.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),W({direction:Hl[Z.key],factor:Z.shiftKey?4:1})}}},pe=()=>{var Ne;if(k||!((Ne=C.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:Z,width:se,height:me,autoPanOnNodeFocus:ke,setCenter:ve}=te.getState();if(!ke)return;Sc(new Map([[t,w]]),{x:0,y:0,width:se,height:me},Z,!0).length>0||ve(w.position.x+U.width/2,w.position.y+U.height/2,{zoom:Z[2]})};return d.jsx("div",{className:nt(["react-flow__node",`react-flow__node-${z}`,{[_]:G},w.className,{selected:w.selected,selectable:Q,parent:$,draggable:G,dragging:V}]),ref:C,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:q?"visible":"hidden",...w.style,...M},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:F,onMouseMove:R,onMouseLeave:A,onContextMenu:ie,onClick:fe,onDoubleClick:oe,onKeyDown:ee?he:void 0,tabIndex:ee?0:void 0,onFocus:ee?pe:void 0,role:w.ariaRole??(ee?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${$g}-${b}`,"aria-label":w.ariaLabel,...w.domAttributes,children:d.jsx(Z_,{value:t,children:d.jsx(B,{id:t,data:w.data,type:z,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:w.selected??!1,selectable:Q,draggable:G,deletable:w.deletable??!0,isConnectable:ne,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:V,dragHandle:w.dragHandle,zIndex:j.z,parentId:w.parentId,...U})})})}var wS=L.memo(xS);const _S=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Xg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=De(_S,Qe),u=gS(t.onlyRenderVisibleElements),c=yS();return d.jsx("div",{className:"react-flow__nodes",style:ta,children:u.map(h=>d.jsx(wS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Xg.displayName="NodeRenderer";const SS=L.memo(Xg);function kS(t){return De(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&m1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const NS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},jS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ip={[is.Arrow]:NS,[is.ArrowClosed]:jS};function bS(t){const r=Ye();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(ip,t)?ip[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",mn.error009(t)),null)},[t])}const ES=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=bS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},qg=({defaultColor:t,rfId:r})=>{const o=De(u=>u.edges),s=De(u=>u.defaultEdgeOptions),a=L.useMemo(()=>N1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(ES,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};qg.displayName="MarkerDefinitions";var CS=L.memo(qg);function Kg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:y,...x}){const[v,m]=L.useState({x:1,y:0,width:0,height:0}),_=nt(["react-flow__edge-textwrapper",y]),k=L.useRef(null);return L.useEffect(()=>{if(k.current){const b=k.current.getBBox();m({x:b.x,y:b.y,width:b.width,height:b.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-v.width/2} ${r-v.height/2})`,className:_,visibility:v.width?"visible":"hidden",...x,children:[a&&d.jsx("rect",{width:v.width+2*c[0],x:-c[0],y:-c[1],height:v.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:v.height/2,dy:"0.3em",ref:k,style:s,children:o}),p]}):null}Kg.displayName="EdgeText";const MS=L.memo(Kg);function na({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:y=20,...x}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...x,d:t,fill:"none",className:nt(["react-flow__edge-path",x.className])}),y?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:y,className:"react-flow__edge-interaction"}):null,s&&pn(r)&&pn(o)?d.jsx(MS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function op({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function Qg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top}){const[c,h]=op({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,y]=op({pos:u,x1:s,y1:a,x2:t,y2:r}),[x,v,m,_]=xg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:y});return[`M${t},${r} C${c},${h} ${p},${y} ${s},${a}`,x,v,m,_]}function Zg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,interactionWidth:N})=>{const[P,w,j]=Qg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),$=t.isInternal?void 0:r;return d.jsx(na,{id:$,path:P,labelX:w,labelY:j,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,interactionWidth:N})})}const PS=Zg({isInternal:!1}),Jg=Zg({isInternal:!0});PS.displayName="SimpleBezierEdge";Jg.displayName="SimpleBezierEdgeInternal";function em(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,sourcePosition:_=Se.Bottom,targetPosition:k=Se.Top,markerEnd:b,markerStart:E,pathOptions:N,interactionWidth:P})=>{const[w,j,$]=uc({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:N==null?void 0:N.borderRadius,offset:N==null?void 0:N.offset,stepPosition:N==null?void 0:N.stepPosition}),z=t.isInternal?void 0:r;return d.jsx(na,{id:z,path:w,labelX:j,labelY:$,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,markerEnd:b,markerStart:E,interactionWidth:P})})}const tm=em({isInternal:!1}),nm=em({isInternal:!0});tm.displayName="SmoothStepEdge";nm.displayName="SmoothStepEdgeInternal";function rm(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(tm,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const IS=rm({isInternal:!1}),im=rm({isInternal:!0});IS.displayName="StepEdge";im.displayName="StepEdgeInternal";function om(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,markerEnd:_,markerStart:k,interactionWidth:b})=>{const[E,N,P]=Sg({sourceX:o,sourceY:s,targetX:a,targetY:u}),w=t.isInternal?void 0:r;return d.jsx(na,{id:w,path:E,labelX:N,labelY:P,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,markerEnd:_,markerStart:k,interactionWidth:b})})}const RS=om({isInternal:!1}),sm=om({isInternal:!0});RS.displayName="StraightEdge";sm.displayName="StraightEdgeInternal";function lm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,pathOptions:N,interactionWidth:P})=>{const[w,j,$]=wg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:N==null?void 0:N.curvature}),z=t.isInternal?void 0:r;return d.jsx(na,{id:z,path:w,labelX:j,labelY:$,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,interactionWidth:P})})}const TS=lm({isInternal:!1}),am=lm({isInternal:!0});TS.displayName="BezierEdge";am.displayName="BezierEdgeInternal";const sp={default:am,straight:sm,step:im,smoothstep:nm,simplebezier:Jg},lp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},LS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,AS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,ap="react-flow__edgeupdater";function up({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:nt([ap,`${ap}-${h}`]),cx:LS(r,s,t),cy:AS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function $S({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:y,onReconnectStart:x,onReconnectEnd:v,setReconnecting:m,setUpdateHover:_}){const k=Ye(),b=(j,$)=>{if(j.button!==0)return;const{autoPanOnConnect:z,domNode:B,connectionMode:G,connectionRadius:Q,lib:ne,onConnectStart:ee,cancelConnection:te,nodeLookup:q,rfId:C,panBy:V,updateConnection:W}=k.getState(),U=$.type==="target",M=(R,A)=>{m(!1),v==null||v(R,o,$.type,A)},D=R=>y==null?void 0:y(o,R),F=(R,A)=>{m(!0),x==null||x(j,o,$.type),ee==null||ee(R,A)};fc.onPointerDown(j.nativeEvent,{autoPanOnConnect:z,connectionMode:G,connectionRadius:Q,domNode:B,handleId:$.id,nodeId:$.nodeId,nodeLookup:q,isTarget:U,edgeUpdaterType:$.type,lib:ne,flowId:C,cancelConnection:te,panBy:V,isValidConnection:(...R)=>{var A,ie;return((ie=(A=k.getState()).isValidConnection)==null?void 0:ie.call(A,...R))??!0},onConnect:D,onConnectStart:F,onConnectEnd:(...R)=>{var A,ie;return(ie=(A=k.getState()).onConnectEnd)==null?void 0:ie.call(A,...R)},onReconnectEnd:M,updateConnection:W,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},E=j=>b(j,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),N=j=>b(j,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),P=()=>_(!0),w=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(up,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:E,onMouseEnter:P,onMouseOut:w,type:"source"}),(t===!0||t==="target")&&d.jsx(up,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:N,onMouseEnter:P,onMouseOut:w,type:"target"})]})}function zS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,reconnectRadius:x,onReconnect:v,onReconnectStart:m,onReconnectEnd:_,rfId:k,edgeTypes:b,noPanClassName:E,onError:N,disableKeyboardA11y:P}){let w=De(ve=>ve.edgeLookup.get(t));const j=De(ve=>ve.defaultEdgeOptions);w=j?{...j,...w}:w;let $=w.type||"default",z=(b==null?void 0:b[$])||sp[$];z===void 0&&(N==null||N("011",mn.error011($)),$="default",z=(b==null?void 0:b.default)||sp.default);const B=!!(w.focusable||r&&typeof w.focusable>"u"),G=typeof v<"u"&&(w.reconnectable||o&&typeof w.reconnectable>"u"),Q=!!(w.selectable||s&&typeof w.selectable>"u"),ne=L.useRef(null),[ee,te]=L.useState(!1),[q,C]=L.useState(!1),V=Ye(),{zIndex:W=w.zIndex,sourceX:U,sourceY:M,targetX:D,targetY:F,sourcePosition:R,targetPosition:A}=De(L.useCallback(ve=>{const re=ve.nodeLookup.get(w.source),Ne=ve.nodeLookup.get(w.target);if(!re||!Ne)return lp;const Me=k1({id:t,sourceNode:re,targetNode:Ne,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:ve.connectionMode,onError:N}),Te=g1({selected:w.selected,zIndex:w.zIndex,sourceNode:re,targetNode:Ne,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||lp,zIndex:Te}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex,N]),Qe),ie=L.useMemo(()=>w.markerStart?`url('#${cc(w.markerStart,k)}')`:void 0,[w.markerStart,k]),oe=L.useMemo(()=>w.markerEnd?`url('#${cc(w.markerEnd,k)}')`:void 0,[w.markerEnd,k]);if(w.hidden||U===null||M===null||D===null||F===null)return null;const fe=ve=>{var Te;const{addSelectedEdges:re,unselectNodesAndEdges:Ne,multiSelectionActive:Me}=V.getState();Q&&(V.setState({nodesSelectionActive:!1}),w.selected&&Me?(Ne({nodes:[],edges:[w]}),(Te=ne.current)==null||Te.blur()):re([t])),a&&a(ve,w)},he=u?ve=>{u(ve,{...w})}:void 0,pe=c?ve=>{c(ve,{...w})}:void 0,Z=h?ve=>{h(ve,{...w})}:void 0,se=p?ve=>{p(ve,{...w})}:void 0,me=y?ve=>{y(ve,{...w})}:void 0,ke=ve=>{var re;if(!P&&ig.includes(ve.key)&&Q){const{unselectNodesAndEdges:Ne,addSelectedEdges:Me}=V.getState();ve.key==="Escape"?((re=ne.current)==null||re.blur(),Ne({edges:[w]})):Me([t])}};return d.jsx("svg",{style:{zIndex:W},children:d.jsxs("g",{className:nt(["react-flow__edge",`react-flow__edge-${$}`,w.className,E,{selected:w.selected,animated:w.animated,inactive:!Q&&!a,updating:ee,selectable:Q}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:Z,onMouseMove:se,onMouseLeave:me,onKeyDown:B?ke:void 0,tabIndex:B?0:void 0,role:w.ariaRole??(B?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":B?`${zg}-${k}`:void 0,ref:ne,...w.domAttributes,children:[!q&&d.jsx(z,{id:t,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:Q,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:U,sourceY:M,targetX:D,targetY:F,sourcePosition:R,targetPosition:A,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),G&&d.jsx($S,{edge:w,isReconnectable:G,reconnectRadius:x,onReconnect:v,onReconnectStart:m,onReconnectEnd:_,sourceX:U,sourceY:M,targetX:D,targetY:F,sourcePosition:R,targetPosition:A,setUpdateHover:te,setReconnecting:C})]})})}var DS=L.memo(zS);const OS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function um({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:y,onEdgeClick:x,reconnectRadius:v,onEdgeDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:b}){const{edgesFocusable:E,edgesReconnectable:N,elementsSelectable:P,onError:w}=De(OS,Qe),j=kS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(CS,{defaultColor:t,rfId:o}),j.map($=>d.jsx(DS,{id:$,edgesFocusable:E,edgesReconnectable:N,elementsSelectable:P,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,onClick:x,reconnectRadius:v,onDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:w,edgeTypes:s,disableKeyboardA11y:b},$))]})}um.displayName="EdgeRenderer";const FS=L.memo(um),cp=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function HS({children:t}){const r=Ye(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return Hg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=cp(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:cp(s)},children:t})}function BS(t){const r=ea(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const VS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function WS(t){const r=De(VS),o=Ye();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function US(t){return t.connection.inProgress?{...t.connection,to:gs(t.connection.to,t.transform)}:{...t.connection}}function YS(t){return US}function GS(t){const r=YS();return De(r,Qe)}const XS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function qS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=De(XS,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:nt(["react-flow__connection",lg(h)]),children:d.jsx(cm,{style:r,type:o,CustomComponent:s,isValid:h})})})}const cm=({style:t,type:r=Lr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:y,toNode:x,toHandle:v,toPosition:m,pointer:_}=GS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:y.x,toY:y.y,fromPosition:p,toPosition:m,connectionStatus:lg(s),toNode:x,toHandle:v,pointer:_});let k="";const b={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:y.x,targetY:y.y,targetPosition:m};switch(r){case Lr.Bezier:[k]=wg(b);break;case Lr.SimpleBezier:[k]=Qg(b);break;case Lr.Step:[k]=uc({...b,borderRadius:0});break;case Lr.SmoothStep:[k]=uc(b);break;default:[k]=Sg(b)}return d.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};cm.displayName="ConnectionLine";const KS={};function dp(t=KS){L.useRef(t),Ye(),L.useEffect(()=>{},[t])}function QS(){Ye(),L.useRef(!1),L.useEffect(()=>{},[])}function dm({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:x,onSelectionContextMenu:v,onSelectionStart:m,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:b,connectionLineComponent:E,connectionLineContainerStyle:N,selectionKeyCode:P,selectionOnDrag:w,selectionMode:j,multiSelectionKeyCode:$,panActivationKeyCode:z,zoomActivationKeyCode:B,deleteKeyCode:G,onlyRenderVisibleElements:Q,elementsSelectable:ne,defaultViewport:ee,translateExtent:te,minZoom:q,maxZoom:C,preventScrolling:V,defaultMarkerColor:W,zoomOnScroll:U,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:F,panOnScrollMode:R,zoomOnDoubleClick:A,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneScroll:se,onPaneContextMenu:me,paneClickDistance:ke,nodeClickDistance:ve,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,viewport:ut,onViewportChange:Je,nodesDraggable:An}){return dp(t),dp(r),QS(),BS(o),WS(ut),d.jsx(hS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneContextMenu:me,onPaneScroll:se,paneClickDistance:ke,deleteKeyCode:G,selectionKeyCode:P,selectionOnDrag:w,selectionMode:j,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:$,panActivationKeyCode:z,zoomActivationKeyCode:B,elementsSelectable:ne,zoomOnScroll:U,zoomOnPinch:M,zoomOnDoubleClick:A,panOnScroll:D,panOnScrollSpeed:F,panOnScrollMode:R,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:ee,translateExtent:te,minZoom:q,maxZoom:C,onSelectionContextMenu:v,preventScrolling:V,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,onViewportChange:Je,isControlledViewport:!!ut,children:d.jsxs(HS,{children:[d.jsx(FS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,onlyRenderVisibleElements:Q,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,defaultMarkerColor:W,noPanClassName:qt,disableKeyboardA11y:gt,rfId:Pt}),d.jsx(qS,{style:b,type:k,component:E,containerStyle:N}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(SS,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:x,nodeClickDistance:ve,onlyRenderVisibleElements:Q,noPanClassName:qt,noDragClassName:Ge,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,nodesDraggable:An}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}dm.displayName="GraphView";const ZS=L.memo(dm),JS=hg(),fp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:y=2,nodeOrigin:x,nodeExtent:v,zIndexMode:m="basic"}={})=>{const _=new Map,k=new Map,b=new Map,E=new Map,N=s??r??[],P=o??t??[],w=x??[0,0],j=v??ns;jg(b,E,N);const{nodesInitialized:$}=dc(P,_,k,{nodeOrigin:w,nodeExtent:j,zIndexMode:m});let z=[0,0,1];if(c&&a&&u){const B=hs(_,{filter:ee=>!!((ee.width||ee.initialWidth)&&(ee.height||ee.initialHeight))}),{x:G,y:Q,zoom:ne}=Nc(B,a,u,p,y,(h==null?void 0:h.padding)??.1);z=[G,Q,ne]}return{rfId:"1",width:a??0,height:u??0,transform:z,nodes:P,nodesInitialized:$,nodeLookup:_,parentLookup:k,edges:N,edgeLookup:E,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:y,translateExtent:ns,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Zi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...sg},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:JS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:og,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},ek=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:x,nodeExtent:v,zIndexMode:m})=>f_((_,k)=>{async function b(){const{nodeLookup:E,panZoom:N,fitViewOptions:P,fitViewResolver:w,width:j,height:$,minZoom:z,maxZoom:B}=k();N&&(await a1({nodes:E,width:j,height:$,panZoom:N,minZoom:z,maxZoom:B},P),w==null||w.resolve(!0),_({fitViewResolver:null}))}return{...fp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:x,nodeExtent:v,defaultNodes:o,defaultEdges:s,zIndexMode:m}),setNodes:E=>{const{nodeLookup:N,parentLookup:P,nodeOrigin:w,nodeExtent:j,elevateNodesOnSelect:$,fitViewQueued:z,zIndexMode:B,nodesSelectionActive:G}=k(),{nodesInitialized:Q,hasSelectedNodes:ne}=dc(E,N,P,{nodeOrigin:w,nodeExtent:j,elevateNodesOnSelect:$,checkEquality:!0,zIndexMode:B}),ee=G&≠z&&Q?(b(),_({nodes:E,nodesInitialized:Q,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:ee})):_({nodes:E,nodesInitialized:Q,nodesSelectionActive:ee})},setEdges:E=>{const{connectionLookup:N,edgeLookup:P}=k();jg(N,P,E),_({edges:E})},setDefaultNodesAndEdges:(E,N)=>{if(E){const{setNodes:P}=k();P(E),_({hasDefaultNodes:!0})}if(N){const{setEdges:P}=k();P(N),_({hasDefaultEdges:!0})}},updateNodeInternals:E=>{const{triggerNodeChanges:N,nodeLookup:P,parentLookup:w,domNode:j,nodeOrigin:$,nodeExtent:z,debug:B,fitViewQueued:G,zIndexMode:Q}=k(),{changes:ne,updatedInternals:ee}=I1(E,P,w,j,$,z,Q);ee&&(E1(P,w,{nodeOrigin:$,nodeExtent:z,zIndexMode:Q}),G?(b(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(ne==null?void 0:ne.length)>0&&(B&&console.log("React Flow: trigger node changes",ne),N==null||N(ne)))},updateNodePositions:(E,N=!1)=>{const P=[];let w=[];const{nodeLookup:j,triggerNodeChanges:$,connection:z,updateConnection:B,onNodesChangeMiddlewareMap:G}=k();for(const[Q,ne]of E){const ee=j.get(Q),te=!!(ee!=null&&ee.expandParent&&(ee!=null&&ee.parentId)&&(ne!=null&&ne.position)),q={id:Q,type:"position",position:te?{x:Math.max(0,ne.position.x),y:Math.max(0,ne.position.y)}:ne.position,dragging:N};if(ee&&z.inProgress&&z.fromNode.id===ee.id){const C=mi(ee,z.fromHandle,Se.Left,!0);B({...z,from:C})}te&&ee.parentId&&P.push({id:Q,parentId:ee.parentId,rect:{...ne.internals.positionAbsolute,width:ne.measured.width??0,height:ne.measured.height??0}}),w.push(q)}if(P.length>0){const{parentLookup:Q,nodeOrigin:ne}=k(),ee=Pc(P,j,Q,ne);w.push(...ee)}for(const Q of G.values())w=Q(w);$(w)},triggerNodeChanges:E=>{const{onNodesChange:N,setNodes:P,nodes:w,hasDefaultNodes:j,debug:$}=k();if(E!=null&&E.length){if(j){const z=T_(E,w);P(z)}$&&console.log("React Flow: trigger node changes",E),N==null||N(E)}},triggerEdgeChanges:E=>{const{onEdgesChange:N,setEdges:P,edges:w,hasDefaultEdges:j,debug:$}=k();if(E!=null&&E.length){if(j){const z=L_(E,w);P(z)}$&&console.log("React Flow: trigger edge changes",E),N==null||N(E)}},addSelectedNodes:E=>{const{multiSelectionActive:N,edgeLookup:P,nodeLookup:w,triggerNodeChanges:j,triggerEdgeChanges:$}=k();if(N){const z=E.map(B=>ai(B,!0));j(z);return}j(Gi(w,new Set([...E]),!0)),$(Gi(P))},addSelectedEdges:E=>{const{multiSelectionActive:N,edgeLookup:P,nodeLookup:w,triggerNodeChanges:j,triggerEdgeChanges:$}=k();if(N){const z=E.map(B=>ai(B,!0));$(z);return}$(Gi(P,new Set([...E]))),j(Gi(w,new Set,!0))},unselectNodesAndEdges:({nodes:E,edges:N}={})=>{const{edges:P,nodes:w,nodeLookup:j,triggerNodeChanges:$,triggerEdgeChanges:z}=k(),B=E||w,G=N||P,Q=[];for(const ee of B){if(!ee.selected)continue;const te=j.get(ee.id);te&&(te.selected=!1),Q.push(ai(ee.id,!1))}const ne=[];for(const ee of G)ee.selected&&ne.push(ai(ee.id,!1));$(Q),z(ne)},setMinZoom:E=>{const{panZoom:N,maxZoom:P}=k();N==null||N.setScaleExtent([E,P]),_({minZoom:E})},setMaxZoom:E=>{const{panZoom:N,minZoom:P}=k();N==null||N.setScaleExtent([P,E]),_({maxZoom:E})},setTranslateExtent:E=>{var N;(N=k().panZoom)==null||N.setTranslateExtent(E),_({translateExtent:E})},resetSelectedElements:()=>{const{edges:E,nodes:N,triggerNodeChanges:P,triggerEdgeChanges:w,elementsSelectable:j}=k();if(!j)return;const $=N.reduce((B,G)=>G.selected?[...B,ai(G.id,!1)]:B,[]),z=E.reduce((B,G)=>G.selected?[...B,ai(G.id,!1)]:B,[]);P($),w(z)},setNodeExtent:E=>{const{nodes:N,nodeLookup:P,parentLookup:w,nodeOrigin:j,elevateNodesOnSelect:$,nodeExtent:z,zIndexMode:B}=k();E[0][0]===z[0][0]&&E[0][1]===z[0][1]&&E[1][0]===z[1][0]&&E[1][1]===z[1][1]||(dc(N,P,w,{nodeOrigin:j,nodeExtent:E,elevateNodesOnSelect:$,checkEquality:!1,zIndexMode:B}),_({nodeExtent:E}))},panBy:E=>{const{transform:N,width:P,height:w,panZoom:j,translateExtent:$}=k();return R1({delta:E,panZoom:j,transform:N,translateExtent:$,width:P,height:w})},setCenter:async(E,N,P)=>{const{width:w,height:j,maxZoom:$,panZoom:z}=k();if(!z)return!1;const B=typeof(P==null?void 0:P.zoom)<"u"?P.zoom:$;return await z.setViewport({x:w/2-E*B,y:j/2-N*B,zoom:B},{duration:P==null?void 0:P.duration,ease:P==null?void 0:P.ease,interpolate:P==null?void 0:P.interpolate}),!0},cancelConnection:()=>{_({connection:{...sg}})},updateConnection:E=>{_({connection:E})},reset:()=>_({...fp()})}},Object.is);function fm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:y,nodeOrigin:x,nodeExtent:v,zIndexMode:m,children:_}){const[k]=L.useState(()=>ek({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:y,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:x,nodeExtent:v,zIndexMode:m}));return d.jsx(h_,{value:k,children:d.jsx(O_,{children:d.jsx(eS,{children:_})})})}function tk({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:y,maxZoom:x,nodeOrigin:v,nodeExtent:m,zIndexMode:_}){return L.useContext(Zl)?d.jsx(d.Fragment,{children:t}):d.jsx(fm,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:y,initialMaxZoom:x,nodeOrigin:v,nodeExtent:m,zIndexMode:_,children:t})}const nk={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function rk({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:y,onMove:x,onMoveStart:v,onMoveEnd:m,onConnect:_,onConnectStart:k,onConnectEnd:b,onClickConnectStart:E,onClickConnectEnd:N,onNodeMouseEnter:P,onNodeMouseMove:w,onNodeMouseLeave:j,onNodeContextMenu:$,onNodeDoubleClick:z,onNodeDragStart:B,onNodeDrag:G,onNodeDragStop:Q,onNodesDelete:ne,onEdgesDelete:ee,onDelete:te,onSelectionChange:q,onSelectionDragStart:C,onSelectionDrag:V,onSelectionDragStop:W,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:F,connectionMode:R,connectionLineType:A=Lr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:Z=!1,selectionMode:se=rs.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:ke=ss()?"Meta":"Control",zoomActivationKeyCode:ve=ss()?"Meta":"Control",snapToGrid:re,snapGrid:Ne,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Te,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,nodeOrigin:Ge=Dg,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt=!0,defaultViewport:mt=b_,minZoom:Pt=.5,maxZoom:ut=2,translateExtent:Je=ns,preventScrolling:An=!0,nodeExtent:Ot,defaultMarkerColor:xn="#b1b1b7",zoomOnScroll:io=!0,zoomOnPinch:$n=!0,panOnScroll:vi=!1,panOnScrollSpeed:or=.5,panOnScrollMode:$r=di.Free,zoomOnDoubleClick:zn=!0,panOnDrag:zr=!0,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn=1,nodeClickDistance:Fn=0,children:_n,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn=10,onNodesChange:Ht,onEdgesChange:Or,noDragClassName:nn="nodrag",noWheelClassName:Fr="nowheel",noPanClassName:yt="nopan",fitView:Hn,fitViewOptions:ur,connectOnClick:oo,attributionPosition:It,proOptions:Bn,defaultEdgeOptions:Hr,elevateNodesOnSelect:jn=!0,elevateEdgesOnSelect:Br=!1,disableKeyboardA11y:xi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:so,autoPanOnSelection:Vr=!0,autoPanSpeed:wi,connectionRadius:cr,isValidConnection:lo,onError:dr,style:Vn,id:bt,nodeDragThreshold:Wr,connectionDragThreshold:Et,viewport:ao,onViewportChange:Ur,width:Yr,height:Wn,colorMode:Un="light",debug:bn,onScroll:Bt,ariaLabelConfig:_i,zIndexMode:Gr="basic",...fr},hr){const Yn=bt||"1",En=P_(Un),uo=L.useCallback(pr=>{pr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Bt==null||Bt(pr)},[Bt]);return d.jsx("div",{"data-testid":"rf__wrapper",...fr,onScroll:uo,style:{...Vn,...nk},ref:hr,className:nt(["react-flow",a,En]),id:bt,role:"application",children:d.jsxs(tk,{nodes:t,edges:r,width:Yr,height:Wn,fitView:Hn,fitViewOptions:ur,minZoom:Pt,maxZoom:ut,nodeOrigin:Ge,nodeExtent:Ot,zIndexMode:Gr,children:[d.jsx(M_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:k,onConnectEnd:b,onClickConnectStart:E,onClickConnectEnd:N,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt,elevateNodesOnSelect:jn,elevateEdgesOnSelect:Br,minZoom:Pt,maxZoom:ut,nodeExtent:Ot,onNodesChange:Ht,onEdgesChange:Or,snapToGrid:re,snapGrid:Ne,connectionMode:R,translateExtent:Je,connectOnClick:oo,defaultEdgeOptions:Hr,fitView:Hn,fitViewOptions:ur,onNodesDelete:ne,onEdgesDelete:ee,onDelete:te,onNodeDragStart:B,onNodeDrag:G,onNodeDragStop:Q,onSelectionDrag:V,onSelectionDragStart:C,onSelectionDragStop:W,onMove:x,onMoveStart:v,onMoveEnd:m,noPanClassName:yt,nodeOrigin:Ge,rfId:Yn,autoPanOnConnect:Ve,autoPanOnNodeDrag:so,autoPanSpeed:wi,onError:dr,connectionRadius:cr,isValidConnection:lo,selectNodesOnDrag:Te,nodeDragThreshold:Wr,connectionDragThreshold:Et,onBeforeDelete:F,debug:bn,ariaLabelConfig:_i,zIndexMode:Gr}),d.jsx(ZS,{onInit:y,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:P,onNodeMouseMove:w,onNodeMouseLeave:j,onNodeContextMenu:$,onNodeDoubleClick:z,nodeTypes:u,edgeTypes:c,connectionLineType:A,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:Z,selectionMode:se,deleteKeyCode:he,multiSelectionKeyCode:ke,panActivationKeyCode:me,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:mt,translateExtent:Je,minZoom:Pt,maxZoom:ut,preventScrolling:An,zoomOnScroll:io,zoomOnPinch:$n,zoomOnDoubleClick:zn,panOnScroll:vi,panOnScrollSpeed:or,panOnScrollMode:$r,panOnDrag:zr,autoPanOnSelection:Vr,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn,nodeClickDistance:Fn,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn,defaultMarkerColor:xn,noDragClassName:nn,noWheelClassName:Fr,noPanClassName:yt,rfId:Yn,disableKeyboardA11y:xi,nodeExtent:Ot,viewport:ao,onViewportChange:Ur,nodesDraggable:$e}),d.jsx(j_,{onSelectionChange:q}),_n,d.jsx(w_,{proOptions:Bn,position:It}),d.jsx(x_,{rfId:Yn,disableKeyboardA11y:xi})]})})}var ik=Fg(rk);function ok({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:nt(["react-flow__background-pattern",o,s])})}function sk({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:nt(["react-flow__background-pattern","dots",r])})}var Ar;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Ar||(Ar={}));const lk={[Ar.Dots]:1,[Ar.Lines]:1,[Ar.Cross]:6},ak=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function hm({id:t,variant:r=Ar.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:y,patternClassName:x}){const v=L.useRef(null),{transform:m,patternId:_}=De(ak,Qe),k=s||lk[r],b=r===Ar.Dots,E=r===Ar.Cross,N=Array.isArray(o)?o:[o,o],P=[N[0]*m[2]||1,N[1]*m[2]||1],w=k*m[2],j=Array.isArray(u)?u:[u,u],$=E?[w,w]:P,z=[j[0]*m[2]+$[0]/2,j[1]*m[2]+$[1]/2],B=`${_}${t||""}`;return d.jsxs("svg",{className:nt(["react-flow__background",y]),style:{...p,...ta,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:v,"data-testid":"rf__background",children:[d.jsx("pattern",{id:B,x:m[0]%P[0],y:m[1]%P[1],width:P[0],height:P[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${z[0]},-${z[1]})`,children:b?d.jsx(sk,{radius:w/2,className:x}):d.jsx(ok,{dimensions:$,lineWidth:a,variant:r,className:x})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${B})`})]})}hm.displayName="Background";const uk=L.memo(hm);function ck(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function fk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 hk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 pk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 Nl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:nt(["react-flow__controls-button",r]),...o,children:t})}const gk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function pm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:y,children:x,position:v="bottom-left",orientation:m="vertical","aria-label":_}){const k=Ye(),{isInteractive:b,minZoomReached:E,maxZoomReached:N,ariaLabelConfig:P}=De(gk,Qe),{zoomIn:w,zoomOut:j,fitView:$}=ea(),z=()=>{w(),u==null||u()},B=()=>{j(),c==null||c()},G=()=>{$(a),h==null||h()},Q=()=>{k.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),p==null||p(!b)},ne=m==="horizontal"?"horizontal":"vertical";return d.jsxs(Jl,{className:nt(["react-flow__controls",ne,y]),position:v,style:t,"data-testid":"rf__controls","aria-label":_??P["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(Nl,{onClick:z,className:"react-flow__controls-zoomin",title:P["controls.zoomIn.ariaLabel"],"aria-label":P["controls.zoomIn.ariaLabel"],disabled:N,children:d.jsx(ck,{})}),d.jsx(Nl,{onClick:B,className:"react-flow__controls-zoomout",title:P["controls.zoomOut.ariaLabel"],"aria-label":P["controls.zoomOut.ariaLabel"],disabled:E,children:d.jsx(dk,{})})]}),o&&d.jsx(Nl,{className:"react-flow__controls-fitview",onClick:G,title:P["controls.fitView.ariaLabel"],"aria-label":P["controls.fitView.ariaLabel"],children:d.jsx(fk,{})}),s&&d.jsx(Nl,{className:"react-flow__controls-interactive",onClick:Q,title:P["controls.interactive.ariaLabel"],"aria-label":P["controls.interactive.ariaLabel"],children:b?d.jsx(pk,{}):d.jsx(hk,{})}),x]})}pm.displayName="Controls";const mk=L.memo(pm);function yk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:y,borderRadius:x,shapeRendering:v,selected:m,onClick:_}){const{background:k,backgroundColor:b}=u||{},E=c||k||b;return d.jsx("rect",{className:nt(["react-flow__minimap-node",{selected:m},y]),x:r,y:o,rx:x,ry:x,width:s,height:a,style:{fill:E,stroke:h,strokeWidth:p},shapeRendering:v,onClick:_?N=>_(N,t):void 0})}const vk=L.memo(yk),xk=t=>t.nodes.map(r=>r.id),qu=t=>t instanceof Function?t:()=>t;function wk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=vk,onClick:c}){const h=De(xk,Qe),p=qu(r),y=qu(t),x=qu(o),v=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(m=>d.jsx(Sk,{id:m,nodeColorFunc:p,nodeStrokeColorFunc:y,nodeClassNameFunc:x,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:v},m))})}function _k({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:y,x,y:v,width:m,height:_}=De(k=>{const b=k.nodeLookup.get(t);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const E=b.internals.userNode,{x:N,y:P}=b.internals.positionAbsolute,{width:w,height:j}=vn(E);return{node:E,x:N,y:P,width:w,height:j}},Qe);return!y||y.hidden||!pg(y)?null:d.jsx(h,{x,y:v,width:m,height:_,style:y.style,selected:!!y.selected,className:s(y),color:r(y),borderRadius:a,strokeColor:o(y),strokeWidth:u,shapeRendering:c,onClick:p,id:y.id})}const Sk=L.memo(_k);var kk=L.memo(wk);const Nk=200,jk=150,bk=t=>!t.hidden,Ek=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?dg(hs(t.nodeLookup,{filter:bk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},hp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,Ck=(t,r)=>hp(t.viewBB,r.viewBB)&&hp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,Mk="react-flow__minimap-desc";function gm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:y,maskStrokeColor:x,maskStrokeWidth:v,position:m="bottom-right",onClick:_,onNodeClick:k,pannable:b=!1,zoomable:E=!1,ariaLabel:N,inversePan:P,zoomStep:w=1,offsetScale:j=5}){const $=Ye(),z=L.useRef(null),{boundingRect:B,viewBB:G,rfId:Q,panZoom:ne,translateExtent:ee,flowWidth:te,flowHeight:q,ariaLabelConfig:C}=De(Ek,Ck),V=(t==null?void 0:t.width)??Nk,W=(t==null?void 0:t.height)??jk,U=B.width/V,M=B.height/W,D=Math.max(U,M),F=D*V,R=D*W,A=j*D,ie=B.x-(F-B.width)/2-A,oe=B.y-(R-B.height)/2-A,fe=F+A*2,he=R+A*2,pe=`${Mk}-${Q}`,Z=L.useRef(0),se=L.useRef();Z.current=D,L.useEffect(()=>{if(z.current&&ne)return se.current=H1({domNode:z.current,panZoom:ne,getTransform:()=>$.getState().transform,getViewScale:()=>Z.current}),()=>{var re;(re=se.current)==null||re.destroy()}},[ne]),L.useEffect(()=>{var re;(re=se.current)==null||re.update({translateExtent:ee,width:te,height:q,inversePan:P,pannable:b,zoomStep:w,zoomable:E})},[b,E,P,w,ee,te,q]);const me=_?re=>{var Te;const[Ne,Me]=((Te=se.current)==null?void 0:Te.pointer(re))||[0,0];_(re,{x:Ne,y:Me})}:void 0,ke=k?L.useCallback((re,Ne)=>{const Me=$.getState().nodeLookup.get(Ne).internals.userNode;k(re,Me)},[]):void 0,ve=N??C["minimap.ariaLabel"];return d.jsx(Jl,{position:m,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof y=="string"?y:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof v=="number"?v*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:nt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:V,height:W,viewBox:`${ie} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:z,onClick:me,children:[ve&&d.jsx("title",{id:pe,children:ve}),d.jsx(kk,{onClick:ke,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-A},${oe-A}h${fe+A*2}v${he+A*2}h${-fe-A*2}z + M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}gm.displayName="MiniMap";const Pk=L.memo(gm),Ik=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Rk={[to.Line]:"right",[to.Handle]:"bottom-right"};function Tk({nodeId:t,position:r,variant:o=to.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:y=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:v=!1,resizeDirection:m,autoScale:_=!0,shouldResize:k,onResizeStart:b,onResize:E,onResizeEnd:N}){const P=Ug(),w=typeof t=="string"?t:P,j=Ye(),$=L.useRef(null),z=o===to.Handle,B=De(L.useCallback(Ik(z&&_),[z,_]),Qe),G=L.useRef(null),Q=r??Rk[o];L.useEffect(()=>{if(!(!$.current||!w))return G.current||(G.current=e_({domNode:$.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:ee,transform:te,snapGrid:q,snapToGrid:C,nodeOrigin:V,domNode:W}=j.getState();return{nodeLookup:ee,transform:te,snapGrid:q,snapToGrid:C,nodeOrigin:V,paneDomNode:W}},onChange:(ee,te)=>{const{triggerNodeChanges:q,nodeLookup:C,parentLookup:V,nodeOrigin:W}=j.getState(),U=[],M={x:ee.x,y:ee.y},D=C.get(w);if(D&&D.expandParent&&D.parentId){const F=D.origin??W,R=ee.width??D.measured.width??0,A=ee.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:R,height:A,...gg({x:ee.x??D.position.x,y:ee.y??D.position.y},{width:R,height:A},D.parentId,C,F)}},oe=Pc([ie],C,V,W);U.push(...oe),M.x=ee.x?Math.max(F[0]*R,ee.x):void 0,M.y=ee.y?Math.max(F[1]*A,ee.y):void 0}if(M.x!==void 0&&M.y!==void 0){const F={id:w,type:"position",position:{...M}};U.push(F)}if(ee.width!==void 0&&ee.height!==void 0){const R={id:w,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:ee.width,height:ee.height}};U.push(R)}for(const F of te){const R={...F,type:"position"};U.push(R)}q(U)},onEnd:({width:ee,height:te})=>{const q={id:w,type:"dimensions",resizing:!1,dimensions:{width:ee,height:te}};j.getState().triggerNodeChanges([q])}})),G.current.update({controlPosition:Q,boundaries:{minWidth:h,minHeight:p,maxWidth:y,maxHeight:x},keepAspectRatio:v,resizeDirection:m,onResizeStart:b,onResize:E,onResizeEnd:N,shouldResize:k}),()=>{var ee;(ee=G.current)==null||ee.destroy()}},[Q,h,p,y,x,v,b,E,N,k]);const ne=Q.split("-");return d.jsx("div",{className:nt(["react-flow__resize-control","nodrag",...ne,o,s]),ref:$,style:{...a,scale:B,...c&&{[z?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Tk);const Lk={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function ra(t){return Lk[t]??8}const Bl=208,as=64,Ak=88,$k=28,zk=8;function Dk(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function mm(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const N of t){const P=ra(N.type),w=s.get(P)??[];w.push(N),s.set(P,w)}const u=[...s.keys()].sort((N,P)=>N-P).map(N=>[...s.get(N)??[]].sort((P,w)=>P.name.localeCompare(w.name)||P.id.localeCompare(w.id))),c=new Set(t.map(N=>N.id)),h=new Map,p=new Map;for(const N of t)h.set(N.id,[]),p.set(N.id,[]);for(const N of r)!c.has(N.src)||!c.has(N.dst)||N.src===N.dst||(p.get(N.src).push(N.dst),h.get(N.dst).push(N.src));const y=new Map;u.forEach((N,P)=>{for(const w of N)y.set(w.id,P)});const x=new Map,v=()=>{for(const N of u)N.forEach((P,w)=>x.set(P.id,w))};v();const m=(N,P)=>{const w=N.map((j,$)=>{const z=P(j.id).map(G=>x.get(G)).filter(G=>G!==void 0),B=Dk(z);return{n:j,bary:Number.isNaN(B)?$:B,name:j.name,id:j.id}});return w.sort((j,$)=>j.bary-$.bary||j.name.localeCompare($.name)||j.id.localeCompare($.id)),w.map(j=>j.n)},_=N=>P=>y.get(P)===N;for(let N=0;N(h.get(w)??[]).filter(_(P-1))),v();for(let P=u.length-2;P>=0;P--)u[P]=m(u[P],w=>(p.get(w)??[]).filter(_(P+1))),v()}const k=Bl+Ak,b=as+$k,E=Math.max(...u.map(N=>N.length),1);return u.forEach((N,P)=>{const w=(E-N.length)*b/2;N.forEach((j,$)=>{o.set(j.id,{x:P*k,y:w+$*b})})}),o}const Ok=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),ym=90,Fk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),pp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Hk=Math.PI*(3-Math.sqrt(5)),vm=220,Bk=26,Vk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function xm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function FN(t){return pp[t]?pp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Wk(t){return t>=ym?"3d":"2d"}function Uk(t){return t>=ym?"overview":"full"}function Yk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(xm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Fk.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Yk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Xk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function qk(t,r,o,s){const a=new Set(t.map(b=>b.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const b of r){if(!a.has(b.src)||!a.has(b.dst))continue;const E=u.get(b.src)??[];E.push({dst:b.dst,id:b.id}),u.set(b.src,E);const N=c.get(b.dst)??[];N.push({src:b.src,id:b.id}),c.set(b.dst,N)}const h=new Set(t.filter(b=>Ok.has(b.type)).map(b=>b.id)),p=h.size?h:a,y=new Set,x=[o];for(;x.length;){const b=x.pop();if(!y.has(b)){y.add(b);for(const E of u.get(b)??[])y.has(E.dst)||x.push(E.dst)}}const v=new Set([o]),m=[...p].filter(b=>y.has(b)),_=new Set(m);for(;m.length;){const b=m.pop();v.add(b);for(const E of c.get(b)??[])y.has(E.src)&&!_.has(E.src)&&(_.add(E.src),m.push(E.src))}const k=new Set;for(const b of r)v.has(b.src)&&v.has(b.dst)&&k.add(b.id);return{nodeIds:v,edgeIds:k}}function HN(t){const r=new Map;for(const s of t){const a=ra(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*vm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Bk*Math.sqrt(h+1),y=h*Hk;o.set(c.id,{x:u,y:p*Math.cos(y),z:p*Math.sin(y)})})}return o}function BN(t){const r=new Map;for(const o of t){const s=ra(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*vm,count:s}))}const jl=16,Kk=12,Qk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Zk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),gp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Jk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},mp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],yp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),eN=new Set(["looks_idempotent_on_pk","null","blank"]),tN=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function nN(t){return gp[t]?gp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function rN(t,r,o){const s=new Map(r.map(m=>[m.id,m])),a=[];Qk.has(t.type)&&a.push("sink"),Zk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(m=>m.dst===t.id),h=o.filter(m=>m.src===t.id),p=c.slice(0,jl).map(m=>bl(m,s,m.src)),y=h.slice(0,jl).map(m=>bl(m,s,m.dst)),x=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,v={type:t.type,typeLabel:Qo(ro(t.type)),layer:Vk[ra(t.type)]??"other",purpose:nN(t.type),name:t.name,qualifiedName:t.qualified_name,file:x,context:t.context,roles:a,facts:oN(u).filter(m=>!(m.key==="app"&&m.value===t.context)),inputs:p,outputs:y,extraInputs:Math.max(0,c.length-jl),extraOutputs:Math.max(0,h.length-jl),degreeIn:c.length,degreeOut:h.length,inputKinds:vp(c.map(m=>bl(m,s,m.src))),outputKinds:vp(h.map(m=>bl(m,s,m.dst))),pathSummary:""};return v.pathSummary=iN(v),v}function vp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function iN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function bl(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Qo(ro(s.type)):"",edgeType:t.type,edgeLabel:Qo(t.type),inferred:t.confidence<.8}}function oN(t){const r=[...mp.filter(a=>a in t),...Object.keys(t).filter(a=>!mp.includes(a)&&!yp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||yp.has(a)||tN.has(a))continue;s.add(a);const u=sN(a,t[a]);u!=null&&o.push({key:a,label:Jk[a]??Qo(a),value:u})}return o}function sN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!eN.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return lN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Kk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function lN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const aN=12,xp=6,wp=.22,uN=.78;function cN(t,r,o){const s=o??mm(t,r),a=[];for(const h of r){const p=s.get(h.src),y=s.get(h.dst);if(!p||!y)continue;const x=p.y+as/2,v=y.y+as/2;if(Math.abs(x-v)${Math.round(_/8)}`})}const u=new Map;for(const h of a){const p=u.get(h.corridor)??[];p.push(h),u.set(h.corridor,p)}const c=new Map;for(const h of u.values()){const p=[...h].sort((m,_)=>m.y0-_.y0||m.y1-_.y1||m.id.localeCompare(_.id)),y=[],x=new Map;for(const m of p){let _=y.findIndex(k=>k.every(b=>!dN(m,b)));_<0&&(_=y.length,y.push([])),y[_].push(m),x.set(m.id,_)}const v=y.length;for(const m of h)c.set(m.id,fN(x.get(m.id)??0,v))}return c}function dN(t,r){return t.y0N0(()=>import("./LayeredGraph3D-C3jIpw-r.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),gN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function mN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(no,{type:"target",position:Se.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:ro(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Tr(t.name)}),d.jsx(no,{type:"source",position:Se.Right,isConnectable:!1})]})}const yN={load:mN},vN=new Set(["django","react","stitch","arch"]);function xN({topologyKey:t}){const{fitView:r}=ea();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function wN(t,r,o=null,s={}){const a=new Map(t.map(y=>[y.id,y])),u=mm(t,r),c=cN(t,r,u),h=t.map(y=>{var m;const x=((m=s.roles)==null?void 0:m[y.id])||[],v=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:y.id,type:"load",position:u.get(y.id)??{x:0,y:0},data:{name:y.name,type:y.type,file:y.file_path,roles:x,dim:v},selected:o===y.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:Bl,height:as,style:{width:Bl,height:as}}}),p=r.filter(y=>a.has(y.src)&&a.has(y.dst)).map(y=>{const x=gN[y.weight]||"var(--edge-cheap)",v=!!(o&&(y.src===o||y.dst===o));return{id:y.id,source:y.src,target:y.dst,type:"smoothstep",animated:y.weight==="critical",pathOptions:{borderRadius:8,stepPosition:c.get(y.id)??.5},style:{stroke:x,strokeWidth:y.weight==="critical"?2.4:1.2,strokeDasharray:y.confidence<.8?"6 4":void 0},markerEnd:{type:is.ArrowClosed,width:14,height:14,color:x},label:v?y.type.replaceAll("_"," "):void 0,labelStyle:v?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:v?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:v?[3,5]:void 0,labelBgBorderRadius:v?4:void 0}});return{rfNodes:h,rfEdges:p}}function _N({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:y}){const x=rN(t,r,o);return L.useEffect(()=>{const v=m=>{m.key==="Escape"&&s()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:x.typeLabel}),d.jsx("div",{className:"inspector-roles",children:x.roles.map(v=>d.jsx("span",{className:"inspector-chip",children:v},v))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Tr(x.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:x.purpose}),x.context?d.jsx("div",{className:"muted",children:Tr(x.context)}):null,x.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Tr(x.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Tr(x.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",x.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[x.degreeIn," in · ",x.degreeOut," out"]}),x.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:x.pathSummary}):null,x.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:x.facts.map(v=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:v.label}),d.jsx("dd",{children:Tr(v.value)})]},v.key))}):null,d.jsx(_p,{title:"Inputs",testId:"graph-inspector-inputs",links:x.inputs,extra:x.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(_p,{title:"Outputs",testId:"graph-inspector-outputs",links:x.outputs,extra:x.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),a?d.jsx("p",{className:"whatif-hint","data-testid":"whatif-hint",children:y?"Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map.":"Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."}):null,d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",title:"Start a hypothetical walk from this node. Does not use Base/Head.",onClick:()=>a(t.id),children:"What if this changes"}):null,y?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",title:"Hide nodes that are not on a path from here to a sink. Does not start a new walk.",onClick:()=>y(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function _p({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Ku({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:y,repoPath:x,onOpenFile:v,pinnedId:m,onPin:_}){const[k,b]=L.useState(null),E=a!==void 0?a:k,N=re=>{a===void 0&&b(re),u==null||u(re)},[P,w]=L.useState(null),[j,$]=L.useState(null),[z,B]=L.useState(new Set(vN)),[G,Q]=L.useState(!1),[ne,ee]=L.useState(""),[te,q]=L.useState(!1),C=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,V=P??Wk(t.length),W=j??Uk(t.length),U=G?E:null,M=L.useMemo(()=>p?qk(t,r,p):null,[t,r,p]),D=M?t.filter(re=>M.nodeIds.has(re.id)):t,F=M?r.filter(re=>M.edgeIds.has(re.id)):r,R=L.useMemo(()=>Gk(D,F,{detail:W,families:z,focusId:U,neighborhoodOnly:!!U}),[D,F,W,z,U]),A=L.useMemo(()=>`${R.nodes.map(re=>re.id).join("\0")}|${R.edges.map(re=>re.id).join("\0")}`,[R.nodes,R.edges]),ie=E?t.find(re=>re.id===E)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const re=wN(R.nodes,R.edges,E,{roles:c,testOverlay:h});return C&&(re.rfEdges=re.rfEdges.map(Ne=>({...Ne,animated:!1}))),re},[R.nodes,R.edges,E,C,c,h]);L.useEffect(()=>{if(!s)return;const re=t.find(Ne=>Ne.file_path===s);re&&N(re.id)},[s,t]);const he=L.useMemo(()=>Xk(t,ne),[t,ne]),pe=(re,Ne)=>{N(Ne.id)},Z=()=>{N(null),Q(!1)},se=ie?d.jsx(_N,{node:ie,nodes:t,edges:r,onClose:Z,onWhatIf:o,onSelect:N,onOpenFile:v,pinned:m===ie.id,onPin:_,onIsolate:y?re=>{y(p===re?null:re)}:void 0}):null,me=re=>{B(Ne=>{const Me=new Set(Ne);if(Me.has(re)){if(Me.size===1)return Ne;Me.delete(re)}else Me.add(re);return Me})},ke=L.useMemo(()=>{const re=new Set;for(const Ne of t)re.add(xm(Ne.type));return re},[t]),ve=t.length-R.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:V==="2d"?"active":"","aria-pressed":V==="2d",onClick:()=>w("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:V==="3d"?"active":"","aria-pressed":V==="3d",onClick:()=>w("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:W==="overview"?"active":"","aria-pressed":W==="overview",onClick:()=>$("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:W==="full"?"active":"","aria-pressed":W==="full",onClick:()=>$("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(re=>ke.has(re)).map(re=>d.jsx("button",{type:"button","data-testid":`graph-family-${re}`,className:z.has(re)?"active":"","aria-pressed":z.has(re),onClick:()=>me(re),children:re},re))}),d.jsx("button",{type:"button",className:G?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!E,onClick:()=>Q(re=>!re),children:G?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>y==null?void 0:y(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:ne,onChange:re=>{ee(re.target.value),q(!0)},onFocus:()=>q(!0),onBlur:()=>window.setTimeout(()=>q(!1),150)}),te&&ne.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(re=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:Ne=>Ne.preventDefault(),onClick:()=>{N(re.id),ee(""),q(!1)},children:[re.name,d.jsx("span",{className:"muted",children:ro(re.type)})]})},re.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[R.nodes.length," nodes · ",R.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:V==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(pN,{nodes:R.nodes,edges:R.edges,selectedId:E,neighborIds:U?R.neighborIds:hN,onSelect:re=>{N(re),re||Q(!1)}})}),se]}):d.jsxs(fm,{children:[d.jsxs(ik,{nodes:oe,edges:fe,nodeTypes:yN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:Z,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(xN,{topologyKey:A}),d.jsx(uk,{}),d.jsx(Pk,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(mk,{})]}),se]})})]})}function wm(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function SN(t){localStorage.setItem("loadpath.editor",t)}async function kN(t,r,o,s=wm()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const Sp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],NN=["preset","branch","tag","commit"];function jN(t){var a;if(!(t!=null&&t.git))return[...Sp];const r=((a=t.presets)!=null&&a.length?t.presets:Sp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function bN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function EN(t){return NN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function CN(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function kp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[y,x]=L.useState(!1),[v,m]=L.useState(null),[_,k]=L.useState(0),b=L.useMemo(()=>{const j=jN(u);return v===null?j:bN(j,v)},[u,v]),E=L.useMemo(()=>EN(b),[b]);L.useEffect(()=>{y&&c()},[y,c]),L.useEffect(()=>{k(0)},[v,y]);const N=()=>{x(!1),m(null)},P=j=>{r(j.value),N()},w=j=>{if(j.key==="ArrowDown"){if(j.preventDefault(),!y){x(!0);return}k($=>Math.min($+1,Math.max(b.length-1,0)))}else if(j.key==="ArrowUp"){if(j.preventDefault(),!y)return;k($=>Math.max($-1,0))}else if(j.key==="Enter"&&y){j.preventDefault();const $=b[_];$&&P($)}else j.key==="Escape"&&y&&(j.preventDefault(),N())};return d.jsxs("div",{className:"combo",ref:p,onBlur:j=>{j.currentTarget.contains(j.relatedTarget)||N()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":y,"aria-controls":h,"aria-autocomplete":"list",onChange:j=>{r(j.target.value),y&&m(j.target.value)},onKeyDown:w}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":y,onMouseDown:j=>j.preventDefault(),onClick:()=>y?N():x(!0),children:d.jsx(_0,{})})]}),y?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:E.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):E.map(j=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:CN(j.group)}),j.items.map($=>{const z=b.indexOf($);return d.jsxs("button",{type:"button",role:"option","aria-selected":z===_,className:z===_?"combo-option active":"combo-option","data-testid":`ref-option-${$.group}`,onMouseDown:B=>B.preventDefault(),onMouseEnter:()=>k(z),onClick:()=>P($),children:[d.jsx("span",{className:"combo-label",children:$.label}),$.detail?d.jsx("span",{className:"combo-detail",children:$.detail}):null]},`${$.group}:${$.value}`)})]},j.group))}):null]})}function MN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[y,x]=L.useState(""),[v,m]=L.useState(!1),_=L.useRef(null),k=L.useRef(0),b=async w=>{const j=k.current+1;k.current=j,m(!0);try{const $=await Pe.browse(w);if(k.current!==j)return;a($),c($.path),p($.is_git?$.path:null),x("")}catch($){if(k.current!==j)return;x($ instanceof Error?$.message:String($))}finally{k.current===j&&m(!1)}};L.useEffect(()=>{var w,j;b(t),(w=_.current)==null||w.focus(),(j=_.current)==null||j.select()},[t]);const E=h||(s==null?void 0:s.path)||u,N=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",P=w=>{w.key==="Escape"&&(w.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:P,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:w=>w.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:w=>{w.preventDefault(),b(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:w=>c(w.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void b(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void b(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),y?d.jsx("div",{className:"error",role:"alert",children:y}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":v,children:s!=null&&s.entries.length?s.entries.map(w=>{const j=h===w.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":j,className:j?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":w.path,onClick:()=>p(w.path),onDoubleClick:()=>void b(w.path),children:[d.jsx(Ep,{}),d.jsx("span",{className:"explorer-name",children:w.name}),w.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},w.path)}):d.jsx("div",{className:"muted explorer-empty",children:v?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:E,children:E}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!E,onClick:()=>E&&r(E),children:["Use ",N]})]})]})})}const PN={scan:{start:0,end:20},extract:{start:20,end:88},boot:{start:88,end:94},stitch:{start:94,end:99},skipped:{start:100,end:100},done:{start:100,end:100}},IN=new Set(["scan","extract","boot","stitch"]);function RN(t){const r=t.phase||"";if(!r||r==="idle")return null;const o=PN[r];if(!o)return null;if(o.start===o.end)return o.end;const s=t.total||0;if(s<=0)return o.start;const a=Math.min(1,Math.max(0,(t.done||0)/s));return Math.round(o.start+(o.end-o.start)*a)}function TN(t){return!t.phase||t.phase==="idle"?null:typeof t.percent=="number"&&Number.isFinite(t.percent)?Math.max(0,Math.min(100,Math.round(t.percent))):RN(t)}const Vl=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],LN="obsidian",_m="loadpath.theme";function AN(t){return Vl.some(r=>r.id===t)}function Sm(){try{const t=localStorage.getItem(_m)||"";if(AN(t))return t}catch{}return LN}function $N(t){var r;return((r=Vl.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function km(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=$N(t);try{localStorage.setItem(_m,t)}catch{}}const Qu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:m0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:y0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:v0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:x0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:w0}];function Zu(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function zN(){var co,fo,Si,ho,po,go,ki,Xr,rn,on;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,y]=L.useState(null),[x,v]=L.useState(null),[m,_]=L.useState(null),[k,b]=L.useState([]),[E,N]=L.useState("review"),[P,w]=L.useState(""),[j,$]=L.useState(""),[z,B]=L.useState(null),[G,Q]=L.useState(!1),[ne,ee]=L.useState(!1),[te,q]=L.useState(""),[C,V]=L.useState({}),[W,U]=L.useState([]),[M,D]=L.useState([]),[F,R]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[A,ie]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[oe,fe]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[he,pe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[Z,se]=L.useState(0),[me,ke]=L.useState(""),[ve,re]=L.useState(Sm),[Ne,Me]=L.useState(!1),[Te,$e]=L.useState(!1),[st,lt]=L.useState(!1),[at,Ge]=L.useState(null),[wt,qt]=L.useState(null),[gt,mt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[Pt,ut]=L.useState(null),[Je,An]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[Ot,xn]=L.useState([]),[io,$n]=L.useState(null),[vi,or]=L.useState(null),[$r,zn]=L.useState(null),[zr,sr]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[lr,Ft]=L.useState(null),[ct,Dn]=L.useState(null),[On,wn]=L.useState(!1),[Fn,_n]=L.useState(!1),rt=L.useRef(o);rt.current=o;const Dr=L.useRef(!1);Dr.current=Te;const _t=L.useRef(""),ar=L.useRef(""),Sn=I=>{re(I),km(I)},dt=L.useRef(""),He=I=>{dt.current=I,$(I)},kn=I=>{let Y=0,ce=!1;B(0);const je=()=>{Pe.indexProgress(I).then(Ie=>{if(!dt.current)return;if(Ie.phase&&Ie.phase!=="idle"&&Ie.message&&He(Ie.message),IN.has(Ie.phase))ce=!0;else if(!ce)return;const qr=TN(Ie);qr!=null&&(Ie.phase==="scan"&&!Ie.done?Y=qr:Y=Math.max(Y,qr),B(Y))}).catch(()=>{})};je();const Le=window.setInterval(je,250);return()=>{window.clearInterval(Le),B(null)}};L.useEffect(()=>{Pe.settings().then(V).catch(()=>{}).finally(()=>Me(!0)),Pe.repos().then(I=>b(I.repos)).catch(()=>{})},[]);const Nn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const I=o;let Y=!1;return ar.current!==I&&Bn(I),Pe.config(I).then(ce=>{!Y&&rt.current===I&&or(ce)}).catch(()=>{}),Pe.architectureHealth(I).then(ce=>{!Y&&rt.current===I&&zn(ce)}).catch(()=>{}),()=>{Y=!0}},[t,o]);const Ht=I=>{rt.current=I,s(I),localStorage.setItem("loadpath.repo",I),I.trim()!==_t.current&&(_t.current="",Ft(null))},Or=L.useCallback(I=>{const Y=(I??rt.current).trim();return!Y||_t.current===Y?Promise.resolve():(_t.current=Y,Pe.gitRefs(Y).then(ce=>{rt.current.trim()===Y&&Ft(ce)}).catch(()=>{_t.current===Y&&(_t.current="",Ft(null))}))},[]),nn=(I,Y)=>{u(I),h(Y),localStorage.setItem("loadpath.base",I),localStorage.setItem("loadpath.head",Y)},Fr=(I,Y,ce)=>{ie(I),R(Y),localStorage.setItem("loadpath.provider",I),localStorage.setItem("loadpath.scmRepo",Y),ce!==void 0&&(fe(ce),localStorage.setItem("loadpath.prNumber",ce))},yt=I=>{y(I),se(0),Ge(wt&&I.nodes.some(Y=>Y.id===wt)?wt:null),ut(null),$n(null),I.what_if||(v(I),I.id&&localStorage.setItem("loadpath.lastReviewId",I.id))},Hn=async I=>{try{const Y=await Pe.reviews(I);xn(Y.reviews)}catch{xn([])}},ur=async I=>{try{zn(await Pe.architectureHealth(I))}catch{zn(null)}},oo=I=>I==="github"?!!C.github_token_set:I==="gitlab"?!!C.gitlab_token_set:!!C.bitbucket_token_set,It=L.useCallback(async(I=A)=>{var Y;try{const ce=await Pe.scmRepos(I);D(ce.repos),(Y=ce.user)!=null&&Y.login&&V(je=>({...je,...I==="github"?{github_user:ce.user.login}:I==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{D([])}},[A]);L.useEffect(()=>{if(t!=="prs")return;let I=!1;return It(A).catch(()=>{I||D([])}),()=>{I=!0}},[t,A,It]),L.useEffect(()=>{if(!ct)return;let I=!1,Y=0;const ce=async()=>{try{const je=await Pe.githubOAuthPoll(ct.flow_id);if(I)return;if(je.status==="complete"){Dn(null);const Le=await Pe.settings();V(Le),q(je.user?`Signed in to GitHub as ${je.user}`:"Signed in to GitHub"),It("github");return}if(je.status==="pending"||je.status==="slow_down"){Y=window.setTimeout(ce,Math.max(je.interval||ct.interval,5)*1e3);return}Dn(null),w(je.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(je){if(I)return;Dn(null),w(je instanceof Error?je.message:String(je))}};return Y=window.setTimeout(ce,Math.max(ct.interval,5)*1e3),()=>{I=!0,window.clearTimeout(Y)}},[ct,It]),L.useEffect(()=>{if(!On)return;let I=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(I)return;if(Le.bitbucket.connected){wn(!1);const Ie=await Pe.settings();V(Ie),q(Le.bitbucket.user?`Signed in to Bitbucket as ${Le.bitbucket.user}`:"Signed in to Bitbucket"),It("bitbucket");return}if(Date.now()-ce>18e4){wn(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(I)return;wn(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{I=!0,window.clearTimeout(Y)}},[On,It]),L.useEffect(()=>{if(!Fn)return;let I=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(I)return;if(Le.gitlab.connected){_n(!1);const Ie=await Pe.settings();V(Ie),q(Le.gitlab.user?`Signed in to GitLab as ${Le.gitlab.user}`:"Signed in to GitLab"),It("gitlab");return}if(Date.now()-ce>18e4){_n(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(I)return;_n(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{I=!0,window.clearTimeout(Y)}},[Fn,It]);const Bn=async(I=o,Y=!1)=>{if(!I.trim())return null;ar.current=I,ee(!0);try{const ce=await Pe.architecture(I,!1);rt.current===I&&_(ce);const je=Pe.architectureGraph(I).then(Le=>{rt.current===I&&_(Ie=>Ie&&{...Ie,nodes:Le.nodes,edges:Le.edges,graph_pending:!1})});return je.catch(()=>{}).finally(()=>{rt.current===I&&ee(!1)}),Y&&await je,ce}catch(ce){throw rt.current===I&&ee(!1),ce}},Hr=async I=>{const Y=I.trim();if(!(!Y||Y===rt.current)){if(dt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),q(""),y(null),v(null),_(null),N("architecture"),Ht(Y),Q(!0),He(`Loading ${g0(Y)}…`);try{await Promise.all([Bn(Y),Or(Y)])}catch(ce){rt.current===Y&&w(ce instanceof Error?ce.message:String(ce))}finally{rt.current===Y&&(He(""),Q(!1))}}},jn=async()=>{if(dt.current||!Nn())return;w(""),q(""),He("Tracing load path…"),Ht(o),nn(a,c);const I=kn(o);try{const Y=await Pe.review(o,a,c,!0,he);yt(Y),N("review"),r("review"),await Pe.repos().then(ce=>b(ce.repos)).catch(()=>{}),await Promise.all([Bn(o),Hn(o),ur(o)])}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{I(),He("")}},Br=async(I=!0)=>{if(dt.current||!Nn())return;w(""),q(""),He(I?"Indexing…":"Full reindex…"),Ht(o);const Y=kn(o);try{await Pe.index(o,I);const ce=await Bn(o);await Pe.repos().then(je=>b(je.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(N("architecture"),r("architecture"))}catch(ce){w(ce instanceof Error?ce.message:String(ce))}finally{Y(),He("")}},xi=async()=>{if(!dt.current&&Nn()){w(""),q(""),He("Detecting layout…"),Ht(o);try{const I=await Pe.init(o);q(I.message),await Pe.repos().then(Y=>b(Y.repos)).catch(()=>{})}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},Ve=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),q("Copied markdown brief")}catch(I){w(I instanceof Error?I.message:String(I))}},so=async()=>{if(!dt.current){if(p!=null&&p.what_if){w("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first.");return}if(!(p!=null&&p.markdown)||!F||!oe){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const I=await Pe.postComment(A,F,Number(oe),p.markdown);q(I.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},Vr=async()=>{if(!dt.current){w(""),He("Fetching pull requests…");try{const I=await Pe.prs(A,F,"open",o.trim()||void 0);U(I.pull_requests);const Y=M.find(ce=>ce.slug.toLowerCase()===F.trim().toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path)}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},wi=async()=>{w("");try{const I=await Pe.githubOAuthStart();Dn(I),Zu(I.verification_uri_complete,"github.com","/login/device")}catch(I){w(I instanceof Error?I.message:String(I))}},cr=async()=>{w("");try{const I=await Pe.bitbucketOAuthStart();wn(!0),Zu(I.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(I){wn(!1),w(I instanceof Error?I.message:String(I))}},lo=async()=>{w("");try{const I=await Pe.gitlabOAuthStart();_n(!0),Zu(I.authorize_url,new URL(I.authorize_url).hostname,"/oauth/authorize")}catch(I){_n(!1),w(I instanceof Error?I.message:String(I))}},dr=async I=>{if(!(dt.current||!o.trim())){w(""),He("Walking what-if path…");try{const Y=await Pe.whatIf(o,I);q(`${Y.title} — ${Y.confidence.level} · ${(Y.sinks||[]).length} sinks`),yt({...Y,markdown:Y.markdown||"",index:Y.index||(p==null?void 0:p.index),workspace:Y.workspace||(p==null?void 0:p.workspace)}),N("review"),r("review")}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},Vn=()=>{if(x){yt(x),N("review"),r("review"),q("Restored the last git-range walk");return}y(null),se(0),Ge(null),ut(null),$n(null),N("architecture"),r("architecture"),q("")},bt=async I=>{var Le;if(dt.current)return;Fr(I.provider,I.repo,String(I.number));const Y=M.find(Ie=>Ie.slug.toLowerCase()===I.repo.toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path),w(""),He(`Fetching ${I.provider} #${I.number}…`);const ce=(Y==null?void 0:Y.local_path)||o,je=ce?kn(ce):()=>{};try{const Ie=await Pe.reviewPr(I.provider,I.repo,I.number,(Y==null?void 0:Y.local_path)||o||void 0);yt(Ie),Ie.pull_request&&typeof Ie.pull_request.repo_path=="string"&&Ht(Ie.pull_request.repo_path),nn(String(Ie.base||I.target_branch),String(Ie.head||I.source_branch)),N("review"),r("review"),typeof((Le=Ie.pull_request)==null?void 0:Le.repo_path)=="string"&&Hn(Ie.pull_request.repo_path)}catch(Ie){nn(I.base_sha||I.target_branch,I.head_sha||I.source_branch),r("review"),w(Ie instanceof Error?Ie.message:String(Ie))}finally{je(),He("")}},Wr=async I=>{w("");try{V(await Pe.oauthDisconnect(I)),A===I&&D([]),q(`Disconnected ${I}`)}catch(Y){w(Y instanceof Error?Y.message:String(Y))}},Et=async I=>{I.preventDefault();const Y=new FormData(I.currentTarget),ce={github_token:String(Y.get("github_token")||""),github_oauth_client_id:String(Y.get("github_oauth_client_id")||""),github_host:String(Y.get("github_host")||""),gitlab_token:String(Y.get("gitlab_token")||""),gitlab_host:String(Y.get("gitlab_host")||""),gitlab_oauth_client_id:String(Y.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(Y.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(Y.get("bitbucket_token")||""),bitbucket_username:String(Y.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(Y.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(Y.get("bitbucket_oauth_client_secret")||""),ai_provider:String(Y.get("ai_provider")||"none"),ai_api_key:String(Y.get("ai_api_key")||""),ai_model:String(Y.get("ai_model")||""),ai_base_url:String(Y.get("ai_base_url")||"")},je=k.length?{...ce,workspaces:k.map(Le=>({path:Le.path,name:Le.name}))}:ce;try{V(await Pe.saveSettings(je)),q("Settings saved on this machine")}catch(Le){w(Le instanceof Error?Le.message:String(Le))}},ao=async()=>{if(!(!p||dt.current)){He("Residual analysis…");try{const I=await Pe.residual(p);ke(I.note)}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},Ur=L.useRef(jn);Ur.current=jn;const Yr=L.useRef(t);Yr.current=t;const Wn=L.useRef(!1);Wn.current=st;const Un=L.useRef(p);Un.current=p;const bn=L.useRef(Z);bn.current=Z,L.useEffect(()=>{const I=localStorage.getItem("loadpath.lastReviewId"),Y=(localStorage.getItem("loadpath.repo")||"").trim();if(!I||!Y){sr(!1);return}let ce=!1;return Pe.getReview(Y,I).then(je=>{ce||(yt(je),nn(je.base||localStorage.getItem("loadpath.base")||"HEAD~1",je.head||localStorage.getItem("loadpath.head")||"HEAD"),Hn(Y),ur(Y))}).catch(()=>{}).finally(()=>{ce||sr(!1)}),()=>{ce=!0}},[]);const Bt=L.useRef("");L.useEffect(()=>{if(!Je||!o.trim())return;let I=!1;const Y=async()=>{try{const je=await Pe.workspaceStatus(o);if(I)return;Bt.current&&je.fingerprint!==Bt.current&&!dt.current&&(pe(!0),localStorage.setItem("loadpath.dirty","1"),Ur.current()),Bt.current=je.fingerprint}catch{}};Y();const ce=window.setInterval(Y,2e3);return()=>{I=!0,window.clearInterval(ce)}},[Je,o]),L.useEffect(()=>{const I=Y=>{var Le;if((Y.metaKey||Y.ctrlKey)&&Y.key.toLowerCase()==="k"){Y.preventDefault(),lt(Ie=>!Ie);return}if(Wn.current){Y.key==="Escape"&&(Y.preventDefault(),lt(!1));return}if(Dr.current){Y.key==="Escape"&&(Y.preventDefault(),$e(!1));return}const ce=Y.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){Y.key==="Escape"&&ce.blur();return}if(Y.key==="Escape"){w(""),q(""),Ge(wt),ut(null);return}if(Y.key==="j"||Y.key==="k"){const Ie=((Le=Un.current)==null?void 0:Le.read_order)||[];if(!Ie.length)return;Y.preventDefault();const Gn=bn.current,qr=Y.key==="j"?Math.min(Ie.length-1,Gn+1):Math.max(0,Gn-1);se(qr);return}const je=Qu.find(Ie=>Ie.shortcut===Y.key);if(je&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey&&r(je.id),(Y.metaKey||Y.ctrlKey)&&Y.key==="Enter"){if(Yr.current==="settings"||Yr.current==="prs"||dt.current)return;Y.preventDefault(),Ur.current()}};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[wt]);const _i=async(I,Y)=>{if(!o.trim())return;const ce=await kN(o,I,Y);ce.ok?q(ce.message):w(ce.message)},Gr=async()=>{if(p)try{const I=await Pe.exportHtml(p),Y=URL.createObjectURL(I),ce=document.createElement("a");ce.href=Y,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(Y),q("Saved HTML brief")}catch(I){w(I instanceof Error?I.message:String(I))}},fr=async I=>{if(o.trim()){He("Loading stored review…");try{const Y=await Pe.getReview(o,I);yt(Y),nn(Y.base||a,Y.head||c),N("review"),r("review");const ce=Ot.find(je=>je.id!==I);if(ce)try{$n(await Pe.reviewDiff(o,I,ce.id))}catch{$n(null)}}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},hr={selectedId:at,onSelect:Ge,nodeRoles:p==null?void 0:p.node_roles,testOverlay:gt,isolateSource:Pt,onIsolate:ut,repoPath:o,onOpenFile:_i,pinnedId:wt,onPin:qt},Yn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},...p!=null&&p.what_if?[{id:"exit-whatif",group:"Review",label:x?"Back to git-range walk":"Exit what-if walk",run:Vn}]:[],{id:"index",group:"Run",label:"Index repository",run:()=>void Br(!0)},{id:"watch",group:"Run",label:Je?"Stop watching working tree":"Watch working tree",run:()=>{const I=!Je;An(I),localStorage.setItem("loadpath.watch",I?"1":"0")}},{id:"tests",group:"Graph",label:gt?"Hide test overlay":"Show test overlay",run:()=>{const I=!gt;mt(I),localStorage.setItem("loadpath.testOverlay",I?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Gr()},...Qu.map(I=>({id:`tab-${I.id}`,group:"Tabs",label:`Go to ${I.label}`,hint:I.shortcut,run:()=>r(I.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(I=>({id:`node-${I.id}`,group:"Nodes",label:I.name,hint:ro(I.type),run:()=>{Ge(I.id),r("graph")}})),...Ot.slice(0,12).map(I=>({id:`hist-${I.id}`,group:"History",label:I.title||I.id,hint:`${I.level||""} ${I.created_at||""}`.trim(),run:()=>void fr(I.id)}))],En=L.useMemo(()=>E==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[E,m,p]),uo=L.useMemo(()=>E==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[E,m,p]),pr=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Fe=((p==null?void 0:p.findings)||[]).filter(I=>!I.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Qu.map(I=>{const Y=I.icon,ce=t===I.id;return d.jsxs("button",{type:"button","data-testid":I.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":I.label,onClick:()=>r(I.id),children:[d.jsx(Y,{}),d.jsx("span",{children:I.label})]},I.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:ve,onChange:I=>Sn(I.target.value),children:["dark","light"].map(I=>d.jsx("optgroup",{label:I==="dark"?"Dark":"Light",children:Vl.filter(Y=>Y.group===I).map(Y=>d.jsx("option",{value:Y.id,children:Y.label},Y.id))},I))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:j||pr}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[j?d.jsxs("div",{className:z!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","aria-valuemin":z!=null?0:void 0,"aria-valuemax":z!=null?100:void 0,"aria-valuenow":z??void 0,"data-testid":"progress",children:[d.jsx("i",{style:z!=null?{width:`${z}%`}:void 0}),d.jsx("span",{className:"sr-only",children:j})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[k.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:k.some(I=>I.path===o)?o:"",disabled:!!j,"aria-busy":G,onChange:I=>{I.target.value&&Hr(I.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),k.map(I=>d.jsxs("option",{value:I.path,children:[I.name,I.indexed?` (${I.counts.nodes})`:""]},I.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:I=>{const Y=I.target.value;s(Y),Y.trim()!==_t.current&&(_t.current="",Ft(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>$e(!0),children:d.jsx(Ep,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(kp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:I=>nn(I,c),placeholder:"base",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(kp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:I=>nn(a,I),placeholder:"head",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:he?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":he,onClick:()=>{const I=!he;pe(I),localStorage.setItem("loadpath.dirty",I?"1":"0")},children:he?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:Je?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":Je,onClick:()=>{const I=!Je;An(I),localStorage.setItem("loadpath.watch",I?"1":"0")},children:Je?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.what_if?"what-if · ":"",p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!j,onClick:xi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!j,onClick:()=>Br(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!j,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[P?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:P}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,te?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:te}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>q(""),"aria-label":"Dismiss",children:"×"})]}):null,((co=p==null?void 0:p.index)!=null&&co.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((fo=p==null?void 0:p.index)==null?void 0:fo.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Si=p==null?void 0:p.index)==null?void 0:Si.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(ho=p==null?void 0:p.workspace)!=null&&ho.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,p!=null&&p.what_if?d.jsxs("div",{className:"banner whatif","data-testid":"whatif-banner",children:[d.jsxs("span",{children:["Hypothetical walk from"," ",d.jsx("strong",{children:((po=p.node)==null?void 0:po.name)||"this node"}),". Loadpath ignored Base/Head and asked which sinks would feel this node change — not a filter of the current map."]}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-exit-whatif",onClick:Vn,children:x?"Back to git range":"Back to architecture"})]}):null,G?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:j||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":G||ne,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(DN,{review:p,findings:Fe,aiNote:me,busy:!!j,tourIndex:Z,onTour:se,onAskAi:ao,onCopy:Ve,onPost:so,onSelect:Ge,onOpenFile:_i,onExport:Gr,history:Ot,diff:io,onReopen:fr,onWaiver:(I,Y)=>{o.trim()&&Pe.addWaiver(o,I,Y||void 0,"from review").then(ce=>{or(ce),q(`Waived ${I} in loadpath.yml`)})}}):zr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Ku,{nodes:p.nodes,edges:p.edges,onWhatIf:dr,focusPath:(go=p.read_order[Z])==null?void 0:go.path,...hr}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(ON,{architecture:m,busy:!!j,onReindex:()=>Br(!1),onReview:jn,onSelect:Ge,config:vi,health:$r,onSaveConfig:I=>{Pe.saveConfig(o,I).then(Y=>{or(Y),q("Wrote loadpath.yml")})},onWaiver:(I,Y,ce)=>{Pe.addWaiver(o,I,Y,ce).then(je=>{or(je),q(`Waived ${I}`)})}}):G?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(ne||m!=null&&m.graph_pending)&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(ki=m==null?void 0:m.counts)!=null&&ki.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Ku,{nodes:m.nodes,edges:m.edges,onWhatIf:dr,...hr,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":E==="review","data-testid":"graph-mode-review",className:E==="review"?"active":"",onClick:()=>N("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":E==="architecture","data-testid":"graph-mode-architecture",className:E==="architecture"?"active":"",onClick:()=>N("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:gt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":gt,onClick:()=>{const I=!gt;mt(I),localStorage.setItem("loadpath.testOverlay",I?"1":"0")},children:"Tests"})]}),En.length?d.jsx(Ku,{nodes:En,edges:uo,onWhatIf:dr,...hr}):ne||m!=null&&m.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:A,onChange:I=>Fr(I.target.value,F,oe),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:M.length?"Search your repos":"owner/repo",value:F,onChange:I=>Fr(A,I.target.value,oe),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:M.map(I=>d.jsxs("option",{value:I.slug,children:[I.private?"private":"public",I.local_path?" · local":""]},I.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!j||!oo(A),onClick:()=>{It(A)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!j,onClick:Vr,children:"List PRs"})]}),M.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[M.length," ",A," repositor",M.length===1?"y":"ies",A==="github"&&C.github_user?` · @${String(C.github_user)}`:"",A==="gitlab"&&C.gitlab_user?` · @${String(C.gitlab_user)}`:"",A==="bitbucket"&&C.bitbucket_user?` · ${String(C.bitbucket_user)}`:""]}):null,W.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):W.map(I=>{var Y;return d.jsxs("article",{className:"pr","data-testid":`pr-${I.number}`,children:[d.jsxs("h3",{children:["#",I.number," ",I.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${I.draft?"":"open"}`,children:I.draft?"draft":I.state}),d.jsx("span",{children:I.author}),d.jsxs("span",{children:[I.source_branch," → ",I.target_branch]}),I.loadpath?d.jsxs("span",{className:`chip ${I.loadpath.level||""}`,"data-testid":`pr-loadpath-${I.number}`,children:[((Y=I.loadpath.level)==null?void 0:Y.toUpperCase())||"REVIEWED",I.loadpath.contract_break&&I.loadpath.contract_break!=="none"?` · ${I.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:I.url,target:"_blank",rel:"noreferrer",children:["Open on ",I.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${I.number}`,onClick:()=>void bt(I),children:"Review this PR"})]})]},`${I.provider}-${I.number}`)})]}),t==="settings"&&Ne&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Et,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Vl.map(I=>d.jsxs("button",{type:"button","data-theme":I.id,className:ve===I.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${I.id}`,onClick:()=>Sn(I.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:I.label}),d.jsx("div",{className:"group",children:I.group})]},I.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:wm(),onChange:I=>SN(I.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:C.github_token_set?C.github_user?`Signed in as @${String(C.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void Wr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!ct||!C.github_oauth_ready,onClick:()=>void wi(),children:ct?"Waiting for GitHub…":"Sign in with GitHub"})})]}),ct?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:ct.user_code})," at GitHub if the browser did not fill it in."]}):null,C.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(C.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(C.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:C.gitlab_token_set?C.gitlab_user?`Signed in as @${String(C.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void Wr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Fn||!C.gitlab_oauth_ready,onClick:()=>void lo(),children:Fn?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(C.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(C.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:C.bitbucket_token_set?C.bitbucket_user?`Signed in as ${String(C.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void Wr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:On||!C.bitbucket_oauth_ready,onClick:()=>void cr(),children:On?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),C.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(C.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(C.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((Xr=C.ai)==null?void 0:Xr.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((rn=C.ai)==null?void 0:rn.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((on=C.ai)==null?void 0:on.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(f0,{open:st,actions:Yn,onClose:()=>lt(!1)}),Te?d.jsx(MN,{initialPath:o,onClose:()=>$e(!1),onSelect:I=>{if(dt.current){w("Wait for the current job to finish before switching workspace.");return}$e(!1),Hr(I)}}):null]})}function DN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:y,onOpenFile:x,onExport:v,history:m,diff:_,onReopen:k,onWaiver:b}){var N,P,w,j,$,z,B,G,Q,ne,ee,te,q,C,V,W,U;const E=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),E.length?d.jsx("ul",{className:"reasons",children:E.map(M=>d.jsx("li",{children:M},M))}):null,t.what_if?d.jsx("span",{className:"chip whatif","data-testid":"whatif-chip",children:"what-if"}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Qo(M)},M)),(N=t.contract_break)!=null&&N.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&y(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>b(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(P=t.workspace)!=null&&P.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>x(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&y(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(Nm,{cards:t.deepening}),(j=(w=t.contract_break)==null?void 0:w.reasons)!=null&&j.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),(z=($=t.contract_break.sides)==null?void 0:$.rows)!=null&&z.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(B=t.auth)!=null&&B.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(G=t.suggested_tests)==null?void 0:G.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(Q=t.trend)!=null&&Q.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",Ju(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),m.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:m.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,m.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>k(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?Ju(M.created_at):""})]},M.id))]}):null,(ee=(ne=t.evolution)==null?void 0:ne.notes)!=null&&ee.length||(q=(te=t.evolution)==null?void 0:te.hotspots)!=null&&q.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((C=t.evolution)==null?void 0:C.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((V=t.evolution)==null?void 0:V.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:v,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",disabled:s||!!t.what_if,title:t.what_if?"Hypothetical walks are not posted to a pull request":void 0,onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(W=t.codeowners_reviewers)!=null&&W.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function ON({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var x;const y=t.findings.filter(v=>!v.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${Ju(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(v=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:v.name})," — ",(v.django_apps||[]).join(", ")||"no apps"," ·"," ",(v.owners||[]).join(", ")||"unowned"]},v.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(v=>d.jsx("div",{className:"muted",children:v},v))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:y.length})]}),y.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):y.map(v=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>v.node_id&&a(v.node_id),children:[d.jsx("span",{className:`chip ${v.severity}`,children:v.severity}),v.message]})},v.rule+v.message))]}),d.jsx(Nm,{cards:t.deepening}),(x=c==null?void 0:c.points)!=null&&x.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(v=>d.jsx("i",{className:v.level||"",title:`${v.level} · ${v.findings} findings`,style:{height:`${8+Math.min(24,(v.findings||0)*4)}px`}},v.id||v.created_at))}),Object.entries(c.contexts).map(([v,m])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:v})," — last ",((_=m[m.length-1])==null?void 0:_.findings)??0," findings"]},v)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(h0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((v,m)=>m[1]-v[1]).slice(0,12).map(([v,m])=>d.jsxs("tr",{children:[d.jsx("td",{children:ro(v)}),d.jsx("td",{children:m})]},v))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function Nm({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:p0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}km(Sm());u0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(zN,{})}));export{Vk as L,BN as a,FN as c,d as j,HN as l,L as r,ro as t}; diff --git a/src/loadpath/static/index.html b/src/loadpath/static/index.html index cdcb187..ea8be1f 100644 --- a/src/loadpath/static/index.html +++ b/src/loadpath/static/index.html @@ -17,7 +17,7 @@ - + diff --git a/ui/src/ImpactGraph.test.ts b/ui/src/ImpactGraph.test.ts index 11097c9..ba89ca6 100644 --- a/ui/src/ImpactGraph.test.ts +++ b/ui/src/ImpactGraph.test.ts @@ -28,6 +28,8 @@ describe("toReactFlowElements", () => { }); expect(rfEdges[0].markerEnd).toMatchObject({ type: MarkerType.ArrowClosed }); expect(rfEdges[0].label).toBeUndefined(); + expect(rfEdges[0].pathOptions?.stepPosition).toBe(0.5); + expect(rfEdges[0].pathOptions?.borderRadius).toBe(8); }); it("labels only edges incident to the selected node", () => { diff --git a/ui/src/ImpactGraph.tsx b/ui/src/ImpactGraph.tsx index 3237c79..d8ae8e2 100644 --- a/ui/src/ImpactGraph.tsx +++ b/ui/src/ImpactGraph.tsx @@ -27,6 +27,7 @@ import { type GraphProjection, } from "./graphView"; import { inspectNode, type InspectorLink } from "./nodeInspector"; +import { assignEdgeStepPositions } from "./graphEdges"; import { GRAPH_NODE_HEIGHT, GRAPH_NODE_WIDTH, @@ -95,6 +96,7 @@ export function toReactFlowElements( ): { rfNodes: Node[]; rfEdges: Edge[] } { const byId = new Map(nodes.map((n) => [n.id, n])); const pos = layoutNodes(nodes, edges); + const stepByEdge = assignEdgeStepPositions(nodes, edges, pos); const rfNodes: Node[] = nodes.map((n) => { const roles = opts.roles?.[n.id] || []; const dim = @@ -127,6 +129,7 @@ export function toReactFlowElements( target: e.dst, type: "smoothstep", animated: e.weight === "critical", + pathOptions: { borderRadius: 8, stepPosition: stepByEdge.get(e.id) ?? 0.5 }, style: { stroke, strokeWidth: e.weight === "critical" ? 2.4 : 1.2, diff --git a/ui/src/graphEdges.test.ts b/ui/src/graphEdges.test.ts new file mode 100644 index 0000000..850101f --- /dev/null +++ b/ui/src/graphEdges.test.ts @@ -0,0 +1,53 @@ +import { describe, expect, it } from "vitest"; +import { assignEdgeStepPositions, stepForLane } from "./graphEdges"; +import type { GraphEdge, GraphNode } from "./types"; + +function node(id: string, type: string): GraphNode { + return { id, type, name: id, qualified_name: id }; +} + +function edge(src: string, dst: string): GraphEdge { + return { id: `${src}->${dst}`, src, dst, type: "uses", weight: "cheap", confidence: 1 }; +} + +describe("assignEdgeStepPositions", () => { + it("staggers overlapping column-to-column edges so they do not share a bend", () => { + const nodes = [ + node("r1", "django.route"), + node("r2", "django.route"), + node("v1", "django.view"), + node("v2", "django.view"), + ]; + const pos = new Map([ + ["r1", { x: 0, y: 0 }], + ["r2", { x: 0, y: 92 }], + ["v1", { x: 296, y: 0 }], + ["v2", { x: 296, y: 184 }], + ]); + const edges = [edge("r1", "v2"), edge("r2", "v2")]; + const steps = assignEdgeStepPositions(nodes, edges, pos); + expect(steps.get("r1->v2")).toBeDefined(); + expect(steps.get("r2->v2")).toBeDefined(); + expect(steps.get("r1->v2")).not.toBe(steps.get("r2->v2")); + expect(Math.abs((steps.get("r1->v2") ?? 0) - (steps.get("r2->v2") ?? 0))).toBeGreaterThan(0.3); + }); + + it("keeps far-apart edges on the default midpoint bend", () => { + const nodes = [node("r1", "django.route"), node("r2", "django.route"), node("v1", "django.view"), node("v2", "django.view")]; + const pos = new Map([ + ["r1", { x: 0, y: 0 }], + ["r2", { x: 0, y: 400 }], + ["v1", { x: 296, y: 0 }], + ["v2", { x: 296, y: 400 }], + ]); + const edges = [edge("r1", "v1"), edge("r2", "v2")]; + const steps = assignEdgeStepPositions(nodes, edges, pos); + expect(steps.size).toBe(0); + }); + + it("spreads lanes between 0.22 and 0.78", () => { + expect(stepForLane(0, 1)).toBe(0.5); + expect(stepForLane(0, 2)).toBe(0.22); + expect(stepForLane(1, 2)).toBe(0.78); + }); +}); diff --git a/ui/src/graphEdges.ts b/ui/src/graphEdges.ts new file mode 100644 index 0000000..067556c --- /dev/null +++ b/ui/src/graphEdges.ts @@ -0,0 +1,76 @@ +import { GRAPH_NODE_HEIGHT, GRAPH_NODE_WIDTH, layoutNodes, type GraphEdge, type GraphNode } from "./types"; + +const HORIZONTAL_EPS = 12; +const Y_PAD = 6; +const STEP_LO = 0.22; +const STEP_HI = 0.78; + +type Span = { + id: string; + y0: number; + y1: number; + corridor: string; +}; + +/** Spread overlapping smooth-step bends so parallel verticals do not share one x. */ +export function assignEdgeStepPositions( + nodes: GraphNode[], + edges: GraphEdge[], + pos?: Map, +): Map { + const placed = pos ?? layoutNodes(nodes, edges); + const spans: Span[] = []; + for (const edge of edges) { + const src = placed.get(edge.src); + const dst = placed.get(edge.dst); + if (!src || !dst) continue; + const sourceY = src.y + GRAPH_NODE_HEIGHT / 2; + const targetY = dst.y + GRAPH_NODE_HEIGHT / 2; + if (Math.abs(sourceY - targetY) < HORIZONTAL_EPS) continue; + const sourceX = src.x + GRAPH_NODE_WIDTH; + const targetX = dst.x; + spans.push({ + id: edge.id, + y0: Math.min(sourceY, targetY), + y1: Math.max(sourceY, targetY), + corridor: `${Math.round(sourceX / 8)}>${Math.round(targetX / 8)}`, + }); + } + + const groups = new Map(); + for (const span of spans) { + const list = groups.get(span.corridor) ?? []; + list.push(span); + groups.set(span.corridor, list); + } + + const steps = new Map(); + for (const group of groups.values()) { + const sorted = [...group].sort((a, b) => a.y0 - b.y0 || a.y1 - b.y1 || a.id.localeCompare(b.id)); + const lanes: Span[][] = []; + const laneOf = new Map(); + for (const span of sorted) { + let lane = lanes.findIndex((items) => items.every((other) => !yOverlap(span, other))); + if (lane < 0) { + lane = lanes.length; + lanes.push([]); + } + lanes[lane].push(span); + laneOf.set(span.id, lane); + } + const n = lanes.length; + for (const span of group) { + steps.set(span.id, stepForLane(laneOf.get(span.id) ?? 0, n)); + } + } + return steps; +} + +function yOverlap(a: Span, b: Span): boolean { + return a.y0 < b.y1 + Y_PAD && b.y0 < a.y1 + Y_PAD; +} + +export function stepForLane(lane: number, laneCount: number): number { + if (laneCount <= 1) return 0.5; + return STEP_LO + ((STEP_HI - STEP_LO) * lane) / (laneCount - 1); +} From 6a35dfc87d61dd3f95e447d7b57c5c1ce57a87db Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 16 Aug 2026 00:31:11 +0000 Subject: [PATCH 09/16] Give each bent graph edge its own vertical in the column gap. Collinear smooth-step edges still stacked when their y-ranges did not overlap. Assign a unique bend per corridor, widen busy column gaps, and draw those paths with a custom step edge. Co-authored-by: zord.lack.net --- ...C3jIpw-r.js => LayeredGraph3D-CfNK3S5A.js} | 2 +- src/loadpath/static/assets/index-CUH75ocM.js | 62 ------------------- src/loadpath/static/assets/index-E4JBz9vY.js | 62 +++++++++++++++++++ src/loadpath/static/index.html | 2 +- ui/src/ImpactGraph.test.ts | 5 +- ui/src/ImpactGraph.tsx | 60 +++++++++++++++++- ui/src/graphEdges.test.ts | 37 ++++++++++- ui/src/graphEdges.ts | 38 +++--------- ui/src/types.ts | 17 ++++- 9 files changed, 184 insertions(+), 101 deletions(-) rename src/loadpath/static/assets/{LayeredGraph3D-C3jIpw-r.js => LayeredGraph3D-CfNK3S5A.js} (99%) delete mode 100644 src/loadpath/static/assets/index-CUH75ocM.js create mode 100644 src/loadpath/static/assets/index-E4JBz9vY.js diff --git a/src/loadpath/static/assets/LayeredGraph3D-C3jIpw-r.js b/src/loadpath/static/assets/LayeredGraph3D-CfNK3S5A.js similarity index 99% rename from src/loadpath/static/assets/LayeredGraph3D-C3jIpw-r.js rename to src/loadpath/static/assets/LayeredGraph3D-CfNK3S5A.js index 6192bdb..9e403b6 100644 --- a/src/loadpath/static/assets/LayeredGraph3D-C3jIpw-r.js +++ b/src/loadpath/static/assets/LayeredGraph3D-CfNK3S5A.js @@ -1,4 +1,4 @@ -import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-CUH75ocM.js";/** +import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-E4JBz9vY.js";/** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT diff --git a/src/loadpath/static/assets/index-CUH75ocM.js b/src/loadpath/static/assets/index-CUH75ocM.js deleted file mode 100644 index 15709c8..0000000 --- a/src/loadpath/static/assets/index-CUH75ocM.js +++ /dev/null @@ -1,62 +0,0 @@ -(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function Np(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ru={exports:{}},Wo={},Tu={exports:{}},Re={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var qf;function t0(){if(qf)return Re;qf=1;var t=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),v=Symbol.iterator;function m(R){return R===null||typeof R!="object"?null:(R=v&&R[v]||R["@@iterator"],typeof R=="function"?R:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,b={};function E(R,A,ie){this.props=R,this.context=A,this.refs=b,this.updater=ie||_}E.prototype.isReactComponent={},E.prototype.setState=function(R,A){if(typeof R!="object"&&typeof R!="function"&&R!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,R,A,"setState")},E.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function N(){}N.prototype=E.prototype;function P(R,A,ie){this.props=R,this.context=A,this.refs=b,this.updater=ie||_}var w=P.prototype=new N;w.constructor=P,k(w,E.prototype),w.isPureReactComponent=!0;var j=Array.isArray,$=Object.prototype.hasOwnProperty,z={current:null},B={key:!0,ref:!0,__self:!0,__source:!0};function G(R,A,ie){var oe,fe={},he=null,pe=null;if(A!=null)for(oe in A.ref!==void 0&&(pe=A.ref),A.key!==void 0&&(he=""+A.key),A)$.call(A,oe)&&!B.hasOwnProperty(oe)&&(fe[oe]=A[oe]);var Z=arguments.length-2;if(Z===1)fe.children=ie;else if(1>>1,A=M[R];if(0>>1;Ra(fe,F))hea(pe,fe)?(M[R]=pe,M[he]=F,R=he):(M[R]=fe,M[oe]=F,R=oe);else if(hea(pe,F))M[R]=pe,M[he]=F,R=he;else break e}}return D}function a(M,D){var F=M.sortIndex-D.sortIndex;return F!==0?F:M.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,h=c.now();t.unstable_now=function(){return c.now()-h}}var p=[],y=[],x=1,v=null,m=3,_=!1,k=!1,b=!1,E=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,P=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(M){for(var D=o(y);D!==null;){if(D.callback===null)s(y);else if(D.startTime<=M)s(y),D.sortIndex=D.expirationTime,r(p,D);else break;D=o(y)}}function j(M){if(b=!1,w(M),!k)if(o(p)!==null)k=!0,W($);else{var D=o(y);D!==null&&U(j,D.startTime-M)}}function $(M,D){k=!1,b&&(b=!1,N(G),G=-1),_=!0;var F=m;try{for(w(D),v=o(p);v!==null&&(!(v.expirationTime>D)||M&&!ee());){var R=v.callback;if(typeof R=="function"){v.callback=null,m=v.priorityLevel;var A=R(v.expirationTime<=D);D=t.unstable_now(),typeof A=="function"?v.callback=A:v===o(p)&&s(p),w(D)}else s(p);v=o(p)}if(v!==null)var ie=!0;else{var oe=o(y);oe!==null&&U(j,oe.startTime-D),ie=!1}return ie}finally{v=null,m=F,_=!1}}var z=!1,B=null,G=-1,Q=5,ne=-1;function ee(){return!(t.unstable_now()-neM||125R?(M.sortIndex=F,r(y,M),o(p)===null&&M===o(y)&&(b?(N(G),G=-1):b=!0,U(j,F-R))):(M.sortIndex=A,r(p,M),k||_||(k=!0,W($))),M},t.unstable_shouldYield=ee,t.unstable_wrapCallback=function(M){var D=m;return function(){var F=m;m=D;try{return M.apply(this,arguments)}finally{m=F}}}})($u)),$u}var eh;function s0(){return eh||(eh=1,Au.exports=o0()),Au.exports}/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var th;function l0(){if(th)return zt;th=1;var t=us(),r=s0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,y=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,x={},v={};function m(e){return p.call(v,e)?!0:p.call(x,e)?!1:y.test(e)?v[e]=!0:(x[e]=!0,!1)}function _(e,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function k(e,n,i,l){if(n===null||typeof n>"u"||_(e,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function b(e,n,i,l,f,g,S){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=f,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=g,this.removeEmptyString=S}var E={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){E[e]=new b(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];E[n]=new b(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){E[e]=new b(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){E[e]=new b(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){E[e]=new b(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){E[e]=new b(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){E[e]=new b(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){E[e]=new b(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){E[e]=new b(e,5,!1,e.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function P(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(N,P);E[n]=new b(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(N,P);E[n]=new b(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(N,P);E[n]=new b(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){E[e]=new b(e,1,!1,e.toLowerCase(),null,!1,!1)}),E.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){E[e]=new b(e,1,!1,e.toLowerCase(),null,!0,!0)});function w(e,n,i,l){var f=E.hasOwnProperty(n)?E[n]:null;(f!==null?f.type!==0:l||!(2T||f[S]!==g[T]){var O=` -`+f[S].replace(" at new "," at ");return e.displayName&&O.includes("")&&(O=O.replace("",e.displayName)),O}while(1<=S&&0<=T);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?A(e):""}function fe(e){switch(e.tag){case 5:return A(e.type);case 16:return A("Lazy");case 13:return A("Suspense");case 19:return A("SuspenseList");case 0:case 2:case 15:return e=oe(e.type,!1),e;case 11:return e=oe(e.type.render,!1),e;case 1:return e=oe(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case B:return"Fragment";case z:return"Portal";case Q:return"Profiler";case G:return"StrictMode";case q:return"Suspense";case C:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ee:return(e.displayName||"Context")+".Consumer";case ne:return(e._context.displayName||"Context")+".Provider";case te:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case W:n=e._payload,e=e._init;try{return he(e(n))}catch{}}return null}function pe(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===G?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Z(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=se(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function ke(e){e._valueTracker||(e._valueTracker=me(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=se(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function re(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return F({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Z(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Te(e,n){n=n.checked,n!=null&&w(e,"checked",n,!1)}function $e(e,n){Te(e,n);var i=Z(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?lt(e,n.type,i):n.hasOwnProperty("defaultValue")&<(e,n.type,Z(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function st(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function lt(e,n,i){(n!=="number"||re(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var at=Array.isArray;function Ge(e,n,i,l){if(e=e.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=Je.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ot(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var xn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},io=["Webkit","ms","Moz","O"];Object.keys(xn).forEach(function(e){io.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),xn[n]=xn[e]})});function $n(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||xn.hasOwnProperty(e)&&xn[e]?(""+n).trim():n+"px"}function vi(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=$n(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,f):e[i]=f}}var or=F({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function $r(e,n){if(n){if(or[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function zn(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var zr=null;function sr(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var lr=null,Ft=null,ct=null;function Dn(e){if(e=Mo(e)){if(typeof lr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=Ps(n),lr(e.stateNode,e.type,n))}}function On(e){Ft?ct?ct.push(e):ct=[e]:Ft=e}function wn(){if(Ft){var e=Ft,n=ct;if(ct=Ft=null,Dn(e),n)for(e=0;e>>=0,e===0?32:31-(ao(e)/Ur|0)|0}var Wn=64,Un=4194304;function bn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Bt(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,f=e.suspendedLanes,g=e.pingedLanes,S=i&268435455;if(S!==0){var T=S&~f;T!==0?l=bn(T):(g&=S,g!==0&&(l=bn(g)))}else S=i&~f,S!==0?l=bn(S):g!==0&&(l=bn(g));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,g=n&-n,f>=g||f===16&&(g&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function En(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Et(n),e[n]=i}function uo(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=wo),Hc=" ",Bc=!1;function Vc(e,n){switch(e){case"keyup":return Km.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var bi=!1;function Zm(e,n){switch(e){case"compositionend":return Wc(n);case"keypress":return n.which!==32?null:(Bc=!0,Hc);case"textInput":return e=n.data,e===Hc&&Bc?null:e;default:return null}}function Jm(e,n){if(bi)return e==="compositionend"||!fa&&Vc(e,n)?(e=Ac(),xs=sa=gr=null,bi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Qc(i)}}function Jc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Jc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function ed(){for(var e=window,n=re();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=re(e.document)}return n}function ga(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function ay(e){var n=ed(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Jc(i.ownerDocument.documentElement,i)){if(l!==null&&ga(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var f=i.textContent.length,g=Math.min(l.start,f);l=l.end===void 0?g:Math.min(l.end,f),!e.extend&&g>l&&(f=l,l=g,g=f),f=Zc(i,g);var S=Zc(i,l);f&&S&&(e.rangeCount!==1||e.anchorNode!==f.node||e.anchorOffset!==f.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),e.removeAllRanges(),g>l?(e.addRange(n),e.extend(S.node,S.offset)):(n.setEnd(S.node,S.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,Ei=null,ma=null,No=null,ya=!1;function td(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;ya||Ei==null||Ei!==re(l)||(l=Ei,"selectionStart"in l&&ga(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),No&&ko(No,l)||(No=l,l=Es(ma,"onSelect"),0Ri||(e.current=Ma[Ri],Ma[Ri]=null,Ri--)}function Be(e,n){Ri++,Ma[Ri]=e.current,e.current=n}var xr={},St=vr(xr),Rt=vr(!1),Qr=xr;function Ti(e,n){var i=e.type.contextTypes;if(!i)return xr;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in i)f[g]=n[g];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=f),f}function Tt(e){return e=e.childContextTypes,e!=null}function Is(){Ue(Rt),Ue(St)}function md(e,n,i){if(St.current!==xr)throw Error(o(168));Be(St,n),Be(Rt,i)}function yd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,pe(e)||"Unknown",f));return F({},i,l)}function Rs(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||xr,Qr=St.current,Be(St,e),Be(Rt,Rt.current),!0}function vd(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=yd(e,n,Qr),l.__reactInternalMemoizedMergedChildContext=e,Ue(Rt),Ue(St),Be(St,e)):Ue(Rt),Be(Rt,i)}var qn=null,Ts=!1,Pa=!1;function xd(e){qn===null?qn=[e]:qn.push(e)}function wy(e){Ts=!0,xd(e)}function wr(){if(!Pa&&qn!==null){Pa=!0;var e=0,n=Fe;try{var i=qn;for(Fe=1;e>=S,f-=S,Kn=1<<32-Et(n)+f|i<Ce?(pt=Ee,Ee=null):pt=Ee.sibling;var Oe=le(X,Ee,K[Ce],de);if(Oe===null){Ee===null&&(Ee=pt);break}e&&Ee&&Oe.alternate===null&&n(X,Ee),H=g(Oe,H,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe,Ee=pt}if(Ce===K.length)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;CeCe?(pt=Ee,Ee=null):pt=Ee.sibling;var Mr=le(X,Ee,Oe.value,de);if(Mr===null){Ee===null&&(Ee=pt);break}e&&Ee&&Mr.alternate===null&&n(X,Ee),H=g(Mr,H,Ce),be===null?_e=Mr:be.sibling=Mr,be=Mr,Ee=pt}if(Oe.done)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;!Oe.done;Ce++,Oe=K.next())Oe=ue(X,Oe.value,de),Oe!==null&&(H=g(Oe,H,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return Xe&&Jr(X,Ce),_e}for(Ee=l(X,Ee);!Oe.done;Ce++,Oe=K.next())Oe=ge(Ee,X,Ce,Oe.value,de),Oe!==null&&(e&&Oe.alternate!==null&&Ee.delete(Oe.key===null?Ce:Oe.key),H=g(Oe,H,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return e&&Ee.forEach(function(e0){return n(X,e0)}),Xe&&Jr(X,Ce),_e}function et(X,H,K,de){if(typeof K=="object"&&K!==null&&K.type===B&&K.key===null&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case $:e:{for(var _e=K.key,be=H;be!==null;){if(be.key===_e){if(_e=K.type,_e===B){if(be.tag===7){i(X,be.sibling),H=f(be,K.props.children),H.return=X,X=H;break e}}else if(be.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===W&&jd(_e)===be.type){i(X,be.sibling),H=f(be,K.props),H.ref=Po(X,be,K),H.return=X,X=H;break e}i(X,be);break}else n(X,be);be=be.sibling}K.type===B?(H=li(K.props.children,X.mode,de,K.key),H.return=X,X=H):(de=ll(K.type,K.key,K.props,null,X.mode,de),de.ref=Po(X,H,K),de.return=X,X=de)}return S(X);case z:e:{for(be=K.key;H!==null;){if(H.key===be)if(H.tag===4&&H.stateNode.containerInfo===K.containerInfo&&H.stateNode.implementation===K.implementation){i(X,H.sibling),H=f(H,K.children||[]),H.return=X,X=H;break e}else{i(X,H);break}else n(X,H);H=H.sibling}H=Eu(K,X.mode,de),H.return=X,X=H}return S(X);case W:return be=K._init,et(X,H,be(K._payload),de)}if(at(K))return xe(X,H,K,de);if(D(K))return we(X,H,K,de);zs(X,K)}return typeof K=="string"&&K!==""||typeof K=="number"?(K=""+K,H!==null&&H.tag===6?(i(X,H.sibling),H=f(H,K),H.return=X,X=H):(i(X,H),H=bu(K,X.mode,de),H.return=X,X=H),S(X)):i(X,H)}return et}var zi=bd(!0),Ed=bd(!1),Ds=vr(null),Os=null,Di=null,$a=null;function za(){$a=Di=Os=null}function Da(e){var n=Ds.current;Ue(Ds),e._currentValue=n}function Oa(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function Oi(e,n){Os=e,$a=Di=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Lt=!0),e.firstContext=null)}function Zt(e){var n=e._currentValue;if($a!==e)if(e={context:e,memoizedValue:n,next:null},Di===null){if(Os===null)throw Error(o(308));Di=e,Os.dependencies={lanes:0,firstContext:e}}else Di=Di.next=e;return n}var ei=null;function Fa(e){ei===null?ei=[e]:ei.push(e)}function Cd(e,n,i,l){var f=n.interleaved;return f===null?(i.next=i,Fa(n)):(i.next=f.next,f.next=i),n.interleaved=i,Zn(e,l)}function Zn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var _r=!1;function Ha(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Md(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Jn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Sr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(ze&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,Zn(e,i)}return f=l.interleaved,f===null?(n.next=n,Fa(l)):(n.next=f.next,f.next=n),l.interleaved=n,Zn(e,i)}function Fs(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}function Pd(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var S={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?f=g=S:g=g.next=S,i=i.next}while(i!==null);g===null?f=g=n:g=g.next=n}else f=g=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function Hs(e,n,i,l){var f=e.updateQueue;_r=!1;var g=f.firstBaseUpdate,S=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,J=O.next;O.next=null,S===null?g=J:S.next=J,S=O;var ae=e.alternate;ae!==null&&(ae=ae.updateQueue,T=ae.lastBaseUpdate,T!==S&&(T===null?ae.firstBaseUpdate=J:T.next=J,ae.lastBaseUpdate=O))}if(g!==null){var ue=f.baseState;S=0,ae=J=O=null,T=g;do{var le=T.lane,ge=T.eventTime;if((l&le)===le){ae!==null&&(ae=ae.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var xe=e,we=T;switch(le=n,ge=i,we.tag){case 1:if(xe=we.payload,typeof xe=="function"){ue=xe.call(ge,ue,le);break e}ue=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=we.payload,le=typeof xe=="function"?xe.call(ge,ue,le):xe,le==null)break e;ue=F({},ue,le);break e;case 2:_r=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,le=f.effects,le===null?f.effects=[T]:le.push(T))}else ge={eventTime:ge,lane:le,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ae===null?(J=ae=ge,O=ue):ae=ae.next=ge,S|=le;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;le=T,T=le.next,le.next=null,f.lastBaseUpdate=le,f.shared.pending=null}}while(!0);if(ae===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=J,f.lastBaseUpdate=ae,n=f.shared.interleaved,n!==null){f=n;do S|=f.lane,f=f.next;while(f!==n)}else g===null&&(f.shared.lanes=0);ri|=S,e.lanes=S,e.memoizedState=ue}}function Id(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=Ya.transition;Ya.transition={};try{e(!1),n()}finally{Fe=i,Ya.transition=l}}function Kd(){return Jt().memoizedState}function Ny(e,n,i){var l=br(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},Qd(e))Zd(n,i);else if(i=Cd(e,n,i,l),i!==null){var f=Mt();dn(i,e,l,f),Jd(i,n,l)}}function jy(e,n,i){var l=br(e),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(Qd(e))Zd(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,T=g(S,i);if(f.hasEagerState=!0,f.eagerState=T,sn(T,S)){var O=n.interleaved;O===null?(f.next=f,Fa(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=Cd(e,n,f,l),i!==null&&(f=Mt(),dn(i,e,l,f),Jd(i,n,l))}}function Qd(e){var n=e.alternate;return e===Ke||n!==null&&n===Ke}function Zd(e,n){Lo=Ws=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Jd(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}var Gs={readContext:Zt,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},by={readContext:Zt,useCallback:function(e,n){return Pn().memoizedState=[e,n===void 0?null:n],e},useContext:Zt,useEffect:Bd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Us(4194308,4,Ud.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Us(4194308,4,e,n)},useInsertionEffect:function(e,n){return Us(4,2,e,n)},useMemo:function(e,n){var i=Pn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=Pn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=Ny.bind(null,Ke,e),[l.memoizedState,e]},useRef:function(e){var n=Pn();return e={current:e},n.memoizedState=e},useState:Fd,useDebugValue:Ja,useDeferredValue:function(e){return Pn().memoizedState=e},useTransition:function(){var e=Fd(!1),n=e[0];return e=ky.bind(null,e[1]),Pn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=Ke,f=Pn();if(Xe){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ht===null)throw Error(o(349));(ni&30)!==0||Ad(l,n,i)}f.memoizedState=i;var g={value:i,getSnapshot:n};return f.queue=g,Bd(zd.bind(null,l,g,e),[e]),l.flags|=2048,zo(9,$d.bind(null,l,g,i,n),void 0,null),i},useId:function(){var e=Pn(),n=ht.identifierPrefix;if(Xe){var i=Qn,l=Kn;i=(l&~(1<<32-Et(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=Ao++,0<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=S.createElement(i,{is:l.is}):(e=S.createElement(i),i==="select"&&(S=e,l.multiple?S.multiple=!0:l.size&&(S.size=l.size))):e=S.createElementNS(e,i),e[Cn]=n,e[Co]=l,wf(e,n,!1,!1),n.stateNode=e;e:{switch(S=zn(i,l),i){case"dialog":We("cancel",e),We("close",e),f=l;break;case"iframe":case"object":case"embed":We("load",e),f=l;break;case"video":case"audio":for(f=0;fWi&&(n.flags|=128,l=!0,Do(g,!1),n.lanes=4194304)}else{if(!l)if(e=Bs(S),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Do(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Xe)return Nt(n),null}else 2*Ve()-g.renderingStartTime>Wi&&i!==1073741824&&(n.flags|=128,l=!0,Do(g,!1),n.lanes=4194304);g.isBackwards?(S.sibling=n.child,n.child=S):(i=g.last,i!==null?i.sibling=S:n.child=S,g.last=S)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(Nt(n),null);case 22:case 23:return ku(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Yt&1073741824)!==0&&(Nt(n),n.subtreeFlags&6&&(n.flags|=8192)):Nt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function Ly(e,n){switch(Ra(n),n.tag){case 1:return Tt(n.type)&&Is(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Fi(),Ue(Rt),Ue(St),Ua(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Va(n),null;case 13:if(Ue(qe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));$i()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Fi(),null;case 10:return Da(n.type._context),null;case 22:case 23:return ku(),null;case 24:return null;default:return null}}var Qs=!1,jt=!1,Ay=typeof WeakSet=="function"?WeakSet:Set,ye=null;function Bi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Ze(e,n,l)}else i.current=null}function du(e,n,i){try{i()}catch(l){Ze(e,n,l)}}var kf=!1;function $y(e,n){if(ka=ys,e=ed(),ga(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,g=l.focusNode;l=l.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var S=0,T=-1,O=-1,J=0,ae=0,ue=e,le=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=S+f),ue!==g||l!==0&&ue.nodeType!==3||(O=S+l),ue.nodeType===3&&(S+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)le=ue,ue=ge;for(;;){if(ue===e)break t;if(le===i&&++J===f&&(T=S),le===g&&++ae===l&&(O=S),(ge=ue.nextSibling)!==null)break;ue=le,le=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(Na={focusedElem:e,selectionRange:i},ys=!1,ye=n;ye!==null;)if(n=ye,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ye=e;else for(;ye!==null;){n=ye;try{var xe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var we=xe.memoizedProps,et=xe.memoizedState,X=n.stateNode,H=X.getSnapshotBeforeUpdate(n.elementType===n.type?we:an(n.type,we),et);X.__reactInternalSnapshotBeforeUpdate=H}break;case 3:var K=n.stateNode.containerInfo;K.nodeType===1?K.textContent="":K.nodeType===9&&K.documentElement&&K.removeChild(K.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(de){Ze(n,n.return,de)}if(e=n.sibling,e!==null){e.return=n.return,ye=e;break}ye=n.return}return xe=kf,kf=!1,xe}function Oo(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&e)===e){var g=f.destroy;f.destroy=void 0,g!==void 0&&du(n,i,g)}f=f.next}while(f!==l)}}function Zs(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function fu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function Nf(e){var n=e.alternate;n!==null&&(e.alternate=null,Nf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[Cn],delete n[Co],delete n[Ca],delete n[vy],delete n[xy])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function jf(e){return e.tag===5||e.tag===3||e.tag===4}function bf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||jf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function hu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=Ms));else if(l!==4&&(e=e.child,e!==null))for(hu(e,n,i),e=e.sibling;e!==null;)hu(e,n,i),e=e.sibling}function pu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(pu(e,n,i),e=e.sibling;e!==null;)pu(e,n,i),e=e.sibling}var vt=null,un=!1;function kr(e,n,i){for(i=i.child;i!==null;)Ef(e,n,i),i=i.sibling}function Ef(e,n,i){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(Vn,i)}catch{}switch(i.tag){case 5:jt||Bi(i,n);case 6:var l=vt,f=un;vt=null,kr(e,n,i),vt=l,un=f,vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):vt.removeChild(i.stateNode));break;case 18:vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?Ea(e.parentNode,i):e.nodeType===1&&Ea(e,i),yo(e)):Ea(vt,i.stateNode));break;case 4:l=vt,f=un,vt=i.stateNode.containerInfo,un=!0,kr(e,n,i),vt=l,un=f;break;case 0:case 11:case 14:case 15:if(!jt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var g=f,S=g.destroy;g=g.tag,S!==void 0&&((g&2)!==0||(g&4)!==0)&&du(i,n,S),f=f.next}while(f!==l)}kr(e,n,i);break;case 1:if(!jt&&(Bi(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Ze(i,n,T)}kr(e,n,i);break;case 21:kr(e,n,i);break;case 22:i.mode&1?(jt=(l=jt)||i.memoizedState!==null,kr(e,n,i),jt=l):kr(e,n,i);break;default:kr(e,n,i)}}function Cf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Ay),n.forEach(function(l){var f=Uy.bind(null,e,l);i.has(l)||(i.add(l),l.then(f,f))})}}function cn(e,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=S),l&=~g}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Dy(l/1960))-l,10e?16:e,jr===null)var l=!1;else{if(e=jr,jr=null,rl=0,(ze&6)!==0)throw Error(o(331));var f=ze;for(ze|=4,ye=e.current;ye!==null;){var g=ye,S=g.child;if((ye.flags&16)!==0){var T=g.deletions;if(T!==null){for(var O=0;OVe()-yu?oi(e,0):mu|=i),$t(e,n)}function Hf(e,n){n===0&&((e.mode&1)===0?n=1:(n=Un,Un<<=1,(Un&130023424)===0&&(Un=4194304)));var i=Mt();e=Zn(e,n),e!==null&&(En(e,n,i),$t(e,i))}function Wy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Hf(e,i)}function Uy(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Hf(e,i)}var Bf;Bf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Rt.current)Lt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Lt=!1,Ry(e,n,i);Lt=(e.flags&131072)!==0}else Lt=!1,Xe&&(n.flags&1048576)!==0&&wd(n,As,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Ks(e,n),e=n.pendingProps;var f=Ti(n,St.current);Oi(n,i),f=Xa(null,n,l,e,f,i);var g=qa();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Tt(l)?(g=!0,Rs(n)):g=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Ha(n),f.updater=Xs,n.stateNode=f,f._reactInternals=n,tu(n,l,e,i),n=ou(null,n,l,!0,g,i)):(n.tag=0,Xe&&g&&Ia(n),Ct(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Ks(e,n),e=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=Gy(l),e=an(l,e),f){case 0:n=iu(null,n,l,e,i);break e;case 1:n=pf(null,n,l,e,i);break e;case 11:n=uf(null,n,l,e,i);break e;case 14:n=cf(null,n,l,an(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),iu(e,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),pf(e,n,l,f,i);case 3:e:{if(gf(n),e===null)throw Error(o(387));l=n.pendingProps,g=n.memoizedState,f=g.element,Md(e,n),Hs(n,l,null,i);var S=n.memoizedState;if(l=S.element,g.isDehydrated)if(g={element:l,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){f=Hi(Error(o(423)),n),n=mf(e,n,l,i,f);break e}else if(l!==f){f=Hi(Error(o(424)),n),n=mf(e,n,l,i,f);break e}else for(Ut=yr(n.stateNode.containerInfo.firstChild),Wt=n,Xe=!0,ln=null,i=Ed(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if($i(),l===f){n=er(e,n,i);break e}Ct(e,n,l,i)}n=n.child}return n;case 5:return Rd(n),e===null&&La(n),l=n.type,f=n.pendingProps,g=e!==null?e.memoizedProps:null,S=f.children,ja(l,f)?S=null:g!==null&&ja(l,g)&&(n.flags|=32),hf(e,n),Ct(e,n,S,i),n.child;case 6:return e===null&&La(n),null;case 13:return yf(e,n,i);case 4:return Ba(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=zi(n,null,l,i):Ct(e,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),uf(e,n,l,f,i);case 7:return Ct(e,n,n.pendingProps,i),n.child;case 8:return Ct(e,n,n.pendingProps.children,i),n.child;case 12:return Ct(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,g=n.memoizedProps,S=f.value,Be(Ds,l._currentValue),l._currentValue=S,g!==null)if(sn(g.value,S)){if(g.children===f.children&&!Rt.current){n=er(e,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var T=g.dependencies;if(T!==null){S=g.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(g.tag===1){O=Jn(-1,i&-i),O.tag=2;var J=g.updateQueue;if(J!==null){J=J.shared;var ae=J.pending;ae===null?O.next=O:(O.next=ae.next,ae.next=O),J.pending=O}}g.lanes|=i,O=g.alternate,O!==null&&(O.lanes|=i),Oa(g.return,i,n),T.lanes|=i;break}O=O.next}}else if(g.tag===10)S=g.type===n.type?null:g.child;else if(g.tag===18){if(S=g.return,S===null)throw Error(o(341));S.lanes|=i,T=S.alternate,T!==null&&(T.lanes|=i),Oa(S,i,n),S=g.sibling}else S=g.child;if(S!==null)S.return=g;else for(S=g;S!==null;){if(S===n){S=null;break}if(g=S.sibling,g!==null){g.return=S.return,S=g;break}S=S.return}g=S}Ct(e,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,Oi(n,i),f=Zt(f),l=l(f),n.flags|=1,Ct(e,n,l,i),n.child;case 14:return l=n.type,f=an(l,n.pendingProps),f=an(l.type,f),cf(e,n,l,f,i);case 15:return df(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),Ks(e,n),n.tag=1,Tt(l)?(e=!0,Rs(n)):e=!1,Oi(n,i),tf(n,l,f),tu(n,l,f,i),ou(null,n,l,!0,e,i);case 19:return xf(e,n,i);case 22:return ff(e,n,i)}throw Error(o(156,n.tag))};function Vf(e,n){return Hr(e,n)}function Yy(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tn(e,n,i,l){return new Yy(e,n,i,l)}function ju(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Gy(e){if(typeof e=="function")return ju(e)?1:0;if(e!=null){if(e=e.$$typeof,e===te)return 11;if(e===V)return 14}return 2}function Cr(e,n){var i=e.alternate;return i===null?(i=tn(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function ll(e,n,i,l,f,g){var S=2;if(l=e,typeof e=="function")ju(e)&&(S=1);else if(typeof e=="string")S=5;else e:switch(e){case B:return li(i.children,f,g,n);case G:S=8,f|=8;break;case Q:return e=tn(12,i,n,f|2),e.elementType=Q,e.lanes=g,e;case q:return e=tn(13,i,n,f),e.elementType=q,e.lanes=g,e;case C:return e=tn(19,i,n,f),e.elementType=C,e.lanes=g,e;case U:return al(i,f,g,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ne:S=10;break e;case ee:S=9;break e;case te:S=11;break e;case V:S=14;break e;case W:S=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=tn(S,i,n,f),n.elementType=e,n.type=l,n.lanes=g,n}function li(e,n,i,l){return e=tn(7,e,l,n),e.lanes=i,e}function al(e,n,i,l){return e=tn(22,e,l,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function bu(e,n,i){return e=tn(6,e,null,n),e.lanes=i,e}function Eu(e,n,i){return n=tn(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Xy(e,n,i,l,f){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Yn(0),this.expirationTimes=Yn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Yn(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Cu(e,n,i,l,f,g,S,T,O){return e=new Xy(e,n,i,T,O),n===1?(n=1,g===!0&&(n|=8)):n=0,g=tn(3,null,null,n),e.current=g,g.stateNode=e,g.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ha(g),e}function qy(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),Lu.exports=l0(),Lu.exports}var rh;function a0(){if(rh)return gl;rh=1;var t=jp();return gl.createRoot=t.createRoot,gl.hydrateRoot=t.hydrateRoot,gl}var u0=a0();function bp(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Ae(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(bp(s,o.statusText||"Request failed"))}return o.json()}const c0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Pe={health:()=>Ae("/api/health"),settings:()=>Ae("/api/settings"),saveSettings:t=>{const r={...t};for(const o of c0)r[o]===""&&delete r[o];return Ae("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ae("/api/repos"),browse:t=>Ae(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ae(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ae("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ae(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Ae(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:(t,r=!0)=>Ae(`/api/architecture?repo_path=${encodeURIComponent(t)}&graph=${r?"1":"0"}`),architectureGraph:t=>Ae(`/api/architecture/graph?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Ae("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Ae("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Ae("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Ae("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Ae("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Ae(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open",s)=>Ae("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o,repo_path:s||null})}),scmRepos:t=>Ae(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ae("/api/oauth/status"),githubOAuthStart:()=>Ae("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ae("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ae("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Ae("/api/oauth/gitlab/start"),oauthDisconnect:t=>Ae("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ae("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})}),reviews:t=>Ae(`/api/reviews?repo_path=${encodeURIComponent(t)}`),getReview:(t,r)=>Ae(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(t)}`),reviewDiff:(t,r,o)=>Ae(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(t)}&other=${encodeURIComponent(o)}`),config:t=>Ae(`/api/config?repo_path=${encodeURIComponent(t)}`),saveConfig:(t,r)=>Ae("/api/config",{method:"PUT",body:JSON.stringify({repo_path:t,...r})}),addWaiver:(t,r,o,s)=>Ae("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:t,rule:r,node:o||null,reason:s||""})}),marks:(t,r)=>Ae(`/api/marks?repo_path=${encodeURIComponent(t)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:t=>Ae(`/api/architecture/health?repo_path=${encodeURIComponent(t)}`),workspaceStatus:t=>Ae(`/api/workspace/status?repo_path=${encodeURIComponent(t)}`),openEditor:(t,r,o,s)=>Ae("/api/open",{method:"POST",body:JSON.stringify({repo_path:t,path:r,line:o||null,editor:s||null})}),exportHtml:t=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:t})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(bp(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(t,r,o,s)=>Ae("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:t,edges:r,source_id:o,target_id:s||null})})};function d0(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):t}function f0({open:t,actions:r,onClose:o}){const[s,a]=L.useState(""),[u,c]=L.useState(0),h=L.useRef(null),p=L.useMemo(()=>d0(r,s),[r,s]);if(L.useEffect(()=>{if(!t)return;a(""),c(0);const v=window.setTimeout(()=>{var m;return(m=h.current)==null?void 0:m.focus()},0);return()=>window.clearTimeout(v)},[t]),L.useEffect(()=>{c(0)},[s]),!t)return null;const y=p[u],x=v=>{v&&(o(),v.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:v=>{v.target===v.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:v=>a(v.target.value),onKeyDown:v=>{v.key==="Escape"?(v.preventDefault(),o()):v.key==="ArrowDown"?(v.preventDefault(),c(m=>Math.min(p.length-1,m+1))):v.key==="ArrowUp"?(v.preventDefault(),c(m=>Math.max(0,m-1))):v.key==="Enter"&&(v.preventDefault(),x(y))}}),d.jsxs("ul",{children:[p.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,p.slice(0,40).map((v,m)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:m===u?"active":"",onMouseEnter:()=>c(m),onClick:()=>x(v),children:[d.jsx("span",{children:v.label}),v.hint?d.jsx("span",{className:"muted",children:v.hint}):null]})},v.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function h0({config:t,busy:r,onSave:o,onWaiver:s}){const[a,u]=L.useState(t),[c,h]=L.useState(t.available_rules[0]||""),[p,y]=L.useState(""),[x,v]=L.useState("");L.useEffect(()=>{u(t)},[t]);const m=Object.entries(a.contexts||{}),_=(P,w,j)=>{const $=a.contexts[P];if(!$)return;const z=B=>B.split(",").map(G=>G.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[P]:{...$,[w]:w==="name"?j:z(j)}}})},k=(P,w)=>{const j=w.trim();if(!j||j===P)return;const{[P]:$,...z}=a.contexts;$&&u({...a,contexts:{...z,[j]:{...$,name:j}}})},b=()=>{let P=1;for(;a.contexts[`context-${P}`];)P+=1;const w=`context-${P}`;u({...a,contexts:{...a.contexts,[w]:{name:w,django_apps:[],react:[],public_api:[],owners:[]}}})},E=P=>{const{[P]:w,...j}=a.contexts;u({...a,contexts:j})},N=P=>{const w=a.rules.includes(P);u({...a,rules:w?a.rules.filter(j=>j!==P):[...a.rules,P]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),m.map(([P,w])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:P})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:P,"data-testid":`config-context-name-${P}`,onBlur:j=>k(P,j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(w.django_apps||[]).join(", "),onChange:j=>_(P,"django_apps",j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(w.react||[]).join(", "),onChange:j=>_(P,"react",j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(w.public_api||[]).join(", "),onChange:j=>_(P,"public_api",j.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(w.owners||[]).join(", "),onChange:j=>_(P,"owners",j.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>E(P),children:"Remove context"})]},P)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:b,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(P=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(P),onChange:()=>N(P)}),P]},P))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((P,w)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:P.rule}),P.node?` · ${P.node}`:"",P.reason?` — ${P.reason}`:""]},`${P.rule}:${P.node}:${w}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:P=>h(P.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(P=>d.jsx("option",{value:P,children:P},P))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:P=>y(P.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:x,onChange:P=>v(P.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,x),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function Qo(t){return t.replaceAll("_"," ")}function p0(t){return t.replaceAll("_"," ")}function ro(t){return t.split(".").pop()||t}function Ju(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function g0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Tr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function yi({className:t,children:r}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function m0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function y0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function v0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function x0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function w0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function Ep({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function _0({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const S0="modulepreload",k0=function(t,r){return new URL(t,r).href},ih={},N0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(x){return Promise.all(x.map(v=>Promise.resolve(v).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),y=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(x=>{if(x=k0(x,s),x in ih)return;ih[x]=!0;const v=x.endsWith(".css"),m=v?'[rel="stylesheet"]':"";if(!!s)for(let b=h.length-1;b>=0;b--){const E=h[b];if(E.href===x&&(!v||E.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${x}"]${m}`))return;const k=document.createElement("link");if(k.rel=v?"stylesheet":S0,v||(k.as="script"),k.crossOrigin="",k.href=x,y&&k.setAttribute("nonce",y),document.head.appendChild(k),v)return new Promise((b,E)=>{k.addEventListener("load",b),k.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${x}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function nt(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Wl(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}El.prototype=Wl.prototype={constructor:El,on:function(t,r){var o=this._,s=b0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),sh.hasOwnProperty(r)?{space:sh[r],local:t}:t}function C0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===ec&&r.documentElement.namespaceURI===ec?r.createElement(t):r.createElementNS(o,t)}}function M0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Cp(t){var r=Ul(t);return(r.local?M0:C0)(r)}function P0(){}function pc(t){return t==null?P0:function(){return this.querySelector(t)}}function I0(t){typeof t!="function"&&(t=pc(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=w&&(w=P+1);!($=E[w])&&++w=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function nv(t){t||(t=rv);function r(v,m){return v&&m?t(v.__data__,m.__data__):!v-!m}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function iv(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function ov(){return Array.from(this)}function sv(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?yv:typeof r=="function"?xv:vv)(t,r,o??"")):Ki(this.node(),t)}function Ki(t,r){return t.style.getPropertyValue(r)||Tp(t).getComputedStyle(t,null).getPropertyValue(r)}function _v(t){return function(){delete this[t]}}function Sv(t,r){return function(){this[t]=r}}function kv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function Nv(t,r){return arguments.length>1?this.each((r==null?_v:typeof r=="function"?kv:Sv)(t,r)):this.node()[t]}function Lp(t){return t.trim().split(/^|\s+/)}function gc(t){return t.classList||new Ap(t)}function Ap(t){this._node=t,this._names=Lp(t.getAttribute("class")||"")}Ap.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function $p(t,r){for(var o=gc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function Zv(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function tc(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:y,dispatch:x}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:y,enumerable:!0,configurable:!0},_:{value:x}})}tc.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function ax(t){return!t.ctrlKey&&!t.button}function ux(){return this.parentNode}function cx(t,r){return r??{x:t.x,y:t.y}}function dx(){return navigator.maxTouchPoints||"ontouchstart"in this}function Bp(){var t=ax,r=ux,o=cx,s=dx,a={},u=Wl("start","drag","end"),c=0,h,p,y,x,v=0;function m(j){j.on("mousedown.drag",_).filter(s).on("touchstart.drag",E).on("touchmove.drag",N,lx).on("touchend.drag touchcancel.drag",P).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(j,$){if(!(x||!t.call(this,j,$))){var z=w(this,r.call(this,j,$),j,$,"mouse");z&&(Gt(j.view).on("mousemove.drag",k,Zo).on("mouseup.drag",b,Zo),Fp(j.view),zu(j),y=!1,h=j.clientX,p=j.clientY,z("start",j))}}function k(j){if(Xi(j),!y){var $=j.clientX-h,z=j.clientY-p;y=$*$+z*z>v}a.mouse("drag",j)}function b(j){Gt(j.view).on("mousemove.drag mouseup.drag",null),Hp(j.view,y),Xi(j),a.mouse("end",j)}function E(j,$){if(t.call(this,j,$)){var z=j.changedTouches,B=r.call(this,j,$),G=z.length,Q,ne;for(Q=0;Q>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?yl(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?yl(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=hx.exec(t))?new Dt(r[1],r[2],r[3],1):(r=px.exec(t))?new Dt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=gx.exec(t))?yl(r[1],r[2],r[3],r[4]):(r=mx.exec(t))?yl(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=yx.exec(t))?hh(r[1],r[2]/100,r[3]/100,1):(r=vx.exec(t))?hh(r[1],r[2]/100,r[3]/100,r[4]):lh.hasOwnProperty(t)?ch(lh[t]):t==="transparent"?new Dt(NaN,NaN,NaN,0):null}function ch(t){return new Dt(t>>16&255,t>>8&255,t&255,1)}function yl(t,r,o,s){return s<=0&&(t=r=o=NaN),new Dt(t,r,o,s)}function _x(t){return t instanceof ds||(t=fi(t)),t?(t=t.rgb(),new Dt(t.r,t.g,t.b,t.opacity)):new Dt}function nc(t,r,o,s){return arguments.length===1?_x(t):new Dt(t,r,o,s??1)}function Dt(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}mc(Dt,nc,Vp(ds,{brighter(t){return t=t==null?Tl:Math.pow(Tl,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Jo:Math.pow(Jo,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Dt(ci(this.r),ci(this.g),ci(this.b),Ll(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:dh,formatHex:dh,formatHex8:Sx,formatRgb:fh,toString:fh}));function dh(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}`}function Sx(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}${ui((isNaN(this.opacity)?1:this.opacity)*255)}`}function fh(){const t=Ll(this.opacity);return`${t===1?"rgb(":"rgba("}${ci(this.r)}, ${ci(this.g)}, ${ci(this.b)}${t===1?")":`, ${t})`}`}function Ll(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ci(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ui(t){return t=ci(t),(t<16?"0":"")+t.toString(16)}function hh(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new hn(t,r,o,s)}function Wp(t){if(t instanceof hn)return new hn(t.h,t.s,t.l,t.opacity);if(t instanceof ds||(t=fi(t)),!t)return new hn;if(t instanceof hn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new hn(c,h,p,t.opacity)}function kx(t,r,o,s){return arguments.length===1?Wp(t):new hn(t,r,o,s??1)}function hn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}mc(hn,kx,Vp(ds,{brighter(t){return t=t==null?Tl:Math.pow(Tl,t),new hn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Jo:Math.pow(Jo,t),new hn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Dt(Du(t>=240?t-240:t+120,a,s),Du(t,a,s),Du(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new hn(ph(this.h),vl(this.s),vl(this.l),Ll(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 t=Ll(this.opacity);return`${t===1?"hsl(":"hsla("}${ph(this.h)}, ${vl(this.s)*100}%, ${vl(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ph(t){return t=(t||0)%360,t<0?t+360:t}function vl(t){return Math.max(0,Math.min(1,t||0))}function Du(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const yc=t=>()=>t;function Nx(t,r){return function(o){return t+o*r}}function jx(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function bx(t){return(t=+t)==1?Up:function(r,o){return o-r?jx(r,o,t):yc(isNaN(r)?o:r)}}function Up(t,r){var o=r-t;return o?Nx(t,o):yc(isNaN(t)?r:t)}const Al=(function t(r){var o=bx(r);function s(a,u){var c=o((a=nc(a)).r,(u=nc(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),y=Up(a.opacity,u.opacity);return function(x){return a.r=c(x),a.g=h(x),a.b=p(x),a.opacity=y(x),a+""}}return s.gamma=t,s})(1);function Ex(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:Rn(s,a)})),o=Ou.lastIndex;return o180?x+=360:x-y>180&&(y+=360),m.push({i:v.push(a(v)+"rotate(",null,s)-2,x:Rn(y,x)})):x&&v.push(a(v)+"rotate("+x+s)}function h(y,x,v,m){y!==x?m.push({i:v.push(a(v)+"skewX(",null,s)-2,x:Rn(y,x)}):x&&v.push(a(v)+"skewX("+x+s)}function p(y,x,v,m,_,k){if(y!==v||x!==m){var b=_.push(a(_)+"scale(",null,",",null,")");k.push({i:b-4,x:Rn(y,v)},{i:b-2,x:Rn(x,m)})}else(v!==1||m!==1)&&_.push(a(_)+"scale("+v+","+m+")")}return function(y,x){var v=[],m=[];return y=t(y),x=t(x),u(y.translateX,y.translateY,x.translateX,x.translateY,v,m),c(y.rotate,x.rotate,v,m),h(y.skewX,x.skewX,v,m),p(y.scaleX,y.scaleY,x.scaleX,x.scaleY,v,m),y=x=null,function(_){for(var k=-1,b=m.length,E;++k=0&&t._call.call(void 0,r),t=t._next;--Qi}function yh(){hi=(zl=ts.now())+Yl,Qi=Go=0;try{Bx()}finally{Qi=0,Wx(),hi=0}}function Vx(){var t=ts.now(),r=t-zl;r>qp&&(Yl-=r,zl=t)}function Wx(){for(var t,r=$l,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:$l=o);Xo=t,oc(s)}function oc(t){if(!Qi){Go&&(Go=clearTimeout(Go));var r=t-hi;r>24?(t<1/0&&(Go=setTimeout(yh,t-ts.now()-Yl)),Uo&&(Uo=clearInterval(Uo))):(Uo||(zl=ts.now(),Uo=setInterval(Vx,qp)),Qi=1,Kp(yh))}}function vh(t,r,o){var s=new Dl;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Ux=Wl("start","end","cancel","interrupt"),Yx=[],Zp=0,xh=1,sc=2,Ml=3,wh=4,lc=5,Pl=6;function Gl(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;Gx(t,o,{name:r,index:s,group:a,on:Ux,tween:Yx,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Zp})}function xc(t,r){var o=yn(t,r);if(o.state>Zp)throw new Error("too late; already scheduled");return o}function Ln(t,r){var o=yn(t,r);if(o.state>Ml)throw new Error("too late; already running");return o}function yn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Gx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=Qp(u,0,o.time);function u(y){o.state=xh,o.timer.restart(c,o.delay,o.time),o.delay<=y&&c(y-o.delay)}function c(y){var x,v,m,_;if(o.state!==xh)return p();for(x in s)if(_=s[x],_.name===o.name){if(_.state===Ml)return vh(c);_.state===wh?(_.state=Pl,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete s[x]):+xsc&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function kw(t,r,o){var s,a,u=Sw(r)?xc:Ln;return function(){var c=u(this,t),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function Nw(t,r){var o=this._id;return arguments.length<2?yn(this.node(),o).on.on(t):this.each(kw(o,t,r))}function jw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function bw(){return this.on("end.remove",jw(this._id))}function Ew(t){var r=this._name,o=this._id;typeof t!="function"&&(t=pc(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function Zw(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function rr(t,r,o){this.k=t,this.x=r,this.y=o}rr.prototype={constructor:rr,scale:function(t){return t===1?this:new rr(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new rr(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Xl=new rr(1,0,0);ng.prototype=rr.prototype;function ng(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Xl;return t.__zoom}function Fu(t){t.stopImmediatePropagation()}function Yo(t){t.preventDefault(),t.stopImmediatePropagation()}function Jw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function e1(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function _h(){return this.__zoom||Xl}function t1(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function n1(){return navigator.maxTouchPoints||"ontouchstart"in this}function r1(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function rg(){var t=Jw,r=e1,o=r1,s=t1,a=n1,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=Cl,y=Wl("start","zoom","end"),x,v,m,_=500,k=150,b=0,E=10;function N(C){C.property("__zoom",_h).on("wheel.zoom",G,{passive:!1}).on("mousedown.zoom",Q).on("dblclick.zoom",ne).filter(a).on("touchstart.zoom",ee).on("touchmove.zoom",te).on("touchend.zoom touchcancel.zoom",q).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}N.transform=function(C,V,W,U){var M=C.selection?C.selection():C;M.property("__zoom",_h),C!==M?$(C,V,W,U):M.interrupt().each(function(){z(this,arguments).event(U).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},N.scaleBy=function(C,V,W,U){N.scaleTo(C,function(){var M=this.__zoom.k,D=typeof V=="function"?V.apply(this,arguments):V;return M*D},W,U)},N.scaleTo=function(C,V,W,U){N.transform(C,function(){var M=r.apply(this,arguments),D=this.__zoom,F=W==null?j(M):typeof W=="function"?W.apply(this,arguments):W,R=D.invert(F),A=typeof V=="function"?V.apply(this,arguments):V;return o(w(P(D,A),F,R),M,c)},W,U)},N.translateBy=function(C,V,W,U){N.transform(C,function(){return o(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),r.apply(this,arguments),c)},null,U)},N.translateTo=function(C,V,W,U,M){N.transform(C,function(){var D=r.apply(this,arguments),F=this.__zoom,R=U==null?j(D):typeof U=="function"?U.apply(this,arguments):U;return o(Xl.translate(R[0],R[1]).scale(F.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),D,c)},U,M)};function P(C,V){return V=Math.max(u[0],Math.min(u[1],V)),V===C.k?C:new rr(V,C.x,C.y)}function w(C,V,W){var U=V[0]-W[0]*C.k,M=V[1]-W[1]*C.k;return U===C.x&&M===C.y?C:new rr(C.k,U,M)}function j(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function $(C,V,W,U){C.on("start.zoom",function(){z(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){z(this,arguments).event(U).end()}).tween("zoom",function(){var M=this,D=arguments,F=z(M,D).event(U),R=r.apply(M,D),A=W==null?j(R):typeof W=="function"?W.apply(M,D):W,ie=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),oe=M.__zoom,fe=typeof V=="function"?V.apply(M,D):V,he=p(oe.invert(A).concat(ie/oe.k),fe.invert(A).concat(ie/fe.k));return function(pe){if(pe===1)pe=fe;else{var Z=he(pe),se=ie/Z[2];pe=new rr(se,A[0]-Z[0]*se,A[1]-Z[1]*se)}F.zoom(null,pe)}})}function z(C,V,W){return!W&&C.__zooming||new B(C,V)}function B(C,V){this.that=C,this.args=V,this.active=0,this.sourceEvent=null,this.extent=r.apply(C,V),this.taps=0}B.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,V){return this.mouse&&C!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var V=Gt(this.that).datum();y.call(C,this.that,new Zw(C,{sourceEvent:this.sourceEvent,target:N,transform:this.that.__zoom,dispatch:y}),V)}};function G(C,...V){if(!t.apply(this,arguments))return;var W=z(this,V).event(C),U=this.__zoom,M=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,s.apply(this,arguments)))),D=fn(C);if(W.wheel)(W.mouse[0][0]!==D[0]||W.mouse[0][1]!==D[1])&&(W.mouse[1]=U.invert(W.mouse[0]=D)),clearTimeout(W.wheel);else{if(U.k===M)return;W.mouse=[D,U.invert(D)],Il(this),W.start()}Yo(C),W.wheel=setTimeout(F,k),W.zoom("mouse",o(w(P(U,M),W.mouse[0],W.mouse[1]),W.extent,c));function F(){W.wheel=null,W.end()}}function Q(C,...V){if(m||!t.apply(this,arguments))return;var W=C.currentTarget,U=z(this,V,!0).event(C),M=Gt(C.view).on("mousemove.zoom",A,!0).on("mouseup.zoom",ie,!0),D=fn(C,W),F=C.clientX,R=C.clientY;Fp(C.view),Fu(C),U.mouse=[D,this.__zoom.invert(D)],Il(this),U.start();function A(oe){if(Yo(oe),!U.moved){var fe=oe.clientX-F,he=oe.clientY-R;U.moved=fe*fe+he*he>b}U.event(oe).zoom("mouse",o(w(U.that.__zoom,U.mouse[0]=fn(oe,W),U.mouse[1]),U.extent,c))}function ie(oe){M.on("mousemove.zoom mouseup.zoom",null),Hp(oe.view,U.moved),Yo(oe),U.event(oe).end()}}function ne(C,...V){if(t.apply(this,arguments)){var W=this.__zoom,U=fn(C.changedTouches?C.changedTouches[0]:C,this),M=W.invert(U),D=W.k*(C.shiftKey?.5:2),F=o(w(P(W,D),U,M),r.apply(this,V),c);Yo(C),h>0?Gt(this).transition().duration(h).call($,F,U,C):Gt(this).call(N.transform,F,U,C)}}function ee(C,...V){if(t.apply(this,arguments)){var W=C.touches,U=W.length,M=z(this,V,C.changedTouches.length===U).event(C),D,F,R,A;for(Fu(C),F=0;F`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},ns=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ig=["Enter"," ","Escape"],og={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Zi;(function(t){t.Strict="strict",t.Loose="loose"})(Zi||(Zi={}));var di;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(di||(di={}));var rs;(function(t){t.Partial="partial",t.Full="full"})(rs||(rs={}));const sg={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Lr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Lr||(Lr={}));var is;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(is||(is={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const Sh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function lg(t){return t===null?null:t?"valid":"invalid"}const ag=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,i1=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),_c=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),fs=(t,r=[0,0])=>{const{width:o,height:s}=vn(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},o1=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):_c(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,ql(a,Ol(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?Kl(s):{x:0,y:0,width:0,height:0}},hs=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=ql(o,Ol(a)),s=!0)}),s?Kl(o):{x:0,y:0,width:0,height:0}},Sc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,y=r.width/a,x=r.height/a,v=[];for(const m of t.values()){const{measured:_,selectable:k=!0,hidden:b=!1}=m;if(c&&!k||b)continue;const E=_.width??m.width??m.initialWidth??0,N=_.height??m.height??m.initialHeight??0,{x:P,y:w}=m.internals.positionAbsolute,j=fg(h,p,y,x,P,w,E,N),$=E*N,z=u&&j>0;(!m.internals.handleBounds||z||j>=$||m.dragging)&&v.push(m)}return v},s1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function l1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=vn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function a1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const h=l1(t,c),p=hs(h),y=Nc(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(y,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function ug({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),h=c.parentId?o.get(c.parentId):void 0,{x:p,y}=h?h.internals.positionAbsolute:{x:0,y:0},x=c.origin??s;let v=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",mn.error005());else{const{width:_,height:k}=vn(h);_&&k&&(v=[[p,y],[p+_,y+k]])}else h&&gi(c.extent)&&(v=[[c.extent[0][0]+p,c.extent[0][1]+y],[c.extent[1][0]+p,c.extent[1][1]+y]]);const m=gi(v)?pi(r,v,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",mn.error015())),{position:{x:m.x-p+(c.measured.width??0)*x[0],y:m.y-y+(c.measured.height??0)*x[1]},positionAbsolute:m}}async function u1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(m=>m.id)),c=[];for(const m of o){if(m.deletable===!1)continue;const _=u.has(m.id),k=!_&&m.parentId&&c.find(b=>b.id===m.parentId);(_||k)&&c.push(m)}const h=new Set(r.map(m=>m.id)),p=s.filter(m=>m.deletable!==!1),x=s1(c,p);for(const m of p)h.has(m.id)&&!x.find(k=>k.id===m.id)&&x.push(m);if(!a)return{edges:x,nodes:c};const v=await a({nodes:c,edges:x});return typeof v=="boolean"?v?{edges:x,nodes:c}:{edges:[],nodes:[]}:v}const Ji=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),pi=(t={x:0,y:0},r,o)=>({x:Ji(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:Ji(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function cg(t,r,o){const{width:s,height:a}=vn(o),{x:u,y:c}=o.internals.positionAbsolute;return pi(t,[[u,c],[u+s,c+a]],r)}const kh=(t,r,o)=>to?-Ji(Math.abs(t-o),1,r)/r:0,kc=(t,r,o=15,s=40)=>{const a=kh(t.x,s,r.width-s)*o,u=kh(t.y,s,r.height-s)*o;return[a,u]},ql=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),ac=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),Kl=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),os=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:fs(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},Ol=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:fs(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},dg=(t,r)=>Kl(ql(ac(t),ac(r))),fg=(t,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),y=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*y)},Fl=(t,r)=>fg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),Nh=t=>pn(t.width)&&pn(t.height)&&pn(t.x)&&pn(t.y),pn=t=>!isNaN(t)&&isFinite(t),hg=(t,r)=>(o,s)=>{},ps=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),gs=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(t-o)/a,y:(r-s)/a};return u?ps(h,c):h},eo=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Yi(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function c1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Yi(t,o),a=Yi(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Yi(t.top??t.y??0,o),a=Yi(t.bottom??t.y??0,o),u=Yi(t.left??t.x??0,r),c=Yi(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function d1(t,r,o,s,a,u){const{x:c,y:h}=eo(t,[r,o,s]),{x:p,y}=eo({x:t.x+t.width,y:t.y+t.height},[r,o,s]),x=a-p,v=u-y;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(x),bottom:Math.floor(v)}}const Nc=(t,r,o,s,a,u)=>{const c=c1(u,r,o),h=(r-c.x)/t.width,p=(o-c.y)/t.height,y=Math.min(h,p),x=Ji(y,s,a),v=t.x+t.width/2,m=t.y+t.height/2,_=r/2-v*x,k=o/2-m*x,b=d1(t,_,k,x,r,o),E={left:Math.min(b.left-c.left,0),top:Math.min(b.top-c.top,0),right:Math.min(b.right-c.right,0),bottom:Math.min(b.bottom-c.bottom,0)};return{x:_-E.left+E.right,y:k-E.top+E.bottom,zoom:x}},ss=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function gi(t){return t!=null&&t!=="parent"}function vn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function pg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function gg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function jh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function f1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function h1(t){return{...og,...t||{}}}function Ko(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=gn(t),h=gs({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y}=o?ps(h,r):h;return{xSnapped:p,ySnapped:y,...h}}const jc=t=>({width:t.offsetWidth,height:t.offsetHeight}),mg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},p1=["INPUT","SELECT","TEXTAREA"];function yg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:p1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const vg=t=>"clientX"in t,gn=(t,r)=>{var u,c;const o=vg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},bh=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...jc(c)}})};function xg({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=t*.125+a*.375+c*.375+o*.125,y=r*.125+u*.375+h*.375+s*.125,x=Math.abs(p-t),v=Math.abs(y-r);return[p,y,x,v]}function _l(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function Eh({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case Se.Left:return[r-_l(r-s,u),o];case Se.Right:return[r+_l(s-r,u),o];case Se.Top:return[r,o-_l(o-a,u)];case Se.Bottom:return[r,o+_l(a-o,u)]}}function wg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top,curvature:c=.25}){const[h,p]=Eh({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[y,x]=Eh({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[v,m,_,k]=xg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:y,targetControlY:x});return[`M${t},${r} C${h},${p} ${y},${x} ${s},${a}`,v,m,_,k]}function _g({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const y1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,v1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),x1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",mn.error006()),r;const s=o.getEdgeId||y1;let a;return ag(t)?a={...t}:a={...t,id:s(t)},v1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function Sg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=_g({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,h]}const Ch={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},w1=({source:t,sourcePosition:r=Se.Bottom,target:o})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function _1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:s=Se.Top,center:a,offset:u,stepPosition:c}){const h=Ch[r],p=Ch[s],y={x:t.x+h.x*u,y:t.y+h.y*u},x={x:o.x+p.x*u,y:o.y+p.y*u},v=w1({source:y,sourcePosition:r,target:x}),m=v.x!==0?"x":"y",_=v[m];let k=[],b,E;const N={x:0,y:0},P={x:0,y:0},[,,w,j]=_g({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[m]*p[m]===-1){m==="x"?(b=a.x??y.x+(x.x-y.x)*c,E=a.y??(y.y+x.y)/2):(b=a.x??(y.x+x.x)/2,E=a.y??y.y+(x.y-y.y)*c);const G=[{x:b,y:y.y},{x:b,y:x.y}],Q=[{x:y.x,y:E},{x:x.x,y:E}];h[m]===_?k=m==="x"?G:Q:k=m==="x"?Q:G}else{const G=[{x:y.x,y:x.y}],Q=[{x:x.x,y:y.y}];if(m==="x"?k=h.x===_?Q:G:k=h.y===_?G:Q,r===s){const C=Math.abs(t[m]-o[m]);if(C<=u){const V=Math.min(u-1,u-C);h[m]===_?N[m]=(y[m]>t[m]?-1:1)*V:P[m]=(x[m]>o[m]?-1:1)*V}}if(r!==s){const C=m==="x"?"y":"x",V=h[m]===p[C],W=y[C]>x[C],U=y[C]=q?(b=(ne.x+ee.x)/2,E=k[0].y):(b=k[0].x,E=(ne.y+ee.y)/2)}const $={x:y.x+N.x,y:y.y+N.y},z={x:x.x+P.x,y:x.y+P.y};return[[t,...$.x!==k[0].x||$.y!==k[0].y?[$]:[],...k,...z.x!==k[k.length-1].x||z.y!==k[k.length-1].y?[z]:[],o],b,E,w,j]}function S1(t,r,o,s){const a=Math.min(Mh(t,r)/2,Mh(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const y=t.xo.id===r):t[0])||null}function cc(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function N1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const y=cc(p,r);u.has(y)||(c.push({id:y,color:p.color||o,...p}),u.add(y))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const kg=1e3,j1=10,bc={nodeOrigin:[0,0],nodeExtent:ns,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},b1={...bc,checkEquality:!0};function Ec(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function E1(t,r,o){const s=Ec(bc,o);for(const a of t.values())if(a.parentId)Mc(a,t,r,s);else{const u=fs(a,s.nodeOrigin),c=gi(a.extent)?a.extent:s.nodeExtent,h=pi(u,c,vn(a));a.internals.positionAbsolute=h}}function C1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function Cc(t){return t==="manual"}function dc(t,r,o,s={}){var x,v;const a=Ec(b1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!Cc(a.zIndexMode)?kg:0;let p=t.length>0,y=!1;r.clear(),o.clear();for(const m of t){let _=c.get(m.id);if(a.checkEquality&&m===(_==null?void 0:_.internals.userNode))r.set(m.id,_);else{const k=fs(m,a.nodeOrigin),b=gi(m.extent)?m.extent:a.nodeExtent,E=pi(k,b,vn(m));_={...a.defaults,...m,measured:{width:(x=m.measured)==null?void 0:x.width,height:(v=m.measured)==null?void 0:v.height},internals:{positionAbsolute:E,handleBounds:C1(m,_),z:Ng(m,h,a.zIndexMode),userNode:m}},r.set(m.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),m.parentId&&Mc(_,r,o,s,u),y||(y=m.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:y}}function M1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function Mc(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=Ec(bc,s),y=t.parentId,x=r.get(y);if(!x){console.warn(`Parent node ${y} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}M1(t,o),a&&!x.parentId&&x.internals.rootParentIndex===void 0&&p==="auto"&&(x.internals.rootParentIndex=++a.i,x.internals.z=x.internals.z+a.i*j1),a&&x.internals.rootParentIndex!==void 0&&(a.i=x.internals.rootParentIndex);const v=u&&!Cc(p)?kg:0,{x:m,y:_,z:k}=P1(t,x,c,h,v,p),{positionAbsolute:b}=t.internals,E=m!==b.x||_!==b.y;(E||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:E?{x:m,y:_}:b,z:k}})}function Ng(t,r,o){const s=pn(t.zIndex)?t.zIndex:0;return Cc(o)?s:s+(t.selected?r:0)}function P1(t,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=vn(t),y=fs(t,o),x=gi(t.extent)?pi(y,t.extent,p):y;let v=pi({x:c+x.x,y:h+x.y},s,p);t.extent==="parent"&&(v=cg(v,p,r));const m=Ng(t,a,u),_=r.internals.z??0;return{x:v.x,y:v.y,z:_>=m?_+1:m}}function Pc(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const y=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??os(p),x=dg(y,h.rect);u.set(h.parentId,{expandedRect:x,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},y)=>{var w;const x=p.internals.positionAbsolute,v=vn(p),m=p.origin??s,_=h.x0||k>0||N||P)&&(a.push({id:y,type:"position",position:{x:p.position.x-_+N,y:p.position.y-k+P}}),(w=o.get(y))==null||w.forEach(j=>{t.some($=>$.id===j.id)||a.push({id:j.id,type:"position",position:{x:j.position.x+_,y:j.position.y+k}})})),(v.width0){const _=Pc(m,r,o,a);y.push(..._)}return{changes:y,updatedInternals:p}}async function R1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Th(t,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${t}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${t}-${u}`;const y=s.get(c)||new Map;s.set(c,y.set(o,r))}}function jg(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},y=`${a}-${c}--${u}-${h}`,x=`${u}-${h}--${a}-${c}`;Th("source",p,x,t,a,c),Th("target",p,y,t,u,h),r.set(s.id,s)}}function bg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:bg(o,r):!1}function Lh(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function T1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!bg(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function Hu({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[y,x]of r){const v=(c=o.get(y))==null?void 0:c.internals.userNode;v&&a.push({...v,position:x.position,dragging:s})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function L1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=ps(u,r);return{x:c.x-u.x,y:c.y-u.y}}function A1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,y={x:0,y:0},x=null,v=!1,m=null,_=!1,k=!1,b=null;function E({noDragClassName:P,handleSelector:w,domNode:j,isSelectable:$,nodeId:z,nodeClickDistance:B=0}){m=Gt(j);function G({x:te,y:q}){const{nodeLookup:C,nodeExtent:V,snapGrid:W,snapToGrid:U,nodeOrigin:M,onNodeDrag:D,onSelectionDrag:F,onError:R,updateNodePositions:A}=r();u={x:te,y:q};let ie=!1;const oe=h.size>1,fe=oe&&V?ac(hs(h)):null,he=oe&&U?L1({dragItems:h,snapGrid:W,x:te,y:q}):null;for(const[pe,Z]of h){if(!C.has(pe))continue;let se={x:te-Z.distance.x,y:q-Z.distance.y};U&&(se=he?{x:Math.round(se.x+he.x),y:Math.round(se.y+he.y)}:ps(se,W));let me=null;if(oe&&V&&!Z.extent&&fe){const{positionAbsolute:re}=Z.internals,Ne=re.x-fe.x+V[0][0],Me=re.x+Z.measured.width-fe.x2+V[1][0],Te=re.y-fe.y+V[0][1],$e=re.y+Z.measured.height-fe.y2+V[1][1];me=[[Ne,Te],[Me,$e]]}const{position:ke,positionAbsolute:ve}=ug({nodeId:pe,nextPosition:se,nodeLookup:C,nodeExtent:me||V,nodeOrigin:M,onError:R});ie=ie||Z.position.x!==ke.x||Z.position.y!==ke.y,Z.position=ke,Z.internals.positionAbsolute=ve}if(k=k||ie,!!ie&&(A(h,!0),b&&(s||D||!z&&F))){const[pe,Z]=Hu({nodeId:z,dragItems:h,nodeLookup:C});s==null||s(b,h,pe,Z),D==null||D(b,pe,Z),z||F==null||F(b,Z)}}async function Q(){if(!x)return;const{transform:te,panBy:q,autoPanSpeed:C,autoPanOnNodeDrag:V}=r();if(!V){p=!1,cancelAnimationFrame(c);return}const[W,U]=kc(y,x,C);(W!==0||U!==0)&&(u.x=(u.x??0)-W/te[2],u.y=(u.y??0)-U/te[2],await q({x:W,y:U})&&G(u)),c=requestAnimationFrame(Q)}function ne(te){var oe;const{nodeLookup:q,multiSelectionActive:C,nodesDraggable:V,transform:W,snapGrid:U,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:F,onSelectionDragStart:R,unselectNodesAndEdges:A}=r();v=!0,(!D||!$)&&!C&&z&&((oe=q.get(z))!=null&&oe.selected||A()),$&&D&&z&&(t==null||t(z));const ie=Ko(te.sourceEvent,{transform:W,snapGrid:U,snapToGrid:M,containerBounds:x});if(u=ie,h=T1(q,V,ie,z),h.size>0&&(o||F||!z&&R)){const[fe,he]=Hu({nodeId:z,dragItems:h,nodeLookup:q});o==null||o(te.sourceEvent,h,fe,he),F==null||F(te.sourceEvent,fe,he),z||R==null||R(te.sourceEvent,he)}}const ee=Bp().clickDistance(B).on("start",te=>{const{domNode:q,nodeDragThreshold:C,transform:V,snapGrid:W,snapToGrid:U}=r();x=(q==null?void 0:q.getBoundingClientRect())||null,_=!1,k=!1,b=te.sourceEvent,C===0&&ne(te),u=Ko(te.sourceEvent,{transform:V,snapGrid:W,snapToGrid:U,containerBounds:x}),y=gn(te.sourceEvent,x)}).on("drag",te=>{const{autoPanOnNodeDrag:q,transform:C,snapGrid:V,snapToGrid:W,nodeDragThreshold:U,nodeLookup:M}=r(),D=Ko(te.sourceEvent,{transform:C,snapGrid:V,snapToGrid:W,containerBounds:x});if(b=te.sourceEvent,(te.sourceEvent.type==="touchmove"&&te.sourceEvent.touches.length>1||z&&!M.has(z))&&(_=!0),!_){if(!p&&q&&v&&(p=!0,Q()),!v){const F=gn(te.sourceEvent,x),R=F.x-y.x,A=F.y-y.y;Math.sqrt(R*R+A*A)>U&&ne(te)}(u.x!==D.xSnapped||u.y!==D.ySnapped)&&h&&v&&(y=gn(te.sourceEvent,x),G(D))}}).on("end",te=>{if(!v||_){_&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,v=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:q,updateNodePositions:C,onNodeDragStop:V,onSelectionDragStop:W}=r();if(k&&(C(h,!1),k=!1),a||V||!z&&W){const[U,M]=Hu({nodeId:z,dragItems:h,nodeLookup:q,dragging:!1});a==null||a(te.sourceEvent,h,U,M),V==null||V(te.sourceEvent,U,M),z||W==null||W(te.sourceEvent,M)}}}).filter(te=>{const q=te.target;return!te.button&&(!P||!Lh(q,`.${P}`,j))&&(!w||Lh(q,w,j))});m.call(ee)}function N(){m==null||m.on(".drag",null)}return{update:E,destroy:N}}function $1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())Fl(a,os(u))>0&&s.push(u);return s}const z1=250;function D1(t,r,o,s){var h,p;let a=[],u=1/0;const c=$1(t,o,r+z1);for(const y of c){const x=[...((h=y.internals.handleBounds)==null?void 0:h.source)??[],...((p=y.internals.handleBounds)==null?void 0:p.target)??[]];for(const v of x){if(s.nodeId===v.nodeId&&s.type===v.type&&s.id===v.id)continue;const{x:m,y:_}=mi(y,v,v.position,!0),k=Math.sqrt(Math.pow(m-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const y=s.type==="source"?"target":"source";return a.find(x=>x.type===y)??a[0]}return a[0]}function Eg(t,r,o,s,a,u=!1){var y,x,v;const c=s.get(t);if(!c)return null;const h=a==="strict"?(y=c.internals.handleBounds)==null?void 0:y[r]:[...((x=c.internals.handleBounds)==null?void 0:x.source)??[],...((v=c.internals.handleBounds)==null?void 0:v.target)??[]],p=(o?h==null?void 0:h.find(m=>m.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...mi(c,p,p.position,!0)}:p}function Cg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function O1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const Mg=()=>!0;function F1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:y,autoPanOnConnect:x,flowId:v,panBy:m,cancelConnection:_,onConnectStart:k,onConnect:b,onConnectEnd:E,isValidConnection:N=Mg,onReconnectEnd:P,updateConnection:w,getTransform:j,getFromHandle:$,autoPanSpeed:z,dragThreshold:B=1,handleDomNode:G}){const Q=mg(t.target);let ne=0,ee;const{x:te,y:q}=gn(t),C=Cg(u,G),V=h==null?void 0:h.getBoundingClientRect();let W=!1;if(!V||!C)return;const U=Eg(a,C,s,p,r);if(!U)return;let M=gn(t,V),D=!1,F=null,R=!1,A=null;function ie(){if(!x||!V)return;const[ke,ve]=kc(M,V,z);m({x:ke,y:ve}),ne=requestAnimationFrame(ie)}const oe={...U,nodeId:a,type:C,position:U.position},fe=p.get(a);let pe={inProgress:!0,isValid:null,from:mi(fe,oe,Se.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:fe,to:M,toHandle:null,toPosition:Sh[oe.position],toNode:null,pointer:M};function Z(){W=!0,w(pe),k==null||k(t,{nodeId:a,handleId:s,handleType:C})}B===0&&Z();function se(ke){if(!W){const{x:$e,y:st}=gn(ke),lt=$e-te,at=st-q;if(!(lt*lt+at*at>B*B))return;Z()}if(!$()||!oe){me(ke);return}const ve=j();M=gn(ke,V),ee=D1(gs(M,ve,!1,[1,1]),o,p,oe),D||(ie(),D=!0);const re=Pg(ke,{handle:ee,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:N,doc:Q,lib:y,flowId:v,nodeLookup:p});A=re.handleDomNode,F=re.connection,R=O1(!!ee,re.isValid);const Ne=p.get(a),Me=Ne?mi(Ne,oe,Se.Left,!0):pe.from,Te={...pe,from:Me,isValid:R,to:re.toHandle&&R?eo({x:re.toHandle.x,y:re.toHandle.y},ve):M,toHandle:re.toHandle,toPosition:R&&re.toHandle?re.toHandle.position:Sh[oe.position],toNode:re.toHandle?p.get(re.toHandle.nodeId):null,pointer:M};w(Te),pe=Te}function me(ke){if(!("touches"in ke&&ke.touches.length>0)){if(W){(ee||A)&&F&&R&&(b==null||b(F));const{inProgress:ve,...re}=pe,Ne={...re,toPosition:pe.toHandle?pe.toPosition:null};E==null||E(ke,Ne),u&&(P==null||P(ke,Ne))}_(),cancelAnimationFrame(ne),D=!1,R=!1,F=null,A=null,Q.removeEventListener("mousemove",se),Q.removeEventListener("mouseup",me),Q.removeEventListener("touchmove",se),Q.removeEventListener("touchend",me)}}Q.addEventListener("mousemove",se),Q.addEventListener("mouseup",me),Q.addEventListener("touchmove",se),Q.addEventListener("touchend",me)}function Pg(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:y=Mg,nodeLookup:x}){const v=u==="target",m=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=gn(t),b=c.elementFromPoint(_,k),E=b!=null&&b.classList.contains(`${h}-flow__handle`)?b:m,N={handleDomNode:E,isValid:!1,connection:null,toHandle:null};if(E){const P=Cg(void 0,E),w=E.getAttribute("data-nodeid"),j=E.getAttribute("data-handleid"),$=E.classList.contains("connectable"),z=E.classList.contains("connectableend");if(!w||!P)return N;const B={source:v?w:s,sourceHandle:v?j:a,target:v?s:w,targetHandle:v?a:j};N.connection=B;const Q=$&&z&&(o===Zi.Strict?v&&P==="source"||!v&&P==="target":w!==s||j!==a);N.isValid=Q&&y(B),N.toHandle=Eg(w,P,j,x,o,!0)}return N}const fc={onPointerDown:F1,isValid:Pg};function H1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Gt(t);function u({translateExtent:h,width:p,height:y,zoomStep:x=1,pannable:v=!0,zoomable:m=!0,inversePan:_=!1}){const k=w=>{if(w.sourceEvent.type!=="wheel"||!r)return;const j=o(),$=w.sourceEvent.ctrlKey&&ss()?10:1,z=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*x,B=j[2]*Math.pow(2,z*$);r.scaleTo(B)};let b=[0,0];const E=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(b=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},N=w=>{const j=o();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!r)return;const $=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],z=[$[0]-b[0],$[1]-b[1]];b=$;const B=s()*Math.max(j[2],Math.log(j[2]))*(_?-1:1),G={x:j[0]-z[0]*B,y:j[1]-z[1]*B},Q=[[0,0],[p,y]];r.setViewportConstrained({x:G.x,y:G.y,zoom:j[2]},Q,h)},P=rg().on("start",E).on("zoom",v?N:null).on("zoom.wheel",m?k:null);a.call(P,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:fn}}const Ql=t=>({x:t.x,y:t.y,zoom:t.k}),Bu=({x:t,y:r,zoom:o})=>Xl.translate(t,r).scale(o),Rr=(t,r)=>t.target.closest(`.${r}`),Ig=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),B1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Vu=(t,r=0,o=B1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Rg=t=>{const r=t.ctrlKey&&ss()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function V1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:y}){return x=>{if(Rr(x,r))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const v=o.property("__zoom").k||1;if(x.ctrlKey&&c){const E=fn(x),N=Rg(x),P=v*Math.pow(2,N);s.scaleTo(o,P,E,x);return}const m=x.deltaMode===1?20:1;let _=a===di.Vertical?0:x.deltaX*m,k=a===di.Horizontal?0:x.deltaY*m;!ss()&&x.shiftKey&&a!==di.Vertical&&(_=x.deltaY*m,k=0),s.translateBy(o,-(_/v)*u,-(k/v)*u,{internal:!0});const b=Ql(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(x,b):(t.isPanScrolling=!0,h==null||h(x,b)),t.panScrollTimeout=setTimeout(()=>{y==null||y(x,b),t.isPanScrolling=!1},150)}}function W1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=Rr(s,t);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function U1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=Ql(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function Y1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;t.usedRightMouseButton=!!(o&&Ig(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,Ql(u.transform)))}}function G1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&Ig(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const p=Ql(c.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function X1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:y,lib:x,connectionInProgress:v}){return m=>{var N;const _=r||o,k=s&&m.ctrlKey,b=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(Rr(m,`${x}-flow__node`)||Rr(m,`${x}-flow__edge`)||Rr(m,`${x}-flow__selection`)||Rr(m,`${x}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!c&&!s||h||v&&!b||Rr(m,p)&&b||Rr(m,y)&&(!b||u&&b&&!r)||!s&&m.ctrlKey&&b)return!1;if(!s&&m.type==="touchstart"&&((N=m.touches)==null?void 0:N.length)>1)return m.preventDefault(),!1;if(!_&&!u&&!k&&b||!a&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(a)&&!a.includes(m.button)&&m.type==="mousedown")return!1;const E=Array.isArray(a)&&a.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||b||t)&&E}}function q1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const y={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=t.getBoundingClientRect();let v=[[0,0],[x.width,x.height]];const m=typeof ResizeObserver<"u"?new ResizeObserver(q=>{const C=q[0];C&&(v=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;m==null||m.observe(t);const _=rg().extent(()=>v).scaleExtent([r,o]).translateExtent(s),k=Gt(t).call(_);j({x:a.x,y:a.y,zoom:Ji(a.zoom,r,o)},[[0,0],[x.width,x.height]],s);const b=k.on("wheel.zoom"),E=k.on("dblclick.zoom");_.wheelDelta(Rg);async function N(q,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?qo:Cl).transform(Vu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),q)}):!1}function P({noWheelClassName:q,noPanClassName:C,onPaneContextMenu:V,userSelectionActive:W,panOnScroll:U,panOnDrag:M,panOnScrollMode:D,panOnScrollSpeed:F,preventScrolling:R,zoomOnPinch:A,zoomOnScroll:ie,zoomOnDoubleClick:oe,panActivationKeyPressed:fe=!1,zoomActivationKeyPressed:he,lib:pe,onTransformChange:Z,connectionInProgress:se,paneClickDistance:me,selectionOnDrag:ke}){W&&!y.isZoomingOrPanning&&w();const ve=U&&!he&&!W;_.clickDistance(ke?1/0:!pn(me)||me<0?0:me);const re=ve?V1({zoomPanValues:y,noWheelClassName:q,d3Selection:k,d3Zoom:_,panOnScrollMode:D,panOnScrollSpeed:F,zoomOnPinch:A,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):W1({noWheelClassName:q,preventScrolling:R,d3ZoomHandler:b});k.on("wheel.zoom",re,{passive:!1});const Ne=U1({zoomPanValues:y,onDraggingChange:p,onPanZoomStart:c});_.on("start",Ne);const Me=Y1({zoomPanValues:y,panOnDrag:M,onPaneContextMenu:!!V,onPanZoom:u,onTransformChange:Z});_.on("zoom",Me);const Te=G1({zoomPanValues:y,panOnDrag:M,panOnScroll:U,onPaneContextMenu:V,onPanZoomEnd:h,onDraggingChange:p});_.on("end",Te);const $e=X1({panActivationKeyPressed:fe,zoomActivationKeyPressed:he,panOnDrag:M,zoomOnScroll:ie,panOnScroll:U,zoomOnDoubleClick:oe,zoomOnPinch:A,userSelectionActive:W,noPanClassName:C,noWheelClassName:q,lib:pe,connectionInProgress:se});_.filter($e),oe?k.on("dblclick.zoom",E):k.on("dblclick.zoom",null)}function w(){_.on("zoom",null)}async function j(q,C,V){const W=Bu(q),U=_==null?void 0:_.constrain()(W,C,V);return U&&await N(U),U}async function $(q,C){const V=Bu(q);return await N(V,C),V}function z(q){if(k){const C=Bu(q),V=k.property("__zoom");(V.k!==q.zoom||V.x!==q.x||V.y!==q.y)&&(_==null||_.transform(k,C,null,{sync:!0}))}}function B(){const q=k?ng(k.node()):{x:0,y:0,k:1};return{x:q.x,y:q.y,zoom:q.k}}async function G(q,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?qo:Cl).scaleTo(Vu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),q)}):!1}async function Q(q,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?qo:Cl).scaleBy(Vu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),q)}):!1}function ne(q){_==null||_.scaleExtent(q)}function ee(q){_==null||_.translateExtent(q)}function te(q){const C=!pn(q)||q<0?0:q;_==null||_.clickDistance(C)}return{update:P,destroy:w,setViewport:$,setViewportConstrained:j,getViewport:B,scaleTo:G,scaleBy:Q,setScaleExtent:ne,setTranslateExtent:ee,syncViewport:z,setClickDistance:te}}var to;(function(t){t.Line="line",t.Handle="handle"})(to||(to={}));function K1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function Ah(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function Pr(t,r){return Math.max(0,r-t)}function Ir(t,r){return Math.max(0,t-r)}function Sl(t,r,o){return Math.max(0,r-t,t-o)}function $h(t,r){return t?!r:r}function Q1(t,r,o,s,a,u,c,h){let{affectsX:p,affectsY:y}=r;const{isHorizontal:x,isVertical:v}=r,m=x&&v,{xSnapped:_,ySnapped:k}=o,{minWidth:b,maxWidth:E,minHeight:N,maxHeight:P}=s,{x:w,y:j,width:$,height:z,aspectRatio:B}=t;let G=Math.floor(x?_-t.pointerX:0),Q=Math.floor(v?k-t.pointerY:0);const ne=$+(p?-G:G),ee=z+(y?-Q:Q),te=-u[0]*$,q=-u[1]*z;let C=Sl(ne,b,E),V=Sl(ee,N,P);if(c){let M=0,D=0;p&&G<0?M=Pr(w+G+te,c[0][0]):!p&&G>0&&(M=Ir(w+ne+te,c[1][0])),y&&Q<0?D=Pr(j+Q+q,c[0][1]):!y&&Q>0&&(D=Ir(j+ee+q,c[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(h){let M=0,D=0;p&&G>0?M=Ir(w+G,h[0][0]):!p&&G<0&&(M=Pr(w+ne,h[1][0])),y&&Q>0?D=Ir(j+Q,h[0][1]):!y&&Q<0&&(D=Pr(j+ee,h[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(a){if(x){const M=Sl(ne/B,N,P)*B;if(C=Math.max(C,M),c){let D=0;!p&&!y||p&&!y&&m?D=Ir(j+q+ne/B,c[1][1])*B:D=Pr(j+q+(p?G:-G)/B,c[0][1])*B,C=Math.max(C,D)}if(h){let D=0;!p&&!y||p&&!y&&m?D=Pr(j+ne/B,h[1][1])*B:D=Ir(j+(p?G:-G)/B,h[0][1])*B,C=Math.max(C,D)}}if(v){const M=Sl(ee*B,b,E)/B;if(V=Math.max(V,M),c){let D=0;!p&&!y||y&&!p&&m?D=Ir(w+ee*B+te,c[1][0])/B:D=Pr(w+(y?Q:-Q)*B+te,c[0][0])/B,V=Math.max(V,D)}if(h){let D=0;!p&&!y||y&&!p&&m?D=Pr(w+ee*B,h[1][0])/B:D=Ir(w+(y?Q:-Q)*B,h[0][0])/B,V=Math.max(V,D)}}}Q=Q+(Q<0?V:-V),G=G+(G<0?C:-C),a&&(m?ne>ee*B?Q=($h(p,y)?-G:G)/B:G=($h(p,y)?-Q:Q)*B:x?(Q=G/B,y=p):(G=Q*B,p=y));const W=p?w+G:w,U=y?j+Q:j;return{width:$+(p?-G:G),height:z+(y?-Q:Q),x:u[0]*G*(p?-1:1)+W,y:u[1]*Q*(y?-1:1)+U}}const Tg={width:0,height:0,x:0,y:0},Z1={...Tg,pointerX:0,pointerY:0,aspectRatio:1};function J1(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function e_({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Gt(t);let c={controlDirection:Ah("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:y,boundaries:x,keepAspectRatio:v,resizeDirection:m,onResizeStart:_,onResize:k,onResizeEnd:b,shouldResize:E}){let N={...Tg},P={...Z1};c={boundaries:x,resizeDirection:m,keepAspectRatio:v,controlDirection:Ah(y)};let w,j=null,$=[],z,B,G,Q=!1;const ne=Bp().on("start",ee=>{const{nodeLookup:te,transform:q,snapGrid:C,snapToGrid:V,nodeOrigin:W,paneDomNode:U}=o();if(w=te.get(r),!w)return;j=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:D}=Ko(ee.sourceEvent,{transform:q,snapGrid:C,snapToGrid:V,containerBounds:j});N={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},P={...N,pointerX:M,pointerY:D,aspectRatio:N.width/N.height},z=void 0,B=gi(w.extent)?w.extent:void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&(z=te.get(w.parentId)),z&&w.extent==="parent"&&(B=[[0,0],[z.measured.width,z.measured.height]]),$=[],G=void 0;for(const[F,R]of te)if(R.parentId===r&&($.push({id:F,position:{...R.position},extent:R.extent}),R.extent==="parent"||R.expandParent)){const A=J1(R,w,R.origin??W);G?G=[[Math.min(A[0][0],G[0][0]),Math.min(A[0][1],G[0][1])],[Math.max(A[1][0],G[1][0]),Math.max(A[1][1],G[1][1])]]:G=A}_==null||_(ee,{...N})}).on("drag",ee=>{const{transform:te,snapGrid:q,snapToGrid:C,nodeOrigin:V}=o(),W=Ko(ee.sourceEvent,{transform:te,snapGrid:q,snapToGrid:C,containerBounds:j}),U=[];if(!w)return;const{x:M,y:D,width:F,height:R}=N,A={},ie=w.origin??V,{width:oe,height:fe,x:he,y:pe}=Q1(P,c.controlDirection,W,c.boundaries,c.keepAspectRatio,ie,B,G),Z=oe!==F,se=fe!==R,me=he!==M&&Z,ke=pe!==D&&se;if(!me&&!ke&&!Z&&!se)return;if((me||ke||ie[0]===1||ie[1]===1)&&(A.x=me?he:N.x,A.y=ke?pe:N.y,N.x=A.x,N.y=A.y,$.length>0)){const Me=he-M,Te=pe-D;for(const $e of $)$e.position={x:$e.position.x-Me+ie[0]*(oe-F),y:$e.position.y-Te+ie[1]*(fe-R)},U.push($e)}if((Z||se)&&(A.width=Z&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:N.width,A.height=se&&(!c.resizeDirection||c.resizeDirection==="vertical")?fe:N.height,N.width=A.width,N.height=A.height),z&&w.expandParent){const Me=ie[0]*(A.width??0);A.x&&A.x{Q&&(b==null||b(ee,{...N}),a==null||a({...N}),Q=!1)});u.call(ne)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Wu={exports:{}},Uu={},Yu={exports:{}},Gu={};/** - * @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 zh;function t_(){if(zh)return Gu;zh=1;var t=us();function r(v,m){return v===m&&(v!==0||1/v===1/m)||v!==v&&m!==m}var o=typeof Object.is=="function"?Object.is:r,s=t.useState,a=t.useEffect,u=t.useLayoutEffect,c=t.useDebugValue;function h(v,m){var _=m(),k=s({inst:{value:_,getSnapshot:m}}),b=k[0].inst,E=k[1];return u(function(){b.value=_,b.getSnapshot=m,p(b)&&E({inst:b})},[v,_,m]),a(function(){return p(b)&&E({inst:b}),v(function(){p(b)&&E({inst:b})})},[v]),c(_),_}function p(v){var m=v.getSnapshot;v=v.value;try{var _=m();return!o(v,_)}catch{return!0}}function y(v,m){return m()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:h;return Gu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:x,Gu}var Dh;function n_(){return Dh||(Dh=1,Yu.exports=t_()),Yu.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 Oh;function r_(){if(Oh)return Uu;Oh=1;var t=us(),r=n_();function o(y,x){return y===x&&(y!==0||1/y===1/x)||y!==y&&x!==x}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Uu.useSyncExternalStoreWithSelector=function(y,x,v,m,_){var k=u(null);if(k.current===null){var b={hasValue:!1,value:null};k.current=b}else b=k.current;k=h(function(){function N(z){if(!P){if(P=!0,w=z,z=m(z),_!==void 0&&b.hasValue){var B=b.value;if(_(B,z))return j=B}return j=z}if(B=j,s(w,z))return B;var G=m(z);return _!==void 0&&_(B,G)?(w=z,B):(w=z,j=G)}var P=!1,w,j,$=v===void 0?null:v;return[function(){return N(x())},$===null?void 0:function(){return N($())}]},[x,v,m,_]);var E=a(y,k[0],k[1]);return c(function(){b.hasValue=!0,b.value=E},[E]),p(E),E},Uu}var Fh;function i_(){return Fh||(Fh=1,Wu.exports=r_()),Wu.exports}var o_=i_();const s_=Np(o_),l_={},Hh=t=>{let r;const o=new Set,s=(x,v)=>{const m=typeof x=="function"?x(r):x;if(!Object.is(m,r)){const _=r;r=v??(typeof m!="object"||m===null)?m:Object.assign({},r,m),o.forEach(k=>k(r,_))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>y,subscribe:x=>(o.add(x),()=>o.delete(x)),destroy:()=>{(l_?"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."),o.clear()}},y=r=t(s,a,p);return p},a_=t=>t?Hh(t):Hh,{useDebugValue:u_}=i0,{useSyncExternalStoreWithSelector:c_}=s_,d_=t=>t;function Lg(t,r=d_,o){const s=c_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return u_(s),s}const Bh=(t,r)=>{const o=a_(t),s=(a,u=r)=>Lg(o,a,u);return Object.assign(s,o),s},f_=(t,r)=>t?Bh(t,r):Bh;function Qe(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}jp();const Zl=L.createContext(null),h_=Zl.Provider,Ag=mn.error001("react");function De(t,r){const o=L.useContext(Zl);if(o===null)throw new Error(Ag);return Lg(o,t,r)}function Ye(){const t=L.useContext(Zl);if(t===null)throw new Error(Ag);return L.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Vh={display:"none"},p_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},$g="react-flow__node-desc",zg="react-flow__edge-desc",g_="react-flow__aria-live",m_=t=>t.ariaLiveMessage,y_=t=>t.ariaLabelConfig;function v_({rfId:t}){const r=De(m_);return d.jsx("div",{id:`${g_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:p_,children:r})}function x_({rfId:t,disableKeyboardA11y:r}){const o=De(y_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${$g}-${t}`,style:Vh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${zg}-${t}`,style:Vh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(v_,{rfId:t})]})}const Jl=L.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return d.jsx("div",{className:nt(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});Jl.displayName="Panel";const Wh="https://reactflow.dev?utm_source=attribution";function w_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:d.jsx(Jl,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Wh}`,children:d.jsx("a",{href:Wh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const __=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},kl=t=>t.id;function S_(t,r){return Qe(t.selectedNodes.map(kl),r.selectedNodes.map(kl))&&Qe(t.selectedEdges.map(kl),r.selectedEdges.map(kl))}function k_({onSelectionChange:t}){const r=Ye(),{selectedNodes:o,selectedEdges:s}=De(__,S_);return L.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const N_=t=>!!t.onSelectionChangeHandlers;function j_({onSelectionChange:t}){const r=De(N_);return t||r?d.jsx(k_,{onSelectionChange:t}):null}const Dg=[0,0],b_={x:0,y:0,zoom:1},E_=["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"],Uh=[...E_,"rfId"],C_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Yh={translateExtent:ns,nodeOrigin:Dg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function M_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=De(C_,Qe),y=Ye();L.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{x.current=Yh,h()}),[]);const x=L.useRef(Yh);return L.useEffect(()=>{for(const v of Uh){const m=t[v],_=x.current[v];m!==_&&(typeof t[v]>"u"||(v==="nodes"?r(m):v==="edges"?o(m):v==="minZoom"?s(m):v==="maxZoom"?a(m):v==="translateExtent"?u(m):v==="nodeExtent"?c(m):v==="ariaLabelConfig"?y.setState({ariaLabelConfig:h1(m)}):v==="fitView"?y.setState({fitViewQueued:m}):v==="fitViewOptions"?y.setState({fitViewOptions:m}):y.setState({[v]:m})))}x.current=t},Uh.map(v=>t[v])),null}function Gh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function P_(t){var s;const[r,o]=L.useState(t==="system"?null:t);return L.useEffect(()=>{if(t!=="system"){o(t);return}const a=Gh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=Gh())!=null&&s.matches?"dark":"light"}const Xh=typeof document<"u"?document:null;function ls(t=null,r={target:Xh,actInsideInputWithModifier:!0}){const[o,s]=L.useState(!1),a=L.useRef(!1),u=L.useRef(new Set([])),[c,h]=L.useMemo(()=>{if(t!==null){const y=(Array.isArray(t)?t:[t]).filter(v=>typeof v=="string").map(v=>v.replace(/\+/g,` -`).replace(` - -`,` -+`).split(` -`)),x=y.reduce((v,m)=>v.concat(...m),[]);return[y,x]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Xh,y=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const x=_=>{var E,N;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!y)&&yg(_))return!1;const b=Kh(_.code,h);if(u.current.add(_[b]),qh(c,u.current,!1)){const P=((N=(E=_.composedPath)==null?void 0:E.call(_))==null?void 0:N[0])||_.target,w=(P==null?void 0:P.nodeName)==="BUTTON"||(P==null?void 0:P.nodeName)==="A";r.preventDefault!==!1&&(a.current||!w)&&_.preventDefault(),s(!0)}},v=_=>{const k=Kh(_.code,h);qh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},m=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",x),p==null||p.addEventListener("keyup",v),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{p==null||p.removeEventListener("keydown",x),p==null||p.removeEventListener("keyup",v),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,s]),o}function qh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Kh(t,r){return r.includes(t)?"code":"key"}const I_=()=>{const t=Ye();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=Nc(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),y={x:r.x-h,y:r.y-p},x=o.snapGrid??a,v=o.snapToGrid??u;return gs(y,s,v,x)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=eo(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function Og(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)R_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function R_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function T_(t,r){return Og(t,r)}function L_(t,r){return Og(t,r)}function ai(t,r){return{id:t,type:"select",selected:r}}function Gi(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(ai(u.id,c)))}return s}function Qh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Zh(t){return{id:t.id,type:"remove"}}const A_=hg();function $_(t,r,o={}){return x1(t,r,{...o,onError:o.onError??A_})}const Jh=t=>i1(t),z_=t=>ag(t);function Fg(t){return L.forwardRef(t)}const Hg=typeof window<"u"?L.useLayoutEffect:L.useEffect;function ep(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>D_(()=>o(a=>a+BigInt(1))));return Hg(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function D_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Bg=L.createContext(null);function O_({children:t}){const r=Ye(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:y,hasDefaultNodes:x,onNodesChange:v,nodeLookup:m,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let b=p;for(const N of h)b=typeof N=="function"?N(b):N;let E=Qh({items:b,lookup:m});for(const N of k.values())E=N(E);x&&y(b),E.length>0?v==null||v(E):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:N,nodes:P,setNodes:w}=r.getState();N&&w(P)})},[]),s=ep(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:y,hasDefaultEdges:x,onEdgesChange:v,edgeLookup:m}=r.getState();let _=p;for(const k of h)_=typeof k=="function"?k(_):k;x?y(_):v&&v(Qh({items:_,lookup:m}))},[]),u=ep(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Bg.Provider,{value:c,children:t})}function F_(){const t=L.useContext(Bg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const H_=t=>!!t.panZoom;function ea(){const t=I_(),r=Ye(),o=F_(),s=De(H_),a=L.useMemo(()=>{const u=v=>r.getState().nodeLookup.get(v),c=v=>{o.nodeQueue.push(v)},h=v=>{o.edgeQueue.push(v)},p=v=>{var N,P;const{nodeLookup:m,nodeOrigin:_}=r.getState(),k=Jh(v)?v:m.get(v.id),b=k.parentId?gg(k.position,k.measured,k.parentId,m,_):k.position,E={...k,position:b,width:((N=k.measured)==null?void 0:N.width)??k.width,height:((P=k.measured)==null?void 0:P.height)??k.height};return os(E)},y=(v,m,_={replace:!1})=>{c(k=>k.map(b=>{if(b.id===v){const E=typeof m=="function"?m(b):m;return _.replace&&Jh(E)?E:{...b,...E}}return b}))},x=(v,m,_={replace:!1})=>{h(k=>k.map(b=>{if(b.id===v){const E=typeof m=="function"?m(b):m;return _.replace&&z_(E)?E:{...b,...E}}return b}))};return{getNodes:()=>r.getState().nodes.map(v=>({...v})),getNode:v=>{var m;return(m=u(v))==null?void 0:m.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:v=[]}=r.getState();return v.map(m=>({...m}))},getEdge:v=>r.getState().edgeLookup.get(v),setNodes:c,setEdges:h,addNodes:v=>{const m=Array.isArray(v)?v:[v];o.nodeQueue.push(_=>[..._,...m])},addEdges:v=>{const m=Array.isArray(v)?v:[v];o.edgeQueue.push(_=>[..._,...m])},toObject:()=>{const{nodes:v=[],edges:m=[],transform:_}=r.getState(),[k,b,E]=_;return{nodes:v.map(N=>({...N})),edges:m.map(N=>({...N})),viewport:{x:k,y:b,zoom:E}}},deleteElements:async({nodes:v=[],edges:m=[]})=>{const{nodes:_,edges:k,onNodesDelete:b,onEdgesDelete:E,triggerNodeChanges:N,triggerEdgeChanges:P,onDelete:w,onBeforeDelete:j}=r.getState(),{nodes:$,edges:z}=await u1({nodesToRemove:v,edgesToRemove:m,nodes:_,edges:k,onBeforeDelete:j}),B=z.length>0,G=$.length>0;if(B){const Q=z.map(Zh);E==null||E(z),P(Q)}if(G){const Q=$.map(Zh);b==null||b($),N(Q)}return(G||B)&&(w==null||w({nodes:$,edges:z})),{deletedNodes:$,deletedEdges:z}},getIntersectingNodes:(v,m=!0,_)=>{const k=Nh(v),b=k?v:p(v),E=_!==void 0;return b?(_||r.getState().nodes).filter(N=>{const P=r.getState().nodeLookup.get(N.id);if(P&&!k&&(N.id===v.id||!P.internals.positionAbsolute))return!1;const w=os(E?N:P),j=Fl(w,b);return m&&j>0||j>=w.width*w.height||j>=b.width*b.height}):[]},isNodeIntersecting:(v,m,_=!0)=>{const b=Nh(v)?v:p(v);if(!b)return!1;const E=Fl(b,m);return _&&E>0||E>=m.width*m.height||E>=b.width*b.height},updateNode:y,updateNodeData:(v,m,_={replace:!1})=>{y(v,k=>{const b=typeof m=="function"?m(k):m;return _.replace?{...k,data:b}:{...k,data:{...k.data,...b}}},_)},updateEdge:x,updateEdgeData:(v,m,_={replace:!1})=>{x(v,k=>{const b=typeof m=="function"?m(k):m;return _.replace?{...k,data:b}:{...k,data:{...k.data,...b}}},_)},getNodesBounds:v=>{const{nodeLookup:m,nodeOrigin:_}=r.getState();return o1(v,{nodeLookup:m,nodeOrigin:_})},getHandleConnections:({type:v,id:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${v}${m?`-${m}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:v,handleId:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${v?m?`-${v}-${m}`:`-${v}`:""}`))==null?void 0:k.values())??[])},fitView:async v=>{const m=r.getState().fitViewResolver??f1();return r.setState({fitViewQueued:!0,fitViewOptions:v,fitViewResolver:m}),o.nodeQueue.push(_=>[..._]),m.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const tp=t=>t.selected,B_=typeof window<"u"?window:void 0;function V_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ye(),{deleteElements:s}=ea(),a=ls(t,{actInsideInputWithModifier:!1}),u=ls(r,{target:B_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(tp),edges:c.filter(tp)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function W_(t){const r=Ye();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=jc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",mn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const ta={position:"absolute",width:"100%",height:"100%",top:0,left:0},U_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function Y_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=di.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:y,translateExtent:x,minZoom:v,maxZoom:m,zoomActivationKeyCode:_,preventScrolling:k=!0,children:b,noWheelClassName:E,noPanClassName:N,onViewportChange:P,isControlledViewport:w,paneClickDistance:j,selectionOnDrag:$}){const z=Ye(),B=L.useRef(null),{userSelectionActive:G,lib:Q,connectionInProgress:ne}=De(U_,Qe),ee=ls(_),te=L.useRef();W_(B);const q=L.useCallback(C=>{P==null||P({x:C[0],y:C[1],zoom:C[2]}),w||z.setState({transform:C})},[P,w]);return L.useEffect(()=>{if(B.current){te.current=q1({domNode:B.current,minZoom:v,maxZoom:m,translateExtent:x,viewport:y,onDraggingChange:U=>z.setState(M=>M.paneDragging===U?M:{paneDragging:U}),onPanZoomStart:(U,M)=>{const{onViewportChangeStart:D,onMoveStart:F}=z.getState();F==null||F(U,M),D==null||D(M)},onPanZoom:(U,M)=>{const{onViewportChange:D,onMove:F}=z.getState();F==null||F(U,M),D==null||D(M)},onPanZoomEnd:(U,M)=>{const{onViewportChangeEnd:D,onMoveEnd:F}=z.getState();F==null||F(U,M),D==null||D(M)}});const{x:C,y:V,zoom:W}=te.current.getViewport();return z.setState({panZoom:te.current,transform:[C,V,W],domNode:B.current.closest(".react-flow")}),()=>{var U;(U=te.current)==null||U.destroy()}}},[]),L.useEffect(()=>{var C;(C=te.current)==null||C.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:ee,preventScrolling:k,noPanClassName:N,userSelectionActive:G,noWheelClassName:E,lib:Q,onTransformChange:q,connectionInProgress:ne,selectionOnDrag:$,paneClickDistance:j})},[t,r,o,s,a,u,c,h,p,ee,k,N,G,E,Q,q,ne,$,j]),d.jsx("div",{className:"react-flow__renderer",ref:B,style:ta,children:b})}const G_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function X_(){const{userSelectionActive:t,userSelectionRect:r}=De(G_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const Xu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},q_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function K_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=rs.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:y,onPaneContextMenu:x,onPaneScroll:v,onPaneMouseEnter:m,onPaneMouseMove:_,onPaneMouseLeave:k,children:b}){const E=L.useRef(0),N=Ye(),{userSelectionActive:P,elementsSelectable:w,dragging:j,panBy:$,autoPanSpeed:z}=De(q_,Qe),B=w&&(t||P),G=L.useRef(null),Q=L.useRef(),ne=L.useRef(new Set),ee=L.useRef(new Set),te=L.useRef(!1),q=L.useRef(!1),C=L.useRef({x:0,y:0}),V=L.useRef(!1),W=Z=>{if(q.current||te.current||N.getState().connection.inProgress){q.current=!1,te.current=!1;return}y==null||y(Z),N.getState().resetSelectedElements(),N.setState({nodesSelectionActive:!1})},U=Z=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Z.preventDefault();return}x==null||x(Z)},M=v?Z=>v(Z):void 0,D=Z=>{q.current&&(Z.stopPropagation(),q.current=!1)},F=Z=>{var $e,st;if(Z.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:se,transform:me}=N.getState();if(Q.current=se==null?void 0:se.getBoundingClientRect(),!Q.current)return;const ke=Z.target===G.current;if(!ke&&!!Z.target.closest(".nokey")||!t||!(c&&ke||r)||Z.button!==0||!Z.isPrimary)return;(st=($e=Z.target)==null?void 0:$e.setPointerCapture)==null||st.call($e,Z.pointerId),q.current=!1;const{x:Ne,y:Me}=gn(Z.nativeEvent,Q.current),Te=gs({x:Ne,y:Me},me);N.setState({userSelectionRect:{width:0,height:0,startX:Te.x,startY:Te.y,x:Ne,y:Me}}),ke||(Z.stopPropagation(),Z.preventDefault())};function R(Z,se){const{userSelectionRect:me}=N.getState();if(!me)return;const{transform:ke,nodeLookup:ve,edgeLookup:re,connectionLookup:Ne,triggerNodeChanges:Me,triggerEdgeChanges:Te,defaultEdgeOptions:$e}=N.getState(),st={x:me.startX,y:me.startY},{x:lt,y:at}=eo(st,ke),Ge={startX:st.x,startY:st.y,x:Zmt.id)),ee.current=new Set;const gt=($e==null?void 0:$e.selectable)??!0;for(const mt of ne.current){const Pt=Ne.get(mt);if(Pt)for(const{edgeId:ut}of Pt.values()){const Je=re.get(ut);Je&&(Je.selectable??gt)&&ee.current.add(ut)}}if(!jh(wt,ne.current)){const mt=Gi(ve,ne.current,!0);Me(mt)}if(!jh(qt,ee.current)){const mt=Gi(re,ee.current);Te(mt)}N.setState({userSelectionRect:Ge,userSelectionActive:!0,nodesSelectionActive:!1})}function A(){if(!a||!Q.current)return;const[Z,se]=kc(C.current,Q.current,z);$({x:Z,y:se}).then(me=>{if(!q.current||!me){E.current=requestAnimationFrame(A);return}const{x:ke,y:ve}=C.current;R(ke,ve),E.current=requestAnimationFrame(A)})}const ie=()=>{cancelAnimationFrame(E.current),E.current=0,V.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=Z=>{const{userSelectionRect:se,transform:me,resetSelectedElements:ke}=N.getState();if(!Q.current||!se)return;const{x:ve,y:re}=gn(Z.nativeEvent,Q.current);C.current={x:ve,y:re};const Ne=eo({x:se.startX,y:se.startY},me);if(!q.current){const Me=r?0:u;if(Math.hypot(ve-Ne.x,re-Ne.y)<=Me)return;ke(),h==null||h(Z)}q.current=!0,V.current||(A(),V.current=!0),R(ve,re)},fe=Z=>{var se,me;if(!B){Z.target===G.current&&N.getState().connection.inProgress&&(te.current=!0);return}Z.button===0&&((me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),!P&&Z.target===G.current&&N.getState().userSelectionRect&&(W==null||W(Z)),N.setState({userSelectionActive:!1,userSelectionRect:null}),q.current&&(p==null||p(Z),N.setState({nodesSelectionActive:ne.current.size>0})),ie())},he=Z=>{var se,me;(me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),ie()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:nt(["react-flow__pane",{draggable:pe,dragging:j,selection:t}]),onClick:B?void 0:Xu(W,G),onContextMenu:Xu(U,G),onWheel:Xu(M,G),onPointerEnter:B?void 0:m,onPointerMove:B?oe:_,onPointerUp:fe,onPointerCancel:B?he:void 0,onPointerDownCapture:B?F:void 0,onClickCapture:B?D:void 0,onPointerLeave:k,ref:G,style:ta,children:[b,d.jsx(X_,{})]})}function hc({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),y=h.get(t);if(!y){p==null||p("012",mn.error012(t));return}r.setState({nodesSelectionActive:!1}),y.selected?(o||y.selected&&c)&&(u({nodes:[y],edges:[]}),requestAnimationFrame(()=>{var x;return(x=s==null?void 0:s.current)==null?void 0:x.blur()})):a([t])}function Vg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ye(),[p,y]=L.useState(!1),x=L.useRef();return L.useEffect(()=>{if(!r)return x.current=A1({getStoreItems:()=>h.getState(),onNodeMouseDown:v=>{hc({id:v,store:h,nodeRef:t})},onDragStart:()=>{y(!0)},onDragStop:()=>{y(!1)}}),()=>{var v;(v=x.current)==null||v.destroy(),x.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!x.current||x.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const Q_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Wg(){const t=Ye();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:y,nodeOrigin:x}=t.getState(),v=new Map,m=Q_(c),_=a?u[0]:5,k=a?u[1]:5,b=o.direction.x*_*o.factor,E=o.direction.y*k*o.factor;for(const[,N]of y){if(!m(N))continue;let P={x:N.internals.positionAbsolute.x+b,y:N.internals.positionAbsolute.y+E};a&&(P=ps(P,u));const{position:w,positionAbsolute:j}=ug({nodeId:N.id,nextPosition:P,nodeLookup:y,nodeExtent:s,nodeOrigin:x,onError:h});N.position=w,N.internals.positionAbsolute=j,v.set(N.id,N)}p(v)},[])}const Ic=L.createContext(null),Z_=Ic.Provider;Ic.Consumer;const Ug=()=>L.useContext(Ic),J_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Yg=L.createContext(null);function eS({children:t}){const r=De(J_,Qe);return d.jsx(Yg.Provider,{value:r,children:t})}function tS(){const t=L.useContext(Yg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const nS={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},rS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:y}=c;if(!h&&!a)return nS;const x=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:x,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Zi.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:x&&y}};function iS({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:y,onMouseDown:x,onTouchStart:v,...m},_){var V,W;const k=c||null,b=t==="target",E=Ye(),N=Ug(),{connectOnClick:P,noPanClassName:w,rfId:j}=tS(),{connectingFrom:$,connectingTo:z,clickConnecting:B,isPossibleEndHandle:G,connectionInProcess:Q,clickConnectionInProcess:ne,valid:ee}=De(rS(N,k,t),Qe);N||(W=(V=E.getState()).onError)==null||W.call(V,"010",mn.error010());const te=U=>{const{defaultEdgeOptions:M,onConnect:D,hasDefaultEdges:F}=E.getState(),R={...M,...U};if(F){const{edges:A,setEdges:ie,onError:oe}=E.getState();ie($_(R,A,{onError:oe}))}D==null||D(R),h==null||h(R)},q=U=>{if(!N)return;const M=vg(U.nativeEvent);if(a&&(M&&U.button===0||!M)){const D=E.getState();fc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:b,handleId:k,nodeId:N,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...F)=>{var R,A;return(A=(R=E.getState()).onConnectEnd)==null?void 0:A.call(R,...F)},updateConnection:D.updateConnection,onConnect:te,isValidConnection:o||((...F)=>{var R,A;return((A=(R=E.getState()).isValidConnection)==null?void 0:A.call(R,...F))??!0}),getTransform:()=>E.getState().transform,getFromHandle:()=>E.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}M?x==null||x(U):v==null||v(U)},C=U=>{const{onClickConnectStart:M,onClickConnectEnd:D,connectionClickStartHandle:F,connectionMode:R,isValidConnection:A,lib:ie,rfId:oe,nodeLookup:fe,connection:he}=E.getState();if(!N||!F&&!a)return;if(!F){M==null||M(U.nativeEvent,{nodeId:N,handleId:k,handleType:t}),E.setState({connectionClickStartHandle:{nodeId:N,type:t,id:k}});return}const pe=mg(U.target),Z=o||A,{connection:se,isValid:me}=fc.isValid(U.nativeEvent,{handle:{nodeId:N,id:k,type:t},connectionMode:R,fromNodeId:F.nodeId,fromHandleId:F.id||null,fromType:F.type,isValidConnection:Z,flowId:oe,doc:pe,lib:ie,nodeLookup:fe});me&&se&&te(se);const ke=structuredClone(he);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,D==null||D(U,ke),E.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":k,"data-nodeid":N,"data-handlepos":r,"data-id":`${j}-${N}-${k}-${t}`,className:nt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",w,y,{source:!b,target:b,connectable:s,connectablestart:a,connectableend:u,clickconnecting:B,connectingfrom:$,connectingto:z,valid:ee,connectionindicator:s&&(!Q||G)&&(Q||ne?u:a)}]),onMouseDown:q,onTouchStart:q,onClick:P?C:void 0,ref:_,...m,children:p})}const no=L.memo(Fg(iS));function oS({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(no,{type:"source",position:o,isConnectable:r})]})}function sS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:s=Se.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(no,{type:"source",position:s,isConnectable:r})]})}function lS(){return null}function aS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const Hl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},np={input:oS,default:sS,output:aS,group:lS};function uS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const cS=t=>{const{width:r,height:o,x:s,y:a}=hs(t.nodeLookup,{filter:u=>!!u.selected});return{width:pn(r)?r:null,height:pn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function dS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ye(),{width:a,height:u,transformString:c,userSelectionActive:h}=De(cS,Qe),p=Wg(),y=L.useRef(null);L.useEffect(()=>{var _;o||(_=y.current)==null||_.focus({preventScroll:!0})},[o]);const x=!h&&a!==null&&u!==null;if(Vg({nodeRef:y,disabled:!x}),!x)return null;const v=t?_=>{const k=s.getState().nodes.filter(b=>b.selected);t(_,k)}:void 0,m=_=>{Object.prototype.hasOwnProperty.call(Hl,_.key)&&(_.preventDefault(),p({direction:Hl[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:nt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:y,className:"react-flow__nodesselection-rect",onContextMenu:v,tabIndex:o?void 0:-1,onKeyDown:o?void 0:m,style:{width:a,height:u}})})}const rp=typeof window<"u"?window:void 0,fS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Gg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:y,selectionOnDrag:x,selectionMode:v,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:b,zoomActivationKeyCode:E,elementsSelectable:N,zoomOnScroll:P,zoomOnPinch:w,panOnScroll:j,panOnScrollSpeed:$,panOnScrollMode:z,zoomOnDoubleClick:B,panOnDrag:G,autoPanOnSelection:Q,defaultViewport:ne,translateExtent:ee,minZoom:te,maxZoom:q,preventScrolling:C,onSelectionContextMenu:V,noWheelClassName:W,noPanClassName:U,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:F}){const{nodesSelectionActive:R,userSelectionActive:A}=De(fS,Qe),ie=ls(y,{target:rp}),oe=ls(b,{target:rp}),fe=oe||G,he=oe||j,pe=x&&fe!==!0,Z=ie||A||pe;return V_({deleteKeyCode:p,multiSelectionKeyCode:k}),d.jsx(Y_,{onPaneContextMenu:u,elementsSelectable:N,zoomOnScroll:P,zoomOnPinch:w,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:$,panOnScrollMode:z,zoomOnDoubleClick:B,panOnDrag:!ie&&fe,defaultViewport:ne,translateExtent:ee,minZoom:te,maxZoom:q,zoomActivationKeyCode:E,preventScrolling:C,noWheelClassName:W,noPanClassName:U,onViewportChange:D,isControlledViewport:F,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(K_,{onSelectionStart:m,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:Q,isSelecting:!!Z,selectionMode:v,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:pe,children:[t,R&&d.jsx(dS,{onSelectionContextMenu:V,noPanClassName:U,disableKeyboardA11y:M})]})})}Gg.displayName="FlowRenderer";const hS=L.memo(Gg),pS=t=>r=>t?Sc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function gS(t){return De(L.useCallback(pS(t),[t]),Qe)}const mS=t=>t.updateNodeInternals;function yS(){const t=De(mS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function vS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ye(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),y=L.useRef(r),x=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!x||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[x,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const v=y.current!==r,m=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(v||m||_)&&(y.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function xS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:y,nodesFocusable:x,resizeObserver:v,noDragClassName:m,noPanClassName:_,disableKeyboardA11y:k,rfId:b,nodeTypes:E,nodeClickDistance:N,onError:P}){const{node:w,internals:j,isParent:$}=De(Z=>{const se=Z.nodeLookup.get(t),me=Z.parentLookup.has(t);return{node:se,internals:se.internals,isParent:me}},Qe);let z=w.type||"default",B=(E==null?void 0:E[z])||np[z];B===void 0&&(P==null||P("003",mn.error003(z)),z="default",B=(E==null?void 0:E.default)||np.default);const G=!!(w.draggable||h&&typeof w.draggable>"u"),Q=!!(w.selectable||p&&typeof w.selectable>"u"),ne=!!(w.connectable||y&&typeof w.connectable>"u"),ee=!!(w.focusable||x&&typeof w.focusable>"u"),te=Ye(),q=pg(w),C=vS({node:w,nodeType:z,hasDimensions:q,resizeObserver:v}),V=Vg({nodeRef:C,disabled:w.hidden||!G,noDragClassName:m,handleSelector:w.dragHandle,nodeId:t,isSelectable:Q,nodeClickDistance:N}),W=Wg();if(w.hidden)return null;const U=vn(w),M=uS(w),D=Q||G||r||o||s||a,F=o?Z=>o(Z,{...j.userNode}):void 0,R=s?Z=>s(Z,{...j.userNode}):void 0,A=a?Z=>a(Z,{...j.userNode}):void 0,ie=u?Z=>u(Z,{...j.userNode}):void 0,oe=c?Z=>c(Z,{...j.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:se,nodeDragThreshold:me}=te.getState();Q&&(!se||!G||me>0)&&hc({id:t,store:te,nodeRef:C}),r&&r(Z,{...j.userNode})},he=Z=>{if(!(yg(Z.nativeEvent)||k)){if(ig.includes(Z.key)&&Q){const se=Z.key==="Escape";hc({id:t,store:te,unselect:se,nodeRef:C})}else if(G&&w.selected&&Object.prototype.hasOwnProperty.call(Hl,Z.key)){Z.preventDefault();const{ariaLabelConfig:se}=te.getState();te.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),W({direction:Hl[Z.key],factor:Z.shiftKey?4:1})}}},pe=()=>{var Ne;if(k||!((Ne=C.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:Z,width:se,height:me,autoPanOnNodeFocus:ke,setCenter:ve}=te.getState();if(!ke)return;Sc(new Map([[t,w]]),{x:0,y:0,width:se,height:me},Z,!0).length>0||ve(w.position.x+U.width/2,w.position.y+U.height/2,{zoom:Z[2]})};return d.jsx("div",{className:nt(["react-flow__node",`react-flow__node-${z}`,{[_]:G},w.className,{selected:w.selected,selectable:Q,parent:$,draggable:G,dragging:V}]),ref:C,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:q?"visible":"hidden",...w.style,...M},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:F,onMouseMove:R,onMouseLeave:A,onContextMenu:ie,onClick:fe,onDoubleClick:oe,onKeyDown:ee?he:void 0,tabIndex:ee?0:void 0,onFocus:ee?pe:void 0,role:w.ariaRole??(ee?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${$g}-${b}`,"aria-label":w.ariaLabel,...w.domAttributes,children:d.jsx(Z_,{value:t,children:d.jsx(B,{id:t,data:w.data,type:z,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:w.selected??!1,selectable:Q,draggable:G,deletable:w.deletable??!0,isConnectable:ne,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:V,dragHandle:w.dragHandle,zIndex:j.z,parentId:w.parentId,...U})})})}var wS=L.memo(xS);const _S=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Xg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=De(_S,Qe),u=gS(t.onlyRenderVisibleElements),c=yS();return d.jsx("div",{className:"react-flow__nodes",style:ta,children:u.map(h=>d.jsx(wS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Xg.displayName="NodeRenderer";const SS=L.memo(Xg);function kS(t){return De(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&m1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const NS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},jS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ip={[is.Arrow]:NS,[is.ArrowClosed]:jS};function bS(t){const r=Ye();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(ip,t)?ip[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",mn.error009(t)),null)},[t])}const ES=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=bS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},qg=({defaultColor:t,rfId:r})=>{const o=De(u=>u.edges),s=De(u=>u.defaultEdgeOptions),a=L.useMemo(()=>N1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(ES,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};qg.displayName="MarkerDefinitions";var CS=L.memo(qg);function Kg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:y,...x}){const[v,m]=L.useState({x:1,y:0,width:0,height:0}),_=nt(["react-flow__edge-textwrapper",y]),k=L.useRef(null);return L.useEffect(()=>{if(k.current){const b=k.current.getBBox();m({x:b.x,y:b.y,width:b.width,height:b.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-v.width/2} ${r-v.height/2})`,className:_,visibility:v.width?"visible":"hidden",...x,children:[a&&d.jsx("rect",{width:v.width+2*c[0],x:-c[0],y:-c[1],height:v.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:v.height/2,dy:"0.3em",ref:k,style:s,children:o}),p]}):null}Kg.displayName="EdgeText";const MS=L.memo(Kg);function na({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:y=20,...x}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...x,d:t,fill:"none",className:nt(["react-flow__edge-path",x.className])}),y?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:y,className:"react-flow__edge-interaction"}):null,s&&pn(r)&&pn(o)?d.jsx(MS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function op({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function Qg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top}){const[c,h]=op({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,y]=op({pos:u,x1:s,y1:a,x2:t,y2:r}),[x,v,m,_]=xg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:y});return[`M${t},${r} C${c},${h} ${p},${y} ${s},${a}`,x,v,m,_]}function Zg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,interactionWidth:N})=>{const[P,w,j]=Qg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),$=t.isInternal?void 0:r;return d.jsx(na,{id:$,path:P,labelX:w,labelY:j,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,interactionWidth:N})})}const PS=Zg({isInternal:!1}),Jg=Zg({isInternal:!0});PS.displayName="SimpleBezierEdge";Jg.displayName="SimpleBezierEdgeInternal";function em(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,sourcePosition:_=Se.Bottom,targetPosition:k=Se.Top,markerEnd:b,markerStart:E,pathOptions:N,interactionWidth:P})=>{const[w,j,$]=uc({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:N==null?void 0:N.borderRadius,offset:N==null?void 0:N.offset,stepPosition:N==null?void 0:N.stepPosition}),z=t.isInternal?void 0:r;return d.jsx(na,{id:z,path:w,labelX:j,labelY:$,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,markerEnd:b,markerStart:E,interactionWidth:P})})}const tm=em({isInternal:!1}),nm=em({isInternal:!0});tm.displayName="SmoothStepEdge";nm.displayName="SmoothStepEdgeInternal";function rm(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(tm,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const IS=rm({isInternal:!1}),im=rm({isInternal:!0});IS.displayName="StepEdge";im.displayName="StepEdgeInternal";function om(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,markerEnd:_,markerStart:k,interactionWidth:b})=>{const[E,N,P]=Sg({sourceX:o,sourceY:s,targetX:a,targetY:u}),w=t.isInternal?void 0:r;return d.jsx(na,{id:w,path:E,labelX:N,labelY:P,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,markerEnd:_,markerStart:k,interactionWidth:b})})}const RS=om({isInternal:!1}),sm=om({isInternal:!0});RS.displayName="StraightEdge";sm.displayName="StraightEdgeInternal";function lm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,pathOptions:N,interactionWidth:P})=>{const[w,j,$]=wg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:N==null?void 0:N.curvature}),z=t.isInternal?void 0:r;return d.jsx(na,{id:z,path:w,labelX:j,labelY:$,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:b,markerStart:E,interactionWidth:P})})}const TS=lm({isInternal:!1}),am=lm({isInternal:!0});TS.displayName="BezierEdge";am.displayName="BezierEdgeInternal";const sp={default:am,straight:sm,step:im,smoothstep:nm,simplebezier:Jg},lp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},LS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,AS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,ap="react-flow__edgeupdater";function up({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:nt([ap,`${ap}-${h}`]),cx:LS(r,s,t),cy:AS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function $S({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:y,onReconnectStart:x,onReconnectEnd:v,setReconnecting:m,setUpdateHover:_}){const k=Ye(),b=(j,$)=>{if(j.button!==0)return;const{autoPanOnConnect:z,domNode:B,connectionMode:G,connectionRadius:Q,lib:ne,onConnectStart:ee,cancelConnection:te,nodeLookup:q,rfId:C,panBy:V,updateConnection:W}=k.getState(),U=$.type==="target",M=(R,A)=>{m(!1),v==null||v(R,o,$.type,A)},D=R=>y==null?void 0:y(o,R),F=(R,A)=>{m(!0),x==null||x(j,o,$.type),ee==null||ee(R,A)};fc.onPointerDown(j.nativeEvent,{autoPanOnConnect:z,connectionMode:G,connectionRadius:Q,domNode:B,handleId:$.id,nodeId:$.nodeId,nodeLookup:q,isTarget:U,edgeUpdaterType:$.type,lib:ne,flowId:C,cancelConnection:te,panBy:V,isValidConnection:(...R)=>{var A,ie;return((ie=(A=k.getState()).isValidConnection)==null?void 0:ie.call(A,...R))??!0},onConnect:D,onConnectStart:F,onConnectEnd:(...R)=>{var A,ie;return(ie=(A=k.getState()).onConnectEnd)==null?void 0:ie.call(A,...R)},onReconnectEnd:M,updateConnection:W,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},E=j=>b(j,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),N=j=>b(j,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),P=()=>_(!0),w=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(up,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:E,onMouseEnter:P,onMouseOut:w,type:"source"}),(t===!0||t==="target")&&d.jsx(up,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:N,onMouseEnter:P,onMouseOut:w,type:"target"})]})}function zS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,reconnectRadius:x,onReconnect:v,onReconnectStart:m,onReconnectEnd:_,rfId:k,edgeTypes:b,noPanClassName:E,onError:N,disableKeyboardA11y:P}){let w=De(ve=>ve.edgeLookup.get(t));const j=De(ve=>ve.defaultEdgeOptions);w=j?{...j,...w}:w;let $=w.type||"default",z=(b==null?void 0:b[$])||sp[$];z===void 0&&(N==null||N("011",mn.error011($)),$="default",z=(b==null?void 0:b.default)||sp.default);const B=!!(w.focusable||r&&typeof w.focusable>"u"),G=typeof v<"u"&&(w.reconnectable||o&&typeof w.reconnectable>"u"),Q=!!(w.selectable||s&&typeof w.selectable>"u"),ne=L.useRef(null),[ee,te]=L.useState(!1),[q,C]=L.useState(!1),V=Ye(),{zIndex:W=w.zIndex,sourceX:U,sourceY:M,targetX:D,targetY:F,sourcePosition:R,targetPosition:A}=De(L.useCallback(ve=>{const re=ve.nodeLookup.get(w.source),Ne=ve.nodeLookup.get(w.target);if(!re||!Ne)return lp;const Me=k1({id:t,sourceNode:re,targetNode:Ne,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:ve.connectionMode,onError:N}),Te=g1({selected:w.selected,zIndex:w.zIndex,sourceNode:re,targetNode:Ne,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||lp,zIndex:Te}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex,N]),Qe),ie=L.useMemo(()=>w.markerStart?`url('#${cc(w.markerStart,k)}')`:void 0,[w.markerStart,k]),oe=L.useMemo(()=>w.markerEnd?`url('#${cc(w.markerEnd,k)}')`:void 0,[w.markerEnd,k]);if(w.hidden||U===null||M===null||D===null||F===null)return null;const fe=ve=>{var Te;const{addSelectedEdges:re,unselectNodesAndEdges:Ne,multiSelectionActive:Me}=V.getState();Q&&(V.setState({nodesSelectionActive:!1}),w.selected&&Me?(Ne({nodes:[],edges:[w]}),(Te=ne.current)==null||Te.blur()):re([t])),a&&a(ve,w)},he=u?ve=>{u(ve,{...w})}:void 0,pe=c?ve=>{c(ve,{...w})}:void 0,Z=h?ve=>{h(ve,{...w})}:void 0,se=p?ve=>{p(ve,{...w})}:void 0,me=y?ve=>{y(ve,{...w})}:void 0,ke=ve=>{var re;if(!P&&ig.includes(ve.key)&&Q){const{unselectNodesAndEdges:Ne,addSelectedEdges:Me}=V.getState();ve.key==="Escape"?((re=ne.current)==null||re.blur(),Ne({edges:[w]})):Me([t])}};return d.jsx("svg",{style:{zIndex:W},children:d.jsxs("g",{className:nt(["react-flow__edge",`react-flow__edge-${$}`,w.className,E,{selected:w.selected,animated:w.animated,inactive:!Q&&!a,updating:ee,selectable:Q}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:Z,onMouseMove:se,onMouseLeave:me,onKeyDown:B?ke:void 0,tabIndex:B?0:void 0,role:w.ariaRole??(B?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":B?`${zg}-${k}`:void 0,ref:ne,...w.domAttributes,children:[!q&&d.jsx(z,{id:t,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:Q,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:U,sourceY:M,targetX:D,targetY:F,sourcePosition:R,targetPosition:A,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),G&&d.jsx($S,{edge:w,isReconnectable:G,reconnectRadius:x,onReconnect:v,onReconnectStart:m,onReconnectEnd:_,sourceX:U,sourceY:M,targetX:D,targetY:F,sourcePosition:R,targetPosition:A,setUpdateHover:te,setReconnecting:C})]})})}var DS=L.memo(zS);const OS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function um({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:y,onEdgeClick:x,reconnectRadius:v,onEdgeDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:b}){const{edgesFocusable:E,edgesReconnectable:N,elementsSelectable:P,onError:w}=De(OS,Qe),j=kS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(CS,{defaultColor:t,rfId:o}),j.map($=>d.jsx(DS,{id:$,edgesFocusable:E,edgesReconnectable:N,elementsSelectable:P,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,onClick:x,reconnectRadius:v,onDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:w,edgeTypes:s,disableKeyboardA11y:b},$))]})}um.displayName="EdgeRenderer";const FS=L.memo(um),cp=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function HS({children:t}){const r=Ye(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return Hg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=cp(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:cp(s)},children:t})}function BS(t){const r=ea(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const VS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function WS(t){const r=De(VS),o=Ye();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function US(t){return t.connection.inProgress?{...t.connection,to:gs(t.connection.to,t.transform)}:{...t.connection}}function YS(t){return US}function GS(t){const r=YS();return De(r,Qe)}const XS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function qS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=De(XS,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:nt(["react-flow__connection",lg(h)]),children:d.jsx(cm,{style:r,type:o,CustomComponent:s,isValid:h})})})}const cm=({style:t,type:r=Lr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:y,toNode:x,toHandle:v,toPosition:m,pointer:_}=GS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:y.x,toY:y.y,fromPosition:p,toPosition:m,connectionStatus:lg(s),toNode:x,toHandle:v,pointer:_});let k="";const b={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:y.x,targetY:y.y,targetPosition:m};switch(r){case Lr.Bezier:[k]=wg(b);break;case Lr.SimpleBezier:[k]=Qg(b);break;case Lr.Step:[k]=uc({...b,borderRadius:0});break;case Lr.SmoothStep:[k]=uc(b);break;default:[k]=Sg(b)}return d.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};cm.displayName="ConnectionLine";const KS={};function dp(t=KS){L.useRef(t),Ye(),L.useEffect(()=>{},[t])}function QS(){Ye(),L.useRef(!1),L.useEffect(()=>{},[])}function dm({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:x,onSelectionContextMenu:v,onSelectionStart:m,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:b,connectionLineComponent:E,connectionLineContainerStyle:N,selectionKeyCode:P,selectionOnDrag:w,selectionMode:j,multiSelectionKeyCode:$,panActivationKeyCode:z,zoomActivationKeyCode:B,deleteKeyCode:G,onlyRenderVisibleElements:Q,elementsSelectable:ne,defaultViewport:ee,translateExtent:te,minZoom:q,maxZoom:C,preventScrolling:V,defaultMarkerColor:W,zoomOnScroll:U,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:F,panOnScrollMode:R,zoomOnDoubleClick:A,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneScroll:se,onPaneContextMenu:me,paneClickDistance:ke,nodeClickDistance:ve,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,viewport:ut,onViewportChange:Je,nodesDraggable:An}){return dp(t),dp(r),QS(),BS(o),WS(ut),d.jsx(hS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneContextMenu:me,onPaneScroll:se,paneClickDistance:ke,deleteKeyCode:G,selectionKeyCode:P,selectionOnDrag:w,selectionMode:j,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:$,panActivationKeyCode:z,zoomActivationKeyCode:B,elementsSelectable:ne,zoomOnScroll:U,zoomOnPinch:M,zoomOnDoubleClick:A,panOnScroll:D,panOnScrollSpeed:F,panOnScrollMode:R,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:ee,translateExtent:te,minZoom:q,maxZoom:C,onSelectionContextMenu:v,preventScrolling:V,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,onViewportChange:Je,isControlledViewport:!!ut,children:d.jsxs(HS,{children:[d.jsx(FS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,onlyRenderVisibleElements:Q,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,defaultMarkerColor:W,noPanClassName:qt,disableKeyboardA11y:gt,rfId:Pt}),d.jsx(qS,{style:b,type:k,component:E,containerStyle:N}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(SS,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:x,nodeClickDistance:ve,onlyRenderVisibleElements:Q,noPanClassName:qt,noDragClassName:Ge,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,nodesDraggable:An}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}dm.displayName="GraphView";const ZS=L.memo(dm),JS=hg(),fp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:y=2,nodeOrigin:x,nodeExtent:v,zIndexMode:m="basic"}={})=>{const _=new Map,k=new Map,b=new Map,E=new Map,N=s??r??[],P=o??t??[],w=x??[0,0],j=v??ns;jg(b,E,N);const{nodesInitialized:$}=dc(P,_,k,{nodeOrigin:w,nodeExtent:j,zIndexMode:m});let z=[0,0,1];if(c&&a&&u){const B=hs(_,{filter:ee=>!!((ee.width||ee.initialWidth)&&(ee.height||ee.initialHeight))}),{x:G,y:Q,zoom:ne}=Nc(B,a,u,p,y,(h==null?void 0:h.padding)??.1);z=[G,Q,ne]}return{rfId:"1",width:a??0,height:u??0,transform:z,nodes:P,nodesInitialized:$,nodeLookup:_,parentLookup:k,edges:N,edgeLookup:E,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:y,translateExtent:ns,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Zi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...sg},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:JS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:og,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},ek=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:x,nodeExtent:v,zIndexMode:m})=>f_((_,k)=>{async function b(){const{nodeLookup:E,panZoom:N,fitViewOptions:P,fitViewResolver:w,width:j,height:$,minZoom:z,maxZoom:B}=k();N&&(await a1({nodes:E,width:j,height:$,panZoom:N,minZoom:z,maxZoom:B},P),w==null||w.resolve(!0),_({fitViewResolver:null}))}return{...fp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:x,nodeExtent:v,defaultNodes:o,defaultEdges:s,zIndexMode:m}),setNodes:E=>{const{nodeLookup:N,parentLookup:P,nodeOrigin:w,nodeExtent:j,elevateNodesOnSelect:$,fitViewQueued:z,zIndexMode:B,nodesSelectionActive:G}=k(),{nodesInitialized:Q,hasSelectedNodes:ne}=dc(E,N,P,{nodeOrigin:w,nodeExtent:j,elevateNodesOnSelect:$,checkEquality:!0,zIndexMode:B}),ee=G&≠z&&Q?(b(),_({nodes:E,nodesInitialized:Q,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:ee})):_({nodes:E,nodesInitialized:Q,nodesSelectionActive:ee})},setEdges:E=>{const{connectionLookup:N,edgeLookup:P}=k();jg(N,P,E),_({edges:E})},setDefaultNodesAndEdges:(E,N)=>{if(E){const{setNodes:P}=k();P(E),_({hasDefaultNodes:!0})}if(N){const{setEdges:P}=k();P(N),_({hasDefaultEdges:!0})}},updateNodeInternals:E=>{const{triggerNodeChanges:N,nodeLookup:P,parentLookup:w,domNode:j,nodeOrigin:$,nodeExtent:z,debug:B,fitViewQueued:G,zIndexMode:Q}=k(),{changes:ne,updatedInternals:ee}=I1(E,P,w,j,$,z,Q);ee&&(E1(P,w,{nodeOrigin:$,nodeExtent:z,zIndexMode:Q}),G?(b(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(ne==null?void 0:ne.length)>0&&(B&&console.log("React Flow: trigger node changes",ne),N==null||N(ne)))},updateNodePositions:(E,N=!1)=>{const P=[];let w=[];const{nodeLookup:j,triggerNodeChanges:$,connection:z,updateConnection:B,onNodesChangeMiddlewareMap:G}=k();for(const[Q,ne]of E){const ee=j.get(Q),te=!!(ee!=null&&ee.expandParent&&(ee!=null&&ee.parentId)&&(ne!=null&&ne.position)),q={id:Q,type:"position",position:te?{x:Math.max(0,ne.position.x),y:Math.max(0,ne.position.y)}:ne.position,dragging:N};if(ee&&z.inProgress&&z.fromNode.id===ee.id){const C=mi(ee,z.fromHandle,Se.Left,!0);B({...z,from:C})}te&&ee.parentId&&P.push({id:Q,parentId:ee.parentId,rect:{...ne.internals.positionAbsolute,width:ne.measured.width??0,height:ne.measured.height??0}}),w.push(q)}if(P.length>0){const{parentLookup:Q,nodeOrigin:ne}=k(),ee=Pc(P,j,Q,ne);w.push(...ee)}for(const Q of G.values())w=Q(w);$(w)},triggerNodeChanges:E=>{const{onNodesChange:N,setNodes:P,nodes:w,hasDefaultNodes:j,debug:$}=k();if(E!=null&&E.length){if(j){const z=T_(E,w);P(z)}$&&console.log("React Flow: trigger node changes",E),N==null||N(E)}},triggerEdgeChanges:E=>{const{onEdgesChange:N,setEdges:P,edges:w,hasDefaultEdges:j,debug:$}=k();if(E!=null&&E.length){if(j){const z=L_(E,w);P(z)}$&&console.log("React Flow: trigger edge changes",E),N==null||N(E)}},addSelectedNodes:E=>{const{multiSelectionActive:N,edgeLookup:P,nodeLookup:w,triggerNodeChanges:j,triggerEdgeChanges:$}=k();if(N){const z=E.map(B=>ai(B,!0));j(z);return}j(Gi(w,new Set([...E]),!0)),$(Gi(P))},addSelectedEdges:E=>{const{multiSelectionActive:N,edgeLookup:P,nodeLookup:w,triggerNodeChanges:j,triggerEdgeChanges:$}=k();if(N){const z=E.map(B=>ai(B,!0));$(z);return}$(Gi(P,new Set([...E]))),j(Gi(w,new Set,!0))},unselectNodesAndEdges:({nodes:E,edges:N}={})=>{const{edges:P,nodes:w,nodeLookup:j,triggerNodeChanges:$,triggerEdgeChanges:z}=k(),B=E||w,G=N||P,Q=[];for(const ee of B){if(!ee.selected)continue;const te=j.get(ee.id);te&&(te.selected=!1),Q.push(ai(ee.id,!1))}const ne=[];for(const ee of G)ee.selected&&ne.push(ai(ee.id,!1));$(Q),z(ne)},setMinZoom:E=>{const{panZoom:N,maxZoom:P}=k();N==null||N.setScaleExtent([E,P]),_({minZoom:E})},setMaxZoom:E=>{const{panZoom:N,minZoom:P}=k();N==null||N.setScaleExtent([P,E]),_({maxZoom:E})},setTranslateExtent:E=>{var N;(N=k().panZoom)==null||N.setTranslateExtent(E),_({translateExtent:E})},resetSelectedElements:()=>{const{edges:E,nodes:N,triggerNodeChanges:P,triggerEdgeChanges:w,elementsSelectable:j}=k();if(!j)return;const $=N.reduce((B,G)=>G.selected?[...B,ai(G.id,!1)]:B,[]),z=E.reduce((B,G)=>G.selected?[...B,ai(G.id,!1)]:B,[]);P($),w(z)},setNodeExtent:E=>{const{nodes:N,nodeLookup:P,parentLookup:w,nodeOrigin:j,elevateNodesOnSelect:$,nodeExtent:z,zIndexMode:B}=k();E[0][0]===z[0][0]&&E[0][1]===z[0][1]&&E[1][0]===z[1][0]&&E[1][1]===z[1][1]||(dc(N,P,w,{nodeOrigin:j,nodeExtent:E,elevateNodesOnSelect:$,checkEquality:!1,zIndexMode:B}),_({nodeExtent:E}))},panBy:E=>{const{transform:N,width:P,height:w,panZoom:j,translateExtent:$}=k();return R1({delta:E,panZoom:j,transform:N,translateExtent:$,width:P,height:w})},setCenter:async(E,N,P)=>{const{width:w,height:j,maxZoom:$,panZoom:z}=k();if(!z)return!1;const B=typeof(P==null?void 0:P.zoom)<"u"?P.zoom:$;return await z.setViewport({x:w/2-E*B,y:j/2-N*B,zoom:B},{duration:P==null?void 0:P.duration,ease:P==null?void 0:P.ease,interpolate:P==null?void 0:P.interpolate}),!0},cancelConnection:()=>{_({connection:{...sg}})},updateConnection:E=>{_({connection:E})},reset:()=>_({...fp()})}},Object.is);function fm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:y,nodeOrigin:x,nodeExtent:v,zIndexMode:m,children:_}){const[k]=L.useState(()=>ek({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:y,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:x,nodeExtent:v,zIndexMode:m}));return d.jsx(h_,{value:k,children:d.jsx(O_,{children:d.jsx(eS,{children:_})})})}function tk({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:y,maxZoom:x,nodeOrigin:v,nodeExtent:m,zIndexMode:_}){return L.useContext(Zl)?d.jsx(d.Fragment,{children:t}):d.jsx(fm,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:y,initialMaxZoom:x,nodeOrigin:v,nodeExtent:m,zIndexMode:_,children:t})}const nk={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function rk({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:y,onMove:x,onMoveStart:v,onMoveEnd:m,onConnect:_,onConnectStart:k,onConnectEnd:b,onClickConnectStart:E,onClickConnectEnd:N,onNodeMouseEnter:P,onNodeMouseMove:w,onNodeMouseLeave:j,onNodeContextMenu:$,onNodeDoubleClick:z,onNodeDragStart:B,onNodeDrag:G,onNodeDragStop:Q,onNodesDelete:ne,onEdgesDelete:ee,onDelete:te,onSelectionChange:q,onSelectionDragStart:C,onSelectionDrag:V,onSelectionDragStop:W,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:F,connectionMode:R,connectionLineType:A=Lr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:Z=!1,selectionMode:se=rs.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:ke=ss()?"Meta":"Control",zoomActivationKeyCode:ve=ss()?"Meta":"Control",snapToGrid:re,snapGrid:Ne,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Te,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,nodeOrigin:Ge=Dg,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt=!0,defaultViewport:mt=b_,minZoom:Pt=.5,maxZoom:ut=2,translateExtent:Je=ns,preventScrolling:An=!0,nodeExtent:Ot,defaultMarkerColor:xn="#b1b1b7",zoomOnScroll:io=!0,zoomOnPinch:$n=!0,panOnScroll:vi=!1,panOnScrollSpeed:or=.5,panOnScrollMode:$r=di.Free,zoomOnDoubleClick:zn=!0,panOnDrag:zr=!0,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn=1,nodeClickDistance:Fn=0,children:_n,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn=10,onNodesChange:Ht,onEdgesChange:Or,noDragClassName:nn="nodrag",noWheelClassName:Fr="nowheel",noPanClassName:yt="nopan",fitView:Hn,fitViewOptions:ur,connectOnClick:oo,attributionPosition:It,proOptions:Bn,defaultEdgeOptions:Hr,elevateNodesOnSelect:jn=!0,elevateEdgesOnSelect:Br=!1,disableKeyboardA11y:xi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:so,autoPanOnSelection:Vr=!0,autoPanSpeed:wi,connectionRadius:cr,isValidConnection:lo,onError:dr,style:Vn,id:bt,nodeDragThreshold:Wr,connectionDragThreshold:Et,viewport:ao,onViewportChange:Ur,width:Yr,height:Wn,colorMode:Un="light",debug:bn,onScroll:Bt,ariaLabelConfig:_i,zIndexMode:Gr="basic",...fr},hr){const Yn=bt||"1",En=P_(Un),uo=L.useCallback(pr=>{pr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Bt==null||Bt(pr)},[Bt]);return d.jsx("div",{"data-testid":"rf__wrapper",...fr,onScroll:uo,style:{...Vn,...nk},ref:hr,className:nt(["react-flow",a,En]),id:bt,role:"application",children:d.jsxs(tk,{nodes:t,edges:r,width:Yr,height:Wn,fitView:Hn,fitViewOptions:ur,minZoom:Pt,maxZoom:ut,nodeOrigin:Ge,nodeExtent:Ot,zIndexMode:Gr,children:[d.jsx(M_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:k,onConnectEnd:b,onClickConnectStart:E,onClickConnectEnd:N,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt,elevateNodesOnSelect:jn,elevateEdgesOnSelect:Br,minZoom:Pt,maxZoom:ut,nodeExtent:Ot,onNodesChange:Ht,onEdgesChange:Or,snapToGrid:re,snapGrid:Ne,connectionMode:R,translateExtent:Je,connectOnClick:oo,defaultEdgeOptions:Hr,fitView:Hn,fitViewOptions:ur,onNodesDelete:ne,onEdgesDelete:ee,onDelete:te,onNodeDragStart:B,onNodeDrag:G,onNodeDragStop:Q,onSelectionDrag:V,onSelectionDragStart:C,onSelectionDragStop:W,onMove:x,onMoveStart:v,onMoveEnd:m,noPanClassName:yt,nodeOrigin:Ge,rfId:Yn,autoPanOnConnect:Ve,autoPanOnNodeDrag:so,autoPanSpeed:wi,onError:dr,connectionRadius:cr,isValidConnection:lo,selectNodesOnDrag:Te,nodeDragThreshold:Wr,connectionDragThreshold:Et,onBeforeDelete:F,debug:bn,ariaLabelConfig:_i,zIndexMode:Gr}),d.jsx(ZS,{onInit:y,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:P,onNodeMouseMove:w,onNodeMouseLeave:j,onNodeContextMenu:$,onNodeDoubleClick:z,nodeTypes:u,edgeTypes:c,connectionLineType:A,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:Z,selectionMode:se,deleteKeyCode:he,multiSelectionKeyCode:ke,panActivationKeyCode:me,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:mt,translateExtent:Je,minZoom:Pt,maxZoom:ut,preventScrolling:An,zoomOnScroll:io,zoomOnPinch:$n,zoomOnDoubleClick:zn,panOnScroll:vi,panOnScrollSpeed:or,panOnScrollMode:$r,panOnDrag:zr,autoPanOnSelection:Vr,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn,nodeClickDistance:Fn,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn,defaultMarkerColor:xn,noDragClassName:nn,noWheelClassName:Fr,noPanClassName:yt,rfId:Yn,disableKeyboardA11y:xi,nodeExtent:Ot,viewport:ao,onViewportChange:Ur,nodesDraggable:$e}),d.jsx(j_,{onSelectionChange:q}),_n,d.jsx(w_,{proOptions:Bn,position:It}),d.jsx(x_,{rfId:Yn,disableKeyboardA11y:xi})]})})}var ik=Fg(rk);function ok({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:nt(["react-flow__background-pattern",o,s])})}function sk({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:nt(["react-flow__background-pattern","dots",r])})}var Ar;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Ar||(Ar={}));const lk={[Ar.Dots]:1,[Ar.Lines]:1,[Ar.Cross]:6},ak=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function hm({id:t,variant:r=Ar.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:y,patternClassName:x}){const v=L.useRef(null),{transform:m,patternId:_}=De(ak,Qe),k=s||lk[r],b=r===Ar.Dots,E=r===Ar.Cross,N=Array.isArray(o)?o:[o,o],P=[N[0]*m[2]||1,N[1]*m[2]||1],w=k*m[2],j=Array.isArray(u)?u:[u,u],$=E?[w,w]:P,z=[j[0]*m[2]+$[0]/2,j[1]*m[2]+$[1]/2],B=`${_}${t||""}`;return d.jsxs("svg",{className:nt(["react-flow__background",y]),style:{...p,...ta,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:v,"data-testid":"rf__background",children:[d.jsx("pattern",{id:B,x:m[0]%P[0],y:m[1]%P[1],width:P[0],height:P[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${z[0]},-${z[1]})`,children:b?d.jsx(sk,{radius:w/2,className:x}):d.jsx(ok,{dimensions:$,lineWidth:a,variant:r,className:x})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${B})`})]})}hm.displayName="Background";const uk=L.memo(hm);function ck(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function fk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 hk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 pk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 Nl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:nt(["react-flow__controls-button",r]),...o,children:t})}const gk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function pm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:y,children:x,position:v="bottom-left",orientation:m="vertical","aria-label":_}){const k=Ye(),{isInteractive:b,minZoomReached:E,maxZoomReached:N,ariaLabelConfig:P}=De(gk,Qe),{zoomIn:w,zoomOut:j,fitView:$}=ea(),z=()=>{w(),u==null||u()},B=()=>{j(),c==null||c()},G=()=>{$(a),h==null||h()},Q=()=>{k.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),p==null||p(!b)},ne=m==="horizontal"?"horizontal":"vertical";return d.jsxs(Jl,{className:nt(["react-flow__controls",ne,y]),position:v,style:t,"data-testid":"rf__controls","aria-label":_??P["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(Nl,{onClick:z,className:"react-flow__controls-zoomin",title:P["controls.zoomIn.ariaLabel"],"aria-label":P["controls.zoomIn.ariaLabel"],disabled:N,children:d.jsx(ck,{})}),d.jsx(Nl,{onClick:B,className:"react-flow__controls-zoomout",title:P["controls.zoomOut.ariaLabel"],"aria-label":P["controls.zoomOut.ariaLabel"],disabled:E,children:d.jsx(dk,{})})]}),o&&d.jsx(Nl,{className:"react-flow__controls-fitview",onClick:G,title:P["controls.fitView.ariaLabel"],"aria-label":P["controls.fitView.ariaLabel"],children:d.jsx(fk,{})}),s&&d.jsx(Nl,{className:"react-flow__controls-interactive",onClick:Q,title:P["controls.interactive.ariaLabel"],"aria-label":P["controls.interactive.ariaLabel"],children:b?d.jsx(pk,{}):d.jsx(hk,{})}),x]})}pm.displayName="Controls";const mk=L.memo(pm);function yk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:y,borderRadius:x,shapeRendering:v,selected:m,onClick:_}){const{background:k,backgroundColor:b}=u||{},E=c||k||b;return d.jsx("rect",{className:nt(["react-flow__minimap-node",{selected:m},y]),x:r,y:o,rx:x,ry:x,width:s,height:a,style:{fill:E,stroke:h,strokeWidth:p},shapeRendering:v,onClick:_?N=>_(N,t):void 0})}const vk=L.memo(yk),xk=t=>t.nodes.map(r=>r.id),qu=t=>t instanceof Function?t:()=>t;function wk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=vk,onClick:c}){const h=De(xk,Qe),p=qu(r),y=qu(t),x=qu(o),v=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(m=>d.jsx(Sk,{id:m,nodeColorFunc:p,nodeStrokeColorFunc:y,nodeClassNameFunc:x,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:v},m))})}function _k({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:y,x,y:v,width:m,height:_}=De(k=>{const b=k.nodeLookup.get(t);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const E=b.internals.userNode,{x:N,y:P}=b.internals.positionAbsolute,{width:w,height:j}=vn(E);return{node:E,x:N,y:P,width:w,height:j}},Qe);return!y||y.hidden||!pg(y)?null:d.jsx(h,{x,y:v,width:m,height:_,style:y.style,selected:!!y.selected,className:s(y),color:r(y),borderRadius:a,strokeColor:o(y),strokeWidth:u,shapeRendering:c,onClick:p,id:y.id})}const Sk=L.memo(_k);var kk=L.memo(wk);const Nk=200,jk=150,bk=t=>!t.hidden,Ek=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?dg(hs(t.nodeLookup,{filter:bk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},hp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,Ck=(t,r)=>hp(t.viewBB,r.viewBB)&&hp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,Mk="react-flow__minimap-desc";function gm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:y,maskStrokeColor:x,maskStrokeWidth:v,position:m="bottom-right",onClick:_,onNodeClick:k,pannable:b=!1,zoomable:E=!1,ariaLabel:N,inversePan:P,zoomStep:w=1,offsetScale:j=5}){const $=Ye(),z=L.useRef(null),{boundingRect:B,viewBB:G,rfId:Q,panZoom:ne,translateExtent:ee,flowWidth:te,flowHeight:q,ariaLabelConfig:C}=De(Ek,Ck),V=(t==null?void 0:t.width)??Nk,W=(t==null?void 0:t.height)??jk,U=B.width/V,M=B.height/W,D=Math.max(U,M),F=D*V,R=D*W,A=j*D,ie=B.x-(F-B.width)/2-A,oe=B.y-(R-B.height)/2-A,fe=F+A*2,he=R+A*2,pe=`${Mk}-${Q}`,Z=L.useRef(0),se=L.useRef();Z.current=D,L.useEffect(()=>{if(z.current&&ne)return se.current=H1({domNode:z.current,panZoom:ne,getTransform:()=>$.getState().transform,getViewScale:()=>Z.current}),()=>{var re;(re=se.current)==null||re.destroy()}},[ne]),L.useEffect(()=>{var re;(re=se.current)==null||re.update({translateExtent:ee,width:te,height:q,inversePan:P,pannable:b,zoomStep:w,zoomable:E})},[b,E,P,w,ee,te,q]);const me=_?re=>{var Te;const[Ne,Me]=((Te=se.current)==null?void 0:Te.pointer(re))||[0,0];_(re,{x:Ne,y:Me})}:void 0,ke=k?L.useCallback((re,Ne)=>{const Me=$.getState().nodeLookup.get(Ne).internals.userNode;k(re,Me)},[]):void 0,ve=N??C["minimap.ariaLabel"];return d.jsx(Jl,{position:m,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof y=="string"?y:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof v=="number"?v*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:nt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:V,height:W,viewBox:`${ie} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:z,onClick:me,children:[ve&&d.jsx("title",{id:pe,children:ve}),d.jsx(kk,{onClick:ke,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-A},${oe-A}h${fe+A*2}v${he+A*2}h${-fe-A*2}z - M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}gm.displayName="MiniMap";const Pk=L.memo(gm),Ik=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Rk={[to.Line]:"right",[to.Handle]:"bottom-right"};function Tk({nodeId:t,position:r,variant:o=to.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:y=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:v=!1,resizeDirection:m,autoScale:_=!0,shouldResize:k,onResizeStart:b,onResize:E,onResizeEnd:N}){const P=Ug(),w=typeof t=="string"?t:P,j=Ye(),$=L.useRef(null),z=o===to.Handle,B=De(L.useCallback(Ik(z&&_),[z,_]),Qe),G=L.useRef(null),Q=r??Rk[o];L.useEffect(()=>{if(!(!$.current||!w))return G.current||(G.current=e_({domNode:$.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:ee,transform:te,snapGrid:q,snapToGrid:C,nodeOrigin:V,domNode:W}=j.getState();return{nodeLookup:ee,transform:te,snapGrid:q,snapToGrid:C,nodeOrigin:V,paneDomNode:W}},onChange:(ee,te)=>{const{triggerNodeChanges:q,nodeLookup:C,parentLookup:V,nodeOrigin:W}=j.getState(),U=[],M={x:ee.x,y:ee.y},D=C.get(w);if(D&&D.expandParent&&D.parentId){const F=D.origin??W,R=ee.width??D.measured.width??0,A=ee.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:R,height:A,...gg({x:ee.x??D.position.x,y:ee.y??D.position.y},{width:R,height:A},D.parentId,C,F)}},oe=Pc([ie],C,V,W);U.push(...oe),M.x=ee.x?Math.max(F[0]*R,ee.x):void 0,M.y=ee.y?Math.max(F[1]*A,ee.y):void 0}if(M.x!==void 0&&M.y!==void 0){const F={id:w,type:"position",position:{...M}};U.push(F)}if(ee.width!==void 0&&ee.height!==void 0){const R={id:w,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:ee.width,height:ee.height}};U.push(R)}for(const F of te){const R={...F,type:"position"};U.push(R)}q(U)},onEnd:({width:ee,height:te})=>{const q={id:w,type:"dimensions",resizing:!1,dimensions:{width:ee,height:te}};j.getState().triggerNodeChanges([q])}})),G.current.update({controlPosition:Q,boundaries:{minWidth:h,minHeight:p,maxWidth:y,maxHeight:x},keepAspectRatio:v,resizeDirection:m,onResizeStart:b,onResize:E,onResizeEnd:N,shouldResize:k}),()=>{var ee;(ee=G.current)==null||ee.destroy()}},[Q,h,p,y,x,v,b,E,N,k]);const ne=Q.split("-");return d.jsx("div",{className:nt(["react-flow__resize-control","nodrag",...ne,o,s]),ref:$,style:{...a,scale:B,...c&&{[z?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Tk);const Lk={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function ra(t){return Lk[t]??8}const Bl=208,as=64,Ak=88,$k=28,zk=8;function Dk(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function mm(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const N of t){const P=ra(N.type),w=s.get(P)??[];w.push(N),s.set(P,w)}const u=[...s.keys()].sort((N,P)=>N-P).map(N=>[...s.get(N)??[]].sort((P,w)=>P.name.localeCompare(w.name)||P.id.localeCompare(w.id))),c=new Set(t.map(N=>N.id)),h=new Map,p=new Map;for(const N of t)h.set(N.id,[]),p.set(N.id,[]);for(const N of r)!c.has(N.src)||!c.has(N.dst)||N.src===N.dst||(p.get(N.src).push(N.dst),h.get(N.dst).push(N.src));const y=new Map;u.forEach((N,P)=>{for(const w of N)y.set(w.id,P)});const x=new Map,v=()=>{for(const N of u)N.forEach((P,w)=>x.set(P.id,w))};v();const m=(N,P)=>{const w=N.map((j,$)=>{const z=P(j.id).map(G=>x.get(G)).filter(G=>G!==void 0),B=Dk(z);return{n:j,bary:Number.isNaN(B)?$:B,name:j.name,id:j.id}});return w.sort((j,$)=>j.bary-$.bary||j.name.localeCompare($.name)||j.id.localeCompare($.id)),w.map(j=>j.n)},_=N=>P=>y.get(P)===N;for(let N=0;N(h.get(w)??[]).filter(_(P-1))),v();for(let P=u.length-2;P>=0;P--)u[P]=m(u[P],w=>(p.get(w)??[]).filter(_(P+1))),v()}const k=Bl+Ak,b=as+$k,E=Math.max(...u.map(N=>N.length),1);return u.forEach((N,P)=>{const w=(E-N.length)*b/2;N.forEach((j,$)=>{o.set(j.id,{x:P*k,y:w+$*b})})}),o}const Ok=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),ym=90,Fk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),pp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Hk=Math.PI*(3-Math.sqrt(5)),vm=220,Bk=26,Vk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function xm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function FN(t){return pp[t]?pp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Wk(t){return t>=ym?"3d":"2d"}function Uk(t){return t>=ym?"overview":"full"}function Yk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(xm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Fk.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Yk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Xk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function qk(t,r,o,s){const a=new Set(t.map(b=>b.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const b of r){if(!a.has(b.src)||!a.has(b.dst))continue;const E=u.get(b.src)??[];E.push({dst:b.dst,id:b.id}),u.set(b.src,E);const N=c.get(b.dst)??[];N.push({src:b.src,id:b.id}),c.set(b.dst,N)}const h=new Set(t.filter(b=>Ok.has(b.type)).map(b=>b.id)),p=h.size?h:a,y=new Set,x=[o];for(;x.length;){const b=x.pop();if(!y.has(b)){y.add(b);for(const E of u.get(b)??[])y.has(E.dst)||x.push(E.dst)}}const v=new Set([o]),m=[...p].filter(b=>y.has(b)),_=new Set(m);for(;m.length;){const b=m.pop();v.add(b);for(const E of c.get(b)??[])y.has(E.src)&&!_.has(E.src)&&(_.add(E.src),m.push(E.src))}const k=new Set;for(const b of r)v.has(b.src)&&v.has(b.dst)&&k.add(b.id);return{nodeIds:v,edgeIds:k}}function HN(t){const r=new Map;for(const s of t){const a=ra(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*vm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Bk*Math.sqrt(h+1),y=h*Hk;o.set(c.id,{x:u,y:p*Math.cos(y),z:p*Math.sin(y)})})}return o}function BN(t){const r=new Map;for(const o of t){const s=ra(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*vm,count:s}))}const jl=16,Kk=12,Qk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Zk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),gp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Jk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},mp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],yp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),eN=new Set(["looks_idempotent_on_pk","null","blank"]),tN=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function nN(t){return gp[t]?gp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function rN(t,r,o){const s=new Map(r.map(m=>[m.id,m])),a=[];Qk.has(t.type)&&a.push("sink"),Zk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(m=>m.dst===t.id),h=o.filter(m=>m.src===t.id),p=c.slice(0,jl).map(m=>bl(m,s,m.src)),y=h.slice(0,jl).map(m=>bl(m,s,m.dst)),x=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,v={type:t.type,typeLabel:Qo(ro(t.type)),layer:Vk[ra(t.type)]??"other",purpose:nN(t.type),name:t.name,qualifiedName:t.qualified_name,file:x,context:t.context,roles:a,facts:oN(u).filter(m=>!(m.key==="app"&&m.value===t.context)),inputs:p,outputs:y,extraInputs:Math.max(0,c.length-jl),extraOutputs:Math.max(0,h.length-jl),degreeIn:c.length,degreeOut:h.length,inputKinds:vp(c.map(m=>bl(m,s,m.src))),outputKinds:vp(h.map(m=>bl(m,s,m.dst))),pathSummary:""};return v.pathSummary=iN(v),v}function vp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function iN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function bl(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Qo(ro(s.type)):"",edgeType:t.type,edgeLabel:Qo(t.type),inferred:t.confidence<.8}}function oN(t){const r=[...mp.filter(a=>a in t),...Object.keys(t).filter(a=>!mp.includes(a)&&!yp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||yp.has(a)||tN.has(a))continue;s.add(a);const u=sN(a,t[a]);u!=null&&o.push({key:a,label:Jk[a]??Qo(a),value:u})}return o}function sN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!eN.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return lN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Kk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function lN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const aN=12,xp=6,wp=.22,uN=.78;function cN(t,r,o){const s=o??mm(t,r),a=[];for(const h of r){const p=s.get(h.src),y=s.get(h.dst);if(!p||!y)continue;const x=p.y+as/2,v=y.y+as/2;if(Math.abs(x-v)${Math.round(_/8)}`})}const u=new Map;for(const h of a){const p=u.get(h.corridor)??[];p.push(h),u.set(h.corridor,p)}const c=new Map;for(const h of u.values()){const p=[...h].sort((m,_)=>m.y0-_.y0||m.y1-_.y1||m.id.localeCompare(_.id)),y=[],x=new Map;for(const m of p){let _=y.findIndex(k=>k.every(b=>!dN(m,b)));_<0&&(_=y.length,y.push([])),y[_].push(m),x.set(m.id,_)}const v=y.length;for(const m of h)c.set(m.id,fN(x.get(m.id)??0,v))}return c}function dN(t,r){return t.y0N0(()=>import("./LayeredGraph3D-C3jIpw-r.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),gN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function mN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(no,{type:"target",position:Se.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:ro(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Tr(t.name)}),d.jsx(no,{type:"source",position:Se.Right,isConnectable:!1})]})}const yN={load:mN},vN=new Set(["django","react","stitch","arch"]);function xN({topologyKey:t}){const{fitView:r}=ea();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function wN(t,r,o=null,s={}){const a=new Map(t.map(y=>[y.id,y])),u=mm(t,r),c=cN(t,r,u),h=t.map(y=>{var m;const x=((m=s.roles)==null?void 0:m[y.id])||[],v=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:y.id,type:"load",position:u.get(y.id)??{x:0,y:0},data:{name:y.name,type:y.type,file:y.file_path,roles:x,dim:v},selected:o===y.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:Bl,height:as,style:{width:Bl,height:as}}}),p=r.filter(y=>a.has(y.src)&&a.has(y.dst)).map(y=>{const x=gN[y.weight]||"var(--edge-cheap)",v=!!(o&&(y.src===o||y.dst===o));return{id:y.id,source:y.src,target:y.dst,type:"smoothstep",animated:y.weight==="critical",pathOptions:{borderRadius:8,stepPosition:c.get(y.id)??.5},style:{stroke:x,strokeWidth:y.weight==="critical"?2.4:1.2,strokeDasharray:y.confidence<.8?"6 4":void 0},markerEnd:{type:is.ArrowClosed,width:14,height:14,color:x},label:v?y.type.replaceAll("_"," "):void 0,labelStyle:v?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:v?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:v?[3,5]:void 0,labelBgBorderRadius:v?4:void 0}});return{rfNodes:h,rfEdges:p}}function _N({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:y}){const x=rN(t,r,o);return L.useEffect(()=>{const v=m=>{m.key==="Escape"&&s()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:x.typeLabel}),d.jsx("div",{className:"inspector-roles",children:x.roles.map(v=>d.jsx("span",{className:"inspector-chip",children:v},v))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Tr(x.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:x.purpose}),x.context?d.jsx("div",{className:"muted",children:Tr(x.context)}):null,x.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Tr(x.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Tr(x.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",x.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[x.degreeIn," in · ",x.degreeOut," out"]}),x.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:x.pathSummary}):null,x.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:x.facts.map(v=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:v.label}),d.jsx("dd",{children:Tr(v.value)})]},v.key))}):null,d.jsx(_p,{title:"Inputs",testId:"graph-inspector-inputs",links:x.inputs,extra:x.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(_p,{title:"Outputs",testId:"graph-inspector-outputs",links:x.outputs,extra:x.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),a?d.jsx("p",{className:"whatif-hint","data-testid":"whatif-hint",children:y?"Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map.":"Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."}):null,d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",title:"Start a hypothetical walk from this node. Does not use Base/Head.",onClick:()=>a(t.id),children:"What if this changes"}):null,y?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",title:"Hide nodes that are not on a path from here to a sink. Does not start a new walk.",onClick:()=>y(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function _p({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Ku({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:y,repoPath:x,onOpenFile:v,pinnedId:m,onPin:_}){const[k,b]=L.useState(null),E=a!==void 0?a:k,N=re=>{a===void 0&&b(re),u==null||u(re)},[P,w]=L.useState(null),[j,$]=L.useState(null),[z,B]=L.useState(new Set(vN)),[G,Q]=L.useState(!1),[ne,ee]=L.useState(""),[te,q]=L.useState(!1),C=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,V=P??Wk(t.length),W=j??Uk(t.length),U=G?E:null,M=L.useMemo(()=>p?qk(t,r,p):null,[t,r,p]),D=M?t.filter(re=>M.nodeIds.has(re.id)):t,F=M?r.filter(re=>M.edgeIds.has(re.id)):r,R=L.useMemo(()=>Gk(D,F,{detail:W,families:z,focusId:U,neighborhoodOnly:!!U}),[D,F,W,z,U]),A=L.useMemo(()=>`${R.nodes.map(re=>re.id).join("\0")}|${R.edges.map(re=>re.id).join("\0")}`,[R.nodes,R.edges]),ie=E?t.find(re=>re.id===E)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const re=wN(R.nodes,R.edges,E,{roles:c,testOverlay:h});return C&&(re.rfEdges=re.rfEdges.map(Ne=>({...Ne,animated:!1}))),re},[R.nodes,R.edges,E,C,c,h]);L.useEffect(()=>{if(!s)return;const re=t.find(Ne=>Ne.file_path===s);re&&N(re.id)},[s,t]);const he=L.useMemo(()=>Xk(t,ne),[t,ne]),pe=(re,Ne)=>{N(Ne.id)},Z=()=>{N(null),Q(!1)},se=ie?d.jsx(_N,{node:ie,nodes:t,edges:r,onClose:Z,onWhatIf:o,onSelect:N,onOpenFile:v,pinned:m===ie.id,onPin:_,onIsolate:y?re=>{y(p===re?null:re)}:void 0}):null,me=re=>{B(Ne=>{const Me=new Set(Ne);if(Me.has(re)){if(Me.size===1)return Ne;Me.delete(re)}else Me.add(re);return Me})},ke=L.useMemo(()=>{const re=new Set;for(const Ne of t)re.add(xm(Ne.type));return re},[t]),ve=t.length-R.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:V==="2d"?"active":"","aria-pressed":V==="2d",onClick:()=>w("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:V==="3d"?"active":"","aria-pressed":V==="3d",onClick:()=>w("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:W==="overview"?"active":"","aria-pressed":W==="overview",onClick:()=>$("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:W==="full"?"active":"","aria-pressed":W==="full",onClick:()=>$("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(re=>ke.has(re)).map(re=>d.jsx("button",{type:"button","data-testid":`graph-family-${re}`,className:z.has(re)?"active":"","aria-pressed":z.has(re),onClick:()=>me(re),children:re},re))}),d.jsx("button",{type:"button",className:G?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!E,onClick:()=>Q(re=>!re),children:G?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>y==null?void 0:y(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:ne,onChange:re=>{ee(re.target.value),q(!0)},onFocus:()=>q(!0),onBlur:()=>window.setTimeout(()=>q(!1),150)}),te&&ne.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(re=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:Ne=>Ne.preventDefault(),onClick:()=>{N(re.id),ee(""),q(!1)},children:[re.name,d.jsx("span",{className:"muted",children:ro(re.type)})]})},re.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[R.nodes.length," nodes · ",R.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:V==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(pN,{nodes:R.nodes,edges:R.edges,selectedId:E,neighborIds:U?R.neighborIds:hN,onSelect:re=>{N(re),re||Q(!1)}})}),se]}):d.jsxs(fm,{children:[d.jsxs(ik,{nodes:oe,edges:fe,nodeTypes:yN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:Z,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(xN,{topologyKey:A}),d.jsx(uk,{}),d.jsx(Pk,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(mk,{})]}),se]})})]})}function wm(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function SN(t){localStorage.setItem("loadpath.editor",t)}async function kN(t,r,o,s=wm()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const Sp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],NN=["preset","branch","tag","commit"];function jN(t){var a;if(!(t!=null&&t.git))return[...Sp];const r=((a=t.presets)!=null&&a.length?t.presets:Sp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function bN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function EN(t){return NN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function CN(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function kp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[y,x]=L.useState(!1),[v,m]=L.useState(null),[_,k]=L.useState(0),b=L.useMemo(()=>{const j=jN(u);return v===null?j:bN(j,v)},[u,v]),E=L.useMemo(()=>EN(b),[b]);L.useEffect(()=>{y&&c()},[y,c]),L.useEffect(()=>{k(0)},[v,y]);const N=()=>{x(!1),m(null)},P=j=>{r(j.value),N()},w=j=>{if(j.key==="ArrowDown"){if(j.preventDefault(),!y){x(!0);return}k($=>Math.min($+1,Math.max(b.length-1,0)))}else if(j.key==="ArrowUp"){if(j.preventDefault(),!y)return;k($=>Math.max($-1,0))}else if(j.key==="Enter"&&y){j.preventDefault();const $=b[_];$&&P($)}else j.key==="Escape"&&y&&(j.preventDefault(),N())};return d.jsxs("div",{className:"combo",ref:p,onBlur:j=>{j.currentTarget.contains(j.relatedTarget)||N()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":y,"aria-controls":h,"aria-autocomplete":"list",onChange:j=>{r(j.target.value),y&&m(j.target.value)},onKeyDown:w}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":y,onMouseDown:j=>j.preventDefault(),onClick:()=>y?N():x(!0),children:d.jsx(_0,{})})]}),y?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:E.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):E.map(j=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:CN(j.group)}),j.items.map($=>{const z=b.indexOf($);return d.jsxs("button",{type:"button",role:"option","aria-selected":z===_,className:z===_?"combo-option active":"combo-option","data-testid":`ref-option-${$.group}`,onMouseDown:B=>B.preventDefault(),onMouseEnter:()=>k(z),onClick:()=>P($),children:[d.jsx("span",{className:"combo-label",children:$.label}),$.detail?d.jsx("span",{className:"combo-detail",children:$.detail}):null]},`${$.group}:${$.value}`)})]},j.group))}):null]})}function MN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[y,x]=L.useState(""),[v,m]=L.useState(!1),_=L.useRef(null),k=L.useRef(0),b=async w=>{const j=k.current+1;k.current=j,m(!0);try{const $=await Pe.browse(w);if(k.current!==j)return;a($),c($.path),p($.is_git?$.path:null),x("")}catch($){if(k.current!==j)return;x($ instanceof Error?$.message:String($))}finally{k.current===j&&m(!1)}};L.useEffect(()=>{var w,j;b(t),(w=_.current)==null||w.focus(),(j=_.current)==null||j.select()},[t]);const E=h||(s==null?void 0:s.path)||u,N=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",P=w=>{w.key==="Escape"&&(w.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:P,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:w=>w.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:w=>{w.preventDefault(),b(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:w=>c(w.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void b(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void b(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),y?d.jsx("div",{className:"error",role:"alert",children:y}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":v,children:s!=null&&s.entries.length?s.entries.map(w=>{const j=h===w.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":j,className:j?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":w.path,onClick:()=>p(w.path),onDoubleClick:()=>void b(w.path),children:[d.jsx(Ep,{}),d.jsx("span",{className:"explorer-name",children:w.name}),w.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},w.path)}):d.jsx("div",{className:"muted explorer-empty",children:v?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:E,children:E}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!E,onClick:()=>E&&r(E),children:["Use ",N]})]})]})})}const PN={scan:{start:0,end:20},extract:{start:20,end:88},boot:{start:88,end:94},stitch:{start:94,end:99},skipped:{start:100,end:100},done:{start:100,end:100}},IN=new Set(["scan","extract","boot","stitch"]);function RN(t){const r=t.phase||"";if(!r||r==="idle")return null;const o=PN[r];if(!o)return null;if(o.start===o.end)return o.end;const s=t.total||0;if(s<=0)return o.start;const a=Math.min(1,Math.max(0,(t.done||0)/s));return Math.round(o.start+(o.end-o.start)*a)}function TN(t){return!t.phase||t.phase==="idle"?null:typeof t.percent=="number"&&Number.isFinite(t.percent)?Math.max(0,Math.min(100,Math.round(t.percent))):RN(t)}const Vl=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],LN="obsidian",_m="loadpath.theme";function AN(t){return Vl.some(r=>r.id===t)}function Sm(){try{const t=localStorage.getItem(_m)||"";if(AN(t))return t}catch{}return LN}function $N(t){var r;return((r=Vl.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function km(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=$N(t);try{localStorage.setItem(_m,t)}catch{}}const Qu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:m0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:y0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:v0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:x0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:w0}];function Zu(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function zN(){var co,fo,Si,ho,po,go,ki,Xr,rn,on;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,y]=L.useState(null),[x,v]=L.useState(null),[m,_]=L.useState(null),[k,b]=L.useState([]),[E,N]=L.useState("review"),[P,w]=L.useState(""),[j,$]=L.useState(""),[z,B]=L.useState(null),[G,Q]=L.useState(!1),[ne,ee]=L.useState(!1),[te,q]=L.useState(""),[C,V]=L.useState({}),[W,U]=L.useState([]),[M,D]=L.useState([]),[F,R]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[A,ie]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[oe,fe]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[he,pe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[Z,se]=L.useState(0),[me,ke]=L.useState(""),[ve,re]=L.useState(Sm),[Ne,Me]=L.useState(!1),[Te,$e]=L.useState(!1),[st,lt]=L.useState(!1),[at,Ge]=L.useState(null),[wt,qt]=L.useState(null),[gt,mt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[Pt,ut]=L.useState(null),[Je,An]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[Ot,xn]=L.useState([]),[io,$n]=L.useState(null),[vi,or]=L.useState(null),[$r,zn]=L.useState(null),[zr,sr]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[lr,Ft]=L.useState(null),[ct,Dn]=L.useState(null),[On,wn]=L.useState(!1),[Fn,_n]=L.useState(!1),rt=L.useRef(o);rt.current=o;const Dr=L.useRef(!1);Dr.current=Te;const _t=L.useRef(""),ar=L.useRef(""),Sn=I=>{re(I),km(I)},dt=L.useRef(""),He=I=>{dt.current=I,$(I)},kn=I=>{let Y=0,ce=!1;B(0);const je=()=>{Pe.indexProgress(I).then(Ie=>{if(!dt.current)return;if(Ie.phase&&Ie.phase!=="idle"&&Ie.message&&He(Ie.message),IN.has(Ie.phase))ce=!0;else if(!ce)return;const qr=TN(Ie);qr!=null&&(Ie.phase==="scan"&&!Ie.done?Y=qr:Y=Math.max(Y,qr),B(Y))}).catch(()=>{})};je();const Le=window.setInterval(je,250);return()=>{window.clearInterval(Le),B(null)}};L.useEffect(()=>{Pe.settings().then(V).catch(()=>{}).finally(()=>Me(!0)),Pe.repos().then(I=>b(I.repos)).catch(()=>{})},[]);const Nn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const I=o;let Y=!1;return ar.current!==I&&Bn(I),Pe.config(I).then(ce=>{!Y&&rt.current===I&&or(ce)}).catch(()=>{}),Pe.architectureHealth(I).then(ce=>{!Y&&rt.current===I&&zn(ce)}).catch(()=>{}),()=>{Y=!0}},[t,o]);const Ht=I=>{rt.current=I,s(I),localStorage.setItem("loadpath.repo",I),I.trim()!==_t.current&&(_t.current="",Ft(null))},Or=L.useCallback(I=>{const Y=(I??rt.current).trim();return!Y||_t.current===Y?Promise.resolve():(_t.current=Y,Pe.gitRefs(Y).then(ce=>{rt.current.trim()===Y&&Ft(ce)}).catch(()=>{_t.current===Y&&(_t.current="",Ft(null))}))},[]),nn=(I,Y)=>{u(I),h(Y),localStorage.setItem("loadpath.base",I),localStorage.setItem("loadpath.head",Y)},Fr=(I,Y,ce)=>{ie(I),R(Y),localStorage.setItem("loadpath.provider",I),localStorage.setItem("loadpath.scmRepo",Y),ce!==void 0&&(fe(ce),localStorage.setItem("loadpath.prNumber",ce))},yt=I=>{y(I),se(0),Ge(wt&&I.nodes.some(Y=>Y.id===wt)?wt:null),ut(null),$n(null),I.what_if||(v(I),I.id&&localStorage.setItem("loadpath.lastReviewId",I.id))},Hn=async I=>{try{const Y=await Pe.reviews(I);xn(Y.reviews)}catch{xn([])}},ur=async I=>{try{zn(await Pe.architectureHealth(I))}catch{zn(null)}},oo=I=>I==="github"?!!C.github_token_set:I==="gitlab"?!!C.gitlab_token_set:!!C.bitbucket_token_set,It=L.useCallback(async(I=A)=>{var Y;try{const ce=await Pe.scmRepos(I);D(ce.repos),(Y=ce.user)!=null&&Y.login&&V(je=>({...je,...I==="github"?{github_user:ce.user.login}:I==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{D([])}},[A]);L.useEffect(()=>{if(t!=="prs")return;let I=!1;return It(A).catch(()=>{I||D([])}),()=>{I=!0}},[t,A,It]),L.useEffect(()=>{if(!ct)return;let I=!1,Y=0;const ce=async()=>{try{const je=await Pe.githubOAuthPoll(ct.flow_id);if(I)return;if(je.status==="complete"){Dn(null);const Le=await Pe.settings();V(Le),q(je.user?`Signed in to GitHub as ${je.user}`:"Signed in to GitHub"),It("github");return}if(je.status==="pending"||je.status==="slow_down"){Y=window.setTimeout(ce,Math.max(je.interval||ct.interval,5)*1e3);return}Dn(null),w(je.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(je){if(I)return;Dn(null),w(je instanceof Error?je.message:String(je))}};return Y=window.setTimeout(ce,Math.max(ct.interval,5)*1e3),()=>{I=!0,window.clearTimeout(Y)}},[ct,It]),L.useEffect(()=>{if(!On)return;let I=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(I)return;if(Le.bitbucket.connected){wn(!1);const Ie=await Pe.settings();V(Ie),q(Le.bitbucket.user?`Signed in to Bitbucket as ${Le.bitbucket.user}`:"Signed in to Bitbucket"),It("bitbucket");return}if(Date.now()-ce>18e4){wn(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(I)return;wn(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{I=!0,window.clearTimeout(Y)}},[On,It]),L.useEffect(()=>{if(!Fn)return;let I=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(I)return;if(Le.gitlab.connected){_n(!1);const Ie=await Pe.settings();V(Ie),q(Le.gitlab.user?`Signed in to GitLab as ${Le.gitlab.user}`:"Signed in to GitLab"),It("gitlab");return}if(Date.now()-ce>18e4){_n(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(I)return;_n(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{I=!0,window.clearTimeout(Y)}},[Fn,It]);const Bn=async(I=o,Y=!1)=>{if(!I.trim())return null;ar.current=I,ee(!0);try{const ce=await Pe.architecture(I,!1);rt.current===I&&_(ce);const je=Pe.architectureGraph(I).then(Le=>{rt.current===I&&_(Ie=>Ie&&{...Ie,nodes:Le.nodes,edges:Le.edges,graph_pending:!1})});return je.catch(()=>{}).finally(()=>{rt.current===I&&ee(!1)}),Y&&await je,ce}catch(ce){throw rt.current===I&&ee(!1),ce}},Hr=async I=>{const Y=I.trim();if(!(!Y||Y===rt.current)){if(dt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),q(""),y(null),v(null),_(null),N("architecture"),Ht(Y),Q(!0),He(`Loading ${g0(Y)}…`);try{await Promise.all([Bn(Y),Or(Y)])}catch(ce){rt.current===Y&&w(ce instanceof Error?ce.message:String(ce))}finally{rt.current===Y&&(He(""),Q(!1))}}},jn=async()=>{if(dt.current||!Nn())return;w(""),q(""),He("Tracing load path…"),Ht(o),nn(a,c);const I=kn(o);try{const Y=await Pe.review(o,a,c,!0,he);yt(Y),N("review"),r("review"),await Pe.repos().then(ce=>b(ce.repos)).catch(()=>{}),await Promise.all([Bn(o),Hn(o),ur(o)])}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{I(),He("")}},Br=async(I=!0)=>{if(dt.current||!Nn())return;w(""),q(""),He(I?"Indexing…":"Full reindex…"),Ht(o);const Y=kn(o);try{await Pe.index(o,I);const ce=await Bn(o);await Pe.repos().then(je=>b(je.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(N("architecture"),r("architecture"))}catch(ce){w(ce instanceof Error?ce.message:String(ce))}finally{Y(),He("")}},xi=async()=>{if(!dt.current&&Nn()){w(""),q(""),He("Detecting layout…"),Ht(o);try{const I=await Pe.init(o);q(I.message),await Pe.repos().then(Y=>b(Y.repos)).catch(()=>{})}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},Ve=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),q("Copied markdown brief")}catch(I){w(I instanceof Error?I.message:String(I))}},so=async()=>{if(!dt.current){if(p!=null&&p.what_if){w("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first.");return}if(!(p!=null&&p.markdown)||!F||!oe){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const I=await Pe.postComment(A,F,Number(oe),p.markdown);q(I.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},Vr=async()=>{if(!dt.current){w(""),He("Fetching pull requests…");try{const I=await Pe.prs(A,F,"open",o.trim()||void 0);U(I.pull_requests);const Y=M.find(ce=>ce.slug.toLowerCase()===F.trim().toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path)}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},wi=async()=>{w("");try{const I=await Pe.githubOAuthStart();Dn(I),Zu(I.verification_uri_complete,"github.com","/login/device")}catch(I){w(I instanceof Error?I.message:String(I))}},cr=async()=>{w("");try{const I=await Pe.bitbucketOAuthStart();wn(!0),Zu(I.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(I){wn(!1),w(I instanceof Error?I.message:String(I))}},lo=async()=>{w("");try{const I=await Pe.gitlabOAuthStart();_n(!0),Zu(I.authorize_url,new URL(I.authorize_url).hostname,"/oauth/authorize")}catch(I){_n(!1),w(I instanceof Error?I.message:String(I))}},dr=async I=>{if(!(dt.current||!o.trim())){w(""),He("Walking what-if path…");try{const Y=await Pe.whatIf(o,I);q(`${Y.title} — ${Y.confidence.level} · ${(Y.sinks||[]).length} sinks`),yt({...Y,markdown:Y.markdown||"",index:Y.index||(p==null?void 0:p.index),workspace:Y.workspace||(p==null?void 0:p.workspace)}),N("review"),r("review")}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},Vn=()=>{if(x){yt(x),N("review"),r("review"),q("Restored the last git-range walk");return}y(null),se(0),Ge(null),ut(null),$n(null),N("architecture"),r("architecture"),q("")},bt=async I=>{var Le;if(dt.current)return;Fr(I.provider,I.repo,String(I.number));const Y=M.find(Ie=>Ie.slug.toLowerCase()===I.repo.toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path),w(""),He(`Fetching ${I.provider} #${I.number}…`);const ce=(Y==null?void 0:Y.local_path)||o,je=ce?kn(ce):()=>{};try{const Ie=await Pe.reviewPr(I.provider,I.repo,I.number,(Y==null?void 0:Y.local_path)||o||void 0);yt(Ie),Ie.pull_request&&typeof Ie.pull_request.repo_path=="string"&&Ht(Ie.pull_request.repo_path),nn(String(Ie.base||I.target_branch),String(Ie.head||I.source_branch)),N("review"),r("review"),typeof((Le=Ie.pull_request)==null?void 0:Le.repo_path)=="string"&&Hn(Ie.pull_request.repo_path)}catch(Ie){nn(I.base_sha||I.target_branch,I.head_sha||I.source_branch),r("review"),w(Ie instanceof Error?Ie.message:String(Ie))}finally{je(),He("")}},Wr=async I=>{w("");try{V(await Pe.oauthDisconnect(I)),A===I&&D([]),q(`Disconnected ${I}`)}catch(Y){w(Y instanceof Error?Y.message:String(Y))}},Et=async I=>{I.preventDefault();const Y=new FormData(I.currentTarget),ce={github_token:String(Y.get("github_token")||""),github_oauth_client_id:String(Y.get("github_oauth_client_id")||""),github_host:String(Y.get("github_host")||""),gitlab_token:String(Y.get("gitlab_token")||""),gitlab_host:String(Y.get("gitlab_host")||""),gitlab_oauth_client_id:String(Y.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(Y.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(Y.get("bitbucket_token")||""),bitbucket_username:String(Y.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(Y.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(Y.get("bitbucket_oauth_client_secret")||""),ai_provider:String(Y.get("ai_provider")||"none"),ai_api_key:String(Y.get("ai_api_key")||""),ai_model:String(Y.get("ai_model")||""),ai_base_url:String(Y.get("ai_base_url")||"")},je=k.length?{...ce,workspaces:k.map(Le=>({path:Le.path,name:Le.name}))}:ce;try{V(await Pe.saveSettings(je)),q("Settings saved on this machine")}catch(Le){w(Le instanceof Error?Le.message:String(Le))}},ao=async()=>{if(!(!p||dt.current)){He("Residual analysis…");try{const I=await Pe.residual(p);ke(I.note)}catch(I){w(I instanceof Error?I.message:String(I))}finally{He("")}}},Ur=L.useRef(jn);Ur.current=jn;const Yr=L.useRef(t);Yr.current=t;const Wn=L.useRef(!1);Wn.current=st;const Un=L.useRef(p);Un.current=p;const bn=L.useRef(Z);bn.current=Z,L.useEffect(()=>{const I=localStorage.getItem("loadpath.lastReviewId"),Y=(localStorage.getItem("loadpath.repo")||"").trim();if(!I||!Y){sr(!1);return}let ce=!1;return Pe.getReview(Y,I).then(je=>{ce||(yt(je),nn(je.base||localStorage.getItem("loadpath.base")||"HEAD~1",je.head||localStorage.getItem("loadpath.head")||"HEAD"),Hn(Y),ur(Y))}).catch(()=>{}).finally(()=>{ce||sr(!1)}),()=>{ce=!0}},[]);const Bt=L.useRef("");L.useEffect(()=>{if(!Je||!o.trim())return;let I=!1;const Y=async()=>{try{const je=await Pe.workspaceStatus(o);if(I)return;Bt.current&&je.fingerprint!==Bt.current&&!dt.current&&(pe(!0),localStorage.setItem("loadpath.dirty","1"),Ur.current()),Bt.current=je.fingerprint}catch{}};Y();const ce=window.setInterval(Y,2e3);return()=>{I=!0,window.clearInterval(ce)}},[Je,o]),L.useEffect(()=>{const I=Y=>{var Le;if((Y.metaKey||Y.ctrlKey)&&Y.key.toLowerCase()==="k"){Y.preventDefault(),lt(Ie=>!Ie);return}if(Wn.current){Y.key==="Escape"&&(Y.preventDefault(),lt(!1));return}if(Dr.current){Y.key==="Escape"&&(Y.preventDefault(),$e(!1));return}const ce=Y.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){Y.key==="Escape"&&ce.blur();return}if(Y.key==="Escape"){w(""),q(""),Ge(wt),ut(null);return}if(Y.key==="j"||Y.key==="k"){const Ie=((Le=Un.current)==null?void 0:Le.read_order)||[];if(!Ie.length)return;Y.preventDefault();const Gn=bn.current,qr=Y.key==="j"?Math.min(Ie.length-1,Gn+1):Math.max(0,Gn-1);se(qr);return}const je=Qu.find(Ie=>Ie.shortcut===Y.key);if(je&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey&&r(je.id),(Y.metaKey||Y.ctrlKey)&&Y.key==="Enter"){if(Yr.current==="settings"||Yr.current==="prs"||dt.current)return;Y.preventDefault(),Ur.current()}};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[wt]);const _i=async(I,Y)=>{if(!o.trim())return;const ce=await kN(o,I,Y);ce.ok?q(ce.message):w(ce.message)},Gr=async()=>{if(p)try{const I=await Pe.exportHtml(p),Y=URL.createObjectURL(I),ce=document.createElement("a");ce.href=Y,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(Y),q("Saved HTML brief")}catch(I){w(I instanceof Error?I.message:String(I))}},fr=async I=>{if(o.trim()){He("Loading stored review…");try{const Y=await Pe.getReview(o,I);yt(Y),nn(Y.base||a,Y.head||c),N("review"),r("review");const ce=Ot.find(je=>je.id!==I);if(ce)try{$n(await Pe.reviewDiff(o,I,ce.id))}catch{$n(null)}}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},hr={selectedId:at,onSelect:Ge,nodeRoles:p==null?void 0:p.node_roles,testOverlay:gt,isolateSource:Pt,onIsolate:ut,repoPath:o,onOpenFile:_i,pinnedId:wt,onPin:qt},Yn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},...p!=null&&p.what_if?[{id:"exit-whatif",group:"Review",label:x?"Back to git-range walk":"Exit what-if walk",run:Vn}]:[],{id:"index",group:"Run",label:"Index repository",run:()=>void Br(!0)},{id:"watch",group:"Run",label:Je?"Stop watching working tree":"Watch working tree",run:()=>{const I=!Je;An(I),localStorage.setItem("loadpath.watch",I?"1":"0")}},{id:"tests",group:"Graph",label:gt?"Hide test overlay":"Show test overlay",run:()=>{const I=!gt;mt(I),localStorage.setItem("loadpath.testOverlay",I?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Gr()},...Qu.map(I=>({id:`tab-${I.id}`,group:"Tabs",label:`Go to ${I.label}`,hint:I.shortcut,run:()=>r(I.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(I=>({id:`node-${I.id}`,group:"Nodes",label:I.name,hint:ro(I.type),run:()=>{Ge(I.id),r("graph")}})),...Ot.slice(0,12).map(I=>({id:`hist-${I.id}`,group:"History",label:I.title||I.id,hint:`${I.level||""} ${I.created_at||""}`.trim(),run:()=>void fr(I.id)}))],En=L.useMemo(()=>E==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[E,m,p]),uo=L.useMemo(()=>E==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[E,m,p]),pr=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Fe=((p==null?void 0:p.findings)||[]).filter(I=>!I.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Qu.map(I=>{const Y=I.icon,ce=t===I.id;return d.jsxs("button",{type:"button","data-testid":I.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":I.label,onClick:()=>r(I.id),children:[d.jsx(Y,{}),d.jsx("span",{children:I.label})]},I.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:ve,onChange:I=>Sn(I.target.value),children:["dark","light"].map(I=>d.jsx("optgroup",{label:I==="dark"?"Dark":"Light",children:Vl.filter(Y=>Y.group===I).map(Y=>d.jsx("option",{value:Y.id,children:Y.label},Y.id))},I))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:j||pr}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[j?d.jsxs("div",{className:z!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","aria-valuemin":z!=null?0:void 0,"aria-valuemax":z!=null?100:void 0,"aria-valuenow":z??void 0,"data-testid":"progress",children:[d.jsx("i",{style:z!=null?{width:`${z}%`}:void 0}),d.jsx("span",{className:"sr-only",children:j})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[k.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:k.some(I=>I.path===o)?o:"",disabled:!!j,"aria-busy":G,onChange:I=>{I.target.value&&Hr(I.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),k.map(I=>d.jsxs("option",{value:I.path,children:[I.name,I.indexed?` (${I.counts.nodes})`:""]},I.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:I=>{const Y=I.target.value;s(Y),Y.trim()!==_t.current&&(_t.current="",Ft(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>$e(!0),children:d.jsx(Ep,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(kp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:I=>nn(I,c),placeholder:"base",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(kp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:I=>nn(a,I),placeholder:"head",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:he?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":he,onClick:()=>{const I=!he;pe(I),localStorage.setItem("loadpath.dirty",I?"1":"0")},children:he?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:Je?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":Je,onClick:()=>{const I=!Je;An(I),localStorage.setItem("loadpath.watch",I?"1":"0")},children:Je?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.what_if?"what-if · ":"",p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!j,onClick:xi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!j,onClick:()=>Br(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!j,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[P?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:P}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,te?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:te}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>q(""),"aria-label":"Dismiss",children:"×"})]}):null,((co=p==null?void 0:p.index)!=null&&co.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((fo=p==null?void 0:p.index)==null?void 0:fo.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Si=p==null?void 0:p.index)==null?void 0:Si.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(ho=p==null?void 0:p.workspace)!=null&&ho.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,p!=null&&p.what_if?d.jsxs("div",{className:"banner whatif","data-testid":"whatif-banner",children:[d.jsxs("span",{children:["Hypothetical walk from"," ",d.jsx("strong",{children:((po=p.node)==null?void 0:po.name)||"this node"}),". Loadpath ignored Base/Head and asked which sinks would feel this node change — not a filter of the current map."]}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-exit-whatif",onClick:Vn,children:x?"Back to git range":"Back to architecture"})]}):null,G?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:j||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":G||ne,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(DN,{review:p,findings:Fe,aiNote:me,busy:!!j,tourIndex:Z,onTour:se,onAskAi:ao,onCopy:Ve,onPost:so,onSelect:Ge,onOpenFile:_i,onExport:Gr,history:Ot,diff:io,onReopen:fr,onWaiver:(I,Y)=>{o.trim()&&Pe.addWaiver(o,I,Y||void 0,"from review").then(ce=>{or(ce),q(`Waived ${I} in loadpath.yml`)})}}):zr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Ku,{nodes:p.nodes,edges:p.edges,onWhatIf:dr,focusPath:(go=p.read_order[Z])==null?void 0:go.path,...hr}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(ON,{architecture:m,busy:!!j,onReindex:()=>Br(!1),onReview:jn,onSelect:Ge,config:vi,health:$r,onSaveConfig:I=>{Pe.saveConfig(o,I).then(Y=>{or(Y),q("Wrote loadpath.yml")})},onWaiver:(I,Y,ce)=>{Pe.addWaiver(o,I,Y,ce).then(je=>{or(je),q(`Waived ${I}`)})}}):G?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(ne||m!=null&&m.graph_pending)&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(ki=m==null?void 0:m.counts)!=null&&ki.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Ku,{nodes:m.nodes,edges:m.edges,onWhatIf:dr,...hr,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":E==="review","data-testid":"graph-mode-review",className:E==="review"?"active":"",onClick:()=>N("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":E==="architecture","data-testid":"graph-mode-architecture",className:E==="architecture"?"active":"",onClick:()=>N("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:gt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":gt,onClick:()=>{const I=!gt;mt(I),localStorage.setItem("loadpath.testOverlay",I?"1":"0")},children:"Tests"})]}),En.length?d.jsx(Ku,{nodes:En,edges:uo,onWhatIf:dr,...hr}):ne||m!=null&&m.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:A,onChange:I=>Fr(I.target.value,F,oe),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:M.length?"Search your repos":"owner/repo",value:F,onChange:I=>Fr(A,I.target.value,oe),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:M.map(I=>d.jsxs("option",{value:I.slug,children:[I.private?"private":"public",I.local_path?" · local":""]},I.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!j||!oo(A),onClick:()=>{It(A)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!j,onClick:Vr,children:"List PRs"})]}),M.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[M.length," ",A," repositor",M.length===1?"y":"ies",A==="github"&&C.github_user?` · @${String(C.github_user)}`:"",A==="gitlab"&&C.gitlab_user?` · @${String(C.gitlab_user)}`:"",A==="bitbucket"&&C.bitbucket_user?` · ${String(C.bitbucket_user)}`:""]}):null,W.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):W.map(I=>{var Y;return d.jsxs("article",{className:"pr","data-testid":`pr-${I.number}`,children:[d.jsxs("h3",{children:["#",I.number," ",I.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${I.draft?"":"open"}`,children:I.draft?"draft":I.state}),d.jsx("span",{children:I.author}),d.jsxs("span",{children:[I.source_branch," → ",I.target_branch]}),I.loadpath?d.jsxs("span",{className:`chip ${I.loadpath.level||""}`,"data-testid":`pr-loadpath-${I.number}`,children:[((Y=I.loadpath.level)==null?void 0:Y.toUpperCase())||"REVIEWED",I.loadpath.contract_break&&I.loadpath.contract_break!=="none"?` · ${I.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:I.url,target:"_blank",rel:"noreferrer",children:["Open on ",I.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${I.number}`,onClick:()=>void bt(I),children:"Review this PR"})]})]},`${I.provider}-${I.number}`)})]}),t==="settings"&&Ne&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Et,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Vl.map(I=>d.jsxs("button",{type:"button","data-theme":I.id,className:ve===I.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${I.id}`,onClick:()=>Sn(I.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:I.label}),d.jsx("div",{className:"group",children:I.group})]},I.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:wm(),onChange:I=>SN(I.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:C.github_token_set?C.github_user?`Signed in as @${String(C.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void Wr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!ct||!C.github_oauth_ready,onClick:()=>void wi(),children:ct?"Waiting for GitHub…":"Sign in with GitHub"})})]}),ct?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:ct.user_code})," at GitHub if the browser did not fill it in."]}):null,C.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(C.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(C.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:C.gitlab_token_set?C.gitlab_user?`Signed in as @${String(C.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void Wr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Fn||!C.gitlab_oauth_ready,onClick:()=>void lo(),children:Fn?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(C.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(C.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:C.bitbucket_token_set?C.bitbucket_user?`Signed in as ${String(C.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void Wr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:On||!C.bitbucket_oauth_ready,onClick:()=>void cr(),children:On?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),C.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(C.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(C.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((Xr=C.ai)==null?void 0:Xr.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((rn=C.ai)==null?void 0:rn.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((on=C.ai)==null?void 0:on.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(f0,{open:st,actions:Yn,onClose:()=>lt(!1)}),Te?d.jsx(MN,{initialPath:o,onClose:()=>$e(!1),onSelect:I=>{if(dt.current){w("Wait for the current job to finish before switching workspace.");return}$e(!1),Hr(I)}}):null]})}function DN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:y,onOpenFile:x,onExport:v,history:m,diff:_,onReopen:k,onWaiver:b}){var N,P,w,j,$,z,B,G,Q,ne,ee,te,q,C,V,W,U;const E=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),E.length?d.jsx("ul",{className:"reasons",children:E.map(M=>d.jsx("li",{children:M},M))}):null,t.what_if?d.jsx("span",{className:"chip whatif","data-testid":"whatif-chip",children:"what-if"}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Qo(M)},M)),(N=t.contract_break)!=null&&N.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&y(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>b(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(P=t.workspace)!=null&&P.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>x(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&y(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(Nm,{cards:t.deepening}),(j=(w=t.contract_break)==null?void 0:w.reasons)!=null&&j.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),(z=($=t.contract_break.sides)==null?void 0:$.rows)!=null&&z.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(B=t.auth)!=null&&B.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(G=t.suggested_tests)==null?void 0:G.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(Q=t.trend)!=null&&Q.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",Ju(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),m.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:m.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,m.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>k(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?Ju(M.created_at):""})]},M.id))]}):null,(ee=(ne=t.evolution)==null?void 0:ne.notes)!=null&&ee.length||(q=(te=t.evolution)==null?void 0:te.hotspots)!=null&&q.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((C=t.evolution)==null?void 0:C.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((V=t.evolution)==null?void 0:V.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:v,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",disabled:s||!!t.what_if,title:t.what_if?"Hypothetical walks are not posted to a pull request":void 0,onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(W=t.codeowners_reviewers)!=null&&W.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function ON({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var x;const y=t.findings.filter(v=>!v.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${Ju(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(v=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:v.name})," — ",(v.django_apps||[]).join(", ")||"no apps"," ·"," ",(v.owners||[]).join(", ")||"unowned"]},v.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(v=>d.jsx("div",{className:"muted",children:v},v))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:y.length})]}),y.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):y.map(v=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>v.node_id&&a(v.node_id),children:[d.jsx("span",{className:`chip ${v.severity}`,children:v.severity}),v.message]})},v.rule+v.message))]}),d.jsx(Nm,{cards:t.deepening}),(x=c==null?void 0:c.points)!=null&&x.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(v=>d.jsx("i",{className:v.level||"",title:`${v.level} · ${v.findings} findings`,style:{height:`${8+Math.min(24,(v.findings||0)*4)}px`}},v.id||v.created_at))}),Object.entries(c.contexts).map(([v,m])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:v})," — last ",((_=m[m.length-1])==null?void 0:_.findings)??0," findings"]},v)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(h0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((v,m)=>m[1]-v[1]).slice(0,12).map(([v,m])=>d.jsxs("tr",{children:[d.jsx("td",{children:ro(v)}),d.jsx("td",{children:m})]},v))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function Nm({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:p0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}km(Sm());u0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(zN,{})}));export{Vk as L,BN as a,FN as c,d as j,HN as l,L as r,ro as t}; diff --git a/src/loadpath/static/assets/index-E4JBz9vY.js b/src/loadpath/static/assets/index-E4JBz9vY.js new file mode 100644 index 0000000..e0c626c --- /dev/null +++ b/src/loadpath/static/assets/index-E4JBz9vY.js @@ -0,0 +1,62 @@ +(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function kp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Tu={exports:{}},Wo={},Lu={exports:{}},Re={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var qf;function e0(){if(qf)return Re;qf=1;var t=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),v=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),y=Symbol.iterator;function m(I){return I===null||typeof I!="object"?null:(I=y&&I[y]||I["@@iterator"],typeof I=="function"?I:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,j={};function b(I,z,ie){this.props=I,this.context=z,this.refs=j,this.updater=ie||_}b.prototype.isReactComponent={},b.prototype.setState=function(I,z){if(typeof I!="object"&&typeof I!="function"&&I!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,I,z,"setState")},b.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function E(){}E.prototype=b.prototype;function R(I,z,ie){this.props=I,this.context=z,this.refs=j,this.updater=ie||_}var w=R.prototype=new E;w.constructor=R,k(w,b.prototype),w.isPureReactComponent=!0;var N=Array.isArray,A=Object.prototype.hasOwnProperty,$={current:null},F={key:!0,ref:!0,__self:!0,__source:!0};function G(I,z,ie){var oe,fe={},he=null,pe=null;if(z!=null)for(oe in z.ref!==void 0&&(pe=z.ref),z.key!==void 0&&(he=""+z.key),z)A.call(z,oe)&&!F.hasOwnProperty(oe)&&(fe[oe]=z[oe]);var Z=arguments.length-2;if(Z===1)fe.children=ie;else if(1>>1,z=M[I];if(0>>1;Ia(fe,H))hea(pe,fe)?(M[I]=pe,M[he]=H,I=he):(M[I]=fe,M[oe]=H,I=oe);else if(hea(pe,H))M[I]=pe,M[he]=H,I=he;else break e}}return D}function a(M,D){var H=M.sortIndex-D.sortIndex;return H!==0?H:M.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,h=c.now();t.unstable_now=function(){return c.now()-h}}var p=[],v=[],x=1,y=null,m=3,_=!1,k=!1,j=!1,b=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(M){for(var D=o(v);D!==null;){if(D.callback===null)s(v);else if(D.startTime<=M)s(v),D.sortIndex=D.expirationTime,r(p,D);else break;D=o(v)}}function N(M){if(j=!1,w(M),!k)if(o(p)!==null)k=!0,W(A);else{var D=o(v);D!==null&&U(N,D.startTime-M)}}function A(M,D){k=!1,j&&(j=!1,E(G),G=-1),_=!0;var H=m;try{for(w(D),y=o(p);y!==null&&(!(y.expirationTime>D)||M&&!ee());){var I=y.callback;if(typeof I=="function"){y.callback=null,m=y.priorityLevel;var z=I(y.expirationTime<=D);D=t.unstable_now(),typeof z=="function"?y.callback=z:y===o(p)&&s(p),w(D)}else s(p);y=o(p)}if(y!==null)var ie=!0;else{var oe=o(v);oe!==null&&U(N,oe.startTime-D),ie=!1}return ie}finally{y=null,m=H,_=!1}}var $=!1,F=null,G=-1,q=5,te=-1;function ee(){return!(t.unstable_now()-teM||125I?(M.sortIndex=H,r(v,M),o(p)===null&&M===o(v)&&(j?(E(G),G=-1):j=!0,U(N,H-I))):(M.sortIndex=z,r(p,M),k||_||(k=!0,W(A))),M},t.unstable_shouldYield=ee,t.unstable_wrapCallback=function(M){var D=m;return function(){var H=m;m=D;try{return M.apply(this,arguments)}finally{m=H}}}})(zu)),zu}var eh;function o0(){return eh||(eh=1,$u.exports=i0()),$u.exports}/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var th;function s0(){if(th)return zt;th=1;var t=us(),r=o0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,v=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,x={},y={};function m(e){return p.call(y,e)?!0:p.call(x,e)?!1:v.test(e)?y[e]=!0:(x[e]=!0,!1)}function _(e,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function k(e,n,i,l){if(n===null||typeof n>"u"||_(e,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function j(e,n,i,l,f,g,S){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=f,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=g,this.removeEmptyString=S}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){b[e]=new j(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];b[n]=new j(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){b[e]=new j(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){b[e]=new j(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){b[e]=new j(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){b[e]=new j(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){b[e]=new j(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){b[e]=new j(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){b[e]=new j(e,5,!1,e.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function R(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){b[e]=new j(e,1,!1,e.toLowerCase(),null,!1,!1)}),b.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){b[e]=new j(e,1,!1,e.toLowerCase(),null,!0,!0)});function w(e,n,i,l){var f=b.hasOwnProperty(n)?b[n]:null;(f!==null?f.type!==0:l||!(2T||f[S]!==g[T]){var O=` +`+f[S].replace(" at new "," at ");return e.displayName&&O.includes("")&&(O=O.replace("",e.displayName)),O}while(1<=S&&0<=T);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?z(e):""}function fe(e){switch(e.tag){case 5:return z(e.type);case 16:return z("Lazy");case 13:return z("Suspense");case 19:return z("SuspenseList");case 0:case 2:case 15:return e=oe(e.type,!1),e;case 11:return e=oe(e.type.render,!1),e;case 1:return e=oe(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case F:return"Fragment";case $:return"Portal";case q:return"Profiler";case G:return"StrictMode";case K:return"Suspense";case C:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ee:return(e.displayName||"Context")+".Consumer";case te:return(e._context.displayName||"Context")+".Provider";case ne:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case W:n=e._payload,e=e._init;try{return he(e(n))}catch{}}return null}function pe(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===G?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Z(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=se(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function ke(e){e._valueTracker||(e._valueTracker=me(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=se(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function re(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return H({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Z(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Te(e,n){n=n.checked,n!=null&&w(e,"checked",n,!1)}function $e(e,n){Te(e,n);var i=Z(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?lt(e,n.type,i):n.hasOwnProperty("defaultValue")&<(e,n.type,Z(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function st(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function lt(e,n,i){(n!=="number"||re(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var at=Array.isArray;function Ge(e,n,i,l){if(e=e.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=Je.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ot(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var xn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},io=["Webkit","ms","Moz","O"];Object.keys(xn).forEach(function(e){io.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),xn[n]=xn[e]})});function $n(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||xn.hasOwnProperty(e)&&xn[e]?(""+n).trim():n+"px"}function vi(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=$n(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,f):e[i]=f}}var or=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function $r(e,n){if(n){if(or[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function zn(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var zr=null;function sr(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var lr=null,Ft=null,ct=null;function Dn(e){if(e=Mo(e)){if(typeof lr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=Is(n),lr(e.stateNode,e.type,n))}}function On(e){Ft?ct?ct.push(e):ct=[e]:Ft=e}function wn(){if(Ft){var e=Ft,n=ct;if(ct=Ft=null,Dn(e),n)for(e=0;e>>=0,e===0?32:31-(ao(e)/Ur|0)|0}var Wn=64,Un=4194304;function bn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Bt(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,f=e.suspendedLanes,g=e.pingedLanes,S=i&268435455;if(S!==0){var T=S&~f;T!==0?l=bn(T):(g&=S,g!==0&&(l=bn(g)))}else S=i&~f,S!==0?l=bn(S):g!==0&&(l=bn(g));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,g=n&-n,f>=g||f===16&&(g&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function En(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Et(n),e[n]=i}function uo(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=wo),Hc=" ",Bc=!1;function Vc(e,n){switch(e){case"keyup":return qm.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var bi=!1;function Qm(e,n){switch(e){case"compositionend":return Wc(n);case"keypress":return n.which!==32?null:(Bc=!0,Hc);case"textInput":return e=n.data,e===Hc&&Bc?null:e;default:return null}}function Zm(e,n){if(bi)return e==="compositionend"||!ha&&Vc(e,n)?(e=Ac(),ws=la=gr=null,bi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Qc(i)}}function Jc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Jc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function ed(){for(var e=window,n=re();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=re(e.document)}return n}function ma(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function ly(e){var n=ed(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Jc(i.ownerDocument.documentElement,i)){if(l!==null&&ma(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var f=i.textContent.length,g=Math.min(l.start,f);l=l.end===void 0?g:Math.min(l.end,f),!e.extend&&g>l&&(f=l,l=g,g=f),f=Zc(i,g);var S=Zc(i,l);f&&S&&(e.rangeCount!==1||e.anchorNode!==f.node||e.anchorOffset!==f.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),e.removeAllRanges(),g>l?(e.addRange(n),e.extend(S.node,S.offset)):(n.setEnd(S.node,S.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,Ei=null,ya=null,No=null,va=!1;function td(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;va||Ei==null||Ei!==re(l)||(l=Ei,"selectionStart"in l&&ma(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),No&&ko(No,l)||(No=l,l=Cs(ya,"onSelect"),0Ri||(e.current=Pa[Ri],Pa[Ri]=null,Ri--)}function Be(e,n){Ri++,Pa[Ri]=e.current,e.current=n}var xr={},St=vr(xr),Rt=vr(!1),Qr=xr;function Ti(e,n){var i=e.type.contextTypes;if(!i)return xr;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in i)f[g]=n[g];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=f),f}function Tt(e){return e=e.childContextTypes,e!=null}function Rs(){Ue(Rt),Ue(St)}function md(e,n,i){if(St.current!==xr)throw Error(o(168));Be(St,n),Be(Rt,i)}function yd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,pe(e)||"Unknown",f));return H({},i,l)}function Ts(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||xr,Qr=St.current,Be(St,e),Be(Rt,Rt.current),!0}function vd(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=yd(e,n,Qr),l.__reactInternalMemoizedMergedChildContext=e,Ue(Rt),Ue(St),Be(St,e)):Ue(Rt),Be(Rt,i)}var qn=null,Ls=!1,Ia=!1;function xd(e){qn===null?qn=[e]:qn.push(e)}function xy(e){Ls=!0,xd(e)}function wr(){if(!Ia&&qn!==null){Ia=!0;var e=0,n=Fe;try{var i=qn;for(Fe=1;e>=S,f-=S,Kn=1<<32-Et(n)+f|i<Ce?(pt=Ee,Ee=null):pt=Ee.sibling;var Oe=le(X,Ee,Q[Ce],de);if(Oe===null){Ee===null&&(Ee=pt);break}e&&Ee&&Oe.alternate===null&&n(X,Ee),B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe,Ee=pt}if(Ce===Q.length)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;CeCe?(pt=Ee,Ee=null):pt=Ee.sibling;var Mr=le(X,Ee,Oe.value,de);if(Mr===null){Ee===null&&(Ee=pt);break}e&&Ee&&Mr.alternate===null&&n(X,Ee),B=g(Mr,B,Ce),be===null?_e=Mr:be.sibling=Mr,be=Mr,Ee=pt}if(Oe.done)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;!Oe.done;Ce++,Oe=Q.next())Oe=ue(X,Oe.value,de),Oe!==null&&(B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return Xe&&Jr(X,Ce),_e}for(Ee=l(X,Ee);!Oe.done;Ce++,Oe=Q.next())Oe=ge(Ee,X,Ce,Oe.value,de),Oe!==null&&(e&&Oe.alternate!==null&&Ee.delete(Oe.key===null?Ce:Oe.key),B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return e&&Ee.forEach(function(Jy){return n(X,Jy)}),Xe&&Jr(X,Ce),_e}function et(X,B,Q,de){if(typeof Q=="object"&&Q!==null&&Q.type===F&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case A:e:{for(var _e=Q.key,be=B;be!==null;){if(be.key===_e){if(_e=Q.type,_e===F){if(be.tag===7){i(X,be.sibling),B=f(be,Q.props.children),B.return=X,X=B;break e}}else if(be.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===W&&jd(_e)===be.type){i(X,be.sibling),B=f(be,Q.props),B.ref=Po(X,be,Q),B.return=X,X=B;break e}i(X,be);break}else n(X,be);be=be.sibling}Q.type===F?(B=li(Q.props.children,X.mode,de,Q.key),B.return=X,X=B):(de=al(Q.type,Q.key,Q.props,null,X.mode,de),de.ref=Po(X,B,Q),de.return=X,X=de)}return S(X);case $:e:{for(be=Q.key;B!==null;){if(B.key===be)if(B.tag===4&&B.stateNode.containerInfo===Q.containerInfo&&B.stateNode.implementation===Q.implementation){i(X,B.sibling),B=f(B,Q.children||[]),B.return=X,X=B;break e}else{i(X,B);break}else n(X,B);B=B.sibling}B=Cu(Q,X.mode,de),B.return=X,X=B}return S(X);case W:return be=Q._init,et(X,B,be(Q._payload),de)}if(at(Q))return xe(X,B,Q,de);if(D(Q))return we(X,B,Q,de);Ds(X,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"?(Q=""+Q,B!==null&&B.tag===6?(i(X,B.sibling),B=f(B,Q),B.return=X,X=B):(i(X,B),B=Eu(Q,X.mode,de),B.return=X,X=B),S(X)):i(X,B)}return et}var zi=bd(!0),Ed=bd(!1),Os=vr(null),Fs=null,Di=null,za=null;function Da(){za=Di=Fs=null}function Oa(e){var n=Os.current;Ue(Os),e._currentValue=n}function Fa(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function Oi(e,n){Fs=e,za=Di=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Lt=!0),e.firstContext=null)}function Zt(e){var n=e._currentValue;if(za!==e)if(e={context:e,memoizedValue:n,next:null},Di===null){if(Fs===null)throw Error(o(308));Di=e,Fs.dependencies={lanes:0,firstContext:e}}else Di=Di.next=e;return n}var ei=null;function Ha(e){ei===null?ei=[e]:ei.push(e)}function Cd(e,n,i,l){var f=n.interleaved;return f===null?(i.next=i,Ha(n)):(i.next=f.next,f.next=i),n.interleaved=i,Zn(e,l)}function Zn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var _r=!1;function Ba(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Md(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Jn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Sr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(ze&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,Zn(e,i)}return f=l.interleaved,f===null?(n.next=n,Ha(l)):(n.next=f.next,f.next=n),l.interleaved=n,Zn(e,i)}function Hs(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}function Pd(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var S={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?f=g=S:g=g.next=S,i=i.next}while(i!==null);g===null?f=g=n:g=g.next=n}else f=g=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function Bs(e,n,i,l){var f=e.updateQueue;_r=!1;var g=f.firstBaseUpdate,S=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,J=O.next;O.next=null,S===null?g=J:S.next=J,S=O;var ae=e.alternate;ae!==null&&(ae=ae.updateQueue,T=ae.lastBaseUpdate,T!==S&&(T===null?ae.firstBaseUpdate=J:T.next=J,ae.lastBaseUpdate=O))}if(g!==null){var ue=f.baseState;S=0,ae=J=O=null,T=g;do{var le=T.lane,ge=T.eventTime;if((l&le)===le){ae!==null&&(ae=ae.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var xe=e,we=T;switch(le=n,ge=i,we.tag){case 1:if(xe=we.payload,typeof xe=="function"){ue=xe.call(ge,ue,le);break e}ue=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=we.payload,le=typeof xe=="function"?xe.call(ge,ue,le):xe,le==null)break e;ue=H({},ue,le);break e;case 2:_r=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,le=f.effects,le===null?f.effects=[T]:le.push(T))}else ge={eventTime:ge,lane:le,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ae===null?(J=ae=ge,O=ue):ae=ae.next=ge,S|=le;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;le=T,T=le.next,le.next=null,f.lastBaseUpdate=le,f.shared.pending=null}}while(!0);if(ae===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=J,f.lastBaseUpdate=ae,n=f.shared.interleaved,n!==null){f=n;do S|=f.lane,f=f.next;while(f!==n)}else g===null&&(f.shared.lanes=0);ri|=S,e.lanes=S,e.memoizedState=ue}}function Id(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=Ga.transition;Ga.transition={};try{e(!1),n()}finally{Fe=i,Ga.transition=l}}function Kd(){return Jt().memoizedState}function ky(e,n,i){var l=br(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},Qd(e))Zd(n,i);else if(i=Cd(e,n,i,l),i!==null){var f=Mt();dn(i,e,l,f),Jd(i,n,l)}}function Ny(e,n,i){var l=br(e),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(Qd(e))Zd(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,T=g(S,i);if(f.hasEagerState=!0,f.eagerState=T,sn(T,S)){var O=n.interleaved;O===null?(f.next=f,Ha(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=Cd(e,n,f,l),i!==null&&(f=Mt(),dn(i,e,l,f),Jd(i,n,l))}}function Qd(e){var n=e.alternate;return e===Ke||n!==null&&n===Ke}function Zd(e,n){Lo=Us=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Jd(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}var Xs={readContext:Zt,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},jy={readContext:Zt,useCallback:function(e,n){return Pn().memoizedState=[e,n===void 0?null:n],e},useContext:Zt,useEffect:Bd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Ys(4194308,4,Ud.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Ys(4194308,4,e,n)},useInsertionEffect:function(e,n){return Ys(4,2,e,n)},useMemo:function(e,n){var i=Pn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=Pn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=ky.bind(null,Ke,e),[l.memoizedState,e]},useRef:function(e){var n=Pn();return e={current:e},n.memoizedState=e},useState:Fd,useDebugValue:eu,useDeferredValue:function(e){return Pn().memoizedState=e},useTransition:function(){var e=Fd(!1),n=e[0];return e=Sy.bind(null,e[1]),Pn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=Ke,f=Pn();if(Xe){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ht===null)throw Error(o(349));(ni&30)!==0||Ad(l,n,i)}f.memoizedState=i;var g={value:i,getSnapshot:n};return f.queue=g,Bd(zd.bind(null,l,g,e),[e]),l.flags|=2048,zo(9,$d.bind(null,l,g,i,n),void 0,null),i},useId:function(){var e=Pn(),n=ht.identifierPrefix;if(Xe){var i=Qn,l=Kn;i=(l&~(1<<32-Et(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=Ao++,0<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=S.createElement(i,{is:l.is}):(e=S.createElement(i),i==="select"&&(S=e,l.multiple?S.multiple=!0:l.size&&(S.size=l.size))):e=S.createElementNS(e,i),e[Cn]=n,e[Co]=l,wf(e,n,!1,!1),n.stateNode=e;e:{switch(S=zn(i,l),i){case"dialog":We("cancel",e),We("close",e),f=l;break;case"iframe":case"object":case"embed":We("load",e),f=l;break;case"video":case"audio":for(f=0;fWi&&(n.flags|=128,l=!0,Do(g,!1),n.lanes=4194304)}else{if(!l)if(e=Vs(S),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Do(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Xe)return Nt(n),null}else 2*Ve()-g.renderingStartTime>Wi&&i!==1073741824&&(n.flags|=128,l=!0,Do(g,!1),n.lanes=4194304);g.isBackwards?(S.sibling=n.child,n.child=S):(i=g.last,i!==null?i.sibling=S:n.child=S,g.last=S)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(Nt(n),null);case 22:case 23:return Nu(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Yt&1073741824)!==0&&(Nt(n),n.subtreeFlags&6&&(n.flags|=8192)):Nt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function Ty(e,n){switch(Ta(n),n.tag){case 1:return Tt(n.type)&&Rs(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Fi(),Ue(Rt),Ue(St),Ya(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Wa(n),null;case 13:if(Ue(qe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));$i()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Fi(),null;case 10:return Oa(n.type._context),null;case 22:case 23:return Nu(),null;case 24:return null;default:return null}}var Zs=!1,jt=!1,Ly=typeof WeakSet=="function"?WeakSet:Set,ye=null;function Bi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Ze(e,n,l)}else i.current=null}function fu(e,n,i){try{i()}catch(l){Ze(e,n,l)}}var kf=!1;function Ay(e,n){if(Na=vs,e=ed(),ma(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,g=l.focusNode;l=l.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var S=0,T=-1,O=-1,J=0,ae=0,ue=e,le=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=S+f),ue!==g||l!==0&&ue.nodeType!==3||(O=S+l),ue.nodeType===3&&(S+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)le=ue,ue=ge;for(;;){if(ue===e)break t;if(le===i&&++J===f&&(T=S),le===g&&++ae===l&&(O=S),(ge=ue.nextSibling)!==null)break;ue=le,le=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(ja={focusedElem:e,selectionRange:i},vs=!1,ye=n;ye!==null;)if(n=ye,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ye=e;else for(;ye!==null;){n=ye;try{var xe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var we=xe.memoizedProps,et=xe.memoizedState,X=n.stateNode,B=X.getSnapshotBeforeUpdate(n.elementType===n.type?we:an(n.type,we),et);X.__reactInternalSnapshotBeforeUpdate=B}break;case 3:var Q=n.stateNode.containerInfo;Q.nodeType===1?Q.textContent="":Q.nodeType===9&&Q.documentElement&&Q.removeChild(Q.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(de){Ze(n,n.return,de)}if(e=n.sibling,e!==null){e.return=n.return,ye=e;break}ye=n.return}return xe=kf,kf=!1,xe}function Oo(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&e)===e){var g=f.destroy;f.destroy=void 0,g!==void 0&&fu(n,i,g)}f=f.next}while(f!==l)}}function Js(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function hu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function Nf(e){var n=e.alternate;n!==null&&(e.alternate=null,Nf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[Cn],delete n[Co],delete n[Ma],delete n[yy],delete n[vy])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function jf(e){return e.tag===5||e.tag===3||e.tag===4}function bf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||jf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function pu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=Ps));else if(l!==4&&(e=e.child,e!==null))for(pu(e,n,i),e=e.sibling;e!==null;)pu(e,n,i),e=e.sibling}function gu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(gu(e,n,i),e=e.sibling;e!==null;)gu(e,n,i),e=e.sibling}var vt=null,un=!1;function kr(e,n,i){for(i=i.child;i!==null;)Ef(e,n,i),i=i.sibling}function Ef(e,n,i){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(Vn,i)}catch{}switch(i.tag){case 5:jt||Bi(i,n);case 6:var l=vt,f=un;vt=null,kr(e,n,i),vt=l,un=f,vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):vt.removeChild(i.stateNode));break;case 18:vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?Ca(e.parentNode,i):e.nodeType===1&&Ca(e,i),yo(e)):Ca(vt,i.stateNode));break;case 4:l=vt,f=un,vt=i.stateNode.containerInfo,un=!0,kr(e,n,i),vt=l,un=f;break;case 0:case 11:case 14:case 15:if(!jt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var g=f,S=g.destroy;g=g.tag,S!==void 0&&((g&2)!==0||(g&4)!==0)&&fu(i,n,S),f=f.next}while(f!==l)}kr(e,n,i);break;case 1:if(!jt&&(Bi(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Ze(i,n,T)}kr(e,n,i);break;case 21:kr(e,n,i);break;case 22:i.mode&1?(jt=(l=jt)||i.memoizedState!==null,kr(e,n,i),jt=l):kr(e,n,i);break;default:kr(e,n,i)}}function Cf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Ly),n.forEach(function(l){var f=Wy.bind(null,e,l);i.has(l)||(i.add(l),l.then(f,f))})}}function cn(e,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=S),l&=~g}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*zy(l/1960))-l,10e?16:e,jr===null)var l=!1;else{if(e=jr,jr=null,il=0,(ze&6)!==0)throw Error(o(331));var f=ze;for(ze|=4,ye=e.current;ye!==null;){var g=ye,S=g.child;if((ye.flags&16)!==0){var T=g.deletions;if(T!==null){for(var O=0;OVe()-vu?oi(e,0):yu|=i),$t(e,n)}function Hf(e,n){n===0&&((e.mode&1)===0?n=1:(n=Un,Un<<=1,(Un&130023424)===0&&(Un=4194304)));var i=Mt();e=Zn(e,n),e!==null&&(En(e,n,i),$t(e,i))}function Vy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Hf(e,i)}function Wy(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Hf(e,i)}var Bf;Bf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Rt.current)Lt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Lt=!1,Iy(e,n,i);Lt=(e.flags&131072)!==0}else Lt=!1,Xe&&(n.flags&1048576)!==0&&wd(n,$s,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Qs(e,n),e=n.pendingProps;var f=Ti(n,St.current);Oi(n,i),f=qa(null,n,l,e,f,i);var g=Ka();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Tt(l)?(g=!0,Ts(n)):g=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Ba(n),f.updater=qs,n.stateNode=f,f._reactInternals=n,nu(n,l,e,i),n=su(null,n,l,!0,g,i)):(n.tag=0,Xe&&g&&Ra(n),Ct(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Qs(e,n),e=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=Yy(l),e=an(l,e),f){case 0:n=ou(null,n,l,e,i);break e;case 1:n=pf(null,n,l,e,i);break e;case 11:n=uf(null,n,l,e,i);break e;case 14:n=cf(null,n,l,an(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),ou(e,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),pf(e,n,l,f,i);case 3:e:{if(gf(n),e===null)throw Error(o(387));l=n.pendingProps,g=n.memoizedState,f=g.element,Md(e,n),Bs(n,l,null,i);var S=n.memoizedState;if(l=S.element,g.isDehydrated)if(g={element:l,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){f=Hi(Error(o(423)),n),n=mf(e,n,l,i,f);break e}else if(l!==f){f=Hi(Error(o(424)),n),n=mf(e,n,l,i,f);break e}else for(Ut=yr(n.stateNode.containerInfo.firstChild),Wt=n,Xe=!0,ln=null,i=Ed(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if($i(),l===f){n=er(e,n,i);break e}Ct(e,n,l,i)}n=n.child}return n;case 5:return Rd(n),e===null&&Aa(n),l=n.type,f=n.pendingProps,g=e!==null?e.memoizedProps:null,S=f.children,ba(l,f)?S=null:g!==null&&ba(l,g)&&(n.flags|=32),hf(e,n),Ct(e,n,S,i),n.child;case 6:return e===null&&Aa(n),null;case 13:return yf(e,n,i);case 4:return Va(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=zi(n,null,l,i):Ct(e,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),uf(e,n,l,f,i);case 7:return Ct(e,n,n.pendingProps,i),n.child;case 8:return Ct(e,n,n.pendingProps.children,i),n.child;case 12:return Ct(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,g=n.memoizedProps,S=f.value,Be(Os,l._currentValue),l._currentValue=S,g!==null)if(sn(g.value,S)){if(g.children===f.children&&!Rt.current){n=er(e,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var T=g.dependencies;if(T!==null){S=g.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(g.tag===1){O=Jn(-1,i&-i),O.tag=2;var J=g.updateQueue;if(J!==null){J=J.shared;var ae=J.pending;ae===null?O.next=O:(O.next=ae.next,ae.next=O),J.pending=O}}g.lanes|=i,O=g.alternate,O!==null&&(O.lanes|=i),Fa(g.return,i,n),T.lanes|=i;break}O=O.next}}else if(g.tag===10)S=g.type===n.type?null:g.child;else if(g.tag===18){if(S=g.return,S===null)throw Error(o(341));S.lanes|=i,T=S.alternate,T!==null&&(T.lanes|=i),Fa(S,i,n),S=g.sibling}else S=g.child;if(S!==null)S.return=g;else for(S=g;S!==null;){if(S===n){S=null;break}if(g=S.sibling,g!==null){g.return=S.return,S=g;break}S=S.return}g=S}Ct(e,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,Oi(n,i),f=Zt(f),l=l(f),n.flags|=1,Ct(e,n,l,i),n.child;case 14:return l=n.type,f=an(l,n.pendingProps),f=an(l.type,f),cf(e,n,l,f,i);case 15:return df(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),Qs(e,n),n.tag=1,Tt(l)?(e=!0,Ts(n)):e=!1,Oi(n,i),tf(n,l,f),nu(n,l,f,i),su(null,n,l,!0,e,i);case 19:return xf(e,n,i);case 22:return ff(e,n,i)}throw Error(o(156,n.tag))};function Vf(e,n){return Hr(e,n)}function Uy(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tn(e,n,i,l){return new Uy(e,n,i,l)}function bu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Yy(e){if(typeof e=="function")return bu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ne)return 11;if(e===V)return 14}return 2}function Cr(e,n){var i=e.alternate;return i===null?(i=tn(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function al(e,n,i,l,f,g){var S=2;if(l=e,typeof e=="function")bu(e)&&(S=1);else if(typeof e=="string")S=5;else e:switch(e){case F:return li(i.children,f,g,n);case G:S=8,f|=8;break;case q:return e=tn(12,i,n,f|2),e.elementType=q,e.lanes=g,e;case K:return e=tn(13,i,n,f),e.elementType=K,e.lanes=g,e;case C:return e=tn(19,i,n,f),e.elementType=C,e.lanes=g,e;case U:return ul(i,f,g,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case te:S=10;break e;case ee:S=9;break e;case ne:S=11;break e;case V:S=14;break e;case W:S=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=tn(S,i,n,f),n.elementType=e,n.type=l,n.lanes=g,n}function li(e,n,i,l){return e=tn(7,e,l,n),e.lanes=i,e}function ul(e,n,i,l){return e=tn(22,e,l,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function Eu(e,n,i){return e=tn(6,e,null,n),e.lanes=i,e}function Cu(e,n,i){return n=tn(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Gy(e,n,i,l,f){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Yn(0),this.expirationTimes=Yn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Yn(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Mu(e,n,i,l,f,g,S,T,O){return e=new Gy(e,n,i,T,O),n===1?(n=1,g===!0&&(n|=8)):n=0,g=tn(3,null,null,n),e.current=g,g.stateNode=e,g.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ba(g),e}function Xy(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),Au.exports=s0(),Au.exports}var rh;function l0(){if(rh)return ml;rh=1;var t=Np();return ml.createRoot=t.createRoot,ml.hydrateRoot=t.hydrateRoot,ml}var a0=l0();function jp(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Ae(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(jp(s,o.statusText||"Request failed"))}return o.json()}const u0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Pe={health:()=>Ae("/api/health"),settings:()=>Ae("/api/settings"),saveSettings:t=>{const r={...t};for(const o of u0)r[o]===""&&delete r[o];return Ae("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ae("/api/repos"),browse:t=>Ae(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ae(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ae("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ae(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Ae(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:(t,r=!0)=>Ae(`/api/architecture?repo_path=${encodeURIComponent(t)}&graph=${r?"1":"0"}`),architectureGraph:t=>Ae(`/api/architecture/graph?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Ae("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Ae("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Ae("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Ae("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Ae("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Ae(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open",s)=>Ae("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o,repo_path:s||null})}),scmRepos:t=>Ae(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ae("/api/oauth/status"),githubOAuthStart:()=>Ae("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ae("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ae("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Ae("/api/oauth/gitlab/start"),oauthDisconnect:t=>Ae("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ae("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})}),reviews:t=>Ae(`/api/reviews?repo_path=${encodeURIComponent(t)}`),getReview:(t,r)=>Ae(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(t)}`),reviewDiff:(t,r,o)=>Ae(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(t)}&other=${encodeURIComponent(o)}`),config:t=>Ae(`/api/config?repo_path=${encodeURIComponent(t)}`),saveConfig:(t,r)=>Ae("/api/config",{method:"PUT",body:JSON.stringify({repo_path:t,...r})}),addWaiver:(t,r,o,s)=>Ae("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:t,rule:r,node:o||null,reason:s||""})}),marks:(t,r)=>Ae(`/api/marks?repo_path=${encodeURIComponent(t)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:t=>Ae(`/api/architecture/health?repo_path=${encodeURIComponent(t)}`),workspaceStatus:t=>Ae(`/api/workspace/status?repo_path=${encodeURIComponent(t)}`),openEditor:(t,r,o,s)=>Ae("/api/open",{method:"POST",body:JSON.stringify({repo_path:t,path:r,line:o||null,editor:s||null})}),exportHtml:t=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:t})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(jp(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(t,r,o,s)=>Ae("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:t,edges:r,source_id:o,target_id:s||null})})};function c0(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):t}function d0({open:t,actions:r,onClose:o}){const[s,a]=L.useState(""),[u,c]=L.useState(0),h=L.useRef(null),p=L.useMemo(()=>c0(r,s),[r,s]);if(L.useEffect(()=>{if(!t)return;a(""),c(0);const y=window.setTimeout(()=>{var m;return(m=h.current)==null?void 0:m.focus()},0);return()=>window.clearTimeout(y)},[t]),L.useEffect(()=>{c(0)},[s]),!t)return null;const v=p[u],x=y=>{y&&(o(),y.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:y=>{y.target===y.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:y=>a(y.target.value),onKeyDown:y=>{y.key==="Escape"?(y.preventDefault(),o()):y.key==="ArrowDown"?(y.preventDefault(),c(m=>Math.min(p.length-1,m+1))):y.key==="ArrowUp"?(y.preventDefault(),c(m=>Math.max(0,m-1))):y.key==="Enter"&&(y.preventDefault(),x(v))}}),d.jsxs("ul",{children:[p.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,p.slice(0,40).map((y,m)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:m===u?"active":"",onMouseEnter:()=>c(m),onClick:()=>x(y),children:[d.jsx("span",{children:y.label}),y.hint?d.jsx("span",{className:"muted",children:y.hint}):null]})},y.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function f0({config:t,busy:r,onSave:o,onWaiver:s}){const[a,u]=L.useState(t),[c,h]=L.useState(t.available_rules[0]||""),[p,v]=L.useState(""),[x,y]=L.useState("");L.useEffect(()=>{u(t)},[t]);const m=Object.entries(a.contexts||{}),_=(R,w,N)=>{const A=a.contexts[R];if(!A)return;const $=F=>F.split(",").map(G=>G.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[R]:{...A,[w]:w==="name"?N:$(N)}}})},k=(R,w)=>{const N=w.trim();if(!N||N===R)return;const{[R]:A,...$}=a.contexts;A&&u({...a,contexts:{...$,[N]:{...A,name:N}}})},j=()=>{let R=1;for(;a.contexts[`context-${R}`];)R+=1;const w=`context-${R}`;u({...a,contexts:{...a.contexts,[w]:{name:w,django_apps:[],react:[],public_api:[],owners:[]}}})},b=R=>{const{[R]:w,...N}=a.contexts;u({...a,contexts:N})},E=R=>{const w=a.rules.includes(R);u({...a,rules:w?a.rules.filter(N=>N!==R):[...a.rules,R]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),m.map(([R,w])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:R})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:R,"data-testid":`config-context-name-${R}`,onBlur:N=>k(R,N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(w.django_apps||[]).join(", "),onChange:N=>_(R,"django_apps",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(w.react||[]).join(", "),onChange:N=>_(R,"react",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(w.public_api||[]).join(", "),onChange:N=>_(R,"public_api",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(w.owners||[]).join(", "),onChange:N=>_(R,"owners",N.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>b(R),children:"Remove context"})]},R)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:j,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(R),onChange:()=>E(R)}),R]},R))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((R,w)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:R.rule}),R.node?` · ${R.node}`:"",R.reason?` — ${R.reason}`:""]},`${R.rule}:${R.node}:${w}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:R=>h(R.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsx("option",{value:R,children:R},R))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:R=>v(R.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:x,onChange:R=>y(R.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,x),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function Qo(t){return t.replaceAll("_"," ")}function h0(t){return t.replaceAll("_"," ")}function ro(t){return t.split(".").pop()||t}function ec(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function p0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Tr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function yi({className:t,children:r}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function g0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function m0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function y0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function v0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function x0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function bp({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function w0({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const _0="modulepreload",S0=function(t,r){return new URL(t,r).href},ih={},k0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(x){return Promise.all(x.map(y=>Promise.resolve(y).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),v=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(x=>{if(x=S0(x,s),x in ih)return;ih[x]=!0;const y=x.endsWith(".css"),m=y?'[rel="stylesheet"]':"";if(!!s)for(let j=h.length-1;j>=0;j--){const b=h[j];if(b.href===x&&(!y||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${x}"]${m}`))return;const k=document.createElement("link");if(k.rel=y?"stylesheet":_0,y||(k.as="script"),k.crossOrigin="",k.href=x,v&&k.setAttribute("nonce",v),document.head.appendChild(k),y)return new Promise((j,b)=>{k.addEventListener("load",j),k.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${x}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function nt(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Yl(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}Cl.prototype=Yl.prototype={constructor:Cl,on:function(t,r){var o=this._,s=j0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),sh.hasOwnProperty(r)?{space:sh[r],local:t}:t}function E0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===tc&&r.documentElement.namespaceURI===tc?r.createElement(t):r.createElementNS(o,t)}}function C0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Ep(t){var r=Gl(t);return(r.local?C0:E0)(r)}function M0(){}function pc(t){return t==null?M0:function(){return this.querySelector(t)}}function P0(t){typeof t!="function"&&(t=pc(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=w&&(w=R+1);!(A=b[w])&&++w=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function tv(t){t||(t=nv);function r(y,m){return y&&m?t(y.__data__,m.__data__):!y-!m}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function rv(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function iv(){return Array.from(this)}function ov(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?mv:typeof r=="function"?vv:yv)(t,r,o??"")):Ki(this.node(),t)}function Ki(t,r){return t.style.getPropertyValue(r)||Rp(t).getComputedStyle(t,null).getPropertyValue(r)}function wv(t){return function(){delete this[t]}}function _v(t,r){return function(){this[t]=r}}function Sv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function kv(t,r){return arguments.length>1?this.each((r==null?wv:typeof r=="function"?Sv:_v)(t,r)):this.node()[t]}function Tp(t){return t.trim().split(/^|\s+/)}function gc(t){return t.classList||new Lp(t)}function Lp(t){this._node=t,this._names=Tp(t.getAttribute("class")||"")}Lp.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Ap(t,r){for(var o=gc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function Qv(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function nc(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:v,dispatch:x}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:v,enumerable:!0,configurable:!0},_:{value:x}})}nc.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function lx(t){return!t.ctrlKey&&!t.button}function ax(){return this.parentNode}function ux(t,r){return r??{x:t.x,y:t.y}}function cx(){return navigator.maxTouchPoints||"ontouchstart"in this}function Hp(){var t=lx,r=ax,o=ux,s=cx,a={},u=Yl("start","drag","end"),c=0,h,p,v,x,y=0;function m(N){N.on("mousedown.drag",_).filter(s).on("touchstart.drag",b).on("touchmove.drag",E,sx).on("touchend.drag touchcancel.drag",R).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(N,A){if(!(x||!t.call(this,N,A))){var $=w(this,r.call(this,N,A),N,A,"mouse");$&&(Gt(N.view).on("mousemove.drag",k,Zo).on("mouseup.drag",j,Zo),Op(N.view),Du(N),v=!1,h=N.clientX,p=N.clientY,$("start",N))}}function k(N){if(Xi(N),!v){var A=N.clientX-h,$=N.clientY-p;v=A*A+$*$>y}a.mouse("drag",N)}function j(N){Gt(N.view).on("mousemove.drag mouseup.drag",null),Fp(N.view,v),Xi(N),a.mouse("end",N)}function b(N,A){if(t.call(this,N,A)){var $=N.changedTouches,F=r.call(this,N,A),G=$.length,q,te;for(q=0;q>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?vl(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?vl(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=fx.exec(t))?new Dt(r[1],r[2],r[3],1):(r=hx.exec(t))?new Dt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=px.exec(t))?vl(r[1],r[2],r[3],r[4]):(r=gx.exec(t))?vl(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=mx.exec(t))?hh(r[1],r[2]/100,r[3]/100,1):(r=yx.exec(t))?hh(r[1],r[2]/100,r[3]/100,r[4]):lh.hasOwnProperty(t)?ch(lh[t]):t==="transparent"?new Dt(NaN,NaN,NaN,0):null}function ch(t){return new Dt(t>>16&255,t>>8&255,t&255,1)}function vl(t,r,o,s){return s<=0&&(t=r=o=NaN),new Dt(t,r,o,s)}function wx(t){return t instanceof ds||(t=fi(t)),t?(t=t.rgb(),new Dt(t.r,t.g,t.b,t.opacity)):new Dt}function rc(t,r,o,s){return arguments.length===1?wx(t):new Dt(t,r,o,s??1)}function Dt(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}mc(Dt,rc,Bp(ds,{brighter(t){return t=t==null?Ll:Math.pow(Ll,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Jo:Math.pow(Jo,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Dt(ci(this.r),ci(this.g),ci(this.b),Al(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:dh,formatHex:dh,formatHex8:_x,formatRgb:fh,toString:fh}));function dh(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}`}function _x(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}${ui((isNaN(this.opacity)?1:this.opacity)*255)}`}function fh(){const t=Al(this.opacity);return`${t===1?"rgb(":"rgba("}${ci(this.r)}, ${ci(this.g)}, ${ci(this.b)}${t===1?")":`, ${t})`}`}function Al(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ci(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ui(t){return t=ci(t),(t<16?"0":"")+t.toString(16)}function hh(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new hn(t,r,o,s)}function Vp(t){if(t instanceof hn)return new hn(t.h,t.s,t.l,t.opacity);if(t instanceof ds||(t=fi(t)),!t)return new hn;if(t instanceof hn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new hn(c,h,p,t.opacity)}function Sx(t,r,o,s){return arguments.length===1?Vp(t):new hn(t,r,o,s??1)}function hn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}mc(hn,Sx,Bp(ds,{brighter(t){return t=t==null?Ll:Math.pow(Ll,t),new hn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Jo:Math.pow(Jo,t),new hn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Dt(Ou(t>=240?t-240:t+120,a,s),Ou(t,a,s),Ou(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new hn(ph(this.h),xl(this.s),xl(this.l),Al(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 t=Al(this.opacity);return`${t===1?"hsl(":"hsla("}${ph(this.h)}, ${xl(this.s)*100}%, ${xl(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ph(t){return t=(t||0)%360,t<0?t+360:t}function xl(t){return Math.max(0,Math.min(1,t||0))}function Ou(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const yc=t=>()=>t;function kx(t,r){return function(o){return t+o*r}}function Nx(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function jx(t){return(t=+t)==1?Wp:function(r,o){return o-r?Nx(r,o,t):yc(isNaN(r)?o:r)}}function Wp(t,r){var o=r-t;return o?kx(t,o):yc(isNaN(t)?r:t)}const $l=(function t(r){var o=jx(r);function s(a,u){var c=o((a=rc(a)).r,(u=rc(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),v=Wp(a.opacity,u.opacity);return function(x){return a.r=c(x),a.g=h(x),a.b=p(x),a.opacity=v(x),a+""}}return s.gamma=t,s})(1);function bx(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:Rn(s,a)})),o=Fu.lastIndex;return o180?x+=360:x-v>180&&(v+=360),m.push({i:y.push(a(y)+"rotate(",null,s)-2,x:Rn(v,x)})):x&&y.push(a(y)+"rotate("+x+s)}function h(v,x,y,m){v!==x?m.push({i:y.push(a(y)+"skewX(",null,s)-2,x:Rn(v,x)}):x&&y.push(a(y)+"skewX("+x+s)}function p(v,x,y,m,_,k){if(v!==y||x!==m){var j=_.push(a(_)+"scale(",null,",",null,")");k.push({i:j-4,x:Rn(v,y)},{i:j-2,x:Rn(x,m)})}else(y!==1||m!==1)&&_.push(a(_)+"scale("+y+","+m+")")}return function(v,x){var y=[],m=[];return v=t(v),x=t(x),u(v.translateX,v.translateY,x.translateX,x.translateY,y,m),c(v.rotate,x.rotate,y,m),h(v.skewX,x.skewX,y,m),p(v.scaleX,v.scaleY,x.scaleX,x.scaleY,y,m),v=x=null,function(_){for(var k=-1,j=m.length,b;++k=0&&t._call.call(void 0,r),t=t._next;--Qi}function yh(){hi=(Dl=ts.now())+Xl,Qi=Go=0;try{Hx()}finally{Qi=0,Vx(),hi=0}}function Bx(){var t=ts.now(),r=t-Dl;r>Xp&&(Xl-=r,Dl=t)}function Vx(){for(var t,r=zl,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:zl=o);Xo=t,sc(s)}function sc(t){if(!Qi){Go&&(Go=clearTimeout(Go));var r=t-hi;r>24?(t<1/0&&(Go=setTimeout(yh,t-ts.now()-Xl)),Uo&&(Uo=clearInterval(Uo))):(Uo||(Dl=ts.now(),Uo=setInterval(Bx,Xp)),Qi=1,qp(yh))}}function vh(t,r,o){var s=new Ol;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Wx=Yl("start","end","cancel","interrupt"),Ux=[],Qp=0,xh=1,lc=2,Pl=3,wh=4,ac=5,Il=6;function ql(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;Yx(t,o,{name:r,index:s,group:a,on:Wx,tween:Ux,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Qp})}function xc(t,r){var o=yn(t,r);if(o.state>Qp)throw new Error("too late; already scheduled");return o}function Ln(t,r){var o=yn(t,r);if(o.state>Pl)throw new Error("too late; already running");return o}function yn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Yx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=Kp(u,0,o.time);function u(v){o.state=xh,o.timer.restart(c,o.delay,o.time),o.delay<=v&&c(v-o.delay)}function c(v){var x,y,m,_;if(o.state!==xh)return p();for(x in s)if(_=s[x],_.name===o.name){if(_.state===Pl)return vh(c);_.state===wh?(_.state=Il,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete s[x]):+xlc&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function Sw(t,r,o){var s,a,u=_w(r)?xc:Ln;return function(){var c=u(this,t),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function kw(t,r){var o=this._id;return arguments.length<2?yn(this.node(),o).on.on(t):this.each(Sw(o,t,r))}function Nw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function jw(){return this.on("end.remove",Nw(this._id))}function bw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=pc(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function Qw(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function rr(t,r,o){this.k=t,this.x=r,this.y=o}rr.prototype={constructor:rr,scale:function(t){return t===1?this:new rr(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new rr(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Kl=new rr(1,0,0);tg.prototype=rr.prototype;function tg(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Kl;return t.__zoom}function Hu(t){t.stopImmediatePropagation()}function Yo(t){t.preventDefault(),t.stopImmediatePropagation()}function Zw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Jw(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function _h(){return this.__zoom||Kl}function e1(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function t1(){return navigator.maxTouchPoints||"ontouchstart"in this}function n1(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function ng(){var t=Zw,r=Jw,o=n1,s=e1,a=t1,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=Ml,v=Yl("start","zoom","end"),x,y,m,_=500,k=150,j=0,b=10;function E(C){C.property("__zoom",_h).on("wheel.zoom",G,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",te).filter(a).on("touchstart.zoom",ee).on("touchmove.zoom",ne).on("touchend.zoom touchcancel.zoom",K).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(C,V,W,U){var M=C.selection?C.selection():C;M.property("__zoom",_h),C!==M?A(C,V,W,U):M.interrupt().each(function(){$(this,arguments).event(U).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},E.scaleBy=function(C,V,W,U){E.scaleTo(C,function(){var M=this.__zoom.k,D=typeof V=="function"?V.apply(this,arguments):V;return M*D},W,U)},E.scaleTo=function(C,V,W,U){E.transform(C,function(){var M=r.apply(this,arguments),D=this.__zoom,H=W==null?N(M):typeof W=="function"?W.apply(this,arguments):W,I=D.invert(H),z=typeof V=="function"?V.apply(this,arguments):V;return o(w(R(D,z),H,I),M,c)},W,U)},E.translateBy=function(C,V,W,U){E.transform(C,function(){return o(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),r.apply(this,arguments),c)},null,U)},E.translateTo=function(C,V,W,U,M){E.transform(C,function(){var D=r.apply(this,arguments),H=this.__zoom,I=U==null?N(D):typeof U=="function"?U.apply(this,arguments):U;return o(Kl.translate(I[0],I[1]).scale(H.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),D,c)},U,M)};function R(C,V){return V=Math.max(u[0],Math.min(u[1],V)),V===C.k?C:new rr(V,C.x,C.y)}function w(C,V,W){var U=V[0]-W[0]*C.k,M=V[1]-W[1]*C.k;return U===C.x&&M===C.y?C:new rr(C.k,U,M)}function N(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function A(C,V,W,U){C.on("start.zoom",function(){$(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(U).end()}).tween("zoom",function(){var M=this,D=arguments,H=$(M,D).event(U),I=r.apply(M,D),z=W==null?N(I):typeof W=="function"?W.apply(M,D):W,ie=Math.max(I[1][0]-I[0][0],I[1][1]-I[0][1]),oe=M.__zoom,fe=typeof V=="function"?V.apply(M,D):V,he=p(oe.invert(z).concat(ie/oe.k),fe.invert(z).concat(ie/fe.k));return function(pe){if(pe===1)pe=fe;else{var Z=he(pe),se=ie/Z[2];pe=new rr(se,z[0]-Z[0]*se,z[1]-Z[1]*se)}H.zoom(null,pe)}})}function $(C,V,W){return!W&&C.__zooming||new F(C,V)}function F(C,V){this.that=C,this.args=V,this.active=0,this.sourceEvent=null,this.extent=r.apply(C,V),this.taps=0}F.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,V){return this.mouse&&C!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var V=Gt(this.that).datum();v.call(C,this.that,new Qw(C,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:v}),V)}};function G(C,...V){if(!t.apply(this,arguments))return;var W=$(this,V).event(C),U=this.__zoom,M=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,s.apply(this,arguments)))),D=fn(C);if(W.wheel)(W.mouse[0][0]!==D[0]||W.mouse[0][1]!==D[1])&&(W.mouse[1]=U.invert(W.mouse[0]=D)),clearTimeout(W.wheel);else{if(U.k===M)return;W.mouse=[D,U.invert(D)],Rl(this),W.start()}Yo(C),W.wheel=setTimeout(H,k),W.zoom("mouse",o(w(R(U,M),W.mouse[0],W.mouse[1]),W.extent,c));function H(){W.wheel=null,W.end()}}function q(C,...V){if(m||!t.apply(this,arguments))return;var W=C.currentTarget,U=$(this,V,!0).event(C),M=Gt(C.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",ie,!0),D=fn(C,W),H=C.clientX,I=C.clientY;Op(C.view),Hu(C),U.mouse=[D,this.__zoom.invert(D)],Rl(this),U.start();function z(oe){if(Yo(oe),!U.moved){var fe=oe.clientX-H,he=oe.clientY-I;U.moved=fe*fe+he*he>j}U.event(oe).zoom("mouse",o(w(U.that.__zoom,U.mouse[0]=fn(oe,W),U.mouse[1]),U.extent,c))}function ie(oe){M.on("mousemove.zoom mouseup.zoom",null),Fp(oe.view,U.moved),Yo(oe),U.event(oe).end()}}function te(C,...V){if(t.apply(this,arguments)){var W=this.__zoom,U=fn(C.changedTouches?C.changedTouches[0]:C,this),M=W.invert(U),D=W.k*(C.shiftKey?.5:2),H=o(w(R(W,D),U,M),r.apply(this,V),c);Yo(C),h>0?Gt(this).transition().duration(h).call(A,H,U,C):Gt(this).call(E.transform,H,U,C)}}function ee(C,...V){if(t.apply(this,arguments)){var W=C.touches,U=W.length,M=$(this,V,C.changedTouches.length===U).event(C),D,H,I,z;for(Hu(C),H=0;H`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},ns=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],rg=["Enter"," ","Escape"],ig={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Zi;(function(t){t.Strict="strict",t.Loose="loose"})(Zi||(Zi={}));var di;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(di||(di={}));var rs;(function(t){t.Partial="partial",t.Full="full"})(rs||(rs={}));const og={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Lr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Lr||(Lr={}));var is;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(is||(is={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const Sh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function sg(t){return t===null?null:t?"valid":"invalid"}const lg=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,r1=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),_c=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),fs=(t,r=[0,0])=>{const{width:o,height:s}=vn(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},i1=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):_c(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,Ql(a,Fl(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?Zl(s):{x:0,y:0,width:0,height:0}},hs=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=Ql(o,Fl(a)),s=!0)}),s?Zl(o):{x:0,y:0,width:0,height:0}},Sc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,v=r.width/a,x=r.height/a,y=[];for(const m of t.values()){const{measured:_,selectable:k=!0,hidden:j=!1}=m;if(c&&!k||j)continue;const b=_.width??m.width??m.initialWidth??0,E=_.height??m.height??m.initialHeight??0,{x:R,y:w}=m.internals.positionAbsolute,N=dg(h,p,v,x,R,w,b,E),A=b*E,$=u&&N>0;(!m.internals.handleBounds||$||N>=A||m.dragging)&&y.push(m)}return y},o1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function s1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=vn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function l1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const h=s1(t,c),p=hs(h),v=Nc(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(v,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function ag({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),h=c.parentId?o.get(c.parentId):void 0,{x:p,y:v}=h?h.internals.positionAbsolute:{x:0,y:0},x=c.origin??s;let y=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",mn.error005());else{const{width:_,height:k}=vn(h);_&&k&&(y=[[p,v],[p+_,v+k]])}else h&&gi(c.extent)&&(y=[[c.extent[0][0]+p,c.extent[0][1]+v],[c.extent[1][0]+p,c.extent[1][1]+v]]);const m=gi(y)?pi(r,y,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",mn.error015())),{position:{x:m.x-p+(c.measured.width??0)*x[0],y:m.y-v+(c.measured.height??0)*x[1]},positionAbsolute:m}}async function a1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(m=>m.id)),c=[];for(const m of o){if(m.deletable===!1)continue;const _=u.has(m.id),k=!_&&m.parentId&&c.find(j=>j.id===m.parentId);(_||k)&&c.push(m)}const h=new Set(r.map(m=>m.id)),p=s.filter(m=>m.deletable!==!1),x=o1(c,p);for(const m of p)h.has(m.id)&&!x.find(k=>k.id===m.id)&&x.push(m);if(!a)return{edges:x,nodes:c};const y=await a({nodes:c,edges:x});return typeof y=="boolean"?y?{edges:x,nodes:c}:{edges:[],nodes:[]}:y}const Ji=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),pi=(t={x:0,y:0},r,o)=>({x:Ji(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:Ji(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function ug(t,r,o){const{width:s,height:a}=vn(o),{x:u,y:c}=o.internals.positionAbsolute;return pi(t,[[u,c],[u+s,c+a]],r)}const kh=(t,r,o)=>to?-Ji(Math.abs(t-o),1,r)/r:0,kc=(t,r,o=15,s=40)=>{const a=kh(t.x,s,r.width-s)*o,u=kh(t.y,s,r.height-s)*o;return[a,u]},Ql=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),uc=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),Zl=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),os=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:fs(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},Fl=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:fs(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},cg=(t,r)=>Zl(Ql(uc(t),uc(r))),dg=(t,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),v=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*v)},Hl=(t,r)=>dg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),Nh=t=>pn(t.width)&&pn(t.height)&&pn(t.x)&&pn(t.y),pn=t=>!isNaN(t)&&isFinite(t),fg=(t,r)=>(o,s)=>{},ps=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),gs=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(t-o)/a,y:(r-s)/a};return u?ps(h,c):h},eo=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Yi(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function u1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Yi(t,o),a=Yi(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Yi(t.top??t.y??0,o),a=Yi(t.bottom??t.y??0,o),u=Yi(t.left??t.x??0,r),c=Yi(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function c1(t,r,o,s,a,u){const{x:c,y:h}=eo(t,[r,o,s]),{x:p,y:v}=eo({x:t.x+t.width,y:t.y+t.height},[r,o,s]),x=a-p,y=u-v;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(x),bottom:Math.floor(y)}}const Nc=(t,r,o,s,a,u)=>{const c=u1(u,r,o),h=(r-c.x)/t.width,p=(o-c.y)/t.height,v=Math.min(h,p),x=Ji(v,s,a),y=t.x+t.width/2,m=t.y+t.height/2,_=r/2-y*x,k=o/2-m*x,j=c1(t,_,k,x,r,o),b={left:Math.min(j.left-c.left,0),top:Math.min(j.top-c.top,0),right:Math.min(j.right-c.right,0),bottom:Math.min(j.bottom-c.bottom,0)};return{x:_-b.left+b.right,y:k-b.top+b.bottom,zoom:x}},ss=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function gi(t){return t!=null&&t!=="parent"}function vn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function hg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function pg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function jh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function d1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function f1(t){return{...ig,...t||{}}}function Ko(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=gn(t),h=gs({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y:v}=o?ps(h,r):h;return{xSnapped:p,ySnapped:v,...h}}const jc=t=>({width:t.offsetWidth,height:t.offsetHeight}),gg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},h1=["INPUT","SELECT","TEXTAREA"];function mg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:h1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const yg=t=>"clientX"in t,gn=(t,r)=>{var u,c;const o=yg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},bh=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...jc(c)}})};function vg({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=t*.125+a*.375+c*.375+o*.125,v=r*.125+u*.375+h*.375+s*.125,x=Math.abs(p-t),y=Math.abs(v-r);return[p,v,x,y]}function Sl(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function Eh({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case Se.Left:return[r-Sl(r-s,u),o];case Se.Right:return[r+Sl(s-r,u),o];case Se.Top:return[r,o-Sl(o-a,u)];case Se.Bottom:return[r,o+Sl(a-o,u)]}}function xg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top,curvature:c=.25}){const[h,p]=Eh({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[v,x]=Eh({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[y,m,_,k]=vg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:v,targetControlY:x});return[`M${t},${r} C${h},${p} ${v},${x} ${s},${a}`,y,m,_,k]}function wg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const m1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,y1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),v1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",mn.error006()),r;const s=o.getEdgeId||m1;let a;return lg(t)?a={...t}:a={...t,id:s(t)},y1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function _g({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=wg({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,h]}const Ch={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},x1=({source:t,sourcePosition:r=Se.Bottom,target:o})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function w1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:s=Se.Top,center:a,offset:u,stepPosition:c}){const h=Ch[r],p=Ch[s],v={x:t.x+h.x*u,y:t.y+h.y*u},x={x:o.x+p.x*u,y:o.y+p.y*u},y=x1({source:v,sourcePosition:r,target:x}),m=y.x!==0?"x":"y",_=y[m];let k=[],j,b;const E={x:0,y:0},R={x:0,y:0},[,,w,N]=wg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[m]*p[m]===-1){m==="x"?(j=a.x??v.x+(x.x-v.x)*c,b=a.y??(v.y+x.y)/2):(j=a.x??(v.x+x.x)/2,b=a.y??v.y+(x.y-v.y)*c);const G=[{x:j,y:v.y},{x:j,y:x.y}],q=[{x:v.x,y:b},{x:x.x,y:b}];h[m]===_?k=m==="x"?G:q:k=m==="x"?q:G}else{const G=[{x:v.x,y:x.y}],q=[{x:x.x,y:v.y}];if(m==="x"?k=h.x===_?q:G:k=h.y===_?G:q,r===s){const C=Math.abs(t[m]-o[m]);if(C<=u){const V=Math.min(u-1,u-C);h[m]===_?E[m]=(v[m]>t[m]?-1:1)*V:R[m]=(x[m]>o[m]?-1:1)*V}}if(r!==s){const C=m==="x"?"y":"x",V=h[m]===p[C],W=v[C]>x[C],U=v[C]=K?(j=(te.x+ee.x)/2,b=k[0].y):(j=k[0].x,b=(te.y+ee.y)/2)}const A={x:v.x+E.x,y:v.y+E.y},$={x:x.x+R.x,y:x.y+R.y};return[[t,...A.x!==k[0].x||A.y!==k[0].y?[A]:[],...k,...$.x!==k[k.length-1].x||$.y!==k[k.length-1].y?[$]:[],o],j,b,w,N]}function _1(t,r,o,s){const a=Math.min(Mh(t,r)/2,Mh(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const v=t.xo.id===r):t[0])||null}function cc(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function k1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const v=cc(p,r);u.has(v)||(c.push({id:v,color:p.color||o,...p}),u.add(v))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const Sg=1e3,N1=10,bc={nodeOrigin:[0,0],nodeExtent:ns,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},j1={...bc,checkEquality:!0};function Ec(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function b1(t,r,o){const s=Ec(bc,o);for(const a of t.values())if(a.parentId)Mc(a,t,r,s);else{const u=fs(a,s.nodeOrigin),c=gi(a.extent)?a.extent:s.nodeExtent,h=pi(u,c,vn(a));a.internals.positionAbsolute=h}}function E1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function Cc(t){return t==="manual"}function dc(t,r,o,s={}){var x,y;const a=Ec(j1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!Cc(a.zIndexMode)?Sg:0;let p=t.length>0,v=!1;r.clear(),o.clear();for(const m of t){let _=c.get(m.id);if(a.checkEquality&&m===(_==null?void 0:_.internals.userNode))r.set(m.id,_);else{const k=fs(m,a.nodeOrigin),j=gi(m.extent)?m.extent:a.nodeExtent,b=pi(k,j,vn(m));_={...a.defaults,...m,measured:{width:(x=m.measured)==null?void 0:x.width,height:(y=m.measured)==null?void 0:y.height},internals:{positionAbsolute:b,handleBounds:E1(m,_),z:kg(m,h,a.zIndexMode),userNode:m}},r.set(m.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),m.parentId&&Mc(_,r,o,s,u),v||(v=m.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:v}}function C1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function Mc(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=Ec(bc,s),v=t.parentId,x=r.get(v);if(!x){console.warn(`Parent node ${v} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}C1(t,o),a&&!x.parentId&&x.internals.rootParentIndex===void 0&&p==="auto"&&(x.internals.rootParentIndex=++a.i,x.internals.z=x.internals.z+a.i*N1),a&&x.internals.rootParentIndex!==void 0&&(a.i=x.internals.rootParentIndex);const y=u&&!Cc(p)?Sg:0,{x:m,y:_,z:k}=M1(t,x,c,h,y,p),{positionAbsolute:j}=t.internals,b=m!==j.x||_!==j.y;(b||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:b?{x:m,y:_}:j,z:k}})}function kg(t,r,o){const s=pn(t.zIndex)?t.zIndex:0;return Cc(o)?s:s+(t.selected?r:0)}function M1(t,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=vn(t),v=fs(t,o),x=gi(t.extent)?pi(v,t.extent,p):v;let y=pi({x:c+x.x,y:h+x.y},s,p);t.extent==="parent"&&(y=ug(y,p,r));const m=kg(t,a,u),_=r.internals.z??0;return{x:y.x,y:y.y,z:_>=m?_+1:m}}function Pc(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const v=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??os(p),x=cg(v,h.rect);u.set(h.parentId,{expandedRect:x,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},v)=>{var w;const x=p.internals.positionAbsolute,y=vn(p),m=p.origin??s,_=h.x0||k>0||E||R)&&(a.push({id:v,type:"position",position:{x:p.position.x-_+E,y:p.position.y-k+R}}),(w=o.get(v))==null||w.forEach(N=>{t.some(A=>A.id===N.id)||a.push({id:N.id,type:"position",position:{x:N.position.x+_,y:N.position.y+k}})})),(y.width0){const _=Pc(m,r,o,a);v.push(..._)}return{changes:v,updatedInternals:p}}async function I1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Th(t,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${t}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${t}-${u}`;const v=s.get(c)||new Map;s.set(c,v.set(o,r))}}function Ng(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},v=`${a}-${c}--${u}-${h}`,x=`${u}-${h}--${a}-${c}`;Th("source",p,x,t,a,c),Th("target",p,v,t,u,h),r.set(s.id,s)}}function jg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:jg(o,r):!1}function Lh(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function R1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!jg(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function Bu({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[v,x]of r){const y=(c=o.get(v))==null?void 0:c.internals.userNode;y&&a.push({...y,position:x.position,dragging:s})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function T1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=ps(u,r);return{x:c.x-u.x,y:c.y-u.y}}function L1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,v={x:0,y:0},x=null,y=!1,m=null,_=!1,k=!1,j=null;function b({noDragClassName:R,handleSelector:w,domNode:N,isSelectable:A,nodeId:$,nodeClickDistance:F=0}){m=Gt(N);function G({x:ne,y:K}){const{nodeLookup:C,nodeExtent:V,snapGrid:W,snapToGrid:U,nodeOrigin:M,onNodeDrag:D,onSelectionDrag:H,onError:I,updateNodePositions:z}=r();u={x:ne,y:K};let ie=!1;const oe=h.size>1,fe=oe&&V?uc(hs(h)):null,he=oe&&U?T1({dragItems:h,snapGrid:W,x:ne,y:K}):null;for(const[pe,Z]of h){if(!C.has(pe))continue;let se={x:ne-Z.distance.x,y:K-Z.distance.y};U&&(se=he?{x:Math.round(se.x+he.x),y:Math.round(se.y+he.y)}:ps(se,W));let me=null;if(oe&&V&&!Z.extent&&fe){const{positionAbsolute:re}=Z.internals,Ne=re.x-fe.x+V[0][0],Me=re.x+Z.measured.width-fe.x2+V[1][0],Te=re.y-fe.y+V[0][1],$e=re.y+Z.measured.height-fe.y2+V[1][1];me=[[Ne,Te],[Me,$e]]}const{position:ke,positionAbsolute:ve}=ag({nodeId:pe,nextPosition:se,nodeLookup:C,nodeExtent:me||V,nodeOrigin:M,onError:I});ie=ie||Z.position.x!==ke.x||Z.position.y!==ke.y,Z.position=ke,Z.internals.positionAbsolute=ve}if(k=k||ie,!!ie&&(z(h,!0),j&&(s||D||!$&&H))){const[pe,Z]=Bu({nodeId:$,dragItems:h,nodeLookup:C});s==null||s(j,h,pe,Z),D==null||D(j,pe,Z),$||H==null||H(j,Z)}}async function q(){if(!x)return;const{transform:ne,panBy:K,autoPanSpeed:C,autoPanOnNodeDrag:V}=r();if(!V){p=!1,cancelAnimationFrame(c);return}const[W,U]=kc(v,x,C);(W!==0||U!==0)&&(u.x=(u.x??0)-W/ne[2],u.y=(u.y??0)-U/ne[2],await K({x:W,y:U})&&G(u)),c=requestAnimationFrame(q)}function te(ne){var oe;const{nodeLookup:K,multiSelectionActive:C,nodesDraggable:V,transform:W,snapGrid:U,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:H,onSelectionDragStart:I,unselectNodesAndEdges:z}=r();y=!0,(!D||!A)&&!C&&$&&((oe=K.get($))!=null&&oe.selected||z()),A&&D&&$&&(t==null||t($));const ie=Ko(ne.sourceEvent,{transform:W,snapGrid:U,snapToGrid:M,containerBounds:x});if(u=ie,h=R1(K,V,ie,$),h.size>0&&(o||H||!$&&I)){const[fe,he]=Bu({nodeId:$,dragItems:h,nodeLookup:K});o==null||o(ne.sourceEvent,h,fe,he),H==null||H(ne.sourceEvent,fe,he),$||I==null||I(ne.sourceEvent,he)}}const ee=Hp().clickDistance(F).on("start",ne=>{const{domNode:K,nodeDragThreshold:C,transform:V,snapGrid:W,snapToGrid:U}=r();x=(K==null?void 0:K.getBoundingClientRect())||null,_=!1,k=!1,j=ne.sourceEvent,C===0&&te(ne),u=Ko(ne.sourceEvent,{transform:V,snapGrid:W,snapToGrid:U,containerBounds:x}),v=gn(ne.sourceEvent,x)}).on("drag",ne=>{const{autoPanOnNodeDrag:K,transform:C,snapGrid:V,snapToGrid:W,nodeDragThreshold:U,nodeLookup:M}=r(),D=Ko(ne.sourceEvent,{transform:C,snapGrid:V,snapToGrid:W,containerBounds:x});if(j=ne.sourceEvent,(ne.sourceEvent.type==="touchmove"&&ne.sourceEvent.touches.length>1||$&&!M.has($))&&(_=!0),!_){if(!p&&K&&y&&(p=!0,q()),!y){const H=gn(ne.sourceEvent,x),I=H.x-v.x,z=H.y-v.y;Math.sqrt(I*I+z*z)>U&&te(ne)}(u.x!==D.xSnapped||u.y!==D.ySnapped)&&h&&y&&(v=gn(ne.sourceEvent,x),G(D))}}).on("end",ne=>{if(!y||_){_&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,y=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:K,updateNodePositions:C,onNodeDragStop:V,onSelectionDragStop:W}=r();if(k&&(C(h,!1),k=!1),a||V||!$&&W){const[U,M]=Bu({nodeId:$,dragItems:h,nodeLookup:K,dragging:!1});a==null||a(ne.sourceEvent,h,U,M),V==null||V(ne.sourceEvent,U,M),$||W==null||W(ne.sourceEvent,M)}}}).filter(ne=>{const K=ne.target;return!ne.button&&(!R||!Lh(K,`.${R}`,N))&&(!w||Lh(K,w,N))});m.call(ee)}function E(){m==null||m.on(".drag",null)}return{update:b,destroy:E}}function A1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())Hl(a,os(u))>0&&s.push(u);return s}const $1=250;function z1(t,r,o,s){var h,p;let a=[],u=1/0;const c=A1(t,o,r+$1);for(const v of c){const x=[...((h=v.internals.handleBounds)==null?void 0:h.source)??[],...((p=v.internals.handleBounds)==null?void 0:p.target)??[]];for(const y of x){if(s.nodeId===y.nodeId&&s.type===y.type&&s.id===y.id)continue;const{x:m,y:_}=mi(v,y,y.position,!0),k=Math.sqrt(Math.pow(m-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const v=s.type==="source"?"target":"source";return a.find(x=>x.type===v)??a[0]}return a[0]}function bg(t,r,o,s,a,u=!1){var v,x,y;const c=s.get(t);if(!c)return null;const h=a==="strict"?(v=c.internals.handleBounds)==null?void 0:v[r]:[...((x=c.internals.handleBounds)==null?void 0:x.source)??[],...((y=c.internals.handleBounds)==null?void 0:y.target)??[]],p=(o?h==null?void 0:h.find(m=>m.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...mi(c,p,p.position,!0)}:p}function Eg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function D1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const Cg=()=>!0;function O1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:v,autoPanOnConnect:x,flowId:y,panBy:m,cancelConnection:_,onConnectStart:k,onConnect:j,onConnectEnd:b,isValidConnection:E=Cg,onReconnectEnd:R,updateConnection:w,getTransform:N,getFromHandle:A,autoPanSpeed:$,dragThreshold:F=1,handleDomNode:G}){const q=gg(t.target);let te=0,ee;const{x:ne,y:K}=gn(t),C=Eg(u,G),V=h==null?void 0:h.getBoundingClientRect();let W=!1;if(!V||!C)return;const U=bg(a,C,s,p,r);if(!U)return;let M=gn(t,V),D=!1,H=null,I=!1,z=null;function ie(){if(!x||!V)return;const[ke,ve]=kc(M,V,$);m({x:ke,y:ve}),te=requestAnimationFrame(ie)}const oe={...U,nodeId:a,type:C,position:U.position},fe=p.get(a);let pe={inProgress:!0,isValid:null,from:mi(fe,oe,Se.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:fe,to:M,toHandle:null,toPosition:Sh[oe.position],toNode:null,pointer:M};function Z(){W=!0,w(pe),k==null||k(t,{nodeId:a,handleId:s,handleType:C})}F===0&&Z();function se(ke){if(!W){const{x:$e,y:st}=gn(ke),lt=$e-ne,at=st-K;if(!(lt*lt+at*at>F*F))return;Z()}if(!A()||!oe){me(ke);return}const ve=N();M=gn(ke,V),ee=z1(gs(M,ve,!1,[1,1]),o,p,oe),D||(ie(),D=!0);const re=Mg(ke,{handle:ee,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:E,doc:q,lib:v,flowId:y,nodeLookup:p});z=re.handleDomNode,H=re.connection,I=D1(!!ee,re.isValid);const Ne=p.get(a),Me=Ne?mi(Ne,oe,Se.Left,!0):pe.from,Te={...pe,from:Me,isValid:I,to:re.toHandle&&I?eo({x:re.toHandle.x,y:re.toHandle.y},ve):M,toHandle:re.toHandle,toPosition:I&&re.toHandle?re.toHandle.position:Sh[oe.position],toNode:re.toHandle?p.get(re.toHandle.nodeId):null,pointer:M};w(Te),pe=Te}function me(ke){if(!("touches"in ke&&ke.touches.length>0)){if(W){(ee||z)&&H&&I&&(j==null||j(H));const{inProgress:ve,...re}=pe,Ne={...re,toPosition:pe.toHandle?pe.toPosition:null};b==null||b(ke,Ne),u&&(R==null||R(ke,Ne))}_(),cancelAnimationFrame(te),D=!1,I=!1,H=null,z=null,q.removeEventListener("mousemove",se),q.removeEventListener("mouseup",me),q.removeEventListener("touchmove",se),q.removeEventListener("touchend",me)}}q.addEventListener("mousemove",se),q.addEventListener("mouseup",me),q.addEventListener("touchmove",se),q.addEventListener("touchend",me)}function Mg(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:v=Cg,nodeLookup:x}){const y=u==="target",m=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=gn(t),j=c.elementFromPoint(_,k),b=j!=null&&j.classList.contains(`${h}-flow__handle`)?j:m,E={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const R=Eg(void 0,b),w=b.getAttribute("data-nodeid"),N=b.getAttribute("data-handleid"),A=b.classList.contains("connectable"),$=b.classList.contains("connectableend");if(!w||!R)return E;const F={source:y?w:s,sourceHandle:y?N:a,target:y?s:w,targetHandle:y?a:N};E.connection=F;const q=A&&$&&(o===Zi.Strict?y&&R==="source"||!y&&R==="target":w!==s||N!==a);E.isValid=q&&v(F),E.toHandle=bg(w,R,N,x,o,!0)}return E}const fc={onPointerDown:O1,isValid:Mg};function F1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Gt(t);function u({translateExtent:h,width:p,height:v,zoomStep:x=1,pannable:y=!0,zoomable:m=!0,inversePan:_=!1}){const k=w=>{if(w.sourceEvent.type!=="wheel"||!r)return;const N=o(),A=w.sourceEvent.ctrlKey&&ss()?10:1,$=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*x,F=N[2]*Math.pow(2,$*A);r.scaleTo(F)};let j=[0,0];const b=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(j=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},E=w=>{const N=o();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!r)return;const A=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],$=[A[0]-j[0],A[1]-j[1]];j=A;const F=s()*Math.max(N[2],Math.log(N[2]))*(_?-1:1),G={x:N[0]-$[0]*F,y:N[1]-$[1]*F},q=[[0,0],[p,v]];r.setViewportConstrained({x:G.x,y:G.y,zoom:N[2]},q,h)},R=ng().on("start",b).on("zoom",y?E:null).on("zoom.wheel",m?k:null);a.call(R,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:fn}}const Jl=t=>({x:t.x,y:t.y,zoom:t.k}),Vu=({x:t,y:r,zoom:o})=>Kl.translate(t,r).scale(o),Rr=(t,r)=>t.target.closest(`.${r}`),Pg=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),H1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Wu=(t,r=0,o=H1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Ig=t=>{const r=t.ctrlKey&&ss()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function B1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:v}){return x=>{if(Rr(x,r))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const y=o.property("__zoom").k||1;if(x.ctrlKey&&c){const b=fn(x),E=Ig(x),R=y*Math.pow(2,E);s.scaleTo(o,R,b,x);return}const m=x.deltaMode===1?20:1;let _=a===di.Vertical?0:x.deltaX*m,k=a===di.Horizontal?0:x.deltaY*m;!ss()&&x.shiftKey&&a!==di.Vertical&&(_=x.deltaY*m,k=0),s.translateBy(o,-(_/y)*u,-(k/y)*u,{internal:!0});const j=Jl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(x,j):(t.isPanScrolling=!0,h==null||h(x,j)),t.panScrollTimeout=setTimeout(()=>{v==null||v(x,j),t.isPanScrolling=!1},150)}}function V1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=Rr(s,t);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function W1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=Jl(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function U1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;t.usedRightMouseButton=!!(o&&Pg(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,Jl(u.transform)))}}function Y1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&Pg(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const p=Jl(c.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function G1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:v,lib:x,connectionInProgress:y}){return m=>{var E;const _=r||o,k=s&&m.ctrlKey,j=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(Rr(m,`${x}-flow__node`)||Rr(m,`${x}-flow__edge`)||Rr(m,`${x}-flow__selection`)||Rr(m,`${x}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!c&&!s||h||y&&!j||Rr(m,p)&&j||Rr(m,v)&&(!j||u&&j&&!r)||!s&&m.ctrlKey&&j)return!1;if(!s&&m.type==="touchstart"&&((E=m.touches)==null?void 0:E.length)>1)return m.preventDefault(),!1;if(!_&&!u&&!k&&j||!a&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(a)&&!a.includes(m.button)&&m.type==="mousedown")return!1;const b=Array.isArray(a)&&a.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||j||t)&&b}}function X1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const v={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=t.getBoundingClientRect();let y=[[0,0],[x.width,x.height]];const m=typeof ResizeObserver<"u"?new ResizeObserver(K=>{const C=K[0];C&&(y=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;m==null||m.observe(t);const _=ng().extent(()=>y).scaleExtent([r,o]).translateExtent(s),k=Gt(t).call(_);N({x:a.x,y:a.y,zoom:Ji(a.zoom,r,o)},[[0,0],[x.width,x.height]],s);const j=k.on("wheel.zoom"),b=k.on("dblclick.zoom");_.wheelDelta(Ig);async function E(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?qo:Ml).transform(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function R({noWheelClassName:K,noPanClassName:C,onPaneContextMenu:V,userSelectionActive:W,panOnScroll:U,panOnDrag:M,panOnScrollMode:D,panOnScrollSpeed:H,preventScrolling:I,zoomOnPinch:z,zoomOnScroll:ie,zoomOnDoubleClick:oe,panActivationKeyPressed:fe=!1,zoomActivationKeyPressed:he,lib:pe,onTransformChange:Z,connectionInProgress:se,paneClickDistance:me,selectionOnDrag:ke}){W&&!v.isZoomingOrPanning&&w();const ve=U&&!he&&!W;_.clickDistance(ke?1/0:!pn(me)||me<0?0:me);const re=ve?B1({zoomPanValues:v,noWheelClassName:K,d3Selection:k,d3Zoom:_,panOnScrollMode:D,panOnScrollSpeed:H,zoomOnPinch:z,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):V1({noWheelClassName:K,preventScrolling:I,d3ZoomHandler:j});k.on("wheel.zoom",re,{passive:!1});const Ne=W1({zoomPanValues:v,onDraggingChange:p,onPanZoomStart:c});_.on("start",Ne);const Me=U1({zoomPanValues:v,panOnDrag:M,onPaneContextMenu:!!V,onPanZoom:u,onTransformChange:Z});_.on("zoom",Me);const Te=Y1({zoomPanValues:v,panOnDrag:M,panOnScroll:U,onPaneContextMenu:V,onPanZoomEnd:h,onDraggingChange:p});_.on("end",Te);const $e=G1({panActivationKeyPressed:fe,zoomActivationKeyPressed:he,panOnDrag:M,zoomOnScroll:ie,panOnScroll:U,zoomOnDoubleClick:oe,zoomOnPinch:z,userSelectionActive:W,noPanClassName:C,noWheelClassName:K,lib:pe,connectionInProgress:se});_.filter($e),oe?k.on("dblclick.zoom",b):k.on("dblclick.zoom",null)}function w(){_.on("zoom",null)}async function N(K,C,V){const W=Vu(K),U=_==null?void 0:_.constrain()(W,C,V);return U&&await E(U),U}async function A(K,C){const V=Vu(K);return await E(V,C),V}function $(K){if(k){const C=Vu(K),V=k.property("__zoom");(V.k!==K.zoom||V.x!==K.x||V.y!==K.y)&&(_==null||_.transform(k,C,null,{sync:!0}))}}function F(){const K=k?tg(k.node()):{x:0,y:0,k:1};return{x:K.x,y:K.y,zoom:K.k}}async function G(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?qo:Ml).scaleTo(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}async function q(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?qo:Ml).scaleBy(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function te(K){_==null||_.scaleExtent(K)}function ee(K){_==null||_.translateExtent(K)}function ne(K){const C=!pn(K)||K<0?0:K;_==null||_.clickDistance(C)}return{update:R,destroy:w,setViewport:A,setViewportConstrained:N,getViewport:F,scaleTo:G,scaleBy:q,setScaleExtent:te,setTranslateExtent:ee,syncViewport:$,setClickDistance:ne}}var to;(function(t){t.Line="line",t.Handle="handle"})(to||(to={}));function q1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function Ah(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function Pr(t,r){return Math.max(0,r-t)}function Ir(t,r){return Math.max(0,t-r)}function kl(t,r,o){return Math.max(0,r-t,t-o)}function $h(t,r){return t?!r:r}function K1(t,r,o,s,a,u,c,h){let{affectsX:p,affectsY:v}=r;const{isHorizontal:x,isVertical:y}=r,m=x&&y,{xSnapped:_,ySnapped:k}=o,{minWidth:j,maxWidth:b,minHeight:E,maxHeight:R}=s,{x:w,y:N,width:A,height:$,aspectRatio:F}=t;let G=Math.floor(x?_-t.pointerX:0),q=Math.floor(y?k-t.pointerY:0);const te=A+(p?-G:G),ee=$+(v?-q:q),ne=-u[0]*A,K=-u[1]*$;let C=kl(te,j,b),V=kl(ee,E,R);if(c){let M=0,D=0;p&&G<0?M=Pr(w+G+ne,c[0][0]):!p&&G>0&&(M=Ir(w+te+ne,c[1][0])),v&&q<0?D=Pr(N+q+K,c[0][1]):!v&&q>0&&(D=Ir(N+ee+K,c[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(h){let M=0,D=0;p&&G>0?M=Ir(w+G,h[0][0]):!p&&G<0&&(M=Pr(w+te,h[1][0])),v&&q>0?D=Ir(N+q,h[0][1]):!v&&q<0&&(D=Pr(N+ee,h[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(a){if(x){const M=kl(te/F,E,R)*F;if(C=Math.max(C,M),c){let D=0;!p&&!v||p&&!v&&m?D=Ir(N+K+te/F,c[1][1])*F:D=Pr(N+K+(p?G:-G)/F,c[0][1])*F,C=Math.max(C,D)}if(h){let D=0;!p&&!v||p&&!v&&m?D=Pr(N+te/F,h[1][1])*F:D=Ir(N+(p?G:-G)/F,h[0][1])*F,C=Math.max(C,D)}}if(y){const M=kl(ee*F,j,b)/F;if(V=Math.max(V,M),c){let D=0;!p&&!v||v&&!p&&m?D=Ir(w+ee*F+ne,c[1][0])/F:D=Pr(w+(v?q:-q)*F+ne,c[0][0])/F,V=Math.max(V,D)}if(h){let D=0;!p&&!v||v&&!p&&m?D=Pr(w+ee*F,h[1][0])/F:D=Ir(w+(v?q:-q)*F,h[0][0])/F,V=Math.max(V,D)}}}q=q+(q<0?V:-V),G=G+(G<0?C:-C),a&&(m?te>ee*F?q=($h(p,v)?-G:G)/F:G=($h(p,v)?-q:q)*F:x?(q=G/F,v=p):(G=q*F,p=v));const W=p?w+G:w,U=v?N+q:N;return{width:A+(p?-G:G),height:$+(v?-q:q),x:u[0]*G*(p?-1:1)+W,y:u[1]*q*(v?-1:1)+U}}const Rg={width:0,height:0,x:0,y:0},Q1={...Rg,pointerX:0,pointerY:0,aspectRatio:1};function Z1(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function J1({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Gt(t);let c={controlDirection:Ah("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:v,boundaries:x,keepAspectRatio:y,resizeDirection:m,onResizeStart:_,onResize:k,onResizeEnd:j,shouldResize:b}){let E={...Rg},R={...Q1};c={boundaries:x,resizeDirection:m,keepAspectRatio:y,controlDirection:Ah(v)};let w,N=null,A=[],$,F,G,q=!1;const te=Hp().on("start",ee=>{const{nodeLookup:ne,transform:K,snapGrid:C,snapToGrid:V,nodeOrigin:W,paneDomNode:U}=o();if(w=ne.get(r),!w)return;N=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:D}=Ko(ee.sourceEvent,{transform:K,snapGrid:C,snapToGrid:V,containerBounds:N});E={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},R={...E,pointerX:M,pointerY:D,aspectRatio:E.width/E.height},$=void 0,F=gi(w.extent)?w.extent:void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&($=ne.get(w.parentId)),$&&w.extent==="parent"&&(F=[[0,0],[$.measured.width,$.measured.height]]),A=[],G=void 0;for(const[H,I]of ne)if(I.parentId===r&&(A.push({id:H,position:{...I.position},extent:I.extent}),I.extent==="parent"||I.expandParent)){const z=Z1(I,w,I.origin??W);G?G=[[Math.min(z[0][0],G[0][0]),Math.min(z[0][1],G[0][1])],[Math.max(z[1][0],G[1][0]),Math.max(z[1][1],G[1][1])]]:G=z}_==null||_(ee,{...E})}).on("drag",ee=>{const{transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V}=o(),W=Ko(ee.sourceEvent,{transform:ne,snapGrid:K,snapToGrid:C,containerBounds:N}),U=[];if(!w)return;const{x:M,y:D,width:H,height:I}=E,z={},ie=w.origin??V,{width:oe,height:fe,x:he,y:pe}=K1(R,c.controlDirection,W,c.boundaries,c.keepAspectRatio,ie,F,G),Z=oe!==H,se=fe!==I,me=he!==M&&Z,ke=pe!==D&&se;if(!me&&!ke&&!Z&&!se)return;if((me||ke||ie[0]===1||ie[1]===1)&&(z.x=me?he:E.x,z.y=ke?pe:E.y,E.x=z.x,E.y=z.y,A.length>0)){const Me=he-M,Te=pe-D;for(const $e of A)$e.position={x:$e.position.x-Me+ie[0]*(oe-H),y:$e.position.y-Te+ie[1]*(fe-I)},U.push($e)}if((Z||se)&&(z.width=Z&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:E.width,z.height=se&&(!c.resizeDirection||c.resizeDirection==="vertical")?fe:E.height,E.width=z.width,E.height=z.height),$&&w.expandParent){const Me=ie[0]*(z.width??0);z.x&&z.x{q&&(j==null||j(ee,{...E}),a==null||a({...E}),q=!1)});u.call(te)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Uu={exports:{}},Yu={},Gu={exports:{}},Xu={};/** + * @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 zh;function e_(){if(zh)return Xu;zh=1;var t=us();function r(y,m){return y===m&&(y!==0||1/y===1/m)||y!==y&&m!==m}var o=typeof Object.is=="function"?Object.is:r,s=t.useState,a=t.useEffect,u=t.useLayoutEffect,c=t.useDebugValue;function h(y,m){var _=m(),k=s({inst:{value:_,getSnapshot:m}}),j=k[0].inst,b=k[1];return u(function(){j.value=_,j.getSnapshot=m,p(j)&&b({inst:j})},[y,_,m]),a(function(){return p(j)&&b({inst:j}),y(function(){p(j)&&b({inst:j})})},[y]),c(_),_}function p(y){var m=y.getSnapshot;y=y.value;try{var _=m();return!o(y,_)}catch{return!0}}function v(y,m){return m()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?v:h;return Xu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:x,Xu}var Dh;function t_(){return Dh||(Dh=1,Gu.exports=e_()),Gu.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 Oh;function n_(){if(Oh)return Yu;Oh=1;var t=us(),r=t_();function o(v,x){return v===x&&(v!==0||1/v===1/x)||v!==v&&x!==x}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Yu.useSyncExternalStoreWithSelector=function(v,x,y,m,_){var k=u(null);if(k.current===null){var j={hasValue:!1,value:null};k.current=j}else j=k.current;k=h(function(){function E($){if(!R){if(R=!0,w=$,$=m($),_!==void 0&&j.hasValue){var F=j.value;if(_(F,$))return N=F}return N=$}if(F=N,s(w,$))return F;var G=m($);return _!==void 0&&_(F,G)?(w=$,F):(w=$,N=G)}var R=!1,w,N,A=y===void 0?null:y;return[function(){return E(x())},A===null?void 0:function(){return E(A())}]},[x,y,m,_]);var b=a(v,k[0],k[1]);return c(function(){j.hasValue=!0,j.value=b},[b]),p(b),b},Yu}var Fh;function r_(){return Fh||(Fh=1,Uu.exports=n_()),Uu.exports}var i_=r_();const o_=kp(i_),s_={},Hh=t=>{let r;const o=new Set,s=(x,y)=>{const m=typeof x=="function"?x(r):x;if(!Object.is(m,r)){const _=r;r=y??(typeof m!="object"||m===null)?m:Object.assign({},r,m),o.forEach(k=>k(r,_))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>v,subscribe:x=>(o.add(x),()=>o.delete(x)),destroy:()=>{(s_?"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."),o.clear()}},v=r=t(s,a,p);return p},l_=t=>t?Hh(t):Hh,{useDebugValue:a_}=r0,{useSyncExternalStoreWithSelector:u_}=o_,c_=t=>t;function Tg(t,r=c_,o){const s=u_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return a_(s),s}const Bh=(t,r)=>{const o=l_(t),s=(a,u=r)=>Tg(o,a,u);return Object.assign(s,o),s},d_=(t,r)=>t?Bh(t,r):Bh;function Qe(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}Np();const ea=L.createContext(null),f_=ea.Provider,Lg=mn.error001("react");function De(t,r){const o=L.useContext(ea);if(o===null)throw new Error(Lg);return Tg(o,t,r)}function Ye(){const t=L.useContext(ea);if(t===null)throw new Error(Lg);return L.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Vh={display:"none"},h_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ag="react-flow__node-desc",$g="react-flow__edge-desc",p_="react-flow__aria-live",g_=t=>t.ariaLiveMessage,m_=t=>t.ariaLabelConfig;function y_({rfId:t}){const r=De(g_);return d.jsx("div",{id:`${p_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:h_,children:r})}function v_({rfId:t,disableKeyboardA11y:r}){const o=De(m_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${Ag}-${t}`,style:Vh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${$g}-${t}`,style:Vh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(y_,{rfId:t})]})}const ta=L.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return d.jsx("div",{className:nt(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});ta.displayName="Panel";const Wh="https://reactflow.dev?utm_source=attribution";function x_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:d.jsx(ta,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Wh}`,children:d.jsx("a",{href:Wh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const w_=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},Nl=t=>t.id;function __(t,r){return Qe(t.selectedNodes.map(Nl),r.selectedNodes.map(Nl))&&Qe(t.selectedEdges.map(Nl),r.selectedEdges.map(Nl))}function S_({onSelectionChange:t}){const r=Ye(),{selectedNodes:o,selectedEdges:s}=De(w_,__);return L.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const k_=t=>!!t.onSelectionChangeHandlers;function N_({onSelectionChange:t}){const r=De(k_);return t||r?d.jsx(S_,{onSelectionChange:t}):null}const zg=[0,0],j_={x:0,y:0,zoom:1},b_=["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"],Uh=[...b_,"rfId"],E_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Yh={translateExtent:ns,nodeOrigin:zg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function C_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=De(E_,Qe),v=Ye();L.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{x.current=Yh,h()}),[]);const x=L.useRef(Yh);return L.useEffect(()=>{for(const y of Uh){const m=t[y],_=x.current[y];m!==_&&(typeof t[y]>"u"||(y==="nodes"?r(m):y==="edges"?o(m):y==="minZoom"?s(m):y==="maxZoom"?a(m):y==="translateExtent"?u(m):y==="nodeExtent"?c(m):y==="ariaLabelConfig"?v.setState({ariaLabelConfig:f1(m)}):y==="fitView"?v.setState({fitViewQueued:m}):y==="fitViewOptions"?v.setState({fitViewOptions:m}):v.setState({[y]:m})))}x.current=t},Uh.map(y=>t[y])),null}function Gh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function M_(t){var s;const[r,o]=L.useState(t==="system"?null:t);return L.useEffect(()=>{if(t!=="system"){o(t);return}const a=Gh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=Gh())!=null&&s.matches?"dark":"light"}const Xh=typeof document<"u"?document:null;function ls(t=null,r={target:Xh,actInsideInputWithModifier:!0}){const[o,s]=L.useState(!1),a=L.useRef(!1),u=L.useRef(new Set([])),[c,h]=L.useMemo(()=>{if(t!==null){const v=(Array.isArray(t)?t:[t]).filter(y=>typeof y=="string").map(y=>y.replace(/\+/g,` +`).replace(` + +`,` ++`).split(` +`)),x=v.reduce((y,m)=>y.concat(...m),[]);return[v,x]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Xh,v=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const x=_=>{var b,E;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!v)&&mg(_))return!1;const j=Kh(_.code,h);if(u.current.add(_[j]),qh(c,u.current,!1)){const R=((E=(b=_.composedPath)==null?void 0:b.call(_))==null?void 0:E[0])||_.target,w=(R==null?void 0:R.nodeName)==="BUTTON"||(R==null?void 0:R.nodeName)==="A";r.preventDefault!==!1&&(a.current||!w)&&_.preventDefault(),s(!0)}},y=_=>{const k=Kh(_.code,h);qh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},m=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",x),p==null||p.addEventListener("keyup",y),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{p==null||p.removeEventListener("keydown",x),p==null||p.removeEventListener("keyup",y),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,s]),o}function qh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Kh(t,r){return r.includes(t)?"code":"key"}const P_=()=>{const t=Ye();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=Nc(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),v={x:r.x-h,y:r.y-p},x=o.snapGrid??a,y=o.snapToGrid??u;return gs(v,s,y,x)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=eo(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function Dg(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)I_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function I_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function R_(t,r){return Dg(t,r)}function T_(t,r){return Dg(t,r)}function ai(t,r){return{id:t,type:"select",selected:r}}function Gi(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(ai(u.id,c)))}return s}function Qh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Zh(t){return{id:t.id,type:"remove"}}const L_=fg();function A_(t,r,o={}){return v1(t,r,{...o,onError:o.onError??L_})}const Jh=t=>r1(t),$_=t=>lg(t);function Og(t){return L.forwardRef(t)}const Fg=typeof window<"u"?L.useLayoutEffect:L.useEffect;function ep(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>z_(()=>o(a=>a+BigInt(1))));return Fg(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function z_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Hg=L.createContext(null);function D_({children:t}){const r=Ye(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:v,hasDefaultNodes:x,onNodesChange:y,nodeLookup:m,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let j=p;for(const E of h)j=typeof E=="function"?E(j):E;let b=Qh({items:j,lookup:m});for(const E of k.values())b=E(b);x&&v(j),b.length>0?y==null||y(b):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:R,setNodes:w}=r.getState();E&&w(R)})},[]),s=ep(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:v,hasDefaultEdges:x,onEdgesChange:y,edgeLookup:m}=r.getState();let _=p;for(const k of h)_=typeof k=="function"?k(_):k;x?v(_):y&&y(Qh({items:_,lookup:m}))},[]),u=ep(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Hg.Provider,{value:c,children:t})}function O_(){const t=L.useContext(Hg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const F_=t=>!!t.panZoom;function na(){const t=P_(),r=Ye(),o=O_(),s=De(F_),a=L.useMemo(()=>{const u=y=>r.getState().nodeLookup.get(y),c=y=>{o.nodeQueue.push(y)},h=y=>{o.edgeQueue.push(y)},p=y=>{var E,R;const{nodeLookup:m,nodeOrigin:_}=r.getState(),k=Jh(y)?y:m.get(y.id),j=k.parentId?pg(k.position,k.measured,k.parentId,m,_):k.position,b={...k,position:j,width:((E=k.measured)==null?void 0:E.width)??k.width,height:((R=k.measured)==null?void 0:R.height)??k.height};return os(b)},v=(y,m,_={replace:!1})=>{c(k=>k.map(j=>{if(j.id===y){const b=typeof m=="function"?m(j):m;return _.replace&&Jh(b)?b:{...j,...b}}return j}))},x=(y,m,_={replace:!1})=>{h(k=>k.map(j=>{if(j.id===y){const b=typeof m=="function"?m(j):m;return _.replace&&$_(b)?b:{...j,...b}}return j}))};return{getNodes:()=>r.getState().nodes.map(y=>({...y})),getNode:y=>{var m;return(m=u(y))==null?void 0:m.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:y=[]}=r.getState();return y.map(m=>({...m}))},getEdge:y=>r.getState().edgeLookup.get(y),setNodes:c,setEdges:h,addNodes:y=>{const m=Array.isArray(y)?y:[y];o.nodeQueue.push(_=>[..._,...m])},addEdges:y=>{const m=Array.isArray(y)?y:[y];o.edgeQueue.push(_=>[..._,...m])},toObject:()=>{const{nodes:y=[],edges:m=[],transform:_}=r.getState(),[k,j,b]=_;return{nodes:y.map(E=>({...E})),edges:m.map(E=>({...E})),viewport:{x:k,y:j,zoom:b}}},deleteElements:async({nodes:y=[],edges:m=[]})=>{const{nodes:_,edges:k,onNodesDelete:j,onEdgesDelete:b,triggerNodeChanges:E,triggerEdgeChanges:R,onDelete:w,onBeforeDelete:N}=r.getState(),{nodes:A,edges:$}=await a1({nodesToRemove:y,edgesToRemove:m,nodes:_,edges:k,onBeforeDelete:N}),F=$.length>0,G=A.length>0;if(F){const q=$.map(Zh);b==null||b($),R(q)}if(G){const q=A.map(Zh);j==null||j(A),E(q)}return(G||F)&&(w==null||w({nodes:A,edges:$})),{deletedNodes:A,deletedEdges:$}},getIntersectingNodes:(y,m=!0,_)=>{const k=Nh(y),j=k?y:p(y),b=_!==void 0;return j?(_||r.getState().nodes).filter(E=>{const R=r.getState().nodeLookup.get(E.id);if(R&&!k&&(E.id===y.id||!R.internals.positionAbsolute))return!1;const w=os(b?E:R),N=Hl(w,j);return m&&N>0||N>=w.width*w.height||N>=j.width*j.height}):[]},isNodeIntersecting:(y,m,_=!0)=>{const j=Nh(y)?y:p(y);if(!j)return!1;const b=Hl(j,m);return _&&b>0||b>=m.width*m.height||b>=j.width*j.height},updateNode:v,updateNodeData:(y,m,_={replace:!1})=>{v(y,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},updateEdge:x,updateEdgeData:(y,m,_={replace:!1})=>{x(y,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},getNodesBounds:y=>{const{nodeLookup:m,nodeOrigin:_}=r.getState();return i1(y,{nodeLookup:m,nodeOrigin:_})},getHandleConnections:({type:y,id:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${y}${m?`-${m}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:y,handleId:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${y?m?`-${y}-${m}`:`-${y}`:""}`))==null?void 0:k.values())??[])},fitView:async y=>{const m=r.getState().fitViewResolver??d1();return r.setState({fitViewQueued:!0,fitViewOptions:y,fitViewResolver:m}),o.nodeQueue.push(_=>[..._]),m.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const tp=t=>t.selected,H_=typeof window<"u"?window:void 0;function B_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ye(),{deleteElements:s}=na(),a=ls(t,{actInsideInputWithModifier:!1}),u=ls(r,{target:H_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(tp),edges:c.filter(tp)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function V_(t){const r=Ye();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=jc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",mn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const ra={position:"absolute",width:"100%",height:"100%",top:0,left:0},W_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function U_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=di.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:v,translateExtent:x,minZoom:y,maxZoom:m,zoomActivationKeyCode:_,preventScrolling:k=!0,children:j,noWheelClassName:b,noPanClassName:E,onViewportChange:R,isControlledViewport:w,paneClickDistance:N,selectionOnDrag:A}){const $=Ye(),F=L.useRef(null),{userSelectionActive:G,lib:q,connectionInProgress:te}=De(W_,Qe),ee=ls(_),ne=L.useRef();V_(F);const K=L.useCallback(C=>{R==null||R({x:C[0],y:C[1],zoom:C[2]}),w||$.setState({transform:C})},[R,w]);return L.useEffect(()=>{if(F.current){ne.current=X1({domNode:F.current,minZoom:y,maxZoom:m,translateExtent:x,viewport:v,onDraggingChange:U=>$.setState(M=>M.paneDragging===U?M:{paneDragging:U}),onPanZoomStart:(U,M)=>{const{onViewportChangeStart:D,onMoveStart:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoom:(U,M)=>{const{onViewportChange:D,onMove:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoomEnd:(U,M)=>{const{onViewportChangeEnd:D,onMoveEnd:H}=$.getState();H==null||H(U,M),D==null||D(M)}});const{x:C,y:V,zoom:W}=ne.current.getViewport();return $.setState({panZoom:ne.current,transform:[C,V,W],domNode:F.current.closest(".react-flow")}),()=>{var U;(U=ne.current)==null||U.destroy()}}},[]),L.useEffect(()=>{var C;(C=ne.current)==null||C.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:ee,preventScrolling:k,noPanClassName:E,userSelectionActive:G,noWheelClassName:b,lib:q,onTransformChange:K,connectionInProgress:te,selectionOnDrag:A,paneClickDistance:N})},[t,r,o,s,a,u,c,h,p,ee,k,E,G,b,q,K,te,A,N]),d.jsx("div",{className:"react-flow__renderer",ref:F,style:ra,children:j})}const Y_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function G_(){const{userSelectionActive:t,userSelectionRect:r}=De(Y_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const qu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},X_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function q_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=rs.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:v,onPaneContextMenu:x,onPaneScroll:y,onPaneMouseEnter:m,onPaneMouseMove:_,onPaneMouseLeave:k,children:j}){const b=L.useRef(0),E=Ye(),{userSelectionActive:R,elementsSelectable:w,dragging:N,panBy:A,autoPanSpeed:$}=De(X_,Qe),F=w&&(t||R),G=L.useRef(null),q=L.useRef(),te=L.useRef(new Set),ee=L.useRef(new Set),ne=L.useRef(!1),K=L.useRef(!1),C=L.useRef({x:0,y:0}),V=L.useRef(!1),W=Z=>{if(K.current||ne.current||E.getState().connection.inProgress){K.current=!1,ne.current=!1;return}v==null||v(Z),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},U=Z=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Z.preventDefault();return}x==null||x(Z)},M=y?Z=>y(Z):void 0,D=Z=>{K.current&&(Z.stopPropagation(),K.current=!1)},H=Z=>{var $e,st;if(Z.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:se,transform:me}=E.getState();if(q.current=se==null?void 0:se.getBoundingClientRect(),!q.current)return;const ke=Z.target===G.current;if(!ke&&!!Z.target.closest(".nokey")||!t||!(c&&ke||r)||Z.button!==0||!Z.isPrimary)return;(st=($e=Z.target)==null?void 0:$e.setPointerCapture)==null||st.call($e,Z.pointerId),K.current=!1;const{x:Ne,y:Me}=gn(Z.nativeEvent,q.current),Te=gs({x:Ne,y:Me},me);E.setState({userSelectionRect:{width:0,height:0,startX:Te.x,startY:Te.y,x:Ne,y:Me}}),ke||(Z.stopPropagation(),Z.preventDefault())};function I(Z,se){const{userSelectionRect:me}=E.getState();if(!me)return;const{transform:ke,nodeLookup:ve,edgeLookup:re,connectionLookup:Ne,triggerNodeChanges:Me,triggerEdgeChanges:Te,defaultEdgeOptions:$e}=E.getState(),st={x:me.startX,y:me.startY},{x:lt,y:at}=eo(st,ke),Ge={startX:st.x,startY:st.y,x:Zmt.id)),ee.current=new Set;const gt=($e==null?void 0:$e.selectable)??!0;for(const mt of te.current){const Pt=Ne.get(mt);if(Pt)for(const{edgeId:ut}of Pt.values()){const Je=re.get(ut);Je&&(Je.selectable??gt)&&ee.current.add(ut)}}if(!jh(wt,te.current)){const mt=Gi(ve,te.current,!0);Me(mt)}if(!jh(qt,ee.current)){const mt=Gi(re,ee.current);Te(mt)}E.setState({userSelectionRect:Ge,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!a||!q.current)return;const[Z,se]=kc(C.current,q.current,$);A({x:Z,y:se}).then(me=>{if(!K.current||!me){b.current=requestAnimationFrame(z);return}const{x:ke,y:ve}=C.current;I(ke,ve),b.current=requestAnimationFrame(z)})}const ie=()=>{cancelAnimationFrame(b.current),b.current=0,V.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=Z=>{const{userSelectionRect:se,transform:me,resetSelectedElements:ke}=E.getState();if(!q.current||!se)return;const{x:ve,y:re}=gn(Z.nativeEvent,q.current);C.current={x:ve,y:re};const Ne=eo({x:se.startX,y:se.startY},me);if(!K.current){const Me=r?0:u;if(Math.hypot(ve-Ne.x,re-Ne.y)<=Me)return;ke(),h==null||h(Z)}K.current=!0,V.current||(z(),V.current=!0),I(ve,re)},fe=Z=>{var se,me;if(!F){Z.target===G.current&&E.getState().connection.inProgress&&(ne.current=!0);return}Z.button===0&&((me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),!R&&Z.target===G.current&&E.getState().userSelectionRect&&(W==null||W(Z)),E.setState({userSelectionActive:!1,userSelectionRect:null}),K.current&&(p==null||p(Z),E.setState({nodesSelectionActive:te.current.size>0})),ie())},he=Z=>{var se,me;(me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),ie()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:nt(["react-flow__pane",{draggable:pe,dragging:N,selection:t}]),onClick:F?void 0:qu(W,G),onContextMenu:qu(U,G),onWheel:qu(M,G),onPointerEnter:F?void 0:m,onPointerMove:F?oe:_,onPointerUp:fe,onPointerCancel:F?he:void 0,onPointerDownCapture:F?H:void 0,onClickCapture:F?D:void 0,onPointerLeave:k,ref:G,style:ra,children:[j,d.jsx(G_,{})]})}function hc({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),v=h.get(t);if(!v){p==null||p("012",mn.error012(t));return}r.setState({nodesSelectionActive:!1}),v.selected?(o||v.selected&&c)&&(u({nodes:[v],edges:[]}),requestAnimationFrame(()=>{var x;return(x=s==null?void 0:s.current)==null?void 0:x.blur()})):a([t])}function Bg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ye(),[p,v]=L.useState(!1),x=L.useRef();return L.useEffect(()=>{if(!r)return x.current=L1({getStoreItems:()=>h.getState(),onNodeMouseDown:y=>{hc({id:y,store:h,nodeRef:t})},onDragStart:()=>{v(!0)},onDragStop:()=>{v(!1)}}),()=>{var y;(y=x.current)==null||y.destroy(),x.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!x.current||x.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const K_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Vg(){const t=Ye();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:v,nodeOrigin:x}=t.getState(),y=new Map,m=K_(c),_=a?u[0]:5,k=a?u[1]:5,j=o.direction.x*_*o.factor,b=o.direction.y*k*o.factor;for(const[,E]of v){if(!m(E))continue;let R={x:E.internals.positionAbsolute.x+j,y:E.internals.positionAbsolute.y+b};a&&(R=ps(R,u));const{position:w,positionAbsolute:N}=ag({nodeId:E.id,nextPosition:R,nodeLookup:v,nodeExtent:s,nodeOrigin:x,onError:h});E.position=w,E.internals.positionAbsolute=N,y.set(E.id,E)}p(y)},[])}const Ic=L.createContext(null),Q_=Ic.Provider;Ic.Consumer;const Wg=()=>L.useContext(Ic),Z_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Ug=L.createContext(null);function J_({children:t}){const r=De(Z_,Qe);return d.jsx(Ug.Provider,{value:r,children:t})}function eS(){const t=L.useContext(Ug);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const tS={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},nS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:v}=c;if(!h&&!a)return tS;const x=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:x,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Zi.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:x&&v}};function rS({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:v,onMouseDown:x,onTouchStart:y,...m},_){var V,W;const k=c||null,j=t==="target",b=Ye(),E=Wg(),{connectOnClick:R,noPanClassName:w,rfId:N}=eS(),{connectingFrom:A,connectingTo:$,clickConnecting:F,isPossibleEndHandle:G,connectionInProcess:q,clickConnectionInProcess:te,valid:ee}=De(nS(E,k,t),Qe);E||(W=(V=b.getState()).onError)==null||W.call(V,"010",mn.error010());const ne=U=>{const{defaultEdgeOptions:M,onConnect:D,hasDefaultEdges:H}=b.getState(),I={...M,...U};if(H){const{edges:z,setEdges:ie,onError:oe}=b.getState();ie(A_(I,z,{onError:oe}))}D==null||D(I),h==null||h(I)},K=U=>{if(!E)return;const M=yg(U.nativeEvent);if(a&&(M&&U.button===0||!M)){const D=b.getState();fc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:j,handleId:k,nodeId:E,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...H)=>{var I,z;return(z=(I=b.getState()).onConnectEnd)==null?void 0:z.call(I,...H)},updateConnection:D.updateConnection,onConnect:ne,isValidConnection:o||((...H)=>{var I,z;return((z=(I=b.getState()).isValidConnection)==null?void 0:z.call(I,...H))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}M?x==null||x(U):y==null||y(U)},C=U=>{const{onClickConnectStart:M,onClickConnectEnd:D,connectionClickStartHandle:H,connectionMode:I,isValidConnection:z,lib:ie,rfId:oe,nodeLookup:fe,connection:he}=b.getState();if(!E||!H&&!a)return;if(!H){M==null||M(U.nativeEvent,{nodeId:E,handleId:k,handleType:t}),b.setState({connectionClickStartHandle:{nodeId:E,type:t,id:k}});return}const pe=gg(U.target),Z=o||z,{connection:se,isValid:me}=fc.isValid(U.nativeEvent,{handle:{nodeId:E,id:k,type:t},connectionMode:I,fromNodeId:H.nodeId,fromHandleId:H.id||null,fromType:H.type,isValidConnection:Z,flowId:oe,doc:pe,lib:ie,nodeLookup:fe});me&&se&&ne(se);const ke=structuredClone(he);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,D==null||D(U,ke),b.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":k,"data-nodeid":E,"data-handlepos":r,"data-id":`${N}-${E}-${k}-${t}`,className:nt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",w,v,{source:!j,target:j,connectable:s,connectablestart:a,connectableend:u,clickconnecting:F,connectingfrom:A,connectingto:$,valid:ee,connectionindicator:s&&(!q||G)&&(q||te?u:a)}]),onMouseDown:K,onTouchStart:K,onClick:R?C:void 0,ref:_,...m,children:p})}const no=L.memo(Og(rS));function iS({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(no,{type:"source",position:o,isConnectable:r})]})}function oS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:s=Se.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(no,{type:"source",position:s,isConnectable:r})]})}function sS(){return null}function lS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const Vl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},np={input:iS,default:oS,output:lS,group:sS};function aS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const uS=t=>{const{width:r,height:o,x:s,y:a}=hs(t.nodeLookup,{filter:u=>!!u.selected});return{width:pn(r)?r:null,height:pn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function cS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ye(),{width:a,height:u,transformString:c,userSelectionActive:h}=De(uS,Qe),p=Vg(),v=L.useRef(null);L.useEffect(()=>{var _;o||(_=v.current)==null||_.focus({preventScroll:!0})},[o]);const x=!h&&a!==null&&u!==null;if(Bg({nodeRef:v,disabled:!x}),!x)return null;const y=t?_=>{const k=s.getState().nodes.filter(j=>j.selected);t(_,k)}:void 0,m=_=>{Object.prototype.hasOwnProperty.call(Vl,_.key)&&(_.preventDefault(),p({direction:Vl[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:nt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:v,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:o?void 0:-1,onKeyDown:o?void 0:m,style:{width:a,height:u}})})}const rp=typeof window<"u"?window:void 0,dS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Yg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:v,selectionOnDrag:x,selectionMode:y,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:j,zoomActivationKeyCode:b,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:N,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:G,autoPanOnSelection:q,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,preventScrolling:C,onSelectionContextMenu:V,noWheelClassName:W,noPanClassName:U,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:H}){const{nodesSelectionActive:I,userSelectionActive:z}=De(dS,Qe),ie=ls(v,{target:rp}),oe=ls(j,{target:rp}),fe=oe||G,he=oe||N,pe=x&&fe!==!0,Z=ie||z||pe;return B_({deleteKeyCode:p,multiSelectionKeyCode:k}),d.jsx(U_,{onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:!ie&&fe,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,zoomActivationKeyCode:b,preventScrolling:C,noWheelClassName:W,noPanClassName:U,onViewportChange:D,isControlledViewport:H,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(q_,{onSelectionStart:m,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:q,isSelecting:!!Z,selectionMode:y,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:pe,children:[t,I&&d.jsx(cS,{onSelectionContextMenu:V,noPanClassName:U,disableKeyboardA11y:M})]})})}Yg.displayName="FlowRenderer";const fS=L.memo(Yg),hS=t=>r=>t?Sc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function pS(t){return De(L.useCallback(hS(t),[t]),Qe)}const gS=t=>t.updateNodeInternals;function mS(){const t=De(gS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function yS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ye(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),v=L.useRef(r),x=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!x||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[x,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const y=v.current!==r,m=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(y||m||_)&&(v.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function vS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:v,nodesFocusable:x,resizeObserver:y,noDragClassName:m,noPanClassName:_,disableKeyboardA11y:k,rfId:j,nodeTypes:b,nodeClickDistance:E,onError:R}){const{node:w,internals:N,isParent:A}=De(Z=>{const se=Z.nodeLookup.get(t),me=Z.parentLookup.has(t);return{node:se,internals:se.internals,isParent:me}},Qe);let $=w.type||"default",F=(b==null?void 0:b[$])||np[$];F===void 0&&(R==null||R("003",mn.error003($)),$="default",F=(b==null?void 0:b.default)||np.default);const G=!!(w.draggable||h&&typeof w.draggable>"u"),q=!!(w.selectable||p&&typeof w.selectable>"u"),te=!!(w.connectable||v&&typeof w.connectable>"u"),ee=!!(w.focusable||x&&typeof w.focusable>"u"),ne=Ye(),K=hg(w),C=yS({node:w,nodeType:$,hasDimensions:K,resizeObserver:y}),V=Bg({nodeRef:C,disabled:w.hidden||!G,noDragClassName:m,handleSelector:w.dragHandle,nodeId:t,isSelectable:q,nodeClickDistance:E}),W=Vg();if(w.hidden)return null;const U=vn(w),M=aS(w),D=q||G||r||o||s||a,H=o?Z=>o(Z,{...N.userNode}):void 0,I=s?Z=>s(Z,{...N.userNode}):void 0,z=a?Z=>a(Z,{...N.userNode}):void 0,ie=u?Z=>u(Z,{...N.userNode}):void 0,oe=c?Z=>c(Z,{...N.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:se,nodeDragThreshold:me}=ne.getState();q&&(!se||!G||me>0)&&hc({id:t,store:ne,nodeRef:C}),r&&r(Z,{...N.userNode})},he=Z=>{if(!(mg(Z.nativeEvent)||k)){if(rg.includes(Z.key)&&q){const se=Z.key==="Escape";hc({id:t,store:ne,unselect:se,nodeRef:C})}else if(G&&w.selected&&Object.prototype.hasOwnProperty.call(Vl,Z.key)){Z.preventDefault();const{ariaLabelConfig:se}=ne.getState();ne.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),W({direction:Vl[Z.key],factor:Z.shiftKey?4:1})}}},pe=()=>{var Ne;if(k||!((Ne=C.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:Z,width:se,height:me,autoPanOnNodeFocus:ke,setCenter:ve}=ne.getState();if(!ke)return;Sc(new Map([[t,w]]),{x:0,y:0,width:se,height:me},Z,!0).length>0||ve(w.position.x+U.width/2,w.position.y+U.height/2,{zoom:Z[2]})};return d.jsx("div",{className:nt(["react-flow__node",`react-flow__node-${$}`,{[_]:G},w.className,{selected:w.selected,selectable:q,parent:A,draggable:G,dragging:V}]),ref:C,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:K?"visible":"hidden",...w.style,...M},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:H,onMouseMove:I,onMouseLeave:z,onContextMenu:ie,onClick:fe,onDoubleClick:oe,onKeyDown:ee?he:void 0,tabIndex:ee?0:void 0,onFocus:ee?pe:void 0,role:w.ariaRole??(ee?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${Ag}-${j}`,"aria-label":w.ariaLabel,...w.domAttributes,children:d.jsx(Q_,{value:t,children:d.jsx(F,{id:t,data:w.data,type:$,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:w.selected??!1,selectable:q,draggable:G,deletable:w.deletable??!0,isConnectable:te,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:V,dragHandle:w.dragHandle,zIndex:N.z,parentId:w.parentId,...U})})})}var xS=L.memo(vS);const wS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Gg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=De(wS,Qe),u=pS(t.onlyRenderVisibleElements),c=mS();return d.jsx("div",{className:"react-flow__nodes",style:ra,children:u.map(h=>d.jsx(xS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Gg.displayName="NodeRenderer";const _S=L.memo(Gg);function SS(t){return De(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&g1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const kS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},NS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ip={[is.Arrow]:kS,[is.ArrowClosed]:NS};function jS(t){const r=Ye();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(ip,t)?ip[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",mn.error009(t)),null)},[t])}const bS=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=jS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},Xg=({defaultColor:t,rfId:r})=>{const o=De(u=>u.edges),s=De(u=>u.defaultEdgeOptions),a=L.useMemo(()=>k1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(bS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Xg.displayName="MarkerDefinitions";var ES=L.memo(Xg);function qg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:v,...x}){const[y,m]=L.useState({x:1,y:0,width:0,height:0}),_=nt(["react-flow__edge-textwrapper",v]),k=L.useRef(null);return L.useEffect(()=>{if(k.current){const j=k.current.getBBox();m({x:j.x,y:j.y,width:j.width,height:j.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-y.width/2} ${r-y.height/2})`,className:_,visibility:y.width?"visible":"hidden",...x,children:[a&&d.jsx("rect",{width:y.width+2*c[0],x:-c[0],y:-c[1],height:y.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:k,style:s,children:o}),p]}):null}qg.displayName="EdgeText";const CS=L.memo(qg);function ms({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:v=20,...x}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...x,d:t,fill:"none",className:nt(["react-flow__edge-path",x.className])}),v?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:v,className:"react-flow__edge-interaction"}):null,s&&pn(r)&&pn(o)?d.jsx(CS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function op({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function Kg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top}){const[c,h]=op({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,v]=op({pos:u,x1:s,y1:a,x2:t,y2:r}),[x,y,m,_]=vg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:v});return[`M${t},${r} C${c},${h} ${p},${v} ${s},${a}`,x,y,m,_]}function Qg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})=>{const[R,w,N]=Kg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),A=t.isInternal?void 0:r;return d.jsx(ms,{id:A,path:R,labelX:w,labelY:N,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})})}const MS=Qg({isInternal:!1}),Zg=Qg({isInternal:!0});MS.displayName="SimpleBezierEdge";Zg.displayName="SimpleBezierEdgeInternal";function Jg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,sourcePosition:_=Se.Bottom,targetPosition:k=Se.Top,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=Bl({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),$=t.isInternal?void 0:r;return d.jsx(ms,{id:$,path:w,labelX:N,labelY:A,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:j,markerStart:b,interactionWidth:R})})}const em=Jg({isInternal:!1}),tm=Jg({isInternal:!0});em.displayName="SmoothStepEdge";tm.displayName="SmoothStepEdgeInternal";function nm(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(em,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const PS=nm({isInternal:!1}),rm=nm({isInternal:!0});PS.displayName="StepEdge";rm.displayName="StepEdgeInternal";function im(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:j})=>{const[b,E,R]=_g({sourceX:o,sourceY:s,targetX:a,targetY:u}),w=t.isInternal?void 0:r;return d.jsx(ms,{id:w,path:b,labelX:E,labelY:R,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:j})})}const IS=im({isInternal:!1}),om=im({isInternal:!0});IS.displayName="StraightEdge";om.displayName="StraightEdgeInternal";function sm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=xg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:E==null?void 0:E.curvature}),$=t.isInternal?void 0:r;return d.jsx(ms,{id:$,path:w,labelX:N,labelY:A,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:R})})}const RS=sm({isInternal:!1}),lm=sm({isInternal:!0});RS.displayName="BezierEdge";lm.displayName="BezierEdgeInternal";const sp={default:lm,straight:om,step:rm,smoothstep:tm,simplebezier:Zg},lp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},TS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,LS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,ap="react-flow__edgeupdater";function up({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:nt([ap,`${ap}-${h}`]),cx:TS(r,s,t),cy:LS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function AS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:v,onReconnectStart:x,onReconnectEnd:y,setReconnecting:m,setUpdateHover:_}){const k=Ye(),j=(N,A)=>{if(N.button!==0)return;const{autoPanOnConnect:$,domNode:F,connectionMode:G,connectionRadius:q,lib:te,onConnectStart:ee,cancelConnection:ne,nodeLookup:K,rfId:C,panBy:V,updateConnection:W}=k.getState(),U=A.type==="target",M=(I,z)=>{m(!1),y==null||y(I,o,A.type,z)},D=I=>v==null?void 0:v(o,I),H=(I,z)=>{m(!0),x==null||x(N,o,A.type),ee==null||ee(I,z)};fc.onPointerDown(N.nativeEvent,{autoPanOnConnect:$,connectionMode:G,connectionRadius:q,domNode:F,handleId:A.id,nodeId:A.nodeId,nodeLookup:K,isTarget:U,edgeUpdaterType:A.type,lib:te,flowId:C,cancelConnection:ne,panBy:V,isValidConnection:(...I)=>{var z,ie;return((ie=(z=k.getState()).isValidConnection)==null?void 0:ie.call(z,...I))??!0},onConnect:D,onConnectStart:H,onConnectEnd:(...I)=>{var z,ie;return(ie=(z=k.getState()).onConnectEnd)==null?void 0:ie.call(z,...I)},onReconnectEnd:M,updateConnection:W,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:N.currentTarget})},b=N=>j(N,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),E=N=>j(N,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),R=()=>_(!0),w=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(up,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:b,onMouseEnter:R,onMouseOut:w,type:"source"}),(t===!0||t==="target")&&d.jsx(up,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:E,onMouseEnter:R,onMouseOut:w,type:"target"})]})}function $S({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,rfId:k,edgeTypes:j,noPanClassName:b,onError:E,disableKeyboardA11y:R}){let w=De(ve=>ve.edgeLookup.get(t));const N=De(ve=>ve.defaultEdgeOptions);w=N?{...N,...w}:w;let A=w.type||"default",$=(j==null?void 0:j[A])||sp[A];$===void 0&&(E==null||E("011",mn.error011(A)),A="default",$=(j==null?void 0:j.default)||sp.default);const F=!!(w.focusable||r&&typeof w.focusable>"u"),G=typeof y<"u"&&(w.reconnectable||o&&typeof w.reconnectable>"u"),q=!!(w.selectable||s&&typeof w.selectable>"u"),te=L.useRef(null),[ee,ne]=L.useState(!1),[K,C]=L.useState(!1),V=Ye(),{zIndex:W=w.zIndex,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z}=De(L.useCallback(ve=>{const re=ve.nodeLookup.get(w.source),Ne=ve.nodeLookup.get(w.target);if(!re||!Ne)return lp;const Me=S1({id:t,sourceNode:re,targetNode:Ne,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:ve.connectionMode,onError:E}),Te=p1({selected:w.selected,zIndex:w.zIndex,sourceNode:re,targetNode:Ne,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||lp,zIndex:Te}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex,E]),Qe),ie=L.useMemo(()=>w.markerStart?`url('#${cc(w.markerStart,k)}')`:void 0,[w.markerStart,k]),oe=L.useMemo(()=>w.markerEnd?`url('#${cc(w.markerEnd,k)}')`:void 0,[w.markerEnd,k]);if(w.hidden||U===null||M===null||D===null||H===null)return null;const fe=ve=>{var Te;const{addSelectedEdges:re,unselectNodesAndEdges:Ne,multiSelectionActive:Me}=V.getState();q&&(V.setState({nodesSelectionActive:!1}),w.selected&&Me?(Ne({nodes:[],edges:[w]}),(Te=te.current)==null||Te.blur()):re([t])),a&&a(ve,w)},he=u?ve=>{u(ve,{...w})}:void 0,pe=c?ve=>{c(ve,{...w})}:void 0,Z=h?ve=>{h(ve,{...w})}:void 0,se=p?ve=>{p(ve,{...w})}:void 0,me=v?ve=>{v(ve,{...w})}:void 0,ke=ve=>{var re;if(!R&&rg.includes(ve.key)&&q){const{unselectNodesAndEdges:Ne,addSelectedEdges:Me}=V.getState();ve.key==="Escape"?((re=te.current)==null||re.blur(),Ne({edges:[w]})):Me([t])}};return d.jsx("svg",{style:{zIndex:W},children:d.jsxs("g",{className:nt(["react-flow__edge",`react-flow__edge-${A}`,w.className,b,{selected:w.selected,animated:w.animated,inactive:!q&&!a,updating:ee,selectable:q}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:Z,onMouseMove:se,onMouseLeave:me,onKeyDown:F?ke:void 0,tabIndex:F?0:void 0,role:w.ariaRole??(F?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":F?`${$g}-${k}`:void 0,ref:te,...w.domAttributes,children:[!K&&d.jsx($,{id:t,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:q,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),G&&d.jsx(AS,{edge:w,isReconnectable:G,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,setUpdateHover:ne,setReconnecting:C})]})})}var zS=L.memo($S);const DS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function am({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:v,onEdgeClick:x,reconnectRadius:y,onEdgeDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:j}){const{edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,onError:w}=De(DS,Qe),N=SS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(ES,{defaultColor:t,rfId:o}),N.map(A=>d.jsx(zS,{id:A,edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,onClick:x,reconnectRadius:y,onDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:w,edgeTypes:s,disableKeyboardA11y:j},A))]})}am.displayName="EdgeRenderer";const OS=L.memo(am),cp=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function FS({children:t}){const r=Ye(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return Fg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=cp(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:cp(s)},children:t})}function HS(t){const r=na(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const BS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function VS(t){const r=De(BS),o=Ye();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function WS(t){return t.connection.inProgress?{...t.connection,to:gs(t.connection.to,t.transform)}:{...t.connection}}function US(t){return WS}function YS(t){const r=US();return De(r,Qe)}const GS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function XS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=De(GS,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:nt(["react-flow__connection",sg(h)]),children:d.jsx(um,{style:r,type:o,CustomComponent:s,isValid:h})})})}const um=({style:t,type:r=Lr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:v,toNode:x,toHandle:y,toPosition:m,pointer:_}=YS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:v.x,toY:v.y,fromPosition:p,toPosition:m,connectionStatus:sg(s),toNode:x,toHandle:y,pointer:_});let k="";const j={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:v.x,targetY:v.y,targetPosition:m};switch(r){case Lr.Bezier:[k]=xg(j);break;case Lr.SimpleBezier:[k]=Kg(j);break;case Lr.Step:[k]=Bl({...j,borderRadius:0});break;case Lr.SmoothStep:[k]=Bl(j);break;default:[k]=_g(j)}return d.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};um.displayName="ConnectionLine";const qS={};function dp(t=qS){L.useRef(t),Ye(),L.useEffect(()=>{},[t])}function KS(){Ye(),L.useRef(!1),L.useEffect(()=>{},[])}function cm({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,onSelectionContextMenu:y,onSelectionStart:m,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:j,connectionLineComponent:b,connectionLineContainerStyle:E,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,deleteKeyCode:G,onlyRenderVisibleElements:q,elementsSelectable:te,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,preventScrolling:V,defaultMarkerColor:W,zoomOnScroll:U,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,zoomOnDoubleClick:z,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneScroll:se,onPaneContextMenu:me,paneClickDistance:ke,nodeClickDistance:ve,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,viewport:ut,onViewportChange:Je,nodesDraggable:An}){return dp(t),dp(r),KS(),HS(o),VS(ut),d.jsx(fS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneContextMenu:me,onPaneScroll:se,paneClickDistance:ke,deleteKeyCode:G,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,elementsSelectable:te,zoomOnScroll:U,zoomOnPinch:M,zoomOnDoubleClick:z,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,onSelectionContextMenu:y,preventScrolling:V,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,onViewportChange:Je,isControlledViewport:!!ut,children:d.jsxs(FS,{children:[d.jsx(OS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,onlyRenderVisibleElements:q,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,defaultMarkerColor:W,noPanClassName:qt,disableKeyboardA11y:gt,rfId:Pt}),d.jsx(XS,{style:j,type:k,component:b,containerStyle:E}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(_S,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,nodeClickDistance:ve,onlyRenderVisibleElements:q,noPanClassName:qt,noDragClassName:Ge,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,nodesDraggable:An}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}cm.displayName="GraphView";const QS=L.memo(cm),ZS=fg(),fp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:v=2,nodeOrigin:x,nodeExtent:y,zIndexMode:m="basic"}={})=>{const _=new Map,k=new Map,j=new Map,b=new Map,E=s??r??[],R=o??t??[],w=x??[0,0],N=y??ns;Ng(j,b,E);const{nodesInitialized:A}=dc(R,_,k,{nodeOrigin:w,nodeExtent:N,zIndexMode:m});let $=[0,0,1];if(c&&a&&u){const F=hs(_,{filter:ee=>!!((ee.width||ee.initialWidth)&&(ee.height||ee.initialHeight))}),{x:G,y:q,zoom:te}=Nc(F,a,u,p,v,(h==null?void 0:h.padding)??.1);$=[G,q,te]}return{rfId:"1",width:a??0,height:u??0,transform:$,nodes:R,nodesInitialized:A,nodeLookup:_,parentLookup:k,edges:E,edgeLookup:b,connectionLookup:j,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:v,translateExtent:ns,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Zi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...og},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:ZS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:ig,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},JS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m})=>d_((_,k)=>{async function j(){const{nodeLookup:b,panZoom:E,fitViewOptions:R,fitViewResolver:w,width:N,height:A,minZoom:$,maxZoom:F}=k();E&&(await l1({nodes:b,width:N,height:A,panZoom:E,minZoom:$,maxZoom:F},R),w==null||w.resolve(!0),_({fitViewResolver:null}))}return{...fp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,defaultNodes:o,defaultEdges:s,zIndexMode:m}),setNodes:b=>{const{nodeLookup:E,parentLookup:R,nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,fitViewQueued:$,zIndexMode:F,nodesSelectionActive:G}=k(),{nodesInitialized:q,hasSelectedNodes:te}=dc(b,E,R,{nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:F}),ee=G&&te;$&&q?(j(),_({nodes:b,nodesInitialized:q,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:ee})):_({nodes:b,nodesInitialized:q,nodesSelectionActive:ee})},setEdges:b=>{const{connectionLookup:E,edgeLookup:R}=k();Ng(E,R,b),_({edges:b})},setDefaultNodesAndEdges:(b,E)=>{if(b){const{setNodes:R}=k();R(b),_({hasDefaultNodes:!0})}if(E){const{setEdges:R}=k();R(E),_({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:E,nodeLookup:R,parentLookup:w,domNode:N,nodeOrigin:A,nodeExtent:$,debug:F,fitViewQueued:G,zIndexMode:q}=k(),{changes:te,updatedInternals:ee}=P1(b,R,w,N,A,$,q);ee&&(b1(R,w,{nodeOrigin:A,nodeExtent:$,zIndexMode:q}),G?(j(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(te==null?void 0:te.length)>0&&(F&&console.log("React Flow: trigger node changes",te),E==null||E(te)))},updateNodePositions:(b,E=!1)=>{const R=[];let w=[];const{nodeLookup:N,triggerNodeChanges:A,connection:$,updateConnection:F,onNodesChangeMiddlewareMap:G}=k();for(const[q,te]of b){const ee=N.get(q),ne=!!(ee!=null&&ee.expandParent&&(ee!=null&&ee.parentId)&&(te!=null&&te.position)),K={id:q,type:"position",position:ne?{x:Math.max(0,te.position.x),y:Math.max(0,te.position.y)}:te.position,dragging:E};if(ee&&$.inProgress&&$.fromNode.id===ee.id){const C=mi(ee,$.fromHandle,Se.Left,!0);F({...$,from:C})}ne&&ee.parentId&&R.push({id:q,parentId:ee.parentId,rect:{...te.internals.positionAbsolute,width:te.measured.width??0,height:te.measured.height??0}}),w.push(K)}if(R.length>0){const{parentLookup:q,nodeOrigin:te}=k(),ee=Pc(R,N,q,te);w.push(...ee)}for(const q of G.values())w=q(w);A(w)},triggerNodeChanges:b=>{const{onNodesChange:E,setNodes:R,nodes:w,hasDefaultNodes:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=R_(b,w);R($)}A&&console.log("React Flow: trigger node changes",b),E==null||E(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:E,setEdges:R,edges:w,hasDefaultEdges:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=T_(b,w);R($)}A&&console.log("React Flow: trigger edge changes",b),E==null||E(b)}},addSelectedNodes:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));N($);return}N(Gi(w,new Set([...b]),!0)),A(Gi(R))},addSelectedEdges:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));A($);return}A(Gi(R,new Set([...b]))),N(Gi(w,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:E}={})=>{const{edges:R,nodes:w,nodeLookup:N,triggerNodeChanges:A,triggerEdgeChanges:$}=k(),F=b||w,G=E||R,q=[];for(const ee of F){if(!ee.selected)continue;const ne=N.get(ee.id);ne&&(ne.selected=!1),q.push(ai(ee.id,!1))}const te=[];for(const ee of G)ee.selected&&te.push(ai(ee.id,!1));A(q),$(te)},setMinZoom:b=>{const{panZoom:E,maxZoom:R}=k();E==null||E.setScaleExtent([b,R]),_({minZoom:b})},setMaxZoom:b=>{const{panZoom:E,minZoom:R}=k();E==null||E.setScaleExtent([R,b]),_({maxZoom:b})},setTranslateExtent:b=>{var E;(E=k().panZoom)==null||E.setTranslateExtent(b),_({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:E,triggerNodeChanges:R,triggerEdgeChanges:w,elementsSelectable:N}=k();if(!N)return;const A=E.reduce((F,G)=>G.selected?[...F,ai(G.id,!1)]:F,[]),$=b.reduce((F,G)=>G.selected?[...F,ai(G.id,!1)]:F,[]);R(A),w($)},setNodeExtent:b=>{const{nodes:E,nodeLookup:R,parentLookup:w,nodeOrigin:N,elevateNodesOnSelect:A,nodeExtent:$,zIndexMode:F}=k();b[0][0]===$[0][0]&&b[0][1]===$[0][1]&&b[1][0]===$[1][0]&&b[1][1]===$[1][1]||(dc(E,R,w,{nodeOrigin:N,nodeExtent:b,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:F}),_({nodeExtent:b}))},panBy:b=>{const{transform:E,width:R,height:w,panZoom:N,translateExtent:A}=k();return I1({delta:b,panZoom:N,transform:E,translateExtent:A,width:R,height:w})},setCenter:async(b,E,R)=>{const{width:w,height:N,maxZoom:A,panZoom:$}=k();if(!$)return!1;const F=typeof(R==null?void 0:R.zoom)<"u"?R.zoom:A;return await $.setViewport({x:w/2-b*F,y:N/2-E*F,zoom:F},{duration:R==null?void 0:R.duration,ease:R==null?void 0:R.ease,interpolate:R==null?void 0:R.interpolate}),!0},cancelConnection:()=>{_({connection:{...og}})},updateConnection:b=>{_({connection:b})},reset:()=>_({...fp()})}},Object.is);function dm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m,children:_}){const[k]=L.useState(()=>JS({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:v,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:x,nodeExtent:y,zIndexMode:m}));return d.jsx(f_,{value:k,children:d.jsx(D_,{children:d.jsx(J_,{children:_})})})}function ek({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:v,maxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_}){return L.useContext(ea)?d.jsx(d.Fragment,{children:t}):d.jsx(dm,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:v,initialMaxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_,children:t})}const tk={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function nk({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:v,onMove:x,onMoveStart:y,onMoveEnd:m,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,onNodeDragStart:F,onNodeDrag:G,onNodeDragStop:q,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onSelectionChange:K,onSelectionDragStart:C,onSelectionDrag:V,onSelectionDragStop:W,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:H,connectionMode:I,connectionLineType:z=Lr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:Z=!1,selectionMode:se=rs.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:ke=ss()?"Meta":"Control",zoomActivationKeyCode:ve=ss()?"Meta":"Control",snapToGrid:re,snapGrid:Ne,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Te,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,nodeOrigin:Ge=zg,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt=!0,defaultViewport:mt=j_,minZoom:Pt=.5,maxZoom:ut=2,translateExtent:Je=ns,preventScrolling:An=!0,nodeExtent:Ot,defaultMarkerColor:xn="#b1b1b7",zoomOnScroll:io=!0,zoomOnPinch:$n=!0,panOnScroll:vi=!1,panOnScrollSpeed:or=.5,panOnScrollMode:$r=di.Free,zoomOnDoubleClick:zn=!0,panOnDrag:zr=!0,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn=1,nodeClickDistance:Fn=0,children:_n,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn=10,onNodesChange:Ht,onEdgesChange:Or,noDragClassName:nn="nodrag",noWheelClassName:Fr="nowheel",noPanClassName:yt="nopan",fitView:Hn,fitViewOptions:ur,connectOnClick:oo,attributionPosition:It,proOptions:Bn,defaultEdgeOptions:Hr,elevateNodesOnSelect:jn=!0,elevateEdgesOnSelect:Br=!1,disableKeyboardA11y:xi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:so,autoPanOnSelection:Vr=!0,autoPanSpeed:wi,connectionRadius:cr,isValidConnection:lo,onError:dr,style:Vn,id:bt,nodeDragThreshold:Wr,connectionDragThreshold:Et,viewport:ao,onViewportChange:Ur,width:Yr,height:Wn,colorMode:Un="light",debug:bn,onScroll:Bt,ariaLabelConfig:_i,zIndexMode:Gr="basic",...fr},hr){const Yn=bt||"1",En=M_(Un),uo=L.useCallback(pr=>{pr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Bt==null||Bt(pr)},[Bt]);return d.jsx("div",{"data-testid":"rf__wrapper",...fr,onScroll:uo,style:{...Vn,...tk},ref:hr,className:nt(["react-flow",a,En]),id:bt,role:"application",children:d.jsxs(ek,{nodes:t,edges:r,width:Yr,height:Wn,fitView:Hn,fitViewOptions:ur,minZoom:Pt,maxZoom:ut,nodeOrigin:Ge,nodeExtent:Ot,zIndexMode:Gr,children:[d.jsx(C_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt,elevateNodesOnSelect:jn,elevateEdgesOnSelect:Br,minZoom:Pt,maxZoom:ut,nodeExtent:Ot,onNodesChange:Ht,onEdgesChange:Or,snapToGrid:re,snapGrid:Ne,connectionMode:I,translateExtent:Je,connectOnClick:oo,defaultEdgeOptions:Hr,fitView:Hn,fitViewOptions:ur,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onNodeDragStart:F,onNodeDrag:G,onNodeDragStop:q,onSelectionDrag:V,onSelectionDragStart:C,onSelectionDragStop:W,onMove:x,onMoveStart:y,onMoveEnd:m,noPanClassName:yt,nodeOrigin:Ge,rfId:Yn,autoPanOnConnect:Ve,autoPanOnNodeDrag:so,autoPanSpeed:wi,onError:dr,connectionRadius:cr,isValidConnection:lo,selectNodesOnDrag:Te,nodeDragThreshold:Wr,connectionDragThreshold:Et,onBeforeDelete:H,debug:bn,ariaLabelConfig:_i,zIndexMode:Gr}),d.jsx(QS,{onInit:v,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,nodeTypes:u,edgeTypes:c,connectionLineType:z,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:Z,selectionMode:se,deleteKeyCode:he,multiSelectionKeyCode:ke,panActivationKeyCode:me,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:mt,translateExtent:Je,minZoom:Pt,maxZoom:ut,preventScrolling:An,zoomOnScroll:io,zoomOnPinch:$n,zoomOnDoubleClick:zn,panOnScroll:vi,panOnScrollSpeed:or,panOnScrollMode:$r,panOnDrag:zr,autoPanOnSelection:Vr,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn,nodeClickDistance:Fn,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn,defaultMarkerColor:xn,noDragClassName:nn,noWheelClassName:Fr,noPanClassName:yt,rfId:Yn,disableKeyboardA11y:xi,nodeExtent:Ot,viewport:ao,onViewportChange:Ur,nodesDraggable:$e}),d.jsx(N_,{onSelectionChange:K}),_n,d.jsx(x_,{proOptions:Bn,position:It}),d.jsx(v_,{rfId:Yn,disableKeyboardA11y:xi})]})})}var rk=Og(nk);function ik({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:nt(["react-flow__background-pattern",o,s])})}function ok({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:nt(["react-flow__background-pattern","dots",r])})}var Ar;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Ar||(Ar={}));const sk={[Ar.Dots]:1,[Ar.Lines]:1,[Ar.Cross]:6},lk=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function fm({id:t,variant:r=Ar.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:v,patternClassName:x}){const y=L.useRef(null),{transform:m,patternId:_}=De(lk,Qe),k=s||sk[r],j=r===Ar.Dots,b=r===Ar.Cross,E=Array.isArray(o)?o:[o,o],R=[E[0]*m[2]||1,E[1]*m[2]||1],w=k*m[2],N=Array.isArray(u)?u:[u,u],A=b?[w,w]:R,$=[N[0]*m[2]+A[0]/2,N[1]*m[2]+A[1]/2],F=`${_}${t||""}`;return d.jsxs("svg",{className:nt(["react-flow__background",v]),style:{...p,...ra,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:y,"data-testid":"rf__background",children:[d.jsx("pattern",{id:F,x:m[0]%R[0],y:m[1]%R[1],width:R[0],height:R[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:j?d.jsx(ok,{radius:w/2,className:x}):d.jsx(ik,{dimensions:A,lineWidth:a,variant:r,className:x})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${F})`})]})}fm.displayName="Background";const ak=L.memo(fm);function uk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ck(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 fk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 hk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 jl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:nt(["react-flow__controls-button",r]),...o,children:t})}const pk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function hm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:v,children:x,position:y="bottom-left",orientation:m="vertical","aria-label":_}){const k=Ye(),{isInteractive:j,minZoomReached:b,maxZoomReached:E,ariaLabelConfig:R}=De(pk,Qe),{zoomIn:w,zoomOut:N,fitView:A}=na(),$=()=>{w(),u==null||u()},F=()=>{N(),c==null||c()},G=()=>{A(a),h==null||h()},q=()=>{k.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),p==null||p(!j)},te=m==="horizontal"?"horizontal":"vertical";return d.jsxs(ta,{className:nt(["react-flow__controls",te,v]),position:y,style:t,"data-testid":"rf__controls","aria-label":_??R["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(jl,{onClick:$,className:"react-flow__controls-zoomin",title:R["controls.zoomIn.ariaLabel"],"aria-label":R["controls.zoomIn.ariaLabel"],disabled:E,children:d.jsx(uk,{})}),d.jsx(jl,{onClick:F,className:"react-flow__controls-zoomout",title:R["controls.zoomOut.ariaLabel"],"aria-label":R["controls.zoomOut.ariaLabel"],disabled:b,children:d.jsx(ck,{})})]}),o&&d.jsx(jl,{className:"react-flow__controls-fitview",onClick:G,title:R["controls.fitView.ariaLabel"],"aria-label":R["controls.fitView.ariaLabel"],children:d.jsx(dk,{})}),s&&d.jsx(jl,{className:"react-flow__controls-interactive",onClick:q,title:R["controls.interactive.ariaLabel"],"aria-label":R["controls.interactive.ariaLabel"],children:j?d.jsx(hk,{}):d.jsx(fk,{})}),x]})}hm.displayName="Controls";const gk=L.memo(hm);function mk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:v,borderRadius:x,shapeRendering:y,selected:m,onClick:_}){const{background:k,backgroundColor:j}=u||{},b=c||k||j;return d.jsx("rect",{className:nt(["react-flow__minimap-node",{selected:m},v]),x:r,y:o,rx:x,ry:x,width:s,height:a,style:{fill:b,stroke:h,strokeWidth:p},shapeRendering:y,onClick:_?E=>_(E,t):void 0})}const yk=L.memo(mk),vk=t=>t.nodes.map(r=>r.id),Ku=t=>t instanceof Function?t:()=>t;function xk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=yk,onClick:c}){const h=De(vk,Qe),p=Ku(r),v=Ku(t),x=Ku(o),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(m=>d.jsx(_k,{id:m,nodeColorFunc:p,nodeStrokeColorFunc:v,nodeClassNameFunc:x,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:y},m))})}function wk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:v,x,y,width:m,height:_}=De(k=>{const j=k.nodeLookup.get(t);if(!j)return{node:void 0,x:0,y:0,width:0,height:0};const b=j.internals.userNode,{x:E,y:R}=j.internals.positionAbsolute,{width:w,height:N}=vn(b);return{node:b,x:E,y:R,width:w,height:N}},Qe);return!v||v.hidden||!hg(v)?null:d.jsx(h,{x,y,width:m,height:_,style:v.style,selected:!!v.selected,className:s(v),color:r(v),borderRadius:a,strokeColor:o(v),strokeWidth:u,shapeRendering:c,onClick:p,id:v.id})}const _k=L.memo(wk);var Sk=L.memo(xk);const kk=200,Nk=150,jk=t=>!t.hidden,bk=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?cg(hs(t.nodeLookup,{filter:jk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},hp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,Ek=(t,r)=>hp(t.viewBB,r.viewBB)&&hp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,Ck="react-flow__minimap-desc";function pm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:v,maskStrokeColor:x,maskStrokeWidth:y,position:m="bottom-right",onClick:_,onNodeClick:k,pannable:j=!1,zoomable:b=!1,ariaLabel:E,inversePan:R,zoomStep:w=1,offsetScale:N=5}){const A=Ye(),$=L.useRef(null),{boundingRect:F,viewBB:G,rfId:q,panZoom:te,translateExtent:ee,flowWidth:ne,flowHeight:K,ariaLabelConfig:C}=De(bk,Ek),V=(t==null?void 0:t.width)??kk,W=(t==null?void 0:t.height)??Nk,U=F.width/V,M=F.height/W,D=Math.max(U,M),H=D*V,I=D*W,z=N*D,ie=F.x-(H-F.width)/2-z,oe=F.y-(I-F.height)/2-z,fe=H+z*2,he=I+z*2,pe=`${Ck}-${q}`,Z=L.useRef(0),se=L.useRef();Z.current=D,L.useEffect(()=>{if($.current&&te)return se.current=F1({domNode:$.current,panZoom:te,getTransform:()=>A.getState().transform,getViewScale:()=>Z.current}),()=>{var re;(re=se.current)==null||re.destroy()}},[te]),L.useEffect(()=>{var re;(re=se.current)==null||re.update({translateExtent:ee,width:ne,height:K,inversePan:R,pannable:j,zoomStep:w,zoomable:b})},[j,b,R,w,ee,ne,K]);const me=_?re=>{var Te;const[Ne,Me]=((Te=se.current)==null?void 0:Te.pointer(re))||[0,0];_(re,{x:Ne,y:Me})}:void 0,ke=k?L.useCallback((re,Ne)=>{const Me=A.getState().nodeLookup.get(Ne).internals.userNode;k(re,Me)},[]):void 0,ve=E??C["minimap.ariaLabel"];return d.jsx(ta,{position:m,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof v=="string"?v:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof y=="number"?y*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:nt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:V,height:W,viewBox:`${ie} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:$,onClick:me,children:[ve&&d.jsx("title",{id:pe,children:ve}),d.jsx(Sk,{onClick:ke,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-z},${oe-z}h${fe+z*2}v${he+z*2}h${-fe-z*2}z + M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}pm.displayName="MiniMap";const Mk=L.memo(pm),Pk=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Ik={[to.Line]:"right",[to.Handle]:"bottom-right"};function Rk({nodeId:t,position:r,variant:o=to.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:v=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:y=!1,resizeDirection:m,autoScale:_=!0,shouldResize:k,onResizeStart:j,onResize:b,onResizeEnd:E}){const R=Wg(),w=typeof t=="string"?t:R,N=Ye(),A=L.useRef(null),$=o===to.Handle,F=De(L.useCallback(Pk($&&_),[$,_]),Qe),G=L.useRef(null),q=r??Ik[o];L.useEffect(()=>{if(!(!A.current||!w))return G.current||(G.current=J1({domNode:A.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,domNode:W}=N.getState();return{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,paneDomNode:W}},onChange:(ee,ne)=>{const{triggerNodeChanges:K,nodeLookup:C,parentLookup:V,nodeOrigin:W}=N.getState(),U=[],M={x:ee.x,y:ee.y},D=C.get(w);if(D&&D.expandParent&&D.parentId){const H=D.origin??W,I=ee.width??D.measured.width??0,z=ee.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:I,height:z,...pg({x:ee.x??D.position.x,y:ee.y??D.position.y},{width:I,height:z},D.parentId,C,H)}},oe=Pc([ie],C,V,W);U.push(...oe),M.x=ee.x?Math.max(H[0]*I,ee.x):void 0,M.y=ee.y?Math.max(H[1]*z,ee.y):void 0}if(M.x!==void 0&&M.y!==void 0){const H={id:w,type:"position",position:{...M}};U.push(H)}if(ee.width!==void 0&&ee.height!==void 0){const I={id:w,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:ee.width,height:ee.height}};U.push(I)}for(const H of ne){const I={...H,type:"position"};U.push(I)}K(U)},onEnd:({width:ee,height:ne})=>{const K={id:w,type:"dimensions",resizing:!1,dimensions:{width:ee,height:ne}};N.getState().triggerNodeChanges([K])}})),G.current.update({controlPosition:q,boundaries:{minWidth:h,minHeight:p,maxWidth:v,maxHeight:x},keepAspectRatio:y,resizeDirection:m,onResizeStart:j,onResize:b,onResizeEnd:E,shouldResize:k}),()=>{var ee;(ee=G.current)==null||ee.destroy()}},[q,h,p,v,x,y,j,b,E,k]);const te=q.split("-");return d.jsx("div",{className:nt(["react-flow__resize-control","nodrag",...te,o,s]),ref:A,style:{...a,scale:F,...c&&{[$?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Rk);const Tk={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function ia(t){return Tk[t]??8}const Wl=208,as=64,Lk=88,Ak=28,$k=8;function zk(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function gm(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const w of t){const N=ia(w.type),A=s.get(N)??[];A.push(w),s.set(N,A)}const u=[...s.keys()].sort((w,N)=>w-N).map(w=>[...s.get(w)??[]].sort((N,A)=>N.name.localeCompare(A.name)||N.id.localeCompare(A.id))),c=new Set(t.map(w=>w.id)),h=new Map,p=new Map;for(const w of t)h.set(w.id,[]),p.set(w.id,[]);for(const w of r)!c.has(w.src)||!c.has(w.dst)||w.src===w.dst||(p.get(w.src).push(w.dst),h.get(w.dst).push(w.src));const v=new Map;u.forEach((w,N)=>{for(const A of w)v.set(A.id,N)});const x=new Map,y=()=>{for(const w of u)w.forEach((N,A)=>x.set(N.id,A))};y();const m=(w,N)=>{const A=w.map(($,F)=>{const G=N($.id).map(te=>x.get(te)).filter(te=>te!==void 0),q=zk(G);return{n:$,bary:Number.isNaN(q)?F:q,name:$.name,id:$.id}});return A.sort(($,F)=>$.bary-F.bary||$.name.localeCompare(F.name)||$.id.localeCompare(F.id)),A.map($=>$.n)},_=w=>N=>v.get(N)===w;for(let w=0;w<$k;w++){for(let N=1;N(h.get(A)??[]).filter(_(N-1))),y();for(let N=u.length-2;N>=0;N--)u[N]=m(u[N],A=>(p.get(A)??[]).filter(_(N+1))),y()}const k=Wl+Lk,j=as+Ak,b=Math.max(...u.map(w=>w.length),1),E=[];let R=0;for(let w=0;wG.id)),A=new Set((u[w+1]??[]).map(G=>G.id));let $=0;if(A.size)for(const G of r)N.has(G.src)&&A.has(G.dst)&&($+=1);const F=Math.min(96,Math.max(0,($-1)*12));R+=k+F}return u.forEach((w,N)=>{const A=(b-w.length)*j/2;w.forEach(($,F)=>{o.set($.id,{x:E[N]??0,y:A+F*j})})}),o}const Dk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),mm=90,Ok=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),pp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Fk=Math.PI*(3-Math.sqrt(5)),ym=220,Hk=26,Bk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function vm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function FN(t){return pp[t]?pp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Vk(t){return t>=mm?"3d":"2d"}function Wk(t){return t>=mm?"overview":"full"}function Uk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(vm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Ok.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Uk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Gk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function Xk(t,r,o,s){const a=new Set(t.map(j=>j.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const j of r){if(!a.has(j.src)||!a.has(j.dst))continue;const b=u.get(j.src)??[];b.push({dst:j.dst,id:j.id}),u.set(j.src,b);const E=c.get(j.dst)??[];E.push({src:j.src,id:j.id}),c.set(j.dst,E)}const h=new Set(t.filter(j=>Dk.has(j.type)).map(j=>j.id)),p=h.size?h:a,v=new Set,x=[o];for(;x.length;){const j=x.pop();if(!v.has(j)){v.add(j);for(const b of u.get(j)??[])v.has(b.dst)||x.push(b.dst)}}const y=new Set([o]),m=[...p].filter(j=>v.has(j)),_=new Set(m);for(;m.length;){const j=m.pop();y.add(j);for(const b of c.get(j)??[])v.has(b.src)&&!_.has(b.src)&&(_.add(b.src),m.push(b.src))}const k=new Set;for(const j of r)y.has(j.src)&&y.has(j.dst)&&k.add(j.id);return{nodeIds:y,edgeIds:k}}function HN(t){const r=new Map;for(const s of t){const a=ia(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*ym;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Hk*Math.sqrt(h+1),v=h*Fk;o.set(c.id,{x:u,y:p*Math.cos(v),z:p*Math.sin(v)})})}return o}function BN(t){const r=new Map;for(const o of t){const s=ia(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*ym,count:s}))}const bl=16,qk=12,Kk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Qk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),gp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Zk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},mp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],yp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Jk=new Set(["looks_idempotent_on_pk","null","blank"]),eN=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function tN(t){return gp[t]?gp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function nN(t,r,o){const s=new Map(r.map(m=>[m.id,m])),a=[];Kk.has(t.type)&&a.push("sink"),Qk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(m=>m.dst===t.id),h=o.filter(m=>m.src===t.id),p=c.slice(0,bl).map(m=>El(m,s,m.src)),v=h.slice(0,bl).map(m=>El(m,s,m.dst)),x=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,y={type:t.type,typeLabel:Qo(ro(t.type)),layer:Bk[ia(t.type)]??"other",purpose:tN(t.type),name:t.name,qualifiedName:t.qualified_name,file:x,context:t.context,roles:a,facts:iN(u).filter(m=>!(m.key==="app"&&m.value===t.context)),inputs:p,outputs:v,extraInputs:Math.max(0,c.length-bl),extraOutputs:Math.max(0,h.length-bl),degreeIn:c.length,degreeOut:h.length,inputKinds:vp(c.map(m=>El(m,s,m.src))),outputKinds:vp(h.map(m=>El(m,s,m.dst))),pathSummary:""};return y.pathSummary=rN(y),y}function vp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function rN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function El(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Qo(ro(s.type)):"",edgeType:t.type,edgeLabel:Qo(t.type),inferred:t.confidence<.8}}function iN(t){const r=[...mp.filter(a=>a in t),...Object.keys(t).filter(a=>!mp.includes(a)&&!yp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||yp.has(a)||eN.has(a))continue;s.add(a);const u=oN(a,t[a]);u!=null&&o.push({key:a,label:Zk[a]??Qo(a),value:u})}return o}function oN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Jk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return sN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,qk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function sN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const lN=12,xp=.2,aN=.8;function uN(t,r,o){const s=o??gm(t,r),a=[];for(const h of r){const p=s.get(h.src),v=s.get(h.dst);if(!p||!v)continue;const x=p.y+as/2,y=v.y+as/2;if(Math.abs(x-y)${Math.round(_/8)}`})}const u=new Map;for(const h of a){const p=u.get(h.corridor)??[];p.push(h),u.set(h.corridor,p)}const c=new Map;for(const h of u.values()){const p=[...h].sort((x,y)=>x.sourceY-y.sourceY||x.id.localeCompare(y.id)),v=p.length;p.forEach((x,y)=>{c.set(x.id,cN(y,v))})}return c}function cN(t,r){return r<=1?.5:xp+(aN-xp)*t/(r-1)}const dN=new Set,fN=L.lazy(()=>k0(()=>import("./LayeredGraph3D-CfNK3S5A.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),hN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function pN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(no,{type:"target",position:Se.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:ro(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Tr(t.name)}),d.jsx(no,{type:"source",position:Se.Right,isConnectable:!1})]})}const gN={load:pN},mN=new Set(["django","react","stitch","arch"]);function yN({id:t,sourceX:r,sourceY:o,targetX:s,targetY:a,sourcePosition:u,targetPosition:c,style:h,markerEnd:p,markerStart:v,label:x,labelStyle:y,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,data:b,interactionWidth:E}){const[R,w,N]=Bl({sourceX:r,sourceY:o,sourcePosition:u,targetX:s,targetY:a,targetPosition:c,borderRadius:8,stepPosition:(b==null?void 0:b.stepPosition)??.5});return d.jsx(ms,{id:t,path:R,labelX:w,labelY:N,label:x,labelStyle:y,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,style:h,markerEnd:p,markerStart:v,interactionWidth:E})}const vN={loadstep:yN};function xN({topologyKey:t}){const{fitView:r}=na();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function wN(t,r,o=null,s={}){const a=new Map(t.map(v=>[v.id,v])),u=gm(t,r),c=uN(t,r,u),h=t.map(v=>{var m;const x=((m=s.roles)==null?void 0:m[v.id])||[],y=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:v.id,type:"load",position:u.get(v.id)??{x:0,y:0},data:{name:v.name,type:v.type,file:v.file_path,roles:x,dim:y},selected:o===v.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:Wl,height:as,style:{width:Wl,height:as}}}),p=r.filter(v=>a.has(v.src)&&a.has(v.dst)).map(v=>{const x=hN[v.weight]||"var(--edge-cheap)",y=!!(o&&(v.src===o||v.dst===o));return{id:v.id,source:v.src,target:v.dst,type:"loadstep",animated:v.weight==="critical",data:{stepPosition:c.get(v.id)??.5},style:{stroke:x,strokeWidth:v.weight==="critical"?2.4:1.2,strokeDasharray:v.confidence<.8?"6 4":void 0},markerEnd:{type:is.ArrowClosed,width:14,height:14,color:x},label:y?v.type.replaceAll("_"," "):void 0,labelStyle:y?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:y?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:y?[3,5]:void 0,labelBgBorderRadius:y?4:void 0}});return{rfNodes:h,rfEdges:p}}function _N({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:v}){const x=nN(t,r,o);return L.useEffect(()=>{const y=m=>{m.key==="Escape"&&s()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:x.typeLabel}),d.jsx("div",{className:"inspector-roles",children:x.roles.map(y=>d.jsx("span",{className:"inspector-chip",children:y},y))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Tr(x.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:x.purpose}),x.context?d.jsx("div",{className:"muted",children:Tr(x.context)}):null,x.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Tr(x.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Tr(x.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",x.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[x.degreeIn," in · ",x.degreeOut," out"]}),x.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:x.pathSummary}):null,x.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:x.facts.map(y=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:y.label}),d.jsx("dd",{children:Tr(y.value)})]},y.key))}):null,d.jsx(wp,{title:"Inputs",testId:"graph-inspector-inputs",links:x.inputs,extra:x.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(wp,{title:"Outputs",testId:"graph-inspector-outputs",links:x.outputs,extra:x.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),a?d.jsx("p",{className:"whatif-hint","data-testid":"whatif-hint",children:v?"Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map.":"Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."}):null,d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",title:"Start a hypothetical walk from this node. Does not use Base/Head.",onClick:()=>a(t.id),children:"What if this changes"}):null,v?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",title:"Hide nodes that are not on a path from here to a sink. Does not start a new walk.",onClick:()=>v(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function wp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Qu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:v,repoPath:x,onOpenFile:y,pinnedId:m,onPin:_}){const[k,j]=L.useState(null),b=a!==void 0?a:k,E=re=>{a===void 0&&j(re),u==null||u(re)},[R,w]=L.useState(null),[N,A]=L.useState(null),[$,F]=L.useState(new Set(mN)),[G,q]=L.useState(!1),[te,ee]=L.useState(""),[ne,K]=L.useState(!1),C=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,V=R??Vk(t.length),W=N??Wk(t.length),U=G?b:null,M=L.useMemo(()=>p?Xk(t,r,p):null,[t,r,p]),D=M?t.filter(re=>M.nodeIds.has(re.id)):t,H=M?r.filter(re=>M.edgeIds.has(re.id)):r,I=L.useMemo(()=>Yk(D,H,{detail:W,families:$,focusId:U,neighborhoodOnly:!!U}),[D,H,W,$,U]),z=L.useMemo(()=>`${I.nodes.map(re=>re.id).join("\0")}|${I.edges.map(re=>re.id).join("\0")}`,[I.nodes,I.edges]),ie=b?t.find(re=>re.id===b)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const re=wN(I.nodes,I.edges,b,{roles:c,testOverlay:h});return C&&(re.rfEdges=re.rfEdges.map(Ne=>({...Ne,animated:!1}))),re},[I.nodes,I.edges,b,C,c,h]);L.useEffect(()=>{if(!s)return;const re=t.find(Ne=>Ne.file_path===s);re&&E(re.id)},[s,t]);const he=L.useMemo(()=>Gk(t,te),[t,te]),pe=(re,Ne)=>{E(Ne.id)},Z=()=>{E(null),q(!1)},se=ie?d.jsx(_N,{node:ie,nodes:t,edges:r,onClose:Z,onWhatIf:o,onSelect:E,onOpenFile:y,pinned:m===ie.id,onPin:_,onIsolate:v?re=>{v(p===re?null:re)}:void 0}):null,me=re=>{F(Ne=>{const Me=new Set(Ne);if(Me.has(re)){if(Me.size===1)return Ne;Me.delete(re)}else Me.add(re);return Me})},ke=L.useMemo(()=>{const re=new Set;for(const Ne of t)re.add(vm(Ne.type));return re},[t]),ve=t.length-I.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:V==="2d"?"active":"","aria-pressed":V==="2d",onClick:()=>w("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:V==="3d"?"active":"","aria-pressed":V==="3d",onClick:()=>w("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:W==="overview"?"active":"","aria-pressed":W==="overview",onClick:()=>A("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:W==="full"?"active":"","aria-pressed":W==="full",onClick:()=>A("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(re=>ke.has(re)).map(re=>d.jsx("button",{type:"button","data-testid":`graph-family-${re}`,className:$.has(re)?"active":"","aria-pressed":$.has(re),onClick:()=>me(re),children:re},re))}),d.jsx("button",{type:"button",className:G?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!b,onClick:()=>q(re=>!re),children:G?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>v==null?void 0:v(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:te,onChange:re=>{ee(re.target.value),K(!0)},onFocus:()=>K(!0),onBlur:()=>window.setTimeout(()=>K(!1),150)}),ne&&te.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(re=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:Ne=>Ne.preventDefault(),onClick:()=>{E(re.id),ee(""),K(!1)},children:[re.name,d.jsx("span",{className:"muted",children:ro(re.type)})]})},re.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[I.nodes.length," nodes · ",I.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:V==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(fN,{nodes:I.nodes,edges:I.edges,selectedId:b,neighborIds:U?I.neighborIds:dN,onSelect:re=>{E(re),re||q(!1)}})}),se]}):d.jsxs(dm,{children:[d.jsxs(rk,{nodes:oe,edges:fe,nodeTypes:gN,edgeTypes:vN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:Z,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(xN,{topologyKey:z}),d.jsx(ak,{}),d.jsx(Mk,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(gk,{})]}),se]})})]})}function xm(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function SN(t){localStorage.setItem("loadpath.editor",t)}async function kN(t,r,o,s=xm()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const _p=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],NN=["preset","branch","tag","commit"];function jN(t){var a;if(!(t!=null&&t.git))return[..._p];const r=((a=t.presets)!=null&&a.length?t.presets:_p.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function bN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function EN(t){return NN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function CN(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function Sp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[v,x]=L.useState(!1),[y,m]=L.useState(null),[_,k]=L.useState(0),j=L.useMemo(()=>{const N=jN(u);return y===null?N:bN(N,y)},[u,y]),b=L.useMemo(()=>EN(j),[j]);L.useEffect(()=>{v&&c()},[v,c]),L.useEffect(()=>{k(0)},[y,v]);const E=()=>{x(!1),m(null)},R=N=>{r(N.value),E()},w=N=>{if(N.key==="ArrowDown"){if(N.preventDefault(),!v){x(!0);return}k(A=>Math.min(A+1,Math.max(j.length-1,0)))}else if(N.key==="ArrowUp"){if(N.preventDefault(),!v)return;k(A=>Math.max(A-1,0))}else if(N.key==="Enter"&&v){N.preventDefault();const A=j[_];A&&R(A)}else N.key==="Escape"&&v&&(N.preventDefault(),E())};return d.jsxs("div",{className:"combo",ref:p,onBlur:N=>{N.currentTarget.contains(N.relatedTarget)||E()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":v,"aria-controls":h,"aria-autocomplete":"list",onChange:N=>{r(N.target.value),v&&m(N.target.value)},onKeyDown:w}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":v,onMouseDown:N=>N.preventDefault(),onClick:()=>v?E():x(!0),children:d.jsx(w0,{})})]}),v?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:b.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):b.map(N=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:CN(N.group)}),N.items.map(A=>{const $=j.indexOf(A);return d.jsxs("button",{type:"button",role:"option","aria-selected":$===_,className:$===_?"combo-option active":"combo-option","data-testid":`ref-option-${A.group}`,onMouseDown:F=>F.preventDefault(),onMouseEnter:()=>k($),onClick:()=>R(A),children:[d.jsx("span",{className:"combo-label",children:A.label}),A.detail?d.jsx("span",{className:"combo-detail",children:A.detail}):null]},`${A.group}:${A.value}`)})]},N.group))}):null]})}function MN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[v,x]=L.useState(""),[y,m]=L.useState(!1),_=L.useRef(null),k=L.useRef(0),j=async w=>{const N=k.current+1;k.current=N,m(!0);try{const A=await Pe.browse(w);if(k.current!==N)return;a(A),c(A.path),p(A.is_git?A.path:null),x("")}catch(A){if(k.current!==N)return;x(A instanceof Error?A.message:String(A))}finally{k.current===N&&m(!1)}};L.useEffect(()=>{var w,N;j(t),(w=_.current)==null||w.focus(),(N=_.current)==null||N.select()},[t]);const b=h||(s==null?void 0:s.path)||u,E=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",R=w=>{w.key==="Escape"&&(w.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:R,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:w=>w.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:w=>{w.preventDefault(),j(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:w=>c(w.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),v?d.jsx("div",{className:"error",role:"alert",children:v}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":y,children:s!=null&&s.entries.length?s.entries.map(w=>{const N=h===w.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":N,className:N?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":w.path,onClick:()=>p(w.path),onDoubleClick:()=>void j(w.path),children:[d.jsx(bp,{}),d.jsx("span",{className:"explorer-name",children:w.name}),w.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},w.path)}):d.jsx("div",{className:"muted explorer-empty",children:y?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:b,children:b}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!b,onClick:()=>b&&r(b),children:["Use ",E]})]})]})})}const PN={scan:{start:0,end:20},extract:{start:20,end:88},boot:{start:88,end:94},stitch:{start:94,end:99},skipped:{start:100,end:100},done:{start:100,end:100}},IN=new Set(["scan","extract","boot","stitch"]);function RN(t){const r=t.phase||"";if(!r||r==="idle")return null;const o=PN[r];if(!o)return null;if(o.start===o.end)return o.end;const s=t.total||0;if(s<=0)return o.start;const a=Math.min(1,Math.max(0,(t.done||0)/s));return Math.round(o.start+(o.end-o.start)*a)}function TN(t){return!t.phase||t.phase==="idle"?null:typeof t.percent=="number"&&Number.isFinite(t.percent)?Math.max(0,Math.min(100,Math.round(t.percent))):RN(t)}const Ul=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],LN="obsidian",wm="loadpath.theme";function AN(t){return Ul.some(r=>r.id===t)}function _m(){try{const t=localStorage.getItem(wm)||"";if(AN(t))return t}catch{}return LN}function $N(t){var r;return((r=Ul.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function Sm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=$N(t);try{localStorage.setItem(wm,t)}catch{}}const Zu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:g0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:m0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:y0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:v0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:x0}];function Ju(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function zN(){var co,fo,Si,ho,po,go,ki,Xr,rn,on;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,v]=L.useState(null),[x,y]=L.useState(null),[m,_]=L.useState(null),[k,j]=L.useState([]),[b,E]=L.useState("review"),[R,w]=L.useState(""),[N,A]=L.useState(""),[$,F]=L.useState(null),[G,q]=L.useState(!1),[te,ee]=L.useState(!1),[ne,K]=L.useState(""),[C,V]=L.useState({}),[W,U]=L.useState([]),[M,D]=L.useState([]),[H,I]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[z,ie]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[oe,fe]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[he,pe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[Z,se]=L.useState(0),[me,ke]=L.useState(""),[ve,re]=L.useState(_m),[Ne,Me]=L.useState(!1),[Te,$e]=L.useState(!1),[st,lt]=L.useState(!1),[at,Ge]=L.useState(null),[wt,qt]=L.useState(null),[gt,mt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[Pt,ut]=L.useState(null),[Je,An]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[Ot,xn]=L.useState([]),[io,$n]=L.useState(null),[vi,or]=L.useState(null),[$r,zn]=L.useState(null),[zr,sr]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[lr,Ft]=L.useState(null),[ct,Dn]=L.useState(null),[On,wn]=L.useState(!1),[Fn,_n]=L.useState(!1),rt=L.useRef(o);rt.current=o;const Dr=L.useRef(!1);Dr.current=Te;const _t=L.useRef(""),ar=L.useRef(""),Sn=P=>{re(P),Sm(P)},dt=L.useRef(""),He=P=>{dt.current=P,A(P)},kn=P=>{let Y=0,ce=!1;F(0);const je=()=>{Pe.indexProgress(P).then(Ie=>{if(!dt.current)return;if(Ie.phase&&Ie.phase!=="idle"&&Ie.message&&He(Ie.message),IN.has(Ie.phase))ce=!0;else if(!ce)return;const qr=TN(Ie);qr!=null&&(Ie.phase==="scan"&&!Ie.done?Y=qr:Y=Math.max(Y,qr),F(Y))}).catch(()=>{})};je();const Le=window.setInterval(je,250);return()=>{window.clearInterval(Le),F(null)}};L.useEffect(()=>{Pe.settings().then(V).catch(()=>{}).finally(()=>Me(!0)),Pe.repos().then(P=>j(P.repos)).catch(()=>{})},[]);const Nn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const P=o;let Y=!1;return ar.current!==P&&Bn(P),Pe.config(P).then(ce=>{!Y&&rt.current===P&&or(ce)}).catch(()=>{}),Pe.architectureHealth(P).then(ce=>{!Y&&rt.current===P&&zn(ce)}).catch(()=>{}),()=>{Y=!0}},[t,o]);const Ht=P=>{rt.current=P,s(P),localStorage.setItem("loadpath.repo",P),P.trim()!==_t.current&&(_t.current="",Ft(null))},Or=L.useCallback(P=>{const Y=(P??rt.current).trim();return!Y||_t.current===Y?Promise.resolve():(_t.current=Y,Pe.gitRefs(Y).then(ce=>{rt.current.trim()===Y&&Ft(ce)}).catch(()=>{_t.current===Y&&(_t.current="",Ft(null))}))},[]),nn=(P,Y)=>{u(P),h(Y),localStorage.setItem("loadpath.base",P),localStorage.setItem("loadpath.head",Y)},Fr=(P,Y,ce)=>{ie(P),I(Y),localStorage.setItem("loadpath.provider",P),localStorage.setItem("loadpath.scmRepo",Y),ce!==void 0&&(fe(ce),localStorage.setItem("loadpath.prNumber",ce))},yt=P=>{v(P),se(0),Ge(wt&&P.nodes.some(Y=>Y.id===wt)?wt:null),ut(null),$n(null),P.what_if||(y(P),P.id&&localStorage.setItem("loadpath.lastReviewId",P.id))},Hn=async P=>{try{const Y=await Pe.reviews(P);xn(Y.reviews)}catch{xn([])}},ur=async P=>{try{zn(await Pe.architectureHealth(P))}catch{zn(null)}},oo=P=>P==="github"?!!C.github_token_set:P==="gitlab"?!!C.gitlab_token_set:!!C.bitbucket_token_set,It=L.useCallback(async(P=z)=>{var Y;try{const ce=await Pe.scmRepos(P);D(ce.repos),(Y=ce.user)!=null&&Y.login&&V(je=>({...je,...P==="github"?{github_user:ce.user.login}:P==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{D([])}},[z]);L.useEffect(()=>{if(t!=="prs")return;let P=!1;return It(z).catch(()=>{P||D([])}),()=>{P=!0}},[t,z,It]),L.useEffect(()=>{if(!ct)return;let P=!1,Y=0;const ce=async()=>{try{const je=await Pe.githubOAuthPoll(ct.flow_id);if(P)return;if(je.status==="complete"){Dn(null);const Le=await Pe.settings();V(Le),K(je.user?`Signed in to GitHub as ${je.user}`:"Signed in to GitHub"),It("github");return}if(je.status==="pending"||je.status==="slow_down"){Y=window.setTimeout(ce,Math.max(je.interval||ct.interval,5)*1e3);return}Dn(null),w(je.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(je){if(P)return;Dn(null),w(je instanceof Error?je.message:String(je))}};return Y=window.setTimeout(ce,Math.max(ct.interval,5)*1e3),()=>{P=!0,window.clearTimeout(Y)}},[ct,It]),L.useEffect(()=>{if(!On)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.bitbucket.connected){wn(!1);const Ie=await Pe.settings();V(Ie),K(Le.bitbucket.user?`Signed in to Bitbucket as ${Le.bitbucket.user}`:"Signed in to Bitbucket"),It("bitbucket");return}if(Date.now()-ce>18e4){wn(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;wn(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[On,It]),L.useEffect(()=>{if(!Fn)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.gitlab.connected){_n(!1);const Ie=await Pe.settings();V(Ie),K(Le.gitlab.user?`Signed in to GitLab as ${Le.gitlab.user}`:"Signed in to GitLab"),It("gitlab");return}if(Date.now()-ce>18e4){_n(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;_n(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[Fn,It]);const Bn=async(P=o,Y=!1)=>{if(!P.trim())return null;ar.current=P,ee(!0);try{const ce=await Pe.architecture(P,!1);rt.current===P&&_(ce);const je=Pe.architectureGraph(P).then(Le=>{rt.current===P&&_(Ie=>Ie&&{...Ie,nodes:Le.nodes,edges:Le.edges,graph_pending:!1})});return je.catch(()=>{}).finally(()=>{rt.current===P&&ee(!1)}),Y&&await je,ce}catch(ce){throw rt.current===P&&ee(!1),ce}},Hr=async P=>{const Y=P.trim();if(!(!Y||Y===rt.current)){if(dt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),K(""),v(null),y(null),_(null),E("architecture"),Ht(Y),q(!0),He(`Loading ${p0(Y)}…`);try{await Promise.all([Bn(Y),Or(Y)])}catch(ce){rt.current===Y&&w(ce instanceof Error?ce.message:String(ce))}finally{rt.current===Y&&(He(""),q(!1))}}},jn=async()=>{if(dt.current||!Nn())return;w(""),K(""),He("Tracing load path…"),Ht(o),nn(a,c);const P=kn(o);try{const Y=await Pe.review(o,a,c,!0,he);yt(Y),E("review"),r("review"),await Pe.repos().then(ce=>j(ce.repos)).catch(()=>{}),await Promise.all([Bn(o),Hn(o),ur(o)])}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{P(),He("")}},Br=async(P=!0)=>{if(dt.current||!Nn())return;w(""),K(""),He(P?"Indexing…":"Full reindex…"),Ht(o);const Y=kn(o);try{await Pe.index(o,P);const ce=await Bn(o);await Pe.repos().then(je=>j(je.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(E("architecture"),r("architecture"))}catch(ce){w(ce instanceof Error?ce.message:String(ce))}finally{Y(),He("")}},xi=async()=>{if(!dt.current&&Nn()){w(""),K(""),He("Detecting layout…"),Ht(o);try{const P=await Pe.init(o);K(P.message),await Pe.repos().then(Y=>j(Y.repos)).catch(()=>{})}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ve=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),K("Copied markdown brief")}catch(P){w(P instanceof Error?P.message:String(P))}},so=async()=>{if(!dt.current){if(p!=null&&p.what_if){w("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first.");return}if(!(p!=null&&p.markdown)||!H||!oe){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const P=await Pe.postComment(z,H,Number(oe),p.markdown);K(P.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Vr=async()=>{if(!dt.current){w(""),He("Fetching pull requests…");try{const P=await Pe.prs(z,H,"open",o.trim()||void 0);U(P.pull_requests);const Y=M.find(ce=>ce.slug.toLowerCase()===H.trim().toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},wi=async()=>{w("");try{const P=await Pe.githubOAuthStart();Dn(P),Ju(P.verification_uri_complete,"github.com","/login/device")}catch(P){w(P instanceof Error?P.message:String(P))}},cr=async()=>{w("");try{const P=await Pe.bitbucketOAuthStart();wn(!0),Ju(P.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(P){wn(!1),w(P instanceof Error?P.message:String(P))}},lo=async()=>{w("");try{const P=await Pe.gitlabOAuthStart();_n(!0),Ju(P.authorize_url,new URL(P.authorize_url).hostname,"/oauth/authorize")}catch(P){_n(!1),w(P instanceof Error?P.message:String(P))}},dr=async P=>{if(!(dt.current||!o.trim())){w(""),He("Walking what-if path…");try{const Y=await Pe.whatIf(o,P);K(`${Y.title} — ${Y.confidence.level} · ${(Y.sinks||[]).length} sinks`),yt({...Y,markdown:Y.markdown||"",index:Y.index||(p==null?void 0:p.index),workspace:Y.workspace||(p==null?void 0:p.workspace)}),E("review"),r("review")}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},Vn=()=>{if(x){yt(x),E("review"),r("review"),K("Restored the last git-range walk");return}v(null),se(0),Ge(null),ut(null),$n(null),E("architecture"),r("architecture"),K("")},bt=async P=>{var Le;if(dt.current)return;Fr(P.provider,P.repo,String(P.number));const Y=M.find(Ie=>Ie.slug.toLowerCase()===P.repo.toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path),w(""),He(`Fetching ${P.provider} #${P.number}…`);const ce=(Y==null?void 0:Y.local_path)||o,je=ce?kn(ce):()=>{};try{const Ie=await Pe.reviewPr(P.provider,P.repo,P.number,(Y==null?void 0:Y.local_path)||o||void 0);yt(Ie),Ie.pull_request&&typeof Ie.pull_request.repo_path=="string"&&Ht(Ie.pull_request.repo_path),nn(String(Ie.base||P.target_branch),String(Ie.head||P.source_branch)),E("review"),r("review"),typeof((Le=Ie.pull_request)==null?void 0:Le.repo_path)=="string"&&Hn(Ie.pull_request.repo_path)}catch(Ie){nn(P.base_sha||P.target_branch,P.head_sha||P.source_branch),r("review"),w(Ie instanceof Error?Ie.message:String(Ie))}finally{je(),He("")}},Wr=async P=>{w("");try{V(await Pe.oauthDisconnect(P)),z===P&&D([]),K(`Disconnected ${P}`)}catch(Y){w(Y instanceof Error?Y.message:String(Y))}},Et=async P=>{P.preventDefault();const Y=new FormData(P.currentTarget),ce={github_token:String(Y.get("github_token")||""),github_oauth_client_id:String(Y.get("github_oauth_client_id")||""),github_host:String(Y.get("github_host")||""),gitlab_token:String(Y.get("gitlab_token")||""),gitlab_host:String(Y.get("gitlab_host")||""),gitlab_oauth_client_id:String(Y.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(Y.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(Y.get("bitbucket_token")||""),bitbucket_username:String(Y.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(Y.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(Y.get("bitbucket_oauth_client_secret")||""),ai_provider:String(Y.get("ai_provider")||"none"),ai_api_key:String(Y.get("ai_api_key")||""),ai_model:String(Y.get("ai_model")||""),ai_base_url:String(Y.get("ai_base_url")||"")},je=k.length?{...ce,workspaces:k.map(Le=>({path:Le.path,name:Le.name}))}:ce;try{V(await Pe.saveSettings(je)),K("Settings saved on this machine")}catch(Le){w(Le instanceof Error?Le.message:String(Le))}},ao=async()=>{if(!(!p||dt.current)){He("Residual analysis…");try{const P=await Pe.residual(p);ke(P.note)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ur=L.useRef(jn);Ur.current=jn;const Yr=L.useRef(t);Yr.current=t;const Wn=L.useRef(!1);Wn.current=st;const Un=L.useRef(p);Un.current=p;const bn=L.useRef(Z);bn.current=Z,L.useEffect(()=>{const P=localStorage.getItem("loadpath.lastReviewId"),Y=(localStorage.getItem("loadpath.repo")||"").trim();if(!P||!Y){sr(!1);return}let ce=!1;return Pe.getReview(Y,P).then(je=>{ce||(yt(je),nn(je.base||localStorage.getItem("loadpath.base")||"HEAD~1",je.head||localStorage.getItem("loadpath.head")||"HEAD"),Hn(Y),ur(Y))}).catch(()=>{}).finally(()=>{ce||sr(!1)}),()=>{ce=!0}},[]);const Bt=L.useRef("");L.useEffect(()=>{if(!Je||!o.trim())return;let P=!1;const Y=async()=>{try{const je=await Pe.workspaceStatus(o);if(P)return;Bt.current&&je.fingerprint!==Bt.current&&!dt.current&&(pe(!0),localStorage.setItem("loadpath.dirty","1"),Ur.current()),Bt.current=je.fingerprint}catch{}};Y();const ce=window.setInterval(Y,2e3);return()=>{P=!0,window.clearInterval(ce)}},[Je,o]),L.useEffect(()=>{const P=Y=>{var Le;if((Y.metaKey||Y.ctrlKey)&&Y.key.toLowerCase()==="k"){Y.preventDefault(),lt(Ie=>!Ie);return}if(Wn.current){Y.key==="Escape"&&(Y.preventDefault(),lt(!1));return}if(Dr.current){Y.key==="Escape"&&(Y.preventDefault(),$e(!1));return}const ce=Y.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){Y.key==="Escape"&&ce.blur();return}if(Y.key==="Escape"){w(""),K(""),Ge(wt),ut(null);return}if(Y.key==="j"||Y.key==="k"){const Ie=((Le=Un.current)==null?void 0:Le.read_order)||[];if(!Ie.length)return;Y.preventDefault();const Gn=bn.current,qr=Y.key==="j"?Math.min(Ie.length-1,Gn+1):Math.max(0,Gn-1);se(qr);return}const je=Zu.find(Ie=>Ie.shortcut===Y.key);if(je&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey&&r(je.id),(Y.metaKey||Y.ctrlKey)&&Y.key==="Enter"){if(Yr.current==="settings"||Yr.current==="prs"||dt.current)return;Y.preventDefault(),Ur.current()}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[wt]);const _i=async(P,Y)=>{if(!o.trim())return;const ce=await kN(o,P,Y);ce.ok?K(ce.message):w(ce.message)},Gr=async()=>{if(p)try{const P=await Pe.exportHtml(p),Y=URL.createObjectURL(P),ce=document.createElement("a");ce.href=Y,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(Y),K("Saved HTML brief")}catch(P){w(P instanceof Error?P.message:String(P))}},fr=async P=>{if(o.trim()){He("Loading stored review…");try{const Y=await Pe.getReview(o,P);yt(Y),nn(Y.base||a,Y.head||c),E("review"),r("review");const ce=Ot.find(je=>je.id!==P);if(ce)try{$n(await Pe.reviewDiff(o,P,ce.id))}catch{$n(null)}}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},hr={selectedId:at,onSelect:Ge,nodeRoles:p==null?void 0:p.node_roles,testOverlay:gt,isolateSource:Pt,onIsolate:ut,repoPath:o,onOpenFile:_i,pinnedId:wt,onPin:qt},Yn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},...p!=null&&p.what_if?[{id:"exit-whatif",group:"Review",label:x?"Back to git-range walk":"Exit what-if walk",run:Vn}]:[],{id:"index",group:"Run",label:"Index repository",run:()=>void Br(!0)},{id:"watch",group:"Run",label:Je?"Stop watching working tree":"Watch working tree",run:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")}},{id:"tests",group:"Graph",label:gt?"Hide test overlay":"Show test overlay",run:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Gr()},...Zu.map(P=>({id:`tab-${P.id}`,group:"Tabs",label:`Go to ${P.label}`,hint:P.shortcut,run:()=>r(P.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(P=>({id:`node-${P.id}`,group:"Nodes",label:P.name,hint:ro(P.type),run:()=>{Ge(P.id),r("graph")}})),...Ot.slice(0,12).map(P=>({id:`hist-${P.id}`,group:"History",label:P.title||P.id,hint:`${P.level||""} ${P.created_at||""}`.trim(),run:()=>void fr(P.id)}))],En=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[b,m,p]),uo=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[b,m,p]),pr=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Fe=((p==null?void 0:p.findings)||[]).filter(P=>!P.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Zu.map(P=>{const Y=P.icon,ce=t===P.id;return d.jsxs("button",{type:"button","data-testid":P.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":P.label,onClick:()=>r(P.id),children:[d.jsx(Y,{}),d.jsx("span",{children:P.label})]},P.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:ve,onChange:P=>Sn(P.target.value),children:["dark","light"].map(P=>d.jsx("optgroup",{label:P==="dark"?"Dark":"Light",children:Ul.filter(Y=>Y.group===P).map(Y=>d.jsx("option",{value:Y.id,children:Y.label},Y.id))},P))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:N||pr}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[N?d.jsxs("div",{className:$!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","aria-valuemin":$!=null?0:void 0,"aria-valuemax":$!=null?100:void 0,"aria-valuenow":$??void 0,"data-testid":"progress",children:[d.jsx("i",{style:$!=null?{width:`${$}%`}:void 0}),d.jsx("span",{className:"sr-only",children:N})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[k.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:k.some(P=>P.path===o)?o:"",disabled:!!N,"aria-busy":G,onChange:P=>{P.target.value&&Hr(P.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),k.map(P=>d.jsxs("option",{value:P.path,children:[P.name,P.indexed?` (${P.counts.nodes})`:""]},P.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:P=>{const Y=P.target.value;s(Y),Y.trim()!==_t.current&&(_t.current="",Ft(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>$e(!0),children:d.jsx(bp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(Sp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:P=>nn(P,c),placeholder:"base",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(Sp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:P=>nn(a,P),placeholder:"head",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:he?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":he,onClick:()=>{const P=!he;pe(P),localStorage.setItem("loadpath.dirty",P?"1":"0")},children:he?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:Je?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":Je,onClick:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")},children:Je?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.what_if?"what-if · ":"",p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!N,onClick:xi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!N,onClick:()=>Br(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!N,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[R?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:R}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,ne?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:ne}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>K(""),"aria-label":"Dismiss",children:"×"})]}):null,((co=p==null?void 0:p.index)!=null&&co.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((fo=p==null?void 0:p.index)==null?void 0:fo.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Si=p==null?void 0:p.index)==null?void 0:Si.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(ho=p==null?void 0:p.workspace)!=null&&ho.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,p!=null&&p.what_if?d.jsxs("div",{className:"banner whatif","data-testid":"whatif-banner",children:[d.jsxs("span",{children:["Hypothetical walk from"," ",d.jsx("strong",{children:((po=p.node)==null?void 0:po.name)||"this node"}),". Loadpath ignored Base/Head and asked which sinks would feel this node change — not a filter of the current map."]}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-exit-whatif",onClick:Vn,children:x?"Back to git range":"Back to architecture"})]}):null,G?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:N||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":G||te,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(DN,{review:p,findings:Fe,aiNote:me,busy:!!N,tourIndex:Z,onTour:se,onAskAi:ao,onCopy:Ve,onPost:so,onSelect:Ge,onOpenFile:_i,onExport:Gr,history:Ot,diff:io,onReopen:fr,onWaiver:(P,Y)=>{o.trim()&&Pe.addWaiver(o,P,Y||void 0,"from review").then(ce=>{or(ce),K(`Waived ${P} in loadpath.yml`)})}}):zr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Qu,{nodes:p.nodes,edges:p.edges,onWhatIf:dr,focusPath:(go=p.read_order[Z])==null?void 0:go.path,...hr}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(ON,{architecture:m,busy:!!N,onReindex:()=>Br(!1),onReview:jn,onSelect:Ge,config:vi,health:$r,onSaveConfig:P=>{Pe.saveConfig(o,P).then(Y=>{or(Y),K("Wrote loadpath.yml")})},onWaiver:(P,Y,ce)=>{Pe.addWaiver(o,P,Y,ce).then(je=>{or(je),K(`Waived ${P}`)})}}):G?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(te||m!=null&&m.graph_pending)&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(ki=m==null?void 0:m.counts)!=null&&ki.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Qu,{nodes:m.nodes,edges:m.edges,onWhatIf:dr,...hr,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":b==="review","data-testid":"graph-mode-review",className:b==="review"?"active":"",onClick:()=>E("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":b==="architecture","data-testid":"graph-mode-architecture",className:b==="architecture"?"active":"",onClick:()=>E("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:gt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":gt,onClick:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")},children:"Tests"})]}),En.length?d.jsx(Qu,{nodes:En,edges:uo,onWhatIf:dr,...hr}):te||m!=null&&m.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:z,onChange:P=>Fr(P.target.value,H,oe),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:M.length?"Search your repos":"owner/repo",value:H,onChange:P=>Fr(z,P.target.value,oe),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:M.map(P=>d.jsxs("option",{value:P.slug,children:[P.private?"private":"public",P.local_path?" · local":""]},P.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!N||!oo(z),onClick:()=>{It(z)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!N,onClick:Vr,children:"List PRs"})]}),M.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[M.length," ",z," repositor",M.length===1?"y":"ies",z==="github"&&C.github_user?` · @${String(C.github_user)}`:"",z==="gitlab"&&C.gitlab_user?` · @${String(C.gitlab_user)}`:"",z==="bitbucket"&&C.bitbucket_user?` · ${String(C.bitbucket_user)}`:""]}):null,W.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):W.map(P=>{var Y;return d.jsxs("article",{className:"pr","data-testid":`pr-${P.number}`,children:[d.jsxs("h3",{children:["#",P.number," ",P.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${P.draft?"":"open"}`,children:P.draft?"draft":P.state}),d.jsx("span",{children:P.author}),d.jsxs("span",{children:[P.source_branch," → ",P.target_branch]}),P.loadpath?d.jsxs("span",{className:`chip ${P.loadpath.level||""}`,"data-testid":`pr-loadpath-${P.number}`,children:[((Y=P.loadpath.level)==null?void 0:Y.toUpperCase())||"REVIEWED",P.loadpath.contract_break&&P.loadpath.contract_break!=="none"?` · ${P.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:P.url,target:"_blank",rel:"noreferrer",children:["Open on ",P.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${P.number}`,onClick:()=>void bt(P),children:"Review this PR"})]})]},`${P.provider}-${P.number}`)})]}),t==="settings"&&Ne&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Et,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Ul.map(P=>d.jsxs("button",{type:"button","data-theme":P.id,className:ve===P.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${P.id}`,onClick:()=>Sn(P.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:P.label}),d.jsx("div",{className:"group",children:P.group})]},P.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:xm(),onChange:P=>SN(P.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:C.github_token_set?C.github_user?`Signed in as @${String(C.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void Wr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!ct||!C.github_oauth_ready,onClick:()=>void wi(),children:ct?"Waiting for GitHub…":"Sign in with GitHub"})})]}),ct?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:ct.user_code})," at GitHub if the browser did not fill it in."]}):null,C.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(C.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(C.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:C.gitlab_token_set?C.gitlab_user?`Signed in as @${String(C.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void Wr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Fn||!C.gitlab_oauth_ready,onClick:()=>void lo(),children:Fn?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(C.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(C.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:C.bitbucket_token_set?C.bitbucket_user?`Signed in as ${String(C.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void Wr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:On||!C.bitbucket_oauth_ready,onClick:()=>void cr(),children:On?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),C.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(C.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(C.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((Xr=C.ai)==null?void 0:Xr.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((rn=C.ai)==null?void 0:rn.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((on=C.ai)==null?void 0:on.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(d0,{open:st,actions:Yn,onClose:()=>lt(!1)}),Te?d.jsx(MN,{initialPath:o,onClose:()=>$e(!1),onSelect:P=>{if(dt.current){w("Wait for the current job to finish before switching workspace.");return}$e(!1),Hr(P)}}):null]})}function DN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:v,onOpenFile:x,onExport:y,history:m,diff:_,onReopen:k,onWaiver:j}){var E,R,w,N,A,$,F,G,q,te,ee,ne,K,C,V,W,U;const b=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),b.length?d.jsx("ul",{className:"reasons",children:b.map(M=>d.jsx("li",{children:M},M))}):null,t.what_if?d.jsx("span",{className:"chip whatif","data-testid":"whatif-chip",children:"what-if"}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Qo(M)},M)),(E=t.contract_break)!=null&&E.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>j(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(R=t.workspace)!=null&&R.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>x(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(km,{cards:t.deepening}),(N=(w=t.contract_break)==null?void 0:w.reasons)!=null&&N.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),($=(A=t.contract_break.sides)==null?void 0:A.rows)!=null&&$.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(F=t.auth)!=null&&F.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(G=t.suggested_tests)==null?void 0:G.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(q=t.trend)!=null&&q.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",ec(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),m.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:m.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,m.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>k(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?ec(M.created_at):""})]},M.id))]}):null,(ee=(te=t.evolution)==null?void 0:te.notes)!=null&&ee.length||(K=(ne=t.evolution)==null?void 0:ne.hotspots)!=null&&K.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((C=t.evolution)==null?void 0:C.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((V=t.evolution)==null?void 0:V.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:y,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",disabled:s||!!t.what_if,title:t.what_if?"Hypothetical walks are not posted to a pull request":void 0,onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(W=t.codeowners_reviewers)!=null&&W.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function ON({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var x;const v=t.findings.filter(y=>!y.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${ec(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(y=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y.name})," — ",(y.django_apps||[]).join(", ")||"no apps"," ·"," ",(y.owners||[]).join(", ")||"unowned"]},y.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(y=>d.jsx("div",{className:"muted",children:y},y))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:v.length})]}),v.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):v.map(y=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>y.node_id&&a(y.node_id),children:[d.jsx("span",{className:`chip ${y.severity}`,children:y.severity}),y.message]})},y.rule+y.message))]}),d.jsx(km,{cards:t.deepening}),(x=c==null?void 0:c.points)!=null&&x.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(y=>d.jsx("i",{className:y.level||"",title:`${y.level} · ${y.findings} findings`,style:{height:`${8+Math.min(24,(y.findings||0)*4)}px`}},y.id||y.created_at))}),Object.entries(c.contexts).map(([y,m])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y})," — last ",((_=m[m.length-1])==null?void 0:_.findings)??0," findings"]},y)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(f0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((y,m)=>m[1]-y[1]).slice(0,12).map(([y,m])=>d.jsxs("tr",{children:[d.jsx("td",{children:ro(y)}),d.jsx("td",{children:m})]},y))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function km({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:h0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}Sm(_m());a0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(zN,{})}));export{Bk as L,BN as a,FN as c,d as j,HN as l,L as r,ro as t}; diff --git a/src/loadpath/static/index.html b/src/loadpath/static/index.html index ea8be1f..83e4cda 100644 --- a/src/loadpath/static/index.html +++ b/src/loadpath/static/index.html @@ -17,7 +17,7 @@ - + diff --git a/ui/src/ImpactGraph.test.ts b/ui/src/ImpactGraph.test.ts index ba89ca6..7b18f9a 100644 --- a/ui/src/ImpactGraph.test.ts +++ b/ui/src/ImpactGraph.test.ts @@ -24,12 +24,11 @@ describe("toReactFlowElements", () => { id: "ok", source: "view", target: "ser", - type: "smoothstep", + type: "loadstep", }); expect(rfEdges[0].markerEnd).toMatchObject({ type: MarkerType.ArrowClosed }); expect(rfEdges[0].label).toBeUndefined(); - expect(rfEdges[0].pathOptions?.stepPosition).toBe(0.5); - expect(rfEdges[0].pathOptions?.borderRadius).toBe(8); + expect(rfEdges[0].data).toMatchObject({ stepPosition: 0.5 }); }); it("labels only edges incident to the selected node", () => { diff --git a/ui/src/ImpactGraph.tsx b/ui/src/ImpactGraph.tsx index d8ae8e2..3a6ebb9 100644 --- a/ui/src/ImpactGraph.tsx +++ b/ui/src/ImpactGraph.tsx @@ -1,6 +1,7 @@ import { lazy, Suspense, useEffect, useMemo, useState } from "react"; import { Background, + BaseEdge, Controls, Handle, MarkerType, @@ -8,8 +9,10 @@ import { Position, ReactFlow, ReactFlowProvider, + getSmoothStepPath, useReactFlow, type Edge, + type EdgeProps, type Node, type NodeMouseHandler, } from "@xyflow/react"; @@ -71,6 +74,58 @@ function LoadNode({ const nodeTypes = { load: LoadNode }; const ALL_FAMILIES = new Set(["django", "react", "stitch", "arch"]); +function LoadStepEdge({ + id, + sourceX, + sourceY, + targetX, + targetY, + sourcePosition, + targetPosition, + style, + markerEnd, + markerStart, + label, + labelStyle, + labelShowBg, + labelBgStyle, + labelBgPadding, + labelBgBorderRadius, + data, + interactionWidth, +}: EdgeProps>) { + const [path, labelX, labelY] = getSmoothStepPath({ + sourceX, + sourceY, + sourcePosition, + targetX, + targetY, + targetPosition, + borderRadius: 8, + stepPosition: data?.stepPosition ?? 0.5, + }); + return ( + + ); +} + +const edgeTypes = { loadstep: LoadStepEdge }; + function FitViewOnTopology({ topologyKey }: { topologyKey: string }) { const { fitView } = useReactFlow(); useEffect(() => { @@ -127,9 +182,9 @@ export function toReactFlowElements( id: e.id, source: e.src, target: e.dst, - type: "smoothstep", + type: "loadstep", animated: e.weight === "critical", - pathOptions: { borderRadius: 8, stepPosition: stepByEdge.get(e.id) ?? 0.5 }, + data: { stepPosition: stepByEdge.get(e.id) ?? 0.5 }, style: { stroke, strokeWidth: e.weight === "critical" ? 2.4 : 1.2, @@ -647,6 +702,7 @@ export function ImpactGraph({ nodes={rfNodes} edges={rfEdges} nodeTypes={nodeTypes} + edgeTypes={edgeTypes} fitView={false} minZoom={0.25} nodesDraggable={false} diff --git a/ui/src/graphEdges.test.ts b/ui/src/graphEdges.test.ts index 850101f..ea70b7b 100644 --- a/ui/src/graphEdges.test.ts +++ b/ui/src/graphEdges.test.ts @@ -1,3 +1,4 @@ +import { getSmoothStepPath, Position } from "@xyflow/react"; import { describe, expect, it } from "vitest"; import { assignEdgeStepPositions, stepForLane } from "./graphEdges"; import type { GraphEdge, GraphNode } from "./types"; @@ -45,9 +46,39 @@ describe("assignEdgeStepPositions", () => { expect(steps.size).toBe(0); }); - it("spreads lanes between 0.22 and 0.78", () => { + it("separates collinear verticals in the same gap even when their y ranges do not overlap", () => { + const nodes = [node("r1", "django.route"), node("r2", "django.route"), node("v1", "django.view"), node("v2", "django.view")]; + const pos = new Map([ + ["r1", { x: 0, y: 0 }], + ["r2", { x: 0, y: 400 }], + ["v1", { x: 296, y: 48 }], + ["v2", { x: 296, y: 448 }], + ]); + const edges = [edge("r1", "v1"), edge("r2", "v2")]; + const steps = assignEdgeStepPositions(nodes, edges, pos); + expect(steps.get("r1->v1")).toBe(0.2); + expect(steps.get("r2->v2")).toBe(0.8); + }); + + it("spreads lanes between 0.2 and 0.8", () => { expect(stepForLane(0, 1)).toBe(0.5); - expect(stepForLane(0, 2)).toBe(0.22); - expect(stepForLane(1, 2)).toBe(0.78); + expect(stepForLane(0, 2)).toBe(0.2); + expect(stepForLane(1, 2)).toBe(0.8); + }); +}); + +describe("getSmoothStepPath stepPosition", () => { + it("moves the vertical segment when stepPosition changes", () => { + const shared = { + sourceX: 208, + sourceY: 32, + targetX: 336, + targetY: 120, + sourcePosition: Position.Right, + targetPosition: Position.Left, + }; + const [left] = getSmoothStepPath({ ...shared, stepPosition: 0.2 }); + const [right] = getSmoothStepPath({ ...shared, stepPosition: 0.8 }); + expect(left).not.toBe(right); }); }); diff --git a/ui/src/graphEdges.ts b/ui/src/graphEdges.ts index 067556c..bc42ec3 100644 --- a/ui/src/graphEdges.ts +++ b/ui/src/graphEdges.ts @@ -1,18 +1,16 @@ import { GRAPH_NODE_HEIGHT, GRAPH_NODE_WIDTH, layoutNodes, type GraphEdge, type GraphNode } from "./types"; const HORIZONTAL_EPS = 12; -const Y_PAD = 6; -const STEP_LO = 0.22; -const STEP_HI = 0.78; +const STEP_LO = 0.2; +const STEP_HI = 0.8; type Span = { id: string; - y0: number; - y1: number; + sourceY: number; corridor: string; }; -/** Spread overlapping smooth-step bends so parallel verticals do not share one x. */ +/** Give each bent edge in a column gap its own vertical so parallel routes do not share one x. */ export function assignEdgeStepPositions( nodes: GraphNode[], edges: GraphEdge[], @@ -31,8 +29,7 @@ export function assignEdgeStepPositions( const targetX = dst.x; spans.push({ id: edge.id, - y0: Math.min(sourceY, targetY), - y1: Math.max(sourceY, targetY), + sourceY, corridor: `${Math.round(sourceX / 8)}>${Math.round(targetX / 8)}`, }); } @@ -46,30 +43,15 @@ export function assignEdgeStepPositions( const steps = new Map(); for (const group of groups.values()) { - const sorted = [...group].sort((a, b) => a.y0 - b.y0 || a.y1 - b.y1 || a.id.localeCompare(b.id)); - const lanes: Span[][] = []; - const laneOf = new Map(); - for (const span of sorted) { - let lane = lanes.findIndex((items) => items.every((other) => !yOverlap(span, other))); - if (lane < 0) { - lane = lanes.length; - lanes.push([]); - } - lanes[lane].push(span); - laneOf.set(span.id, lane); - } - const n = lanes.length; - for (const span of group) { - steps.set(span.id, stepForLane(laneOf.get(span.id) ?? 0, n)); - } + const sorted = [...group].sort((a, b) => a.sourceY - b.sourceY || a.id.localeCompare(b.id)); + const n = sorted.length; + sorted.forEach((span, i) => { + steps.set(span.id, stepForLane(i, n)); + }); } return steps; } -function yOverlap(a: Span, b: Span): boolean { - return a.y0 < b.y1 + Y_PAD && b.y0 < a.y1 + Y_PAD; -} - export function stepForLane(lane: number, laneCount: number): number { if (laneCount <= 1) return 0.5; return STEP_LO + ((STEP_HI - STEP_LO) * lane) / (laneCount - 1); diff --git a/ui/src/types.ts b/ui/src/types.ts index 8247b8e..4be97c5 100644 --- a/ui/src/types.ts +++ b/ui/src/types.ts @@ -511,10 +511,25 @@ export function layoutNodes( const colPitch = GRAPH_NODE_WIDTH + GRAPH_COL_GAP; const rowPitch = GRAPH_NODE_HEIGHT + GRAPH_ROW_GAP; const maxRows = Math.max(...order.map((col) => col.length), 1); + const colX: number[] = []; + let x = 0; + for (let i = 0; i < order.length; i++) { + colX.push(x); + const here = new Set((order[i] ?? []).map((n) => n.id)); + const next = new Set((order[i + 1] ?? []).map((n) => n.id)); + let between = 0; + if (next.size) { + for (const e of edges) { + if (here.has(e.src) && next.has(e.dst)) between += 1; + } + } + const extra = Math.min(96, Math.max(0, (between - 1) * 12)); + x += colPitch + extra; + } order.forEach((col, colIndex) => { const y0 = ((maxRows - col.length) * rowPitch) / 2; col.forEach((n, i) => { - pos.set(n.id, { x: colIndex * colPitch, y: y0 + i * rowPitch }); + pos.set(n.id, { x: colX[colIndex] ?? 0, y: y0 + i * rowPitch }); }); }); return pos; From 9ac2fd259ea6f9204418a26b3445be7e50320f41 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 16 Aug 2026 00:37:22 +0000 Subject: [PATCH 10/16] Assert staggered architecture edges and keep column extra-gap modest. Close the inspector before clicking InvoicePage in the review-graph e2e, and check that parallel left-to-right edges use distinct verticals. Co-authored-by: zord.lack.net --- ...CfNK3S5A.js => LayeredGraph3D-CRmek7qf.js} | 2 +- .../{index-E4JBz9vY.js => index-CuokeAZI.js} | 2 +- src/loadpath/static/index.html | 2 +- tests/e2e/test_ui_flows.py | 41 ++++++++++++++++++- ui/src/types.ts | 2 +- 5 files changed, 44 insertions(+), 5 deletions(-) rename src/loadpath/static/assets/{LayeredGraph3D-CfNK3S5A.js => LayeredGraph3D-CRmek7qf.js} (99%) rename src/loadpath/static/assets/{index-E4JBz9vY.js => index-CuokeAZI.js} (99%) diff --git a/src/loadpath/static/assets/LayeredGraph3D-CfNK3S5A.js b/src/loadpath/static/assets/LayeredGraph3D-CRmek7qf.js similarity index 99% rename from src/loadpath/static/assets/LayeredGraph3D-CfNK3S5A.js rename to src/loadpath/static/assets/LayeredGraph3D-CRmek7qf.js index 9e403b6..2b15832 100644 --- a/src/loadpath/static/assets/LayeredGraph3D-CfNK3S5A.js +++ b/src/loadpath/static/assets/LayeredGraph3D-CRmek7qf.js @@ -1,4 +1,4 @@ -import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-E4JBz9vY.js";/** +import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-CuokeAZI.js";/** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT diff --git a/src/loadpath/static/assets/index-E4JBz9vY.js b/src/loadpath/static/assets/index-CuokeAZI.js similarity index 99% rename from src/loadpath/static/assets/index-E4JBz9vY.js rename to src/loadpath/static/assets/index-CuokeAZI.js index e0c626c..9616429 100644 --- a/src/loadpath/static/assets/index-E4JBz9vY.js +++ b/src/loadpath/static/assets/index-CuokeAZI.js @@ -59,4 +59,4 @@ Error generating stack: `+g.message+` `,` +`).split(` `)),x=v.reduce((y,m)=>y.concat(...m),[]);return[v,x]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Xh,v=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const x=_=>{var b,E;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!v)&&mg(_))return!1;const j=Kh(_.code,h);if(u.current.add(_[j]),qh(c,u.current,!1)){const R=((E=(b=_.composedPath)==null?void 0:b.call(_))==null?void 0:E[0])||_.target,w=(R==null?void 0:R.nodeName)==="BUTTON"||(R==null?void 0:R.nodeName)==="A";r.preventDefault!==!1&&(a.current||!w)&&_.preventDefault(),s(!0)}},y=_=>{const k=Kh(_.code,h);qh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},m=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",x),p==null||p.addEventListener("keyup",y),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{p==null||p.removeEventListener("keydown",x),p==null||p.removeEventListener("keyup",y),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,s]),o}function qh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Kh(t,r){return r.includes(t)?"code":"key"}const P_=()=>{const t=Ye();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=Nc(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),v={x:r.x-h,y:r.y-p},x=o.snapGrid??a,y=o.snapToGrid??u;return gs(v,s,y,x)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=eo(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function Dg(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)I_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function I_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function R_(t,r){return Dg(t,r)}function T_(t,r){return Dg(t,r)}function ai(t,r){return{id:t,type:"select",selected:r}}function Gi(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(ai(u.id,c)))}return s}function Qh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Zh(t){return{id:t.id,type:"remove"}}const L_=fg();function A_(t,r,o={}){return v1(t,r,{...o,onError:o.onError??L_})}const Jh=t=>r1(t),$_=t=>lg(t);function Og(t){return L.forwardRef(t)}const Fg=typeof window<"u"?L.useLayoutEffect:L.useEffect;function ep(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>z_(()=>o(a=>a+BigInt(1))));return Fg(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function z_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Hg=L.createContext(null);function D_({children:t}){const r=Ye(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:v,hasDefaultNodes:x,onNodesChange:y,nodeLookup:m,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let j=p;for(const E of h)j=typeof E=="function"?E(j):E;let b=Qh({items:j,lookup:m});for(const E of k.values())b=E(b);x&&v(j),b.length>0?y==null||y(b):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:R,setNodes:w}=r.getState();E&&w(R)})},[]),s=ep(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:v,hasDefaultEdges:x,onEdgesChange:y,edgeLookup:m}=r.getState();let _=p;for(const k of h)_=typeof k=="function"?k(_):k;x?v(_):y&&y(Qh({items:_,lookup:m}))},[]),u=ep(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Hg.Provider,{value:c,children:t})}function O_(){const t=L.useContext(Hg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const F_=t=>!!t.panZoom;function na(){const t=P_(),r=Ye(),o=O_(),s=De(F_),a=L.useMemo(()=>{const u=y=>r.getState().nodeLookup.get(y),c=y=>{o.nodeQueue.push(y)},h=y=>{o.edgeQueue.push(y)},p=y=>{var E,R;const{nodeLookup:m,nodeOrigin:_}=r.getState(),k=Jh(y)?y:m.get(y.id),j=k.parentId?pg(k.position,k.measured,k.parentId,m,_):k.position,b={...k,position:j,width:((E=k.measured)==null?void 0:E.width)??k.width,height:((R=k.measured)==null?void 0:R.height)??k.height};return os(b)},v=(y,m,_={replace:!1})=>{c(k=>k.map(j=>{if(j.id===y){const b=typeof m=="function"?m(j):m;return _.replace&&Jh(b)?b:{...j,...b}}return j}))},x=(y,m,_={replace:!1})=>{h(k=>k.map(j=>{if(j.id===y){const b=typeof m=="function"?m(j):m;return _.replace&&$_(b)?b:{...j,...b}}return j}))};return{getNodes:()=>r.getState().nodes.map(y=>({...y})),getNode:y=>{var m;return(m=u(y))==null?void 0:m.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:y=[]}=r.getState();return y.map(m=>({...m}))},getEdge:y=>r.getState().edgeLookup.get(y),setNodes:c,setEdges:h,addNodes:y=>{const m=Array.isArray(y)?y:[y];o.nodeQueue.push(_=>[..._,...m])},addEdges:y=>{const m=Array.isArray(y)?y:[y];o.edgeQueue.push(_=>[..._,...m])},toObject:()=>{const{nodes:y=[],edges:m=[],transform:_}=r.getState(),[k,j,b]=_;return{nodes:y.map(E=>({...E})),edges:m.map(E=>({...E})),viewport:{x:k,y:j,zoom:b}}},deleteElements:async({nodes:y=[],edges:m=[]})=>{const{nodes:_,edges:k,onNodesDelete:j,onEdgesDelete:b,triggerNodeChanges:E,triggerEdgeChanges:R,onDelete:w,onBeforeDelete:N}=r.getState(),{nodes:A,edges:$}=await a1({nodesToRemove:y,edgesToRemove:m,nodes:_,edges:k,onBeforeDelete:N}),F=$.length>0,G=A.length>0;if(F){const q=$.map(Zh);b==null||b($),R(q)}if(G){const q=A.map(Zh);j==null||j(A),E(q)}return(G||F)&&(w==null||w({nodes:A,edges:$})),{deletedNodes:A,deletedEdges:$}},getIntersectingNodes:(y,m=!0,_)=>{const k=Nh(y),j=k?y:p(y),b=_!==void 0;return j?(_||r.getState().nodes).filter(E=>{const R=r.getState().nodeLookup.get(E.id);if(R&&!k&&(E.id===y.id||!R.internals.positionAbsolute))return!1;const w=os(b?E:R),N=Hl(w,j);return m&&N>0||N>=w.width*w.height||N>=j.width*j.height}):[]},isNodeIntersecting:(y,m,_=!0)=>{const j=Nh(y)?y:p(y);if(!j)return!1;const b=Hl(j,m);return _&&b>0||b>=m.width*m.height||b>=j.width*j.height},updateNode:v,updateNodeData:(y,m,_={replace:!1})=>{v(y,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},updateEdge:x,updateEdgeData:(y,m,_={replace:!1})=>{x(y,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},getNodesBounds:y=>{const{nodeLookup:m,nodeOrigin:_}=r.getState();return i1(y,{nodeLookup:m,nodeOrigin:_})},getHandleConnections:({type:y,id:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${y}${m?`-${m}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:y,handleId:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${y?m?`-${y}-${m}`:`-${y}`:""}`))==null?void 0:k.values())??[])},fitView:async y=>{const m=r.getState().fitViewResolver??d1();return r.setState({fitViewQueued:!0,fitViewOptions:y,fitViewResolver:m}),o.nodeQueue.push(_=>[..._]),m.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const tp=t=>t.selected,H_=typeof window<"u"?window:void 0;function B_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ye(),{deleteElements:s}=na(),a=ls(t,{actInsideInputWithModifier:!1}),u=ls(r,{target:H_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(tp),edges:c.filter(tp)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function V_(t){const r=Ye();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=jc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",mn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const ra={position:"absolute",width:"100%",height:"100%",top:0,left:0},W_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function U_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=di.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:v,translateExtent:x,minZoom:y,maxZoom:m,zoomActivationKeyCode:_,preventScrolling:k=!0,children:j,noWheelClassName:b,noPanClassName:E,onViewportChange:R,isControlledViewport:w,paneClickDistance:N,selectionOnDrag:A}){const $=Ye(),F=L.useRef(null),{userSelectionActive:G,lib:q,connectionInProgress:te}=De(W_,Qe),ee=ls(_),ne=L.useRef();V_(F);const K=L.useCallback(C=>{R==null||R({x:C[0],y:C[1],zoom:C[2]}),w||$.setState({transform:C})},[R,w]);return L.useEffect(()=>{if(F.current){ne.current=X1({domNode:F.current,minZoom:y,maxZoom:m,translateExtent:x,viewport:v,onDraggingChange:U=>$.setState(M=>M.paneDragging===U?M:{paneDragging:U}),onPanZoomStart:(U,M)=>{const{onViewportChangeStart:D,onMoveStart:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoom:(U,M)=>{const{onViewportChange:D,onMove:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoomEnd:(U,M)=>{const{onViewportChangeEnd:D,onMoveEnd:H}=$.getState();H==null||H(U,M),D==null||D(M)}});const{x:C,y:V,zoom:W}=ne.current.getViewport();return $.setState({panZoom:ne.current,transform:[C,V,W],domNode:F.current.closest(".react-flow")}),()=>{var U;(U=ne.current)==null||U.destroy()}}},[]),L.useEffect(()=>{var C;(C=ne.current)==null||C.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:ee,preventScrolling:k,noPanClassName:E,userSelectionActive:G,noWheelClassName:b,lib:q,onTransformChange:K,connectionInProgress:te,selectionOnDrag:A,paneClickDistance:N})},[t,r,o,s,a,u,c,h,p,ee,k,E,G,b,q,K,te,A,N]),d.jsx("div",{className:"react-flow__renderer",ref:F,style:ra,children:j})}const Y_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function G_(){const{userSelectionActive:t,userSelectionRect:r}=De(Y_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const qu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},X_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function q_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=rs.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:v,onPaneContextMenu:x,onPaneScroll:y,onPaneMouseEnter:m,onPaneMouseMove:_,onPaneMouseLeave:k,children:j}){const b=L.useRef(0),E=Ye(),{userSelectionActive:R,elementsSelectable:w,dragging:N,panBy:A,autoPanSpeed:$}=De(X_,Qe),F=w&&(t||R),G=L.useRef(null),q=L.useRef(),te=L.useRef(new Set),ee=L.useRef(new Set),ne=L.useRef(!1),K=L.useRef(!1),C=L.useRef({x:0,y:0}),V=L.useRef(!1),W=Z=>{if(K.current||ne.current||E.getState().connection.inProgress){K.current=!1,ne.current=!1;return}v==null||v(Z),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},U=Z=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Z.preventDefault();return}x==null||x(Z)},M=y?Z=>y(Z):void 0,D=Z=>{K.current&&(Z.stopPropagation(),K.current=!1)},H=Z=>{var $e,st;if(Z.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:se,transform:me}=E.getState();if(q.current=se==null?void 0:se.getBoundingClientRect(),!q.current)return;const ke=Z.target===G.current;if(!ke&&!!Z.target.closest(".nokey")||!t||!(c&&ke||r)||Z.button!==0||!Z.isPrimary)return;(st=($e=Z.target)==null?void 0:$e.setPointerCapture)==null||st.call($e,Z.pointerId),K.current=!1;const{x:Ne,y:Me}=gn(Z.nativeEvent,q.current),Te=gs({x:Ne,y:Me},me);E.setState({userSelectionRect:{width:0,height:0,startX:Te.x,startY:Te.y,x:Ne,y:Me}}),ke||(Z.stopPropagation(),Z.preventDefault())};function I(Z,se){const{userSelectionRect:me}=E.getState();if(!me)return;const{transform:ke,nodeLookup:ve,edgeLookup:re,connectionLookup:Ne,triggerNodeChanges:Me,triggerEdgeChanges:Te,defaultEdgeOptions:$e}=E.getState(),st={x:me.startX,y:me.startY},{x:lt,y:at}=eo(st,ke),Ge={startX:st.x,startY:st.y,x:Zmt.id)),ee.current=new Set;const gt=($e==null?void 0:$e.selectable)??!0;for(const mt of te.current){const Pt=Ne.get(mt);if(Pt)for(const{edgeId:ut}of Pt.values()){const Je=re.get(ut);Je&&(Je.selectable??gt)&&ee.current.add(ut)}}if(!jh(wt,te.current)){const mt=Gi(ve,te.current,!0);Me(mt)}if(!jh(qt,ee.current)){const mt=Gi(re,ee.current);Te(mt)}E.setState({userSelectionRect:Ge,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!a||!q.current)return;const[Z,se]=kc(C.current,q.current,$);A({x:Z,y:se}).then(me=>{if(!K.current||!me){b.current=requestAnimationFrame(z);return}const{x:ke,y:ve}=C.current;I(ke,ve),b.current=requestAnimationFrame(z)})}const ie=()=>{cancelAnimationFrame(b.current),b.current=0,V.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=Z=>{const{userSelectionRect:se,transform:me,resetSelectedElements:ke}=E.getState();if(!q.current||!se)return;const{x:ve,y:re}=gn(Z.nativeEvent,q.current);C.current={x:ve,y:re};const Ne=eo({x:se.startX,y:se.startY},me);if(!K.current){const Me=r?0:u;if(Math.hypot(ve-Ne.x,re-Ne.y)<=Me)return;ke(),h==null||h(Z)}K.current=!0,V.current||(z(),V.current=!0),I(ve,re)},fe=Z=>{var se,me;if(!F){Z.target===G.current&&E.getState().connection.inProgress&&(ne.current=!0);return}Z.button===0&&((me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),!R&&Z.target===G.current&&E.getState().userSelectionRect&&(W==null||W(Z)),E.setState({userSelectionActive:!1,userSelectionRect:null}),K.current&&(p==null||p(Z),E.setState({nodesSelectionActive:te.current.size>0})),ie())},he=Z=>{var se,me;(me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),ie()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:nt(["react-flow__pane",{draggable:pe,dragging:N,selection:t}]),onClick:F?void 0:qu(W,G),onContextMenu:qu(U,G),onWheel:qu(M,G),onPointerEnter:F?void 0:m,onPointerMove:F?oe:_,onPointerUp:fe,onPointerCancel:F?he:void 0,onPointerDownCapture:F?H:void 0,onClickCapture:F?D:void 0,onPointerLeave:k,ref:G,style:ra,children:[j,d.jsx(G_,{})]})}function hc({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),v=h.get(t);if(!v){p==null||p("012",mn.error012(t));return}r.setState({nodesSelectionActive:!1}),v.selected?(o||v.selected&&c)&&(u({nodes:[v],edges:[]}),requestAnimationFrame(()=>{var x;return(x=s==null?void 0:s.current)==null?void 0:x.blur()})):a([t])}function Bg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ye(),[p,v]=L.useState(!1),x=L.useRef();return L.useEffect(()=>{if(!r)return x.current=L1({getStoreItems:()=>h.getState(),onNodeMouseDown:y=>{hc({id:y,store:h,nodeRef:t})},onDragStart:()=>{v(!0)},onDragStop:()=>{v(!1)}}),()=>{var y;(y=x.current)==null||y.destroy(),x.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!x.current||x.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const K_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Vg(){const t=Ye();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:v,nodeOrigin:x}=t.getState(),y=new Map,m=K_(c),_=a?u[0]:5,k=a?u[1]:5,j=o.direction.x*_*o.factor,b=o.direction.y*k*o.factor;for(const[,E]of v){if(!m(E))continue;let R={x:E.internals.positionAbsolute.x+j,y:E.internals.positionAbsolute.y+b};a&&(R=ps(R,u));const{position:w,positionAbsolute:N}=ag({nodeId:E.id,nextPosition:R,nodeLookup:v,nodeExtent:s,nodeOrigin:x,onError:h});E.position=w,E.internals.positionAbsolute=N,y.set(E.id,E)}p(y)},[])}const Ic=L.createContext(null),Q_=Ic.Provider;Ic.Consumer;const Wg=()=>L.useContext(Ic),Z_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Ug=L.createContext(null);function J_({children:t}){const r=De(Z_,Qe);return d.jsx(Ug.Provider,{value:r,children:t})}function eS(){const t=L.useContext(Ug);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const tS={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},nS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:v}=c;if(!h&&!a)return tS;const x=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:x,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Zi.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:x&&v}};function rS({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:v,onMouseDown:x,onTouchStart:y,...m},_){var V,W;const k=c||null,j=t==="target",b=Ye(),E=Wg(),{connectOnClick:R,noPanClassName:w,rfId:N}=eS(),{connectingFrom:A,connectingTo:$,clickConnecting:F,isPossibleEndHandle:G,connectionInProcess:q,clickConnectionInProcess:te,valid:ee}=De(nS(E,k,t),Qe);E||(W=(V=b.getState()).onError)==null||W.call(V,"010",mn.error010());const ne=U=>{const{defaultEdgeOptions:M,onConnect:D,hasDefaultEdges:H}=b.getState(),I={...M,...U};if(H){const{edges:z,setEdges:ie,onError:oe}=b.getState();ie(A_(I,z,{onError:oe}))}D==null||D(I),h==null||h(I)},K=U=>{if(!E)return;const M=yg(U.nativeEvent);if(a&&(M&&U.button===0||!M)){const D=b.getState();fc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:j,handleId:k,nodeId:E,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...H)=>{var I,z;return(z=(I=b.getState()).onConnectEnd)==null?void 0:z.call(I,...H)},updateConnection:D.updateConnection,onConnect:ne,isValidConnection:o||((...H)=>{var I,z;return((z=(I=b.getState()).isValidConnection)==null?void 0:z.call(I,...H))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}M?x==null||x(U):y==null||y(U)},C=U=>{const{onClickConnectStart:M,onClickConnectEnd:D,connectionClickStartHandle:H,connectionMode:I,isValidConnection:z,lib:ie,rfId:oe,nodeLookup:fe,connection:he}=b.getState();if(!E||!H&&!a)return;if(!H){M==null||M(U.nativeEvent,{nodeId:E,handleId:k,handleType:t}),b.setState({connectionClickStartHandle:{nodeId:E,type:t,id:k}});return}const pe=gg(U.target),Z=o||z,{connection:se,isValid:me}=fc.isValid(U.nativeEvent,{handle:{nodeId:E,id:k,type:t},connectionMode:I,fromNodeId:H.nodeId,fromHandleId:H.id||null,fromType:H.type,isValidConnection:Z,flowId:oe,doc:pe,lib:ie,nodeLookup:fe});me&&se&&ne(se);const ke=structuredClone(he);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,D==null||D(U,ke),b.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":k,"data-nodeid":E,"data-handlepos":r,"data-id":`${N}-${E}-${k}-${t}`,className:nt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",w,v,{source:!j,target:j,connectable:s,connectablestart:a,connectableend:u,clickconnecting:F,connectingfrom:A,connectingto:$,valid:ee,connectionindicator:s&&(!q||G)&&(q||te?u:a)}]),onMouseDown:K,onTouchStart:K,onClick:R?C:void 0,ref:_,...m,children:p})}const no=L.memo(Og(rS));function iS({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(no,{type:"source",position:o,isConnectable:r})]})}function oS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:s=Se.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(no,{type:"source",position:s,isConnectable:r})]})}function sS(){return null}function lS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const Vl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},np={input:iS,default:oS,output:lS,group:sS};function aS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const uS=t=>{const{width:r,height:o,x:s,y:a}=hs(t.nodeLookup,{filter:u=>!!u.selected});return{width:pn(r)?r:null,height:pn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function cS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ye(),{width:a,height:u,transformString:c,userSelectionActive:h}=De(uS,Qe),p=Vg(),v=L.useRef(null);L.useEffect(()=>{var _;o||(_=v.current)==null||_.focus({preventScroll:!0})},[o]);const x=!h&&a!==null&&u!==null;if(Bg({nodeRef:v,disabled:!x}),!x)return null;const y=t?_=>{const k=s.getState().nodes.filter(j=>j.selected);t(_,k)}:void 0,m=_=>{Object.prototype.hasOwnProperty.call(Vl,_.key)&&(_.preventDefault(),p({direction:Vl[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:nt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:v,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:o?void 0:-1,onKeyDown:o?void 0:m,style:{width:a,height:u}})})}const rp=typeof window<"u"?window:void 0,dS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Yg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:v,selectionOnDrag:x,selectionMode:y,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:j,zoomActivationKeyCode:b,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:N,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:G,autoPanOnSelection:q,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,preventScrolling:C,onSelectionContextMenu:V,noWheelClassName:W,noPanClassName:U,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:H}){const{nodesSelectionActive:I,userSelectionActive:z}=De(dS,Qe),ie=ls(v,{target:rp}),oe=ls(j,{target:rp}),fe=oe||G,he=oe||N,pe=x&&fe!==!0,Z=ie||z||pe;return B_({deleteKeyCode:p,multiSelectionKeyCode:k}),d.jsx(U_,{onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:!ie&&fe,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,zoomActivationKeyCode:b,preventScrolling:C,noWheelClassName:W,noPanClassName:U,onViewportChange:D,isControlledViewport:H,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(q_,{onSelectionStart:m,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:q,isSelecting:!!Z,selectionMode:y,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:pe,children:[t,I&&d.jsx(cS,{onSelectionContextMenu:V,noPanClassName:U,disableKeyboardA11y:M})]})})}Yg.displayName="FlowRenderer";const fS=L.memo(Yg),hS=t=>r=>t?Sc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function pS(t){return De(L.useCallback(hS(t),[t]),Qe)}const gS=t=>t.updateNodeInternals;function mS(){const t=De(gS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function yS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ye(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),v=L.useRef(r),x=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!x||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[x,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const y=v.current!==r,m=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(y||m||_)&&(v.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function vS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:v,nodesFocusable:x,resizeObserver:y,noDragClassName:m,noPanClassName:_,disableKeyboardA11y:k,rfId:j,nodeTypes:b,nodeClickDistance:E,onError:R}){const{node:w,internals:N,isParent:A}=De(Z=>{const se=Z.nodeLookup.get(t),me=Z.parentLookup.has(t);return{node:se,internals:se.internals,isParent:me}},Qe);let $=w.type||"default",F=(b==null?void 0:b[$])||np[$];F===void 0&&(R==null||R("003",mn.error003($)),$="default",F=(b==null?void 0:b.default)||np.default);const G=!!(w.draggable||h&&typeof w.draggable>"u"),q=!!(w.selectable||p&&typeof w.selectable>"u"),te=!!(w.connectable||v&&typeof w.connectable>"u"),ee=!!(w.focusable||x&&typeof w.focusable>"u"),ne=Ye(),K=hg(w),C=yS({node:w,nodeType:$,hasDimensions:K,resizeObserver:y}),V=Bg({nodeRef:C,disabled:w.hidden||!G,noDragClassName:m,handleSelector:w.dragHandle,nodeId:t,isSelectable:q,nodeClickDistance:E}),W=Vg();if(w.hidden)return null;const U=vn(w),M=aS(w),D=q||G||r||o||s||a,H=o?Z=>o(Z,{...N.userNode}):void 0,I=s?Z=>s(Z,{...N.userNode}):void 0,z=a?Z=>a(Z,{...N.userNode}):void 0,ie=u?Z=>u(Z,{...N.userNode}):void 0,oe=c?Z=>c(Z,{...N.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:se,nodeDragThreshold:me}=ne.getState();q&&(!se||!G||me>0)&&hc({id:t,store:ne,nodeRef:C}),r&&r(Z,{...N.userNode})},he=Z=>{if(!(mg(Z.nativeEvent)||k)){if(rg.includes(Z.key)&&q){const se=Z.key==="Escape";hc({id:t,store:ne,unselect:se,nodeRef:C})}else if(G&&w.selected&&Object.prototype.hasOwnProperty.call(Vl,Z.key)){Z.preventDefault();const{ariaLabelConfig:se}=ne.getState();ne.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),W({direction:Vl[Z.key],factor:Z.shiftKey?4:1})}}},pe=()=>{var Ne;if(k||!((Ne=C.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:Z,width:se,height:me,autoPanOnNodeFocus:ke,setCenter:ve}=ne.getState();if(!ke)return;Sc(new Map([[t,w]]),{x:0,y:0,width:se,height:me},Z,!0).length>0||ve(w.position.x+U.width/2,w.position.y+U.height/2,{zoom:Z[2]})};return d.jsx("div",{className:nt(["react-flow__node",`react-flow__node-${$}`,{[_]:G},w.className,{selected:w.selected,selectable:q,parent:A,draggable:G,dragging:V}]),ref:C,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:K?"visible":"hidden",...w.style,...M},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:H,onMouseMove:I,onMouseLeave:z,onContextMenu:ie,onClick:fe,onDoubleClick:oe,onKeyDown:ee?he:void 0,tabIndex:ee?0:void 0,onFocus:ee?pe:void 0,role:w.ariaRole??(ee?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${Ag}-${j}`,"aria-label":w.ariaLabel,...w.domAttributes,children:d.jsx(Q_,{value:t,children:d.jsx(F,{id:t,data:w.data,type:$,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:w.selected??!1,selectable:q,draggable:G,deletable:w.deletable??!0,isConnectable:te,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:V,dragHandle:w.dragHandle,zIndex:N.z,parentId:w.parentId,...U})})})}var xS=L.memo(vS);const wS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Gg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=De(wS,Qe),u=pS(t.onlyRenderVisibleElements),c=mS();return d.jsx("div",{className:"react-flow__nodes",style:ra,children:u.map(h=>d.jsx(xS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Gg.displayName="NodeRenderer";const _S=L.memo(Gg);function SS(t){return De(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&g1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const kS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},NS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ip={[is.Arrow]:kS,[is.ArrowClosed]:NS};function jS(t){const r=Ye();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(ip,t)?ip[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",mn.error009(t)),null)},[t])}const bS=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=jS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},Xg=({defaultColor:t,rfId:r})=>{const o=De(u=>u.edges),s=De(u=>u.defaultEdgeOptions),a=L.useMemo(()=>k1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(bS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Xg.displayName="MarkerDefinitions";var ES=L.memo(Xg);function qg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:v,...x}){const[y,m]=L.useState({x:1,y:0,width:0,height:0}),_=nt(["react-flow__edge-textwrapper",v]),k=L.useRef(null);return L.useEffect(()=>{if(k.current){const j=k.current.getBBox();m({x:j.x,y:j.y,width:j.width,height:j.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-y.width/2} ${r-y.height/2})`,className:_,visibility:y.width?"visible":"hidden",...x,children:[a&&d.jsx("rect",{width:y.width+2*c[0],x:-c[0],y:-c[1],height:y.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:k,style:s,children:o}),p]}):null}qg.displayName="EdgeText";const CS=L.memo(qg);function ms({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:v=20,...x}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...x,d:t,fill:"none",className:nt(["react-flow__edge-path",x.className])}),v?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:v,className:"react-flow__edge-interaction"}):null,s&&pn(r)&&pn(o)?d.jsx(CS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function op({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function Kg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top}){const[c,h]=op({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,v]=op({pos:u,x1:s,y1:a,x2:t,y2:r}),[x,y,m,_]=vg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:v});return[`M${t},${r} C${c},${h} ${p},${v} ${s},${a}`,x,y,m,_]}function Qg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})=>{const[R,w,N]=Kg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),A=t.isInternal?void 0:r;return d.jsx(ms,{id:A,path:R,labelX:w,labelY:N,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})})}const MS=Qg({isInternal:!1}),Zg=Qg({isInternal:!0});MS.displayName="SimpleBezierEdge";Zg.displayName="SimpleBezierEdgeInternal";function Jg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,sourcePosition:_=Se.Bottom,targetPosition:k=Se.Top,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=Bl({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),$=t.isInternal?void 0:r;return d.jsx(ms,{id:$,path:w,labelX:N,labelY:A,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:j,markerStart:b,interactionWidth:R})})}const em=Jg({isInternal:!1}),tm=Jg({isInternal:!0});em.displayName="SmoothStepEdge";tm.displayName="SmoothStepEdgeInternal";function nm(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(em,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const PS=nm({isInternal:!1}),rm=nm({isInternal:!0});PS.displayName="StepEdge";rm.displayName="StepEdgeInternal";function im(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:j})=>{const[b,E,R]=_g({sourceX:o,sourceY:s,targetX:a,targetY:u}),w=t.isInternal?void 0:r;return d.jsx(ms,{id:w,path:b,labelX:E,labelY:R,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:j})})}const IS=im({isInternal:!1}),om=im({isInternal:!0});IS.displayName="StraightEdge";om.displayName="StraightEdgeInternal";function sm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=xg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:E==null?void 0:E.curvature}),$=t.isInternal?void 0:r;return d.jsx(ms,{id:$,path:w,labelX:N,labelY:A,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:R})})}const RS=sm({isInternal:!1}),lm=sm({isInternal:!0});RS.displayName="BezierEdge";lm.displayName="BezierEdgeInternal";const sp={default:lm,straight:om,step:rm,smoothstep:tm,simplebezier:Zg},lp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},TS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,LS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,ap="react-flow__edgeupdater";function up({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:nt([ap,`${ap}-${h}`]),cx:TS(r,s,t),cy:LS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function AS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:v,onReconnectStart:x,onReconnectEnd:y,setReconnecting:m,setUpdateHover:_}){const k=Ye(),j=(N,A)=>{if(N.button!==0)return;const{autoPanOnConnect:$,domNode:F,connectionMode:G,connectionRadius:q,lib:te,onConnectStart:ee,cancelConnection:ne,nodeLookup:K,rfId:C,panBy:V,updateConnection:W}=k.getState(),U=A.type==="target",M=(I,z)=>{m(!1),y==null||y(I,o,A.type,z)},D=I=>v==null?void 0:v(o,I),H=(I,z)=>{m(!0),x==null||x(N,o,A.type),ee==null||ee(I,z)};fc.onPointerDown(N.nativeEvent,{autoPanOnConnect:$,connectionMode:G,connectionRadius:q,domNode:F,handleId:A.id,nodeId:A.nodeId,nodeLookup:K,isTarget:U,edgeUpdaterType:A.type,lib:te,flowId:C,cancelConnection:ne,panBy:V,isValidConnection:(...I)=>{var z,ie;return((ie=(z=k.getState()).isValidConnection)==null?void 0:ie.call(z,...I))??!0},onConnect:D,onConnectStart:H,onConnectEnd:(...I)=>{var z,ie;return(ie=(z=k.getState()).onConnectEnd)==null?void 0:ie.call(z,...I)},onReconnectEnd:M,updateConnection:W,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:N.currentTarget})},b=N=>j(N,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),E=N=>j(N,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),R=()=>_(!0),w=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(up,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:b,onMouseEnter:R,onMouseOut:w,type:"source"}),(t===!0||t==="target")&&d.jsx(up,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:E,onMouseEnter:R,onMouseOut:w,type:"target"})]})}function $S({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,rfId:k,edgeTypes:j,noPanClassName:b,onError:E,disableKeyboardA11y:R}){let w=De(ve=>ve.edgeLookup.get(t));const N=De(ve=>ve.defaultEdgeOptions);w=N?{...N,...w}:w;let A=w.type||"default",$=(j==null?void 0:j[A])||sp[A];$===void 0&&(E==null||E("011",mn.error011(A)),A="default",$=(j==null?void 0:j.default)||sp.default);const F=!!(w.focusable||r&&typeof w.focusable>"u"),G=typeof y<"u"&&(w.reconnectable||o&&typeof w.reconnectable>"u"),q=!!(w.selectable||s&&typeof w.selectable>"u"),te=L.useRef(null),[ee,ne]=L.useState(!1),[K,C]=L.useState(!1),V=Ye(),{zIndex:W=w.zIndex,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z}=De(L.useCallback(ve=>{const re=ve.nodeLookup.get(w.source),Ne=ve.nodeLookup.get(w.target);if(!re||!Ne)return lp;const Me=S1({id:t,sourceNode:re,targetNode:Ne,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:ve.connectionMode,onError:E}),Te=p1({selected:w.selected,zIndex:w.zIndex,sourceNode:re,targetNode:Ne,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||lp,zIndex:Te}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex,E]),Qe),ie=L.useMemo(()=>w.markerStart?`url('#${cc(w.markerStart,k)}')`:void 0,[w.markerStart,k]),oe=L.useMemo(()=>w.markerEnd?`url('#${cc(w.markerEnd,k)}')`:void 0,[w.markerEnd,k]);if(w.hidden||U===null||M===null||D===null||H===null)return null;const fe=ve=>{var Te;const{addSelectedEdges:re,unselectNodesAndEdges:Ne,multiSelectionActive:Me}=V.getState();q&&(V.setState({nodesSelectionActive:!1}),w.selected&&Me?(Ne({nodes:[],edges:[w]}),(Te=te.current)==null||Te.blur()):re([t])),a&&a(ve,w)},he=u?ve=>{u(ve,{...w})}:void 0,pe=c?ve=>{c(ve,{...w})}:void 0,Z=h?ve=>{h(ve,{...w})}:void 0,se=p?ve=>{p(ve,{...w})}:void 0,me=v?ve=>{v(ve,{...w})}:void 0,ke=ve=>{var re;if(!R&&rg.includes(ve.key)&&q){const{unselectNodesAndEdges:Ne,addSelectedEdges:Me}=V.getState();ve.key==="Escape"?((re=te.current)==null||re.blur(),Ne({edges:[w]})):Me([t])}};return d.jsx("svg",{style:{zIndex:W},children:d.jsxs("g",{className:nt(["react-flow__edge",`react-flow__edge-${A}`,w.className,b,{selected:w.selected,animated:w.animated,inactive:!q&&!a,updating:ee,selectable:q}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:Z,onMouseMove:se,onMouseLeave:me,onKeyDown:F?ke:void 0,tabIndex:F?0:void 0,role:w.ariaRole??(F?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":F?`${$g}-${k}`:void 0,ref:te,...w.domAttributes,children:[!K&&d.jsx($,{id:t,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:q,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),G&&d.jsx(AS,{edge:w,isReconnectable:G,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,setUpdateHover:ne,setReconnecting:C})]})})}var zS=L.memo($S);const DS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function am({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:v,onEdgeClick:x,reconnectRadius:y,onEdgeDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:j}){const{edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,onError:w}=De(DS,Qe),N=SS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(ES,{defaultColor:t,rfId:o}),N.map(A=>d.jsx(zS,{id:A,edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,onClick:x,reconnectRadius:y,onDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:w,edgeTypes:s,disableKeyboardA11y:j},A))]})}am.displayName="EdgeRenderer";const OS=L.memo(am),cp=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function FS({children:t}){const r=Ye(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return Fg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=cp(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:cp(s)},children:t})}function HS(t){const r=na(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const BS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function VS(t){const r=De(BS),o=Ye();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function WS(t){return t.connection.inProgress?{...t.connection,to:gs(t.connection.to,t.transform)}:{...t.connection}}function US(t){return WS}function YS(t){const r=US();return De(r,Qe)}const GS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function XS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=De(GS,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:nt(["react-flow__connection",sg(h)]),children:d.jsx(um,{style:r,type:o,CustomComponent:s,isValid:h})})})}const um=({style:t,type:r=Lr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:v,toNode:x,toHandle:y,toPosition:m,pointer:_}=YS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:v.x,toY:v.y,fromPosition:p,toPosition:m,connectionStatus:sg(s),toNode:x,toHandle:y,pointer:_});let k="";const j={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:v.x,targetY:v.y,targetPosition:m};switch(r){case Lr.Bezier:[k]=xg(j);break;case Lr.SimpleBezier:[k]=Kg(j);break;case Lr.Step:[k]=Bl({...j,borderRadius:0});break;case Lr.SmoothStep:[k]=Bl(j);break;default:[k]=_g(j)}return d.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};um.displayName="ConnectionLine";const qS={};function dp(t=qS){L.useRef(t),Ye(),L.useEffect(()=>{},[t])}function KS(){Ye(),L.useRef(!1),L.useEffect(()=>{},[])}function cm({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,onSelectionContextMenu:y,onSelectionStart:m,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:j,connectionLineComponent:b,connectionLineContainerStyle:E,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,deleteKeyCode:G,onlyRenderVisibleElements:q,elementsSelectable:te,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,preventScrolling:V,defaultMarkerColor:W,zoomOnScroll:U,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,zoomOnDoubleClick:z,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneScroll:se,onPaneContextMenu:me,paneClickDistance:ke,nodeClickDistance:ve,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,viewport:ut,onViewportChange:Je,nodesDraggable:An}){return dp(t),dp(r),KS(),HS(o),VS(ut),d.jsx(fS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneContextMenu:me,onPaneScroll:se,paneClickDistance:ke,deleteKeyCode:G,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,elementsSelectable:te,zoomOnScroll:U,zoomOnPinch:M,zoomOnDoubleClick:z,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,onSelectionContextMenu:y,preventScrolling:V,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,onViewportChange:Je,isControlledViewport:!!ut,children:d.jsxs(FS,{children:[d.jsx(OS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,onlyRenderVisibleElements:q,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,defaultMarkerColor:W,noPanClassName:qt,disableKeyboardA11y:gt,rfId:Pt}),d.jsx(XS,{style:j,type:k,component:b,containerStyle:E}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(_S,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,nodeClickDistance:ve,onlyRenderVisibleElements:q,noPanClassName:qt,noDragClassName:Ge,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,nodesDraggable:An}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}cm.displayName="GraphView";const QS=L.memo(cm),ZS=fg(),fp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:v=2,nodeOrigin:x,nodeExtent:y,zIndexMode:m="basic"}={})=>{const _=new Map,k=new Map,j=new Map,b=new Map,E=s??r??[],R=o??t??[],w=x??[0,0],N=y??ns;Ng(j,b,E);const{nodesInitialized:A}=dc(R,_,k,{nodeOrigin:w,nodeExtent:N,zIndexMode:m});let $=[0,0,1];if(c&&a&&u){const F=hs(_,{filter:ee=>!!((ee.width||ee.initialWidth)&&(ee.height||ee.initialHeight))}),{x:G,y:q,zoom:te}=Nc(F,a,u,p,v,(h==null?void 0:h.padding)??.1);$=[G,q,te]}return{rfId:"1",width:a??0,height:u??0,transform:$,nodes:R,nodesInitialized:A,nodeLookup:_,parentLookup:k,edges:E,edgeLookup:b,connectionLookup:j,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:v,translateExtent:ns,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Zi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...og},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:ZS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:ig,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},JS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m})=>d_((_,k)=>{async function j(){const{nodeLookup:b,panZoom:E,fitViewOptions:R,fitViewResolver:w,width:N,height:A,minZoom:$,maxZoom:F}=k();E&&(await l1({nodes:b,width:N,height:A,panZoom:E,minZoom:$,maxZoom:F},R),w==null||w.resolve(!0),_({fitViewResolver:null}))}return{...fp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,defaultNodes:o,defaultEdges:s,zIndexMode:m}),setNodes:b=>{const{nodeLookup:E,parentLookup:R,nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,fitViewQueued:$,zIndexMode:F,nodesSelectionActive:G}=k(),{nodesInitialized:q,hasSelectedNodes:te}=dc(b,E,R,{nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:F}),ee=G&&te;$&&q?(j(),_({nodes:b,nodesInitialized:q,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:ee})):_({nodes:b,nodesInitialized:q,nodesSelectionActive:ee})},setEdges:b=>{const{connectionLookup:E,edgeLookup:R}=k();Ng(E,R,b),_({edges:b})},setDefaultNodesAndEdges:(b,E)=>{if(b){const{setNodes:R}=k();R(b),_({hasDefaultNodes:!0})}if(E){const{setEdges:R}=k();R(E),_({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:E,nodeLookup:R,parentLookup:w,domNode:N,nodeOrigin:A,nodeExtent:$,debug:F,fitViewQueued:G,zIndexMode:q}=k(),{changes:te,updatedInternals:ee}=P1(b,R,w,N,A,$,q);ee&&(b1(R,w,{nodeOrigin:A,nodeExtent:$,zIndexMode:q}),G?(j(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(te==null?void 0:te.length)>0&&(F&&console.log("React Flow: trigger node changes",te),E==null||E(te)))},updateNodePositions:(b,E=!1)=>{const R=[];let w=[];const{nodeLookup:N,triggerNodeChanges:A,connection:$,updateConnection:F,onNodesChangeMiddlewareMap:G}=k();for(const[q,te]of b){const ee=N.get(q),ne=!!(ee!=null&&ee.expandParent&&(ee!=null&&ee.parentId)&&(te!=null&&te.position)),K={id:q,type:"position",position:ne?{x:Math.max(0,te.position.x),y:Math.max(0,te.position.y)}:te.position,dragging:E};if(ee&&$.inProgress&&$.fromNode.id===ee.id){const C=mi(ee,$.fromHandle,Se.Left,!0);F({...$,from:C})}ne&&ee.parentId&&R.push({id:q,parentId:ee.parentId,rect:{...te.internals.positionAbsolute,width:te.measured.width??0,height:te.measured.height??0}}),w.push(K)}if(R.length>0){const{parentLookup:q,nodeOrigin:te}=k(),ee=Pc(R,N,q,te);w.push(...ee)}for(const q of G.values())w=q(w);A(w)},triggerNodeChanges:b=>{const{onNodesChange:E,setNodes:R,nodes:w,hasDefaultNodes:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=R_(b,w);R($)}A&&console.log("React Flow: trigger node changes",b),E==null||E(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:E,setEdges:R,edges:w,hasDefaultEdges:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=T_(b,w);R($)}A&&console.log("React Flow: trigger edge changes",b),E==null||E(b)}},addSelectedNodes:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));N($);return}N(Gi(w,new Set([...b]),!0)),A(Gi(R))},addSelectedEdges:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));A($);return}A(Gi(R,new Set([...b]))),N(Gi(w,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:E}={})=>{const{edges:R,nodes:w,nodeLookup:N,triggerNodeChanges:A,triggerEdgeChanges:$}=k(),F=b||w,G=E||R,q=[];for(const ee of F){if(!ee.selected)continue;const ne=N.get(ee.id);ne&&(ne.selected=!1),q.push(ai(ee.id,!1))}const te=[];for(const ee of G)ee.selected&&te.push(ai(ee.id,!1));A(q),$(te)},setMinZoom:b=>{const{panZoom:E,maxZoom:R}=k();E==null||E.setScaleExtent([b,R]),_({minZoom:b})},setMaxZoom:b=>{const{panZoom:E,minZoom:R}=k();E==null||E.setScaleExtent([R,b]),_({maxZoom:b})},setTranslateExtent:b=>{var E;(E=k().panZoom)==null||E.setTranslateExtent(b),_({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:E,triggerNodeChanges:R,triggerEdgeChanges:w,elementsSelectable:N}=k();if(!N)return;const A=E.reduce((F,G)=>G.selected?[...F,ai(G.id,!1)]:F,[]),$=b.reduce((F,G)=>G.selected?[...F,ai(G.id,!1)]:F,[]);R(A),w($)},setNodeExtent:b=>{const{nodes:E,nodeLookup:R,parentLookup:w,nodeOrigin:N,elevateNodesOnSelect:A,nodeExtent:$,zIndexMode:F}=k();b[0][0]===$[0][0]&&b[0][1]===$[0][1]&&b[1][0]===$[1][0]&&b[1][1]===$[1][1]||(dc(E,R,w,{nodeOrigin:N,nodeExtent:b,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:F}),_({nodeExtent:b}))},panBy:b=>{const{transform:E,width:R,height:w,panZoom:N,translateExtent:A}=k();return I1({delta:b,panZoom:N,transform:E,translateExtent:A,width:R,height:w})},setCenter:async(b,E,R)=>{const{width:w,height:N,maxZoom:A,panZoom:$}=k();if(!$)return!1;const F=typeof(R==null?void 0:R.zoom)<"u"?R.zoom:A;return await $.setViewport({x:w/2-b*F,y:N/2-E*F,zoom:F},{duration:R==null?void 0:R.duration,ease:R==null?void 0:R.ease,interpolate:R==null?void 0:R.interpolate}),!0},cancelConnection:()=>{_({connection:{...og}})},updateConnection:b=>{_({connection:b})},reset:()=>_({...fp()})}},Object.is);function dm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m,children:_}){const[k]=L.useState(()=>JS({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:v,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:x,nodeExtent:y,zIndexMode:m}));return d.jsx(f_,{value:k,children:d.jsx(D_,{children:d.jsx(J_,{children:_})})})}function ek({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:v,maxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_}){return L.useContext(ea)?d.jsx(d.Fragment,{children:t}):d.jsx(dm,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:v,initialMaxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_,children:t})}const tk={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function nk({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:v,onMove:x,onMoveStart:y,onMoveEnd:m,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,onNodeDragStart:F,onNodeDrag:G,onNodeDragStop:q,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onSelectionChange:K,onSelectionDragStart:C,onSelectionDrag:V,onSelectionDragStop:W,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:H,connectionMode:I,connectionLineType:z=Lr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:Z=!1,selectionMode:se=rs.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:ke=ss()?"Meta":"Control",zoomActivationKeyCode:ve=ss()?"Meta":"Control",snapToGrid:re,snapGrid:Ne,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Te,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,nodeOrigin:Ge=zg,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt=!0,defaultViewport:mt=j_,minZoom:Pt=.5,maxZoom:ut=2,translateExtent:Je=ns,preventScrolling:An=!0,nodeExtent:Ot,defaultMarkerColor:xn="#b1b1b7",zoomOnScroll:io=!0,zoomOnPinch:$n=!0,panOnScroll:vi=!1,panOnScrollSpeed:or=.5,panOnScrollMode:$r=di.Free,zoomOnDoubleClick:zn=!0,panOnDrag:zr=!0,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn=1,nodeClickDistance:Fn=0,children:_n,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn=10,onNodesChange:Ht,onEdgesChange:Or,noDragClassName:nn="nodrag",noWheelClassName:Fr="nowheel",noPanClassName:yt="nopan",fitView:Hn,fitViewOptions:ur,connectOnClick:oo,attributionPosition:It,proOptions:Bn,defaultEdgeOptions:Hr,elevateNodesOnSelect:jn=!0,elevateEdgesOnSelect:Br=!1,disableKeyboardA11y:xi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:so,autoPanOnSelection:Vr=!0,autoPanSpeed:wi,connectionRadius:cr,isValidConnection:lo,onError:dr,style:Vn,id:bt,nodeDragThreshold:Wr,connectionDragThreshold:Et,viewport:ao,onViewportChange:Ur,width:Yr,height:Wn,colorMode:Un="light",debug:bn,onScroll:Bt,ariaLabelConfig:_i,zIndexMode:Gr="basic",...fr},hr){const Yn=bt||"1",En=M_(Un),uo=L.useCallback(pr=>{pr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Bt==null||Bt(pr)},[Bt]);return d.jsx("div",{"data-testid":"rf__wrapper",...fr,onScroll:uo,style:{...Vn,...tk},ref:hr,className:nt(["react-flow",a,En]),id:bt,role:"application",children:d.jsxs(ek,{nodes:t,edges:r,width:Yr,height:Wn,fitView:Hn,fitViewOptions:ur,minZoom:Pt,maxZoom:ut,nodeOrigin:Ge,nodeExtent:Ot,zIndexMode:Gr,children:[d.jsx(C_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt,elevateNodesOnSelect:jn,elevateEdgesOnSelect:Br,minZoom:Pt,maxZoom:ut,nodeExtent:Ot,onNodesChange:Ht,onEdgesChange:Or,snapToGrid:re,snapGrid:Ne,connectionMode:I,translateExtent:Je,connectOnClick:oo,defaultEdgeOptions:Hr,fitView:Hn,fitViewOptions:ur,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onNodeDragStart:F,onNodeDrag:G,onNodeDragStop:q,onSelectionDrag:V,onSelectionDragStart:C,onSelectionDragStop:W,onMove:x,onMoveStart:y,onMoveEnd:m,noPanClassName:yt,nodeOrigin:Ge,rfId:Yn,autoPanOnConnect:Ve,autoPanOnNodeDrag:so,autoPanSpeed:wi,onError:dr,connectionRadius:cr,isValidConnection:lo,selectNodesOnDrag:Te,nodeDragThreshold:Wr,connectionDragThreshold:Et,onBeforeDelete:H,debug:bn,ariaLabelConfig:_i,zIndexMode:Gr}),d.jsx(QS,{onInit:v,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,nodeTypes:u,edgeTypes:c,connectionLineType:z,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:Z,selectionMode:se,deleteKeyCode:he,multiSelectionKeyCode:ke,panActivationKeyCode:me,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:mt,translateExtent:Je,minZoom:Pt,maxZoom:ut,preventScrolling:An,zoomOnScroll:io,zoomOnPinch:$n,zoomOnDoubleClick:zn,panOnScroll:vi,panOnScrollSpeed:or,panOnScrollMode:$r,panOnDrag:zr,autoPanOnSelection:Vr,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn,nodeClickDistance:Fn,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn,defaultMarkerColor:xn,noDragClassName:nn,noWheelClassName:Fr,noPanClassName:yt,rfId:Yn,disableKeyboardA11y:xi,nodeExtent:Ot,viewport:ao,onViewportChange:Ur,nodesDraggable:$e}),d.jsx(N_,{onSelectionChange:K}),_n,d.jsx(x_,{proOptions:Bn,position:It}),d.jsx(v_,{rfId:Yn,disableKeyboardA11y:xi})]})})}var rk=Og(nk);function ik({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:nt(["react-flow__background-pattern",o,s])})}function ok({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:nt(["react-flow__background-pattern","dots",r])})}var Ar;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Ar||(Ar={}));const sk={[Ar.Dots]:1,[Ar.Lines]:1,[Ar.Cross]:6},lk=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function fm({id:t,variant:r=Ar.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:v,patternClassName:x}){const y=L.useRef(null),{transform:m,patternId:_}=De(lk,Qe),k=s||sk[r],j=r===Ar.Dots,b=r===Ar.Cross,E=Array.isArray(o)?o:[o,o],R=[E[0]*m[2]||1,E[1]*m[2]||1],w=k*m[2],N=Array.isArray(u)?u:[u,u],A=b?[w,w]:R,$=[N[0]*m[2]+A[0]/2,N[1]*m[2]+A[1]/2],F=`${_}${t||""}`;return d.jsxs("svg",{className:nt(["react-flow__background",v]),style:{...p,...ra,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:y,"data-testid":"rf__background",children:[d.jsx("pattern",{id:F,x:m[0]%R[0],y:m[1]%R[1],width:R[0],height:R[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:j?d.jsx(ok,{radius:w/2,className:x}):d.jsx(ik,{dimensions:A,lineWidth:a,variant:r,className:x})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${F})`})]})}fm.displayName="Background";const ak=L.memo(fm);function uk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ck(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 fk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 hk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 jl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:nt(["react-flow__controls-button",r]),...o,children:t})}const pk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function hm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:v,children:x,position:y="bottom-left",orientation:m="vertical","aria-label":_}){const k=Ye(),{isInteractive:j,minZoomReached:b,maxZoomReached:E,ariaLabelConfig:R}=De(pk,Qe),{zoomIn:w,zoomOut:N,fitView:A}=na(),$=()=>{w(),u==null||u()},F=()=>{N(),c==null||c()},G=()=>{A(a),h==null||h()},q=()=>{k.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),p==null||p(!j)},te=m==="horizontal"?"horizontal":"vertical";return d.jsxs(ta,{className:nt(["react-flow__controls",te,v]),position:y,style:t,"data-testid":"rf__controls","aria-label":_??R["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(jl,{onClick:$,className:"react-flow__controls-zoomin",title:R["controls.zoomIn.ariaLabel"],"aria-label":R["controls.zoomIn.ariaLabel"],disabled:E,children:d.jsx(uk,{})}),d.jsx(jl,{onClick:F,className:"react-flow__controls-zoomout",title:R["controls.zoomOut.ariaLabel"],"aria-label":R["controls.zoomOut.ariaLabel"],disabled:b,children:d.jsx(ck,{})})]}),o&&d.jsx(jl,{className:"react-flow__controls-fitview",onClick:G,title:R["controls.fitView.ariaLabel"],"aria-label":R["controls.fitView.ariaLabel"],children:d.jsx(dk,{})}),s&&d.jsx(jl,{className:"react-flow__controls-interactive",onClick:q,title:R["controls.interactive.ariaLabel"],"aria-label":R["controls.interactive.ariaLabel"],children:j?d.jsx(hk,{}):d.jsx(fk,{})}),x]})}hm.displayName="Controls";const gk=L.memo(hm);function mk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:v,borderRadius:x,shapeRendering:y,selected:m,onClick:_}){const{background:k,backgroundColor:j}=u||{},b=c||k||j;return d.jsx("rect",{className:nt(["react-flow__minimap-node",{selected:m},v]),x:r,y:o,rx:x,ry:x,width:s,height:a,style:{fill:b,stroke:h,strokeWidth:p},shapeRendering:y,onClick:_?E=>_(E,t):void 0})}const yk=L.memo(mk),vk=t=>t.nodes.map(r=>r.id),Ku=t=>t instanceof Function?t:()=>t;function xk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=yk,onClick:c}){const h=De(vk,Qe),p=Ku(r),v=Ku(t),x=Ku(o),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(m=>d.jsx(_k,{id:m,nodeColorFunc:p,nodeStrokeColorFunc:v,nodeClassNameFunc:x,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:y},m))})}function wk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:v,x,y,width:m,height:_}=De(k=>{const j=k.nodeLookup.get(t);if(!j)return{node:void 0,x:0,y:0,width:0,height:0};const b=j.internals.userNode,{x:E,y:R}=j.internals.positionAbsolute,{width:w,height:N}=vn(b);return{node:b,x:E,y:R,width:w,height:N}},Qe);return!v||v.hidden||!hg(v)?null:d.jsx(h,{x,y,width:m,height:_,style:v.style,selected:!!v.selected,className:s(v),color:r(v),borderRadius:a,strokeColor:o(v),strokeWidth:u,shapeRendering:c,onClick:p,id:v.id})}const _k=L.memo(wk);var Sk=L.memo(xk);const kk=200,Nk=150,jk=t=>!t.hidden,bk=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?cg(hs(t.nodeLookup,{filter:jk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},hp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,Ek=(t,r)=>hp(t.viewBB,r.viewBB)&&hp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,Ck="react-flow__minimap-desc";function pm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:v,maskStrokeColor:x,maskStrokeWidth:y,position:m="bottom-right",onClick:_,onNodeClick:k,pannable:j=!1,zoomable:b=!1,ariaLabel:E,inversePan:R,zoomStep:w=1,offsetScale:N=5}){const A=Ye(),$=L.useRef(null),{boundingRect:F,viewBB:G,rfId:q,panZoom:te,translateExtent:ee,flowWidth:ne,flowHeight:K,ariaLabelConfig:C}=De(bk,Ek),V=(t==null?void 0:t.width)??kk,W=(t==null?void 0:t.height)??Nk,U=F.width/V,M=F.height/W,D=Math.max(U,M),H=D*V,I=D*W,z=N*D,ie=F.x-(H-F.width)/2-z,oe=F.y-(I-F.height)/2-z,fe=H+z*2,he=I+z*2,pe=`${Ck}-${q}`,Z=L.useRef(0),se=L.useRef();Z.current=D,L.useEffect(()=>{if($.current&&te)return se.current=F1({domNode:$.current,panZoom:te,getTransform:()=>A.getState().transform,getViewScale:()=>Z.current}),()=>{var re;(re=se.current)==null||re.destroy()}},[te]),L.useEffect(()=>{var re;(re=se.current)==null||re.update({translateExtent:ee,width:ne,height:K,inversePan:R,pannable:j,zoomStep:w,zoomable:b})},[j,b,R,w,ee,ne,K]);const me=_?re=>{var Te;const[Ne,Me]=((Te=se.current)==null?void 0:Te.pointer(re))||[0,0];_(re,{x:Ne,y:Me})}:void 0,ke=k?L.useCallback((re,Ne)=>{const Me=A.getState().nodeLookup.get(Ne).internals.userNode;k(re,Me)},[]):void 0,ve=E??C["minimap.ariaLabel"];return d.jsx(ta,{position:m,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof v=="string"?v:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof y=="number"?y*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:nt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:V,height:W,viewBox:`${ie} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:$,onClick:me,children:[ve&&d.jsx("title",{id:pe,children:ve}),d.jsx(Sk,{onClick:ke,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-z},${oe-z}h${fe+z*2}v${he+z*2}h${-fe-z*2}z - M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}pm.displayName="MiniMap";const Mk=L.memo(pm),Pk=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Ik={[to.Line]:"right",[to.Handle]:"bottom-right"};function Rk({nodeId:t,position:r,variant:o=to.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:v=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:y=!1,resizeDirection:m,autoScale:_=!0,shouldResize:k,onResizeStart:j,onResize:b,onResizeEnd:E}){const R=Wg(),w=typeof t=="string"?t:R,N=Ye(),A=L.useRef(null),$=o===to.Handle,F=De(L.useCallback(Pk($&&_),[$,_]),Qe),G=L.useRef(null),q=r??Ik[o];L.useEffect(()=>{if(!(!A.current||!w))return G.current||(G.current=J1({domNode:A.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,domNode:W}=N.getState();return{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,paneDomNode:W}},onChange:(ee,ne)=>{const{triggerNodeChanges:K,nodeLookup:C,parentLookup:V,nodeOrigin:W}=N.getState(),U=[],M={x:ee.x,y:ee.y},D=C.get(w);if(D&&D.expandParent&&D.parentId){const H=D.origin??W,I=ee.width??D.measured.width??0,z=ee.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:I,height:z,...pg({x:ee.x??D.position.x,y:ee.y??D.position.y},{width:I,height:z},D.parentId,C,H)}},oe=Pc([ie],C,V,W);U.push(...oe),M.x=ee.x?Math.max(H[0]*I,ee.x):void 0,M.y=ee.y?Math.max(H[1]*z,ee.y):void 0}if(M.x!==void 0&&M.y!==void 0){const H={id:w,type:"position",position:{...M}};U.push(H)}if(ee.width!==void 0&&ee.height!==void 0){const I={id:w,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:ee.width,height:ee.height}};U.push(I)}for(const H of ne){const I={...H,type:"position"};U.push(I)}K(U)},onEnd:({width:ee,height:ne})=>{const K={id:w,type:"dimensions",resizing:!1,dimensions:{width:ee,height:ne}};N.getState().triggerNodeChanges([K])}})),G.current.update({controlPosition:q,boundaries:{minWidth:h,minHeight:p,maxWidth:v,maxHeight:x},keepAspectRatio:y,resizeDirection:m,onResizeStart:j,onResize:b,onResizeEnd:E,shouldResize:k}),()=>{var ee;(ee=G.current)==null||ee.destroy()}},[q,h,p,v,x,y,j,b,E,k]);const te=q.split("-");return d.jsx("div",{className:nt(["react-flow__resize-control","nodrag",...te,o,s]),ref:A,style:{...a,scale:F,...c&&{[$?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Rk);const Tk={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function ia(t){return Tk[t]??8}const Wl=208,as=64,Lk=88,Ak=28,$k=8;function zk(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function gm(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const w of t){const N=ia(w.type),A=s.get(N)??[];A.push(w),s.set(N,A)}const u=[...s.keys()].sort((w,N)=>w-N).map(w=>[...s.get(w)??[]].sort((N,A)=>N.name.localeCompare(A.name)||N.id.localeCompare(A.id))),c=new Set(t.map(w=>w.id)),h=new Map,p=new Map;for(const w of t)h.set(w.id,[]),p.set(w.id,[]);for(const w of r)!c.has(w.src)||!c.has(w.dst)||w.src===w.dst||(p.get(w.src).push(w.dst),h.get(w.dst).push(w.src));const v=new Map;u.forEach((w,N)=>{for(const A of w)v.set(A.id,N)});const x=new Map,y=()=>{for(const w of u)w.forEach((N,A)=>x.set(N.id,A))};y();const m=(w,N)=>{const A=w.map(($,F)=>{const G=N($.id).map(te=>x.get(te)).filter(te=>te!==void 0),q=zk(G);return{n:$,bary:Number.isNaN(q)?F:q,name:$.name,id:$.id}});return A.sort(($,F)=>$.bary-F.bary||$.name.localeCompare(F.name)||$.id.localeCompare(F.id)),A.map($=>$.n)},_=w=>N=>v.get(N)===w;for(let w=0;w<$k;w++){for(let N=1;N(h.get(A)??[]).filter(_(N-1))),y();for(let N=u.length-2;N>=0;N--)u[N]=m(u[N],A=>(p.get(A)??[]).filter(_(N+1))),y()}const k=Wl+Lk,j=as+Ak,b=Math.max(...u.map(w=>w.length),1),E=[];let R=0;for(let w=0;wG.id)),A=new Set((u[w+1]??[]).map(G=>G.id));let $=0;if(A.size)for(const G of r)N.has(G.src)&&A.has(G.dst)&&($+=1);const F=Math.min(96,Math.max(0,($-1)*12));R+=k+F}return u.forEach((w,N)=>{const A=(b-w.length)*j/2;w.forEach(($,F)=>{o.set($.id,{x:E[N]??0,y:A+F*j})})}),o}const Dk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),mm=90,Ok=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),pp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Fk=Math.PI*(3-Math.sqrt(5)),ym=220,Hk=26,Bk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function vm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function FN(t){return pp[t]?pp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Vk(t){return t>=mm?"3d":"2d"}function Wk(t){return t>=mm?"overview":"full"}function Uk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(vm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Ok.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Uk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Gk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function Xk(t,r,o,s){const a=new Set(t.map(j=>j.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const j of r){if(!a.has(j.src)||!a.has(j.dst))continue;const b=u.get(j.src)??[];b.push({dst:j.dst,id:j.id}),u.set(j.src,b);const E=c.get(j.dst)??[];E.push({src:j.src,id:j.id}),c.set(j.dst,E)}const h=new Set(t.filter(j=>Dk.has(j.type)).map(j=>j.id)),p=h.size?h:a,v=new Set,x=[o];for(;x.length;){const j=x.pop();if(!v.has(j)){v.add(j);for(const b of u.get(j)??[])v.has(b.dst)||x.push(b.dst)}}const y=new Set([o]),m=[...p].filter(j=>v.has(j)),_=new Set(m);for(;m.length;){const j=m.pop();y.add(j);for(const b of c.get(j)??[])v.has(b.src)&&!_.has(b.src)&&(_.add(b.src),m.push(b.src))}const k=new Set;for(const j of r)y.has(j.src)&&y.has(j.dst)&&k.add(j.id);return{nodeIds:y,edgeIds:k}}function HN(t){const r=new Map;for(const s of t){const a=ia(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*ym;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Hk*Math.sqrt(h+1),v=h*Fk;o.set(c.id,{x:u,y:p*Math.cos(v),z:p*Math.sin(v)})})}return o}function BN(t){const r=new Map;for(const o of t){const s=ia(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*ym,count:s}))}const bl=16,qk=12,Kk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Qk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),gp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Zk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},mp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],yp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Jk=new Set(["looks_idempotent_on_pk","null","blank"]),eN=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function tN(t){return gp[t]?gp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function nN(t,r,o){const s=new Map(r.map(m=>[m.id,m])),a=[];Kk.has(t.type)&&a.push("sink"),Qk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(m=>m.dst===t.id),h=o.filter(m=>m.src===t.id),p=c.slice(0,bl).map(m=>El(m,s,m.src)),v=h.slice(0,bl).map(m=>El(m,s,m.dst)),x=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,y={type:t.type,typeLabel:Qo(ro(t.type)),layer:Bk[ia(t.type)]??"other",purpose:tN(t.type),name:t.name,qualifiedName:t.qualified_name,file:x,context:t.context,roles:a,facts:iN(u).filter(m=>!(m.key==="app"&&m.value===t.context)),inputs:p,outputs:v,extraInputs:Math.max(0,c.length-bl),extraOutputs:Math.max(0,h.length-bl),degreeIn:c.length,degreeOut:h.length,inputKinds:vp(c.map(m=>El(m,s,m.src))),outputKinds:vp(h.map(m=>El(m,s,m.dst))),pathSummary:""};return y.pathSummary=rN(y),y}function vp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function rN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function El(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Qo(ro(s.type)):"",edgeType:t.type,edgeLabel:Qo(t.type),inferred:t.confidence<.8}}function iN(t){const r=[...mp.filter(a=>a in t),...Object.keys(t).filter(a=>!mp.includes(a)&&!yp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||yp.has(a)||eN.has(a))continue;s.add(a);const u=oN(a,t[a]);u!=null&&o.push({key:a,label:Zk[a]??Qo(a),value:u})}return o}function oN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Jk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return sN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,qk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function sN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const lN=12,xp=.2,aN=.8;function uN(t,r,o){const s=o??gm(t,r),a=[];for(const h of r){const p=s.get(h.src),v=s.get(h.dst);if(!p||!v)continue;const x=p.y+as/2,y=v.y+as/2;if(Math.abs(x-y)${Math.round(_/8)}`})}const u=new Map;for(const h of a){const p=u.get(h.corridor)??[];p.push(h),u.set(h.corridor,p)}const c=new Map;for(const h of u.values()){const p=[...h].sort((x,y)=>x.sourceY-y.sourceY||x.id.localeCompare(y.id)),v=p.length;p.forEach((x,y)=>{c.set(x.id,cN(y,v))})}return c}function cN(t,r){return r<=1?.5:xp+(aN-xp)*t/(r-1)}const dN=new Set,fN=L.lazy(()=>k0(()=>import("./LayeredGraph3D-CfNK3S5A.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),hN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function pN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(no,{type:"target",position:Se.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:ro(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Tr(t.name)}),d.jsx(no,{type:"source",position:Se.Right,isConnectable:!1})]})}const gN={load:pN},mN=new Set(["django","react","stitch","arch"]);function yN({id:t,sourceX:r,sourceY:o,targetX:s,targetY:a,sourcePosition:u,targetPosition:c,style:h,markerEnd:p,markerStart:v,label:x,labelStyle:y,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,data:b,interactionWidth:E}){const[R,w,N]=Bl({sourceX:r,sourceY:o,sourcePosition:u,targetX:s,targetY:a,targetPosition:c,borderRadius:8,stepPosition:(b==null?void 0:b.stepPosition)??.5});return d.jsx(ms,{id:t,path:R,labelX:w,labelY:N,label:x,labelStyle:y,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,style:h,markerEnd:p,markerStart:v,interactionWidth:E})}const vN={loadstep:yN};function xN({topologyKey:t}){const{fitView:r}=na();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function wN(t,r,o=null,s={}){const a=new Map(t.map(v=>[v.id,v])),u=gm(t,r),c=uN(t,r,u),h=t.map(v=>{var m;const x=((m=s.roles)==null?void 0:m[v.id])||[],y=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:v.id,type:"load",position:u.get(v.id)??{x:0,y:0},data:{name:v.name,type:v.type,file:v.file_path,roles:x,dim:y},selected:o===v.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:Wl,height:as,style:{width:Wl,height:as}}}),p=r.filter(v=>a.has(v.src)&&a.has(v.dst)).map(v=>{const x=hN[v.weight]||"var(--edge-cheap)",y=!!(o&&(v.src===o||v.dst===o));return{id:v.id,source:v.src,target:v.dst,type:"loadstep",animated:v.weight==="critical",data:{stepPosition:c.get(v.id)??.5},style:{stroke:x,strokeWidth:v.weight==="critical"?2.4:1.2,strokeDasharray:v.confidence<.8?"6 4":void 0},markerEnd:{type:is.ArrowClosed,width:14,height:14,color:x},label:y?v.type.replaceAll("_"," "):void 0,labelStyle:y?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:y?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:y?[3,5]:void 0,labelBgBorderRadius:y?4:void 0}});return{rfNodes:h,rfEdges:p}}function _N({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:v}){const x=nN(t,r,o);return L.useEffect(()=>{const y=m=>{m.key==="Escape"&&s()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:x.typeLabel}),d.jsx("div",{className:"inspector-roles",children:x.roles.map(y=>d.jsx("span",{className:"inspector-chip",children:y},y))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Tr(x.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:x.purpose}),x.context?d.jsx("div",{className:"muted",children:Tr(x.context)}):null,x.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Tr(x.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Tr(x.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",x.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[x.degreeIn," in · ",x.degreeOut," out"]}),x.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:x.pathSummary}):null,x.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:x.facts.map(y=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:y.label}),d.jsx("dd",{children:Tr(y.value)})]},y.key))}):null,d.jsx(wp,{title:"Inputs",testId:"graph-inspector-inputs",links:x.inputs,extra:x.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(wp,{title:"Outputs",testId:"graph-inspector-outputs",links:x.outputs,extra:x.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),a?d.jsx("p",{className:"whatif-hint","data-testid":"whatif-hint",children:v?"Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map.":"Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."}):null,d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",title:"Start a hypothetical walk from this node. Does not use Base/Head.",onClick:()=>a(t.id),children:"What if this changes"}):null,v?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",title:"Hide nodes that are not on a path from here to a sink. Does not start a new walk.",onClick:()=>v(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function wp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Qu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:v,repoPath:x,onOpenFile:y,pinnedId:m,onPin:_}){const[k,j]=L.useState(null),b=a!==void 0?a:k,E=re=>{a===void 0&&j(re),u==null||u(re)},[R,w]=L.useState(null),[N,A]=L.useState(null),[$,F]=L.useState(new Set(mN)),[G,q]=L.useState(!1),[te,ee]=L.useState(""),[ne,K]=L.useState(!1),C=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,V=R??Vk(t.length),W=N??Wk(t.length),U=G?b:null,M=L.useMemo(()=>p?Xk(t,r,p):null,[t,r,p]),D=M?t.filter(re=>M.nodeIds.has(re.id)):t,H=M?r.filter(re=>M.edgeIds.has(re.id)):r,I=L.useMemo(()=>Yk(D,H,{detail:W,families:$,focusId:U,neighborhoodOnly:!!U}),[D,H,W,$,U]),z=L.useMemo(()=>`${I.nodes.map(re=>re.id).join("\0")}|${I.edges.map(re=>re.id).join("\0")}`,[I.nodes,I.edges]),ie=b?t.find(re=>re.id===b)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const re=wN(I.nodes,I.edges,b,{roles:c,testOverlay:h});return C&&(re.rfEdges=re.rfEdges.map(Ne=>({...Ne,animated:!1}))),re},[I.nodes,I.edges,b,C,c,h]);L.useEffect(()=>{if(!s)return;const re=t.find(Ne=>Ne.file_path===s);re&&E(re.id)},[s,t]);const he=L.useMemo(()=>Gk(t,te),[t,te]),pe=(re,Ne)=>{E(Ne.id)},Z=()=>{E(null),q(!1)},se=ie?d.jsx(_N,{node:ie,nodes:t,edges:r,onClose:Z,onWhatIf:o,onSelect:E,onOpenFile:y,pinned:m===ie.id,onPin:_,onIsolate:v?re=>{v(p===re?null:re)}:void 0}):null,me=re=>{F(Ne=>{const Me=new Set(Ne);if(Me.has(re)){if(Me.size===1)return Ne;Me.delete(re)}else Me.add(re);return Me})},ke=L.useMemo(()=>{const re=new Set;for(const Ne of t)re.add(vm(Ne.type));return re},[t]),ve=t.length-I.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:V==="2d"?"active":"","aria-pressed":V==="2d",onClick:()=>w("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:V==="3d"?"active":"","aria-pressed":V==="3d",onClick:()=>w("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:W==="overview"?"active":"","aria-pressed":W==="overview",onClick:()=>A("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:W==="full"?"active":"","aria-pressed":W==="full",onClick:()=>A("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(re=>ke.has(re)).map(re=>d.jsx("button",{type:"button","data-testid":`graph-family-${re}`,className:$.has(re)?"active":"","aria-pressed":$.has(re),onClick:()=>me(re),children:re},re))}),d.jsx("button",{type:"button",className:G?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!b,onClick:()=>q(re=>!re),children:G?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>v==null?void 0:v(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:te,onChange:re=>{ee(re.target.value),K(!0)},onFocus:()=>K(!0),onBlur:()=>window.setTimeout(()=>K(!1),150)}),ne&&te.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(re=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:Ne=>Ne.preventDefault(),onClick:()=>{E(re.id),ee(""),K(!1)},children:[re.name,d.jsx("span",{className:"muted",children:ro(re.type)})]})},re.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[I.nodes.length," nodes · ",I.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:V==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(fN,{nodes:I.nodes,edges:I.edges,selectedId:b,neighborIds:U?I.neighborIds:dN,onSelect:re=>{E(re),re||q(!1)}})}),se]}):d.jsxs(dm,{children:[d.jsxs(rk,{nodes:oe,edges:fe,nodeTypes:gN,edgeTypes:vN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:Z,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(xN,{topologyKey:z}),d.jsx(ak,{}),d.jsx(Mk,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(gk,{})]}),se]})})]})}function xm(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function SN(t){localStorage.setItem("loadpath.editor",t)}async function kN(t,r,o,s=xm()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const _p=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],NN=["preset","branch","tag","commit"];function jN(t){var a;if(!(t!=null&&t.git))return[..._p];const r=((a=t.presets)!=null&&a.length?t.presets:_p.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function bN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function EN(t){return NN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function CN(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function Sp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[v,x]=L.useState(!1),[y,m]=L.useState(null),[_,k]=L.useState(0),j=L.useMemo(()=>{const N=jN(u);return y===null?N:bN(N,y)},[u,y]),b=L.useMemo(()=>EN(j),[j]);L.useEffect(()=>{v&&c()},[v,c]),L.useEffect(()=>{k(0)},[y,v]);const E=()=>{x(!1),m(null)},R=N=>{r(N.value),E()},w=N=>{if(N.key==="ArrowDown"){if(N.preventDefault(),!v){x(!0);return}k(A=>Math.min(A+1,Math.max(j.length-1,0)))}else if(N.key==="ArrowUp"){if(N.preventDefault(),!v)return;k(A=>Math.max(A-1,0))}else if(N.key==="Enter"&&v){N.preventDefault();const A=j[_];A&&R(A)}else N.key==="Escape"&&v&&(N.preventDefault(),E())};return d.jsxs("div",{className:"combo",ref:p,onBlur:N=>{N.currentTarget.contains(N.relatedTarget)||E()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":v,"aria-controls":h,"aria-autocomplete":"list",onChange:N=>{r(N.target.value),v&&m(N.target.value)},onKeyDown:w}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":v,onMouseDown:N=>N.preventDefault(),onClick:()=>v?E():x(!0),children:d.jsx(w0,{})})]}),v?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:b.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):b.map(N=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:CN(N.group)}),N.items.map(A=>{const $=j.indexOf(A);return d.jsxs("button",{type:"button",role:"option","aria-selected":$===_,className:$===_?"combo-option active":"combo-option","data-testid":`ref-option-${A.group}`,onMouseDown:F=>F.preventDefault(),onMouseEnter:()=>k($),onClick:()=>R(A),children:[d.jsx("span",{className:"combo-label",children:A.label}),A.detail?d.jsx("span",{className:"combo-detail",children:A.detail}):null]},`${A.group}:${A.value}`)})]},N.group))}):null]})}function MN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[v,x]=L.useState(""),[y,m]=L.useState(!1),_=L.useRef(null),k=L.useRef(0),j=async w=>{const N=k.current+1;k.current=N,m(!0);try{const A=await Pe.browse(w);if(k.current!==N)return;a(A),c(A.path),p(A.is_git?A.path:null),x("")}catch(A){if(k.current!==N)return;x(A instanceof Error?A.message:String(A))}finally{k.current===N&&m(!1)}};L.useEffect(()=>{var w,N;j(t),(w=_.current)==null||w.focus(),(N=_.current)==null||N.select()},[t]);const b=h||(s==null?void 0:s.path)||u,E=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",R=w=>{w.key==="Escape"&&(w.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:R,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:w=>w.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:w=>{w.preventDefault(),j(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:w=>c(w.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),v?d.jsx("div",{className:"error",role:"alert",children:v}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":y,children:s!=null&&s.entries.length?s.entries.map(w=>{const N=h===w.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":N,className:N?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":w.path,onClick:()=>p(w.path),onDoubleClick:()=>void j(w.path),children:[d.jsx(bp,{}),d.jsx("span",{className:"explorer-name",children:w.name}),w.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},w.path)}):d.jsx("div",{className:"muted explorer-empty",children:y?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:b,children:b}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!b,onClick:()=>b&&r(b),children:["Use ",E]})]})]})})}const PN={scan:{start:0,end:20},extract:{start:20,end:88},boot:{start:88,end:94},stitch:{start:94,end:99},skipped:{start:100,end:100},done:{start:100,end:100}},IN=new Set(["scan","extract","boot","stitch"]);function RN(t){const r=t.phase||"";if(!r||r==="idle")return null;const o=PN[r];if(!o)return null;if(o.start===o.end)return o.end;const s=t.total||0;if(s<=0)return o.start;const a=Math.min(1,Math.max(0,(t.done||0)/s));return Math.round(o.start+(o.end-o.start)*a)}function TN(t){return!t.phase||t.phase==="idle"?null:typeof t.percent=="number"&&Number.isFinite(t.percent)?Math.max(0,Math.min(100,Math.round(t.percent))):RN(t)}const Ul=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],LN="obsidian",wm="loadpath.theme";function AN(t){return Ul.some(r=>r.id===t)}function _m(){try{const t=localStorage.getItem(wm)||"";if(AN(t))return t}catch{}return LN}function $N(t){var r;return((r=Ul.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function Sm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=$N(t);try{localStorage.setItem(wm,t)}catch{}}const Zu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:g0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:m0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:y0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:v0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:x0}];function Ju(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function zN(){var co,fo,Si,ho,po,go,ki,Xr,rn,on;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,v]=L.useState(null),[x,y]=L.useState(null),[m,_]=L.useState(null),[k,j]=L.useState([]),[b,E]=L.useState("review"),[R,w]=L.useState(""),[N,A]=L.useState(""),[$,F]=L.useState(null),[G,q]=L.useState(!1),[te,ee]=L.useState(!1),[ne,K]=L.useState(""),[C,V]=L.useState({}),[W,U]=L.useState([]),[M,D]=L.useState([]),[H,I]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[z,ie]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[oe,fe]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[he,pe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[Z,se]=L.useState(0),[me,ke]=L.useState(""),[ve,re]=L.useState(_m),[Ne,Me]=L.useState(!1),[Te,$e]=L.useState(!1),[st,lt]=L.useState(!1),[at,Ge]=L.useState(null),[wt,qt]=L.useState(null),[gt,mt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[Pt,ut]=L.useState(null),[Je,An]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[Ot,xn]=L.useState([]),[io,$n]=L.useState(null),[vi,or]=L.useState(null),[$r,zn]=L.useState(null),[zr,sr]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[lr,Ft]=L.useState(null),[ct,Dn]=L.useState(null),[On,wn]=L.useState(!1),[Fn,_n]=L.useState(!1),rt=L.useRef(o);rt.current=o;const Dr=L.useRef(!1);Dr.current=Te;const _t=L.useRef(""),ar=L.useRef(""),Sn=P=>{re(P),Sm(P)},dt=L.useRef(""),He=P=>{dt.current=P,A(P)},kn=P=>{let Y=0,ce=!1;F(0);const je=()=>{Pe.indexProgress(P).then(Ie=>{if(!dt.current)return;if(Ie.phase&&Ie.phase!=="idle"&&Ie.message&&He(Ie.message),IN.has(Ie.phase))ce=!0;else if(!ce)return;const qr=TN(Ie);qr!=null&&(Ie.phase==="scan"&&!Ie.done?Y=qr:Y=Math.max(Y,qr),F(Y))}).catch(()=>{})};je();const Le=window.setInterval(je,250);return()=>{window.clearInterval(Le),F(null)}};L.useEffect(()=>{Pe.settings().then(V).catch(()=>{}).finally(()=>Me(!0)),Pe.repos().then(P=>j(P.repos)).catch(()=>{})},[]);const Nn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const P=o;let Y=!1;return ar.current!==P&&Bn(P),Pe.config(P).then(ce=>{!Y&&rt.current===P&&or(ce)}).catch(()=>{}),Pe.architectureHealth(P).then(ce=>{!Y&&rt.current===P&&zn(ce)}).catch(()=>{}),()=>{Y=!0}},[t,o]);const Ht=P=>{rt.current=P,s(P),localStorage.setItem("loadpath.repo",P),P.trim()!==_t.current&&(_t.current="",Ft(null))},Or=L.useCallback(P=>{const Y=(P??rt.current).trim();return!Y||_t.current===Y?Promise.resolve():(_t.current=Y,Pe.gitRefs(Y).then(ce=>{rt.current.trim()===Y&&Ft(ce)}).catch(()=>{_t.current===Y&&(_t.current="",Ft(null))}))},[]),nn=(P,Y)=>{u(P),h(Y),localStorage.setItem("loadpath.base",P),localStorage.setItem("loadpath.head",Y)},Fr=(P,Y,ce)=>{ie(P),I(Y),localStorage.setItem("loadpath.provider",P),localStorage.setItem("loadpath.scmRepo",Y),ce!==void 0&&(fe(ce),localStorage.setItem("loadpath.prNumber",ce))},yt=P=>{v(P),se(0),Ge(wt&&P.nodes.some(Y=>Y.id===wt)?wt:null),ut(null),$n(null),P.what_if||(y(P),P.id&&localStorage.setItem("loadpath.lastReviewId",P.id))},Hn=async P=>{try{const Y=await Pe.reviews(P);xn(Y.reviews)}catch{xn([])}},ur=async P=>{try{zn(await Pe.architectureHealth(P))}catch{zn(null)}},oo=P=>P==="github"?!!C.github_token_set:P==="gitlab"?!!C.gitlab_token_set:!!C.bitbucket_token_set,It=L.useCallback(async(P=z)=>{var Y;try{const ce=await Pe.scmRepos(P);D(ce.repos),(Y=ce.user)!=null&&Y.login&&V(je=>({...je,...P==="github"?{github_user:ce.user.login}:P==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{D([])}},[z]);L.useEffect(()=>{if(t!=="prs")return;let P=!1;return It(z).catch(()=>{P||D([])}),()=>{P=!0}},[t,z,It]),L.useEffect(()=>{if(!ct)return;let P=!1,Y=0;const ce=async()=>{try{const je=await Pe.githubOAuthPoll(ct.flow_id);if(P)return;if(je.status==="complete"){Dn(null);const Le=await Pe.settings();V(Le),K(je.user?`Signed in to GitHub as ${je.user}`:"Signed in to GitHub"),It("github");return}if(je.status==="pending"||je.status==="slow_down"){Y=window.setTimeout(ce,Math.max(je.interval||ct.interval,5)*1e3);return}Dn(null),w(je.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(je){if(P)return;Dn(null),w(je instanceof Error?je.message:String(je))}};return Y=window.setTimeout(ce,Math.max(ct.interval,5)*1e3),()=>{P=!0,window.clearTimeout(Y)}},[ct,It]),L.useEffect(()=>{if(!On)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.bitbucket.connected){wn(!1);const Ie=await Pe.settings();V(Ie),K(Le.bitbucket.user?`Signed in to Bitbucket as ${Le.bitbucket.user}`:"Signed in to Bitbucket"),It("bitbucket");return}if(Date.now()-ce>18e4){wn(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;wn(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[On,It]),L.useEffect(()=>{if(!Fn)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.gitlab.connected){_n(!1);const Ie=await Pe.settings();V(Ie),K(Le.gitlab.user?`Signed in to GitLab as ${Le.gitlab.user}`:"Signed in to GitLab"),It("gitlab");return}if(Date.now()-ce>18e4){_n(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;_n(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[Fn,It]);const Bn=async(P=o,Y=!1)=>{if(!P.trim())return null;ar.current=P,ee(!0);try{const ce=await Pe.architecture(P,!1);rt.current===P&&_(ce);const je=Pe.architectureGraph(P).then(Le=>{rt.current===P&&_(Ie=>Ie&&{...Ie,nodes:Le.nodes,edges:Le.edges,graph_pending:!1})});return je.catch(()=>{}).finally(()=>{rt.current===P&&ee(!1)}),Y&&await je,ce}catch(ce){throw rt.current===P&&ee(!1),ce}},Hr=async P=>{const Y=P.trim();if(!(!Y||Y===rt.current)){if(dt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),K(""),v(null),y(null),_(null),E("architecture"),Ht(Y),q(!0),He(`Loading ${p0(Y)}…`);try{await Promise.all([Bn(Y),Or(Y)])}catch(ce){rt.current===Y&&w(ce instanceof Error?ce.message:String(ce))}finally{rt.current===Y&&(He(""),q(!1))}}},jn=async()=>{if(dt.current||!Nn())return;w(""),K(""),He("Tracing load path…"),Ht(o),nn(a,c);const P=kn(o);try{const Y=await Pe.review(o,a,c,!0,he);yt(Y),E("review"),r("review"),await Pe.repos().then(ce=>j(ce.repos)).catch(()=>{}),await Promise.all([Bn(o),Hn(o),ur(o)])}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{P(),He("")}},Br=async(P=!0)=>{if(dt.current||!Nn())return;w(""),K(""),He(P?"Indexing…":"Full reindex…"),Ht(o);const Y=kn(o);try{await Pe.index(o,P);const ce=await Bn(o);await Pe.repos().then(je=>j(je.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(E("architecture"),r("architecture"))}catch(ce){w(ce instanceof Error?ce.message:String(ce))}finally{Y(),He("")}},xi=async()=>{if(!dt.current&&Nn()){w(""),K(""),He("Detecting layout…"),Ht(o);try{const P=await Pe.init(o);K(P.message),await Pe.repos().then(Y=>j(Y.repos)).catch(()=>{})}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ve=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),K("Copied markdown brief")}catch(P){w(P instanceof Error?P.message:String(P))}},so=async()=>{if(!dt.current){if(p!=null&&p.what_if){w("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first.");return}if(!(p!=null&&p.markdown)||!H||!oe){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const P=await Pe.postComment(z,H,Number(oe),p.markdown);K(P.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Vr=async()=>{if(!dt.current){w(""),He("Fetching pull requests…");try{const P=await Pe.prs(z,H,"open",o.trim()||void 0);U(P.pull_requests);const Y=M.find(ce=>ce.slug.toLowerCase()===H.trim().toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},wi=async()=>{w("");try{const P=await Pe.githubOAuthStart();Dn(P),Ju(P.verification_uri_complete,"github.com","/login/device")}catch(P){w(P instanceof Error?P.message:String(P))}},cr=async()=>{w("");try{const P=await Pe.bitbucketOAuthStart();wn(!0),Ju(P.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(P){wn(!1),w(P instanceof Error?P.message:String(P))}},lo=async()=>{w("");try{const P=await Pe.gitlabOAuthStart();_n(!0),Ju(P.authorize_url,new URL(P.authorize_url).hostname,"/oauth/authorize")}catch(P){_n(!1),w(P instanceof Error?P.message:String(P))}},dr=async P=>{if(!(dt.current||!o.trim())){w(""),He("Walking what-if path…");try{const Y=await Pe.whatIf(o,P);K(`${Y.title} — ${Y.confidence.level} · ${(Y.sinks||[]).length} sinks`),yt({...Y,markdown:Y.markdown||"",index:Y.index||(p==null?void 0:p.index),workspace:Y.workspace||(p==null?void 0:p.workspace)}),E("review"),r("review")}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},Vn=()=>{if(x){yt(x),E("review"),r("review"),K("Restored the last git-range walk");return}v(null),se(0),Ge(null),ut(null),$n(null),E("architecture"),r("architecture"),K("")},bt=async P=>{var Le;if(dt.current)return;Fr(P.provider,P.repo,String(P.number));const Y=M.find(Ie=>Ie.slug.toLowerCase()===P.repo.toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path),w(""),He(`Fetching ${P.provider} #${P.number}…`);const ce=(Y==null?void 0:Y.local_path)||o,je=ce?kn(ce):()=>{};try{const Ie=await Pe.reviewPr(P.provider,P.repo,P.number,(Y==null?void 0:Y.local_path)||o||void 0);yt(Ie),Ie.pull_request&&typeof Ie.pull_request.repo_path=="string"&&Ht(Ie.pull_request.repo_path),nn(String(Ie.base||P.target_branch),String(Ie.head||P.source_branch)),E("review"),r("review"),typeof((Le=Ie.pull_request)==null?void 0:Le.repo_path)=="string"&&Hn(Ie.pull_request.repo_path)}catch(Ie){nn(P.base_sha||P.target_branch,P.head_sha||P.source_branch),r("review"),w(Ie instanceof Error?Ie.message:String(Ie))}finally{je(),He("")}},Wr=async P=>{w("");try{V(await Pe.oauthDisconnect(P)),z===P&&D([]),K(`Disconnected ${P}`)}catch(Y){w(Y instanceof Error?Y.message:String(Y))}},Et=async P=>{P.preventDefault();const Y=new FormData(P.currentTarget),ce={github_token:String(Y.get("github_token")||""),github_oauth_client_id:String(Y.get("github_oauth_client_id")||""),github_host:String(Y.get("github_host")||""),gitlab_token:String(Y.get("gitlab_token")||""),gitlab_host:String(Y.get("gitlab_host")||""),gitlab_oauth_client_id:String(Y.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(Y.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(Y.get("bitbucket_token")||""),bitbucket_username:String(Y.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(Y.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(Y.get("bitbucket_oauth_client_secret")||""),ai_provider:String(Y.get("ai_provider")||"none"),ai_api_key:String(Y.get("ai_api_key")||""),ai_model:String(Y.get("ai_model")||""),ai_base_url:String(Y.get("ai_base_url")||"")},je=k.length?{...ce,workspaces:k.map(Le=>({path:Le.path,name:Le.name}))}:ce;try{V(await Pe.saveSettings(je)),K("Settings saved on this machine")}catch(Le){w(Le instanceof Error?Le.message:String(Le))}},ao=async()=>{if(!(!p||dt.current)){He("Residual analysis…");try{const P=await Pe.residual(p);ke(P.note)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ur=L.useRef(jn);Ur.current=jn;const Yr=L.useRef(t);Yr.current=t;const Wn=L.useRef(!1);Wn.current=st;const Un=L.useRef(p);Un.current=p;const bn=L.useRef(Z);bn.current=Z,L.useEffect(()=>{const P=localStorage.getItem("loadpath.lastReviewId"),Y=(localStorage.getItem("loadpath.repo")||"").trim();if(!P||!Y){sr(!1);return}let ce=!1;return Pe.getReview(Y,P).then(je=>{ce||(yt(je),nn(je.base||localStorage.getItem("loadpath.base")||"HEAD~1",je.head||localStorage.getItem("loadpath.head")||"HEAD"),Hn(Y),ur(Y))}).catch(()=>{}).finally(()=>{ce||sr(!1)}),()=>{ce=!0}},[]);const Bt=L.useRef("");L.useEffect(()=>{if(!Je||!o.trim())return;let P=!1;const Y=async()=>{try{const je=await Pe.workspaceStatus(o);if(P)return;Bt.current&&je.fingerprint!==Bt.current&&!dt.current&&(pe(!0),localStorage.setItem("loadpath.dirty","1"),Ur.current()),Bt.current=je.fingerprint}catch{}};Y();const ce=window.setInterval(Y,2e3);return()=>{P=!0,window.clearInterval(ce)}},[Je,o]),L.useEffect(()=>{const P=Y=>{var Le;if((Y.metaKey||Y.ctrlKey)&&Y.key.toLowerCase()==="k"){Y.preventDefault(),lt(Ie=>!Ie);return}if(Wn.current){Y.key==="Escape"&&(Y.preventDefault(),lt(!1));return}if(Dr.current){Y.key==="Escape"&&(Y.preventDefault(),$e(!1));return}const ce=Y.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){Y.key==="Escape"&&ce.blur();return}if(Y.key==="Escape"){w(""),K(""),Ge(wt),ut(null);return}if(Y.key==="j"||Y.key==="k"){const Ie=((Le=Un.current)==null?void 0:Le.read_order)||[];if(!Ie.length)return;Y.preventDefault();const Gn=bn.current,qr=Y.key==="j"?Math.min(Ie.length-1,Gn+1):Math.max(0,Gn-1);se(qr);return}const je=Zu.find(Ie=>Ie.shortcut===Y.key);if(je&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey&&r(je.id),(Y.metaKey||Y.ctrlKey)&&Y.key==="Enter"){if(Yr.current==="settings"||Yr.current==="prs"||dt.current)return;Y.preventDefault(),Ur.current()}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[wt]);const _i=async(P,Y)=>{if(!o.trim())return;const ce=await kN(o,P,Y);ce.ok?K(ce.message):w(ce.message)},Gr=async()=>{if(p)try{const P=await Pe.exportHtml(p),Y=URL.createObjectURL(P),ce=document.createElement("a");ce.href=Y,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(Y),K("Saved HTML brief")}catch(P){w(P instanceof Error?P.message:String(P))}},fr=async P=>{if(o.trim()){He("Loading stored review…");try{const Y=await Pe.getReview(o,P);yt(Y),nn(Y.base||a,Y.head||c),E("review"),r("review");const ce=Ot.find(je=>je.id!==P);if(ce)try{$n(await Pe.reviewDiff(o,P,ce.id))}catch{$n(null)}}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},hr={selectedId:at,onSelect:Ge,nodeRoles:p==null?void 0:p.node_roles,testOverlay:gt,isolateSource:Pt,onIsolate:ut,repoPath:o,onOpenFile:_i,pinnedId:wt,onPin:qt},Yn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},...p!=null&&p.what_if?[{id:"exit-whatif",group:"Review",label:x?"Back to git-range walk":"Exit what-if walk",run:Vn}]:[],{id:"index",group:"Run",label:"Index repository",run:()=>void Br(!0)},{id:"watch",group:"Run",label:Je?"Stop watching working tree":"Watch working tree",run:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")}},{id:"tests",group:"Graph",label:gt?"Hide test overlay":"Show test overlay",run:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Gr()},...Zu.map(P=>({id:`tab-${P.id}`,group:"Tabs",label:`Go to ${P.label}`,hint:P.shortcut,run:()=>r(P.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(P=>({id:`node-${P.id}`,group:"Nodes",label:P.name,hint:ro(P.type),run:()=>{Ge(P.id),r("graph")}})),...Ot.slice(0,12).map(P=>({id:`hist-${P.id}`,group:"History",label:P.title||P.id,hint:`${P.level||""} ${P.created_at||""}`.trim(),run:()=>void fr(P.id)}))],En=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[b,m,p]),uo=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[b,m,p]),pr=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Fe=((p==null?void 0:p.findings)||[]).filter(P=>!P.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Zu.map(P=>{const Y=P.icon,ce=t===P.id;return d.jsxs("button",{type:"button","data-testid":P.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":P.label,onClick:()=>r(P.id),children:[d.jsx(Y,{}),d.jsx("span",{children:P.label})]},P.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:ve,onChange:P=>Sn(P.target.value),children:["dark","light"].map(P=>d.jsx("optgroup",{label:P==="dark"?"Dark":"Light",children:Ul.filter(Y=>Y.group===P).map(Y=>d.jsx("option",{value:Y.id,children:Y.label},Y.id))},P))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:N||pr}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[N?d.jsxs("div",{className:$!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","aria-valuemin":$!=null?0:void 0,"aria-valuemax":$!=null?100:void 0,"aria-valuenow":$??void 0,"data-testid":"progress",children:[d.jsx("i",{style:$!=null?{width:`${$}%`}:void 0}),d.jsx("span",{className:"sr-only",children:N})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[k.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:k.some(P=>P.path===o)?o:"",disabled:!!N,"aria-busy":G,onChange:P=>{P.target.value&&Hr(P.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),k.map(P=>d.jsxs("option",{value:P.path,children:[P.name,P.indexed?` (${P.counts.nodes})`:""]},P.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:P=>{const Y=P.target.value;s(Y),Y.trim()!==_t.current&&(_t.current="",Ft(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>$e(!0),children:d.jsx(bp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(Sp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:P=>nn(P,c),placeholder:"base",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(Sp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:P=>nn(a,P),placeholder:"head",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:he?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":he,onClick:()=>{const P=!he;pe(P),localStorage.setItem("loadpath.dirty",P?"1":"0")},children:he?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:Je?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":Je,onClick:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")},children:Je?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.what_if?"what-if · ":"",p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!N,onClick:xi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!N,onClick:()=>Br(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!N,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[R?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:R}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,ne?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:ne}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>K(""),"aria-label":"Dismiss",children:"×"})]}):null,((co=p==null?void 0:p.index)!=null&&co.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((fo=p==null?void 0:p.index)==null?void 0:fo.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Si=p==null?void 0:p.index)==null?void 0:Si.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(ho=p==null?void 0:p.workspace)!=null&&ho.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,p!=null&&p.what_if?d.jsxs("div",{className:"banner whatif","data-testid":"whatif-banner",children:[d.jsxs("span",{children:["Hypothetical walk from"," ",d.jsx("strong",{children:((po=p.node)==null?void 0:po.name)||"this node"}),". Loadpath ignored Base/Head and asked which sinks would feel this node change — not a filter of the current map."]}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-exit-whatif",onClick:Vn,children:x?"Back to git range":"Back to architecture"})]}):null,G?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:N||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":G||te,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(DN,{review:p,findings:Fe,aiNote:me,busy:!!N,tourIndex:Z,onTour:se,onAskAi:ao,onCopy:Ve,onPost:so,onSelect:Ge,onOpenFile:_i,onExport:Gr,history:Ot,diff:io,onReopen:fr,onWaiver:(P,Y)=>{o.trim()&&Pe.addWaiver(o,P,Y||void 0,"from review").then(ce=>{or(ce),K(`Waived ${P} in loadpath.yml`)})}}):zr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Qu,{nodes:p.nodes,edges:p.edges,onWhatIf:dr,focusPath:(go=p.read_order[Z])==null?void 0:go.path,...hr}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(ON,{architecture:m,busy:!!N,onReindex:()=>Br(!1),onReview:jn,onSelect:Ge,config:vi,health:$r,onSaveConfig:P=>{Pe.saveConfig(o,P).then(Y=>{or(Y),K("Wrote loadpath.yml")})},onWaiver:(P,Y,ce)=>{Pe.addWaiver(o,P,Y,ce).then(je=>{or(je),K(`Waived ${P}`)})}}):G?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(te||m!=null&&m.graph_pending)&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(ki=m==null?void 0:m.counts)!=null&&ki.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Qu,{nodes:m.nodes,edges:m.edges,onWhatIf:dr,...hr,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":b==="review","data-testid":"graph-mode-review",className:b==="review"?"active":"",onClick:()=>E("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":b==="architecture","data-testid":"graph-mode-architecture",className:b==="architecture"?"active":"",onClick:()=>E("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:gt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":gt,onClick:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")},children:"Tests"})]}),En.length?d.jsx(Qu,{nodes:En,edges:uo,onWhatIf:dr,...hr}):te||m!=null&&m.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:z,onChange:P=>Fr(P.target.value,H,oe),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:M.length?"Search your repos":"owner/repo",value:H,onChange:P=>Fr(z,P.target.value,oe),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:M.map(P=>d.jsxs("option",{value:P.slug,children:[P.private?"private":"public",P.local_path?" · local":""]},P.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!N||!oo(z),onClick:()=>{It(z)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!N,onClick:Vr,children:"List PRs"})]}),M.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[M.length," ",z," repositor",M.length===1?"y":"ies",z==="github"&&C.github_user?` · @${String(C.github_user)}`:"",z==="gitlab"&&C.gitlab_user?` · @${String(C.gitlab_user)}`:"",z==="bitbucket"&&C.bitbucket_user?` · ${String(C.bitbucket_user)}`:""]}):null,W.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):W.map(P=>{var Y;return d.jsxs("article",{className:"pr","data-testid":`pr-${P.number}`,children:[d.jsxs("h3",{children:["#",P.number," ",P.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${P.draft?"":"open"}`,children:P.draft?"draft":P.state}),d.jsx("span",{children:P.author}),d.jsxs("span",{children:[P.source_branch," → ",P.target_branch]}),P.loadpath?d.jsxs("span",{className:`chip ${P.loadpath.level||""}`,"data-testid":`pr-loadpath-${P.number}`,children:[((Y=P.loadpath.level)==null?void 0:Y.toUpperCase())||"REVIEWED",P.loadpath.contract_break&&P.loadpath.contract_break!=="none"?` · ${P.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:P.url,target:"_blank",rel:"noreferrer",children:["Open on ",P.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${P.number}`,onClick:()=>void bt(P),children:"Review this PR"})]})]},`${P.provider}-${P.number}`)})]}),t==="settings"&&Ne&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Et,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Ul.map(P=>d.jsxs("button",{type:"button","data-theme":P.id,className:ve===P.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${P.id}`,onClick:()=>Sn(P.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:P.label}),d.jsx("div",{className:"group",children:P.group})]},P.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:xm(),onChange:P=>SN(P.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:C.github_token_set?C.github_user?`Signed in as @${String(C.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void Wr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!ct||!C.github_oauth_ready,onClick:()=>void wi(),children:ct?"Waiting for GitHub…":"Sign in with GitHub"})})]}),ct?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:ct.user_code})," at GitHub if the browser did not fill it in."]}):null,C.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(C.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(C.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:C.gitlab_token_set?C.gitlab_user?`Signed in as @${String(C.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void Wr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Fn||!C.gitlab_oauth_ready,onClick:()=>void lo(),children:Fn?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(C.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(C.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:C.bitbucket_token_set?C.bitbucket_user?`Signed in as ${String(C.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void Wr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:On||!C.bitbucket_oauth_ready,onClick:()=>void cr(),children:On?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),C.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(C.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(C.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((Xr=C.ai)==null?void 0:Xr.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((rn=C.ai)==null?void 0:rn.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((on=C.ai)==null?void 0:on.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(d0,{open:st,actions:Yn,onClose:()=>lt(!1)}),Te?d.jsx(MN,{initialPath:o,onClose:()=>$e(!1),onSelect:P=>{if(dt.current){w("Wait for the current job to finish before switching workspace.");return}$e(!1),Hr(P)}}):null]})}function DN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:v,onOpenFile:x,onExport:y,history:m,diff:_,onReopen:k,onWaiver:j}){var E,R,w,N,A,$,F,G,q,te,ee,ne,K,C,V,W,U;const b=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),b.length?d.jsx("ul",{className:"reasons",children:b.map(M=>d.jsx("li",{children:M},M))}):null,t.what_if?d.jsx("span",{className:"chip whatif","data-testid":"whatif-chip",children:"what-if"}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Qo(M)},M)),(E=t.contract_break)!=null&&E.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>j(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(R=t.workspace)!=null&&R.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>x(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(km,{cards:t.deepening}),(N=(w=t.contract_break)==null?void 0:w.reasons)!=null&&N.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),($=(A=t.contract_break.sides)==null?void 0:A.rows)!=null&&$.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(F=t.auth)!=null&&F.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(G=t.suggested_tests)==null?void 0:G.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(q=t.trend)!=null&&q.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",ec(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),m.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:m.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,m.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>k(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?ec(M.created_at):""})]},M.id))]}):null,(ee=(te=t.evolution)==null?void 0:te.notes)!=null&&ee.length||(K=(ne=t.evolution)==null?void 0:ne.hotspots)!=null&&K.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((C=t.evolution)==null?void 0:C.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((V=t.evolution)==null?void 0:V.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:y,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",disabled:s||!!t.what_if,title:t.what_if?"Hypothetical walks are not posted to a pull request":void 0,onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(W=t.codeowners_reviewers)!=null&&W.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function ON({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var x;const v=t.findings.filter(y=>!y.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${ec(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(y=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y.name})," — ",(y.django_apps||[]).join(", ")||"no apps"," ·"," ",(y.owners||[]).join(", ")||"unowned"]},y.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(y=>d.jsx("div",{className:"muted",children:y},y))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:v.length})]}),v.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):v.map(y=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>y.node_id&&a(y.node_id),children:[d.jsx("span",{className:`chip ${y.severity}`,children:y.severity}),y.message]})},y.rule+y.message))]}),d.jsx(km,{cards:t.deepening}),(x=c==null?void 0:c.points)!=null&&x.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(y=>d.jsx("i",{className:y.level||"",title:`${y.level} · ${y.findings} findings`,style:{height:`${8+Math.min(24,(y.findings||0)*4)}px`}},y.id||y.created_at))}),Object.entries(c.contexts).map(([y,m])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y})," — last ",((_=m[m.length-1])==null?void 0:_.findings)??0," findings"]},y)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(f0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((y,m)=>m[1]-y[1]).slice(0,12).map(([y,m])=>d.jsxs("tr",{children:[d.jsx("td",{children:ro(y)}),d.jsx("td",{children:m})]},y))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function km({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:h0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}Sm(_m());a0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(zN,{})}));export{Bk as L,BN as a,FN as c,d as j,HN as l,L as r,ro as t}; + M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}pm.displayName="MiniMap";const Mk=L.memo(pm),Pk=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Ik={[to.Line]:"right",[to.Handle]:"bottom-right"};function Rk({nodeId:t,position:r,variant:o=to.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:v=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:y=!1,resizeDirection:m,autoScale:_=!0,shouldResize:k,onResizeStart:j,onResize:b,onResizeEnd:E}){const R=Wg(),w=typeof t=="string"?t:R,N=Ye(),A=L.useRef(null),$=o===to.Handle,F=De(L.useCallback(Pk($&&_),[$,_]),Qe),G=L.useRef(null),q=r??Ik[o];L.useEffect(()=>{if(!(!A.current||!w))return G.current||(G.current=J1({domNode:A.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,domNode:W}=N.getState();return{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,paneDomNode:W}},onChange:(ee,ne)=>{const{triggerNodeChanges:K,nodeLookup:C,parentLookup:V,nodeOrigin:W}=N.getState(),U=[],M={x:ee.x,y:ee.y},D=C.get(w);if(D&&D.expandParent&&D.parentId){const H=D.origin??W,I=ee.width??D.measured.width??0,z=ee.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:I,height:z,...pg({x:ee.x??D.position.x,y:ee.y??D.position.y},{width:I,height:z},D.parentId,C,H)}},oe=Pc([ie],C,V,W);U.push(...oe),M.x=ee.x?Math.max(H[0]*I,ee.x):void 0,M.y=ee.y?Math.max(H[1]*z,ee.y):void 0}if(M.x!==void 0&&M.y!==void 0){const H={id:w,type:"position",position:{...M}};U.push(H)}if(ee.width!==void 0&&ee.height!==void 0){const I={id:w,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:ee.width,height:ee.height}};U.push(I)}for(const H of ne){const I={...H,type:"position"};U.push(I)}K(U)},onEnd:({width:ee,height:ne})=>{const K={id:w,type:"dimensions",resizing:!1,dimensions:{width:ee,height:ne}};N.getState().triggerNodeChanges([K])}})),G.current.update({controlPosition:q,boundaries:{minWidth:h,minHeight:p,maxWidth:v,maxHeight:x},keepAspectRatio:y,resizeDirection:m,onResizeStart:j,onResize:b,onResizeEnd:E,shouldResize:k}),()=>{var ee;(ee=G.current)==null||ee.destroy()}},[q,h,p,v,x,y,j,b,E,k]);const te=q.split("-");return d.jsx("div",{className:nt(["react-flow__resize-control","nodrag",...te,o,s]),ref:A,style:{...a,scale:F,...c&&{[$?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Rk);const Tk={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function ia(t){return Tk[t]??8}const Wl=208,as=64,Lk=88,Ak=28,$k=8;function zk(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function gm(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const w of t){const N=ia(w.type),A=s.get(N)??[];A.push(w),s.set(N,A)}const u=[...s.keys()].sort((w,N)=>w-N).map(w=>[...s.get(w)??[]].sort((N,A)=>N.name.localeCompare(A.name)||N.id.localeCompare(A.id))),c=new Set(t.map(w=>w.id)),h=new Map,p=new Map;for(const w of t)h.set(w.id,[]),p.set(w.id,[]);for(const w of r)!c.has(w.src)||!c.has(w.dst)||w.src===w.dst||(p.get(w.src).push(w.dst),h.get(w.dst).push(w.src));const v=new Map;u.forEach((w,N)=>{for(const A of w)v.set(A.id,N)});const x=new Map,y=()=>{for(const w of u)w.forEach((N,A)=>x.set(N.id,A))};y();const m=(w,N)=>{const A=w.map(($,F)=>{const G=N($.id).map(te=>x.get(te)).filter(te=>te!==void 0),q=zk(G);return{n:$,bary:Number.isNaN(q)?F:q,name:$.name,id:$.id}});return A.sort(($,F)=>$.bary-F.bary||$.name.localeCompare(F.name)||$.id.localeCompare(F.id)),A.map($=>$.n)},_=w=>N=>v.get(N)===w;for(let w=0;w<$k;w++){for(let N=1;N(h.get(A)??[]).filter(_(N-1))),y();for(let N=u.length-2;N>=0;N--)u[N]=m(u[N],A=>(p.get(A)??[]).filter(_(N+1))),y()}const k=Wl+Lk,j=as+Ak,b=Math.max(...u.map(w=>w.length),1),E=[];let R=0;for(let w=0;wG.id)),A=new Set((u[w+1]??[]).map(G=>G.id));let $=0;if(A.size)for(const G of r)N.has(G.src)&&A.has(G.dst)&&($+=1);const F=Math.min(48,Math.max(0,($-2)*10));R+=k+F}return u.forEach((w,N)=>{const A=(b-w.length)*j/2;w.forEach(($,F)=>{o.set($.id,{x:E[N]??0,y:A+F*j})})}),o}const Dk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),mm=90,Ok=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),pp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Fk=Math.PI*(3-Math.sqrt(5)),ym=220,Hk=26,Bk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function vm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function FN(t){return pp[t]?pp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Vk(t){return t>=mm?"3d":"2d"}function Wk(t){return t>=mm?"overview":"full"}function Uk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(vm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Ok.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Uk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Gk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function Xk(t,r,o,s){const a=new Set(t.map(j=>j.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const j of r){if(!a.has(j.src)||!a.has(j.dst))continue;const b=u.get(j.src)??[];b.push({dst:j.dst,id:j.id}),u.set(j.src,b);const E=c.get(j.dst)??[];E.push({src:j.src,id:j.id}),c.set(j.dst,E)}const h=new Set(t.filter(j=>Dk.has(j.type)).map(j=>j.id)),p=h.size?h:a,v=new Set,x=[o];for(;x.length;){const j=x.pop();if(!v.has(j)){v.add(j);for(const b of u.get(j)??[])v.has(b.dst)||x.push(b.dst)}}const y=new Set([o]),m=[...p].filter(j=>v.has(j)),_=new Set(m);for(;m.length;){const j=m.pop();y.add(j);for(const b of c.get(j)??[])v.has(b.src)&&!_.has(b.src)&&(_.add(b.src),m.push(b.src))}const k=new Set;for(const j of r)y.has(j.src)&&y.has(j.dst)&&k.add(j.id);return{nodeIds:y,edgeIds:k}}function HN(t){const r=new Map;for(const s of t){const a=ia(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*ym;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Hk*Math.sqrt(h+1),v=h*Fk;o.set(c.id,{x:u,y:p*Math.cos(v),z:p*Math.sin(v)})})}return o}function BN(t){const r=new Map;for(const o of t){const s=ia(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*ym,count:s}))}const bl=16,qk=12,Kk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Qk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),gp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Zk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},mp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],yp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Jk=new Set(["looks_idempotent_on_pk","null","blank"]),eN=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function tN(t){return gp[t]?gp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function nN(t,r,o){const s=new Map(r.map(m=>[m.id,m])),a=[];Kk.has(t.type)&&a.push("sink"),Qk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(m=>m.dst===t.id),h=o.filter(m=>m.src===t.id),p=c.slice(0,bl).map(m=>El(m,s,m.src)),v=h.slice(0,bl).map(m=>El(m,s,m.dst)),x=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,y={type:t.type,typeLabel:Qo(ro(t.type)),layer:Bk[ia(t.type)]??"other",purpose:tN(t.type),name:t.name,qualifiedName:t.qualified_name,file:x,context:t.context,roles:a,facts:iN(u).filter(m=>!(m.key==="app"&&m.value===t.context)),inputs:p,outputs:v,extraInputs:Math.max(0,c.length-bl),extraOutputs:Math.max(0,h.length-bl),degreeIn:c.length,degreeOut:h.length,inputKinds:vp(c.map(m=>El(m,s,m.src))),outputKinds:vp(h.map(m=>El(m,s,m.dst))),pathSummary:""};return y.pathSummary=rN(y),y}function vp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function rN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function El(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Qo(ro(s.type)):"",edgeType:t.type,edgeLabel:Qo(t.type),inferred:t.confidence<.8}}function iN(t){const r=[...mp.filter(a=>a in t),...Object.keys(t).filter(a=>!mp.includes(a)&&!yp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||yp.has(a)||eN.has(a))continue;s.add(a);const u=oN(a,t[a]);u!=null&&o.push({key:a,label:Zk[a]??Qo(a),value:u})}return o}function oN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Jk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return sN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,qk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function sN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const lN=12,xp=.2,aN=.8;function uN(t,r,o){const s=o??gm(t,r),a=[];for(const h of r){const p=s.get(h.src),v=s.get(h.dst);if(!p||!v)continue;const x=p.y+as/2,y=v.y+as/2;if(Math.abs(x-y)${Math.round(_/8)}`})}const u=new Map;for(const h of a){const p=u.get(h.corridor)??[];p.push(h),u.set(h.corridor,p)}const c=new Map;for(const h of u.values()){const p=[...h].sort((x,y)=>x.sourceY-y.sourceY||x.id.localeCompare(y.id)),v=p.length;p.forEach((x,y)=>{c.set(x.id,cN(y,v))})}return c}function cN(t,r){return r<=1?.5:xp+(aN-xp)*t/(r-1)}const dN=new Set,fN=L.lazy(()=>k0(()=>import("./LayeredGraph3D-CRmek7qf.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),hN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function pN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(no,{type:"target",position:Se.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:ro(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Tr(t.name)}),d.jsx(no,{type:"source",position:Se.Right,isConnectable:!1})]})}const gN={load:pN},mN=new Set(["django","react","stitch","arch"]);function yN({id:t,sourceX:r,sourceY:o,targetX:s,targetY:a,sourcePosition:u,targetPosition:c,style:h,markerEnd:p,markerStart:v,label:x,labelStyle:y,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,data:b,interactionWidth:E}){const[R,w,N]=Bl({sourceX:r,sourceY:o,sourcePosition:u,targetX:s,targetY:a,targetPosition:c,borderRadius:8,stepPosition:(b==null?void 0:b.stepPosition)??.5});return d.jsx(ms,{id:t,path:R,labelX:w,labelY:N,label:x,labelStyle:y,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,style:h,markerEnd:p,markerStart:v,interactionWidth:E})}const vN={loadstep:yN};function xN({topologyKey:t}){const{fitView:r}=na();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function wN(t,r,o=null,s={}){const a=new Map(t.map(v=>[v.id,v])),u=gm(t,r),c=uN(t,r,u),h=t.map(v=>{var m;const x=((m=s.roles)==null?void 0:m[v.id])||[],y=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:v.id,type:"load",position:u.get(v.id)??{x:0,y:0},data:{name:v.name,type:v.type,file:v.file_path,roles:x,dim:y},selected:o===v.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:Wl,height:as,style:{width:Wl,height:as}}}),p=r.filter(v=>a.has(v.src)&&a.has(v.dst)).map(v=>{const x=hN[v.weight]||"var(--edge-cheap)",y=!!(o&&(v.src===o||v.dst===o));return{id:v.id,source:v.src,target:v.dst,type:"loadstep",animated:v.weight==="critical",data:{stepPosition:c.get(v.id)??.5},style:{stroke:x,strokeWidth:v.weight==="critical"?2.4:1.2,strokeDasharray:v.confidence<.8?"6 4":void 0},markerEnd:{type:is.ArrowClosed,width:14,height:14,color:x},label:y?v.type.replaceAll("_"," "):void 0,labelStyle:y?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:y?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:y?[3,5]:void 0,labelBgBorderRadius:y?4:void 0}});return{rfNodes:h,rfEdges:p}}function _N({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:v}){const x=nN(t,r,o);return L.useEffect(()=>{const y=m=>{m.key==="Escape"&&s()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:x.typeLabel}),d.jsx("div",{className:"inspector-roles",children:x.roles.map(y=>d.jsx("span",{className:"inspector-chip",children:y},y))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Tr(x.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:x.purpose}),x.context?d.jsx("div",{className:"muted",children:Tr(x.context)}):null,x.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Tr(x.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Tr(x.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",x.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[x.degreeIn," in · ",x.degreeOut," out"]}),x.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:x.pathSummary}):null,x.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:x.facts.map(y=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:y.label}),d.jsx("dd",{children:Tr(y.value)})]},y.key))}):null,d.jsx(wp,{title:"Inputs",testId:"graph-inspector-inputs",links:x.inputs,extra:x.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(wp,{title:"Outputs",testId:"graph-inspector-outputs",links:x.outputs,extra:x.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),a?d.jsx("p",{className:"whatif-hint","data-testid":"whatif-hint",children:v?"Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map.":"Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."}):null,d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",title:"Start a hypothetical walk from this node. Does not use Base/Head.",onClick:()=>a(t.id),children:"What if this changes"}):null,v?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",title:"Hide nodes that are not on a path from here to a sink. Does not start a new walk.",onClick:()=>v(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function wp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Qu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:v,repoPath:x,onOpenFile:y,pinnedId:m,onPin:_}){const[k,j]=L.useState(null),b=a!==void 0?a:k,E=re=>{a===void 0&&j(re),u==null||u(re)},[R,w]=L.useState(null),[N,A]=L.useState(null),[$,F]=L.useState(new Set(mN)),[G,q]=L.useState(!1),[te,ee]=L.useState(""),[ne,K]=L.useState(!1),C=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,V=R??Vk(t.length),W=N??Wk(t.length),U=G?b:null,M=L.useMemo(()=>p?Xk(t,r,p):null,[t,r,p]),D=M?t.filter(re=>M.nodeIds.has(re.id)):t,H=M?r.filter(re=>M.edgeIds.has(re.id)):r,I=L.useMemo(()=>Yk(D,H,{detail:W,families:$,focusId:U,neighborhoodOnly:!!U}),[D,H,W,$,U]),z=L.useMemo(()=>`${I.nodes.map(re=>re.id).join("\0")}|${I.edges.map(re=>re.id).join("\0")}`,[I.nodes,I.edges]),ie=b?t.find(re=>re.id===b)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const re=wN(I.nodes,I.edges,b,{roles:c,testOverlay:h});return C&&(re.rfEdges=re.rfEdges.map(Ne=>({...Ne,animated:!1}))),re},[I.nodes,I.edges,b,C,c,h]);L.useEffect(()=>{if(!s)return;const re=t.find(Ne=>Ne.file_path===s);re&&E(re.id)},[s,t]);const he=L.useMemo(()=>Gk(t,te),[t,te]),pe=(re,Ne)=>{E(Ne.id)},Z=()=>{E(null),q(!1)},se=ie?d.jsx(_N,{node:ie,nodes:t,edges:r,onClose:Z,onWhatIf:o,onSelect:E,onOpenFile:y,pinned:m===ie.id,onPin:_,onIsolate:v?re=>{v(p===re?null:re)}:void 0}):null,me=re=>{F(Ne=>{const Me=new Set(Ne);if(Me.has(re)){if(Me.size===1)return Ne;Me.delete(re)}else Me.add(re);return Me})},ke=L.useMemo(()=>{const re=new Set;for(const Ne of t)re.add(vm(Ne.type));return re},[t]),ve=t.length-I.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:V==="2d"?"active":"","aria-pressed":V==="2d",onClick:()=>w("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:V==="3d"?"active":"","aria-pressed":V==="3d",onClick:()=>w("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:W==="overview"?"active":"","aria-pressed":W==="overview",onClick:()=>A("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:W==="full"?"active":"","aria-pressed":W==="full",onClick:()=>A("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(re=>ke.has(re)).map(re=>d.jsx("button",{type:"button","data-testid":`graph-family-${re}`,className:$.has(re)?"active":"","aria-pressed":$.has(re),onClick:()=>me(re),children:re},re))}),d.jsx("button",{type:"button",className:G?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!b,onClick:()=>q(re=>!re),children:G?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>v==null?void 0:v(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:te,onChange:re=>{ee(re.target.value),K(!0)},onFocus:()=>K(!0),onBlur:()=>window.setTimeout(()=>K(!1),150)}),ne&&te.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(re=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:Ne=>Ne.preventDefault(),onClick:()=>{E(re.id),ee(""),K(!1)},children:[re.name,d.jsx("span",{className:"muted",children:ro(re.type)})]})},re.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[I.nodes.length," nodes · ",I.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:V==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(fN,{nodes:I.nodes,edges:I.edges,selectedId:b,neighborIds:U?I.neighborIds:dN,onSelect:re=>{E(re),re||q(!1)}})}),se]}):d.jsxs(dm,{children:[d.jsxs(rk,{nodes:oe,edges:fe,nodeTypes:gN,edgeTypes:vN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:Z,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(xN,{topologyKey:z}),d.jsx(ak,{}),d.jsx(Mk,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(gk,{})]}),se]})})]})}function xm(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function SN(t){localStorage.setItem("loadpath.editor",t)}async function kN(t,r,o,s=xm()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const _p=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],NN=["preset","branch","tag","commit"];function jN(t){var a;if(!(t!=null&&t.git))return[..._p];const r=((a=t.presets)!=null&&a.length?t.presets:_p.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function bN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function EN(t){return NN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function CN(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function Sp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[v,x]=L.useState(!1),[y,m]=L.useState(null),[_,k]=L.useState(0),j=L.useMemo(()=>{const N=jN(u);return y===null?N:bN(N,y)},[u,y]),b=L.useMemo(()=>EN(j),[j]);L.useEffect(()=>{v&&c()},[v,c]),L.useEffect(()=>{k(0)},[y,v]);const E=()=>{x(!1),m(null)},R=N=>{r(N.value),E()},w=N=>{if(N.key==="ArrowDown"){if(N.preventDefault(),!v){x(!0);return}k(A=>Math.min(A+1,Math.max(j.length-1,0)))}else if(N.key==="ArrowUp"){if(N.preventDefault(),!v)return;k(A=>Math.max(A-1,0))}else if(N.key==="Enter"&&v){N.preventDefault();const A=j[_];A&&R(A)}else N.key==="Escape"&&v&&(N.preventDefault(),E())};return d.jsxs("div",{className:"combo",ref:p,onBlur:N=>{N.currentTarget.contains(N.relatedTarget)||E()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":v,"aria-controls":h,"aria-autocomplete":"list",onChange:N=>{r(N.target.value),v&&m(N.target.value)},onKeyDown:w}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":v,onMouseDown:N=>N.preventDefault(),onClick:()=>v?E():x(!0),children:d.jsx(w0,{})})]}),v?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:b.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):b.map(N=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:CN(N.group)}),N.items.map(A=>{const $=j.indexOf(A);return d.jsxs("button",{type:"button",role:"option","aria-selected":$===_,className:$===_?"combo-option active":"combo-option","data-testid":`ref-option-${A.group}`,onMouseDown:F=>F.preventDefault(),onMouseEnter:()=>k($),onClick:()=>R(A),children:[d.jsx("span",{className:"combo-label",children:A.label}),A.detail?d.jsx("span",{className:"combo-detail",children:A.detail}):null]},`${A.group}:${A.value}`)})]},N.group))}):null]})}function MN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[v,x]=L.useState(""),[y,m]=L.useState(!1),_=L.useRef(null),k=L.useRef(0),j=async w=>{const N=k.current+1;k.current=N,m(!0);try{const A=await Pe.browse(w);if(k.current!==N)return;a(A),c(A.path),p(A.is_git?A.path:null),x("")}catch(A){if(k.current!==N)return;x(A instanceof Error?A.message:String(A))}finally{k.current===N&&m(!1)}};L.useEffect(()=>{var w,N;j(t),(w=_.current)==null||w.focus(),(N=_.current)==null||N.select()},[t]);const b=h||(s==null?void 0:s.path)||u,E=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",R=w=>{w.key==="Escape"&&(w.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:R,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:w=>w.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:w=>{w.preventDefault(),j(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:w=>c(w.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),v?d.jsx("div",{className:"error",role:"alert",children:v}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":y,children:s!=null&&s.entries.length?s.entries.map(w=>{const N=h===w.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":N,className:N?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":w.path,onClick:()=>p(w.path),onDoubleClick:()=>void j(w.path),children:[d.jsx(bp,{}),d.jsx("span",{className:"explorer-name",children:w.name}),w.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},w.path)}):d.jsx("div",{className:"muted explorer-empty",children:y?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:b,children:b}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!b,onClick:()=>b&&r(b),children:["Use ",E]})]})]})})}const PN={scan:{start:0,end:20},extract:{start:20,end:88},boot:{start:88,end:94},stitch:{start:94,end:99},skipped:{start:100,end:100},done:{start:100,end:100}},IN=new Set(["scan","extract","boot","stitch"]);function RN(t){const r=t.phase||"";if(!r||r==="idle")return null;const o=PN[r];if(!o)return null;if(o.start===o.end)return o.end;const s=t.total||0;if(s<=0)return o.start;const a=Math.min(1,Math.max(0,(t.done||0)/s));return Math.round(o.start+(o.end-o.start)*a)}function TN(t){return!t.phase||t.phase==="idle"?null:typeof t.percent=="number"&&Number.isFinite(t.percent)?Math.max(0,Math.min(100,Math.round(t.percent))):RN(t)}const Ul=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],LN="obsidian",wm="loadpath.theme";function AN(t){return Ul.some(r=>r.id===t)}function _m(){try{const t=localStorage.getItem(wm)||"";if(AN(t))return t}catch{}return LN}function $N(t){var r;return((r=Ul.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function Sm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=$N(t);try{localStorage.setItem(wm,t)}catch{}}const Zu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:g0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:m0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:y0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:v0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:x0}];function Ju(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function zN(){var co,fo,Si,ho,po,go,ki,Xr,rn,on;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,v]=L.useState(null),[x,y]=L.useState(null),[m,_]=L.useState(null),[k,j]=L.useState([]),[b,E]=L.useState("review"),[R,w]=L.useState(""),[N,A]=L.useState(""),[$,F]=L.useState(null),[G,q]=L.useState(!1),[te,ee]=L.useState(!1),[ne,K]=L.useState(""),[C,V]=L.useState({}),[W,U]=L.useState([]),[M,D]=L.useState([]),[H,I]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[z,ie]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[oe,fe]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[he,pe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[Z,se]=L.useState(0),[me,ke]=L.useState(""),[ve,re]=L.useState(_m),[Ne,Me]=L.useState(!1),[Te,$e]=L.useState(!1),[st,lt]=L.useState(!1),[at,Ge]=L.useState(null),[wt,qt]=L.useState(null),[gt,mt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[Pt,ut]=L.useState(null),[Je,An]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[Ot,xn]=L.useState([]),[io,$n]=L.useState(null),[vi,or]=L.useState(null),[$r,zn]=L.useState(null),[zr,sr]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[lr,Ft]=L.useState(null),[ct,Dn]=L.useState(null),[On,wn]=L.useState(!1),[Fn,_n]=L.useState(!1),rt=L.useRef(o);rt.current=o;const Dr=L.useRef(!1);Dr.current=Te;const _t=L.useRef(""),ar=L.useRef(""),Sn=P=>{re(P),Sm(P)},dt=L.useRef(""),He=P=>{dt.current=P,A(P)},kn=P=>{let Y=0,ce=!1;F(0);const je=()=>{Pe.indexProgress(P).then(Ie=>{if(!dt.current)return;if(Ie.phase&&Ie.phase!=="idle"&&Ie.message&&He(Ie.message),IN.has(Ie.phase))ce=!0;else if(!ce)return;const qr=TN(Ie);qr!=null&&(Ie.phase==="scan"&&!Ie.done?Y=qr:Y=Math.max(Y,qr),F(Y))}).catch(()=>{})};je();const Le=window.setInterval(je,250);return()=>{window.clearInterval(Le),F(null)}};L.useEffect(()=>{Pe.settings().then(V).catch(()=>{}).finally(()=>Me(!0)),Pe.repos().then(P=>j(P.repos)).catch(()=>{})},[]);const Nn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const P=o;let Y=!1;return ar.current!==P&&Bn(P),Pe.config(P).then(ce=>{!Y&&rt.current===P&&or(ce)}).catch(()=>{}),Pe.architectureHealth(P).then(ce=>{!Y&&rt.current===P&&zn(ce)}).catch(()=>{}),()=>{Y=!0}},[t,o]);const Ht=P=>{rt.current=P,s(P),localStorage.setItem("loadpath.repo",P),P.trim()!==_t.current&&(_t.current="",Ft(null))},Or=L.useCallback(P=>{const Y=(P??rt.current).trim();return!Y||_t.current===Y?Promise.resolve():(_t.current=Y,Pe.gitRefs(Y).then(ce=>{rt.current.trim()===Y&&Ft(ce)}).catch(()=>{_t.current===Y&&(_t.current="",Ft(null))}))},[]),nn=(P,Y)=>{u(P),h(Y),localStorage.setItem("loadpath.base",P),localStorage.setItem("loadpath.head",Y)},Fr=(P,Y,ce)=>{ie(P),I(Y),localStorage.setItem("loadpath.provider",P),localStorage.setItem("loadpath.scmRepo",Y),ce!==void 0&&(fe(ce),localStorage.setItem("loadpath.prNumber",ce))},yt=P=>{v(P),se(0),Ge(wt&&P.nodes.some(Y=>Y.id===wt)?wt:null),ut(null),$n(null),P.what_if||(y(P),P.id&&localStorage.setItem("loadpath.lastReviewId",P.id))},Hn=async P=>{try{const Y=await Pe.reviews(P);xn(Y.reviews)}catch{xn([])}},ur=async P=>{try{zn(await Pe.architectureHealth(P))}catch{zn(null)}},oo=P=>P==="github"?!!C.github_token_set:P==="gitlab"?!!C.gitlab_token_set:!!C.bitbucket_token_set,It=L.useCallback(async(P=z)=>{var Y;try{const ce=await Pe.scmRepos(P);D(ce.repos),(Y=ce.user)!=null&&Y.login&&V(je=>({...je,...P==="github"?{github_user:ce.user.login}:P==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{D([])}},[z]);L.useEffect(()=>{if(t!=="prs")return;let P=!1;return It(z).catch(()=>{P||D([])}),()=>{P=!0}},[t,z,It]),L.useEffect(()=>{if(!ct)return;let P=!1,Y=0;const ce=async()=>{try{const je=await Pe.githubOAuthPoll(ct.flow_id);if(P)return;if(je.status==="complete"){Dn(null);const Le=await Pe.settings();V(Le),K(je.user?`Signed in to GitHub as ${je.user}`:"Signed in to GitHub"),It("github");return}if(je.status==="pending"||je.status==="slow_down"){Y=window.setTimeout(ce,Math.max(je.interval||ct.interval,5)*1e3);return}Dn(null),w(je.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(je){if(P)return;Dn(null),w(je instanceof Error?je.message:String(je))}};return Y=window.setTimeout(ce,Math.max(ct.interval,5)*1e3),()=>{P=!0,window.clearTimeout(Y)}},[ct,It]),L.useEffect(()=>{if(!On)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.bitbucket.connected){wn(!1);const Ie=await Pe.settings();V(Ie),K(Le.bitbucket.user?`Signed in to Bitbucket as ${Le.bitbucket.user}`:"Signed in to Bitbucket"),It("bitbucket");return}if(Date.now()-ce>18e4){wn(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;wn(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[On,It]),L.useEffect(()=>{if(!Fn)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.gitlab.connected){_n(!1);const Ie=await Pe.settings();V(Ie),K(Le.gitlab.user?`Signed in to GitLab as ${Le.gitlab.user}`:"Signed in to GitLab"),It("gitlab");return}if(Date.now()-ce>18e4){_n(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;_n(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[Fn,It]);const Bn=async(P=o,Y=!1)=>{if(!P.trim())return null;ar.current=P,ee(!0);try{const ce=await Pe.architecture(P,!1);rt.current===P&&_(ce);const je=Pe.architectureGraph(P).then(Le=>{rt.current===P&&_(Ie=>Ie&&{...Ie,nodes:Le.nodes,edges:Le.edges,graph_pending:!1})});return je.catch(()=>{}).finally(()=>{rt.current===P&&ee(!1)}),Y&&await je,ce}catch(ce){throw rt.current===P&&ee(!1),ce}},Hr=async P=>{const Y=P.trim();if(!(!Y||Y===rt.current)){if(dt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),K(""),v(null),y(null),_(null),E("architecture"),Ht(Y),q(!0),He(`Loading ${p0(Y)}…`);try{await Promise.all([Bn(Y),Or(Y)])}catch(ce){rt.current===Y&&w(ce instanceof Error?ce.message:String(ce))}finally{rt.current===Y&&(He(""),q(!1))}}},jn=async()=>{if(dt.current||!Nn())return;w(""),K(""),He("Tracing load path…"),Ht(o),nn(a,c);const P=kn(o);try{const Y=await Pe.review(o,a,c,!0,he);yt(Y),E("review"),r("review"),await Pe.repos().then(ce=>j(ce.repos)).catch(()=>{}),await Promise.all([Bn(o),Hn(o),ur(o)])}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{P(),He("")}},Br=async(P=!0)=>{if(dt.current||!Nn())return;w(""),K(""),He(P?"Indexing…":"Full reindex…"),Ht(o);const Y=kn(o);try{await Pe.index(o,P);const ce=await Bn(o);await Pe.repos().then(je=>j(je.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(E("architecture"),r("architecture"))}catch(ce){w(ce instanceof Error?ce.message:String(ce))}finally{Y(),He("")}},xi=async()=>{if(!dt.current&&Nn()){w(""),K(""),He("Detecting layout…"),Ht(o);try{const P=await Pe.init(o);K(P.message),await Pe.repos().then(Y=>j(Y.repos)).catch(()=>{})}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ve=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),K("Copied markdown brief")}catch(P){w(P instanceof Error?P.message:String(P))}},so=async()=>{if(!dt.current){if(p!=null&&p.what_if){w("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first.");return}if(!(p!=null&&p.markdown)||!H||!oe){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const P=await Pe.postComment(z,H,Number(oe),p.markdown);K(P.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Vr=async()=>{if(!dt.current){w(""),He("Fetching pull requests…");try{const P=await Pe.prs(z,H,"open",o.trim()||void 0);U(P.pull_requests);const Y=M.find(ce=>ce.slug.toLowerCase()===H.trim().toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},wi=async()=>{w("");try{const P=await Pe.githubOAuthStart();Dn(P),Ju(P.verification_uri_complete,"github.com","/login/device")}catch(P){w(P instanceof Error?P.message:String(P))}},cr=async()=>{w("");try{const P=await Pe.bitbucketOAuthStart();wn(!0),Ju(P.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(P){wn(!1),w(P instanceof Error?P.message:String(P))}},lo=async()=>{w("");try{const P=await Pe.gitlabOAuthStart();_n(!0),Ju(P.authorize_url,new URL(P.authorize_url).hostname,"/oauth/authorize")}catch(P){_n(!1),w(P instanceof Error?P.message:String(P))}},dr=async P=>{if(!(dt.current||!o.trim())){w(""),He("Walking what-if path…");try{const Y=await Pe.whatIf(o,P);K(`${Y.title} — ${Y.confidence.level} · ${(Y.sinks||[]).length} sinks`),yt({...Y,markdown:Y.markdown||"",index:Y.index||(p==null?void 0:p.index),workspace:Y.workspace||(p==null?void 0:p.workspace)}),E("review"),r("review")}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},Vn=()=>{if(x){yt(x),E("review"),r("review"),K("Restored the last git-range walk");return}v(null),se(0),Ge(null),ut(null),$n(null),E("architecture"),r("architecture"),K("")},bt=async P=>{var Le;if(dt.current)return;Fr(P.provider,P.repo,String(P.number));const Y=M.find(Ie=>Ie.slug.toLowerCase()===P.repo.toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path),w(""),He(`Fetching ${P.provider} #${P.number}…`);const ce=(Y==null?void 0:Y.local_path)||o,je=ce?kn(ce):()=>{};try{const Ie=await Pe.reviewPr(P.provider,P.repo,P.number,(Y==null?void 0:Y.local_path)||o||void 0);yt(Ie),Ie.pull_request&&typeof Ie.pull_request.repo_path=="string"&&Ht(Ie.pull_request.repo_path),nn(String(Ie.base||P.target_branch),String(Ie.head||P.source_branch)),E("review"),r("review"),typeof((Le=Ie.pull_request)==null?void 0:Le.repo_path)=="string"&&Hn(Ie.pull_request.repo_path)}catch(Ie){nn(P.base_sha||P.target_branch,P.head_sha||P.source_branch),r("review"),w(Ie instanceof Error?Ie.message:String(Ie))}finally{je(),He("")}},Wr=async P=>{w("");try{V(await Pe.oauthDisconnect(P)),z===P&&D([]),K(`Disconnected ${P}`)}catch(Y){w(Y instanceof Error?Y.message:String(Y))}},Et=async P=>{P.preventDefault();const Y=new FormData(P.currentTarget),ce={github_token:String(Y.get("github_token")||""),github_oauth_client_id:String(Y.get("github_oauth_client_id")||""),github_host:String(Y.get("github_host")||""),gitlab_token:String(Y.get("gitlab_token")||""),gitlab_host:String(Y.get("gitlab_host")||""),gitlab_oauth_client_id:String(Y.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(Y.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(Y.get("bitbucket_token")||""),bitbucket_username:String(Y.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(Y.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(Y.get("bitbucket_oauth_client_secret")||""),ai_provider:String(Y.get("ai_provider")||"none"),ai_api_key:String(Y.get("ai_api_key")||""),ai_model:String(Y.get("ai_model")||""),ai_base_url:String(Y.get("ai_base_url")||"")},je=k.length?{...ce,workspaces:k.map(Le=>({path:Le.path,name:Le.name}))}:ce;try{V(await Pe.saveSettings(je)),K("Settings saved on this machine")}catch(Le){w(Le instanceof Error?Le.message:String(Le))}},ao=async()=>{if(!(!p||dt.current)){He("Residual analysis…");try{const P=await Pe.residual(p);ke(P.note)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ur=L.useRef(jn);Ur.current=jn;const Yr=L.useRef(t);Yr.current=t;const Wn=L.useRef(!1);Wn.current=st;const Un=L.useRef(p);Un.current=p;const bn=L.useRef(Z);bn.current=Z,L.useEffect(()=>{const P=localStorage.getItem("loadpath.lastReviewId"),Y=(localStorage.getItem("loadpath.repo")||"").trim();if(!P||!Y){sr(!1);return}let ce=!1;return Pe.getReview(Y,P).then(je=>{ce||(yt(je),nn(je.base||localStorage.getItem("loadpath.base")||"HEAD~1",je.head||localStorage.getItem("loadpath.head")||"HEAD"),Hn(Y),ur(Y))}).catch(()=>{}).finally(()=>{ce||sr(!1)}),()=>{ce=!0}},[]);const Bt=L.useRef("");L.useEffect(()=>{if(!Je||!o.trim())return;let P=!1;const Y=async()=>{try{const je=await Pe.workspaceStatus(o);if(P)return;Bt.current&&je.fingerprint!==Bt.current&&!dt.current&&(pe(!0),localStorage.setItem("loadpath.dirty","1"),Ur.current()),Bt.current=je.fingerprint}catch{}};Y();const ce=window.setInterval(Y,2e3);return()=>{P=!0,window.clearInterval(ce)}},[Je,o]),L.useEffect(()=>{const P=Y=>{var Le;if((Y.metaKey||Y.ctrlKey)&&Y.key.toLowerCase()==="k"){Y.preventDefault(),lt(Ie=>!Ie);return}if(Wn.current){Y.key==="Escape"&&(Y.preventDefault(),lt(!1));return}if(Dr.current){Y.key==="Escape"&&(Y.preventDefault(),$e(!1));return}const ce=Y.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){Y.key==="Escape"&&ce.blur();return}if(Y.key==="Escape"){w(""),K(""),Ge(wt),ut(null);return}if(Y.key==="j"||Y.key==="k"){const Ie=((Le=Un.current)==null?void 0:Le.read_order)||[];if(!Ie.length)return;Y.preventDefault();const Gn=bn.current,qr=Y.key==="j"?Math.min(Ie.length-1,Gn+1):Math.max(0,Gn-1);se(qr);return}const je=Zu.find(Ie=>Ie.shortcut===Y.key);if(je&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey&&r(je.id),(Y.metaKey||Y.ctrlKey)&&Y.key==="Enter"){if(Yr.current==="settings"||Yr.current==="prs"||dt.current)return;Y.preventDefault(),Ur.current()}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[wt]);const _i=async(P,Y)=>{if(!o.trim())return;const ce=await kN(o,P,Y);ce.ok?K(ce.message):w(ce.message)},Gr=async()=>{if(p)try{const P=await Pe.exportHtml(p),Y=URL.createObjectURL(P),ce=document.createElement("a");ce.href=Y,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(Y),K("Saved HTML brief")}catch(P){w(P instanceof Error?P.message:String(P))}},fr=async P=>{if(o.trim()){He("Loading stored review…");try{const Y=await Pe.getReview(o,P);yt(Y),nn(Y.base||a,Y.head||c),E("review"),r("review");const ce=Ot.find(je=>je.id!==P);if(ce)try{$n(await Pe.reviewDiff(o,P,ce.id))}catch{$n(null)}}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},hr={selectedId:at,onSelect:Ge,nodeRoles:p==null?void 0:p.node_roles,testOverlay:gt,isolateSource:Pt,onIsolate:ut,repoPath:o,onOpenFile:_i,pinnedId:wt,onPin:qt},Yn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},...p!=null&&p.what_if?[{id:"exit-whatif",group:"Review",label:x?"Back to git-range walk":"Exit what-if walk",run:Vn}]:[],{id:"index",group:"Run",label:"Index repository",run:()=>void Br(!0)},{id:"watch",group:"Run",label:Je?"Stop watching working tree":"Watch working tree",run:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")}},{id:"tests",group:"Graph",label:gt?"Hide test overlay":"Show test overlay",run:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Gr()},...Zu.map(P=>({id:`tab-${P.id}`,group:"Tabs",label:`Go to ${P.label}`,hint:P.shortcut,run:()=>r(P.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(P=>({id:`node-${P.id}`,group:"Nodes",label:P.name,hint:ro(P.type),run:()=>{Ge(P.id),r("graph")}})),...Ot.slice(0,12).map(P=>({id:`hist-${P.id}`,group:"History",label:P.title||P.id,hint:`${P.level||""} ${P.created_at||""}`.trim(),run:()=>void fr(P.id)}))],En=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[b,m,p]),uo=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[b,m,p]),pr=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Fe=((p==null?void 0:p.findings)||[]).filter(P=>!P.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Zu.map(P=>{const Y=P.icon,ce=t===P.id;return d.jsxs("button",{type:"button","data-testid":P.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":P.label,onClick:()=>r(P.id),children:[d.jsx(Y,{}),d.jsx("span",{children:P.label})]},P.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:ve,onChange:P=>Sn(P.target.value),children:["dark","light"].map(P=>d.jsx("optgroup",{label:P==="dark"?"Dark":"Light",children:Ul.filter(Y=>Y.group===P).map(Y=>d.jsx("option",{value:Y.id,children:Y.label},Y.id))},P))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:N||pr}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[N?d.jsxs("div",{className:$!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","aria-valuemin":$!=null?0:void 0,"aria-valuemax":$!=null?100:void 0,"aria-valuenow":$??void 0,"data-testid":"progress",children:[d.jsx("i",{style:$!=null?{width:`${$}%`}:void 0}),d.jsx("span",{className:"sr-only",children:N})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[k.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:k.some(P=>P.path===o)?o:"",disabled:!!N,"aria-busy":G,onChange:P=>{P.target.value&&Hr(P.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),k.map(P=>d.jsxs("option",{value:P.path,children:[P.name,P.indexed?` (${P.counts.nodes})`:""]},P.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:P=>{const Y=P.target.value;s(Y),Y.trim()!==_t.current&&(_t.current="",Ft(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>$e(!0),children:d.jsx(bp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(Sp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:P=>nn(P,c),placeholder:"base",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(Sp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:P=>nn(a,P),placeholder:"head",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:he?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":he,onClick:()=>{const P=!he;pe(P),localStorage.setItem("loadpath.dirty",P?"1":"0")},children:he?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:Je?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":Je,onClick:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")},children:Je?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.what_if?"what-if · ":"",p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!N,onClick:xi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!N,onClick:()=>Br(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!N,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[R?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:R}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,ne?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:ne}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>K(""),"aria-label":"Dismiss",children:"×"})]}):null,((co=p==null?void 0:p.index)!=null&&co.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((fo=p==null?void 0:p.index)==null?void 0:fo.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Si=p==null?void 0:p.index)==null?void 0:Si.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(ho=p==null?void 0:p.workspace)!=null&&ho.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,p!=null&&p.what_if?d.jsxs("div",{className:"banner whatif","data-testid":"whatif-banner",children:[d.jsxs("span",{children:["Hypothetical walk from"," ",d.jsx("strong",{children:((po=p.node)==null?void 0:po.name)||"this node"}),". Loadpath ignored Base/Head and asked which sinks would feel this node change — not a filter of the current map."]}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-exit-whatif",onClick:Vn,children:x?"Back to git range":"Back to architecture"})]}):null,G?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:N||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":G||te,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(DN,{review:p,findings:Fe,aiNote:me,busy:!!N,tourIndex:Z,onTour:se,onAskAi:ao,onCopy:Ve,onPost:so,onSelect:Ge,onOpenFile:_i,onExport:Gr,history:Ot,diff:io,onReopen:fr,onWaiver:(P,Y)=>{o.trim()&&Pe.addWaiver(o,P,Y||void 0,"from review").then(ce=>{or(ce),K(`Waived ${P} in loadpath.yml`)})}}):zr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Qu,{nodes:p.nodes,edges:p.edges,onWhatIf:dr,focusPath:(go=p.read_order[Z])==null?void 0:go.path,...hr}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(ON,{architecture:m,busy:!!N,onReindex:()=>Br(!1),onReview:jn,onSelect:Ge,config:vi,health:$r,onSaveConfig:P=>{Pe.saveConfig(o,P).then(Y=>{or(Y),K("Wrote loadpath.yml")})},onWaiver:(P,Y,ce)=>{Pe.addWaiver(o,P,Y,ce).then(je=>{or(je),K(`Waived ${P}`)})}}):G?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(te||m!=null&&m.graph_pending)&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(ki=m==null?void 0:m.counts)!=null&&ki.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Qu,{nodes:m.nodes,edges:m.edges,onWhatIf:dr,...hr,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":b==="review","data-testid":"graph-mode-review",className:b==="review"?"active":"",onClick:()=>E("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":b==="architecture","data-testid":"graph-mode-architecture",className:b==="architecture"?"active":"",onClick:()=>E("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:gt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":gt,onClick:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")},children:"Tests"})]}),En.length?d.jsx(Qu,{nodes:En,edges:uo,onWhatIf:dr,...hr}):te||m!=null&&m.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:z,onChange:P=>Fr(P.target.value,H,oe),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:M.length?"Search your repos":"owner/repo",value:H,onChange:P=>Fr(z,P.target.value,oe),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:M.map(P=>d.jsxs("option",{value:P.slug,children:[P.private?"private":"public",P.local_path?" · local":""]},P.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!N||!oo(z),onClick:()=>{It(z)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!N,onClick:Vr,children:"List PRs"})]}),M.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[M.length," ",z," repositor",M.length===1?"y":"ies",z==="github"&&C.github_user?` · @${String(C.github_user)}`:"",z==="gitlab"&&C.gitlab_user?` · @${String(C.gitlab_user)}`:"",z==="bitbucket"&&C.bitbucket_user?` · ${String(C.bitbucket_user)}`:""]}):null,W.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):W.map(P=>{var Y;return d.jsxs("article",{className:"pr","data-testid":`pr-${P.number}`,children:[d.jsxs("h3",{children:["#",P.number," ",P.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${P.draft?"":"open"}`,children:P.draft?"draft":P.state}),d.jsx("span",{children:P.author}),d.jsxs("span",{children:[P.source_branch," → ",P.target_branch]}),P.loadpath?d.jsxs("span",{className:`chip ${P.loadpath.level||""}`,"data-testid":`pr-loadpath-${P.number}`,children:[((Y=P.loadpath.level)==null?void 0:Y.toUpperCase())||"REVIEWED",P.loadpath.contract_break&&P.loadpath.contract_break!=="none"?` · ${P.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:P.url,target:"_blank",rel:"noreferrer",children:["Open on ",P.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${P.number}`,onClick:()=>void bt(P),children:"Review this PR"})]})]},`${P.provider}-${P.number}`)})]}),t==="settings"&&Ne&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Et,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Ul.map(P=>d.jsxs("button",{type:"button","data-theme":P.id,className:ve===P.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${P.id}`,onClick:()=>Sn(P.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:P.label}),d.jsx("div",{className:"group",children:P.group})]},P.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:xm(),onChange:P=>SN(P.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:C.github_token_set?C.github_user?`Signed in as @${String(C.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void Wr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!ct||!C.github_oauth_ready,onClick:()=>void wi(),children:ct?"Waiting for GitHub…":"Sign in with GitHub"})})]}),ct?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:ct.user_code})," at GitHub if the browser did not fill it in."]}):null,C.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(C.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(C.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:C.gitlab_token_set?C.gitlab_user?`Signed in as @${String(C.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void Wr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Fn||!C.gitlab_oauth_ready,onClick:()=>void lo(),children:Fn?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(C.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(C.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:C.bitbucket_token_set?C.bitbucket_user?`Signed in as ${String(C.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void Wr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:On||!C.bitbucket_oauth_ready,onClick:()=>void cr(),children:On?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),C.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(C.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(C.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((Xr=C.ai)==null?void 0:Xr.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((rn=C.ai)==null?void 0:rn.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((on=C.ai)==null?void 0:on.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(d0,{open:st,actions:Yn,onClose:()=>lt(!1)}),Te?d.jsx(MN,{initialPath:o,onClose:()=>$e(!1),onSelect:P=>{if(dt.current){w("Wait for the current job to finish before switching workspace.");return}$e(!1),Hr(P)}}):null]})}function DN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:v,onOpenFile:x,onExport:y,history:m,diff:_,onReopen:k,onWaiver:j}){var E,R,w,N,A,$,F,G,q,te,ee,ne,K,C,V,W,U;const b=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),b.length?d.jsx("ul",{className:"reasons",children:b.map(M=>d.jsx("li",{children:M},M))}):null,t.what_if?d.jsx("span",{className:"chip whatif","data-testid":"whatif-chip",children:"what-if"}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Qo(M)},M)),(E=t.contract_break)!=null&&E.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>j(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(R=t.workspace)!=null&&R.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>x(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(km,{cards:t.deepening}),(N=(w=t.contract_break)==null?void 0:w.reasons)!=null&&N.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),($=(A=t.contract_break.sides)==null?void 0:A.rows)!=null&&$.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(F=t.auth)!=null&&F.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(G=t.suggested_tests)==null?void 0:G.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(q=t.trend)!=null&&q.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",ec(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),m.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:m.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,m.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>k(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?ec(M.created_at):""})]},M.id))]}):null,(ee=(te=t.evolution)==null?void 0:te.notes)!=null&&ee.length||(K=(ne=t.evolution)==null?void 0:ne.hotspots)!=null&&K.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((C=t.evolution)==null?void 0:C.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((V=t.evolution)==null?void 0:V.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:y,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",disabled:s||!!t.what_if,title:t.what_if?"Hypothetical walks are not posted to a pull request":void 0,onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(W=t.codeowners_reviewers)!=null&&W.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function ON({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var x;const v=t.findings.filter(y=>!y.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${ec(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(y=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y.name})," — ",(y.django_apps||[]).join(", ")||"no apps"," ·"," ",(y.owners||[]).join(", ")||"unowned"]},y.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(y=>d.jsx("div",{className:"muted",children:y},y))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:v.length})]}),v.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):v.map(y=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>y.node_id&&a(y.node_id),children:[d.jsx("span",{className:`chip ${y.severity}`,children:y.severity}),y.message]})},y.rule+y.message))]}),d.jsx(km,{cards:t.deepening}),(x=c==null?void 0:c.points)!=null&&x.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(y=>d.jsx("i",{className:y.level||"",title:`${y.level} · ${y.findings} findings`,style:{height:`${8+Math.min(24,(y.findings||0)*4)}px`}},y.id||y.created_at))}),Object.entries(c.contexts).map(([y,m])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y})," — last ",((_=m[m.length-1])==null?void 0:_.findings)??0," findings"]},y)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(f0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((y,m)=>m[1]-y[1]).slice(0,12).map(([y,m])=>d.jsxs("tr",{children:[d.jsx("td",{children:ro(y)}),d.jsx("td",{children:m})]},y))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function km({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:h0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}Sm(_m());a0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(zN,{})}));export{Bk as L,BN as a,FN as c,d as j,HN as l,L as r,ro as t}; diff --git a/src/loadpath/static/index.html b/src/loadpath/static/index.html index 83e4cda..bb56dd1 100644 --- a/src/loadpath/static/index.html +++ b/src/loadpath/static/index.html @@ -17,7 +17,7 @@ - + diff --git a/tests/e2e/test_ui_flows.py b/tests/e2e/test_ui_flows.py index a3f5b60..23a2de0 100644 --- a/tests/e2e/test_ui_flows.py +++ b/tests/e2e/test_ui_flows.py @@ -115,7 +115,10 @@ def test_ui_index_review_graph_copy_and_workspace(live_app, browser_page): page.get_by_test_id("graph-full").wait_for() wait_visible_graph(page) page.locator(".react-flow__minimap-node").first.wait_for(timeout=10_000) - page.locator(".react-flow__node").first.click() + closer = page.get_by_test_id("graph-inspector-close") + if closer.count() and closer.is_visible(): + closer.click() + page.locator(".react-flow__node").filter(has_text="InvoicePage").first.click() inspector = page.get_by_test_id("graph-inspector") inspector.wait_for(timeout=10_000) assert inspector.inner_text().strip() @@ -545,6 +548,42 @@ def test_ui_architecture_brief_paints_before_graph(live_app, browser_page): wait_visible_graph(page) +@pytest.mark.playwright +def test_ui_architecture_edges_use_distinct_verticals(live_app, browser_page): + base_url, repo = live_app + page = browser_page + page.goto(base_url, wait_until="networkidle") + _wait_fonts(page) + _index_repo(page, repo) + page.get_by_test_id("architecture-brief").locator(".level").wait_for(timeout=20_000) + wait_visible_graph(page) + info = page.evaluate( + """() => { + const paths = [...document.querySelectorAll('.react-flow__edge-path')].map((p) => p.getAttribute('d') || ''); + const bySx = {}; + for (const d of paths) { + const m = d.match(/^M(-?\\d+\\.?\\d*)/); + const nums = [...d.matchAll(/(-?\\d+\\.?\\d*)/g)].map((mm) => Number(mm[1])); + if (!m || nums.length < 4) continue; + const sx = Math.round(Number(m[1])); + const lastX = nums[nums.length - 2]; + if (lastX <= sx) continue; + const verts = []; + for (let i = 0; i + 3 < nums.length; i += 2) { + if (Math.abs(nums[i] - nums[i + 2]) < 1 && Math.abs(nums[i + 1] - nums[i + 3]) > 8) { + verts.push(Math.round(nums[i])); + } + } + (bySx[sx] ||= []).push(verts); + } + return Object.values(bySx).filter((list) => list.length >= 2); + }""" + ) + assert info, "expected multiple left-to-right edges from one column" + distinct = any(len({x for verts in group for x in verts}) > 1 for group in info) + assert distinct, info + + @pytest.mark.playwright def test_ui_whatif_banner_and_back_to_git_range(live_app, browser_page): base_url, repo = live_app diff --git a/ui/src/types.ts b/ui/src/types.ts index 4be97c5..c770814 100644 --- a/ui/src/types.ts +++ b/ui/src/types.ts @@ -523,7 +523,7 @@ export function layoutNodes( if (here.has(e.src) && next.has(e.dst)) between += 1; } } - const extra = Math.min(96, Math.max(0, (between - 1) * 12)); + const extra = Math.min(48, Math.max(0, (between - 2) * 10)); x += colPitch + extra; } order.forEach((col, colIndex) => { From aa0bd425edcb339f276a1427d5715e8765121d3f Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 16 Aug 2026 00:44:39 +0000 Subject: [PATCH 11/16] Space overlapping graph verticals instead of packing every corridor edge. Stacked route-to-view links that would read as one dashed bus get lanes at 0.2 and 0.8. Far-apart segments in the same gap can share an x. Co-authored-by: zord.lack.net --- ...CRmek7qf.js => LayeredGraph3D-BSASMssr.js} | 2 +- .../{index-CuokeAZI.js => index-BIpkr91b.js} | 16 +++--- src/loadpath/static/index.html | 2 +- tests/e2e/test_ui_flows.py | 36 +++++++------ ui/src/graphEdges.test.ts | 22 ++++++-- ui/src/graphEdges.ts | 54 +++++++++++++++---- 6 files changed, 92 insertions(+), 40 deletions(-) rename src/loadpath/static/assets/{LayeredGraph3D-CRmek7qf.js => LayeredGraph3D-BSASMssr.js} (99%) rename src/loadpath/static/assets/{index-CuokeAZI.js => index-BIpkr91b.js} (79%) diff --git a/src/loadpath/static/assets/LayeredGraph3D-CRmek7qf.js b/src/loadpath/static/assets/LayeredGraph3D-BSASMssr.js similarity index 99% rename from src/loadpath/static/assets/LayeredGraph3D-CRmek7qf.js rename to src/loadpath/static/assets/LayeredGraph3D-BSASMssr.js index 2b15832..6c2aa73 100644 --- a/src/loadpath/static/assets/LayeredGraph3D-CRmek7qf.js +++ b/src/loadpath/static/assets/LayeredGraph3D-BSASMssr.js @@ -1,4 +1,4 @@ -import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-CuokeAZI.js";/** +import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-BIpkr91b.js";/** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT diff --git a/src/loadpath/static/assets/index-CuokeAZI.js b/src/loadpath/static/assets/index-BIpkr91b.js similarity index 79% rename from src/loadpath/static/assets/index-CuokeAZI.js rename to src/loadpath/static/assets/index-BIpkr91b.js index 9616429..5b4e9fe 100644 --- a/src/loadpath/static/assets/index-CuokeAZI.js +++ b/src/loadpath/static/assets/index-BIpkr91b.js @@ -1,4 +1,4 @@ -(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function kp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Tu={exports:{}},Wo={},Lu={exports:{}},Re={};/** +(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function kp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Tu={exports:{}},Uo={},Lu={exports:{}},Re={};/** * @license React * react.production.min.js * @@ -14,7 +14,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Qf;function t0(){if(Qf)return Wo;Qf=1;var t=us(),r=Symbol.for("react.element"),o=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function c(h,p,v){var x,y={},m=null,_=null;v!==void 0&&(m=""+v),p.key!==void 0&&(m=""+p.key),p.ref!==void 0&&(_=p.ref);for(x in p)s.call(p,x)&&!u.hasOwnProperty(x)&&(y[x]=p[x]);if(h&&h.defaultProps)for(x in p=h.defaultProps,p)y[x]===void 0&&(y[x]=p[x]);return{$$typeof:r,type:h,key:m,ref:_,props:y,_owner:a.current}}return Wo.Fragment=o,Wo.jsx=c,Wo.jsxs=c,Wo}var Zf;function n0(){return Zf||(Zf=1,Tu.exports=t0()),Tu.exports}var d=n0(),L=us();const r0=kp(L);var ml={},Au={exports:{}},zt={},$u={exports:{}},zu={};/** + */var Qf;function t0(){if(Qf)return Uo;Qf=1;var t=us(),r=Symbol.for("react.element"),o=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function c(h,p,v){var x,y={},m=null,_=null;v!==void 0&&(m=""+v),p.key!==void 0&&(m=""+p.key),p.ref!==void 0&&(_=p.ref);for(x in p)s.call(p,x)&&!u.hasOwnProperty(x)&&(y[x]=p[x]);if(h&&h.defaultProps)for(x in p=h.defaultProps,p)y[x]===void 0&&(y[x]=p[x]);return{$$typeof:r,type:h,key:m,ref:_,props:y,_owner:a.current}}return Uo.Fragment=o,Uo.jsx=c,Uo.jsxs=c,Uo}var Zf;function n0(){return Zf||(Zf=1,Tu.exports=t0()),Tu.exports}var d=n0(),L=us();const r0=kp(L);var ml={},Au={exports:{}},zt={},$u={exports:{}},zu={};/** * @license React * scheduler.production.min.js * @@ -34,10 +34,10 @@ `+I+e}var ie=!1;function oe(e,n){if(!e||ie)return"";ie=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(n)if(n=function(){throw Error()},Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(n,[])}catch(J){var l=J}Reflect.construct(e,[],n)}else{try{n.call()}catch(J){l=J}e.call(n.prototype)}else{try{throw Error()}catch(J){l=J}e()}}catch(J){if(J&&l&&typeof J.stack=="string"){for(var f=J.stack.split(` `),g=l.stack.split(` `),S=f.length-1,T=g.length-1;1<=S&&0<=T&&f[S]!==g[T];)T--;for(;1<=S&&0<=T;S--,T--)if(f[S]!==g[T]){if(S!==1||T!==1)do if(S--,T--,0>T||f[S]!==g[T]){var O=` -`+f[S].replace(" at new "," at ");return e.displayName&&O.includes("")&&(O=O.replace("",e.displayName)),O}while(1<=S&&0<=T);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?z(e):""}function fe(e){switch(e.tag){case 5:return z(e.type);case 16:return z("Lazy");case 13:return z("Suspense");case 19:return z("SuspenseList");case 0:case 2:case 15:return e=oe(e.type,!1),e;case 11:return e=oe(e.type.render,!1),e;case 1:return e=oe(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case F:return"Fragment";case $:return"Portal";case q:return"Profiler";case G:return"StrictMode";case K:return"Suspense";case C:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ee:return(e.displayName||"Context")+".Consumer";case te:return(e._context.displayName||"Context")+".Provider";case ne:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case W:n=e._payload,e=e._init;try{return he(e(n))}catch{}}return null}function pe(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===G?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Z(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=se(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function ke(e){e._valueTracker||(e._valueTracker=me(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=se(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function re(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return H({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Z(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Te(e,n){n=n.checked,n!=null&&w(e,"checked",n,!1)}function $e(e,n){Te(e,n);var i=Z(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?lt(e,n.type,i):n.hasOwnProperty("defaultValue")&<(e,n.type,Z(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function st(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function lt(e,n,i){(n!=="number"||re(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var at=Array.isArray;function Ge(e,n,i,l){if(e=e.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=Je.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ot(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var xn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},io=["Webkit","ms","Moz","O"];Object.keys(xn).forEach(function(e){io.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),xn[n]=xn[e]})});function $n(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||xn.hasOwnProperty(e)&&xn[e]?(""+n).trim():n+"px"}function vi(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=$n(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,f):e[i]=f}}var or=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function $r(e,n){if(n){if(or[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function zn(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var zr=null;function sr(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var lr=null,Ft=null,ct=null;function Dn(e){if(e=Mo(e)){if(typeof lr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=Is(n),lr(e.stateNode,e.type,n))}}function On(e){Ft?ct?ct.push(e):ct=[e]:Ft=e}function wn(){if(Ft){var e=Ft,n=ct;if(ct=Ft=null,Dn(e),n)for(e=0;e>>=0,e===0?32:31-(ao(e)/Ur|0)|0}var Wn=64,Un=4194304;function bn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Bt(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,f=e.suspendedLanes,g=e.pingedLanes,S=i&268435455;if(S!==0){var T=S&~f;T!==0?l=bn(T):(g&=S,g!==0&&(l=bn(g)))}else S=i&~f,S!==0?l=bn(S):g!==0&&(l=bn(g));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,g=n&-n,f>=g||f===16&&(g&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function En(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Et(n),e[n]=i}function uo(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=wo),Hc=" ",Bc=!1;function Vc(e,n){switch(e){case"keyup":return qm.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var bi=!1;function Qm(e,n){switch(e){case"compositionend":return Wc(n);case"keypress":return n.which!==32?null:(Bc=!0,Hc);case"textInput":return e=n.data,e===Hc&&Bc?null:e;default:return null}}function Zm(e,n){if(bi)return e==="compositionend"||!ha&&Vc(e,n)?(e=Ac(),ws=la=gr=null,bi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Qc(i)}}function Jc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Jc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function ed(){for(var e=window,n=re();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=re(e.document)}return n}function ma(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function ly(e){var n=ed(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Jc(i.ownerDocument.documentElement,i)){if(l!==null&&ma(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var f=i.textContent.length,g=Math.min(l.start,f);l=l.end===void 0?g:Math.min(l.end,f),!e.extend&&g>l&&(f=l,l=g,g=f),f=Zc(i,g);var S=Zc(i,l);f&&S&&(e.rangeCount!==1||e.anchorNode!==f.node||e.anchorOffset!==f.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),e.removeAllRanges(),g>l?(e.addRange(n),e.extend(S.node,S.offset)):(n.setEnd(S.node,S.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,Ei=null,ya=null,No=null,va=!1;function td(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;va||Ei==null||Ei!==re(l)||(l=Ei,"selectionStart"in l&&ma(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),No&&ko(No,l)||(No=l,l=Cs(ya,"onSelect"),0Ri||(e.current=Pa[Ri],Pa[Ri]=null,Ri--)}function Be(e,n){Ri++,Pa[Ri]=e.current,e.current=n}var xr={},St=vr(xr),Rt=vr(!1),Qr=xr;function Ti(e,n){var i=e.type.contextTypes;if(!i)return xr;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in i)f[g]=n[g];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=f),f}function Tt(e){return e=e.childContextTypes,e!=null}function Rs(){Ue(Rt),Ue(St)}function md(e,n,i){if(St.current!==xr)throw Error(o(168));Be(St,n),Be(Rt,i)}function yd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,pe(e)||"Unknown",f));return H({},i,l)}function Ts(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||xr,Qr=St.current,Be(St,e),Be(Rt,Rt.current),!0}function vd(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=yd(e,n,Qr),l.__reactInternalMemoizedMergedChildContext=e,Ue(Rt),Ue(St),Be(St,e)):Ue(Rt),Be(Rt,i)}var qn=null,Ls=!1,Ia=!1;function xd(e){qn===null?qn=[e]:qn.push(e)}function xy(e){Ls=!0,xd(e)}function wr(){if(!Ia&&qn!==null){Ia=!0;var e=0,n=Fe;try{var i=qn;for(Fe=1;e>=S,f-=S,Kn=1<<32-Et(n)+f|i<Ce?(pt=Ee,Ee=null):pt=Ee.sibling;var Oe=le(X,Ee,Q[Ce],de);if(Oe===null){Ee===null&&(Ee=pt);break}e&&Ee&&Oe.alternate===null&&n(X,Ee),B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe,Ee=pt}if(Ce===Q.length)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;CeCe?(pt=Ee,Ee=null):pt=Ee.sibling;var Mr=le(X,Ee,Oe.value,de);if(Mr===null){Ee===null&&(Ee=pt);break}e&&Ee&&Mr.alternate===null&&n(X,Ee),B=g(Mr,B,Ce),be===null?_e=Mr:be.sibling=Mr,be=Mr,Ee=pt}if(Oe.done)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;!Oe.done;Ce++,Oe=Q.next())Oe=ue(X,Oe.value,de),Oe!==null&&(B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return Xe&&Jr(X,Ce),_e}for(Ee=l(X,Ee);!Oe.done;Ce++,Oe=Q.next())Oe=ge(Ee,X,Ce,Oe.value,de),Oe!==null&&(e&&Oe.alternate!==null&&Ee.delete(Oe.key===null?Ce:Oe.key),B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return e&&Ee.forEach(function(Jy){return n(X,Jy)}),Xe&&Jr(X,Ce),_e}function et(X,B,Q,de){if(typeof Q=="object"&&Q!==null&&Q.type===F&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case A:e:{for(var _e=Q.key,be=B;be!==null;){if(be.key===_e){if(_e=Q.type,_e===F){if(be.tag===7){i(X,be.sibling),B=f(be,Q.props.children),B.return=X,X=B;break e}}else if(be.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===W&&jd(_e)===be.type){i(X,be.sibling),B=f(be,Q.props),B.ref=Po(X,be,Q),B.return=X,X=B;break e}i(X,be);break}else n(X,be);be=be.sibling}Q.type===F?(B=li(Q.props.children,X.mode,de,Q.key),B.return=X,X=B):(de=al(Q.type,Q.key,Q.props,null,X.mode,de),de.ref=Po(X,B,Q),de.return=X,X=de)}return S(X);case $:e:{for(be=Q.key;B!==null;){if(B.key===be)if(B.tag===4&&B.stateNode.containerInfo===Q.containerInfo&&B.stateNode.implementation===Q.implementation){i(X,B.sibling),B=f(B,Q.children||[]),B.return=X,X=B;break e}else{i(X,B);break}else n(X,B);B=B.sibling}B=Cu(Q,X.mode,de),B.return=X,X=B}return S(X);case W:return be=Q._init,et(X,B,be(Q._payload),de)}if(at(Q))return xe(X,B,Q,de);if(D(Q))return we(X,B,Q,de);Ds(X,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"?(Q=""+Q,B!==null&&B.tag===6?(i(X,B.sibling),B=f(B,Q),B.return=X,X=B):(i(X,B),B=Eu(Q,X.mode,de),B.return=X,X=B),S(X)):i(X,B)}return et}var zi=bd(!0),Ed=bd(!1),Os=vr(null),Fs=null,Di=null,za=null;function Da(){za=Di=Fs=null}function Oa(e){var n=Os.current;Ue(Os),e._currentValue=n}function Fa(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function Oi(e,n){Fs=e,za=Di=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Lt=!0),e.firstContext=null)}function Zt(e){var n=e._currentValue;if(za!==e)if(e={context:e,memoizedValue:n,next:null},Di===null){if(Fs===null)throw Error(o(308));Di=e,Fs.dependencies={lanes:0,firstContext:e}}else Di=Di.next=e;return n}var ei=null;function Ha(e){ei===null?ei=[e]:ei.push(e)}function Cd(e,n,i,l){var f=n.interleaved;return f===null?(i.next=i,Ha(n)):(i.next=f.next,f.next=i),n.interleaved=i,Zn(e,l)}function Zn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var _r=!1;function Ba(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Md(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Jn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Sr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(ze&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,Zn(e,i)}return f=l.interleaved,f===null?(n.next=n,Ha(l)):(n.next=f.next,f.next=n),l.interleaved=n,Zn(e,i)}function Hs(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}function Pd(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var S={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?f=g=S:g=g.next=S,i=i.next}while(i!==null);g===null?f=g=n:g=g.next=n}else f=g=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function Bs(e,n,i,l){var f=e.updateQueue;_r=!1;var g=f.firstBaseUpdate,S=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,J=O.next;O.next=null,S===null?g=J:S.next=J,S=O;var ae=e.alternate;ae!==null&&(ae=ae.updateQueue,T=ae.lastBaseUpdate,T!==S&&(T===null?ae.firstBaseUpdate=J:T.next=J,ae.lastBaseUpdate=O))}if(g!==null){var ue=f.baseState;S=0,ae=J=O=null,T=g;do{var le=T.lane,ge=T.eventTime;if((l&le)===le){ae!==null&&(ae=ae.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var xe=e,we=T;switch(le=n,ge=i,we.tag){case 1:if(xe=we.payload,typeof xe=="function"){ue=xe.call(ge,ue,le);break e}ue=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=we.payload,le=typeof xe=="function"?xe.call(ge,ue,le):xe,le==null)break e;ue=H({},ue,le);break e;case 2:_r=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,le=f.effects,le===null?f.effects=[T]:le.push(T))}else ge={eventTime:ge,lane:le,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ae===null?(J=ae=ge,O=ue):ae=ae.next=ge,S|=le;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;le=T,T=le.next,le.next=null,f.lastBaseUpdate=le,f.shared.pending=null}}while(!0);if(ae===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=J,f.lastBaseUpdate=ae,n=f.shared.interleaved,n!==null){f=n;do S|=f.lane,f=f.next;while(f!==n)}else g===null&&(f.shared.lanes=0);ri|=S,e.lanes=S,e.memoizedState=ue}}function Id(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=Ga.transition;Ga.transition={};try{e(!1),n()}finally{Fe=i,Ga.transition=l}}function Kd(){return Jt().memoizedState}function ky(e,n,i){var l=br(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},Qd(e))Zd(n,i);else if(i=Cd(e,n,i,l),i!==null){var f=Mt();dn(i,e,l,f),Jd(i,n,l)}}function Ny(e,n,i){var l=br(e),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(Qd(e))Zd(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,T=g(S,i);if(f.hasEagerState=!0,f.eagerState=T,sn(T,S)){var O=n.interleaved;O===null?(f.next=f,Ha(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=Cd(e,n,f,l),i!==null&&(f=Mt(),dn(i,e,l,f),Jd(i,n,l))}}function Qd(e){var n=e.alternate;return e===Ke||n!==null&&n===Ke}function Zd(e,n){Lo=Us=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Jd(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}var Xs={readContext:Zt,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},jy={readContext:Zt,useCallback:function(e,n){return Pn().memoizedState=[e,n===void 0?null:n],e},useContext:Zt,useEffect:Bd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Ys(4194308,4,Ud.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Ys(4194308,4,e,n)},useInsertionEffect:function(e,n){return Ys(4,2,e,n)},useMemo:function(e,n){var i=Pn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=Pn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=ky.bind(null,Ke,e),[l.memoizedState,e]},useRef:function(e){var n=Pn();return e={current:e},n.memoizedState=e},useState:Fd,useDebugValue:eu,useDeferredValue:function(e){return Pn().memoizedState=e},useTransition:function(){var e=Fd(!1),n=e[0];return e=Sy.bind(null,e[1]),Pn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=Ke,f=Pn();if(Xe){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ht===null)throw Error(o(349));(ni&30)!==0||Ad(l,n,i)}f.memoizedState=i;var g={value:i,getSnapshot:n};return f.queue=g,Bd(zd.bind(null,l,g,e),[e]),l.flags|=2048,zo(9,$d.bind(null,l,g,i,n),void 0,null),i},useId:function(){var e=Pn(),n=ht.identifierPrefix;if(Xe){var i=Qn,l=Kn;i=(l&~(1<<32-Et(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=Ao++,0")&&(O=O.replace("",e.displayName)),O}while(1<=S&&0<=T);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?z(e):""}function fe(e){switch(e.tag){case 5:return z(e.type);case 16:return z("Lazy");case 13:return z("Suspense");case 19:return z("SuspenseList");case 0:case 2:case 15:return e=oe(e.type,!1),e;case 11:return e=oe(e.type.render,!1),e;case 1:return e=oe(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case F:return"Fragment";case $:return"Portal";case q:return"Profiler";case G:return"StrictMode";case K:return"Suspense";case C:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ee:return(e.displayName||"Context")+".Consumer";case te:return(e._context.displayName||"Context")+".Provider";case ne:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case W:n=e._payload,e=e._init;try{return he(e(n))}catch{}}return null}function pe(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===G?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Z(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=se(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function ke(e){e._valueTracker||(e._valueTracker=me(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=se(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function re(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return H({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Z(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Te(e,n){n=n.checked,n!=null&&w(e,"checked",n,!1)}function $e(e,n){Te(e,n);var i=Z(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?lt(e,n.type,i):n.hasOwnProperty("defaultValue")&<(e,n.type,Z(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function st(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function lt(e,n,i){(n!=="number"||re(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var at=Array.isArray;function Ge(e,n,i,l){if(e=e.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=Je.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ot(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var xn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},oo=["Webkit","ms","Moz","O"];Object.keys(xn).forEach(function(e){oo.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),xn[n]=xn[e]})});function $n(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||xn.hasOwnProperty(e)&&xn[e]?(""+n).trim():n+"px"}function vi(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=$n(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,f):e[i]=f}}var or=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function $r(e,n){if(n){if(or[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function zn(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var zr=null;function sr(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var lr=null,Ft=null,ct=null;function Dn(e){if(e=Po(e)){if(typeof lr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=Is(n),lr(e.stateNode,e.type,n))}}function On(e){Ft?ct?ct.push(e):ct=[e]:Ft=e}function wn(){if(Ft){var e=Ft,n=ct;if(ct=Ft=null,Dn(e),n)for(e=0;e>>=0,e===0?32:31-(uo(e)/Ur|0)|0}var Wn=64,Un=4194304;function bn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Bt(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,f=e.suspendedLanes,g=e.pingedLanes,S=i&268435455;if(S!==0){var T=S&~f;T!==0?l=bn(T):(g&=S,g!==0&&(l=bn(g)))}else S=i&~f,S!==0?l=bn(S):g!==0&&(l=bn(g));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,g=n&-n,f>=g||f===16&&(g&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function En(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Et(n),e[n]=i}function co(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=_o),Hc=" ",Bc=!1;function Vc(e,n){switch(e){case"keyup":return qm.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var bi=!1;function Qm(e,n){switch(e){case"compositionend":return Wc(n);case"keypress":return n.which!==32?null:(Bc=!0,Hc);case"textInput":return e=n.data,e===Hc&&Bc?null:e;default:return null}}function Zm(e,n){if(bi)return e==="compositionend"||!ha&&Vc(e,n)?(e=Ac(),ws=la=gr=null,bi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Qc(i)}}function Jc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Jc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function ed(){for(var e=window,n=re();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=re(e.document)}return n}function ma(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function ly(e){var n=ed(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Jc(i.ownerDocument.documentElement,i)){if(l!==null&&ma(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var f=i.textContent.length,g=Math.min(l.start,f);l=l.end===void 0?g:Math.min(l.end,f),!e.extend&&g>l&&(f=l,l=g,g=f),f=Zc(i,g);var S=Zc(i,l);f&&S&&(e.rangeCount!==1||e.anchorNode!==f.node||e.anchorOffset!==f.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),e.removeAllRanges(),g>l?(e.addRange(n),e.extend(S.node,S.offset)):(n.setEnd(S.node,S.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,Ei=null,ya=null,jo=null,va=!1;function td(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;va||Ei==null||Ei!==re(l)||(l=Ei,"selectionStart"in l&&ma(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),jo&&No(jo,l)||(jo=l,l=Cs(ya,"onSelect"),0Ri||(e.current=Pa[Ri],Pa[Ri]=null,Ri--)}function Be(e,n){Ri++,Pa[Ri]=e.current,e.current=n}var xr={},St=vr(xr),Rt=vr(!1),Qr=xr;function Ti(e,n){var i=e.type.contextTypes;if(!i)return xr;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in i)f[g]=n[g];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=f),f}function Tt(e){return e=e.childContextTypes,e!=null}function Rs(){Ue(Rt),Ue(St)}function md(e,n,i){if(St.current!==xr)throw Error(o(168));Be(St,n),Be(Rt,i)}function yd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,pe(e)||"Unknown",f));return H({},i,l)}function Ts(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||xr,Qr=St.current,Be(St,e),Be(Rt,Rt.current),!0}function vd(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=yd(e,n,Qr),l.__reactInternalMemoizedMergedChildContext=e,Ue(Rt),Ue(St),Be(St,e)):Ue(Rt),Be(Rt,i)}var qn=null,Ls=!1,Ia=!1;function xd(e){qn===null?qn=[e]:qn.push(e)}function xy(e){Ls=!0,xd(e)}function wr(){if(!Ia&&qn!==null){Ia=!0;var e=0,n=Fe;try{var i=qn;for(Fe=1;e>=S,f-=S,Kn=1<<32-Et(n)+f|i<Ce?(pt=Ee,Ee=null):pt=Ee.sibling;var Oe=le(X,Ee,Q[Ce],de);if(Oe===null){Ee===null&&(Ee=pt);break}e&&Ee&&Oe.alternate===null&&n(X,Ee),B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe,Ee=pt}if(Ce===Q.length)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;CeCe?(pt=Ee,Ee=null):pt=Ee.sibling;var Mr=le(X,Ee,Oe.value,de);if(Mr===null){Ee===null&&(Ee=pt);break}e&&Ee&&Mr.alternate===null&&n(X,Ee),B=g(Mr,B,Ce),be===null?_e=Mr:be.sibling=Mr,be=Mr,Ee=pt}if(Oe.done)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;!Oe.done;Ce++,Oe=Q.next())Oe=ue(X,Oe.value,de),Oe!==null&&(B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return Xe&&Jr(X,Ce),_e}for(Ee=l(X,Ee);!Oe.done;Ce++,Oe=Q.next())Oe=ge(Ee,X,Ce,Oe.value,de),Oe!==null&&(e&&Oe.alternate!==null&&Ee.delete(Oe.key===null?Ce:Oe.key),B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return e&&Ee.forEach(function(Jy){return n(X,Jy)}),Xe&&Jr(X,Ce),_e}function et(X,B,Q,de){if(typeof Q=="object"&&Q!==null&&Q.type===F&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case A:e:{for(var _e=Q.key,be=B;be!==null;){if(be.key===_e){if(_e=Q.type,_e===F){if(be.tag===7){i(X,be.sibling),B=f(be,Q.props.children),B.return=X,X=B;break e}}else if(be.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===W&&jd(_e)===be.type){i(X,be.sibling),B=f(be,Q.props),B.ref=Io(X,be,Q),B.return=X,X=B;break e}i(X,be);break}else n(X,be);be=be.sibling}Q.type===F?(B=li(Q.props.children,X.mode,de,Q.key),B.return=X,X=B):(de=al(Q.type,Q.key,Q.props,null,X.mode,de),de.ref=Io(X,B,Q),de.return=X,X=de)}return S(X);case $:e:{for(be=Q.key;B!==null;){if(B.key===be)if(B.tag===4&&B.stateNode.containerInfo===Q.containerInfo&&B.stateNode.implementation===Q.implementation){i(X,B.sibling),B=f(B,Q.children||[]),B.return=X,X=B;break e}else{i(X,B);break}else n(X,B);B=B.sibling}B=Cu(Q,X.mode,de),B.return=X,X=B}return S(X);case W:return be=Q._init,et(X,B,be(Q._payload),de)}if(at(Q))return xe(X,B,Q,de);if(D(Q))return we(X,B,Q,de);Ds(X,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"?(Q=""+Q,B!==null&&B.tag===6?(i(X,B.sibling),B=f(B,Q),B.return=X,X=B):(i(X,B),B=Eu(Q,X.mode,de),B.return=X,X=B),S(X)):i(X,B)}return et}var zi=bd(!0),Ed=bd(!1),Os=vr(null),Fs=null,Di=null,za=null;function Da(){za=Di=Fs=null}function Oa(e){var n=Os.current;Ue(Os),e._currentValue=n}function Fa(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function Oi(e,n){Fs=e,za=Di=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Lt=!0),e.firstContext=null)}function Zt(e){var n=e._currentValue;if(za!==e)if(e={context:e,memoizedValue:n,next:null},Di===null){if(Fs===null)throw Error(o(308));Di=e,Fs.dependencies={lanes:0,firstContext:e}}else Di=Di.next=e;return n}var ei=null;function Ha(e){ei===null?ei=[e]:ei.push(e)}function Cd(e,n,i,l){var f=n.interleaved;return f===null?(i.next=i,Ha(n)):(i.next=f.next,f.next=i),n.interleaved=i,Zn(e,l)}function Zn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var _r=!1;function Ba(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Md(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Jn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Sr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(ze&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,Zn(e,i)}return f=l.interleaved,f===null?(n.next=n,Ha(l)):(n.next=f.next,f.next=n),l.interleaved=n,Zn(e,i)}function Hs(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}function Pd(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var S={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?f=g=S:g=g.next=S,i=i.next}while(i!==null);g===null?f=g=n:g=g.next=n}else f=g=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function Bs(e,n,i,l){var f=e.updateQueue;_r=!1;var g=f.firstBaseUpdate,S=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,J=O.next;O.next=null,S===null?g=J:S.next=J,S=O;var ae=e.alternate;ae!==null&&(ae=ae.updateQueue,T=ae.lastBaseUpdate,T!==S&&(T===null?ae.firstBaseUpdate=J:T.next=J,ae.lastBaseUpdate=O))}if(g!==null){var ue=f.baseState;S=0,ae=J=O=null,T=g;do{var le=T.lane,ge=T.eventTime;if((l&le)===le){ae!==null&&(ae=ae.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var xe=e,we=T;switch(le=n,ge=i,we.tag){case 1:if(xe=we.payload,typeof xe=="function"){ue=xe.call(ge,ue,le);break e}ue=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=we.payload,le=typeof xe=="function"?xe.call(ge,ue,le):xe,le==null)break e;ue=H({},ue,le);break e;case 2:_r=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,le=f.effects,le===null?f.effects=[T]:le.push(T))}else ge={eventTime:ge,lane:le,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ae===null?(J=ae=ge,O=ue):ae=ae.next=ge,S|=le;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;le=T,T=le.next,le.next=null,f.lastBaseUpdate=le,f.shared.pending=null}}while(!0);if(ae===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=J,f.lastBaseUpdate=ae,n=f.shared.interleaved,n!==null){f=n;do S|=f.lane,f=f.next;while(f!==n)}else g===null&&(f.shared.lanes=0);ri|=S,e.lanes=S,e.memoizedState=ue}}function Id(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=Ga.transition;Ga.transition={};try{e(!1),n()}finally{Fe=i,Ga.transition=l}}function Kd(){return Jt().memoizedState}function ky(e,n,i){var l=br(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},Qd(e))Zd(n,i);else if(i=Cd(e,n,i,l),i!==null){var f=Mt();dn(i,e,l,f),Jd(i,n,l)}}function Ny(e,n,i){var l=br(e),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(Qd(e))Zd(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,T=g(S,i);if(f.hasEagerState=!0,f.eagerState=T,sn(T,S)){var O=n.interleaved;O===null?(f.next=f,Ha(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=Cd(e,n,f,l),i!==null&&(f=Mt(),dn(i,e,l,f),Jd(i,n,l))}}function Qd(e){var n=e.alternate;return e===Ke||n!==null&&n===Ke}function Zd(e,n){Ao=Us=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Jd(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}var Xs={readContext:Zt,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},jy={readContext:Zt,useCallback:function(e,n){return Pn().memoizedState=[e,n===void 0?null:n],e},useContext:Zt,useEffect:Bd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Ys(4194308,4,Ud.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Ys(4194308,4,e,n)},useInsertionEffect:function(e,n){return Ys(4,2,e,n)},useMemo:function(e,n){var i=Pn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=Pn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=ky.bind(null,Ke,e),[l.memoizedState,e]},useRef:function(e){var n=Pn();return e={current:e},n.memoizedState=e},useState:Fd,useDebugValue:eu,useDeferredValue:function(e){return Pn().memoizedState=e},useTransition:function(){var e=Fd(!1),n=e[0];return e=Sy.bind(null,e[1]),Pn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=Ke,f=Pn();if(Xe){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ht===null)throw Error(o(349));(ni&30)!==0||Ad(l,n,i)}f.memoizedState=i;var g={value:i,getSnapshot:n};return f.queue=g,Bd(zd.bind(null,l,g,e),[e]),l.flags|=2048,Do(9,$d.bind(null,l,g,i,n),void 0,null),i},useId:function(){var e=Pn(),n=ht.identifierPrefix;if(Xe){var i=Qn,l=Kn;i=(l&~(1<<32-Et(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=$o++,0<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=S.createElement(i,{is:l.is}):(e=S.createElement(i),i==="select"&&(S=e,l.multiple?S.multiple=!0:l.size&&(S.size=l.size))):e=S.createElementNS(e,i),e[Cn]=n,e[Co]=l,wf(e,n,!1,!1),n.stateNode=e;e:{switch(S=zn(i,l),i){case"dialog":We("cancel",e),We("close",e),f=l;break;case"iframe":case"object":case"embed":We("load",e),f=l;break;case"video":case"audio":for(f=0;fWi&&(n.flags|=128,l=!0,Do(g,!1),n.lanes=4194304)}else{if(!l)if(e=Vs(S),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Do(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Xe)return Nt(n),null}else 2*Ve()-g.renderingStartTime>Wi&&i!==1073741824&&(n.flags|=128,l=!0,Do(g,!1),n.lanes=4194304);g.isBackwards?(S.sibling=n.child,n.child=S):(i=g.last,i!==null?i.sibling=S:n.child=S,g.last=S)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(Nt(n),null);case 22:case 23:return Nu(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Yt&1073741824)!==0&&(Nt(n),n.subtreeFlags&6&&(n.flags|=8192)):Nt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function Ty(e,n){switch(Ta(n),n.tag){case 1:return Tt(n.type)&&Rs(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Fi(),Ue(Rt),Ue(St),Ya(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Wa(n),null;case 13:if(Ue(qe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));$i()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Fi(),null;case 10:return Oa(n.type._context),null;case 22:case 23:return Nu(),null;case 24:return null;default:return null}}var Zs=!1,jt=!1,Ly=typeof WeakSet=="function"?WeakSet:Set,ye=null;function Bi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Ze(e,n,l)}else i.current=null}function fu(e,n,i){try{i()}catch(l){Ze(e,n,l)}}var kf=!1;function Ay(e,n){if(Na=vs,e=ed(),ma(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,g=l.focusNode;l=l.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var S=0,T=-1,O=-1,J=0,ae=0,ue=e,le=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=S+f),ue!==g||l!==0&&ue.nodeType!==3||(O=S+l),ue.nodeType===3&&(S+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)le=ue,ue=ge;for(;;){if(ue===e)break t;if(le===i&&++J===f&&(T=S),le===g&&++ae===l&&(O=S),(ge=ue.nextSibling)!==null)break;ue=le,le=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(ja={focusedElem:e,selectionRange:i},vs=!1,ye=n;ye!==null;)if(n=ye,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ye=e;else for(;ye!==null;){n=ye;try{var xe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var we=xe.memoizedProps,et=xe.memoizedState,X=n.stateNode,B=X.getSnapshotBeforeUpdate(n.elementType===n.type?we:an(n.type,we),et);X.__reactInternalSnapshotBeforeUpdate=B}break;case 3:var Q=n.stateNode.containerInfo;Q.nodeType===1?Q.textContent="":Q.nodeType===9&&Q.documentElement&&Q.removeChild(Q.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(de){Ze(n,n.return,de)}if(e=n.sibling,e!==null){e.return=n.return,ye=e;break}ye=n.return}return xe=kf,kf=!1,xe}function Oo(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&e)===e){var g=f.destroy;f.destroy=void 0,g!==void 0&&fu(n,i,g)}f=f.next}while(f!==l)}}function Js(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function hu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function Nf(e){var n=e.alternate;n!==null&&(e.alternate=null,Nf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[Cn],delete n[Co],delete n[Ma],delete n[yy],delete n[vy])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function jf(e){return e.tag===5||e.tag===3||e.tag===4}function bf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||jf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function pu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=Ps));else if(l!==4&&(e=e.child,e!==null))for(pu(e,n,i),e=e.sibling;e!==null;)pu(e,n,i),e=e.sibling}function gu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(gu(e,n,i),e=e.sibling;e!==null;)gu(e,n,i),e=e.sibling}var vt=null,un=!1;function kr(e,n,i){for(i=i.child;i!==null;)Ef(e,n,i),i=i.sibling}function Ef(e,n,i){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(Vn,i)}catch{}switch(i.tag){case 5:jt||Bi(i,n);case 6:var l=vt,f=un;vt=null,kr(e,n,i),vt=l,un=f,vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):vt.removeChild(i.stateNode));break;case 18:vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?Ca(e.parentNode,i):e.nodeType===1&&Ca(e,i),yo(e)):Ca(vt,i.stateNode));break;case 4:l=vt,f=un,vt=i.stateNode.containerInfo,un=!0,kr(e,n,i),vt=l,un=f;break;case 0:case 11:case 14:case 15:if(!jt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var g=f,S=g.destroy;g=g.tag,S!==void 0&&((g&2)!==0||(g&4)!==0)&&fu(i,n,S),f=f.next}while(f!==l)}kr(e,n,i);break;case 1:if(!jt&&(Bi(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Ze(i,n,T)}kr(e,n,i);break;case 21:kr(e,n,i);break;case 22:i.mode&1?(jt=(l=jt)||i.memoizedState!==null,kr(e,n,i),jt=l):kr(e,n,i);break;default:kr(e,n,i)}}function Cf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Ly),n.forEach(function(l){var f=Wy.bind(null,e,l);i.has(l)||(i.add(l),l.then(f,f))})}}function cn(e,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=S),l&=~g}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*zy(l/1960))-l,10e?16:e,jr===null)var l=!1;else{if(e=jr,jr=null,il=0,(ze&6)!==0)throw Error(o(331));var f=ze;for(ze|=4,ye=e.current;ye!==null;){var g=ye,S=g.child;if((ye.flags&16)!==0){var T=g.deletions;if(T!==null){for(var O=0;OVe()-vu?oi(e,0):yu|=i),$t(e,n)}function Hf(e,n){n===0&&((e.mode&1)===0?n=1:(n=Un,Un<<=1,(Un&130023424)===0&&(Un=4194304)));var i=Mt();e=Zn(e,n),e!==null&&(En(e,n,i),$t(e,i))}function Vy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Hf(e,i)}function Wy(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Hf(e,i)}var Bf;Bf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Rt.current)Lt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Lt=!1,Iy(e,n,i);Lt=(e.flags&131072)!==0}else Lt=!1,Xe&&(n.flags&1048576)!==0&&wd(n,$s,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Qs(e,n),e=n.pendingProps;var f=Ti(n,St.current);Oi(n,i),f=qa(null,n,l,e,f,i);var g=Ka();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Tt(l)?(g=!0,Ts(n)):g=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Ba(n),f.updater=qs,n.stateNode=f,f._reactInternals=n,nu(n,l,e,i),n=su(null,n,l,!0,g,i)):(n.tag=0,Xe&&g&&Ra(n),Ct(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Qs(e,n),e=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=Yy(l),e=an(l,e),f){case 0:n=ou(null,n,l,e,i);break e;case 1:n=pf(null,n,l,e,i);break e;case 11:n=uf(null,n,l,e,i);break e;case 14:n=cf(null,n,l,an(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),ou(e,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),pf(e,n,l,f,i);case 3:e:{if(gf(n),e===null)throw Error(o(387));l=n.pendingProps,g=n.memoizedState,f=g.element,Md(e,n),Bs(n,l,null,i);var S=n.memoizedState;if(l=S.element,g.isDehydrated)if(g={element:l,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){f=Hi(Error(o(423)),n),n=mf(e,n,l,i,f);break e}else if(l!==f){f=Hi(Error(o(424)),n),n=mf(e,n,l,i,f);break e}else for(Ut=yr(n.stateNode.containerInfo.firstChild),Wt=n,Xe=!0,ln=null,i=Ed(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if($i(),l===f){n=er(e,n,i);break e}Ct(e,n,l,i)}n=n.child}return n;case 5:return Rd(n),e===null&&Aa(n),l=n.type,f=n.pendingProps,g=e!==null?e.memoizedProps:null,S=f.children,ba(l,f)?S=null:g!==null&&ba(l,g)&&(n.flags|=32),hf(e,n),Ct(e,n,S,i),n.child;case 6:return e===null&&Aa(n),null;case 13:return yf(e,n,i);case 4:return Va(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=zi(n,null,l,i):Ct(e,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),uf(e,n,l,f,i);case 7:return Ct(e,n,n.pendingProps,i),n.child;case 8:return Ct(e,n,n.pendingProps.children,i),n.child;case 12:return Ct(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,g=n.memoizedProps,S=f.value,Be(Os,l._currentValue),l._currentValue=S,g!==null)if(sn(g.value,S)){if(g.children===f.children&&!Rt.current){n=er(e,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var T=g.dependencies;if(T!==null){S=g.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(g.tag===1){O=Jn(-1,i&-i),O.tag=2;var J=g.updateQueue;if(J!==null){J=J.shared;var ae=J.pending;ae===null?O.next=O:(O.next=ae.next,ae.next=O),J.pending=O}}g.lanes|=i,O=g.alternate,O!==null&&(O.lanes|=i),Fa(g.return,i,n),T.lanes|=i;break}O=O.next}}else if(g.tag===10)S=g.type===n.type?null:g.child;else if(g.tag===18){if(S=g.return,S===null)throw Error(o(341));S.lanes|=i,T=S.alternate,T!==null&&(T.lanes|=i),Fa(S,i,n),S=g.sibling}else S=g.child;if(S!==null)S.return=g;else for(S=g;S!==null;){if(S===n){S=null;break}if(g=S.sibling,g!==null){g.return=S.return,S=g;break}S=S.return}g=S}Ct(e,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,Oi(n,i),f=Zt(f),l=l(f),n.flags|=1,Ct(e,n,l,i),n.child;case 14:return l=n.type,f=an(l,n.pendingProps),f=an(l.type,f),cf(e,n,l,f,i);case 15:return df(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),Qs(e,n),n.tag=1,Tt(l)?(e=!0,Ts(n)):e=!1,Oi(n,i),tf(n,l,f),nu(n,l,f,i),su(null,n,l,!0,e,i);case 19:return xf(e,n,i);case 22:return ff(e,n,i)}throw Error(o(156,n.tag))};function Vf(e,n){return Hr(e,n)}function Uy(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tn(e,n,i,l){return new Uy(e,n,i,l)}function bu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Yy(e){if(typeof e=="function")return bu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ne)return 11;if(e===V)return 14}return 2}function Cr(e,n){var i=e.alternate;return i===null?(i=tn(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function al(e,n,i,l,f,g){var S=2;if(l=e,typeof e=="function")bu(e)&&(S=1);else if(typeof e=="string")S=5;else e:switch(e){case F:return li(i.children,f,g,n);case G:S=8,f|=8;break;case q:return e=tn(12,i,n,f|2),e.elementType=q,e.lanes=g,e;case K:return e=tn(13,i,n,f),e.elementType=K,e.lanes=g,e;case C:return e=tn(19,i,n,f),e.elementType=C,e.lanes=g,e;case U:return ul(i,f,g,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case te:S=10;break e;case ee:S=9;break e;case ne:S=11;break e;case V:S=14;break e;case W:S=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=tn(S,i,n,f),n.elementType=e,n.type=l,n.lanes=g,n}function li(e,n,i,l){return e=tn(7,e,l,n),e.lanes=i,e}function ul(e,n,i,l){return e=tn(22,e,l,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function Eu(e,n,i){return e=tn(6,e,null,n),e.lanes=i,e}function Cu(e,n,i){return n=tn(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Gy(e,n,i,l,f){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Yn(0),this.expirationTimes=Yn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Yn(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Mu(e,n,i,l,f,g,S,T,O){return e=new Gy(e,n,i,T,O),n===1?(n=1,g===!0&&(n|=8)):n=0,g=tn(3,null,null,n),e.current=g,g.stateNode=e,g.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ba(g),e}function Xy(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),Au.exports=s0(),Au.exports}var rh;function l0(){if(rh)return ml;rh=1;var t=Np();return ml.createRoot=t.createRoot,ml.hydrateRoot=t.hydrateRoot,ml}var a0=l0();function jp(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Ae(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(jp(s,o.statusText||"Request failed"))}return o.json()}const u0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Pe={health:()=>Ae("/api/health"),settings:()=>Ae("/api/settings"),saveSettings:t=>{const r={...t};for(const o of u0)r[o]===""&&delete r[o];return Ae("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ae("/api/repos"),browse:t=>Ae(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ae(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ae("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ae(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Ae(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:(t,r=!0)=>Ae(`/api/architecture?repo_path=${encodeURIComponent(t)}&graph=${r?"1":"0"}`),architectureGraph:t=>Ae(`/api/architecture/graph?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Ae("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Ae("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Ae("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Ae("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Ae("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Ae(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open",s)=>Ae("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o,repo_path:s||null})}),scmRepos:t=>Ae(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ae("/api/oauth/status"),githubOAuthStart:()=>Ae("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ae("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ae("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Ae("/api/oauth/gitlab/start"),oauthDisconnect:t=>Ae("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ae("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})}),reviews:t=>Ae(`/api/reviews?repo_path=${encodeURIComponent(t)}`),getReview:(t,r)=>Ae(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(t)}`),reviewDiff:(t,r,o)=>Ae(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(t)}&other=${encodeURIComponent(o)}`),config:t=>Ae(`/api/config?repo_path=${encodeURIComponent(t)}`),saveConfig:(t,r)=>Ae("/api/config",{method:"PUT",body:JSON.stringify({repo_path:t,...r})}),addWaiver:(t,r,o,s)=>Ae("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:t,rule:r,node:o||null,reason:s||""})}),marks:(t,r)=>Ae(`/api/marks?repo_path=${encodeURIComponent(t)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:t=>Ae(`/api/architecture/health?repo_path=${encodeURIComponent(t)}`),workspaceStatus:t=>Ae(`/api/workspace/status?repo_path=${encodeURIComponent(t)}`),openEditor:(t,r,o,s)=>Ae("/api/open",{method:"POST",body:JSON.stringify({repo_path:t,path:r,line:o||null,editor:s||null})}),exportHtml:t=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:t})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(jp(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(t,r,o,s)=>Ae("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:t,edges:r,source_id:o,target_id:s||null})})};function c0(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):t}function d0({open:t,actions:r,onClose:o}){const[s,a]=L.useState(""),[u,c]=L.useState(0),h=L.useRef(null),p=L.useMemo(()=>c0(r,s),[r,s]);if(L.useEffect(()=>{if(!t)return;a(""),c(0);const y=window.setTimeout(()=>{var m;return(m=h.current)==null?void 0:m.focus()},0);return()=>window.clearTimeout(y)},[t]),L.useEffect(()=>{c(0)},[s]),!t)return null;const v=p[u],x=y=>{y&&(o(),y.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:y=>{y.target===y.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:y=>a(y.target.value),onKeyDown:y=>{y.key==="Escape"?(y.preventDefault(),o()):y.key==="ArrowDown"?(y.preventDefault(),c(m=>Math.min(p.length-1,m+1))):y.key==="ArrowUp"?(y.preventDefault(),c(m=>Math.max(0,m-1))):y.key==="Enter"&&(y.preventDefault(),x(v))}}),d.jsxs("ul",{children:[p.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,p.slice(0,40).map((y,m)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:m===u?"active":"",onMouseEnter:()=>c(m),onClick:()=>x(y),children:[d.jsx("span",{children:y.label}),y.hint?d.jsx("span",{className:"muted",children:y.hint}):null]})},y.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function f0({config:t,busy:r,onSave:o,onWaiver:s}){const[a,u]=L.useState(t),[c,h]=L.useState(t.available_rules[0]||""),[p,v]=L.useState(""),[x,y]=L.useState("");L.useEffect(()=>{u(t)},[t]);const m=Object.entries(a.contexts||{}),_=(R,w,N)=>{const A=a.contexts[R];if(!A)return;const $=F=>F.split(",").map(G=>G.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[R]:{...A,[w]:w==="name"?N:$(N)}}})},k=(R,w)=>{const N=w.trim();if(!N||N===R)return;const{[R]:A,...$}=a.contexts;A&&u({...a,contexts:{...$,[N]:{...A,name:N}}})},j=()=>{let R=1;for(;a.contexts[`context-${R}`];)R+=1;const w=`context-${R}`;u({...a,contexts:{...a.contexts,[w]:{name:w,django_apps:[],react:[],public_api:[],owners:[]}}})},b=R=>{const{[R]:w,...N}=a.contexts;u({...a,contexts:N})},E=R=>{const w=a.rules.includes(R);u({...a,rules:w?a.rules.filter(N=>N!==R):[...a.rules,R]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),m.map(([R,w])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:R})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:R,"data-testid":`config-context-name-${R}`,onBlur:N=>k(R,N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(w.django_apps||[]).join(", "),onChange:N=>_(R,"django_apps",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(w.react||[]).join(", "),onChange:N=>_(R,"react",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(w.public_api||[]).join(", "),onChange:N=>_(R,"public_api",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(w.owners||[]).join(", "),onChange:N=>_(R,"owners",N.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>b(R),children:"Remove context"})]},R)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:j,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(R),onChange:()=>E(R)}),R]},R))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((R,w)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:R.rule}),R.node?` · ${R.node}`:"",R.reason?` — ${R.reason}`:""]},`${R.rule}:${R.node}:${w}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:R=>h(R.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsx("option",{value:R,children:R},R))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:R=>v(R.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:x,onChange:R=>y(R.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,x),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function Qo(t){return t.replaceAll("_"," ")}function h0(t){return t.replaceAll("_"," ")}function ro(t){return t.split(".").pop()||t}function ec(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function p0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Tr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function yi({className:t,children:r}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function g0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function m0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function y0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function v0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function x0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function bp({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function w0({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const _0="modulepreload",S0=function(t,r){return new URL(t,r).href},ih={},k0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(x){return Promise.all(x.map(y=>Promise.resolve(y).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),v=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(x=>{if(x=S0(x,s),x in ih)return;ih[x]=!0;const y=x.endsWith(".css"),m=y?'[rel="stylesheet"]':"";if(!!s)for(let j=h.length-1;j>=0;j--){const b=h[j];if(b.href===x&&(!y||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${x}"]${m}`))return;const k=document.createElement("link");if(k.rel=y?"stylesheet":_0,y||(k.as="script"),k.crossOrigin="",k.href=x,v&&k.setAttribute("nonce",v),document.head.appendChild(k),y)return new Promise((j,b)=>{k.addEventListener("load",j),k.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${x}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function nt(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Yl(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}Cl.prototype=Yl.prototype={constructor:Cl,on:function(t,r){var o=this._,s=j0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),sh.hasOwnProperty(r)?{space:sh[r],local:t}:t}function E0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===tc&&r.documentElement.namespaceURI===tc?r.createElement(t):r.createElementNS(o,t)}}function C0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Ep(t){var r=Gl(t);return(r.local?C0:E0)(r)}function M0(){}function pc(t){return t==null?M0:function(){return this.querySelector(t)}}function P0(t){typeof t!="function"&&(t=pc(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=w&&(w=R+1);!(A=b[w])&&++w=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function tv(t){t||(t=nv);function r(y,m){return y&&m?t(y.__data__,m.__data__):!y-!m}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function rv(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function iv(){return Array.from(this)}function ov(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?mv:typeof r=="function"?vv:yv)(t,r,o??"")):Ki(this.node(),t)}function Ki(t,r){return t.style.getPropertyValue(r)||Rp(t).getComputedStyle(t,null).getPropertyValue(r)}function wv(t){return function(){delete this[t]}}function _v(t,r){return function(){this[t]=r}}function Sv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function kv(t,r){return arguments.length>1?this.each((r==null?wv:typeof r=="function"?Sv:_v)(t,r)):this.node()[t]}function Tp(t){return t.trim().split(/^|\s+/)}function gc(t){return t.classList||new Lp(t)}function Lp(t){this._node=t,this._names=Tp(t.getAttribute("class")||"")}Lp.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Ap(t,r){for(var o=gc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function Qv(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function nc(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:v,dispatch:x}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:v,enumerable:!0,configurable:!0},_:{value:x}})}nc.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function lx(t){return!t.ctrlKey&&!t.button}function ax(){return this.parentNode}function ux(t,r){return r??{x:t.x,y:t.y}}function cx(){return navigator.maxTouchPoints||"ontouchstart"in this}function Hp(){var t=lx,r=ax,o=ux,s=cx,a={},u=Yl("start","drag","end"),c=0,h,p,v,x,y=0;function m(N){N.on("mousedown.drag",_).filter(s).on("touchstart.drag",b).on("touchmove.drag",E,sx).on("touchend.drag touchcancel.drag",R).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(N,A){if(!(x||!t.call(this,N,A))){var $=w(this,r.call(this,N,A),N,A,"mouse");$&&(Gt(N.view).on("mousemove.drag",k,Zo).on("mouseup.drag",j,Zo),Op(N.view),Du(N),v=!1,h=N.clientX,p=N.clientY,$("start",N))}}function k(N){if(Xi(N),!v){var A=N.clientX-h,$=N.clientY-p;v=A*A+$*$>y}a.mouse("drag",N)}function j(N){Gt(N.view).on("mousemove.drag mouseup.drag",null),Fp(N.view,v),Xi(N),a.mouse("end",N)}function b(N,A){if(t.call(this,N,A)){var $=N.changedTouches,F=r.call(this,N,A),G=$.length,q,te;for(q=0;q>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?vl(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?vl(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=fx.exec(t))?new Dt(r[1],r[2],r[3],1):(r=hx.exec(t))?new Dt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=px.exec(t))?vl(r[1],r[2],r[3],r[4]):(r=gx.exec(t))?vl(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=mx.exec(t))?hh(r[1],r[2]/100,r[3]/100,1):(r=yx.exec(t))?hh(r[1],r[2]/100,r[3]/100,r[4]):lh.hasOwnProperty(t)?ch(lh[t]):t==="transparent"?new Dt(NaN,NaN,NaN,0):null}function ch(t){return new Dt(t>>16&255,t>>8&255,t&255,1)}function vl(t,r,o,s){return s<=0&&(t=r=o=NaN),new Dt(t,r,o,s)}function wx(t){return t instanceof ds||(t=fi(t)),t?(t=t.rgb(),new Dt(t.r,t.g,t.b,t.opacity)):new Dt}function rc(t,r,o,s){return arguments.length===1?wx(t):new Dt(t,r,o,s??1)}function Dt(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}mc(Dt,rc,Bp(ds,{brighter(t){return t=t==null?Ll:Math.pow(Ll,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Jo:Math.pow(Jo,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Dt(ci(this.r),ci(this.g),ci(this.b),Al(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:dh,formatHex:dh,formatHex8:_x,formatRgb:fh,toString:fh}));function dh(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}`}function _x(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}${ui((isNaN(this.opacity)?1:this.opacity)*255)}`}function fh(){const t=Al(this.opacity);return`${t===1?"rgb(":"rgba("}${ci(this.r)}, ${ci(this.g)}, ${ci(this.b)}${t===1?")":`, ${t})`}`}function Al(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ci(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ui(t){return t=ci(t),(t<16?"0":"")+t.toString(16)}function hh(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new hn(t,r,o,s)}function Vp(t){if(t instanceof hn)return new hn(t.h,t.s,t.l,t.opacity);if(t instanceof ds||(t=fi(t)),!t)return new hn;if(t instanceof hn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new hn(c,h,p,t.opacity)}function Sx(t,r,o,s){return arguments.length===1?Vp(t):new hn(t,r,o,s??1)}function hn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}mc(hn,Sx,Bp(ds,{brighter(t){return t=t==null?Ll:Math.pow(Ll,t),new hn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Jo:Math.pow(Jo,t),new hn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Dt(Ou(t>=240?t-240:t+120,a,s),Ou(t,a,s),Ou(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new hn(ph(this.h),xl(this.s),xl(this.l),Al(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 t=Al(this.opacity);return`${t===1?"hsl(":"hsla("}${ph(this.h)}, ${xl(this.s)*100}%, ${xl(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ph(t){return t=(t||0)%360,t<0?t+360:t}function xl(t){return Math.max(0,Math.min(1,t||0))}function Ou(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const yc=t=>()=>t;function kx(t,r){return function(o){return t+o*r}}function Nx(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function jx(t){return(t=+t)==1?Wp:function(r,o){return o-r?Nx(r,o,t):yc(isNaN(r)?o:r)}}function Wp(t,r){var o=r-t;return o?kx(t,o):yc(isNaN(t)?r:t)}const $l=(function t(r){var o=jx(r);function s(a,u){var c=o((a=rc(a)).r,(u=rc(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),v=Wp(a.opacity,u.opacity);return function(x){return a.r=c(x),a.g=h(x),a.b=p(x),a.opacity=v(x),a+""}}return s.gamma=t,s})(1);function bx(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:Rn(s,a)})),o=Fu.lastIndex;return o180?x+=360:x-v>180&&(v+=360),m.push({i:y.push(a(y)+"rotate(",null,s)-2,x:Rn(v,x)})):x&&y.push(a(y)+"rotate("+x+s)}function h(v,x,y,m){v!==x?m.push({i:y.push(a(y)+"skewX(",null,s)-2,x:Rn(v,x)}):x&&y.push(a(y)+"skewX("+x+s)}function p(v,x,y,m,_,k){if(v!==y||x!==m){var j=_.push(a(_)+"scale(",null,",",null,")");k.push({i:j-4,x:Rn(v,y)},{i:j-2,x:Rn(x,m)})}else(y!==1||m!==1)&&_.push(a(_)+"scale("+y+","+m+")")}return function(v,x){var y=[],m=[];return v=t(v),x=t(x),u(v.translateX,v.translateY,x.translateX,x.translateY,y,m),c(v.rotate,x.rotate,y,m),h(v.skewX,x.skewX,y,m),p(v.scaleX,v.scaleY,x.scaleX,x.scaleY,y,m),v=x=null,function(_){for(var k=-1,j=m.length,b;++k=0&&t._call.call(void 0,r),t=t._next;--Qi}function yh(){hi=(Dl=ts.now())+Xl,Qi=Go=0;try{Hx()}finally{Qi=0,Vx(),hi=0}}function Bx(){var t=ts.now(),r=t-Dl;r>Xp&&(Xl-=r,Dl=t)}function Vx(){for(var t,r=zl,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:zl=o);Xo=t,sc(s)}function sc(t){if(!Qi){Go&&(Go=clearTimeout(Go));var r=t-hi;r>24?(t<1/0&&(Go=setTimeout(yh,t-ts.now()-Xl)),Uo&&(Uo=clearInterval(Uo))):(Uo||(Dl=ts.now(),Uo=setInterval(Bx,Xp)),Qi=1,qp(yh))}}function vh(t,r,o){var s=new Ol;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Wx=Yl("start","end","cancel","interrupt"),Ux=[],Qp=0,xh=1,lc=2,Pl=3,wh=4,ac=5,Il=6;function ql(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;Yx(t,o,{name:r,index:s,group:a,on:Wx,tween:Ux,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Qp})}function xc(t,r){var o=yn(t,r);if(o.state>Qp)throw new Error("too late; already scheduled");return o}function Ln(t,r){var o=yn(t,r);if(o.state>Pl)throw new Error("too late; already running");return o}function yn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Yx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=Kp(u,0,o.time);function u(v){o.state=xh,o.timer.restart(c,o.delay,o.time),o.delay<=v&&c(v-o.delay)}function c(v){var x,y,m,_;if(o.state!==xh)return p();for(x in s)if(_=s[x],_.name===o.name){if(_.state===Pl)return vh(c);_.state===wh?(_.state=Il,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete s[x]):+xlc&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function Sw(t,r,o){var s,a,u=_w(r)?xc:Ln;return function(){var c=u(this,t),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function kw(t,r){var o=this._id;return arguments.length<2?yn(this.node(),o).on.on(t):this.each(Sw(o,t,r))}function Nw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function jw(){return this.on("end.remove",Nw(this._id))}function bw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=pc(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function Qw(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function rr(t,r,o){this.k=t,this.x=r,this.y=o}rr.prototype={constructor:rr,scale:function(t){return t===1?this:new rr(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new rr(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Kl=new rr(1,0,0);tg.prototype=rr.prototype;function tg(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Kl;return t.__zoom}function Hu(t){t.stopImmediatePropagation()}function Yo(t){t.preventDefault(),t.stopImmediatePropagation()}function Zw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Jw(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function _h(){return this.__zoom||Kl}function e1(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function t1(){return navigator.maxTouchPoints||"ontouchstart"in this}function n1(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function ng(){var t=Zw,r=Jw,o=n1,s=e1,a=t1,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=Ml,v=Yl("start","zoom","end"),x,y,m,_=500,k=150,j=0,b=10;function E(C){C.property("__zoom",_h).on("wheel.zoom",G,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",te).filter(a).on("touchstart.zoom",ee).on("touchmove.zoom",ne).on("touchend.zoom touchcancel.zoom",K).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(C,V,W,U){var M=C.selection?C.selection():C;M.property("__zoom",_h),C!==M?A(C,V,W,U):M.interrupt().each(function(){$(this,arguments).event(U).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},E.scaleBy=function(C,V,W,U){E.scaleTo(C,function(){var M=this.__zoom.k,D=typeof V=="function"?V.apply(this,arguments):V;return M*D},W,U)},E.scaleTo=function(C,V,W,U){E.transform(C,function(){var M=r.apply(this,arguments),D=this.__zoom,H=W==null?N(M):typeof W=="function"?W.apply(this,arguments):W,I=D.invert(H),z=typeof V=="function"?V.apply(this,arguments):V;return o(w(R(D,z),H,I),M,c)},W,U)},E.translateBy=function(C,V,W,U){E.transform(C,function(){return o(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),r.apply(this,arguments),c)},null,U)},E.translateTo=function(C,V,W,U,M){E.transform(C,function(){var D=r.apply(this,arguments),H=this.__zoom,I=U==null?N(D):typeof U=="function"?U.apply(this,arguments):U;return o(Kl.translate(I[0],I[1]).scale(H.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),D,c)},U,M)};function R(C,V){return V=Math.max(u[0],Math.min(u[1],V)),V===C.k?C:new rr(V,C.x,C.y)}function w(C,V,W){var U=V[0]-W[0]*C.k,M=V[1]-W[1]*C.k;return U===C.x&&M===C.y?C:new rr(C.k,U,M)}function N(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function A(C,V,W,U){C.on("start.zoom",function(){$(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(U).end()}).tween("zoom",function(){var M=this,D=arguments,H=$(M,D).event(U),I=r.apply(M,D),z=W==null?N(I):typeof W=="function"?W.apply(M,D):W,ie=Math.max(I[1][0]-I[0][0],I[1][1]-I[0][1]),oe=M.__zoom,fe=typeof V=="function"?V.apply(M,D):V,he=p(oe.invert(z).concat(ie/oe.k),fe.invert(z).concat(ie/fe.k));return function(pe){if(pe===1)pe=fe;else{var Z=he(pe),se=ie/Z[2];pe=new rr(se,z[0]-Z[0]*se,z[1]-Z[1]*se)}H.zoom(null,pe)}})}function $(C,V,W){return!W&&C.__zooming||new F(C,V)}function F(C,V){this.that=C,this.args=V,this.active=0,this.sourceEvent=null,this.extent=r.apply(C,V),this.taps=0}F.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,V){return this.mouse&&C!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var V=Gt(this.that).datum();v.call(C,this.that,new Qw(C,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:v}),V)}};function G(C,...V){if(!t.apply(this,arguments))return;var W=$(this,V).event(C),U=this.__zoom,M=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,s.apply(this,arguments)))),D=fn(C);if(W.wheel)(W.mouse[0][0]!==D[0]||W.mouse[0][1]!==D[1])&&(W.mouse[1]=U.invert(W.mouse[0]=D)),clearTimeout(W.wheel);else{if(U.k===M)return;W.mouse=[D,U.invert(D)],Rl(this),W.start()}Yo(C),W.wheel=setTimeout(H,k),W.zoom("mouse",o(w(R(U,M),W.mouse[0],W.mouse[1]),W.extent,c));function H(){W.wheel=null,W.end()}}function q(C,...V){if(m||!t.apply(this,arguments))return;var W=C.currentTarget,U=$(this,V,!0).event(C),M=Gt(C.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",ie,!0),D=fn(C,W),H=C.clientX,I=C.clientY;Op(C.view),Hu(C),U.mouse=[D,this.__zoom.invert(D)],Rl(this),U.start();function z(oe){if(Yo(oe),!U.moved){var fe=oe.clientX-H,he=oe.clientY-I;U.moved=fe*fe+he*he>j}U.event(oe).zoom("mouse",o(w(U.that.__zoom,U.mouse[0]=fn(oe,W),U.mouse[1]),U.extent,c))}function ie(oe){M.on("mousemove.zoom mouseup.zoom",null),Fp(oe.view,U.moved),Yo(oe),U.event(oe).end()}}function te(C,...V){if(t.apply(this,arguments)){var W=this.__zoom,U=fn(C.changedTouches?C.changedTouches[0]:C,this),M=W.invert(U),D=W.k*(C.shiftKey?.5:2),H=o(w(R(W,D),U,M),r.apply(this,V),c);Yo(C),h>0?Gt(this).transition().duration(h).call(A,H,U,C):Gt(this).call(E.transform,H,U,C)}}function ee(C,...V){if(t.apply(this,arguments)){var W=C.touches,U=W.length,M=$(this,V,C.changedTouches.length===U).event(C),D,H,I,z;for(Hu(C),H=0;H`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},ns=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],rg=["Enter"," ","Escape"],ig={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Zi;(function(t){t.Strict="strict",t.Loose="loose"})(Zi||(Zi={}));var di;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(di||(di={}));var rs;(function(t){t.Partial="partial",t.Full="full"})(rs||(rs={}));const og={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Lr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Lr||(Lr={}));var is;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(is||(is={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const Sh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function sg(t){return t===null?null:t?"valid":"invalid"}const lg=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,r1=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),_c=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),fs=(t,r=[0,0])=>{const{width:o,height:s}=vn(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},i1=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):_c(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,Ql(a,Fl(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?Zl(s):{x:0,y:0,width:0,height:0}},hs=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=Ql(o,Fl(a)),s=!0)}),s?Zl(o):{x:0,y:0,width:0,height:0}},Sc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,v=r.width/a,x=r.height/a,y=[];for(const m of t.values()){const{measured:_,selectable:k=!0,hidden:j=!1}=m;if(c&&!k||j)continue;const b=_.width??m.width??m.initialWidth??0,E=_.height??m.height??m.initialHeight??0,{x:R,y:w}=m.internals.positionAbsolute,N=dg(h,p,v,x,R,w,b,E),A=b*E,$=u&&N>0;(!m.internals.handleBounds||$||N>=A||m.dragging)&&y.push(m)}return y},o1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function s1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=vn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function l1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const h=s1(t,c),p=hs(h),v=Nc(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(v,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function ag({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),h=c.parentId?o.get(c.parentId):void 0,{x:p,y:v}=h?h.internals.positionAbsolute:{x:0,y:0},x=c.origin??s;let y=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",mn.error005());else{const{width:_,height:k}=vn(h);_&&k&&(y=[[p,v],[p+_,v+k]])}else h&&gi(c.extent)&&(y=[[c.extent[0][0]+p,c.extent[0][1]+v],[c.extent[1][0]+p,c.extent[1][1]+v]]);const m=gi(y)?pi(r,y,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",mn.error015())),{position:{x:m.x-p+(c.measured.width??0)*x[0],y:m.y-v+(c.measured.height??0)*x[1]},positionAbsolute:m}}async function a1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(m=>m.id)),c=[];for(const m of o){if(m.deletable===!1)continue;const _=u.has(m.id),k=!_&&m.parentId&&c.find(j=>j.id===m.parentId);(_||k)&&c.push(m)}const h=new Set(r.map(m=>m.id)),p=s.filter(m=>m.deletable!==!1),x=o1(c,p);for(const m of p)h.has(m.id)&&!x.find(k=>k.id===m.id)&&x.push(m);if(!a)return{edges:x,nodes:c};const y=await a({nodes:c,edges:x});return typeof y=="boolean"?y?{edges:x,nodes:c}:{edges:[],nodes:[]}:y}const Ji=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),pi=(t={x:0,y:0},r,o)=>({x:Ji(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:Ji(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function ug(t,r,o){const{width:s,height:a}=vn(o),{x:u,y:c}=o.internals.positionAbsolute;return pi(t,[[u,c],[u+s,c+a]],r)}const kh=(t,r,o)=>to?-Ji(Math.abs(t-o),1,r)/r:0,kc=(t,r,o=15,s=40)=>{const a=kh(t.x,s,r.width-s)*o,u=kh(t.y,s,r.height-s)*o;return[a,u]},Ql=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),uc=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),Zl=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),os=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:fs(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},Fl=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:fs(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},cg=(t,r)=>Zl(Ql(uc(t),uc(r))),dg=(t,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),v=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*v)},Hl=(t,r)=>dg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),Nh=t=>pn(t.width)&&pn(t.height)&&pn(t.x)&&pn(t.y),pn=t=>!isNaN(t)&&isFinite(t),fg=(t,r)=>(o,s)=>{},ps=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),gs=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(t-o)/a,y:(r-s)/a};return u?ps(h,c):h},eo=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Yi(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function u1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Yi(t,o),a=Yi(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Yi(t.top??t.y??0,o),a=Yi(t.bottom??t.y??0,o),u=Yi(t.left??t.x??0,r),c=Yi(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function c1(t,r,o,s,a,u){const{x:c,y:h}=eo(t,[r,o,s]),{x:p,y:v}=eo({x:t.x+t.width,y:t.y+t.height},[r,o,s]),x=a-p,y=u-v;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(x),bottom:Math.floor(y)}}const Nc=(t,r,o,s,a,u)=>{const c=u1(u,r,o),h=(r-c.x)/t.width,p=(o-c.y)/t.height,v=Math.min(h,p),x=Ji(v,s,a),y=t.x+t.width/2,m=t.y+t.height/2,_=r/2-y*x,k=o/2-m*x,j=c1(t,_,k,x,r,o),b={left:Math.min(j.left-c.left,0),top:Math.min(j.top-c.top,0),right:Math.min(j.right-c.right,0),bottom:Math.min(j.bottom-c.bottom,0)};return{x:_-b.left+b.right,y:k-b.top+b.bottom,zoom:x}},ss=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function gi(t){return t!=null&&t!=="parent"}function vn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function hg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function pg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function jh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function d1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function f1(t){return{...ig,...t||{}}}function Ko(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=gn(t),h=gs({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y:v}=o?ps(h,r):h;return{xSnapped:p,ySnapped:v,...h}}const jc=t=>({width:t.offsetWidth,height:t.offsetHeight}),gg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},h1=["INPUT","SELECT","TEXTAREA"];function mg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:h1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const yg=t=>"clientX"in t,gn=(t,r)=>{var u,c;const o=yg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},bh=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...jc(c)}})};function vg({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=t*.125+a*.375+c*.375+o*.125,v=r*.125+u*.375+h*.375+s*.125,x=Math.abs(p-t),y=Math.abs(v-r);return[p,v,x,y]}function Sl(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function Eh({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case Se.Left:return[r-Sl(r-s,u),o];case Se.Right:return[r+Sl(s-r,u),o];case Se.Top:return[r,o-Sl(o-a,u)];case Se.Bottom:return[r,o+Sl(a-o,u)]}}function xg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top,curvature:c=.25}){const[h,p]=Eh({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[v,x]=Eh({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[y,m,_,k]=vg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:v,targetControlY:x});return[`M${t},${r} C${h},${p} ${v},${x} ${s},${a}`,y,m,_,k]}function wg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const m1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,y1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),v1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",mn.error006()),r;const s=o.getEdgeId||m1;let a;return lg(t)?a={...t}:a={...t,id:s(t)},y1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function _g({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=wg({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,h]}const Ch={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},x1=({source:t,sourcePosition:r=Se.Bottom,target:o})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function w1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:s=Se.Top,center:a,offset:u,stepPosition:c}){const h=Ch[r],p=Ch[s],v={x:t.x+h.x*u,y:t.y+h.y*u},x={x:o.x+p.x*u,y:o.y+p.y*u},y=x1({source:v,sourcePosition:r,target:x}),m=y.x!==0?"x":"y",_=y[m];let k=[],j,b;const E={x:0,y:0},R={x:0,y:0},[,,w,N]=wg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[m]*p[m]===-1){m==="x"?(j=a.x??v.x+(x.x-v.x)*c,b=a.y??(v.y+x.y)/2):(j=a.x??(v.x+x.x)/2,b=a.y??v.y+(x.y-v.y)*c);const G=[{x:j,y:v.y},{x:j,y:x.y}],q=[{x:v.x,y:b},{x:x.x,y:b}];h[m]===_?k=m==="x"?G:q:k=m==="x"?q:G}else{const G=[{x:v.x,y:x.y}],q=[{x:x.x,y:v.y}];if(m==="x"?k=h.x===_?q:G:k=h.y===_?G:q,r===s){const C=Math.abs(t[m]-o[m]);if(C<=u){const V=Math.min(u-1,u-C);h[m]===_?E[m]=(v[m]>t[m]?-1:1)*V:R[m]=(x[m]>o[m]?-1:1)*V}}if(r!==s){const C=m==="x"?"y":"x",V=h[m]===p[C],W=v[C]>x[C],U=v[C]=K?(j=(te.x+ee.x)/2,b=k[0].y):(j=k[0].x,b=(te.y+ee.y)/2)}const A={x:v.x+E.x,y:v.y+E.y},$={x:x.x+R.x,y:x.y+R.y};return[[t,...A.x!==k[0].x||A.y!==k[0].y?[A]:[],...k,...$.x!==k[k.length-1].x||$.y!==k[k.length-1].y?[$]:[],o],j,b,w,N]}function _1(t,r,o,s){const a=Math.min(Mh(t,r)/2,Mh(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const v=t.xo.id===r):t[0])||null}function cc(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function k1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const v=cc(p,r);u.has(v)||(c.push({id:v,color:p.color||o,...p}),u.add(v))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const Sg=1e3,N1=10,bc={nodeOrigin:[0,0],nodeExtent:ns,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},j1={...bc,checkEquality:!0};function Ec(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function b1(t,r,o){const s=Ec(bc,o);for(const a of t.values())if(a.parentId)Mc(a,t,r,s);else{const u=fs(a,s.nodeOrigin),c=gi(a.extent)?a.extent:s.nodeExtent,h=pi(u,c,vn(a));a.internals.positionAbsolute=h}}function E1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function Cc(t){return t==="manual"}function dc(t,r,o,s={}){var x,y;const a=Ec(j1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!Cc(a.zIndexMode)?Sg:0;let p=t.length>0,v=!1;r.clear(),o.clear();for(const m of t){let _=c.get(m.id);if(a.checkEquality&&m===(_==null?void 0:_.internals.userNode))r.set(m.id,_);else{const k=fs(m,a.nodeOrigin),j=gi(m.extent)?m.extent:a.nodeExtent,b=pi(k,j,vn(m));_={...a.defaults,...m,measured:{width:(x=m.measured)==null?void 0:x.width,height:(y=m.measured)==null?void 0:y.height},internals:{positionAbsolute:b,handleBounds:E1(m,_),z:kg(m,h,a.zIndexMode),userNode:m}},r.set(m.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),m.parentId&&Mc(_,r,o,s,u),v||(v=m.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:v}}function C1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function Mc(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=Ec(bc,s),v=t.parentId,x=r.get(v);if(!x){console.warn(`Parent node ${v} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}C1(t,o),a&&!x.parentId&&x.internals.rootParentIndex===void 0&&p==="auto"&&(x.internals.rootParentIndex=++a.i,x.internals.z=x.internals.z+a.i*N1),a&&x.internals.rootParentIndex!==void 0&&(a.i=x.internals.rootParentIndex);const y=u&&!Cc(p)?Sg:0,{x:m,y:_,z:k}=M1(t,x,c,h,y,p),{positionAbsolute:j}=t.internals,b=m!==j.x||_!==j.y;(b||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:b?{x:m,y:_}:j,z:k}})}function kg(t,r,o){const s=pn(t.zIndex)?t.zIndex:0;return Cc(o)?s:s+(t.selected?r:0)}function M1(t,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=vn(t),v=fs(t,o),x=gi(t.extent)?pi(v,t.extent,p):v;let y=pi({x:c+x.x,y:h+x.y},s,p);t.extent==="parent"&&(y=ug(y,p,r));const m=kg(t,a,u),_=r.internals.z??0;return{x:y.x,y:y.y,z:_>=m?_+1:m}}function Pc(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const v=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??os(p),x=cg(v,h.rect);u.set(h.parentId,{expandedRect:x,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},v)=>{var w;const x=p.internals.positionAbsolute,y=vn(p),m=p.origin??s,_=h.x0||k>0||E||R)&&(a.push({id:v,type:"position",position:{x:p.position.x-_+E,y:p.position.y-k+R}}),(w=o.get(v))==null||w.forEach(N=>{t.some(A=>A.id===N.id)||a.push({id:N.id,type:"position",position:{x:N.position.x+_,y:N.position.y+k}})})),(y.width0){const _=Pc(m,r,o,a);v.push(..._)}return{changes:v,updatedInternals:p}}async function I1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Th(t,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${t}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${t}-${u}`;const v=s.get(c)||new Map;s.set(c,v.set(o,r))}}function Ng(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},v=`${a}-${c}--${u}-${h}`,x=`${u}-${h}--${a}-${c}`;Th("source",p,x,t,a,c),Th("target",p,v,t,u,h),r.set(s.id,s)}}function jg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:jg(o,r):!1}function Lh(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function R1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!jg(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function Bu({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[v,x]of r){const y=(c=o.get(v))==null?void 0:c.internals.userNode;y&&a.push({...y,position:x.position,dragging:s})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function T1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=ps(u,r);return{x:c.x-u.x,y:c.y-u.y}}function L1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,v={x:0,y:0},x=null,y=!1,m=null,_=!1,k=!1,j=null;function b({noDragClassName:R,handleSelector:w,domNode:N,isSelectable:A,nodeId:$,nodeClickDistance:F=0}){m=Gt(N);function G({x:ne,y:K}){const{nodeLookup:C,nodeExtent:V,snapGrid:W,snapToGrid:U,nodeOrigin:M,onNodeDrag:D,onSelectionDrag:H,onError:I,updateNodePositions:z}=r();u={x:ne,y:K};let ie=!1;const oe=h.size>1,fe=oe&&V?uc(hs(h)):null,he=oe&&U?T1({dragItems:h,snapGrid:W,x:ne,y:K}):null;for(const[pe,Z]of h){if(!C.has(pe))continue;let se={x:ne-Z.distance.x,y:K-Z.distance.y};U&&(se=he?{x:Math.round(se.x+he.x),y:Math.round(se.y+he.y)}:ps(se,W));let me=null;if(oe&&V&&!Z.extent&&fe){const{positionAbsolute:re}=Z.internals,Ne=re.x-fe.x+V[0][0],Me=re.x+Z.measured.width-fe.x2+V[1][0],Te=re.y-fe.y+V[0][1],$e=re.y+Z.measured.height-fe.y2+V[1][1];me=[[Ne,Te],[Me,$e]]}const{position:ke,positionAbsolute:ve}=ag({nodeId:pe,nextPosition:se,nodeLookup:C,nodeExtent:me||V,nodeOrigin:M,onError:I});ie=ie||Z.position.x!==ke.x||Z.position.y!==ke.y,Z.position=ke,Z.internals.positionAbsolute=ve}if(k=k||ie,!!ie&&(z(h,!0),j&&(s||D||!$&&H))){const[pe,Z]=Bu({nodeId:$,dragItems:h,nodeLookup:C});s==null||s(j,h,pe,Z),D==null||D(j,pe,Z),$||H==null||H(j,Z)}}async function q(){if(!x)return;const{transform:ne,panBy:K,autoPanSpeed:C,autoPanOnNodeDrag:V}=r();if(!V){p=!1,cancelAnimationFrame(c);return}const[W,U]=kc(v,x,C);(W!==0||U!==0)&&(u.x=(u.x??0)-W/ne[2],u.y=(u.y??0)-U/ne[2],await K({x:W,y:U})&&G(u)),c=requestAnimationFrame(q)}function te(ne){var oe;const{nodeLookup:K,multiSelectionActive:C,nodesDraggable:V,transform:W,snapGrid:U,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:H,onSelectionDragStart:I,unselectNodesAndEdges:z}=r();y=!0,(!D||!A)&&!C&&$&&((oe=K.get($))!=null&&oe.selected||z()),A&&D&&$&&(t==null||t($));const ie=Ko(ne.sourceEvent,{transform:W,snapGrid:U,snapToGrid:M,containerBounds:x});if(u=ie,h=R1(K,V,ie,$),h.size>0&&(o||H||!$&&I)){const[fe,he]=Bu({nodeId:$,dragItems:h,nodeLookup:K});o==null||o(ne.sourceEvent,h,fe,he),H==null||H(ne.sourceEvent,fe,he),$||I==null||I(ne.sourceEvent,he)}}const ee=Hp().clickDistance(F).on("start",ne=>{const{domNode:K,nodeDragThreshold:C,transform:V,snapGrid:W,snapToGrid:U}=r();x=(K==null?void 0:K.getBoundingClientRect())||null,_=!1,k=!1,j=ne.sourceEvent,C===0&&te(ne),u=Ko(ne.sourceEvent,{transform:V,snapGrid:W,snapToGrid:U,containerBounds:x}),v=gn(ne.sourceEvent,x)}).on("drag",ne=>{const{autoPanOnNodeDrag:K,transform:C,snapGrid:V,snapToGrid:W,nodeDragThreshold:U,nodeLookup:M}=r(),D=Ko(ne.sourceEvent,{transform:C,snapGrid:V,snapToGrid:W,containerBounds:x});if(j=ne.sourceEvent,(ne.sourceEvent.type==="touchmove"&&ne.sourceEvent.touches.length>1||$&&!M.has($))&&(_=!0),!_){if(!p&&K&&y&&(p=!0,q()),!y){const H=gn(ne.sourceEvent,x),I=H.x-v.x,z=H.y-v.y;Math.sqrt(I*I+z*z)>U&&te(ne)}(u.x!==D.xSnapped||u.y!==D.ySnapped)&&h&&y&&(v=gn(ne.sourceEvent,x),G(D))}}).on("end",ne=>{if(!y||_){_&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,y=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:K,updateNodePositions:C,onNodeDragStop:V,onSelectionDragStop:W}=r();if(k&&(C(h,!1),k=!1),a||V||!$&&W){const[U,M]=Bu({nodeId:$,dragItems:h,nodeLookup:K,dragging:!1});a==null||a(ne.sourceEvent,h,U,M),V==null||V(ne.sourceEvent,U,M),$||W==null||W(ne.sourceEvent,M)}}}).filter(ne=>{const K=ne.target;return!ne.button&&(!R||!Lh(K,`.${R}`,N))&&(!w||Lh(K,w,N))});m.call(ee)}function E(){m==null||m.on(".drag",null)}return{update:b,destroy:E}}function A1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())Hl(a,os(u))>0&&s.push(u);return s}const $1=250;function z1(t,r,o,s){var h,p;let a=[],u=1/0;const c=A1(t,o,r+$1);for(const v of c){const x=[...((h=v.internals.handleBounds)==null?void 0:h.source)??[],...((p=v.internals.handleBounds)==null?void 0:p.target)??[]];for(const y of x){if(s.nodeId===y.nodeId&&s.type===y.type&&s.id===y.id)continue;const{x:m,y:_}=mi(v,y,y.position,!0),k=Math.sqrt(Math.pow(m-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const v=s.type==="source"?"target":"source";return a.find(x=>x.type===v)??a[0]}return a[0]}function bg(t,r,o,s,a,u=!1){var v,x,y;const c=s.get(t);if(!c)return null;const h=a==="strict"?(v=c.internals.handleBounds)==null?void 0:v[r]:[...((x=c.internals.handleBounds)==null?void 0:x.source)??[],...((y=c.internals.handleBounds)==null?void 0:y.target)??[]],p=(o?h==null?void 0:h.find(m=>m.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...mi(c,p,p.position,!0)}:p}function Eg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function D1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const Cg=()=>!0;function O1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:v,autoPanOnConnect:x,flowId:y,panBy:m,cancelConnection:_,onConnectStart:k,onConnect:j,onConnectEnd:b,isValidConnection:E=Cg,onReconnectEnd:R,updateConnection:w,getTransform:N,getFromHandle:A,autoPanSpeed:$,dragThreshold:F=1,handleDomNode:G}){const q=gg(t.target);let te=0,ee;const{x:ne,y:K}=gn(t),C=Eg(u,G),V=h==null?void 0:h.getBoundingClientRect();let W=!1;if(!V||!C)return;const U=bg(a,C,s,p,r);if(!U)return;let M=gn(t,V),D=!1,H=null,I=!1,z=null;function ie(){if(!x||!V)return;const[ke,ve]=kc(M,V,$);m({x:ke,y:ve}),te=requestAnimationFrame(ie)}const oe={...U,nodeId:a,type:C,position:U.position},fe=p.get(a);let pe={inProgress:!0,isValid:null,from:mi(fe,oe,Se.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:fe,to:M,toHandle:null,toPosition:Sh[oe.position],toNode:null,pointer:M};function Z(){W=!0,w(pe),k==null||k(t,{nodeId:a,handleId:s,handleType:C})}F===0&&Z();function se(ke){if(!W){const{x:$e,y:st}=gn(ke),lt=$e-ne,at=st-K;if(!(lt*lt+at*at>F*F))return;Z()}if(!A()||!oe){me(ke);return}const ve=N();M=gn(ke,V),ee=z1(gs(M,ve,!1,[1,1]),o,p,oe),D||(ie(),D=!0);const re=Mg(ke,{handle:ee,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:E,doc:q,lib:v,flowId:y,nodeLookup:p});z=re.handleDomNode,H=re.connection,I=D1(!!ee,re.isValid);const Ne=p.get(a),Me=Ne?mi(Ne,oe,Se.Left,!0):pe.from,Te={...pe,from:Me,isValid:I,to:re.toHandle&&I?eo({x:re.toHandle.x,y:re.toHandle.y},ve):M,toHandle:re.toHandle,toPosition:I&&re.toHandle?re.toHandle.position:Sh[oe.position],toNode:re.toHandle?p.get(re.toHandle.nodeId):null,pointer:M};w(Te),pe=Te}function me(ke){if(!("touches"in ke&&ke.touches.length>0)){if(W){(ee||z)&&H&&I&&(j==null||j(H));const{inProgress:ve,...re}=pe,Ne={...re,toPosition:pe.toHandle?pe.toPosition:null};b==null||b(ke,Ne),u&&(R==null||R(ke,Ne))}_(),cancelAnimationFrame(te),D=!1,I=!1,H=null,z=null,q.removeEventListener("mousemove",se),q.removeEventListener("mouseup",me),q.removeEventListener("touchmove",se),q.removeEventListener("touchend",me)}}q.addEventListener("mousemove",se),q.addEventListener("mouseup",me),q.addEventListener("touchmove",se),q.addEventListener("touchend",me)}function Mg(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:v=Cg,nodeLookup:x}){const y=u==="target",m=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=gn(t),j=c.elementFromPoint(_,k),b=j!=null&&j.classList.contains(`${h}-flow__handle`)?j:m,E={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const R=Eg(void 0,b),w=b.getAttribute("data-nodeid"),N=b.getAttribute("data-handleid"),A=b.classList.contains("connectable"),$=b.classList.contains("connectableend");if(!w||!R)return E;const F={source:y?w:s,sourceHandle:y?N:a,target:y?s:w,targetHandle:y?a:N};E.connection=F;const q=A&&$&&(o===Zi.Strict?y&&R==="source"||!y&&R==="target":w!==s||N!==a);E.isValid=q&&v(F),E.toHandle=bg(w,R,N,x,o,!0)}return E}const fc={onPointerDown:O1,isValid:Mg};function F1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Gt(t);function u({translateExtent:h,width:p,height:v,zoomStep:x=1,pannable:y=!0,zoomable:m=!0,inversePan:_=!1}){const k=w=>{if(w.sourceEvent.type!=="wheel"||!r)return;const N=o(),A=w.sourceEvent.ctrlKey&&ss()?10:1,$=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*x,F=N[2]*Math.pow(2,$*A);r.scaleTo(F)};let j=[0,0];const b=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(j=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},E=w=>{const N=o();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!r)return;const A=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],$=[A[0]-j[0],A[1]-j[1]];j=A;const F=s()*Math.max(N[2],Math.log(N[2]))*(_?-1:1),G={x:N[0]-$[0]*F,y:N[1]-$[1]*F},q=[[0,0],[p,v]];r.setViewportConstrained({x:G.x,y:G.y,zoom:N[2]},q,h)},R=ng().on("start",b).on("zoom",y?E:null).on("zoom.wheel",m?k:null);a.call(R,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:fn}}const Jl=t=>({x:t.x,y:t.y,zoom:t.k}),Vu=({x:t,y:r,zoom:o})=>Kl.translate(t,r).scale(o),Rr=(t,r)=>t.target.closest(`.${r}`),Pg=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),H1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Wu=(t,r=0,o=H1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Ig=t=>{const r=t.ctrlKey&&ss()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function B1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:v}){return x=>{if(Rr(x,r))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const y=o.property("__zoom").k||1;if(x.ctrlKey&&c){const b=fn(x),E=Ig(x),R=y*Math.pow(2,E);s.scaleTo(o,R,b,x);return}const m=x.deltaMode===1?20:1;let _=a===di.Vertical?0:x.deltaX*m,k=a===di.Horizontal?0:x.deltaY*m;!ss()&&x.shiftKey&&a!==di.Vertical&&(_=x.deltaY*m,k=0),s.translateBy(o,-(_/y)*u,-(k/y)*u,{internal:!0});const j=Jl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(x,j):(t.isPanScrolling=!0,h==null||h(x,j)),t.panScrollTimeout=setTimeout(()=>{v==null||v(x,j),t.isPanScrolling=!1},150)}}function V1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=Rr(s,t);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function W1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=Jl(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function U1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;t.usedRightMouseButton=!!(o&&Pg(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,Jl(u.transform)))}}function Y1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&Pg(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const p=Jl(c.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function G1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:v,lib:x,connectionInProgress:y}){return m=>{var E;const _=r||o,k=s&&m.ctrlKey,j=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(Rr(m,`${x}-flow__node`)||Rr(m,`${x}-flow__edge`)||Rr(m,`${x}-flow__selection`)||Rr(m,`${x}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!c&&!s||h||y&&!j||Rr(m,p)&&j||Rr(m,v)&&(!j||u&&j&&!r)||!s&&m.ctrlKey&&j)return!1;if(!s&&m.type==="touchstart"&&((E=m.touches)==null?void 0:E.length)>1)return m.preventDefault(),!1;if(!_&&!u&&!k&&j||!a&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(a)&&!a.includes(m.button)&&m.type==="mousedown")return!1;const b=Array.isArray(a)&&a.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||j||t)&&b}}function X1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const v={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=t.getBoundingClientRect();let y=[[0,0],[x.width,x.height]];const m=typeof ResizeObserver<"u"?new ResizeObserver(K=>{const C=K[0];C&&(y=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;m==null||m.observe(t);const _=ng().extent(()=>y).scaleExtent([r,o]).translateExtent(s),k=Gt(t).call(_);N({x:a.x,y:a.y,zoom:Ji(a.zoom,r,o)},[[0,0],[x.width,x.height]],s);const j=k.on("wheel.zoom"),b=k.on("dblclick.zoom");_.wheelDelta(Ig);async function E(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?qo:Ml).transform(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function R({noWheelClassName:K,noPanClassName:C,onPaneContextMenu:V,userSelectionActive:W,panOnScroll:U,panOnDrag:M,panOnScrollMode:D,panOnScrollSpeed:H,preventScrolling:I,zoomOnPinch:z,zoomOnScroll:ie,zoomOnDoubleClick:oe,panActivationKeyPressed:fe=!1,zoomActivationKeyPressed:he,lib:pe,onTransformChange:Z,connectionInProgress:se,paneClickDistance:me,selectionOnDrag:ke}){W&&!v.isZoomingOrPanning&&w();const ve=U&&!he&&!W;_.clickDistance(ke?1/0:!pn(me)||me<0?0:me);const re=ve?B1({zoomPanValues:v,noWheelClassName:K,d3Selection:k,d3Zoom:_,panOnScrollMode:D,panOnScrollSpeed:H,zoomOnPinch:z,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):V1({noWheelClassName:K,preventScrolling:I,d3ZoomHandler:j});k.on("wheel.zoom",re,{passive:!1});const Ne=W1({zoomPanValues:v,onDraggingChange:p,onPanZoomStart:c});_.on("start",Ne);const Me=U1({zoomPanValues:v,panOnDrag:M,onPaneContextMenu:!!V,onPanZoom:u,onTransformChange:Z});_.on("zoom",Me);const Te=Y1({zoomPanValues:v,panOnDrag:M,panOnScroll:U,onPaneContextMenu:V,onPanZoomEnd:h,onDraggingChange:p});_.on("end",Te);const $e=G1({panActivationKeyPressed:fe,zoomActivationKeyPressed:he,panOnDrag:M,zoomOnScroll:ie,panOnScroll:U,zoomOnDoubleClick:oe,zoomOnPinch:z,userSelectionActive:W,noPanClassName:C,noWheelClassName:K,lib:pe,connectionInProgress:se});_.filter($e),oe?k.on("dblclick.zoom",b):k.on("dblclick.zoom",null)}function w(){_.on("zoom",null)}async function N(K,C,V){const W=Vu(K),U=_==null?void 0:_.constrain()(W,C,V);return U&&await E(U),U}async function A(K,C){const V=Vu(K);return await E(V,C),V}function $(K){if(k){const C=Vu(K),V=k.property("__zoom");(V.k!==K.zoom||V.x!==K.x||V.y!==K.y)&&(_==null||_.transform(k,C,null,{sync:!0}))}}function F(){const K=k?tg(k.node()):{x:0,y:0,k:1};return{x:K.x,y:K.y,zoom:K.k}}async function G(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?qo:Ml).scaleTo(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}async function q(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?qo:Ml).scaleBy(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function te(K){_==null||_.scaleExtent(K)}function ee(K){_==null||_.translateExtent(K)}function ne(K){const C=!pn(K)||K<0?0:K;_==null||_.clickDistance(C)}return{update:R,destroy:w,setViewport:A,setViewportConstrained:N,getViewport:F,scaleTo:G,scaleBy:q,setScaleExtent:te,setTranslateExtent:ee,syncViewport:$,setClickDistance:ne}}var to;(function(t){t.Line="line",t.Handle="handle"})(to||(to={}));function q1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function Ah(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function Pr(t,r){return Math.max(0,r-t)}function Ir(t,r){return Math.max(0,t-r)}function kl(t,r,o){return Math.max(0,r-t,t-o)}function $h(t,r){return t?!r:r}function K1(t,r,o,s,a,u,c,h){let{affectsX:p,affectsY:v}=r;const{isHorizontal:x,isVertical:y}=r,m=x&&y,{xSnapped:_,ySnapped:k}=o,{minWidth:j,maxWidth:b,minHeight:E,maxHeight:R}=s,{x:w,y:N,width:A,height:$,aspectRatio:F}=t;let G=Math.floor(x?_-t.pointerX:0),q=Math.floor(y?k-t.pointerY:0);const te=A+(p?-G:G),ee=$+(v?-q:q),ne=-u[0]*A,K=-u[1]*$;let C=kl(te,j,b),V=kl(ee,E,R);if(c){let M=0,D=0;p&&G<0?M=Pr(w+G+ne,c[0][0]):!p&&G>0&&(M=Ir(w+te+ne,c[1][0])),v&&q<0?D=Pr(N+q+K,c[0][1]):!v&&q>0&&(D=Ir(N+ee+K,c[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(h){let M=0,D=0;p&&G>0?M=Ir(w+G,h[0][0]):!p&&G<0&&(M=Pr(w+te,h[1][0])),v&&q>0?D=Ir(N+q,h[0][1]):!v&&q<0&&(D=Pr(N+ee,h[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(a){if(x){const M=kl(te/F,E,R)*F;if(C=Math.max(C,M),c){let D=0;!p&&!v||p&&!v&&m?D=Ir(N+K+te/F,c[1][1])*F:D=Pr(N+K+(p?G:-G)/F,c[0][1])*F,C=Math.max(C,D)}if(h){let D=0;!p&&!v||p&&!v&&m?D=Pr(N+te/F,h[1][1])*F:D=Ir(N+(p?G:-G)/F,h[0][1])*F,C=Math.max(C,D)}}if(y){const M=kl(ee*F,j,b)/F;if(V=Math.max(V,M),c){let D=0;!p&&!v||v&&!p&&m?D=Ir(w+ee*F+ne,c[1][0])/F:D=Pr(w+(v?q:-q)*F+ne,c[0][0])/F,V=Math.max(V,D)}if(h){let D=0;!p&&!v||v&&!p&&m?D=Pr(w+ee*F,h[1][0])/F:D=Ir(w+(v?q:-q)*F,h[0][0])/F,V=Math.max(V,D)}}}q=q+(q<0?V:-V),G=G+(G<0?C:-C),a&&(m?te>ee*F?q=($h(p,v)?-G:G)/F:G=($h(p,v)?-q:q)*F:x?(q=G/F,v=p):(G=q*F,p=v));const W=p?w+G:w,U=v?N+q:N;return{width:A+(p?-G:G),height:$+(v?-q:q),x:u[0]*G*(p?-1:1)+W,y:u[1]*q*(v?-1:1)+U}}const Rg={width:0,height:0,x:0,y:0},Q1={...Rg,pointerX:0,pointerY:0,aspectRatio:1};function Z1(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function J1({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Gt(t);let c={controlDirection:Ah("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:v,boundaries:x,keepAspectRatio:y,resizeDirection:m,onResizeStart:_,onResize:k,onResizeEnd:j,shouldResize:b}){let E={...Rg},R={...Q1};c={boundaries:x,resizeDirection:m,keepAspectRatio:y,controlDirection:Ah(v)};let w,N=null,A=[],$,F,G,q=!1;const te=Hp().on("start",ee=>{const{nodeLookup:ne,transform:K,snapGrid:C,snapToGrid:V,nodeOrigin:W,paneDomNode:U}=o();if(w=ne.get(r),!w)return;N=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:D}=Ko(ee.sourceEvent,{transform:K,snapGrid:C,snapToGrid:V,containerBounds:N});E={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},R={...E,pointerX:M,pointerY:D,aspectRatio:E.width/E.height},$=void 0,F=gi(w.extent)?w.extent:void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&($=ne.get(w.parentId)),$&&w.extent==="parent"&&(F=[[0,0],[$.measured.width,$.measured.height]]),A=[],G=void 0;for(const[H,I]of ne)if(I.parentId===r&&(A.push({id:H,position:{...I.position},extent:I.extent}),I.extent==="parent"||I.expandParent)){const z=Z1(I,w,I.origin??W);G?G=[[Math.min(z[0][0],G[0][0]),Math.min(z[0][1],G[0][1])],[Math.max(z[1][0],G[1][0]),Math.max(z[1][1],G[1][1])]]:G=z}_==null||_(ee,{...E})}).on("drag",ee=>{const{transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V}=o(),W=Ko(ee.sourceEvent,{transform:ne,snapGrid:K,snapToGrid:C,containerBounds:N}),U=[];if(!w)return;const{x:M,y:D,width:H,height:I}=E,z={},ie=w.origin??V,{width:oe,height:fe,x:he,y:pe}=K1(R,c.controlDirection,W,c.boundaries,c.keepAspectRatio,ie,F,G),Z=oe!==H,se=fe!==I,me=he!==M&&Z,ke=pe!==D&&se;if(!me&&!ke&&!Z&&!se)return;if((me||ke||ie[0]===1||ie[1]===1)&&(z.x=me?he:E.x,z.y=ke?pe:E.y,E.x=z.x,E.y=z.y,A.length>0)){const Me=he-M,Te=pe-D;for(const $e of A)$e.position={x:$e.position.x-Me+ie[0]*(oe-H),y:$e.position.y-Te+ie[1]*(fe-I)},U.push($e)}if((Z||se)&&(z.width=Z&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:E.width,z.height=se&&(!c.resizeDirection||c.resizeDirection==="vertical")?fe:E.height,E.width=z.width,E.height=z.height),$&&w.expandParent){const Me=ie[0]*(z.width??0);z.x&&z.x{q&&(j==null||j(ee,{...E}),a==null||a({...E}),q=!1)});u.call(te)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Uu={exports:{}},Yu={},Gu={exports:{}},Xu={};/** +`+g.stack}return{value:e,source:n,stack:f,digest:null}}function ru(e,n,i){return{value:e,source:null,stack:i??null,digest:n??null}}function iu(e,n){try{console.error(n.value)}catch(i){setTimeout(function(){throw i})}}var Cy=typeof WeakMap=="function"?WeakMap:Map;function rf(e,n,i){i=Jn(-1,i),i.tag=3,i.payload={element:null};var l=n.value;return i.callback=function(){nl||(nl=!0,xu=l),iu(e,n)},i}function of(e,n,i){i=Jn(-1,i),i.tag=3;var l=e.type.getDerivedStateFromError;if(typeof l=="function"){var f=n.value;i.payload=function(){return l(f)},i.callback=function(){iu(e,n)}}var g=e.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(i.callback=function(){iu(e,n),typeof l!="function"&&(Nr===null?Nr=new Set([this]):Nr.add(this));var S=n.stack;this.componentDidCatch(n.value,{componentStack:S!==null?S:""})}),i}function sf(e,n,i){var l=e.pingCache;if(l===null){l=e.pingCache=new Cy;var f=new Set;l.set(n,f)}else f=l.get(n),f===void 0&&(f=new Set,l.set(n,f));f.has(i)||(f.add(i),e=By.bind(null,e,n,i),n.then(e,e))}function lf(e){do{var n;if((n=e.tag===13)&&(n=e.memoizedState,n=n!==null?n.dehydrated!==null:!0),n)return e;e=e.return}while(e!==null);return null}function af(e,n,i,l,f){return(e.mode&1)===0?(e===n?e.flags|=65536:(e.flags|=128,i.flags|=131072,i.flags&=-52805,i.tag===1&&(i.alternate===null?i.tag=17:(n=Jn(-1,1),n.tag=2,Sr(i,n,1))),i.lanes|=1),e):(e.flags|=65536,e.lanes=f,e)}var My=N.ReactCurrentOwner,Lt=!1;function Ct(e,n,i,l){n.child=e===null?Ed(n,null,i,l):zi(n,e.child,i,l)}function uf(e,n,i,l,f){i=i.render;var g=n.ref;return Oi(n,f),l=qa(e,n,i,l,g,f),i=Ka(),e!==null&&!Lt?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~f,er(e,n,f)):(Xe&&i&&Ra(n),n.flags|=1,Ct(e,n,l,f),n.child)}function cf(e,n,i,l,f){if(e===null){var g=i.type;return typeof g=="function"&&!bu(g)&&g.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(n.tag=15,n.type=g,df(e,n,g,l,f)):(e=al(i.type,null,l,n,n.mode,f),e.ref=n.ref,e.return=n,n.child=e)}if(g=e.child,(e.lanes&f)===0){var S=g.memoizedProps;if(i=i.compare,i=i!==null?i:No,i(S,l)&&e.ref===n.ref)return er(e,n,f)}return n.flags|=1,e=Cr(g,l),e.ref=n.ref,e.return=n,n.child=e}function df(e,n,i,l,f){if(e!==null){var g=e.memoizedProps;if(No(g,l)&&e.ref===n.ref)if(Lt=!1,n.pendingProps=l=g,(e.lanes&f)!==0)(e.flags&131072)!==0&&(Lt=!0);else return n.lanes=e.lanes,er(e,n,f)}return ou(e,n,i,l,f)}function ff(e,n,i){var l=n.pendingProps,f=l.children,g=e!==null?e.memoizedState:null;if(l.mode==="hidden")if((n.mode&1)===0)n.memoizedState={baseLanes:0,cachePool:null,transitions:null},Be(Vi,Yt),Yt|=i;else{if((i&1073741824)===0)return e=g!==null?g.baseLanes|i:i,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:e,cachePool:null,transitions:null},n.updateQueue=null,Be(Vi,Yt),Yt|=e,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=g!==null?g.baseLanes:i,Be(Vi,Yt),Yt|=l}else g!==null?(l=g.baseLanes|i,n.memoizedState=null):l=i,Be(Vi,Yt),Yt|=l;return Ct(e,n,f,i),n.child}function hf(e,n){var i=n.ref;(e===null&&i!==null||e!==null&&e.ref!==i)&&(n.flags|=512,n.flags|=2097152)}function ou(e,n,i,l,f){var g=Tt(i)?Qr:St.current;return g=Ti(n,g),Oi(n,f),i=qa(e,n,i,l,g,f),l=Ka(),e!==null&&!Lt?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~f,er(e,n,f)):(Xe&&l&&Ra(n),n.flags|=1,Ct(e,n,i,f),n.child)}function pf(e,n,i,l,f){if(Tt(i)){var g=!0;Ts(n)}else g=!1;if(Oi(n,f),n.stateNode===null)Qs(e,n),tf(n,i,l),nu(n,i,l,f),l=!0;else if(e===null){var S=n.stateNode,T=n.memoizedProps;S.props=T;var O=S.context,J=i.contextType;typeof J=="object"&&J!==null?J=Zt(J):(J=Tt(i)?Qr:St.current,J=Ti(n,J));var ae=i.getDerivedStateFromProps,ue=typeof ae=="function"||typeof S.getSnapshotBeforeUpdate=="function";ue||typeof S.UNSAFE_componentWillReceiveProps!="function"&&typeof S.componentWillReceiveProps!="function"||(T!==l||O!==J)&&nf(n,S,l,J),_r=!1;var le=n.memoizedState;S.state=le,Bs(n,l,S,f),O=n.memoizedState,T!==l||le!==O||Rt.current||_r?(typeof ae=="function"&&(tu(n,i,ae,l),O=n.memoizedState),(T=_r||ef(n,i,T,l,le,O,J))?(ue||typeof S.UNSAFE_componentWillMount!="function"&&typeof S.componentWillMount!="function"||(typeof S.componentWillMount=="function"&&S.componentWillMount(),typeof S.UNSAFE_componentWillMount=="function"&&S.UNSAFE_componentWillMount()),typeof S.componentDidMount=="function"&&(n.flags|=4194308)):(typeof S.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=l,n.memoizedState=O),S.props=l,S.state=O,S.context=J,l=T):(typeof S.componentDidMount=="function"&&(n.flags|=4194308),l=!1)}else{S=n.stateNode,Md(e,n),T=n.memoizedProps,J=n.type===n.elementType?T:an(n.type,T),S.props=J,ue=n.pendingProps,le=S.context,O=i.contextType,typeof O=="object"&&O!==null?O=Zt(O):(O=Tt(i)?Qr:St.current,O=Ti(n,O));var ge=i.getDerivedStateFromProps;(ae=typeof ge=="function"||typeof S.getSnapshotBeforeUpdate=="function")||typeof S.UNSAFE_componentWillReceiveProps!="function"&&typeof S.componentWillReceiveProps!="function"||(T!==ue||le!==O)&&nf(n,S,l,O),_r=!1,le=n.memoizedState,S.state=le,Bs(n,l,S,f);var xe=n.memoizedState;T!==ue||le!==xe||Rt.current||_r?(typeof ge=="function"&&(tu(n,i,ge,l),xe=n.memoizedState),(J=_r||ef(n,i,J,l,le,xe,O)||!1)?(ae||typeof S.UNSAFE_componentWillUpdate!="function"&&typeof S.componentWillUpdate!="function"||(typeof S.componentWillUpdate=="function"&&S.componentWillUpdate(l,xe,O),typeof S.UNSAFE_componentWillUpdate=="function"&&S.UNSAFE_componentWillUpdate(l,xe,O)),typeof S.componentDidUpdate=="function"&&(n.flags|=4),typeof S.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof S.componentDidUpdate!="function"||T===e.memoizedProps&&le===e.memoizedState||(n.flags|=4),typeof S.getSnapshotBeforeUpdate!="function"||T===e.memoizedProps&&le===e.memoizedState||(n.flags|=1024),n.memoizedProps=l,n.memoizedState=xe),S.props=l,S.state=xe,S.context=O,l=J):(typeof S.componentDidUpdate!="function"||T===e.memoizedProps&&le===e.memoizedState||(n.flags|=4),typeof S.getSnapshotBeforeUpdate!="function"||T===e.memoizedProps&&le===e.memoizedState||(n.flags|=1024),l=!1)}return su(e,n,i,l,g,f)}function su(e,n,i,l,f,g){hf(e,n);var S=(n.flags&128)!==0;if(!l&&!S)return f&&vd(n,i,!1),er(e,n,g);l=n.stateNode,My.current=n;var T=S&&typeof i.getDerivedStateFromError!="function"?null:l.render();return n.flags|=1,e!==null&&S?(n.child=zi(n,e.child,null,g),n.child=zi(n,null,T,g)):Ct(e,n,T,g),n.memoizedState=l.state,f&&vd(n,i,!0),n.child}function gf(e){var n=e.stateNode;n.pendingContext?md(e,n.pendingContext,n.pendingContext!==n.context):n.context&&md(e,n.context,!1),Va(e,n.containerInfo)}function mf(e,n,i,l,f){return $i(),$a(f),n.flags|=256,Ct(e,n,i,l),n.child}var lu={dehydrated:null,treeContext:null,retryLane:0};function au(e){return{baseLanes:e,cachePool:null,transitions:null}}function yf(e,n,i){var l=n.pendingProps,f=qe.current,g=!1,S=(n.flags&128)!==0,T;if((T=S)||(T=e!==null&&e.memoizedState===null?!1:(f&2)!==0),T?(g=!0,n.flags&=-129):(e===null||e.memoizedState!==null)&&(f|=1),Be(qe,f&1),e===null)return Aa(n),e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?((n.mode&1)===0?n.lanes=1:e.data==="$!"?n.lanes=8:n.lanes=1073741824,null):(S=l.children,e=l.fallback,g?(l=n.mode,g=n.child,S={mode:"hidden",children:S},(l&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=S):g=ul(S,l,0,null),e=li(e,l,i,null),g.return=n,e.return=n,g.sibling=e,n.child=g,n.child.memoizedState=au(i),n.memoizedState=lu,e):uu(n,S));if(f=e.memoizedState,f!==null&&(T=f.dehydrated,T!==null))return Py(e,n,S,l,T,f,i);if(g){g=l.fallback,S=n.mode,f=e.child,T=f.sibling;var O={mode:"hidden",children:l.children};return(S&1)===0&&n.child!==f?(l=n.child,l.childLanes=0,l.pendingProps=O,n.deletions=null):(l=Cr(f,O),l.subtreeFlags=f.subtreeFlags&14680064),T!==null?g=Cr(T,g):(g=li(g,S,i,null),g.flags|=2),g.return=n,l.return=n,l.sibling=g,n.child=l,l=g,g=n.child,S=e.child.memoizedState,S=S===null?au(i):{baseLanes:S.baseLanes|i,cachePool:null,transitions:S.transitions},g.memoizedState=S,g.childLanes=e.childLanes&~i,n.memoizedState=lu,l}return g=e.child,e=g.sibling,l=Cr(g,{mode:"visible",children:l.children}),(n.mode&1)===0&&(l.lanes=i),l.return=n,l.sibling=null,e!==null&&(i=n.deletions,i===null?(n.deletions=[e],n.flags|=16):i.push(e)),n.child=l,n.memoizedState=null,l}function uu(e,n){return n=ul({mode:"visible",children:n},e.mode,0,null),n.return=e,e.child=n}function Ks(e,n,i,l){return l!==null&&$a(l),zi(n,e.child,null,i),e=uu(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Py(e,n,i,l,f,g,S){if(i)return n.flags&256?(n.flags&=-257,l=ru(Error(o(422))),Ks(e,n,S,l)):n.memoizedState!==null?(n.child=e.child,n.flags|=128,null):(g=l.fallback,f=n.mode,l=ul({mode:"visible",children:l.children},f,0,null),g=li(g,f,S,null),g.flags|=2,l.return=n,g.return=n,l.sibling=g,n.child=l,(n.mode&1)!==0&&zi(n,e.child,null,S),n.child.memoizedState=au(S),n.memoizedState=lu,g);if((n.mode&1)===0)return Ks(e,n,S,null);if(f.data==="$!"){if(l=f.nextSibling&&f.nextSibling.dataset,l)var T=l.dgst;return l=T,g=Error(o(419)),l=ru(g,l,void 0),Ks(e,n,S,l)}if(T=(S&e.childLanes)!==0,Lt||T){if(l=ht,l!==null){switch(S&-S){case 4:f=2;break;case 16:f=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:f=32;break;case 536870912:f=268435456;break;default:f=0}f=(f&(l.suspendedLanes|S))!==0?0:f,f!==0&&f!==g.retryLane&&(g.retryLane=f,Zn(e,f),dn(l,e,f,-1))}return ju(),l=ru(Error(o(421))),Ks(e,n,S,l)}return f.data==="$?"?(n.flags|=128,n.child=e.child,n=Vy.bind(null,e),f._reactRetry=n,null):(e=g.treeContext,Ut=yr(f.nextSibling),Wt=n,Xe=!0,ln=null,e!==null&&(Kt[Qt++]=Kn,Kt[Qt++]=Qn,Kt[Qt++]=Zr,Kn=e.id,Qn=e.overflow,Zr=n),n=uu(n,l.children),n.flags|=4096,n)}function vf(e,n,i){e.lanes|=n;var l=e.alternate;l!==null&&(l.lanes|=n),Fa(e.return,n,i)}function cu(e,n,i,l,f){var g=e.memoizedState;g===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:l,tail:i,tailMode:f}:(g.isBackwards=n,g.rendering=null,g.renderingStartTime=0,g.last=l,g.tail=i,g.tailMode=f)}function xf(e,n,i){var l=n.pendingProps,f=l.revealOrder,g=l.tail;if(Ct(e,n,l.children,i),l=qe.current,(l&2)!==0)l=l&1|2,n.flags|=128;else{if(e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&vf(e,i,n);else if(e.tag===19)vf(e,i,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}l&=1}if(Be(qe,l),(n.mode&1)===0)n.memoizedState=null;else switch(f){case"forwards":for(i=n.child,f=null;i!==null;)e=i.alternate,e!==null&&Vs(e)===null&&(f=i),i=i.sibling;i=f,i===null?(f=n.child,n.child=null):(f=i.sibling,i.sibling=null),cu(n,!1,f,i,g);break;case"backwards":for(i=null,f=n.child,n.child=null;f!==null;){if(e=f.alternate,e!==null&&Vs(e)===null){n.child=f;break}e=f.sibling,f.sibling=i,i=f,f=e}cu(n,!0,i,null,g);break;case"together":cu(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function Qs(e,n){(n.mode&1)===0&&e!==null&&(e.alternate=null,n.alternate=null,n.flags|=2)}function er(e,n,i){if(e!==null&&(n.dependencies=e.dependencies),ri|=n.lanes,(i&n.childLanes)===0)return null;if(e!==null&&n.child!==e.child)throw Error(o(153));if(n.child!==null){for(e=n.child,i=Cr(e,e.pendingProps),n.child=i,i.return=n;e.sibling!==null;)e=e.sibling,i=i.sibling=Cr(e,e.pendingProps),i.return=n;i.sibling=null}return n.child}function Iy(e,n,i){switch(n.tag){case 3:gf(n),$i();break;case 5:Rd(n);break;case 1:Tt(n.type)&&Ts(n);break;case 4:Va(n,n.stateNode.containerInfo);break;case 10:var l=n.type._context,f=n.memoizedProps.value;Be(Os,l._currentValue),l._currentValue=f;break;case 13:if(l=n.memoizedState,l!==null)return l.dehydrated!==null?(Be(qe,qe.current&1),n.flags|=128,null):(i&n.child.childLanes)!==0?yf(e,n,i):(Be(qe,qe.current&1),e=er(e,n,i),e!==null?e.sibling:null);Be(qe,qe.current&1);break;case 19:if(l=(i&n.childLanes)!==0,(e.flags&128)!==0){if(l)return xf(e,n,i);n.flags|=128}if(f=n.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),Be(qe,qe.current),l)break;return null;case 22:case 23:return n.lanes=0,ff(e,n,i)}return er(e,n,i)}var wf,du,_f,Sf;wf=function(e,n){for(var i=n.child;i!==null;){if(i.tag===5||i.tag===6)e.appendChild(i.stateNode);else if(i.tag!==4&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===n)break;for(;i.sibling===null;){if(i.return===null||i.return===n)return;i=i.return}i.sibling.return=i.return,i=i.sibling}},du=function(){},_f=function(e,n,i,l){var f=e.memoizedProps;if(f!==l){e=n.stateNode,ti(Mn.current);var g=null;switch(i){case"input":f=Ne(e,f),l=Ne(e,l),g=[];break;case"select":f=H({},f,{value:void 0}),l=H({},l,{value:void 0}),g=[];break;case"textarea":f=wt(e,f),l=wt(e,l),g=[];break;default:typeof f.onClick!="function"&&typeof l.onClick=="function"&&(e.onclick=Ps)}$r(i,l);var S;i=null;for(J in f)if(!l.hasOwnProperty(J)&&f.hasOwnProperty(J)&&f[J]!=null)if(J==="style"){var T=f[J];for(S in T)T.hasOwnProperty(S)&&(i||(i={}),i[S]="")}else J!=="dangerouslySetInnerHTML"&&J!=="children"&&J!=="suppressContentEditableWarning"&&J!=="suppressHydrationWarning"&&J!=="autoFocus"&&(a.hasOwnProperty(J)?g||(g=[]):(g=g||[]).push(J,null));for(J in l){var O=l[J];if(T=f!=null?f[J]:void 0,l.hasOwnProperty(J)&&O!==T&&(O!=null||T!=null))if(J==="style")if(T){for(S in T)!T.hasOwnProperty(S)||O&&O.hasOwnProperty(S)||(i||(i={}),i[S]="");for(S in O)O.hasOwnProperty(S)&&T[S]!==O[S]&&(i||(i={}),i[S]=O[S])}else i||(g||(g=[]),g.push(J,i)),i=O;else J==="dangerouslySetInnerHTML"?(O=O?O.__html:void 0,T=T?T.__html:void 0,O!=null&&T!==O&&(g=g||[]).push(J,O)):J==="children"?typeof O!="string"&&typeof O!="number"||(g=g||[]).push(J,""+O):J!=="suppressContentEditableWarning"&&J!=="suppressHydrationWarning"&&(a.hasOwnProperty(J)?(O!=null&&J==="onScroll"&&We("scroll",e),g||T===O||(g=[])):(g=g||[]).push(J,O))}i&&(g=g||[]).push("style",i);var J=g;(n.updateQueue=J)&&(n.flags|=4)}},Sf=function(e,n,i,l){i!==l&&(n.flags|=4)};function Oo(e,n){if(!Xe)switch(e.tailMode){case"hidden":n=e.tail;for(var i=null;n!==null;)n.alternate!==null&&(i=n),n=n.sibling;i===null?e.tail=null:i.sibling=null;break;case"collapsed":i=e.tail;for(var l=null;i!==null;)i.alternate!==null&&(l=i),i=i.sibling;l===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function Nt(e){var n=e.alternate!==null&&e.alternate.child===e.child,i=0,l=0;if(n)for(var f=e.child;f!==null;)i|=f.lanes|f.childLanes,l|=f.subtreeFlags&14680064,l|=f.flags&14680064,f.return=e,f=f.sibling;else for(f=e.child;f!==null;)i|=f.lanes|f.childLanes,l|=f.subtreeFlags,l|=f.flags,f.return=e,f=f.sibling;return e.subtreeFlags|=l,e.childLanes=i,n}function Ry(e,n,i){var l=n.pendingProps;switch(Ta(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Nt(n),null;case 1:return Tt(n.type)&&Rs(),Nt(n),null;case 3:return l=n.stateNode,Fi(),Ue(Rt),Ue(St),Ya(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(zs(n)?n.flags|=4:e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,ln!==null&&(Su(ln),ln=null))),du(e,n),Nt(n),null;case 5:Wa(n);var f=ti(Lo.current);if(i=n.type,e!==null&&n.stateNode!=null)_f(e,n,i,l,f),e.ref!==n.ref&&(n.flags|=512,n.flags|=2097152);else{if(!l){if(n.stateNode===null)throw Error(o(166));return Nt(n),null}if(e=ti(Mn.current),zs(n)){l=n.stateNode,i=n.type;var g=n.memoizedProps;switch(l[Cn]=n,l[Mo]=g,e=(n.mode&1)!==0,i){case"dialog":We("cancel",l),We("close",l);break;case"iframe":case"object":case"embed":We("load",l);break;case"video":case"audio":for(f=0;f<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=S.createElement(i,{is:l.is}):(e=S.createElement(i),i==="select"&&(S=e,l.multiple?S.multiple=!0:l.size&&(S.size=l.size))):e=S.createElementNS(e,i),e[Cn]=n,e[Mo]=l,wf(e,n,!1,!1),n.stateNode=e;e:{switch(S=zn(i,l),i){case"dialog":We("cancel",e),We("close",e),f=l;break;case"iframe":case"object":case"embed":We("load",e),f=l;break;case"video":case"audio":for(f=0;fWi&&(n.flags|=128,l=!0,Oo(g,!1),n.lanes=4194304)}else{if(!l)if(e=Vs(S),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Oo(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Xe)return Nt(n),null}else 2*Ve()-g.renderingStartTime>Wi&&i!==1073741824&&(n.flags|=128,l=!0,Oo(g,!1),n.lanes=4194304);g.isBackwards?(S.sibling=n.child,n.child=S):(i=g.last,i!==null?i.sibling=S:n.child=S,g.last=S)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(Nt(n),null);case 22:case 23:return Nu(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Yt&1073741824)!==0&&(Nt(n),n.subtreeFlags&6&&(n.flags|=8192)):Nt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function Ty(e,n){switch(Ta(n),n.tag){case 1:return Tt(n.type)&&Rs(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Fi(),Ue(Rt),Ue(St),Ya(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Wa(n),null;case 13:if(Ue(qe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));$i()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Fi(),null;case 10:return Oa(n.type._context),null;case 22:case 23:return Nu(),null;case 24:return null;default:return null}}var Zs=!1,jt=!1,Ly=typeof WeakSet=="function"?WeakSet:Set,ye=null;function Bi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Ze(e,n,l)}else i.current=null}function fu(e,n,i){try{i()}catch(l){Ze(e,n,l)}}var kf=!1;function Ay(e,n){if(Na=vs,e=ed(),ma(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,g=l.focusNode;l=l.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var S=0,T=-1,O=-1,J=0,ae=0,ue=e,le=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=S+f),ue!==g||l!==0&&ue.nodeType!==3||(O=S+l),ue.nodeType===3&&(S+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)le=ue,ue=ge;for(;;){if(ue===e)break t;if(le===i&&++J===f&&(T=S),le===g&&++ae===l&&(O=S),(ge=ue.nextSibling)!==null)break;ue=le,le=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(ja={focusedElem:e,selectionRange:i},vs=!1,ye=n;ye!==null;)if(n=ye,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ye=e;else for(;ye!==null;){n=ye;try{var xe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var we=xe.memoizedProps,et=xe.memoizedState,X=n.stateNode,B=X.getSnapshotBeforeUpdate(n.elementType===n.type?we:an(n.type,we),et);X.__reactInternalSnapshotBeforeUpdate=B}break;case 3:var Q=n.stateNode.containerInfo;Q.nodeType===1?Q.textContent="":Q.nodeType===9&&Q.documentElement&&Q.removeChild(Q.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(de){Ze(n,n.return,de)}if(e=n.sibling,e!==null){e.return=n.return,ye=e;break}ye=n.return}return xe=kf,kf=!1,xe}function Fo(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&e)===e){var g=f.destroy;f.destroy=void 0,g!==void 0&&fu(n,i,g)}f=f.next}while(f!==l)}}function Js(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function hu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function Nf(e){var n=e.alternate;n!==null&&(e.alternate=null,Nf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[Cn],delete n[Mo],delete n[Ma],delete n[yy],delete n[vy])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function jf(e){return e.tag===5||e.tag===3||e.tag===4}function bf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||jf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function pu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=Ps));else if(l!==4&&(e=e.child,e!==null))for(pu(e,n,i),e=e.sibling;e!==null;)pu(e,n,i),e=e.sibling}function gu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(gu(e,n,i),e=e.sibling;e!==null;)gu(e,n,i),e=e.sibling}var vt=null,un=!1;function kr(e,n,i){for(i=i.child;i!==null;)Ef(e,n,i),i=i.sibling}function Ef(e,n,i){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(Vn,i)}catch{}switch(i.tag){case 5:jt||Bi(i,n);case 6:var l=vt,f=un;vt=null,kr(e,n,i),vt=l,un=f,vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):vt.removeChild(i.stateNode));break;case 18:vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?Ca(e.parentNode,i):e.nodeType===1&&Ca(e,i),vo(e)):Ca(vt,i.stateNode));break;case 4:l=vt,f=un,vt=i.stateNode.containerInfo,un=!0,kr(e,n,i),vt=l,un=f;break;case 0:case 11:case 14:case 15:if(!jt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var g=f,S=g.destroy;g=g.tag,S!==void 0&&((g&2)!==0||(g&4)!==0)&&fu(i,n,S),f=f.next}while(f!==l)}kr(e,n,i);break;case 1:if(!jt&&(Bi(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Ze(i,n,T)}kr(e,n,i);break;case 21:kr(e,n,i);break;case 22:i.mode&1?(jt=(l=jt)||i.memoizedState!==null,kr(e,n,i),jt=l):kr(e,n,i);break;default:kr(e,n,i)}}function Cf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Ly),n.forEach(function(l){var f=Wy.bind(null,e,l);i.has(l)||(i.add(l),l.then(f,f))})}}function cn(e,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=S),l&=~g}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*zy(l/1960))-l,10e?16:e,jr===null)var l=!1;else{if(e=jr,jr=null,il=0,(ze&6)!==0)throw Error(o(331));var f=ze;for(ze|=4,ye=e.current;ye!==null;){var g=ye,S=g.child;if((ye.flags&16)!==0){var T=g.deletions;if(T!==null){for(var O=0;OVe()-vu?oi(e,0):yu|=i),$t(e,n)}function Hf(e,n){n===0&&((e.mode&1)===0?n=1:(n=Un,Un<<=1,(Un&130023424)===0&&(Un=4194304)));var i=Mt();e=Zn(e,n),e!==null&&(En(e,n,i),$t(e,i))}function Vy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Hf(e,i)}function Wy(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Hf(e,i)}var Bf;Bf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Rt.current)Lt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Lt=!1,Iy(e,n,i);Lt=(e.flags&131072)!==0}else Lt=!1,Xe&&(n.flags&1048576)!==0&&wd(n,$s,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Qs(e,n),e=n.pendingProps;var f=Ti(n,St.current);Oi(n,i),f=qa(null,n,l,e,f,i);var g=Ka();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Tt(l)?(g=!0,Ts(n)):g=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Ba(n),f.updater=qs,n.stateNode=f,f._reactInternals=n,nu(n,l,e,i),n=su(null,n,l,!0,g,i)):(n.tag=0,Xe&&g&&Ra(n),Ct(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Qs(e,n),e=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=Yy(l),e=an(l,e),f){case 0:n=ou(null,n,l,e,i);break e;case 1:n=pf(null,n,l,e,i);break e;case 11:n=uf(null,n,l,e,i);break e;case 14:n=cf(null,n,l,an(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),ou(e,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),pf(e,n,l,f,i);case 3:e:{if(gf(n),e===null)throw Error(o(387));l=n.pendingProps,g=n.memoizedState,f=g.element,Md(e,n),Bs(n,l,null,i);var S=n.memoizedState;if(l=S.element,g.isDehydrated)if(g={element:l,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){f=Hi(Error(o(423)),n),n=mf(e,n,l,i,f);break e}else if(l!==f){f=Hi(Error(o(424)),n),n=mf(e,n,l,i,f);break e}else for(Ut=yr(n.stateNode.containerInfo.firstChild),Wt=n,Xe=!0,ln=null,i=Ed(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if($i(),l===f){n=er(e,n,i);break e}Ct(e,n,l,i)}n=n.child}return n;case 5:return Rd(n),e===null&&Aa(n),l=n.type,f=n.pendingProps,g=e!==null?e.memoizedProps:null,S=f.children,ba(l,f)?S=null:g!==null&&ba(l,g)&&(n.flags|=32),hf(e,n),Ct(e,n,S,i),n.child;case 6:return e===null&&Aa(n),null;case 13:return yf(e,n,i);case 4:return Va(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=zi(n,null,l,i):Ct(e,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),uf(e,n,l,f,i);case 7:return Ct(e,n,n.pendingProps,i),n.child;case 8:return Ct(e,n,n.pendingProps.children,i),n.child;case 12:return Ct(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,g=n.memoizedProps,S=f.value,Be(Os,l._currentValue),l._currentValue=S,g!==null)if(sn(g.value,S)){if(g.children===f.children&&!Rt.current){n=er(e,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var T=g.dependencies;if(T!==null){S=g.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(g.tag===1){O=Jn(-1,i&-i),O.tag=2;var J=g.updateQueue;if(J!==null){J=J.shared;var ae=J.pending;ae===null?O.next=O:(O.next=ae.next,ae.next=O),J.pending=O}}g.lanes|=i,O=g.alternate,O!==null&&(O.lanes|=i),Fa(g.return,i,n),T.lanes|=i;break}O=O.next}}else if(g.tag===10)S=g.type===n.type?null:g.child;else if(g.tag===18){if(S=g.return,S===null)throw Error(o(341));S.lanes|=i,T=S.alternate,T!==null&&(T.lanes|=i),Fa(S,i,n),S=g.sibling}else S=g.child;if(S!==null)S.return=g;else for(S=g;S!==null;){if(S===n){S=null;break}if(g=S.sibling,g!==null){g.return=S.return,S=g;break}S=S.return}g=S}Ct(e,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,Oi(n,i),f=Zt(f),l=l(f),n.flags|=1,Ct(e,n,l,i),n.child;case 14:return l=n.type,f=an(l,n.pendingProps),f=an(l.type,f),cf(e,n,l,f,i);case 15:return df(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),Qs(e,n),n.tag=1,Tt(l)?(e=!0,Ts(n)):e=!1,Oi(n,i),tf(n,l,f),nu(n,l,f,i),su(null,n,l,!0,e,i);case 19:return xf(e,n,i);case 22:return ff(e,n,i)}throw Error(o(156,n.tag))};function Vf(e,n){return Hr(e,n)}function Uy(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tn(e,n,i,l){return new Uy(e,n,i,l)}function bu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Yy(e){if(typeof e=="function")return bu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ne)return 11;if(e===V)return 14}return 2}function Cr(e,n){var i=e.alternate;return i===null?(i=tn(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function al(e,n,i,l,f,g){var S=2;if(l=e,typeof e=="function")bu(e)&&(S=1);else if(typeof e=="string")S=5;else e:switch(e){case F:return li(i.children,f,g,n);case G:S=8,f|=8;break;case q:return e=tn(12,i,n,f|2),e.elementType=q,e.lanes=g,e;case K:return e=tn(13,i,n,f),e.elementType=K,e.lanes=g,e;case C:return e=tn(19,i,n,f),e.elementType=C,e.lanes=g,e;case U:return ul(i,f,g,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case te:S=10;break e;case ee:S=9;break e;case ne:S=11;break e;case V:S=14;break e;case W:S=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=tn(S,i,n,f),n.elementType=e,n.type=l,n.lanes=g,n}function li(e,n,i,l){return e=tn(7,e,l,n),e.lanes=i,e}function ul(e,n,i,l){return e=tn(22,e,l,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function Eu(e,n,i){return e=tn(6,e,null,n),e.lanes=i,e}function Cu(e,n,i){return n=tn(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Gy(e,n,i,l,f){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Yn(0),this.expirationTimes=Yn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Yn(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Mu(e,n,i,l,f,g,S,T,O){return e=new Gy(e,n,i,T,O),n===1?(n=1,g===!0&&(n|=8)):n=0,g=tn(3,null,null,n),e.current=g,g.stateNode=e,g.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ba(g),e}function Xy(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),Au.exports=s0(),Au.exports}var rh;function l0(){if(rh)return ml;rh=1;var t=Np();return ml.createRoot=t.createRoot,ml.hydrateRoot=t.hydrateRoot,ml}var a0=l0();function jp(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Ae(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(jp(s,o.statusText||"Request failed"))}return o.json()}const u0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Pe={health:()=>Ae("/api/health"),settings:()=>Ae("/api/settings"),saveSettings:t=>{const r={...t};for(const o of u0)r[o]===""&&delete r[o];return Ae("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ae("/api/repos"),browse:t=>Ae(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ae(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ae("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ae(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Ae(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:(t,r=!0)=>Ae(`/api/architecture?repo_path=${encodeURIComponent(t)}&graph=${r?"1":"0"}`),architectureGraph:t=>Ae(`/api/architecture/graph?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Ae("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Ae("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Ae("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Ae("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Ae("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Ae(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open",s)=>Ae("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o,repo_path:s||null})}),scmRepos:t=>Ae(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ae("/api/oauth/status"),githubOAuthStart:()=>Ae("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ae("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ae("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Ae("/api/oauth/gitlab/start"),oauthDisconnect:t=>Ae("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ae("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})}),reviews:t=>Ae(`/api/reviews?repo_path=${encodeURIComponent(t)}`),getReview:(t,r)=>Ae(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(t)}`),reviewDiff:(t,r,o)=>Ae(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(t)}&other=${encodeURIComponent(o)}`),config:t=>Ae(`/api/config?repo_path=${encodeURIComponent(t)}`),saveConfig:(t,r)=>Ae("/api/config",{method:"PUT",body:JSON.stringify({repo_path:t,...r})}),addWaiver:(t,r,o,s)=>Ae("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:t,rule:r,node:o||null,reason:s||""})}),marks:(t,r)=>Ae(`/api/marks?repo_path=${encodeURIComponent(t)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:t=>Ae(`/api/architecture/health?repo_path=${encodeURIComponent(t)}`),workspaceStatus:t=>Ae(`/api/workspace/status?repo_path=${encodeURIComponent(t)}`),openEditor:(t,r,o,s)=>Ae("/api/open",{method:"POST",body:JSON.stringify({repo_path:t,path:r,line:o||null,editor:s||null})}),exportHtml:t=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:t})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(jp(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(t,r,o,s)=>Ae("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:t,edges:r,source_id:o,target_id:s||null})})};function c0(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):t}function d0({open:t,actions:r,onClose:o}){const[s,a]=L.useState(""),[u,c]=L.useState(0),h=L.useRef(null),p=L.useMemo(()=>c0(r,s),[r,s]);if(L.useEffect(()=>{if(!t)return;a(""),c(0);const y=window.setTimeout(()=>{var m;return(m=h.current)==null?void 0:m.focus()},0);return()=>window.clearTimeout(y)},[t]),L.useEffect(()=>{c(0)},[s]),!t)return null;const v=p[u],x=y=>{y&&(o(),y.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:y=>{y.target===y.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:y=>a(y.target.value),onKeyDown:y=>{y.key==="Escape"?(y.preventDefault(),o()):y.key==="ArrowDown"?(y.preventDefault(),c(m=>Math.min(p.length-1,m+1))):y.key==="ArrowUp"?(y.preventDefault(),c(m=>Math.max(0,m-1))):y.key==="Enter"&&(y.preventDefault(),x(v))}}),d.jsxs("ul",{children:[p.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,p.slice(0,40).map((y,m)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:m===u?"active":"",onMouseEnter:()=>c(m),onClick:()=>x(y),children:[d.jsx("span",{children:y.label}),y.hint?d.jsx("span",{className:"muted",children:y.hint}):null]})},y.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function f0({config:t,busy:r,onSave:o,onWaiver:s}){const[a,u]=L.useState(t),[c,h]=L.useState(t.available_rules[0]||""),[p,v]=L.useState(""),[x,y]=L.useState("");L.useEffect(()=>{u(t)},[t]);const m=Object.entries(a.contexts||{}),_=(R,w,N)=>{const A=a.contexts[R];if(!A)return;const $=F=>F.split(",").map(G=>G.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[R]:{...A,[w]:w==="name"?N:$(N)}}})},k=(R,w)=>{const N=w.trim();if(!N||N===R)return;const{[R]:A,...$}=a.contexts;A&&u({...a,contexts:{...$,[N]:{...A,name:N}}})},j=()=>{let R=1;for(;a.contexts[`context-${R}`];)R+=1;const w=`context-${R}`;u({...a,contexts:{...a.contexts,[w]:{name:w,django_apps:[],react:[],public_api:[],owners:[]}}})},b=R=>{const{[R]:w,...N}=a.contexts;u({...a,contexts:N})},E=R=>{const w=a.rules.includes(R);u({...a,rules:w?a.rules.filter(N=>N!==R):[...a.rules,R]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),m.map(([R,w])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:R})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:R,"data-testid":`config-context-name-${R}`,onBlur:N=>k(R,N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(w.django_apps||[]).join(", "),onChange:N=>_(R,"django_apps",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(w.react||[]).join(", "),onChange:N=>_(R,"react",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(w.public_api||[]).join(", "),onChange:N=>_(R,"public_api",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(w.owners||[]).join(", "),onChange:N=>_(R,"owners",N.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>b(R),children:"Remove context"})]},R)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:j,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(R),onChange:()=>E(R)}),R]},R))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((R,w)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:R.rule}),R.node?` · ${R.node}`:"",R.reason?` — ${R.reason}`:""]},`${R.rule}:${R.node}:${w}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:R=>h(R.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsx("option",{value:R,children:R},R))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:R=>v(R.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:x,onChange:R=>y(R.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,x),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function Zo(t){return t.replaceAll("_"," ")}function h0(t){return t.replaceAll("_"," ")}function io(t){return t.split(".").pop()||t}function ec(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function p0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Tr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function yi({className:t,children:r}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function g0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function m0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function y0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function v0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function x0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function bp({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function w0({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const _0="modulepreload",S0=function(t,r){return new URL(t,r).href},ih={},k0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(x){return Promise.all(x.map(y=>Promise.resolve(y).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),v=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(x=>{if(x=S0(x,s),x in ih)return;ih[x]=!0;const y=x.endsWith(".css"),m=y?'[rel="stylesheet"]':"";if(!!s)for(let j=h.length-1;j>=0;j--){const b=h[j];if(b.href===x&&(!y||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${x}"]${m}`))return;const k=document.createElement("link");if(k.rel=y?"stylesheet":_0,y||(k.as="script"),k.crossOrigin="",k.href=x,v&&k.setAttribute("nonce",v),document.head.appendChild(k),y)return new Promise((j,b)=>{k.addEventListener("load",j),k.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${x}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function nt(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Yl(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}Cl.prototype=Yl.prototype={constructor:Cl,on:function(t,r){var o=this._,s=j0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),sh.hasOwnProperty(r)?{space:sh[r],local:t}:t}function E0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===tc&&r.documentElement.namespaceURI===tc?r.createElement(t):r.createElementNS(o,t)}}function C0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Ep(t){var r=Gl(t);return(r.local?C0:E0)(r)}function M0(){}function pc(t){return t==null?M0:function(){return this.querySelector(t)}}function P0(t){typeof t!="function"&&(t=pc(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=w&&(w=R+1);!(A=b[w])&&++w=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function tv(t){t||(t=nv);function r(y,m){return y&&m?t(y.__data__,m.__data__):!y-!m}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function rv(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function iv(){return Array.from(this)}function ov(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?mv:typeof r=="function"?vv:yv)(t,r,o??"")):Ki(this.node(),t)}function Ki(t,r){return t.style.getPropertyValue(r)||Rp(t).getComputedStyle(t,null).getPropertyValue(r)}function wv(t){return function(){delete this[t]}}function _v(t,r){return function(){this[t]=r}}function Sv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function kv(t,r){return arguments.length>1?this.each((r==null?wv:typeof r=="function"?Sv:_v)(t,r)):this.node()[t]}function Tp(t){return t.trim().split(/^|\s+/)}function gc(t){return t.classList||new Lp(t)}function Lp(t){this._node=t,this._names=Tp(t.getAttribute("class")||"")}Lp.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Ap(t,r){for(var o=gc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function Qv(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function nc(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:v,dispatch:x}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:v,enumerable:!0,configurable:!0},_:{value:x}})}nc.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function lx(t){return!t.ctrlKey&&!t.button}function ax(){return this.parentNode}function ux(t,r){return r??{x:t.x,y:t.y}}function cx(){return navigator.maxTouchPoints||"ontouchstart"in this}function Hp(){var t=lx,r=ax,o=ux,s=cx,a={},u=Yl("start","drag","end"),c=0,h,p,v,x,y=0;function m(N){N.on("mousedown.drag",_).filter(s).on("touchstart.drag",b).on("touchmove.drag",E,sx).on("touchend.drag touchcancel.drag",R).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(N,A){if(!(x||!t.call(this,N,A))){var $=w(this,r.call(this,N,A),N,A,"mouse");$&&(Gt(N.view).on("mousemove.drag",k,Jo).on("mouseup.drag",j,Jo),Op(N.view),Du(N),v=!1,h=N.clientX,p=N.clientY,$("start",N))}}function k(N){if(Xi(N),!v){var A=N.clientX-h,$=N.clientY-p;v=A*A+$*$>y}a.mouse("drag",N)}function j(N){Gt(N.view).on("mousemove.drag mouseup.drag",null),Fp(N.view,v),Xi(N),a.mouse("end",N)}function b(N,A){if(t.call(this,N,A)){var $=N.changedTouches,F=r.call(this,N,A),G=$.length,q,te;for(q=0;q>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?vl(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?vl(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=fx.exec(t))?new Dt(r[1],r[2],r[3],1):(r=hx.exec(t))?new Dt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=px.exec(t))?vl(r[1],r[2],r[3],r[4]):(r=gx.exec(t))?vl(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=mx.exec(t))?hh(r[1],r[2]/100,r[3]/100,1):(r=yx.exec(t))?hh(r[1],r[2]/100,r[3]/100,r[4]):lh.hasOwnProperty(t)?ch(lh[t]):t==="transparent"?new Dt(NaN,NaN,NaN,0):null}function ch(t){return new Dt(t>>16&255,t>>8&255,t&255,1)}function vl(t,r,o,s){return s<=0&&(t=r=o=NaN),new Dt(t,r,o,s)}function wx(t){return t instanceof ds||(t=fi(t)),t?(t=t.rgb(),new Dt(t.r,t.g,t.b,t.opacity)):new Dt}function rc(t,r,o,s){return arguments.length===1?wx(t):new Dt(t,r,o,s??1)}function Dt(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}mc(Dt,rc,Bp(ds,{brighter(t){return t=t==null?Ll:Math.pow(Ll,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?es:Math.pow(es,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Dt(ci(this.r),ci(this.g),ci(this.b),Al(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:dh,formatHex:dh,formatHex8:_x,formatRgb:fh,toString:fh}));function dh(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}`}function _x(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}${ui((isNaN(this.opacity)?1:this.opacity)*255)}`}function fh(){const t=Al(this.opacity);return`${t===1?"rgb(":"rgba("}${ci(this.r)}, ${ci(this.g)}, ${ci(this.b)}${t===1?")":`, ${t})`}`}function Al(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ci(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ui(t){return t=ci(t),(t<16?"0":"")+t.toString(16)}function hh(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new hn(t,r,o,s)}function Vp(t){if(t instanceof hn)return new hn(t.h,t.s,t.l,t.opacity);if(t instanceof ds||(t=fi(t)),!t)return new hn;if(t instanceof hn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new hn(c,h,p,t.opacity)}function Sx(t,r,o,s){return arguments.length===1?Vp(t):new hn(t,r,o,s??1)}function hn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}mc(hn,Sx,Bp(ds,{brighter(t){return t=t==null?Ll:Math.pow(Ll,t),new hn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?es:Math.pow(es,t),new hn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Dt(Ou(t>=240?t-240:t+120,a,s),Ou(t,a,s),Ou(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new hn(ph(this.h),xl(this.s),xl(this.l),Al(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 t=Al(this.opacity);return`${t===1?"hsl(":"hsla("}${ph(this.h)}, ${xl(this.s)*100}%, ${xl(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ph(t){return t=(t||0)%360,t<0?t+360:t}function xl(t){return Math.max(0,Math.min(1,t||0))}function Ou(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const yc=t=>()=>t;function kx(t,r){return function(o){return t+o*r}}function Nx(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function jx(t){return(t=+t)==1?Wp:function(r,o){return o-r?Nx(r,o,t):yc(isNaN(r)?o:r)}}function Wp(t,r){var o=r-t;return o?kx(t,o):yc(isNaN(t)?r:t)}const $l=(function t(r){var o=jx(r);function s(a,u){var c=o((a=rc(a)).r,(u=rc(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),v=Wp(a.opacity,u.opacity);return function(x){return a.r=c(x),a.g=h(x),a.b=p(x),a.opacity=v(x),a+""}}return s.gamma=t,s})(1);function bx(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:Rn(s,a)})),o=Fu.lastIndex;return o180?x+=360:x-v>180&&(v+=360),m.push({i:y.push(a(y)+"rotate(",null,s)-2,x:Rn(v,x)})):x&&y.push(a(y)+"rotate("+x+s)}function h(v,x,y,m){v!==x?m.push({i:y.push(a(y)+"skewX(",null,s)-2,x:Rn(v,x)}):x&&y.push(a(y)+"skewX("+x+s)}function p(v,x,y,m,_,k){if(v!==y||x!==m){var j=_.push(a(_)+"scale(",null,",",null,")");k.push({i:j-4,x:Rn(v,y)},{i:j-2,x:Rn(x,m)})}else(y!==1||m!==1)&&_.push(a(_)+"scale("+y+","+m+")")}return function(v,x){var y=[],m=[];return v=t(v),x=t(x),u(v.translateX,v.translateY,x.translateX,x.translateY,y,m),c(v.rotate,x.rotate,y,m),h(v.skewX,x.skewX,y,m),p(v.scaleX,v.scaleY,x.scaleX,x.scaleY,y,m),v=x=null,function(_){for(var k=-1,j=m.length,b;++k=0&&t._call.call(void 0,r),t=t._next;--Qi}function yh(){hi=(Dl=ns.now())+Xl,Qi=Xo=0;try{Hx()}finally{Qi=0,Vx(),hi=0}}function Bx(){var t=ns.now(),r=t-Dl;r>Xp&&(Xl-=r,Dl=t)}function Vx(){for(var t,r=zl,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:zl=o);qo=t,sc(s)}function sc(t){if(!Qi){Xo&&(Xo=clearTimeout(Xo));var r=t-hi;r>24?(t<1/0&&(Xo=setTimeout(yh,t-ns.now()-Xl)),Yo&&(Yo=clearInterval(Yo))):(Yo||(Dl=ns.now(),Yo=setInterval(Bx,Xp)),Qi=1,qp(yh))}}function vh(t,r,o){var s=new Ol;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Wx=Yl("start","end","cancel","interrupt"),Ux=[],Qp=0,xh=1,lc=2,Pl=3,wh=4,ac=5,Il=6;function ql(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;Yx(t,o,{name:r,index:s,group:a,on:Wx,tween:Ux,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Qp})}function xc(t,r){var o=yn(t,r);if(o.state>Qp)throw new Error("too late; already scheduled");return o}function Ln(t,r){var o=yn(t,r);if(o.state>Pl)throw new Error("too late; already running");return o}function yn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Yx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=Kp(u,0,o.time);function u(v){o.state=xh,o.timer.restart(c,o.delay,o.time),o.delay<=v&&c(v-o.delay)}function c(v){var x,y,m,_;if(o.state!==xh)return p();for(x in s)if(_=s[x],_.name===o.name){if(_.state===Pl)return vh(c);_.state===wh?(_.state=Il,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete s[x]):+xlc&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function Sw(t,r,o){var s,a,u=_w(r)?xc:Ln;return function(){var c=u(this,t),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function kw(t,r){var o=this._id;return arguments.length<2?yn(this.node(),o).on.on(t):this.each(Sw(o,t,r))}function Nw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function jw(){return this.on("end.remove",Nw(this._id))}function bw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=pc(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function Qw(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function rr(t,r,o){this.k=t,this.x=r,this.y=o}rr.prototype={constructor:rr,scale:function(t){return t===1?this:new rr(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new rr(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Kl=new rr(1,0,0);tg.prototype=rr.prototype;function tg(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Kl;return t.__zoom}function Hu(t){t.stopImmediatePropagation()}function Go(t){t.preventDefault(),t.stopImmediatePropagation()}function Zw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Jw(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function _h(){return this.__zoom||Kl}function e1(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function t1(){return navigator.maxTouchPoints||"ontouchstart"in this}function n1(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function ng(){var t=Zw,r=Jw,o=n1,s=e1,a=t1,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=Ml,v=Yl("start","zoom","end"),x,y,m,_=500,k=150,j=0,b=10;function E(C){C.property("__zoom",_h).on("wheel.zoom",G,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",te).filter(a).on("touchstart.zoom",ee).on("touchmove.zoom",ne).on("touchend.zoom touchcancel.zoom",K).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(C,V,W,U){var M=C.selection?C.selection():C;M.property("__zoom",_h),C!==M?A(C,V,W,U):M.interrupt().each(function(){$(this,arguments).event(U).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},E.scaleBy=function(C,V,W,U){E.scaleTo(C,function(){var M=this.__zoom.k,D=typeof V=="function"?V.apply(this,arguments):V;return M*D},W,U)},E.scaleTo=function(C,V,W,U){E.transform(C,function(){var M=r.apply(this,arguments),D=this.__zoom,H=W==null?N(M):typeof W=="function"?W.apply(this,arguments):W,I=D.invert(H),z=typeof V=="function"?V.apply(this,arguments):V;return o(w(R(D,z),H,I),M,c)},W,U)},E.translateBy=function(C,V,W,U){E.transform(C,function(){return o(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),r.apply(this,arguments),c)},null,U)},E.translateTo=function(C,V,W,U,M){E.transform(C,function(){var D=r.apply(this,arguments),H=this.__zoom,I=U==null?N(D):typeof U=="function"?U.apply(this,arguments):U;return o(Kl.translate(I[0],I[1]).scale(H.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),D,c)},U,M)};function R(C,V){return V=Math.max(u[0],Math.min(u[1],V)),V===C.k?C:new rr(V,C.x,C.y)}function w(C,V,W){var U=V[0]-W[0]*C.k,M=V[1]-W[1]*C.k;return U===C.x&&M===C.y?C:new rr(C.k,U,M)}function N(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function A(C,V,W,U){C.on("start.zoom",function(){$(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(U).end()}).tween("zoom",function(){var M=this,D=arguments,H=$(M,D).event(U),I=r.apply(M,D),z=W==null?N(I):typeof W=="function"?W.apply(M,D):W,ie=Math.max(I[1][0]-I[0][0],I[1][1]-I[0][1]),oe=M.__zoom,fe=typeof V=="function"?V.apply(M,D):V,he=p(oe.invert(z).concat(ie/oe.k),fe.invert(z).concat(ie/fe.k));return function(pe){if(pe===1)pe=fe;else{var Z=he(pe),se=ie/Z[2];pe=new rr(se,z[0]-Z[0]*se,z[1]-Z[1]*se)}H.zoom(null,pe)}})}function $(C,V,W){return!W&&C.__zooming||new F(C,V)}function F(C,V){this.that=C,this.args=V,this.active=0,this.sourceEvent=null,this.extent=r.apply(C,V),this.taps=0}F.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,V){return this.mouse&&C!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var V=Gt(this.that).datum();v.call(C,this.that,new Qw(C,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:v}),V)}};function G(C,...V){if(!t.apply(this,arguments))return;var W=$(this,V).event(C),U=this.__zoom,M=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,s.apply(this,arguments)))),D=fn(C);if(W.wheel)(W.mouse[0][0]!==D[0]||W.mouse[0][1]!==D[1])&&(W.mouse[1]=U.invert(W.mouse[0]=D)),clearTimeout(W.wheel);else{if(U.k===M)return;W.mouse=[D,U.invert(D)],Rl(this),W.start()}Go(C),W.wheel=setTimeout(H,k),W.zoom("mouse",o(w(R(U,M),W.mouse[0],W.mouse[1]),W.extent,c));function H(){W.wheel=null,W.end()}}function q(C,...V){if(m||!t.apply(this,arguments))return;var W=C.currentTarget,U=$(this,V,!0).event(C),M=Gt(C.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",ie,!0),D=fn(C,W),H=C.clientX,I=C.clientY;Op(C.view),Hu(C),U.mouse=[D,this.__zoom.invert(D)],Rl(this),U.start();function z(oe){if(Go(oe),!U.moved){var fe=oe.clientX-H,he=oe.clientY-I;U.moved=fe*fe+he*he>j}U.event(oe).zoom("mouse",o(w(U.that.__zoom,U.mouse[0]=fn(oe,W),U.mouse[1]),U.extent,c))}function ie(oe){M.on("mousemove.zoom mouseup.zoom",null),Fp(oe.view,U.moved),Go(oe),U.event(oe).end()}}function te(C,...V){if(t.apply(this,arguments)){var W=this.__zoom,U=fn(C.changedTouches?C.changedTouches[0]:C,this),M=W.invert(U),D=W.k*(C.shiftKey?.5:2),H=o(w(R(W,D),U,M),r.apply(this,V),c);Go(C),h>0?Gt(this).transition().duration(h).call(A,H,U,C):Gt(this).call(E.transform,H,U,C)}}function ee(C,...V){if(t.apply(this,arguments)){var W=C.touches,U=W.length,M=$(this,V,C.changedTouches.length===U).event(C),D,H,I,z;for(Hu(C),H=0;H`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},rs=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],rg=["Enter"," ","Escape"],ig={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Zi;(function(t){t.Strict="strict",t.Loose="loose"})(Zi||(Zi={}));var di;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(di||(di={}));var is;(function(t){t.Partial="partial",t.Full="full"})(is||(is={}));const og={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Lr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Lr||(Lr={}));var os;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(os||(os={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const Sh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function sg(t){return t===null?null:t?"valid":"invalid"}const lg=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,r1=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),_c=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),fs=(t,r=[0,0])=>{const{width:o,height:s}=vn(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},i1=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):_c(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,Ql(a,Fl(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?Zl(s):{x:0,y:0,width:0,height:0}},hs=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=Ql(o,Fl(a)),s=!0)}),s?Zl(o):{x:0,y:0,width:0,height:0}},Sc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,v=r.width/a,x=r.height/a,y=[];for(const m of t.values()){const{measured:_,selectable:k=!0,hidden:j=!1}=m;if(c&&!k||j)continue;const b=_.width??m.width??m.initialWidth??0,E=_.height??m.height??m.initialHeight??0,{x:R,y:w}=m.internals.positionAbsolute,N=dg(h,p,v,x,R,w,b,E),A=b*E,$=u&&N>0;(!m.internals.handleBounds||$||N>=A||m.dragging)&&y.push(m)}return y},o1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function s1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=vn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function l1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const h=s1(t,c),p=hs(h),v=Nc(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(v,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function ag({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),h=c.parentId?o.get(c.parentId):void 0,{x:p,y:v}=h?h.internals.positionAbsolute:{x:0,y:0},x=c.origin??s;let y=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",mn.error005());else{const{width:_,height:k}=vn(h);_&&k&&(y=[[p,v],[p+_,v+k]])}else h&&gi(c.extent)&&(y=[[c.extent[0][0]+p,c.extent[0][1]+v],[c.extent[1][0]+p,c.extent[1][1]+v]]);const m=gi(y)?pi(r,y,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",mn.error015())),{position:{x:m.x-p+(c.measured.width??0)*x[0],y:m.y-v+(c.measured.height??0)*x[1]},positionAbsolute:m}}async function a1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(m=>m.id)),c=[];for(const m of o){if(m.deletable===!1)continue;const _=u.has(m.id),k=!_&&m.parentId&&c.find(j=>j.id===m.parentId);(_||k)&&c.push(m)}const h=new Set(r.map(m=>m.id)),p=s.filter(m=>m.deletable!==!1),x=o1(c,p);for(const m of p)h.has(m.id)&&!x.find(k=>k.id===m.id)&&x.push(m);if(!a)return{edges:x,nodes:c};const y=await a({nodes:c,edges:x});return typeof y=="boolean"?y?{edges:x,nodes:c}:{edges:[],nodes:[]}:y}const Ji=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),pi=(t={x:0,y:0},r,o)=>({x:Ji(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:Ji(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function ug(t,r,o){const{width:s,height:a}=vn(o),{x:u,y:c}=o.internals.positionAbsolute;return pi(t,[[u,c],[u+s,c+a]],r)}const kh=(t,r,o)=>to?-Ji(Math.abs(t-o),1,r)/r:0,kc=(t,r,o=15,s=40)=>{const a=kh(t.x,s,r.width-s)*o,u=kh(t.y,s,r.height-s)*o;return[a,u]},Ql=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),uc=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),Zl=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),ss=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:fs(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},Fl=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:fs(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},cg=(t,r)=>Zl(Ql(uc(t),uc(r))),dg=(t,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),v=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*v)},Hl=(t,r)=>dg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),Nh=t=>pn(t.width)&&pn(t.height)&&pn(t.x)&&pn(t.y),pn=t=>!isNaN(t)&&isFinite(t),fg=(t,r)=>(o,s)=>{},ps=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),gs=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(t-o)/a,y:(r-s)/a};return u?ps(h,c):h},eo=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Yi(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function u1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Yi(t,o),a=Yi(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Yi(t.top??t.y??0,o),a=Yi(t.bottom??t.y??0,o),u=Yi(t.left??t.x??0,r),c=Yi(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function c1(t,r,o,s,a,u){const{x:c,y:h}=eo(t,[r,o,s]),{x:p,y:v}=eo({x:t.x+t.width,y:t.y+t.height},[r,o,s]),x=a-p,y=u-v;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(x),bottom:Math.floor(y)}}const Nc=(t,r,o,s,a,u)=>{const c=u1(u,r,o),h=(r-c.x)/t.width,p=(o-c.y)/t.height,v=Math.min(h,p),x=Ji(v,s,a),y=t.x+t.width/2,m=t.y+t.height/2,_=r/2-y*x,k=o/2-m*x,j=c1(t,_,k,x,r,o),b={left:Math.min(j.left-c.left,0),top:Math.min(j.top-c.top,0),right:Math.min(j.right-c.right,0),bottom:Math.min(j.bottom-c.bottom,0)};return{x:_-b.left+b.right,y:k-b.top+b.bottom,zoom:x}},ls=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function gi(t){return t!=null&&t!=="parent"}function vn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function hg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function pg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function jh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function d1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function f1(t){return{...ig,...t||{}}}function Qo(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=gn(t),h=gs({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y:v}=o?ps(h,r):h;return{xSnapped:p,ySnapped:v,...h}}const jc=t=>({width:t.offsetWidth,height:t.offsetHeight}),gg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},h1=["INPUT","SELECT","TEXTAREA"];function mg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:h1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const yg=t=>"clientX"in t,gn=(t,r)=>{var u,c;const o=yg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},bh=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...jc(c)}})};function vg({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=t*.125+a*.375+c*.375+o*.125,v=r*.125+u*.375+h*.375+s*.125,x=Math.abs(p-t),y=Math.abs(v-r);return[p,v,x,y]}function Sl(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function Eh({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case Se.Left:return[r-Sl(r-s,u),o];case Se.Right:return[r+Sl(s-r,u),o];case Se.Top:return[r,o-Sl(o-a,u)];case Se.Bottom:return[r,o+Sl(a-o,u)]}}function xg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top,curvature:c=.25}){const[h,p]=Eh({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[v,x]=Eh({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[y,m,_,k]=vg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:v,targetControlY:x});return[`M${t},${r} C${h},${p} ${v},${x} ${s},${a}`,y,m,_,k]}function wg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const m1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,y1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),v1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",mn.error006()),r;const s=o.getEdgeId||m1;let a;return lg(t)?a={...t}:a={...t,id:s(t)},y1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function _g({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=wg({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,h]}const Ch={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},x1=({source:t,sourcePosition:r=Se.Bottom,target:o})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function w1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:s=Se.Top,center:a,offset:u,stepPosition:c}){const h=Ch[r],p=Ch[s],v={x:t.x+h.x*u,y:t.y+h.y*u},x={x:o.x+p.x*u,y:o.y+p.y*u},y=x1({source:v,sourcePosition:r,target:x}),m=y.x!==0?"x":"y",_=y[m];let k=[],j,b;const E={x:0,y:0},R={x:0,y:0},[,,w,N]=wg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[m]*p[m]===-1){m==="x"?(j=a.x??v.x+(x.x-v.x)*c,b=a.y??(v.y+x.y)/2):(j=a.x??(v.x+x.x)/2,b=a.y??v.y+(x.y-v.y)*c);const G=[{x:j,y:v.y},{x:j,y:x.y}],q=[{x:v.x,y:b},{x:x.x,y:b}];h[m]===_?k=m==="x"?G:q:k=m==="x"?q:G}else{const G=[{x:v.x,y:x.y}],q=[{x:x.x,y:v.y}];if(m==="x"?k=h.x===_?q:G:k=h.y===_?G:q,r===s){const C=Math.abs(t[m]-o[m]);if(C<=u){const V=Math.min(u-1,u-C);h[m]===_?E[m]=(v[m]>t[m]?-1:1)*V:R[m]=(x[m]>o[m]?-1:1)*V}}if(r!==s){const C=m==="x"?"y":"x",V=h[m]===p[C],W=v[C]>x[C],U=v[C]=K?(j=(te.x+ee.x)/2,b=k[0].y):(j=k[0].x,b=(te.y+ee.y)/2)}const A={x:v.x+E.x,y:v.y+E.y},$={x:x.x+R.x,y:x.y+R.y};return[[t,...A.x!==k[0].x||A.y!==k[0].y?[A]:[],...k,...$.x!==k[k.length-1].x||$.y!==k[k.length-1].y?[$]:[],o],j,b,w,N]}function _1(t,r,o,s){const a=Math.min(Mh(t,r)/2,Mh(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const v=t.xo.id===r):t[0])||null}function cc(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function k1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const v=cc(p,r);u.has(v)||(c.push({id:v,color:p.color||o,...p}),u.add(v))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const Sg=1e3,N1=10,bc={nodeOrigin:[0,0],nodeExtent:rs,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},j1={...bc,checkEquality:!0};function Ec(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function b1(t,r,o){const s=Ec(bc,o);for(const a of t.values())if(a.parentId)Mc(a,t,r,s);else{const u=fs(a,s.nodeOrigin),c=gi(a.extent)?a.extent:s.nodeExtent,h=pi(u,c,vn(a));a.internals.positionAbsolute=h}}function E1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function Cc(t){return t==="manual"}function dc(t,r,o,s={}){var x,y;const a=Ec(j1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!Cc(a.zIndexMode)?Sg:0;let p=t.length>0,v=!1;r.clear(),o.clear();for(const m of t){let _=c.get(m.id);if(a.checkEquality&&m===(_==null?void 0:_.internals.userNode))r.set(m.id,_);else{const k=fs(m,a.nodeOrigin),j=gi(m.extent)?m.extent:a.nodeExtent,b=pi(k,j,vn(m));_={...a.defaults,...m,measured:{width:(x=m.measured)==null?void 0:x.width,height:(y=m.measured)==null?void 0:y.height},internals:{positionAbsolute:b,handleBounds:E1(m,_),z:kg(m,h,a.zIndexMode),userNode:m}},r.set(m.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),m.parentId&&Mc(_,r,o,s,u),v||(v=m.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:v}}function C1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function Mc(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=Ec(bc,s),v=t.parentId,x=r.get(v);if(!x){console.warn(`Parent node ${v} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}C1(t,o),a&&!x.parentId&&x.internals.rootParentIndex===void 0&&p==="auto"&&(x.internals.rootParentIndex=++a.i,x.internals.z=x.internals.z+a.i*N1),a&&x.internals.rootParentIndex!==void 0&&(a.i=x.internals.rootParentIndex);const y=u&&!Cc(p)?Sg:0,{x:m,y:_,z:k}=M1(t,x,c,h,y,p),{positionAbsolute:j}=t.internals,b=m!==j.x||_!==j.y;(b||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:b?{x:m,y:_}:j,z:k}})}function kg(t,r,o){const s=pn(t.zIndex)?t.zIndex:0;return Cc(o)?s:s+(t.selected?r:0)}function M1(t,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=vn(t),v=fs(t,o),x=gi(t.extent)?pi(v,t.extent,p):v;let y=pi({x:c+x.x,y:h+x.y},s,p);t.extent==="parent"&&(y=ug(y,p,r));const m=kg(t,a,u),_=r.internals.z??0;return{x:y.x,y:y.y,z:_>=m?_+1:m}}function Pc(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const v=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??ss(p),x=cg(v,h.rect);u.set(h.parentId,{expandedRect:x,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},v)=>{var w;const x=p.internals.positionAbsolute,y=vn(p),m=p.origin??s,_=h.x0||k>0||E||R)&&(a.push({id:v,type:"position",position:{x:p.position.x-_+E,y:p.position.y-k+R}}),(w=o.get(v))==null||w.forEach(N=>{t.some(A=>A.id===N.id)||a.push({id:N.id,type:"position",position:{x:N.position.x+_,y:N.position.y+k}})})),(y.width0){const _=Pc(m,r,o,a);v.push(..._)}return{changes:v,updatedInternals:p}}async function I1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Th(t,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${t}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${t}-${u}`;const v=s.get(c)||new Map;s.set(c,v.set(o,r))}}function Ng(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},v=`${a}-${c}--${u}-${h}`,x=`${u}-${h}--${a}-${c}`;Th("source",p,x,t,a,c),Th("target",p,v,t,u,h),r.set(s.id,s)}}function jg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:jg(o,r):!1}function Lh(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function R1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!jg(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function Bu({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[v,x]of r){const y=(c=o.get(v))==null?void 0:c.internals.userNode;y&&a.push({...y,position:x.position,dragging:s})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function T1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=ps(u,r);return{x:c.x-u.x,y:c.y-u.y}}function L1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,v={x:0,y:0},x=null,y=!1,m=null,_=!1,k=!1,j=null;function b({noDragClassName:R,handleSelector:w,domNode:N,isSelectable:A,nodeId:$,nodeClickDistance:F=0}){m=Gt(N);function G({x:ne,y:K}){const{nodeLookup:C,nodeExtent:V,snapGrid:W,snapToGrid:U,nodeOrigin:M,onNodeDrag:D,onSelectionDrag:H,onError:I,updateNodePositions:z}=r();u={x:ne,y:K};let ie=!1;const oe=h.size>1,fe=oe&&V?uc(hs(h)):null,he=oe&&U?T1({dragItems:h,snapGrid:W,x:ne,y:K}):null;for(const[pe,Z]of h){if(!C.has(pe))continue;let se={x:ne-Z.distance.x,y:K-Z.distance.y};U&&(se=he?{x:Math.round(se.x+he.x),y:Math.round(se.y+he.y)}:ps(se,W));let me=null;if(oe&&V&&!Z.extent&&fe){const{positionAbsolute:re}=Z.internals,Ne=re.x-fe.x+V[0][0],Me=re.x+Z.measured.width-fe.x2+V[1][0],Te=re.y-fe.y+V[0][1],$e=re.y+Z.measured.height-fe.y2+V[1][1];me=[[Ne,Te],[Me,$e]]}const{position:ke,positionAbsolute:ve}=ag({nodeId:pe,nextPosition:se,nodeLookup:C,nodeExtent:me||V,nodeOrigin:M,onError:I});ie=ie||Z.position.x!==ke.x||Z.position.y!==ke.y,Z.position=ke,Z.internals.positionAbsolute=ve}if(k=k||ie,!!ie&&(z(h,!0),j&&(s||D||!$&&H))){const[pe,Z]=Bu({nodeId:$,dragItems:h,nodeLookup:C});s==null||s(j,h,pe,Z),D==null||D(j,pe,Z),$||H==null||H(j,Z)}}async function q(){if(!x)return;const{transform:ne,panBy:K,autoPanSpeed:C,autoPanOnNodeDrag:V}=r();if(!V){p=!1,cancelAnimationFrame(c);return}const[W,U]=kc(v,x,C);(W!==0||U!==0)&&(u.x=(u.x??0)-W/ne[2],u.y=(u.y??0)-U/ne[2],await K({x:W,y:U})&&G(u)),c=requestAnimationFrame(q)}function te(ne){var oe;const{nodeLookup:K,multiSelectionActive:C,nodesDraggable:V,transform:W,snapGrid:U,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:H,onSelectionDragStart:I,unselectNodesAndEdges:z}=r();y=!0,(!D||!A)&&!C&&$&&((oe=K.get($))!=null&&oe.selected||z()),A&&D&&$&&(t==null||t($));const ie=Qo(ne.sourceEvent,{transform:W,snapGrid:U,snapToGrid:M,containerBounds:x});if(u=ie,h=R1(K,V,ie,$),h.size>0&&(o||H||!$&&I)){const[fe,he]=Bu({nodeId:$,dragItems:h,nodeLookup:K});o==null||o(ne.sourceEvent,h,fe,he),H==null||H(ne.sourceEvent,fe,he),$||I==null||I(ne.sourceEvent,he)}}const ee=Hp().clickDistance(F).on("start",ne=>{const{domNode:K,nodeDragThreshold:C,transform:V,snapGrid:W,snapToGrid:U}=r();x=(K==null?void 0:K.getBoundingClientRect())||null,_=!1,k=!1,j=ne.sourceEvent,C===0&&te(ne),u=Qo(ne.sourceEvent,{transform:V,snapGrid:W,snapToGrid:U,containerBounds:x}),v=gn(ne.sourceEvent,x)}).on("drag",ne=>{const{autoPanOnNodeDrag:K,transform:C,snapGrid:V,snapToGrid:W,nodeDragThreshold:U,nodeLookup:M}=r(),D=Qo(ne.sourceEvent,{transform:C,snapGrid:V,snapToGrid:W,containerBounds:x});if(j=ne.sourceEvent,(ne.sourceEvent.type==="touchmove"&&ne.sourceEvent.touches.length>1||$&&!M.has($))&&(_=!0),!_){if(!p&&K&&y&&(p=!0,q()),!y){const H=gn(ne.sourceEvent,x),I=H.x-v.x,z=H.y-v.y;Math.sqrt(I*I+z*z)>U&&te(ne)}(u.x!==D.xSnapped||u.y!==D.ySnapped)&&h&&y&&(v=gn(ne.sourceEvent,x),G(D))}}).on("end",ne=>{if(!y||_){_&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,y=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:K,updateNodePositions:C,onNodeDragStop:V,onSelectionDragStop:W}=r();if(k&&(C(h,!1),k=!1),a||V||!$&&W){const[U,M]=Bu({nodeId:$,dragItems:h,nodeLookup:K,dragging:!1});a==null||a(ne.sourceEvent,h,U,M),V==null||V(ne.sourceEvent,U,M),$||W==null||W(ne.sourceEvent,M)}}}).filter(ne=>{const K=ne.target;return!ne.button&&(!R||!Lh(K,`.${R}`,N))&&(!w||Lh(K,w,N))});m.call(ee)}function E(){m==null||m.on(".drag",null)}return{update:b,destroy:E}}function A1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())Hl(a,ss(u))>0&&s.push(u);return s}const $1=250;function z1(t,r,o,s){var h,p;let a=[],u=1/0;const c=A1(t,o,r+$1);for(const v of c){const x=[...((h=v.internals.handleBounds)==null?void 0:h.source)??[],...((p=v.internals.handleBounds)==null?void 0:p.target)??[]];for(const y of x){if(s.nodeId===y.nodeId&&s.type===y.type&&s.id===y.id)continue;const{x:m,y:_}=mi(v,y,y.position,!0),k=Math.sqrt(Math.pow(m-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const v=s.type==="source"?"target":"source";return a.find(x=>x.type===v)??a[0]}return a[0]}function bg(t,r,o,s,a,u=!1){var v,x,y;const c=s.get(t);if(!c)return null;const h=a==="strict"?(v=c.internals.handleBounds)==null?void 0:v[r]:[...((x=c.internals.handleBounds)==null?void 0:x.source)??[],...((y=c.internals.handleBounds)==null?void 0:y.target)??[]],p=(o?h==null?void 0:h.find(m=>m.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...mi(c,p,p.position,!0)}:p}function Eg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function D1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const Cg=()=>!0;function O1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:v,autoPanOnConnect:x,flowId:y,panBy:m,cancelConnection:_,onConnectStart:k,onConnect:j,onConnectEnd:b,isValidConnection:E=Cg,onReconnectEnd:R,updateConnection:w,getTransform:N,getFromHandle:A,autoPanSpeed:$,dragThreshold:F=1,handleDomNode:G}){const q=gg(t.target);let te=0,ee;const{x:ne,y:K}=gn(t),C=Eg(u,G),V=h==null?void 0:h.getBoundingClientRect();let W=!1;if(!V||!C)return;const U=bg(a,C,s,p,r);if(!U)return;let M=gn(t,V),D=!1,H=null,I=!1,z=null;function ie(){if(!x||!V)return;const[ke,ve]=kc(M,V,$);m({x:ke,y:ve}),te=requestAnimationFrame(ie)}const oe={...U,nodeId:a,type:C,position:U.position},fe=p.get(a);let pe={inProgress:!0,isValid:null,from:mi(fe,oe,Se.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:fe,to:M,toHandle:null,toPosition:Sh[oe.position],toNode:null,pointer:M};function Z(){W=!0,w(pe),k==null||k(t,{nodeId:a,handleId:s,handleType:C})}F===0&&Z();function se(ke){if(!W){const{x:$e,y:st}=gn(ke),lt=$e-ne,at=st-K;if(!(lt*lt+at*at>F*F))return;Z()}if(!A()||!oe){me(ke);return}const ve=N();M=gn(ke,V),ee=z1(gs(M,ve,!1,[1,1]),o,p,oe),D||(ie(),D=!0);const re=Mg(ke,{handle:ee,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:E,doc:q,lib:v,flowId:y,nodeLookup:p});z=re.handleDomNode,H=re.connection,I=D1(!!ee,re.isValid);const Ne=p.get(a),Me=Ne?mi(Ne,oe,Se.Left,!0):pe.from,Te={...pe,from:Me,isValid:I,to:re.toHandle&&I?eo({x:re.toHandle.x,y:re.toHandle.y},ve):M,toHandle:re.toHandle,toPosition:I&&re.toHandle?re.toHandle.position:Sh[oe.position],toNode:re.toHandle?p.get(re.toHandle.nodeId):null,pointer:M};w(Te),pe=Te}function me(ke){if(!("touches"in ke&&ke.touches.length>0)){if(W){(ee||z)&&H&&I&&(j==null||j(H));const{inProgress:ve,...re}=pe,Ne={...re,toPosition:pe.toHandle?pe.toPosition:null};b==null||b(ke,Ne),u&&(R==null||R(ke,Ne))}_(),cancelAnimationFrame(te),D=!1,I=!1,H=null,z=null,q.removeEventListener("mousemove",se),q.removeEventListener("mouseup",me),q.removeEventListener("touchmove",se),q.removeEventListener("touchend",me)}}q.addEventListener("mousemove",se),q.addEventListener("mouseup",me),q.addEventListener("touchmove",se),q.addEventListener("touchend",me)}function Mg(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:v=Cg,nodeLookup:x}){const y=u==="target",m=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=gn(t),j=c.elementFromPoint(_,k),b=j!=null&&j.classList.contains(`${h}-flow__handle`)?j:m,E={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const R=Eg(void 0,b),w=b.getAttribute("data-nodeid"),N=b.getAttribute("data-handleid"),A=b.classList.contains("connectable"),$=b.classList.contains("connectableend");if(!w||!R)return E;const F={source:y?w:s,sourceHandle:y?N:a,target:y?s:w,targetHandle:y?a:N};E.connection=F;const q=A&&$&&(o===Zi.Strict?y&&R==="source"||!y&&R==="target":w!==s||N!==a);E.isValid=q&&v(F),E.toHandle=bg(w,R,N,x,o,!0)}return E}const fc={onPointerDown:O1,isValid:Mg};function F1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Gt(t);function u({translateExtent:h,width:p,height:v,zoomStep:x=1,pannable:y=!0,zoomable:m=!0,inversePan:_=!1}){const k=w=>{if(w.sourceEvent.type!=="wheel"||!r)return;const N=o(),A=w.sourceEvent.ctrlKey&&ls()?10:1,$=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*x,F=N[2]*Math.pow(2,$*A);r.scaleTo(F)};let j=[0,0];const b=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(j=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},E=w=>{const N=o();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!r)return;const A=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],$=[A[0]-j[0],A[1]-j[1]];j=A;const F=s()*Math.max(N[2],Math.log(N[2]))*(_?-1:1),G={x:N[0]-$[0]*F,y:N[1]-$[1]*F},q=[[0,0],[p,v]];r.setViewportConstrained({x:G.x,y:G.y,zoom:N[2]},q,h)},R=ng().on("start",b).on("zoom",y?E:null).on("zoom.wheel",m?k:null);a.call(R,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:fn}}const Jl=t=>({x:t.x,y:t.y,zoom:t.k}),Vu=({x:t,y:r,zoom:o})=>Kl.translate(t,r).scale(o),Rr=(t,r)=>t.target.closest(`.${r}`),Pg=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),H1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Wu=(t,r=0,o=H1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Ig=t=>{const r=t.ctrlKey&&ls()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function B1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:v}){return x=>{if(Rr(x,r))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const y=o.property("__zoom").k||1;if(x.ctrlKey&&c){const b=fn(x),E=Ig(x),R=y*Math.pow(2,E);s.scaleTo(o,R,b,x);return}const m=x.deltaMode===1?20:1;let _=a===di.Vertical?0:x.deltaX*m,k=a===di.Horizontal?0:x.deltaY*m;!ls()&&x.shiftKey&&a!==di.Vertical&&(_=x.deltaY*m,k=0),s.translateBy(o,-(_/y)*u,-(k/y)*u,{internal:!0});const j=Jl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(x,j):(t.isPanScrolling=!0,h==null||h(x,j)),t.panScrollTimeout=setTimeout(()=>{v==null||v(x,j),t.isPanScrolling=!1},150)}}function V1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=Rr(s,t);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function W1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=Jl(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function U1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;t.usedRightMouseButton=!!(o&&Pg(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,Jl(u.transform)))}}function Y1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&Pg(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const p=Jl(c.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function G1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:v,lib:x,connectionInProgress:y}){return m=>{var E;const _=r||o,k=s&&m.ctrlKey,j=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(Rr(m,`${x}-flow__node`)||Rr(m,`${x}-flow__edge`)||Rr(m,`${x}-flow__selection`)||Rr(m,`${x}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!c&&!s||h||y&&!j||Rr(m,p)&&j||Rr(m,v)&&(!j||u&&j&&!r)||!s&&m.ctrlKey&&j)return!1;if(!s&&m.type==="touchstart"&&((E=m.touches)==null?void 0:E.length)>1)return m.preventDefault(),!1;if(!_&&!u&&!k&&j||!a&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(a)&&!a.includes(m.button)&&m.type==="mousedown")return!1;const b=Array.isArray(a)&&a.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||j||t)&&b}}function X1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const v={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=t.getBoundingClientRect();let y=[[0,0],[x.width,x.height]];const m=typeof ResizeObserver<"u"?new ResizeObserver(K=>{const C=K[0];C&&(y=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;m==null||m.observe(t);const _=ng().extent(()=>y).scaleExtent([r,o]).translateExtent(s),k=Gt(t).call(_);N({x:a.x,y:a.y,zoom:Ji(a.zoom,r,o)},[[0,0],[x.width,x.height]],s);const j=k.on("wheel.zoom"),b=k.on("dblclick.zoom");_.wheelDelta(Ig);async function E(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Ml).transform(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function R({noWheelClassName:K,noPanClassName:C,onPaneContextMenu:V,userSelectionActive:W,panOnScroll:U,panOnDrag:M,panOnScrollMode:D,panOnScrollSpeed:H,preventScrolling:I,zoomOnPinch:z,zoomOnScroll:ie,zoomOnDoubleClick:oe,panActivationKeyPressed:fe=!1,zoomActivationKeyPressed:he,lib:pe,onTransformChange:Z,connectionInProgress:se,paneClickDistance:me,selectionOnDrag:ke}){W&&!v.isZoomingOrPanning&&w();const ve=U&&!he&&!W;_.clickDistance(ke?1/0:!pn(me)||me<0?0:me);const re=ve?B1({zoomPanValues:v,noWheelClassName:K,d3Selection:k,d3Zoom:_,panOnScrollMode:D,panOnScrollSpeed:H,zoomOnPinch:z,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):V1({noWheelClassName:K,preventScrolling:I,d3ZoomHandler:j});k.on("wheel.zoom",re,{passive:!1});const Ne=W1({zoomPanValues:v,onDraggingChange:p,onPanZoomStart:c});_.on("start",Ne);const Me=U1({zoomPanValues:v,panOnDrag:M,onPaneContextMenu:!!V,onPanZoom:u,onTransformChange:Z});_.on("zoom",Me);const Te=Y1({zoomPanValues:v,panOnDrag:M,panOnScroll:U,onPaneContextMenu:V,onPanZoomEnd:h,onDraggingChange:p});_.on("end",Te);const $e=G1({panActivationKeyPressed:fe,zoomActivationKeyPressed:he,panOnDrag:M,zoomOnScroll:ie,panOnScroll:U,zoomOnDoubleClick:oe,zoomOnPinch:z,userSelectionActive:W,noPanClassName:C,noWheelClassName:K,lib:pe,connectionInProgress:se});_.filter($e),oe?k.on("dblclick.zoom",b):k.on("dblclick.zoom",null)}function w(){_.on("zoom",null)}async function N(K,C,V){const W=Vu(K),U=_==null?void 0:_.constrain()(W,C,V);return U&&await E(U),U}async function A(K,C){const V=Vu(K);return await E(V,C),V}function $(K){if(k){const C=Vu(K),V=k.property("__zoom");(V.k!==K.zoom||V.x!==K.x||V.y!==K.y)&&(_==null||_.transform(k,C,null,{sync:!0}))}}function F(){const K=k?tg(k.node()):{x:0,y:0,k:1};return{x:K.x,y:K.y,zoom:K.k}}async function G(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Ml).scaleTo(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}async function q(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Ml).scaleBy(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function te(K){_==null||_.scaleExtent(K)}function ee(K){_==null||_.translateExtent(K)}function ne(K){const C=!pn(K)||K<0?0:K;_==null||_.clickDistance(C)}return{update:R,destroy:w,setViewport:A,setViewportConstrained:N,getViewport:F,scaleTo:G,scaleBy:q,setScaleExtent:te,setTranslateExtent:ee,syncViewport:$,setClickDistance:ne}}var to;(function(t){t.Line="line",t.Handle="handle"})(to||(to={}));function q1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function Ah(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function Pr(t,r){return Math.max(0,r-t)}function Ir(t,r){return Math.max(0,t-r)}function kl(t,r,o){return Math.max(0,r-t,t-o)}function $h(t,r){return t?!r:r}function K1(t,r,o,s,a,u,c,h){let{affectsX:p,affectsY:v}=r;const{isHorizontal:x,isVertical:y}=r,m=x&&y,{xSnapped:_,ySnapped:k}=o,{minWidth:j,maxWidth:b,minHeight:E,maxHeight:R}=s,{x:w,y:N,width:A,height:$,aspectRatio:F}=t;let G=Math.floor(x?_-t.pointerX:0),q=Math.floor(y?k-t.pointerY:0);const te=A+(p?-G:G),ee=$+(v?-q:q),ne=-u[0]*A,K=-u[1]*$;let C=kl(te,j,b),V=kl(ee,E,R);if(c){let M=0,D=0;p&&G<0?M=Pr(w+G+ne,c[0][0]):!p&&G>0&&(M=Ir(w+te+ne,c[1][0])),v&&q<0?D=Pr(N+q+K,c[0][1]):!v&&q>0&&(D=Ir(N+ee+K,c[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(h){let M=0,D=0;p&&G>0?M=Ir(w+G,h[0][0]):!p&&G<0&&(M=Pr(w+te,h[1][0])),v&&q>0?D=Ir(N+q,h[0][1]):!v&&q<0&&(D=Pr(N+ee,h[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(a){if(x){const M=kl(te/F,E,R)*F;if(C=Math.max(C,M),c){let D=0;!p&&!v||p&&!v&&m?D=Ir(N+K+te/F,c[1][1])*F:D=Pr(N+K+(p?G:-G)/F,c[0][1])*F,C=Math.max(C,D)}if(h){let D=0;!p&&!v||p&&!v&&m?D=Pr(N+te/F,h[1][1])*F:D=Ir(N+(p?G:-G)/F,h[0][1])*F,C=Math.max(C,D)}}if(y){const M=kl(ee*F,j,b)/F;if(V=Math.max(V,M),c){let D=0;!p&&!v||v&&!p&&m?D=Ir(w+ee*F+ne,c[1][0])/F:D=Pr(w+(v?q:-q)*F+ne,c[0][0])/F,V=Math.max(V,D)}if(h){let D=0;!p&&!v||v&&!p&&m?D=Pr(w+ee*F,h[1][0])/F:D=Ir(w+(v?q:-q)*F,h[0][0])/F,V=Math.max(V,D)}}}q=q+(q<0?V:-V),G=G+(G<0?C:-C),a&&(m?te>ee*F?q=($h(p,v)?-G:G)/F:G=($h(p,v)?-q:q)*F:x?(q=G/F,v=p):(G=q*F,p=v));const W=p?w+G:w,U=v?N+q:N;return{width:A+(p?-G:G),height:$+(v?-q:q),x:u[0]*G*(p?-1:1)+W,y:u[1]*q*(v?-1:1)+U}}const Rg={width:0,height:0,x:0,y:0},Q1={...Rg,pointerX:0,pointerY:0,aspectRatio:1};function Z1(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function J1({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Gt(t);let c={controlDirection:Ah("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:v,boundaries:x,keepAspectRatio:y,resizeDirection:m,onResizeStart:_,onResize:k,onResizeEnd:j,shouldResize:b}){let E={...Rg},R={...Q1};c={boundaries:x,resizeDirection:m,keepAspectRatio:y,controlDirection:Ah(v)};let w,N=null,A=[],$,F,G,q=!1;const te=Hp().on("start",ee=>{const{nodeLookup:ne,transform:K,snapGrid:C,snapToGrid:V,nodeOrigin:W,paneDomNode:U}=o();if(w=ne.get(r),!w)return;N=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:D}=Qo(ee.sourceEvent,{transform:K,snapGrid:C,snapToGrid:V,containerBounds:N});E={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},R={...E,pointerX:M,pointerY:D,aspectRatio:E.width/E.height},$=void 0,F=gi(w.extent)?w.extent:void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&($=ne.get(w.parentId)),$&&w.extent==="parent"&&(F=[[0,0],[$.measured.width,$.measured.height]]),A=[],G=void 0;for(const[H,I]of ne)if(I.parentId===r&&(A.push({id:H,position:{...I.position},extent:I.extent}),I.extent==="parent"||I.expandParent)){const z=Z1(I,w,I.origin??W);G?G=[[Math.min(z[0][0],G[0][0]),Math.min(z[0][1],G[0][1])],[Math.max(z[1][0],G[1][0]),Math.max(z[1][1],G[1][1])]]:G=z}_==null||_(ee,{...E})}).on("drag",ee=>{const{transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V}=o(),W=Qo(ee.sourceEvent,{transform:ne,snapGrid:K,snapToGrid:C,containerBounds:N}),U=[];if(!w)return;const{x:M,y:D,width:H,height:I}=E,z={},ie=w.origin??V,{width:oe,height:fe,x:he,y:pe}=K1(R,c.controlDirection,W,c.boundaries,c.keepAspectRatio,ie,F,G),Z=oe!==H,se=fe!==I,me=he!==M&&Z,ke=pe!==D&&se;if(!me&&!ke&&!Z&&!se)return;if((me||ke||ie[0]===1||ie[1]===1)&&(z.x=me?he:E.x,z.y=ke?pe:E.y,E.x=z.x,E.y=z.y,A.length>0)){const Me=he-M,Te=pe-D;for(const $e of A)$e.position={x:$e.position.x-Me+ie[0]*(oe-H),y:$e.position.y-Te+ie[1]*(fe-I)},U.push($e)}if((Z||se)&&(z.width=Z&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:E.width,z.height=se&&(!c.resizeDirection||c.resizeDirection==="vertical")?fe:E.height,E.width=z.width,E.height=z.height),$&&w.expandParent){const Me=ie[0]*(z.width??0);z.x&&z.x{q&&(j==null||j(ee,{...E}),a==null||a({...E}),q=!1)});u.call(te)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Uu={exports:{}},Yu={},Gu={exports:{}},Xu={};/** * @license React * use-sync-external-store-shim.production.js * @@ -53,10 +53,10 @@ Error generating stack: `+g.message+` * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Oh;function n_(){if(Oh)return Yu;Oh=1;var t=us(),r=t_();function o(v,x){return v===x&&(v!==0||1/v===1/x)||v!==v&&x!==x}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Yu.useSyncExternalStoreWithSelector=function(v,x,y,m,_){var k=u(null);if(k.current===null){var j={hasValue:!1,value:null};k.current=j}else j=k.current;k=h(function(){function E($){if(!R){if(R=!0,w=$,$=m($),_!==void 0&&j.hasValue){var F=j.value;if(_(F,$))return N=F}return N=$}if(F=N,s(w,$))return F;var G=m($);return _!==void 0&&_(F,G)?(w=$,F):(w=$,N=G)}var R=!1,w,N,A=y===void 0?null:y;return[function(){return E(x())},A===null?void 0:function(){return E(A())}]},[x,y,m,_]);var b=a(v,k[0],k[1]);return c(function(){j.hasValue=!0,j.value=b},[b]),p(b),b},Yu}var Fh;function r_(){return Fh||(Fh=1,Uu.exports=n_()),Uu.exports}var i_=r_();const o_=kp(i_),s_={},Hh=t=>{let r;const o=new Set,s=(x,y)=>{const m=typeof x=="function"?x(r):x;if(!Object.is(m,r)){const _=r;r=y??(typeof m!="object"||m===null)?m:Object.assign({},r,m),o.forEach(k=>k(r,_))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>v,subscribe:x=>(o.add(x),()=>o.delete(x)),destroy:()=>{(s_?"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."),o.clear()}},v=r=t(s,a,p);return p},l_=t=>t?Hh(t):Hh,{useDebugValue:a_}=r0,{useSyncExternalStoreWithSelector:u_}=o_,c_=t=>t;function Tg(t,r=c_,o){const s=u_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return a_(s),s}const Bh=(t,r)=>{const o=l_(t),s=(a,u=r)=>Tg(o,a,u);return Object.assign(s,o),s},d_=(t,r)=>t?Bh(t,r):Bh;function Qe(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}Np();const ea=L.createContext(null),f_=ea.Provider,Lg=mn.error001("react");function De(t,r){const o=L.useContext(ea);if(o===null)throw new Error(Lg);return Tg(o,t,r)}function Ye(){const t=L.useContext(ea);if(t===null)throw new Error(Lg);return L.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Vh={display:"none"},h_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ag="react-flow__node-desc",$g="react-flow__edge-desc",p_="react-flow__aria-live",g_=t=>t.ariaLiveMessage,m_=t=>t.ariaLabelConfig;function y_({rfId:t}){const r=De(g_);return d.jsx("div",{id:`${p_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:h_,children:r})}function v_({rfId:t,disableKeyboardA11y:r}){const o=De(m_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${Ag}-${t}`,style:Vh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${$g}-${t}`,style:Vh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(y_,{rfId:t})]})}const ta=L.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return d.jsx("div",{className:nt(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});ta.displayName="Panel";const Wh="https://reactflow.dev?utm_source=attribution";function x_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:d.jsx(ta,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Wh}`,children:d.jsx("a",{href:Wh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const w_=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},Nl=t=>t.id;function __(t,r){return Qe(t.selectedNodes.map(Nl),r.selectedNodes.map(Nl))&&Qe(t.selectedEdges.map(Nl),r.selectedEdges.map(Nl))}function S_({onSelectionChange:t}){const r=Ye(),{selectedNodes:o,selectedEdges:s}=De(w_,__);return L.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const k_=t=>!!t.onSelectionChangeHandlers;function N_({onSelectionChange:t}){const r=De(k_);return t||r?d.jsx(S_,{onSelectionChange:t}):null}const zg=[0,0],j_={x:0,y:0,zoom:1},b_=["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"],Uh=[...b_,"rfId"],E_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Yh={translateExtent:ns,nodeOrigin:zg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function C_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=De(E_,Qe),v=Ye();L.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{x.current=Yh,h()}),[]);const x=L.useRef(Yh);return L.useEffect(()=>{for(const y of Uh){const m=t[y],_=x.current[y];m!==_&&(typeof t[y]>"u"||(y==="nodes"?r(m):y==="edges"?o(m):y==="minZoom"?s(m):y==="maxZoom"?a(m):y==="translateExtent"?u(m):y==="nodeExtent"?c(m):y==="ariaLabelConfig"?v.setState({ariaLabelConfig:f1(m)}):y==="fitView"?v.setState({fitViewQueued:m}):y==="fitViewOptions"?v.setState({fitViewOptions:m}):v.setState({[y]:m})))}x.current=t},Uh.map(y=>t[y])),null}function Gh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function M_(t){var s;const[r,o]=L.useState(t==="system"?null:t);return L.useEffect(()=>{if(t!=="system"){o(t);return}const a=Gh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=Gh())!=null&&s.matches?"dark":"light"}const Xh=typeof document<"u"?document:null;function ls(t=null,r={target:Xh,actInsideInputWithModifier:!0}){const[o,s]=L.useState(!1),a=L.useRef(!1),u=L.useRef(new Set([])),[c,h]=L.useMemo(()=>{if(t!==null){const v=(Array.isArray(t)?t:[t]).filter(y=>typeof y=="string").map(y=>y.replace(/\+/g,` + */var Oh;function n_(){if(Oh)return Yu;Oh=1;var t=us(),r=t_();function o(v,x){return v===x&&(v!==0||1/v===1/x)||v!==v&&x!==x}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Yu.useSyncExternalStoreWithSelector=function(v,x,y,m,_){var k=u(null);if(k.current===null){var j={hasValue:!1,value:null};k.current=j}else j=k.current;k=h(function(){function E($){if(!R){if(R=!0,w=$,$=m($),_!==void 0&&j.hasValue){var F=j.value;if(_(F,$))return N=F}return N=$}if(F=N,s(w,$))return F;var G=m($);return _!==void 0&&_(F,G)?(w=$,F):(w=$,N=G)}var R=!1,w,N,A=y===void 0?null:y;return[function(){return E(x())},A===null?void 0:function(){return E(A())}]},[x,y,m,_]);var b=a(v,k[0],k[1]);return c(function(){j.hasValue=!0,j.value=b},[b]),p(b),b},Yu}var Fh;function r_(){return Fh||(Fh=1,Uu.exports=n_()),Uu.exports}var i_=r_();const o_=kp(i_),s_={},Hh=t=>{let r;const o=new Set,s=(x,y)=>{const m=typeof x=="function"?x(r):x;if(!Object.is(m,r)){const _=r;r=y??(typeof m!="object"||m===null)?m:Object.assign({},r,m),o.forEach(k=>k(r,_))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>v,subscribe:x=>(o.add(x),()=>o.delete(x)),destroy:()=>{(s_?"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."),o.clear()}},v=r=t(s,a,p);return p},l_=t=>t?Hh(t):Hh,{useDebugValue:a_}=r0,{useSyncExternalStoreWithSelector:u_}=o_,c_=t=>t;function Tg(t,r=c_,o){const s=u_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return a_(s),s}const Bh=(t,r)=>{const o=l_(t),s=(a,u=r)=>Tg(o,a,u);return Object.assign(s,o),s},d_=(t,r)=>t?Bh(t,r):Bh;function Qe(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}Np();const ea=L.createContext(null),f_=ea.Provider,Lg=mn.error001("react");function De(t,r){const o=L.useContext(ea);if(o===null)throw new Error(Lg);return Tg(o,t,r)}function Ye(){const t=L.useContext(ea);if(t===null)throw new Error(Lg);return L.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Vh={display:"none"},h_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ag="react-flow__node-desc",$g="react-flow__edge-desc",p_="react-flow__aria-live",g_=t=>t.ariaLiveMessage,m_=t=>t.ariaLabelConfig;function y_({rfId:t}){const r=De(g_);return d.jsx("div",{id:`${p_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:h_,children:r})}function v_({rfId:t,disableKeyboardA11y:r}){const o=De(m_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${Ag}-${t}`,style:Vh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${$g}-${t}`,style:Vh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(y_,{rfId:t})]})}const ta=L.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return d.jsx("div",{className:nt(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});ta.displayName="Panel";const Wh="https://reactflow.dev?utm_source=attribution";function x_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:d.jsx(ta,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Wh}`,children:d.jsx("a",{href:Wh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const w_=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},Nl=t=>t.id;function __(t,r){return Qe(t.selectedNodes.map(Nl),r.selectedNodes.map(Nl))&&Qe(t.selectedEdges.map(Nl),r.selectedEdges.map(Nl))}function S_({onSelectionChange:t}){const r=Ye(),{selectedNodes:o,selectedEdges:s}=De(w_,__);return L.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const k_=t=>!!t.onSelectionChangeHandlers;function N_({onSelectionChange:t}){const r=De(k_);return t||r?d.jsx(S_,{onSelectionChange:t}):null}const zg=[0,0],j_={x:0,y:0,zoom:1},b_=["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"],Uh=[...b_,"rfId"],E_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Yh={translateExtent:rs,nodeOrigin:zg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function C_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=De(E_,Qe),v=Ye();L.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{x.current=Yh,h()}),[]);const x=L.useRef(Yh);return L.useEffect(()=>{for(const y of Uh){const m=t[y],_=x.current[y];m!==_&&(typeof t[y]>"u"||(y==="nodes"?r(m):y==="edges"?o(m):y==="minZoom"?s(m):y==="maxZoom"?a(m):y==="translateExtent"?u(m):y==="nodeExtent"?c(m):y==="ariaLabelConfig"?v.setState({ariaLabelConfig:f1(m)}):y==="fitView"?v.setState({fitViewQueued:m}):y==="fitViewOptions"?v.setState({fitViewOptions:m}):v.setState({[y]:m})))}x.current=t},Uh.map(y=>t[y])),null}function Gh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function M_(t){var s;const[r,o]=L.useState(t==="system"?null:t);return L.useEffect(()=>{if(t!=="system"){o(t);return}const a=Gh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=Gh())!=null&&s.matches?"dark":"light"}const Xh=typeof document<"u"?document:null;function as(t=null,r={target:Xh,actInsideInputWithModifier:!0}){const[o,s]=L.useState(!1),a=L.useRef(!1),u=L.useRef(new Set([])),[c,h]=L.useMemo(()=>{if(t!==null){const v=(Array.isArray(t)?t:[t]).filter(y=>typeof y=="string").map(y=>y.replace(/\+/g,` `).replace(` `,` +`).split(` -`)),x=v.reduce((y,m)=>y.concat(...m),[]);return[v,x]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Xh,v=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const x=_=>{var b,E;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!v)&&mg(_))return!1;const j=Kh(_.code,h);if(u.current.add(_[j]),qh(c,u.current,!1)){const R=((E=(b=_.composedPath)==null?void 0:b.call(_))==null?void 0:E[0])||_.target,w=(R==null?void 0:R.nodeName)==="BUTTON"||(R==null?void 0:R.nodeName)==="A";r.preventDefault!==!1&&(a.current||!w)&&_.preventDefault(),s(!0)}},y=_=>{const k=Kh(_.code,h);qh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},m=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",x),p==null||p.addEventListener("keyup",y),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{p==null||p.removeEventListener("keydown",x),p==null||p.removeEventListener("keyup",y),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,s]),o}function qh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Kh(t,r){return r.includes(t)?"code":"key"}const P_=()=>{const t=Ye();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=Nc(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),v={x:r.x-h,y:r.y-p},x=o.snapGrid??a,y=o.snapToGrid??u;return gs(v,s,y,x)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=eo(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function Dg(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)I_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function I_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function R_(t,r){return Dg(t,r)}function T_(t,r){return Dg(t,r)}function ai(t,r){return{id:t,type:"select",selected:r}}function Gi(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(ai(u.id,c)))}return s}function Qh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Zh(t){return{id:t.id,type:"remove"}}const L_=fg();function A_(t,r,o={}){return v1(t,r,{...o,onError:o.onError??L_})}const Jh=t=>r1(t),$_=t=>lg(t);function Og(t){return L.forwardRef(t)}const Fg=typeof window<"u"?L.useLayoutEffect:L.useEffect;function ep(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>z_(()=>o(a=>a+BigInt(1))));return Fg(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function z_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Hg=L.createContext(null);function D_({children:t}){const r=Ye(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:v,hasDefaultNodes:x,onNodesChange:y,nodeLookup:m,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let j=p;for(const E of h)j=typeof E=="function"?E(j):E;let b=Qh({items:j,lookup:m});for(const E of k.values())b=E(b);x&&v(j),b.length>0?y==null||y(b):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:R,setNodes:w}=r.getState();E&&w(R)})},[]),s=ep(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:v,hasDefaultEdges:x,onEdgesChange:y,edgeLookup:m}=r.getState();let _=p;for(const k of h)_=typeof k=="function"?k(_):k;x?v(_):y&&y(Qh({items:_,lookup:m}))},[]),u=ep(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Hg.Provider,{value:c,children:t})}function O_(){const t=L.useContext(Hg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const F_=t=>!!t.panZoom;function na(){const t=P_(),r=Ye(),o=O_(),s=De(F_),a=L.useMemo(()=>{const u=y=>r.getState().nodeLookup.get(y),c=y=>{o.nodeQueue.push(y)},h=y=>{o.edgeQueue.push(y)},p=y=>{var E,R;const{nodeLookup:m,nodeOrigin:_}=r.getState(),k=Jh(y)?y:m.get(y.id),j=k.parentId?pg(k.position,k.measured,k.parentId,m,_):k.position,b={...k,position:j,width:((E=k.measured)==null?void 0:E.width)??k.width,height:((R=k.measured)==null?void 0:R.height)??k.height};return os(b)},v=(y,m,_={replace:!1})=>{c(k=>k.map(j=>{if(j.id===y){const b=typeof m=="function"?m(j):m;return _.replace&&Jh(b)?b:{...j,...b}}return j}))},x=(y,m,_={replace:!1})=>{h(k=>k.map(j=>{if(j.id===y){const b=typeof m=="function"?m(j):m;return _.replace&&$_(b)?b:{...j,...b}}return j}))};return{getNodes:()=>r.getState().nodes.map(y=>({...y})),getNode:y=>{var m;return(m=u(y))==null?void 0:m.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:y=[]}=r.getState();return y.map(m=>({...m}))},getEdge:y=>r.getState().edgeLookup.get(y),setNodes:c,setEdges:h,addNodes:y=>{const m=Array.isArray(y)?y:[y];o.nodeQueue.push(_=>[..._,...m])},addEdges:y=>{const m=Array.isArray(y)?y:[y];o.edgeQueue.push(_=>[..._,...m])},toObject:()=>{const{nodes:y=[],edges:m=[],transform:_}=r.getState(),[k,j,b]=_;return{nodes:y.map(E=>({...E})),edges:m.map(E=>({...E})),viewport:{x:k,y:j,zoom:b}}},deleteElements:async({nodes:y=[],edges:m=[]})=>{const{nodes:_,edges:k,onNodesDelete:j,onEdgesDelete:b,triggerNodeChanges:E,triggerEdgeChanges:R,onDelete:w,onBeforeDelete:N}=r.getState(),{nodes:A,edges:$}=await a1({nodesToRemove:y,edgesToRemove:m,nodes:_,edges:k,onBeforeDelete:N}),F=$.length>0,G=A.length>0;if(F){const q=$.map(Zh);b==null||b($),R(q)}if(G){const q=A.map(Zh);j==null||j(A),E(q)}return(G||F)&&(w==null||w({nodes:A,edges:$})),{deletedNodes:A,deletedEdges:$}},getIntersectingNodes:(y,m=!0,_)=>{const k=Nh(y),j=k?y:p(y),b=_!==void 0;return j?(_||r.getState().nodes).filter(E=>{const R=r.getState().nodeLookup.get(E.id);if(R&&!k&&(E.id===y.id||!R.internals.positionAbsolute))return!1;const w=os(b?E:R),N=Hl(w,j);return m&&N>0||N>=w.width*w.height||N>=j.width*j.height}):[]},isNodeIntersecting:(y,m,_=!0)=>{const j=Nh(y)?y:p(y);if(!j)return!1;const b=Hl(j,m);return _&&b>0||b>=m.width*m.height||b>=j.width*j.height},updateNode:v,updateNodeData:(y,m,_={replace:!1})=>{v(y,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},updateEdge:x,updateEdgeData:(y,m,_={replace:!1})=>{x(y,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},getNodesBounds:y=>{const{nodeLookup:m,nodeOrigin:_}=r.getState();return i1(y,{nodeLookup:m,nodeOrigin:_})},getHandleConnections:({type:y,id:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${y}${m?`-${m}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:y,handleId:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${y?m?`-${y}-${m}`:`-${y}`:""}`))==null?void 0:k.values())??[])},fitView:async y=>{const m=r.getState().fitViewResolver??d1();return r.setState({fitViewQueued:!0,fitViewOptions:y,fitViewResolver:m}),o.nodeQueue.push(_=>[..._]),m.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const tp=t=>t.selected,H_=typeof window<"u"?window:void 0;function B_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ye(),{deleteElements:s}=na(),a=ls(t,{actInsideInputWithModifier:!1}),u=ls(r,{target:H_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(tp),edges:c.filter(tp)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function V_(t){const r=Ye();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=jc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",mn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const ra={position:"absolute",width:"100%",height:"100%",top:0,left:0},W_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function U_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=di.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:v,translateExtent:x,minZoom:y,maxZoom:m,zoomActivationKeyCode:_,preventScrolling:k=!0,children:j,noWheelClassName:b,noPanClassName:E,onViewportChange:R,isControlledViewport:w,paneClickDistance:N,selectionOnDrag:A}){const $=Ye(),F=L.useRef(null),{userSelectionActive:G,lib:q,connectionInProgress:te}=De(W_,Qe),ee=ls(_),ne=L.useRef();V_(F);const K=L.useCallback(C=>{R==null||R({x:C[0],y:C[1],zoom:C[2]}),w||$.setState({transform:C})},[R,w]);return L.useEffect(()=>{if(F.current){ne.current=X1({domNode:F.current,minZoom:y,maxZoom:m,translateExtent:x,viewport:v,onDraggingChange:U=>$.setState(M=>M.paneDragging===U?M:{paneDragging:U}),onPanZoomStart:(U,M)=>{const{onViewportChangeStart:D,onMoveStart:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoom:(U,M)=>{const{onViewportChange:D,onMove:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoomEnd:(U,M)=>{const{onViewportChangeEnd:D,onMoveEnd:H}=$.getState();H==null||H(U,M),D==null||D(M)}});const{x:C,y:V,zoom:W}=ne.current.getViewport();return $.setState({panZoom:ne.current,transform:[C,V,W],domNode:F.current.closest(".react-flow")}),()=>{var U;(U=ne.current)==null||U.destroy()}}},[]),L.useEffect(()=>{var C;(C=ne.current)==null||C.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:ee,preventScrolling:k,noPanClassName:E,userSelectionActive:G,noWheelClassName:b,lib:q,onTransformChange:K,connectionInProgress:te,selectionOnDrag:A,paneClickDistance:N})},[t,r,o,s,a,u,c,h,p,ee,k,E,G,b,q,K,te,A,N]),d.jsx("div",{className:"react-flow__renderer",ref:F,style:ra,children:j})}const Y_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function G_(){const{userSelectionActive:t,userSelectionRect:r}=De(Y_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const qu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},X_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function q_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=rs.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:v,onPaneContextMenu:x,onPaneScroll:y,onPaneMouseEnter:m,onPaneMouseMove:_,onPaneMouseLeave:k,children:j}){const b=L.useRef(0),E=Ye(),{userSelectionActive:R,elementsSelectable:w,dragging:N,panBy:A,autoPanSpeed:$}=De(X_,Qe),F=w&&(t||R),G=L.useRef(null),q=L.useRef(),te=L.useRef(new Set),ee=L.useRef(new Set),ne=L.useRef(!1),K=L.useRef(!1),C=L.useRef({x:0,y:0}),V=L.useRef(!1),W=Z=>{if(K.current||ne.current||E.getState().connection.inProgress){K.current=!1,ne.current=!1;return}v==null||v(Z),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},U=Z=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Z.preventDefault();return}x==null||x(Z)},M=y?Z=>y(Z):void 0,D=Z=>{K.current&&(Z.stopPropagation(),K.current=!1)},H=Z=>{var $e,st;if(Z.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:se,transform:me}=E.getState();if(q.current=se==null?void 0:se.getBoundingClientRect(),!q.current)return;const ke=Z.target===G.current;if(!ke&&!!Z.target.closest(".nokey")||!t||!(c&&ke||r)||Z.button!==0||!Z.isPrimary)return;(st=($e=Z.target)==null?void 0:$e.setPointerCapture)==null||st.call($e,Z.pointerId),K.current=!1;const{x:Ne,y:Me}=gn(Z.nativeEvent,q.current),Te=gs({x:Ne,y:Me},me);E.setState({userSelectionRect:{width:0,height:0,startX:Te.x,startY:Te.y,x:Ne,y:Me}}),ke||(Z.stopPropagation(),Z.preventDefault())};function I(Z,se){const{userSelectionRect:me}=E.getState();if(!me)return;const{transform:ke,nodeLookup:ve,edgeLookup:re,connectionLookup:Ne,triggerNodeChanges:Me,triggerEdgeChanges:Te,defaultEdgeOptions:$e}=E.getState(),st={x:me.startX,y:me.startY},{x:lt,y:at}=eo(st,ke),Ge={startX:st.x,startY:st.y,x:Zmt.id)),ee.current=new Set;const gt=($e==null?void 0:$e.selectable)??!0;for(const mt of te.current){const Pt=Ne.get(mt);if(Pt)for(const{edgeId:ut}of Pt.values()){const Je=re.get(ut);Je&&(Je.selectable??gt)&&ee.current.add(ut)}}if(!jh(wt,te.current)){const mt=Gi(ve,te.current,!0);Me(mt)}if(!jh(qt,ee.current)){const mt=Gi(re,ee.current);Te(mt)}E.setState({userSelectionRect:Ge,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!a||!q.current)return;const[Z,se]=kc(C.current,q.current,$);A({x:Z,y:se}).then(me=>{if(!K.current||!me){b.current=requestAnimationFrame(z);return}const{x:ke,y:ve}=C.current;I(ke,ve),b.current=requestAnimationFrame(z)})}const ie=()=>{cancelAnimationFrame(b.current),b.current=0,V.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=Z=>{const{userSelectionRect:se,transform:me,resetSelectedElements:ke}=E.getState();if(!q.current||!se)return;const{x:ve,y:re}=gn(Z.nativeEvent,q.current);C.current={x:ve,y:re};const Ne=eo({x:se.startX,y:se.startY},me);if(!K.current){const Me=r?0:u;if(Math.hypot(ve-Ne.x,re-Ne.y)<=Me)return;ke(),h==null||h(Z)}K.current=!0,V.current||(z(),V.current=!0),I(ve,re)},fe=Z=>{var se,me;if(!F){Z.target===G.current&&E.getState().connection.inProgress&&(ne.current=!0);return}Z.button===0&&((me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),!R&&Z.target===G.current&&E.getState().userSelectionRect&&(W==null||W(Z)),E.setState({userSelectionActive:!1,userSelectionRect:null}),K.current&&(p==null||p(Z),E.setState({nodesSelectionActive:te.current.size>0})),ie())},he=Z=>{var se,me;(me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),ie()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:nt(["react-flow__pane",{draggable:pe,dragging:N,selection:t}]),onClick:F?void 0:qu(W,G),onContextMenu:qu(U,G),onWheel:qu(M,G),onPointerEnter:F?void 0:m,onPointerMove:F?oe:_,onPointerUp:fe,onPointerCancel:F?he:void 0,onPointerDownCapture:F?H:void 0,onClickCapture:F?D:void 0,onPointerLeave:k,ref:G,style:ra,children:[j,d.jsx(G_,{})]})}function hc({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),v=h.get(t);if(!v){p==null||p("012",mn.error012(t));return}r.setState({nodesSelectionActive:!1}),v.selected?(o||v.selected&&c)&&(u({nodes:[v],edges:[]}),requestAnimationFrame(()=>{var x;return(x=s==null?void 0:s.current)==null?void 0:x.blur()})):a([t])}function Bg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ye(),[p,v]=L.useState(!1),x=L.useRef();return L.useEffect(()=>{if(!r)return x.current=L1({getStoreItems:()=>h.getState(),onNodeMouseDown:y=>{hc({id:y,store:h,nodeRef:t})},onDragStart:()=>{v(!0)},onDragStop:()=>{v(!1)}}),()=>{var y;(y=x.current)==null||y.destroy(),x.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!x.current||x.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const K_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Vg(){const t=Ye();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:v,nodeOrigin:x}=t.getState(),y=new Map,m=K_(c),_=a?u[0]:5,k=a?u[1]:5,j=o.direction.x*_*o.factor,b=o.direction.y*k*o.factor;for(const[,E]of v){if(!m(E))continue;let R={x:E.internals.positionAbsolute.x+j,y:E.internals.positionAbsolute.y+b};a&&(R=ps(R,u));const{position:w,positionAbsolute:N}=ag({nodeId:E.id,nextPosition:R,nodeLookup:v,nodeExtent:s,nodeOrigin:x,onError:h});E.position=w,E.internals.positionAbsolute=N,y.set(E.id,E)}p(y)},[])}const Ic=L.createContext(null),Q_=Ic.Provider;Ic.Consumer;const Wg=()=>L.useContext(Ic),Z_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Ug=L.createContext(null);function J_({children:t}){const r=De(Z_,Qe);return d.jsx(Ug.Provider,{value:r,children:t})}function eS(){const t=L.useContext(Ug);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const tS={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},nS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:v}=c;if(!h&&!a)return tS;const x=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:x,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Zi.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:x&&v}};function rS({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:v,onMouseDown:x,onTouchStart:y,...m},_){var V,W;const k=c||null,j=t==="target",b=Ye(),E=Wg(),{connectOnClick:R,noPanClassName:w,rfId:N}=eS(),{connectingFrom:A,connectingTo:$,clickConnecting:F,isPossibleEndHandle:G,connectionInProcess:q,clickConnectionInProcess:te,valid:ee}=De(nS(E,k,t),Qe);E||(W=(V=b.getState()).onError)==null||W.call(V,"010",mn.error010());const ne=U=>{const{defaultEdgeOptions:M,onConnect:D,hasDefaultEdges:H}=b.getState(),I={...M,...U};if(H){const{edges:z,setEdges:ie,onError:oe}=b.getState();ie(A_(I,z,{onError:oe}))}D==null||D(I),h==null||h(I)},K=U=>{if(!E)return;const M=yg(U.nativeEvent);if(a&&(M&&U.button===0||!M)){const D=b.getState();fc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:j,handleId:k,nodeId:E,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...H)=>{var I,z;return(z=(I=b.getState()).onConnectEnd)==null?void 0:z.call(I,...H)},updateConnection:D.updateConnection,onConnect:ne,isValidConnection:o||((...H)=>{var I,z;return((z=(I=b.getState()).isValidConnection)==null?void 0:z.call(I,...H))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}M?x==null||x(U):y==null||y(U)},C=U=>{const{onClickConnectStart:M,onClickConnectEnd:D,connectionClickStartHandle:H,connectionMode:I,isValidConnection:z,lib:ie,rfId:oe,nodeLookup:fe,connection:he}=b.getState();if(!E||!H&&!a)return;if(!H){M==null||M(U.nativeEvent,{nodeId:E,handleId:k,handleType:t}),b.setState({connectionClickStartHandle:{nodeId:E,type:t,id:k}});return}const pe=gg(U.target),Z=o||z,{connection:se,isValid:me}=fc.isValid(U.nativeEvent,{handle:{nodeId:E,id:k,type:t},connectionMode:I,fromNodeId:H.nodeId,fromHandleId:H.id||null,fromType:H.type,isValidConnection:Z,flowId:oe,doc:pe,lib:ie,nodeLookup:fe});me&&se&&ne(se);const ke=structuredClone(he);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,D==null||D(U,ke),b.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":k,"data-nodeid":E,"data-handlepos":r,"data-id":`${N}-${E}-${k}-${t}`,className:nt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",w,v,{source:!j,target:j,connectable:s,connectablestart:a,connectableend:u,clickconnecting:F,connectingfrom:A,connectingto:$,valid:ee,connectionindicator:s&&(!q||G)&&(q||te?u:a)}]),onMouseDown:K,onTouchStart:K,onClick:R?C:void 0,ref:_,...m,children:p})}const no=L.memo(Og(rS));function iS({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(no,{type:"source",position:o,isConnectable:r})]})}function oS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:s=Se.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(no,{type:"source",position:s,isConnectable:r})]})}function sS(){return null}function lS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const Vl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},np={input:iS,default:oS,output:lS,group:sS};function aS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const uS=t=>{const{width:r,height:o,x:s,y:a}=hs(t.nodeLookup,{filter:u=>!!u.selected});return{width:pn(r)?r:null,height:pn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function cS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ye(),{width:a,height:u,transformString:c,userSelectionActive:h}=De(uS,Qe),p=Vg(),v=L.useRef(null);L.useEffect(()=>{var _;o||(_=v.current)==null||_.focus({preventScroll:!0})},[o]);const x=!h&&a!==null&&u!==null;if(Bg({nodeRef:v,disabled:!x}),!x)return null;const y=t?_=>{const k=s.getState().nodes.filter(j=>j.selected);t(_,k)}:void 0,m=_=>{Object.prototype.hasOwnProperty.call(Vl,_.key)&&(_.preventDefault(),p({direction:Vl[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:nt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:v,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:o?void 0:-1,onKeyDown:o?void 0:m,style:{width:a,height:u}})})}const rp=typeof window<"u"?window:void 0,dS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Yg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:v,selectionOnDrag:x,selectionMode:y,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:j,zoomActivationKeyCode:b,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:N,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:G,autoPanOnSelection:q,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,preventScrolling:C,onSelectionContextMenu:V,noWheelClassName:W,noPanClassName:U,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:H}){const{nodesSelectionActive:I,userSelectionActive:z}=De(dS,Qe),ie=ls(v,{target:rp}),oe=ls(j,{target:rp}),fe=oe||G,he=oe||N,pe=x&&fe!==!0,Z=ie||z||pe;return B_({deleteKeyCode:p,multiSelectionKeyCode:k}),d.jsx(U_,{onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:!ie&&fe,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,zoomActivationKeyCode:b,preventScrolling:C,noWheelClassName:W,noPanClassName:U,onViewportChange:D,isControlledViewport:H,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(q_,{onSelectionStart:m,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:q,isSelecting:!!Z,selectionMode:y,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:pe,children:[t,I&&d.jsx(cS,{onSelectionContextMenu:V,noPanClassName:U,disableKeyboardA11y:M})]})})}Yg.displayName="FlowRenderer";const fS=L.memo(Yg),hS=t=>r=>t?Sc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function pS(t){return De(L.useCallback(hS(t),[t]),Qe)}const gS=t=>t.updateNodeInternals;function mS(){const t=De(gS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function yS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ye(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),v=L.useRef(r),x=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!x||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[x,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const y=v.current!==r,m=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(y||m||_)&&(v.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function vS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:v,nodesFocusable:x,resizeObserver:y,noDragClassName:m,noPanClassName:_,disableKeyboardA11y:k,rfId:j,nodeTypes:b,nodeClickDistance:E,onError:R}){const{node:w,internals:N,isParent:A}=De(Z=>{const se=Z.nodeLookup.get(t),me=Z.parentLookup.has(t);return{node:se,internals:se.internals,isParent:me}},Qe);let $=w.type||"default",F=(b==null?void 0:b[$])||np[$];F===void 0&&(R==null||R("003",mn.error003($)),$="default",F=(b==null?void 0:b.default)||np.default);const G=!!(w.draggable||h&&typeof w.draggable>"u"),q=!!(w.selectable||p&&typeof w.selectable>"u"),te=!!(w.connectable||v&&typeof w.connectable>"u"),ee=!!(w.focusable||x&&typeof w.focusable>"u"),ne=Ye(),K=hg(w),C=yS({node:w,nodeType:$,hasDimensions:K,resizeObserver:y}),V=Bg({nodeRef:C,disabled:w.hidden||!G,noDragClassName:m,handleSelector:w.dragHandle,nodeId:t,isSelectable:q,nodeClickDistance:E}),W=Vg();if(w.hidden)return null;const U=vn(w),M=aS(w),D=q||G||r||o||s||a,H=o?Z=>o(Z,{...N.userNode}):void 0,I=s?Z=>s(Z,{...N.userNode}):void 0,z=a?Z=>a(Z,{...N.userNode}):void 0,ie=u?Z=>u(Z,{...N.userNode}):void 0,oe=c?Z=>c(Z,{...N.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:se,nodeDragThreshold:me}=ne.getState();q&&(!se||!G||me>0)&&hc({id:t,store:ne,nodeRef:C}),r&&r(Z,{...N.userNode})},he=Z=>{if(!(mg(Z.nativeEvent)||k)){if(rg.includes(Z.key)&&q){const se=Z.key==="Escape";hc({id:t,store:ne,unselect:se,nodeRef:C})}else if(G&&w.selected&&Object.prototype.hasOwnProperty.call(Vl,Z.key)){Z.preventDefault();const{ariaLabelConfig:se}=ne.getState();ne.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),W({direction:Vl[Z.key],factor:Z.shiftKey?4:1})}}},pe=()=>{var Ne;if(k||!((Ne=C.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:Z,width:se,height:me,autoPanOnNodeFocus:ke,setCenter:ve}=ne.getState();if(!ke)return;Sc(new Map([[t,w]]),{x:0,y:0,width:se,height:me},Z,!0).length>0||ve(w.position.x+U.width/2,w.position.y+U.height/2,{zoom:Z[2]})};return d.jsx("div",{className:nt(["react-flow__node",`react-flow__node-${$}`,{[_]:G},w.className,{selected:w.selected,selectable:q,parent:A,draggable:G,dragging:V}]),ref:C,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:K?"visible":"hidden",...w.style,...M},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:H,onMouseMove:I,onMouseLeave:z,onContextMenu:ie,onClick:fe,onDoubleClick:oe,onKeyDown:ee?he:void 0,tabIndex:ee?0:void 0,onFocus:ee?pe:void 0,role:w.ariaRole??(ee?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${Ag}-${j}`,"aria-label":w.ariaLabel,...w.domAttributes,children:d.jsx(Q_,{value:t,children:d.jsx(F,{id:t,data:w.data,type:$,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:w.selected??!1,selectable:q,draggable:G,deletable:w.deletable??!0,isConnectable:te,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:V,dragHandle:w.dragHandle,zIndex:N.z,parentId:w.parentId,...U})})})}var xS=L.memo(vS);const wS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Gg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=De(wS,Qe),u=pS(t.onlyRenderVisibleElements),c=mS();return d.jsx("div",{className:"react-flow__nodes",style:ra,children:u.map(h=>d.jsx(xS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Gg.displayName="NodeRenderer";const _S=L.memo(Gg);function SS(t){return De(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&g1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const kS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},NS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ip={[is.Arrow]:kS,[is.ArrowClosed]:NS};function jS(t){const r=Ye();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(ip,t)?ip[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",mn.error009(t)),null)},[t])}const bS=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=jS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},Xg=({defaultColor:t,rfId:r})=>{const o=De(u=>u.edges),s=De(u=>u.defaultEdgeOptions),a=L.useMemo(()=>k1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(bS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Xg.displayName="MarkerDefinitions";var ES=L.memo(Xg);function qg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:v,...x}){const[y,m]=L.useState({x:1,y:0,width:0,height:0}),_=nt(["react-flow__edge-textwrapper",v]),k=L.useRef(null);return L.useEffect(()=>{if(k.current){const j=k.current.getBBox();m({x:j.x,y:j.y,width:j.width,height:j.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-y.width/2} ${r-y.height/2})`,className:_,visibility:y.width?"visible":"hidden",...x,children:[a&&d.jsx("rect",{width:y.width+2*c[0],x:-c[0],y:-c[1],height:y.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:k,style:s,children:o}),p]}):null}qg.displayName="EdgeText";const CS=L.memo(qg);function ms({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:v=20,...x}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...x,d:t,fill:"none",className:nt(["react-flow__edge-path",x.className])}),v?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:v,className:"react-flow__edge-interaction"}):null,s&&pn(r)&&pn(o)?d.jsx(CS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function op({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function Kg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top}){const[c,h]=op({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,v]=op({pos:u,x1:s,y1:a,x2:t,y2:r}),[x,y,m,_]=vg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:v});return[`M${t},${r} C${c},${h} ${p},${v} ${s},${a}`,x,y,m,_]}function Qg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})=>{const[R,w,N]=Kg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),A=t.isInternal?void 0:r;return d.jsx(ms,{id:A,path:R,labelX:w,labelY:N,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})})}const MS=Qg({isInternal:!1}),Zg=Qg({isInternal:!0});MS.displayName="SimpleBezierEdge";Zg.displayName="SimpleBezierEdgeInternal";function Jg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,sourcePosition:_=Se.Bottom,targetPosition:k=Se.Top,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=Bl({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),$=t.isInternal?void 0:r;return d.jsx(ms,{id:$,path:w,labelX:N,labelY:A,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:j,markerStart:b,interactionWidth:R})})}const em=Jg({isInternal:!1}),tm=Jg({isInternal:!0});em.displayName="SmoothStepEdge";tm.displayName="SmoothStepEdgeInternal";function nm(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(em,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const PS=nm({isInternal:!1}),rm=nm({isInternal:!0});PS.displayName="StepEdge";rm.displayName="StepEdgeInternal";function im(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:j})=>{const[b,E,R]=_g({sourceX:o,sourceY:s,targetX:a,targetY:u}),w=t.isInternal?void 0:r;return d.jsx(ms,{id:w,path:b,labelX:E,labelY:R,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:j})})}const IS=im({isInternal:!1}),om=im({isInternal:!0});IS.displayName="StraightEdge";om.displayName="StraightEdgeInternal";function sm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=xg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:E==null?void 0:E.curvature}),$=t.isInternal?void 0:r;return d.jsx(ms,{id:$,path:w,labelX:N,labelY:A,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:R})})}const RS=sm({isInternal:!1}),lm=sm({isInternal:!0});RS.displayName="BezierEdge";lm.displayName="BezierEdgeInternal";const sp={default:lm,straight:om,step:rm,smoothstep:tm,simplebezier:Zg},lp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},TS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,LS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,ap="react-flow__edgeupdater";function up({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:nt([ap,`${ap}-${h}`]),cx:TS(r,s,t),cy:LS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function AS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:v,onReconnectStart:x,onReconnectEnd:y,setReconnecting:m,setUpdateHover:_}){const k=Ye(),j=(N,A)=>{if(N.button!==0)return;const{autoPanOnConnect:$,domNode:F,connectionMode:G,connectionRadius:q,lib:te,onConnectStart:ee,cancelConnection:ne,nodeLookup:K,rfId:C,panBy:V,updateConnection:W}=k.getState(),U=A.type==="target",M=(I,z)=>{m(!1),y==null||y(I,o,A.type,z)},D=I=>v==null?void 0:v(o,I),H=(I,z)=>{m(!0),x==null||x(N,o,A.type),ee==null||ee(I,z)};fc.onPointerDown(N.nativeEvent,{autoPanOnConnect:$,connectionMode:G,connectionRadius:q,domNode:F,handleId:A.id,nodeId:A.nodeId,nodeLookup:K,isTarget:U,edgeUpdaterType:A.type,lib:te,flowId:C,cancelConnection:ne,panBy:V,isValidConnection:(...I)=>{var z,ie;return((ie=(z=k.getState()).isValidConnection)==null?void 0:ie.call(z,...I))??!0},onConnect:D,onConnectStart:H,onConnectEnd:(...I)=>{var z,ie;return(ie=(z=k.getState()).onConnectEnd)==null?void 0:ie.call(z,...I)},onReconnectEnd:M,updateConnection:W,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:N.currentTarget})},b=N=>j(N,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),E=N=>j(N,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),R=()=>_(!0),w=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(up,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:b,onMouseEnter:R,onMouseOut:w,type:"source"}),(t===!0||t==="target")&&d.jsx(up,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:E,onMouseEnter:R,onMouseOut:w,type:"target"})]})}function $S({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,rfId:k,edgeTypes:j,noPanClassName:b,onError:E,disableKeyboardA11y:R}){let w=De(ve=>ve.edgeLookup.get(t));const N=De(ve=>ve.defaultEdgeOptions);w=N?{...N,...w}:w;let A=w.type||"default",$=(j==null?void 0:j[A])||sp[A];$===void 0&&(E==null||E("011",mn.error011(A)),A="default",$=(j==null?void 0:j.default)||sp.default);const F=!!(w.focusable||r&&typeof w.focusable>"u"),G=typeof y<"u"&&(w.reconnectable||o&&typeof w.reconnectable>"u"),q=!!(w.selectable||s&&typeof w.selectable>"u"),te=L.useRef(null),[ee,ne]=L.useState(!1),[K,C]=L.useState(!1),V=Ye(),{zIndex:W=w.zIndex,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z}=De(L.useCallback(ve=>{const re=ve.nodeLookup.get(w.source),Ne=ve.nodeLookup.get(w.target);if(!re||!Ne)return lp;const Me=S1({id:t,sourceNode:re,targetNode:Ne,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:ve.connectionMode,onError:E}),Te=p1({selected:w.selected,zIndex:w.zIndex,sourceNode:re,targetNode:Ne,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||lp,zIndex:Te}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex,E]),Qe),ie=L.useMemo(()=>w.markerStart?`url('#${cc(w.markerStart,k)}')`:void 0,[w.markerStart,k]),oe=L.useMemo(()=>w.markerEnd?`url('#${cc(w.markerEnd,k)}')`:void 0,[w.markerEnd,k]);if(w.hidden||U===null||M===null||D===null||H===null)return null;const fe=ve=>{var Te;const{addSelectedEdges:re,unselectNodesAndEdges:Ne,multiSelectionActive:Me}=V.getState();q&&(V.setState({nodesSelectionActive:!1}),w.selected&&Me?(Ne({nodes:[],edges:[w]}),(Te=te.current)==null||Te.blur()):re([t])),a&&a(ve,w)},he=u?ve=>{u(ve,{...w})}:void 0,pe=c?ve=>{c(ve,{...w})}:void 0,Z=h?ve=>{h(ve,{...w})}:void 0,se=p?ve=>{p(ve,{...w})}:void 0,me=v?ve=>{v(ve,{...w})}:void 0,ke=ve=>{var re;if(!R&&rg.includes(ve.key)&&q){const{unselectNodesAndEdges:Ne,addSelectedEdges:Me}=V.getState();ve.key==="Escape"?((re=te.current)==null||re.blur(),Ne({edges:[w]})):Me([t])}};return d.jsx("svg",{style:{zIndex:W},children:d.jsxs("g",{className:nt(["react-flow__edge",`react-flow__edge-${A}`,w.className,b,{selected:w.selected,animated:w.animated,inactive:!q&&!a,updating:ee,selectable:q}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:Z,onMouseMove:se,onMouseLeave:me,onKeyDown:F?ke:void 0,tabIndex:F?0:void 0,role:w.ariaRole??(F?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":F?`${$g}-${k}`:void 0,ref:te,...w.domAttributes,children:[!K&&d.jsx($,{id:t,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:q,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),G&&d.jsx(AS,{edge:w,isReconnectable:G,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,setUpdateHover:ne,setReconnecting:C})]})})}var zS=L.memo($S);const DS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function am({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:v,onEdgeClick:x,reconnectRadius:y,onEdgeDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:j}){const{edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,onError:w}=De(DS,Qe),N=SS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(ES,{defaultColor:t,rfId:o}),N.map(A=>d.jsx(zS,{id:A,edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,onClick:x,reconnectRadius:y,onDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:w,edgeTypes:s,disableKeyboardA11y:j},A))]})}am.displayName="EdgeRenderer";const OS=L.memo(am),cp=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function FS({children:t}){const r=Ye(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return Fg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=cp(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:cp(s)},children:t})}function HS(t){const r=na(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const BS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function VS(t){const r=De(BS),o=Ye();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function WS(t){return t.connection.inProgress?{...t.connection,to:gs(t.connection.to,t.transform)}:{...t.connection}}function US(t){return WS}function YS(t){const r=US();return De(r,Qe)}const GS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function XS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=De(GS,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:nt(["react-flow__connection",sg(h)]),children:d.jsx(um,{style:r,type:o,CustomComponent:s,isValid:h})})})}const um=({style:t,type:r=Lr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:v,toNode:x,toHandle:y,toPosition:m,pointer:_}=YS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:v.x,toY:v.y,fromPosition:p,toPosition:m,connectionStatus:sg(s),toNode:x,toHandle:y,pointer:_});let k="";const j={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:v.x,targetY:v.y,targetPosition:m};switch(r){case Lr.Bezier:[k]=xg(j);break;case Lr.SimpleBezier:[k]=Kg(j);break;case Lr.Step:[k]=Bl({...j,borderRadius:0});break;case Lr.SmoothStep:[k]=Bl(j);break;default:[k]=_g(j)}return d.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};um.displayName="ConnectionLine";const qS={};function dp(t=qS){L.useRef(t),Ye(),L.useEffect(()=>{},[t])}function KS(){Ye(),L.useRef(!1),L.useEffect(()=>{},[])}function cm({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,onSelectionContextMenu:y,onSelectionStart:m,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:j,connectionLineComponent:b,connectionLineContainerStyle:E,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,deleteKeyCode:G,onlyRenderVisibleElements:q,elementsSelectable:te,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,preventScrolling:V,defaultMarkerColor:W,zoomOnScroll:U,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,zoomOnDoubleClick:z,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneScroll:se,onPaneContextMenu:me,paneClickDistance:ke,nodeClickDistance:ve,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,viewport:ut,onViewportChange:Je,nodesDraggable:An}){return dp(t),dp(r),KS(),HS(o),VS(ut),d.jsx(fS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneContextMenu:me,onPaneScroll:se,paneClickDistance:ke,deleteKeyCode:G,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,elementsSelectable:te,zoomOnScroll:U,zoomOnPinch:M,zoomOnDoubleClick:z,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,onSelectionContextMenu:y,preventScrolling:V,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,onViewportChange:Je,isControlledViewport:!!ut,children:d.jsxs(FS,{children:[d.jsx(OS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,onlyRenderVisibleElements:q,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,defaultMarkerColor:W,noPanClassName:qt,disableKeyboardA11y:gt,rfId:Pt}),d.jsx(XS,{style:j,type:k,component:b,containerStyle:E}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(_S,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,nodeClickDistance:ve,onlyRenderVisibleElements:q,noPanClassName:qt,noDragClassName:Ge,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,nodesDraggable:An}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}cm.displayName="GraphView";const QS=L.memo(cm),ZS=fg(),fp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:v=2,nodeOrigin:x,nodeExtent:y,zIndexMode:m="basic"}={})=>{const _=new Map,k=new Map,j=new Map,b=new Map,E=s??r??[],R=o??t??[],w=x??[0,0],N=y??ns;Ng(j,b,E);const{nodesInitialized:A}=dc(R,_,k,{nodeOrigin:w,nodeExtent:N,zIndexMode:m});let $=[0,0,1];if(c&&a&&u){const F=hs(_,{filter:ee=>!!((ee.width||ee.initialWidth)&&(ee.height||ee.initialHeight))}),{x:G,y:q,zoom:te}=Nc(F,a,u,p,v,(h==null?void 0:h.padding)??.1);$=[G,q,te]}return{rfId:"1",width:a??0,height:u??0,transform:$,nodes:R,nodesInitialized:A,nodeLookup:_,parentLookup:k,edges:E,edgeLookup:b,connectionLookup:j,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:v,translateExtent:ns,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Zi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...og},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:ZS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:ig,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},JS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m})=>d_((_,k)=>{async function j(){const{nodeLookup:b,panZoom:E,fitViewOptions:R,fitViewResolver:w,width:N,height:A,minZoom:$,maxZoom:F}=k();E&&(await l1({nodes:b,width:N,height:A,panZoom:E,minZoom:$,maxZoom:F},R),w==null||w.resolve(!0),_({fitViewResolver:null}))}return{...fp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,defaultNodes:o,defaultEdges:s,zIndexMode:m}),setNodes:b=>{const{nodeLookup:E,parentLookup:R,nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,fitViewQueued:$,zIndexMode:F,nodesSelectionActive:G}=k(),{nodesInitialized:q,hasSelectedNodes:te}=dc(b,E,R,{nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:F}),ee=G&&te;$&&q?(j(),_({nodes:b,nodesInitialized:q,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:ee})):_({nodes:b,nodesInitialized:q,nodesSelectionActive:ee})},setEdges:b=>{const{connectionLookup:E,edgeLookup:R}=k();Ng(E,R,b),_({edges:b})},setDefaultNodesAndEdges:(b,E)=>{if(b){const{setNodes:R}=k();R(b),_({hasDefaultNodes:!0})}if(E){const{setEdges:R}=k();R(E),_({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:E,nodeLookup:R,parentLookup:w,domNode:N,nodeOrigin:A,nodeExtent:$,debug:F,fitViewQueued:G,zIndexMode:q}=k(),{changes:te,updatedInternals:ee}=P1(b,R,w,N,A,$,q);ee&&(b1(R,w,{nodeOrigin:A,nodeExtent:$,zIndexMode:q}),G?(j(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(te==null?void 0:te.length)>0&&(F&&console.log("React Flow: trigger node changes",te),E==null||E(te)))},updateNodePositions:(b,E=!1)=>{const R=[];let w=[];const{nodeLookup:N,triggerNodeChanges:A,connection:$,updateConnection:F,onNodesChangeMiddlewareMap:G}=k();for(const[q,te]of b){const ee=N.get(q),ne=!!(ee!=null&&ee.expandParent&&(ee!=null&&ee.parentId)&&(te!=null&&te.position)),K={id:q,type:"position",position:ne?{x:Math.max(0,te.position.x),y:Math.max(0,te.position.y)}:te.position,dragging:E};if(ee&&$.inProgress&&$.fromNode.id===ee.id){const C=mi(ee,$.fromHandle,Se.Left,!0);F({...$,from:C})}ne&&ee.parentId&&R.push({id:q,parentId:ee.parentId,rect:{...te.internals.positionAbsolute,width:te.measured.width??0,height:te.measured.height??0}}),w.push(K)}if(R.length>0){const{parentLookup:q,nodeOrigin:te}=k(),ee=Pc(R,N,q,te);w.push(...ee)}for(const q of G.values())w=q(w);A(w)},triggerNodeChanges:b=>{const{onNodesChange:E,setNodes:R,nodes:w,hasDefaultNodes:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=R_(b,w);R($)}A&&console.log("React Flow: trigger node changes",b),E==null||E(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:E,setEdges:R,edges:w,hasDefaultEdges:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=T_(b,w);R($)}A&&console.log("React Flow: trigger edge changes",b),E==null||E(b)}},addSelectedNodes:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));N($);return}N(Gi(w,new Set([...b]),!0)),A(Gi(R))},addSelectedEdges:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));A($);return}A(Gi(R,new Set([...b]))),N(Gi(w,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:E}={})=>{const{edges:R,nodes:w,nodeLookup:N,triggerNodeChanges:A,triggerEdgeChanges:$}=k(),F=b||w,G=E||R,q=[];for(const ee of F){if(!ee.selected)continue;const ne=N.get(ee.id);ne&&(ne.selected=!1),q.push(ai(ee.id,!1))}const te=[];for(const ee of G)ee.selected&&te.push(ai(ee.id,!1));A(q),$(te)},setMinZoom:b=>{const{panZoom:E,maxZoom:R}=k();E==null||E.setScaleExtent([b,R]),_({minZoom:b})},setMaxZoom:b=>{const{panZoom:E,minZoom:R}=k();E==null||E.setScaleExtent([R,b]),_({maxZoom:b})},setTranslateExtent:b=>{var E;(E=k().panZoom)==null||E.setTranslateExtent(b),_({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:E,triggerNodeChanges:R,triggerEdgeChanges:w,elementsSelectable:N}=k();if(!N)return;const A=E.reduce((F,G)=>G.selected?[...F,ai(G.id,!1)]:F,[]),$=b.reduce((F,G)=>G.selected?[...F,ai(G.id,!1)]:F,[]);R(A),w($)},setNodeExtent:b=>{const{nodes:E,nodeLookup:R,parentLookup:w,nodeOrigin:N,elevateNodesOnSelect:A,nodeExtent:$,zIndexMode:F}=k();b[0][0]===$[0][0]&&b[0][1]===$[0][1]&&b[1][0]===$[1][0]&&b[1][1]===$[1][1]||(dc(E,R,w,{nodeOrigin:N,nodeExtent:b,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:F}),_({nodeExtent:b}))},panBy:b=>{const{transform:E,width:R,height:w,panZoom:N,translateExtent:A}=k();return I1({delta:b,panZoom:N,transform:E,translateExtent:A,width:R,height:w})},setCenter:async(b,E,R)=>{const{width:w,height:N,maxZoom:A,panZoom:$}=k();if(!$)return!1;const F=typeof(R==null?void 0:R.zoom)<"u"?R.zoom:A;return await $.setViewport({x:w/2-b*F,y:N/2-E*F,zoom:F},{duration:R==null?void 0:R.duration,ease:R==null?void 0:R.ease,interpolate:R==null?void 0:R.interpolate}),!0},cancelConnection:()=>{_({connection:{...og}})},updateConnection:b=>{_({connection:b})},reset:()=>_({...fp()})}},Object.is);function dm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m,children:_}){const[k]=L.useState(()=>JS({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:v,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:x,nodeExtent:y,zIndexMode:m}));return d.jsx(f_,{value:k,children:d.jsx(D_,{children:d.jsx(J_,{children:_})})})}function ek({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:v,maxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_}){return L.useContext(ea)?d.jsx(d.Fragment,{children:t}):d.jsx(dm,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:v,initialMaxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_,children:t})}const tk={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function nk({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:v,onMove:x,onMoveStart:y,onMoveEnd:m,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,onNodeDragStart:F,onNodeDrag:G,onNodeDragStop:q,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onSelectionChange:K,onSelectionDragStart:C,onSelectionDrag:V,onSelectionDragStop:W,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:H,connectionMode:I,connectionLineType:z=Lr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:Z=!1,selectionMode:se=rs.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:ke=ss()?"Meta":"Control",zoomActivationKeyCode:ve=ss()?"Meta":"Control",snapToGrid:re,snapGrid:Ne,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Te,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,nodeOrigin:Ge=zg,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt=!0,defaultViewport:mt=j_,minZoom:Pt=.5,maxZoom:ut=2,translateExtent:Je=ns,preventScrolling:An=!0,nodeExtent:Ot,defaultMarkerColor:xn="#b1b1b7",zoomOnScroll:io=!0,zoomOnPinch:$n=!0,panOnScroll:vi=!1,panOnScrollSpeed:or=.5,panOnScrollMode:$r=di.Free,zoomOnDoubleClick:zn=!0,panOnDrag:zr=!0,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn=1,nodeClickDistance:Fn=0,children:_n,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn=10,onNodesChange:Ht,onEdgesChange:Or,noDragClassName:nn="nodrag",noWheelClassName:Fr="nowheel",noPanClassName:yt="nopan",fitView:Hn,fitViewOptions:ur,connectOnClick:oo,attributionPosition:It,proOptions:Bn,defaultEdgeOptions:Hr,elevateNodesOnSelect:jn=!0,elevateEdgesOnSelect:Br=!1,disableKeyboardA11y:xi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:so,autoPanOnSelection:Vr=!0,autoPanSpeed:wi,connectionRadius:cr,isValidConnection:lo,onError:dr,style:Vn,id:bt,nodeDragThreshold:Wr,connectionDragThreshold:Et,viewport:ao,onViewportChange:Ur,width:Yr,height:Wn,colorMode:Un="light",debug:bn,onScroll:Bt,ariaLabelConfig:_i,zIndexMode:Gr="basic",...fr},hr){const Yn=bt||"1",En=M_(Un),uo=L.useCallback(pr=>{pr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Bt==null||Bt(pr)},[Bt]);return d.jsx("div",{"data-testid":"rf__wrapper",...fr,onScroll:uo,style:{...Vn,...tk},ref:hr,className:nt(["react-flow",a,En]),id:bt,role:"application",children:d.jsxs(ek,{nodes:t,edges:r,width:Yr,height:Wn,fitView:Hn,fitViewOptions:ur,minZoom:Pt,maxZoom:ut,nodeOrigin:Ge,nodeExtent:Ot,zIndexMode:Gr,children:[d.jsx(C_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt,elevateNodesOnSelect:jn,elevateEdgesOnSelect:Br,minZoom:Pt,maxZoom:ut,nodeExtent:Ot,onNodesChange:Ht,onEdgesChange:Or,snapToGrid:re,snapGrid:Ne,connectionMode:I,translateExtent:Je,connectOnClick:oo,defaultEdgeOptions:Hr,fitView:Hn,fitViewOptions:ur,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onNodeDragStart:F,onNodeDrag:G,onNodeDragStop:q,onSelectionDrag:V,onSelectionDragStart:C,onSelectionDragStop:W,onMove:x,onMoveStart:y,onMoveEnd:m,noPanClassName:yt,nodeOrigin:Ge,rfId:Yn,autoPanOnConnect:Ve,autoPanOnNodeDrag:so,autoPanSpeed:wi,onError:dr,connectionRadius:cr,isValidConnection:lo,selectNodesOnDrag:Te,nodeDragThreshold:Wr,connectionDragThreshold:Et,onBeforeDelete:H,debug:bn,ariaLabelConfig:_i,zIndexMode:Gr}),d.jsx(QS,{onInit:v,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,nodeTypes:u,edgeTypes:c,connectionLineType:z,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:Z,selectionMode:se,deleteKeyCode:he,multiSelectionKeyCode:ke,panActivationKeyCode:me,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:mt,translateExtent:Je,minZoom:Pt,maxZoom:ut,preventScrolling:An,zoomOnScroll:io,zoomOnPinch:$n,zoomOnDoubleClick:zn,panOnScroll:vi,panOnScrollSpeed:or,panOnScrollMode:$r,panOnDrag:zr,autoPanOnSelection:Vr,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn,nodeClickDistance:Fn,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn,defaultMarkerColor:xn,noDragClassName:nn,noWheelClassName:Fr,noPanClassName:yt,rfId:Yn,disableKeyboardA11y:xi,nodeExtent:Ot,viewport:ao,onViewportChange:Ur,nodesDraggable:$e}),d.jsx(N_,{onSelectionChange:K}),_n,d.jsx(x_,{proOptions:Bn,position:It}),d.jsx(v_,{rfId:Yn,disableKeyboardA11y:xi})]})})}var rk=Og(nk);function ik({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:nt(["react-flow__background-pattern",o,s])})}function ok({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:nt(["react-flow__background-pattern","dots",r])})}var Ar;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Ar||(Ar={}));const sk={[Ar.Dots]:1,[Ar.Lines]:1,[Ar.Cross]:6},lk=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function fm({id:t,variant:r=Ar.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:v,patternClassName:x}){const y=L.useRef(null),{transform:m,patternId:_}=De(lk,Qe),k=s||sk[r],j=r===Ar.Dots,b=r===Ar.Cross,E=Array.isArray(o)?o:[o,o],R=[E[0]*m[2]||1,E[1]*m[2]||1],w=k*m[2],N=Array.isArray(u)?u:[u,u],A=b?[w,w]:R,$=[N[0]*m[2]+A[0]/2,N[1]*m[2]+A[1]/2],F=`${_}${t||""}`;return d.jsxs("svg",{className:nt(["react-flow__background",v]),style:{...p,...ra,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:y,"data-testid":"rf__background",children:[d.jsx("pattern",{id:F,x:m[0]%R[0],y:m[1]%R[1],width:R[0],height:R[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:j?d.jsx(ok,{radius:w/2,className:x}):d.jsx(ik,{dimensions:A,lineWidth:a,variant:r,className:x})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${F})`})]})}fm.displayName="Background";const ak=L.memo(fm);function uk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ck(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 fk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 hk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 jl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:nt(["react-flow__controls-button",r]),...o,children:t})}const pk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function hm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:v,children:x,position:y="bottom-left",orientation:m="vertical","aria-label":_}){const k=Ye(),{isInteractive:j,minZoomReached:b,maxZoomReached:E,ariaLabelConfig:R}=De(pk,Qe),{zoomIn:w,zoomOut:N,fitView:A}=na(),$=()=>{w(),u==null||u()},F=()=>{N(),c==null||c()},G=()=>{A(a),h==null||h()},q=()=>{k.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),p==null||p(!j)},te=m==="horizontal"?"horizontal":"vertical";return d.jsxs(ta,{className:nt(["react-flow__controls",te,v]),position:y,style:t,"data-testid":"rf__controls","aria-label":_??R["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(jl,{onClick:$,className:"react-flow__controls-zoomin",title:R["controls.zoomIn.ariaLabel"],"aria-label":R["controls.zoomIn.ariaLabel"],disabled:E,children:d.jsx(uk,{})}),d.jsx(jl,{onClick:F,className:"react-flow__controls-zoomout",title:R["controls.zoomOut.ariaLabel"],"aria-label":R["controls.zoomOut.ariaLabel"],disabled:b,children:d.jsx(ck,{})})]}),o&&d.jsx(jl,{className:"react-flow__controls-fitview",onClick:G,title:R["controls.fitView.ariaLabel"],"aria-label":R["controls.fitView.ariaLabel"],children:d.jsx(dk,{})}),s&&d.jsx(jl,{className:"react-flow__controls-interactive",onClick:q,title:R["controls.interactive.ariaLabel"],"aria-label":R["controls.interactive.ariaLabel"],children:j?d.jsx(hk,{}):d.jsx(fk,{})}),x]})}hm.displayName="Controls";const gk=L.memo(hm);function mk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:v,borderRadius:x,shapeRendering:y,selected:m,onClick:_}){const{background:k,backgroundColor:j}=u||{},b=c||k||j;return d.jsx("rect",{className:nt(["react-flow__minimap-node",{selected:m},v]),x:r,y:o,rx:x,ry:x,width:s,height:a,style:{fill:b,stroke:h,strokeWidth:p},shapeRendering:y,onClick:_?E=>_(E,t):void 0})}const yk=L.memo(mk),vk=t=>t.nodes.map(r=>r.id),Ku=t=>t instanceof Function?t:()=>t;function xk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=yk,onClick:c}){const h=De(vk,Qe),p=Ku(r),v=Ku(t),x=Ku(o),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(m=>d.jsx(_k,{id:m,nodeColorFunc:p,nodeStrokeColorFunc:v,nodeClassNameFunc:x,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:y},m))})}function wk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:v,x,y,width:m,height:_}=De(k=>{const j=k.nodeLookup.get(t);if(!j)return{node:void 0,x:0,y:0,width:0,height:0};const b=j.internals.userNode,{x:E,y:R}=j.internals.positionAbsolute,{width:w,height:N}=vn(b);return{node:b,x:E,y:R,width:w,height:N}},Qe);return!v||v.hidden||!hg(v)?null:d.jsx(h,{x,y,width:m,height:_,style:v.style,selected:!!v.selected,className:s(v),color:r(v),borderRadius:a,strokeColor:o(v),strokeWidth:u,shapeRendering:c,onClick:p,id:v.id})}const _k=L.memo(wk);var Sk=L.memo(xk);const kk=200,Nk=150,jk=t=>!t.hidden,bk=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?cg(hs(t.nodeLookup,{filter:jk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},hp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,Ek=(t,r)=>hp(t.viewBB,r.viewBB)&&hp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,Ck="react-flow__minimap-desc";function pm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:v,maskStrokeColor:x,maskStrokeWidth:y,position:m="bottom-right",onClick:_,onNodeClick:k,pannable:j=!1,zoomable:b=!1,ariaLabel:E,inversePan:R,zoomStep:w=1,offsetScale:N=5}){const A=Ye(),$=L.useRef(null),{boundingRect:F,viewBB:G,rfId:q,panZoom:te,translateExtent:ee,flowWidth:ne,flowHeight:K,ariaLabelConfig:C}=De(bk,Ek),V=(t==null?void 0:t.width)??kk,W=(t==null?void 0:t.height)??Nk,U=F.width/V,M=F.height/W,D=Math.max(U,M),H=D*V,I=D*W,z=N*D,ie=F.x-(H-F.width)/2-z,oe=F.y-(I-F.height)/2-z,fe=H+z*2,he=I+z*2,pe=`${Ck}-${q}`,Z=L.useRef(0),se=L.useRef();Z.current=D,L.useEffect(()=>{if($.current&&te)return se.current=F1({domNode:$.current,panZoom:te,getTransform:()=>A.getState().transform,getViewScale:()=>Z.current}),()=>{var re;(re=se.current)==null||re.destroy()}},[te]),L.useEffect(()=>{var re;(re=se.current)==null||re.update({translateExtent:ee,width:ne,height:K,inversePan:R,pannable:j,zoomStep:w,zoomable:b})},[j,b,R,w,ee,ne,K]);const me=_?re=>{var Te;const[Ne,Me]=((Te=se.current)==null?void 0:Te.pointer(re))||[0,0];_(re,{x:Ne,y:Me})}:void 0,ke=k?L.useCallback((re,Ne)=>{const Me=A.getState().nodeLookup.get(Ne).internals.userNode;k(re,Me)},[]):void 0,ve=E??C["minimap.ariaLabel"];return d.jsx(ta,{position:m,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof v=="string"?v:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof y=="number"?y*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:nt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:V,height:W,viewBox:`${ie} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:$,onClick:me,children:[ve&&d.jsx("title",{id:pe,children:ve}),d.jsx(Sk,{onClick:ke,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-z},${oe-z}h${fe+z*2}v${he+z*2}h${-fe-z*2}z - M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}pm.displayName="MiniMap";const Mk=L.memo(pm),Pk=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Ik={[to.Line]:"right",[to.Handle]:"bottom-right"};function Rk({nodeId:t,position:r,variant:o=to.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:v=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:y=!1,resizeDirection:m,autoScale:_=!0,shouldResize:k,onResizeStart:j,onResize:b,onResizeEnd:E}){const R=Wg(),w=typeof t=="string"?t:R,N=Ye(),A=L.useRef(null),$=o===to.Handle,F=De(L.useCallback(Pk($&&_),[$,_]),Qe),G=L.useRef(null),q=r??Ik[o];L.useEffect(()=>{if(!(!A.current||!w))return G.current||(G.current=J1({domNode:A.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,domNode:W}=N.getState();return{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,paneDomNode:W}},onChange:(ee,ne)=>{const{triggerNodeChanges:K,nodeLookup:C,parentLookup:V,nodeOrigin:W}=N.getState(),U=[],M={x:ee.x,y:ee.y},D=C.get(w);if(D&&D.expandParent&&D.parentId){const H=D.origin??W,I=ee.width??D.measured.width??0,z=ee.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:I,height:z,...pg({x:ee.x??D.position.x,y:ee.y??D.position.y},{width:I,height:z},D.parentId,C,H)}},oe=Pc([ie],C,V,W);U.push(...oe),M.x=ee.x?Math.max(H[0]*I,ee.x):void 0,M.y=ee.y?Math.max(H[1]*z,ee.y):void 0}if(M.x!==void 0&&M.y!==void 0){const H={id:w,type:"position",position:{...M}};U.push(H)}if(ee.width!==void 0&&ee.height!==void 0){const I={id:w,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:ee.width,height:ee.height}};U.push(I)}for(const H of ne){const I={...H,type:"position"};U.push(I)}K(U)},onEnd:({width:ee,height:ne})=>{const K={id:w,type:"dimensions",resizing:!1,dimensions:{width:ee,height:ne}};N.getState().triggerNodeChanges([K])}})),G.current.update({controlPosition:q,boundaries:{minWidth:h,minHeight:p,maxWidth:v,maxHeight:x},keepAspectRatio:y,resizeDirection:m,onResizeStart:j,onResize:b,onResizeEnd:E,shouldResize:k}),()=>{var ee;(ee=G.current)==null||ee.destroy()}},[q,h,p,v,x,y,j,b,E,k]);const te=q.split("-");return d.jsx("div",{className:nt(["react-flow__resize-control","nodrag",...te,o,s]),ref:A,style:{...a,scale:F,...c&&{[$?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Rk);const Tk={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function ia(t){return Tk[t]??8}const Wl=208,as=64,Lk=88,Ak=28,$k=8;function zk(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function gm(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const w of t){const N=ia(w.type),A=s.get(N)??[];A.push(w),s.set(N,A)}const u=[...s.keys()].sort((w,N)=>w-N).map(w=>[...s.get(w)??[]].sort((N,A)=>N.name.localeCompare(A.name)||N.id.localeCompare(A.id))),c=new Set(t.map(w=>w.id)),h=new Map,p=new Map;for(const w of t)h.set(w.id,[]),p.set(w.id,[]);for(const w of r)!c.has(w.src)||!c.has(w.dst)||w.src===w.dst||(p.get(w.src).push(w.dst),h.get(w.dst).push(w.src));const v=new Map;u.forEach((w,N)=>{for(const A of w)v.set(A.id,N)});const x=new Map,y=()=>{for(const w of u)w.forEach((N,A)=>x.set(N.id,A))};y();const m=(w,N)=>{const A=w.map(($,F)=>{const G=N($.id).map(te=>x.get(te)).filter(te=>te!==void 0),q=zk(G);return{n:$,bary:Number.isNaN(q)?F:q,name:$.name,id:$.id}});return A.sort(($,F)=>$.bary-F.bary||$.name.localeCompare(F.name)||$.id.localeCompare(F.id)),A.map($=>$.n)},_=w=>N=>v.get(N)===w;for(let w=0;w<$k;w++){for(let N=1;N(h.get(A)??[]).filter(_(N-1))),y();for(let N=u.length-2;N>=0;N--)u[N]=m(u[N],A=>(p.get(A)??[]).filter(_(N+1))),y()}const k=Wl+Lk,j=as+Ak,b=Math.max(...u.map(w=>w.length),1),E=[];let R=0;for(let w=0;wG.id)),A=new Set((u[w+1]??[]).map(G=>G.id));let $=0;if(A.size)for(const G of r)N.has(G.src)&&A.has(G.dst)&&($+=1);const F=Math.min(48,Math.max(0,($-2)*10));R+=k+F}return u.forEach((w,N)=>{const A=(b-w.length)*j/2;w.forEach(($,F)=>{o.set($.id,{x:E[N]??0,y:A+F*j})})}),o}const Dk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),mm=90,Ok=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),pp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Fk=Math.PI*(3-Math.sqrt(5)),ym=220,Hk=26,Bk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function vm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function FN(t){return pp[t]?pp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Vk(t){return t>=mm?"3d":"2d"}function Wk(t){return t>=mm?"overview":"full"}function Uk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(vm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Ok.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Uk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Gk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function Xk(t,r,o,s){const a=new Set(t.map(j=>j.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const j of r){if(!a.has(j.src)||!a.has(j.dst))continue;const b=u.get(j.src)??[];b.push({dst:j.dst,id:j.id}),u.set(j.src,b);const E=c.get(j.dst)??[];E.push({src:j.src,id:j.id}),c.set(j.dst,E)}const h=new Set(t.filter(j=>Dk.has(j.type)).map(j=>j.id)),p=h.size?h:a,v=new Set,x=[o];for(;x.length;){const j=x.pop();if(!v.has(j)){v.add(j);for(const b of u.get(j)??[])v.has(b.dst)||x.push(b.dst)}}const y=new Set([o]),m=[...p].filter(j=>v.has(j)),_=new Set(m);for(;m.length;){const j=m.pop();y.add(j);for(const b of c.get(j)??[])v.has(b.src)&&!_.has(b.src)&&(_.add(b.src),m.push(b.src))}const k=new Set;for(const j of r)y.has(j.src)&&y.has(j.dst)&&k.add(j.id);return{nodeIds:y,edgeIds:k}}function HN(t){const r=new Map;for(const s of t){const a=ia(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*ym;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Hk*Math.sqrt(h+1),v=h*Fk;o.set(c.id,{x:u,y:p*Math.cos(v),z:p*Math.sin(v)})})}return o}function BN(t){const r=new Map;for(const o of t){const s=ia(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*ym,count:s}))}const bl=16,qk=12,Kk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Qk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),gp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Zk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},mp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],yp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Jk=new Set(["looks_idempotent_on_pk","null","blank"]),eN=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function tN(t){return gp[t]?gp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function nN(t,r,o){const s=new Map(r.map(m=>[m.id,m])),a=[];Kk.has(t.type)&&a.push("sink"),Qk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(m=>m.dst===t.id),h=o.filter(m=>m.src===t.id),p=c.slice(0,bl).map(m=>El(m,s,m.src)),v=h.slice(0,bl).map(m=>El(m,s,m.dst)),x=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,y={type:t.type,typeLabel:Qo(ro(t.type)),layer:Bk[ia(t.type)]??"other",purpose:tN(t.type),name:t.name,qualifiedName:t.qualified_name,file:x,context:t.context,roles:a,facts:iN(u).filter(m=>!(m.key==="app"&&m.value===t.context)),inputs:p,outputs:v,extraInputs:Math.max(0,c.length-bl),extraOutputs:Math.max(0,h.length-bl),degreeIn:c.length,degreeOut:h.length,inputKinds:vp(c.map(m=>El(m,s,m.src))),outputKinds:vp(h.map(m=>El(m,s,m.dst))),pathSummary:""};return y.pathSummary=rN(y),y}function vp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function rN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function El(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Qo(ro(s.type)):"",edgeType:t.type,edgeLabel:Qo(t.type),inferred:t.confidence<.8}}function iN(t){const r=[...mp.filter(a=>a in t),...Object.keys(t).filter(a=>!mp.includes(a)&&!yp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||yp.has(a)||eN.has(a))continue;s.add(a);const u=oN(a,t[a]);u!=null&&o.push({key:a,label:Zk[a]??Qo(a),value:u})}return o}function oN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Jk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return sN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,qk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function sN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const lN=12,xp=.2,aN=.8;function uN(t,r,o){const s=o??gm(t,r),a=[];for(const h of r){const p=s.get(h.src),v=s.get(h.dst);if(!p||!v)continue;const x=p.y+as/2,y=v.y+as/2;if(Math.abs(x-y)${Math.round(_/8)}`})}const u=new Map;for(const h of a){const p=u.get(h.corridor)??[];p.push(h),u.set(h.corridor,p)}const c=new Map;for(const h of u.values()){const p=[...h].sort((x,y)=>x.sourceY-y.sourceY||x.id.localeCompare(y.id)),v=p.length;p.forEach((x,y)=>{c.set(x.id,cN(y,v))})}return c}function cN(t,r){return r<=1?.5:xp+(aN-xp)*t/(r-1)}const dN=new Set,fN=L.lazy(()=>k0(()=>import("./LayeredGraph3D-CRmek7qf.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),hN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function pN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(no,{type:"target",position:Se.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:ro(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Tr(t.name)}),d.jsx(no,{type:"source",position:Se.Right,isConnectable:!1})]})}const gN={load:pN},mN=new Set(["django","react","stitch","arch"]);function yN({id:t,sourceX:r,sourceY:o,targetX:s,targetY:a,sourcePosition:u,targetPosition:c,style:h,markerEnd:p,markerStart:v,label:x,labelStyle:y,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,data:b,interactionWidth:E}){const[R,w,N]=Bl({sourceX:r,sourceY:o,sourcePosition:u,targetX:s,targetY:a,targetPosition:c,borderRadius:8,stepPosition:(b==null?void 0:b.stepPosition)??.5});return d.jsx(ms,{id:t,path:R,labelX:w,labelY:N,label:x,labelStyle:y,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,style:h,markerEnd:p,markerStart:v,interactionWidth:E})}const vN={loadstep:yN};function xN({topologyKey:t}){const{fitView:r}=na();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function wN(t,r,o=null,s={}){const a=new Map(t.map(v=>[v.id,v])),u=gm(t,r),c=uN(t,r,u),h=t.map(v=>{var m;const x=((m=s.roles)==null?void 0:m[v.id])||[],y=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:v.id,type:"load",position:u.get(v.id)??{x:0,y:0},data:{name:v.name,type:v.type,file:v.file_path,roles:x,dim:y},selected:o===v.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:Wl,height:as,style:{width:Wl,height:as}}}),p=r.filter(v=>a.has(v.src)&&a.has(v.dst)).map(v=>{const x=hN[v.weight]||"var(--edge-cheap)",y=!!(o&&(v.src===o||v.dst===o));return{id:v.id,source:v.src,target:v.dst,type:"loadstep",animated:v.weight==="critical",data:{stepPosition:c.get(v.id)??.5},style:{stroke:x,strokeWidth:v.weight==="critical"?2.4:1.2,strokeDasharray:v.confidence<.8?"6 4":void 0},markerEnd:{type:is.ArrowClosed,width:14,height:14,color:x},label:y?v.type.replaceAll("_"," "):void 0,labelStyle:y?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:y?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:y?[3,5]:void 0,labelBgBorderRadius:y?4:void 0}});return{rfNodes:h,rfEdges:p}}function _N({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:v}){const x=nN(t,r,o);return L.useEffect(()=>{const y=m=>{m.key==="Escape"&&s()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:x.typeLabel}),d.jsx("div",{className:"inspector-roles",children:x.roles.map(y=>d.jsx("span",{className:"inspector-chip",children:y},y))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Tr(x.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:x.purpose}),x.context?d.jsx("div",{className:"muted",children:Tr(x.context)}):null,x.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Tr(x.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Tr(x.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",x.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[x.degreeIn," in · ",x.degreeOut," out"]}),x.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:x.pathSummary}):null,x.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:x.facts.map(y=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:y.label}),d.jsx("dd",{children:Tr(y.value)})]},y.key))}):null,d.jsx(wp,{title:"Inputs",testId:"graph-inspector-inputs",links:x.inputs,extra:x.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(wp,{title:"Outputs",testId:"graph-inspector-outputs",links:x.outputs,extra:x.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),a?d.jsx("p",{className:"whatif-hint","data-testid":"whatif-hint",children:v?"Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map.":"Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."}):null,d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",title:"Start a hypothetical walk from this node. Does not use Base/Head.",onClick:()=>a(t.id),children:"What if this changes"}):null,v?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",title:"Hide nodes that are not on a path from here to a sink. Does not start a new walk.",onClick:()=>v(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function wp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Qu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:v,repoPath:x,onOpenFile:y,pinnedId:m,onPin:_}){const[k,j]=L.useState(null),b=a!==void 0?a:k,E=re=>{a===void 0&&j(re),u==null||u(re)},[R,w]=L.useState(null),[N,A]=L.useState(null),[$,F]=L.useState(new Set(mN)),[G,q]=L.useState(!1),[te,ee]=L.useState(""),[ne,K]=L.useState(!1),C=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,V=R??Vk(t.length),W=N??Wk(t.length),U=G?b:null,M=L.useMemo(()=>p?Xk(t,r,p):null,[t,r,p]),D=M?t.filter(re=>M.nodeIds.has(re.id)):t,H=M?r.filter(re=>M.edgeIds.has(re.id)):r,I=L.useMemo(()=>Yk(D,H,{detail:W,families:$,focusId:U,neighborhoodOnly:!!U}),[D,H,W,$,U]),z=L.useMemo(()=>`${I.nodes.map(re=>re.id).join("\0")}|${I.edges.map(re=>re.id).join("\0")}`,[I.nodes,I.edges]),ie=b?t.find(re=>re.id===b)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const re=wN(I.nodes,I.edges,b,{roles:c,testOverlay:h});return C&&(re.rfEdges=re.rfEdges.map(Ne=>({...Ne,animated:!1}))),re},[I.nodes,I.edges,b,C,c,h]);L.useEffect(()=>{if(!s)return;const re=t.find(Ne=>Ne.file_path===s);re&&E(re.id)},[s,t]);const he=L.useMemo(()=>Gk(t,te),[t,te]),pe=(re,Ne)=>{E(Ne.id)},Z=()=>{E(null),q(!1)},se=ie?d.jsx(_N,{node:ie,nodes:t,edges:r,onClose:Z,onWhatIf:o,onSelect:E,onOpenFile:y,pinned:m===ie.id,onPin:_,onIsolate:v?re=>{v(p===re?null:re)}:void 0}):null,me=re=>{F(Ne=>{const Me=new Set(Ne);if(Me.has(re)){if(Me.size===1)return Ne;Me.delete(re)}else Me.add(re);return Me})},ke=L.useMemo(()=>{const re=new Set;for(const Ne of t)re.add(vm(Ne.type));return re},[t]),ve=t.length-I.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:V==="2d"?"active":"","aria-pressed":V==="2d",onClick:()=>w("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:V==="3d"?"active":"","aria-pressed":V==="3d",onClick:()=>w("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:W==="overview"?"active":"","aria-pressed":W==="overview",onClick:()=>A("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:W==="full"?"active":"","aria-pressed":W==="full",onClick:()=>A("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(re=>ke.has(re)).map(re=>d.jsx("button",{type:"button","data-testid":`graph-family-${re}`,className:$.has(re)?"active":"","aria-pressed":$.has(re),onClick:()=>me(re),children:re},re))}),d.jsx("button",{type:"button",className:G?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!b,onClick:()=>q(re=>!re),children:G?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>v==null?void 0:v(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:te,onChange:re=>{ee(re.target.value),K(!0)},onFocus:()=>K(!0),onBlur:()=>window.setTimeout(()=>K(!1),150)}),ne&&te.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(re=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:Ne=>Ne.preventDefault(),onClick:()=>{E(re.id),ee(""),K(!1)},children:[re.name,d.jsx("span",{className:"muted",children:ro(re.type)})]})},re.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[I.nodes.length," nodes · ",I.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:V==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(fN,{nodes:I.nodes,edges:I.edges,selectedId:b,neighborIds:U?I.neighborIds:dN,onSelect:re=>{E(re),re||q(!1)}})}),se]}):d.jsxs(dm,{children:[d.jsxs(rk,{nodes:oe,edges:fe,nodeTypes:gN,edgeTypes:vN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:Z,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(xN,{topologyKey:z}),d.jsx(ak,{}),d.jsx(Mk,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(gk,{})]}),se]})})]})}function xm(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function SN(t){localStorage.setItem("loadpath.editor",t)}async function kN(t,r,o,s=xm()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const _p=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],NN=["preset","branch","tag","commit"];function jN(t){var a;if(!(t!=null&&t.git))return[..._p];const r=((a=t.presets)!=null&&a.length?t.presets:_p.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function bN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function EN(t){return NN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function CN(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function Sp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[v,x]=L.useState(!1),[y,m]=L.useState(null),[_,k]=L.useState(0),j=L.useMemo(()=>{const N=jN(u);return y===null?N:bN(N,y)},[u,y]),b=L.useMemo(()=>EN(j),[j]);L.useEffect(()=>{v&&c()},[v,c]),L.useEffect(()=>{k(0)},[y,v]);const E=()=>{x(!1),m(null)},R=N=>{r(N.value),E()},w=N=>{if(N.key==="ArrowDown"){if(N.preventDefault(),!v){x(!0);return}k(A=>Math.min(A+1,Math.max(j.length-1,0)))}else if(N.key==="ArrowUp"){if(N.preventDefault(),!v)return;k(A=>Math.max(A-1,0))}else if(N.key==="Enter"&&v){N.preventDefault();const A=j[_];A&&R(A)}else N.key==="Escape"&&v&&(N.preventDefault(),E())};return d.jsxs("div",{className:"combo",ref:p,onBlur:N=>{N.currentTarget.contains(N.relatedTarget)||E()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":v,"aria-controls":h,"aria-autocomplete":"list",onChange:N=>{r(N.target.value),v&&m(N.target.value)},onKeyDown:w}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":v,onMouseDown:N=>N.preventDefault(),onClick:()=>v?E():x(!0),children:d.jsx(w0,{})})]}),v?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:b.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):b.map(N=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:CN(N.group)}),N.items.map(A=>{const $=j.indexOf(A);return d.jsxs("button",{type:"button",role:"option","aria-selected":$===_,className:$===_?"combo-option active":"combo-option","data-testid":`ref-option-${A.group}`,onMouseDown:F=>F.preventDefault(),onMouseEnter:()=>k($),onClick:()=>R(A),children:[d.jsx("span",{className:"combo-label",children:A.label}),A.detail?d.jsx("span",{className:"combo-detail",children:A.detail}):null]},`${A.group}:${A.value}`)})]},N.group))}):null]})}function MN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[v,x]=L.useState(""),[y,m]=L.useState(!1),_=L.useRef(null),k=L.useRef(0),j=async w=>{const N=k.current+1;k.current=N,m(!0);try{const A=await Pe.browse(w);if(k.current!==N)return;a(A),c(A.path),p(A.is_git?A.path:null),x("")}catch(A){if(k.current!==N)return;x(A instanceof Error?A.message:String(A))}finally{k.current===N&&m(!1)}};L.useEffect(()=>{var w,N;j(t),(w=_.current)==null||w.focus(),(N=_.current)==null||N.select()},[t]);const b=h||(s==null?void 0:s.path)||u,E=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",R=w=>{w.key==="Escape"&&(w.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:R,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:w=>w.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:w=>{w.preventDefault(),j(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:w=>c(w.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),v?d.jsx("div",{className:"error",role:"alert",children:v}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":y,children:s!=null&&s.entries.length?s.entries.map(w=>{const N=h===w.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":N,className:N?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":w.path,onClick:()=>p(w.path),onDoubleClick:()=>void j(w.path),children:[d.jsx(bp,{}),d.jsx("span",{className:"explorer-name",children:w.name}),w.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},w.path)}):d.jsx("div",{className:"muted explorer-empty",children:y?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:b,children:b}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!b,onClick:()=>b&&r(b),children:["Use ",E]})]})]})})}const PN={scan:{start:0,end:20},extract:{start:20,end:88},boot:{start:88,end:94},stitch:{start:94,end:99},skipped:{start:100,end:100},done:{start:100,end:100}},IN=new Set(["scan","extract","boot","stitch"]);function RN(t){const r=t.phase||"";if(!r||r==="idle")return null;const o=PN[r];if(!o)return null;if(o.start===o.end)return o.end;const s=t.total||0;if(s<=0)return o.start;const a=Math.min(1,Math.max(0,(t.done||0)/s));return Math.round(o.start+(o.end-o.start)*a)}function TN(t){return!t.phase||t.phase==="idle"?null:typeof t.percent=="number"&&Number.isFinite(t.percent)?Math.max(0,Math.min(100,Math.round(t.percent))):RN(t)}const Ul=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],LN="obsidian",wm="loadpath.theme";function AN(t){return Ul.some(r=>r.id===t)}function _m(){try{const t=localStorage.getItem(wm)||"";if(AN(t))return t}catch{}return LN}function $N(t){var r;return((r=Ul.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function Sm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=$N(t);try{localStorage.setItem(wm,t)}catch{}}const Zu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:g0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:m0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:y0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:v0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:x0}];function Ju(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function zN(){var co,fo,Si,ho,po,go,ki,Xr,rn,on;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,v]=L.useState(null),[x,y]=L.useState(null),[m,_]=L.useState(null),[k,j]=L.useState([]),[b,E]=L.useState("review"),[R,w]=L.useState(""),[N,A]=L.useState(""),[$,F]=L.useState(null),[G,q]=L.useState(!1),[te,ee]=L.useState(!1),[ne,K]=L.useState(""),[C,V]=L.useState({}),[W,U]=L.useState([]),[M,D]=L.useState([]),[H,I]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[z,ie]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[oe,fe]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[he,pe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[Z,se]=L.useState(0),[me,ke]=L.useState(""),[ve,re]=L.useState(_m),[Ne,Me]=L.useState(!1),[Te,$e]=L.useState(!1),[st,lt]=L.useState(!1),[at,Ge]=L.useState(null),[wt,qt]=L.useState(null),[gt,mt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[Pt,ut]=L.useState(null),[Je,An]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[Ot,xn]=L.useState([]),[io,$n]=L.useState(null),[vi,or]=L.useState(null),[$r,zn]=L.useState(null),[zr,sr]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[lr,Ft]=L.useState(null),[ct,Dn]=L.useState(null),[On,wn]=L.useState(!1),[Fn,_n]=L.useState(!1),rt=L.useRef(o);rt.current=o;const Dr=L.useRef(!1);Dr.current=Te;const _t=L.useRef(""),ar=L.useRef(""),Sn=P=>{re(P),Sm(P)},dt=L.useRef(""),He=P=>{dt.current=P,A(P)},kn=P=>{let Y=0,ce=!1;F(0);const je=()=>{Pe.indexProgress(P).then(Ie=>{if(!dt.current)return;if(Ie.phase&&Ie.phase!=="idle"&&Ie.message&&He(Ie.message),IN.has(Ie.phase))ce=!0;else if(!ce)return;const qr=TN(Ie);qr!=null&&(Ie.phase==="scan"&&!Ie.done?Y=qr:Y=Math.max(Y,qr),F(Y))}).catch(()=>{})};je();const Le=window.setInterval(je,250);return()=>{window.clearInterval(Le),F(null)}};L.useEffect(()=>{Pe.settings().then(V).catch(()=>{}).finally(()=>Me(!0)),Pe.repos().then(P=>j(P.repos)).catch(()=>{})},[]);const Nn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const P=o;let Y=!1;return ar.current!==P&&Bn(P),Pe.config(P).then(ce=>{!Y&&rt.current===P&&or(ce)}).catch(()=>{}),Pe.architectureHealth(P).then(ce=>{!Y&&rt.current===P&&zn(ce)}).catch(()=>{}),()=>{Y=!0}},[t,o]);const Ht=P=>{rt.current=P,s(P),localStorage.setItem("loadpath.repo",P),P.trim()!==_t.current&&(_t.current="",Ft(null))},Or=L.useCallback(P=>{const Y=(P??rt.current).trim();return!Y||_t.current===Y?Promise.resolve():(_t.current=Y,Pe.gitRefs(Y).then(ce=>{rt.current.trim()===Y&&Ft(ce)}).catch(()=>{_t.current===Y&&(_t.current="",Ft(null))}))},[]),nn=(P,Y)=>{u(P),h(Y),localStorage.setItem("loadpath.base",P),localStorage.setItem("loadpath.head",Y)},Fr=(P,Y,ce)=>{ie(P),I(Y),localStorage.setItem("loadpath.provider",P),localStorage.setItem("loadpath.scmRepo",Y),ce!==void 0&&(fe(ce),localStorage.setItem("loadpath.prNumber",ce))},yt=P=>{v(P),se(0),Ge(wt&&P.nodes.some(Y=>Y.id===wt)?wt:null),ut(null),$n(null),P.what_if||(y(P),P.id&&localStorage.setItem("loadpath.lastReviewId",P.id))},Hn=async P=>{try{const Y=await Pe.reviews(P);xn(Y.reviews)}catch{xn([])}},ur=async P=>{try{zn(await Pe.architectureHealth(P))}catch{zn(null)}},oo=P=>P==="github"?!!C.github_token_set:P==="gitlab"?!!C.gitlab_token_set:!!C.bitbucket_token_set,It=L.useCallback(async(P=z)=>{var Y;try{const ce=await Pe.scmRepos(P);D(ce.repos),(Y=ce.user)!=null&&Y.login&&V(je=>({...je,...P==="github"?{github_user:ce.user.login}:P==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{D([])}},[z]);L.useEffect(()=>{if(t!=="prs")return;let P=!1;return It(z).catch(()=>{P||D([])}),()=>{P=!0}},[t,z,It]),L.useEffect(()=>{if(!ct)return;let P=!1,Y=0;const ce=async()=>{try{const je=await Pe.githubOAuthPoll(ct.flow_id);if(P)return;if(je.status==="complete"){Dn(null);const Le=await Pe.settings();V(Le),K(je.user?`Signed in to GitHub as ${je.user}`:"Signed in to GitHub"),It("github");return}if(je.status==="pending"||je.status==="slow_down"){Y=window.setTimeout(ce,Math.max(je.interval||ct.interval,5)*1e3);return}Dn(null),w(je.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(je){if(P)return;Dn(null),w(je instanceof Error?je.message:String(je))}};return Y=window.setTimeout(ce,Math.max(ct.interval,5)*1e3),()=>{P=!0,window.clearTimeout(Y)}},[ct,It]),L.useEffect(()=>{if(!On)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.bitbucket.connected){wn(!1);const Ie=await Pe.settings();V(Ie),K(Le.bitbucket.user?`Signed in to Bitbucket as ${Le.bitbucket.user}`:"Signed in to Bitbucket"),It("bitbucket");return}if(Date.now()-ce>18e4){wn(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;wn(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[On,It]),L.useEffect(()=>{if(!Fn)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.gitlab.connected){_n(!1);const Ie=await Pe.settings();V(Ie),K(Le.gitlab.user?`Signed in to GitLab as ${Le.gitlab.user}`:"Signed in to GitLab"),It("gitlab");return}if(Date.now()-ce>18e4){_n(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;_n(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[Fn,It]);const Bn=async(P=o,Y=!1)=>{if(!P.trim())return null;ar.current=P,ee(!0);try{const ce=await Pe.architecture(P,!1);rt.current===P&&_(ce);const je=Pe.architectureGraph(P).then(Le=>{rt.current===P&&_(Ie=>Ie&&{...Ie,nodes:Le.nodes,edges:Le.edges,graph_pending:!1})});return je.catch(()=>{}).finally(()=>{rt.current===P&&ee(!1)}),Y&&await je,ce}catch(ce){throw rt.current===P&&ee(!1),ce}},Hr=async P=>{const Y=P.trim();if(!(!Y||Y===rt.current)){if(dt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),K(""),v(null),y(null),_(null),E("architecture"),Ht(Y),q(!0),He(`Loading ${p0(Y)}…`);try{await Promise.all([Bn(Y),Or(Y)])}catch(ce){rt.current===Y&&w(ce instanceof Error?ce.message:String(ce))}finally{rt.current===Y&&(He(""),q(!1))}}},jn=async()=>{if(dt.current||!Nn())return;w(""),K(""),He("Tracing load path…"),Ht(o),nn(a,c);const P=kn(o);try{const Y=await Pe.review(o,a,c,!0,he);yt(Y),E("review"),r("review"),await Pe.repos().then(ce=>j(ce.repos)).catch(()=>{}),await Promise.all([Bn(o),Hn(o),ur(o)])}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{P(),He("")}},Br=async(P=!0)=>{if(dt.current||!Nn())return;w(""),K(""),He(P?"Indexing…":"Full reindex…"),Ht(o);const Y=kn(o);try{await Pe.index(o,P);const ce=await Bn(o);await Pe.repos().then(je=>j(je.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(E("architecture"),r("architecture"))}catch(ce){w(ce instanceof Error?ce.message:String(ce))}finally{Y(),He("")}},xi=async()=>{if(!dt.current&&Nn()){w(""),K(""),He("Detecting layout…"),Ht(o);try{const P=await Pe.init(o);K(P.message),await Pe.repos().then(Y=>j(Y.repos)).catch(()=>{})}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ve=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),K("Copied markdown brief")}catch(P){w(P instanceof Error?P.message:String(P))}},so=async()=>{if(!dt.current){if(p!=null&&p.what_if){w("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first.");return}if(!(p!=null&&p.markdown)||!H||!oe){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const P=await Pe.postComment(z,H,Number(oe),p.markdown);K(P.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Vr=async()=>{if(!dt.current){w(""),He("Fetching pull requests…");try{const P=await Pe.prs(z,H,"open",o.trim()||void 0);U(P.pull_requests);const Y=M.find(ce=>ce.slug.toLowerCase()===H.trim().toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},wi=async()=>{w("");try{const P=await Pe.githubOAuthStart();Dn(P),Ju(P.verification_uri_complete,"github.com","/login/device")}catch(P){w(P instanceof Error?P.message:String(P))}},cr=async()=>{w("");try{const P=await Pe.bitbucketOAuthStart();wn(!0),Ju(P.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(P){wn(!1),w(P instanceof Error?P.message:String(P))}},lo=async()=>{w("");try{const P=await Pe.gitlabOAuthStart();_n(!0),Ju(P.authorize_url,new URL(P.authorize_url).hostname,"/oauth/authorize")}catch(P){_n(!1),w(P instanceof Error?P.message:String(P))}},dr=async P=>{if(!(dt.current||!o.trim())){w(""),He("Walking what-if path…");try{const Y=await Pe.whatIf(o,P);K(`${Y.title} — ${Y.confidence.level} · ${(Y.sinks||[]).length} sinks`),yt({...Y,markdown:Y.markdown||"",index:Y.index||(p==null?void 0:p.index),workspace:Y.workspace||(p==null?void 0:p.workspace)}),E("review"),r("review")}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},Vn=()=>{if(x){yt(x),E("review"),r("review"),K("Restored the last git-range walk");return}v(null),se(0),Ge(null),ut(null),$n(null),E("architecture"),r("architecture"),K("")},bt=async P=>{var Le;if(dt.current)return;Fr(P.provider,P.repo,String(P.number));const Y=M.find(Ie=>Ie.slug.toLowerCase()===P.repo.toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path),w(""),He(`Fetching ${P.provider} #${P.number}…`);const ce=(Y==null?void 0:Y.local_path)||o,je=ce?kn(ce):()=>{};try{const Ie=await Pe.reviewPr(P.provider,P.repo,P.number,(Y==null?void 0:Y.local_path)||o||void 0);yt(Ie),Ie.pull_request&&typeof Ie.pull_request.repo_path=="string"&&Ht(Ie.pull_request.repo_path),nn(String(Ie.base||P.target_branch),String(Ie.head||P.source_branch)),E("review"),r("review"),typeof((Le=Ie.pull_request)==null?void 0:Le.repo_path)=="string"&&Hn(Ie.pull_request.repo_path)}catch(Ie){nn(P.base_sha||P.target_branch,P.head_sha||P.source_branch),r("review"),w(Ie instanceof Error?Ie.message:String(Ie))}finally{je(),He("")}},Wr=async P=>{w("");try{V(await Pe.oauthDisconnect(P)),z===P&&D([]),K(`Disconnected ${P}`)}catch(Y){w(Y instanceof Error?Y.message:String(Y))}},Et=async P=>{P.preventDefault();const Y=new FormData(P.currentTarget),ce={github_token:String(Y.get("github_token")||""),github_oauth_client_id:String(Y.get("github_oauth_client_id")||""),github_host:String(Y.get("github_host")||""),gitlab_token:String(Y.get("gitlab_token")||""),gitlab_host:String(Y.get("gitlab_host")||""),gitlab_oauth_client_id:String(Y.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(Y.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(Y.get("bitbucket_token")||""),bitbucket_username:String(Y.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(Y.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(Y.get("bitbucket_oauth_client_secret")||""),ai_provider:String(Y.get("ai_provider")||"none"),ai_api_key:String(Y.get("ai_api_key")||""),ai_model:String(Y.get("ai_model")||""),ai_base_url:String(Y.get("ai_base_url")||"")},je=k.length?{...ce,workspaces:k.map(Le=>({path:Le.path,name:Le.name}))}:ce;try{V(await Pe.saveSettings(je)),K("Settings saved on this machine")}catch(Le){w(Le instanceof Error?Le.message:String(Le))}},ao=async()=>{if(!(!p||dt.current)){He("Residual analysis…");try{const P=await Pe.residual(p);ke(P.note)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ur=L.useRef(jn);Ur.current=jn;const Yr=L.useRef(t);Yr.current=t;const Wn=L.useRef(!1);Wn.current=st;const Un=L.useRef(p);Un.current=p;const bn=L.useRef(Z);bn.current=Z,L.useEffect(()=>{const P=localStorage.getItem("loadpath.lastReviewId"),Y=(localStorage.getItem("loadpath.repo")||"").trim();if(!P||!Y){sr(!1);return}let ce=!1;return Pe.getReview(Y,P).then(je=>{ce||(yt(je),nn(je.base||localStorage.getItem("loadpath.base")||"HEAD~1",je.head||localStorage.getItem("loadpath.head")||"HEAD"),Hn(Y),ur(Y))}).catch(()=>{}).finally(()=>{ce||sr(!1)}),()=>{ce=!0}},[]);const Bt=L.useRef("");L.useEffect(()=>{if(!Je||!o.trim())return;let P=!1;const Y=async()=>{try{const je=await Pe.workspaceStatus(o);if(P)return;Bt.current&&je.fingerprint!==Bt.current&&!dt.current&&(pe(!0),localStorage.setItem("loadpath.dirty","1"),Ur.current()),Bt.current=je.fingerprint}catch{}};Y();const ce=window.setInterval(Y,2e3);return()=>{P=!0,window.clearInterval(ce)}},[Je,o]),L.useEffect(()=>{const P=Y=>{var Le;if((Y.metaKey||Y.ctrlKey)&&Y.key.toLowerCase()==="k"){Y.preventDefault(),lt(Ie=>!Ie);return}if(Wn.current){Y.key==="Escape"&&(Y.preventDefault(),lt(!1));return}if(Dr.current){Y.key==="Escape"&&(Y.preventDefault(),$e(!1));return}const ce=Y.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){Y.key==="Escape"&&ce.blur();return}if(Y.key==="Escape"){w(""),K(""),Ge(wt),ut(null);return}if(Y.key==="j"||Y.key==="k"){const Ie=((Le=Un.current)==null?void 0:Le.read_order)||[];if(!Ie.length)return;Y.preventDefault();const Gn=bn.current,qr=Y.key==="j"?Math.min(Ie.length-1,Gn+1):Math.max(0,Gn-1);se(qr);return}const je=Zu.find(Ie=>Ie.shortcut===Y.key);if(je&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey&&r(je.id),(Y.metaKey||Y.ctrlKey)&&Y.key==="Enter"){if(Yr.current==="settings"||Yr.current==="prs"||dt.current)return;Y.preventDefault(),Ur.current()}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[wt]);const _i=async(P,Y)=>{if(!o.trim())return;const ce=await kN(o,P,Y);ce.ok?K(ce.message):w(ce.message)},Gr=async()=>{if(p)try{const P=await Pe.exportHtml(p),Y=URL.createObjectURL(P),ce=document.createElement("a");ce.href=Y,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(Y),K("Saved HTML brief")}catch(P){w(P instanceof Error?P.message:String(P))}},fr=async P=>{if(o.trim()){He("Loading stored review…");try{const Y=await Pe.getReview(o,P);yt(Y),nn(Y.base||a,Y.head||c),E("review"),r("review");const ce=Ot.find(je=>je.id!==P);if(ce)try{$n(await Pe.reviewDiff(o,P,ce.id))}catch{$n(null)}}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},hr={selectedId:at,onSelect:Ge,nodeRoles:p==null?void 0:p.node_roles,testOverlay:gt,isolateSource:Pt,onIsolate:ut,repoPath:o,onOpenFile:_i,pinnedId:wt,onPin:qt},Yn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},...p!=null&&p.what_if?[{id:"exit-whatif",group:"Review",label:x?"Back to git-range walk":"Exit what-if walk",run:Vn}]:[],{id:"index",group:"Run",label:"Index repository",run:()=>void Br(!0)},{id:"watch",group:"Run",label:Je?"Stop watching working tree":"Watch working tree",run:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")}},{id:"tests",group:"Graph",label:gt?"Hide test overlay":"Show test overlay",run:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Gr()},...Zu.map(P=>({id:`tab-${P.id}`,group:"Tabs",label:`Go to ${P.label}`,hint:P.shortcut,run:()=>r(P.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(P=>({id:`node-${P.id}`,group:"Nodes",label:P.name,hint:ro(P.type),run:()=>{Ge(P.id),r("graph")}})),...Ot.slice(0,12).map(P=>({id:`hist-${P.id}`,group:"History",label:P.title||P.id,hint:`${P.level||""} ${P.created_at||""}`.trim(),run:()=>void fr(P.id)}))],En=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[b,m,p]),uo=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[b,m,p]),pr=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Fe=((p==null?void 0:p.findings)||[]).filter(P=>!P.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Zu.map(P=>{const Y=P.icon,ce=t===P.id;return d.jsxs("button",{type:"button","data-testid":P.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":P.label,onClick:()=>r(P.id),children:[d.jsx(Y,{}),d.jsx("span",{children:P.label})]},P.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:ve,onChange:P=>Sn(P.target.value),children:["dark","light"].map(P=>d.jsx("optgroup",{label:P==="dark"?"Dark":"Light",children:Ul.filter(Y=>Y.group===P).map(Y=>d.jsx("option",{value:Y.id,children:Y.label},Y.id))},P))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:N||pr}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[N?d.jsxs("div",{className:$!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","aria-valuemin":$!=null?0:void 0,"aria-valuemax":$!=null?100:void 0,"aria-valuenow":$??void 0,"data-testid":"progress",children:[d.jsx("i",{style:$!=null?{width:`${$}%`}:void 0}),d.jsx("span",{className:"sr-only",children:N})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[k.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:k.some(P=>P.path===o)?o:"",disabled:!!N,"aria-busy":G,onChange:P=>{P.target.value&&Hr(P.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),k.map(P=>d.jsxs("option",{value:P.path,children:[P.name,P.indexed?` (${P.counts.nodes})`:""]},P.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:P=>{const Y=P.target.value;s(Y),Y.trim()!==_t.current&&(_t.current="",Ft(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>$e(!0),children:d.jsx(bp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(Sp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:P=>nn(P,c),placeholder:"base",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(Sp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:P=>nn(a,P),placeholder:"head",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:he?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":he,onClick:()=>{const P=!he;pe(P),localStorage.setItem("loadpath.dirty",P?"1":"0")},children:he?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:Je?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":Je,onClick:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")},children:Je?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.what_if?"what-if · ":"",p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!N,onClick:xi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!N,onClick:()=>Br(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!N,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[R?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:R}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,ne?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:ne}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>K(""),"aria-label":"Dismiss",children:"×"})]}):null,((co=p==null?void 0:p.index)!=null&&co.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((fo=p==null?void 0:p.index)==null?void 0:fo.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Si=p==null?void 0:p.index)==null?void 0:Si.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(ho=p==null?void 0:p.workspace)!=null&&ho.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,p!=null&&p.what_if?d.jsxs("div",{className:"banner whatif","data-testid":"whatif-banner",children:[d.jsxs("span",{children:["Hypothetical walk from"," ",d.jsx("strong",{children:((po=p.node)==null?void 0:po.name)||"this node"}),". Loadpath ignored Base/Head and asked which sinks would feel this node change — not a filter of the current map."]}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-exit-whatif",onClick:Vn,children:x?"Back to git range":"Back to architecture"})]}):null,G?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:N||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":G||te,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(DN,{review:p,findings:Fe,aiNote:me,busy:!!N,tourIndex:Z,onTour:se,onAskAi:ao,onCopy:Ve,onPost:so,onSelect:Ge,onOpenFile:_i,onExport:Gr,history:Ot,diff:io,onReopen:fr,onWaiver:(P,Y)=>{o.trim()&&Pe.addWaiver(o,P,Y||void 0,"from review").then(ce=>{or(ce),K(`Waived ${P} in loadpath.yml`)})}}):zr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Qu,{nodes:p.nodes,edges:p.edges,onWhatIf:dr,focusPath:(go=p.read_order[Z])==null?void 0:go.path,...hr}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(ON,{architecture:m,busy:!!N,onReindex:()=>Br(!1),onReview:jn,onSelect:Ge,config:vi,health:$r,onSaveConfig:P=>{Pe.saveConfig(o,P).then(Y=>{or(Y),K("Wrote loadpath.yml")})},onWaiver:(P,Y,ce)=>{Pe.addWaiver(o,P,Y,ce).then(je=>{or(je),K(`Waived ${P}`)})}}):G?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(te||m!=null&&m.graph_pending)&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(ki=m==null?void 0:m.counts)!=null&&ki.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Qu,{nodes:m.nodes,edges:m.edges,onWhatIf:dr,...hr,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":b==="review","data-testid":"graph-mode-review",className:b==="review"?"active":"",onClick:()=>E("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":b==="architecture","data-testid":"graph-mode-architecture",className:b==="architecture"?"active":"",onClick:()=>E("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:gt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":gt,onClick:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")},children:"Tests"})]}),En.length?d.jsx(Qu,{nodes:En,edges:uo,onWhatIf:dr,...hr}):te||m!=null&&m.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:z,onChange:P=>Fr(P.target.value,H,oe),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:M.length?"Search your repos":"owner/repo",value:H,onChange:P=>Fr(z,P.target.value,oe),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:M.map(P=>d.jsxs("option",{value:P.slug,children:[P.private?"private":"public",P.local_path?" · local":""]},P.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!N||!oo(z),onClick:()=>{It(z)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!N,onClick:Vr,children:"List PRs"})]}),M.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[M.length," ",z," repositor",M.length===1?"y":"ies",z==="github"&&C.github_user?` · @${String(C.github_user)}`:"",z==="gitlab"&&C.gitlab_user?` · @${String(C.gitlab_user)}`:"",z==="bitbucket"&&C.bitbucket_user?` · ${String(C.bitbucket_user)}`:""]}):null,W.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):W.map(P=>{var Y;return d.jsxs("article",{className:"pr","data-testid":`pr-${P.number}`,children:[d.jsxs("h3",{children:["#",P.number," ",P.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${P.draft?"":"open"}`,children:P.draft?"draft":P.state}),d.jsx("span",{children:P.author}),d.jsxs("span",{children:[P.source_branch," → ",P.target_branch]}),P.loadpath?d.jsxs("span",{className:`chip ${P.loadpath.level||""}`,"data-testid":`pr-loadpath-${P.number}`,children:[((Y=P.loadpath.level)==null?void 0:Y.toUpperCase())||"REVIEWED",P.loadpath.contract_break&&P.loadpath.contract_break!=="none"?` · ${P.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:P.url,target:"_blank",rel:"noreferrer",children:["Open on ",P.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${P.number}`,onClick:()=>void bt(P),children:"Review this PR"})]})]},`${P.provider}-${P.number}`)})]}),t==="settings"&&Ne&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Et,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Ul.map(P=>d.jsxs("button",{type:"button","data-theme":P.id,className:ve===P.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${P.id}`,onClick:()=>Sn(P.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:P.label}),d.jsx("div",{className:"group",children:P.group})]},P.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:xm(),onChange:P=>SN(P.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:C.github_token_set?C.github_user?`Signed in as @${String(C.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void Wr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!ct||!C.github_oauth_ready,onClick:()=>void wi(),children:ct?"Waiting for GitHub…":"Sign in with GitHub"})})]}),ct?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:ct.user_code})," at GitHub if the browser did not fill it in."]}):null,C.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(C.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(C.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:C.gitlab_token_set?C.gitlab_user?`Signed in as @${String(C.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void Wr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Fn||!C.gitlab_oauth_ready,onClick:()=>void lo(),children:Fn?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(C.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(C.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:C.bitbucket_token_set?C.bitbucket_user?`Signed in as ${String(C.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void Wr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:On||!C.bitbucket_oauth_ready,onClick:()=>void cr(),children:On?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),C.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(C.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(C.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((Xr=C.ai)==null?void 0:Xr.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((rn=C.ai)==null?void 0:rn.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((on=C.ai)==null?void 0:on.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(d0,{open:st,actions:Yn,onClose:()=>lt(!1)}),Te?d.jsx(MN,{initialPath:o,onClose:()=>$e(!1),onSelect:P=>{if(dt.current){w("Wait for the current job to finish before switching workspace.");return}$e(!1),Hr(P)}}):null]})}function DN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:v,onOpenFile:x,onExport:y,history:m,diff:_,onReopen:k,onWaiver:j}){var E,R,w,N,A,$,F,G,q,te,ee,ne,K,C,V,W,U;const b=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),b.length?d.jsx("ul",{className:"reasons",children:b.map(M=>d.jsx("li",{children:M},M))}):null,t.what_if?d.jsx("span",{className:"chip whatif","data-testid":"whatif-chip",children:"what-if"}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Qo(M)},M)),(E=t.contract_break)!=null&&E.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>j(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(R=t.workspace)!=null&&R.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>x(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(km,{cards:t.deepening}),(N=(w=t.contract_break)==null?void 0:w.reasons)!=null&&N.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),($=(A=t.contract_break.sides)==null?void 0:A.rows)!=null&&$.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(F=t.auth)!=null&&F.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(G=t.suggested_tests)==null?void 0:G.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(q=t.trend)!=null&&q.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",ec(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),m.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:m.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,m.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>k(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?ec(M.created_at):""})]},M.id))]}):null,(ee=(te=t.evolution)==null?void 0:te.notes)!=null&&ee.length||(K=(ne=t.evolution)==null?void 0:ne.hotspots)!=null&&K.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((C=t.evolution)==null?void 0:C.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((V=t.evolution)==null?void 0:V.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:y,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",disabled:s||!!t.what_if,title:t.what_if?"Hypothetical walks are not posted to a pull request":void 0,onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(W=t.codeowners_reviewers)!=null&&W.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function ON({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var x;const v=t.findings.filter(y=>!y.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${ec(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(y=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y.name})," — ",(y.django_apps||[]).join(", ")||"no apps"," ·"," ",(y.owners||[]).join(", ")||"unowned"]},y.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(y=>d.jsx("div",{className:"muted",children:y},y))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:v.length})]}),v.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):v.map(y=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>y.node_id&&a(y.node_id),children:[d.jsx("span",{className:`chip ${y.severity}`,children:y.severity}),y.message]})},y.rule+y.message))]}),d.jsx(km,{cards:t.deepening}),(x=c==null?void 0:c.points)!=null&&x.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(y=>d.jsx("i",{className:y.level||"",title:`${y.level} · ${y.findings} findings`,style:{height:`${8+Math.min(24,(y.findings||0)*4)}px`}},y.id||y.created_at))}),Object.entries(c.contexts).map(([y,m])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y})," — last ",((_=m[m.length-1])==null?void 0:_.findings)??0," findings"]},y)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(f0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((y,m)=>m[1]-y[1]).slice(0,12).map(([y,m])=>d.jsxs("tr",{children:[d.jsx("td",{children:ro(y)}),d.jsx("td",{children:m})]},y))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function km({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:h0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}Sm(_m());a0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(zN,{})}));export{Bk as L,BN as a,FN as c,d as j,HN as l,L as r,ro as t}; +`)),x=v.reduce((y,m)=>y.concat(...m),[]);return[v,x]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Xh,v=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const x=_=>{var b,E;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!v)&&mg(_))return!1;const j=Kh(_.code,h);if(u.current.add(_[j]),qh(c,u.current,!1)){const R=((E=(b=_.composedPath)==null?void 0:b.call(_))==null?void 0:E[0])||_.target,w=(R==null?void 0:R.nodeName)==="BUTTON"||(R==null?void 0:R.nodeName)==="A";r.preventDefault!==!1&&(a.current||!w)&&_.preventDefault(),s(!0)}},y=_=>{const k=Kh(_.code,h);qh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},m=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",x),p==null||p.addEventListener("keyup",y),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{p==null||p.removeEventListener("keydown",x),p==null||p.removeEventListener("keyup",y),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,s]),o}function qh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Kh(t,r){return r.includes(t)?"code":"key"}const P_=()=>{const t=Ye();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=Nc(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),v={x:r.x-h,y:r.y-p},x=o.snapGrid??a,y=o.snapToGrid??u;return gs(v,s,y,x)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=eo(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function Dg(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)I_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function I_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function R_(t,r){return Dg(t,r)}function T_(t,r){return Dg(t,r)}function ai(t,r){return{id:t,type:"select",selected:r}}function Gi(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(ai(u.id,c)))}return s}function Qh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Zh(t){return{id:t.id,type:"remove"}}const L_=fg();function A_(t,r,o={}){return v1(t,r,{...o,onError:o.onError??L_})}const Jh=t=>r1(t),$_=t=>lg(t);function Og(t){return L.forwardRef(t)}const Fg=typeof window<"u"?L.useLayoutEffect:L.useEffect;function ep(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>z_(()=>o(a=>a+BigInt(1))));return Fg(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function z_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Hg=L.createContext(null);function D_({children:t}){const r=Ye(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:v,hasDefaultNodes:x,onNodesChange:y,nodeLookup:m,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let j=p;for(const E of h)j=typeof E=="function"?E(j):E;let b=Qh({items:j,lookup:m});for(const E of k.values())b=E(b);x&&v(j),b.length>0?y==null||y(b):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:R,setNodes:w}=r.getState();E&&w(R)})},[]),s=ep(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:v,hasDefaultEdges:x,onEdgesChange:y,edgeLookup:m}=r.getState();let _=p;for(const k of h)_=typeof k=="function"?k(_):k;x?v(_):y&&y(Qh({items:_,lookup:m}))},[]),u=ep(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Hg.Provider,{value:c,children:t})}function O_(){const t=L.useContext(Hg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const F_=t=>!!t.panZoom;function na(){const t=P_(),r=Ye(),o=O_(),s=De(F_),a=L.useMemo(()=>{const u=y=>r.getState().nodeLookup.get(y),c=y=>{o.nodeQueue.push(y)},h=y=>{o.edgeQueue.push(y)},p=y=>{var E,R;const{nodeLookup:m,nodeOrigin:_}=r.getState(),k=Jh(y)?y:m.get(y.id),j=k.parentId?pg(k.position,k.measured,k.parentId,m,_):k.position,b={...k,position:j,width:((E=k.measured)==null?void 0:E.width)??k.width,height:((R=k.measured)==null?void 0:R.height)??k.height};return ss(b)},v=(y,m,_={replace:!1})=>{c(k=>k.map(j=>{if(j.id===y){const b=typeof m=="function"?m(j):m;return _.replace&&Jh(b)?b:{...j,...b}}return j}))},x=(y,m,_={replace:!1})=>{h(k=>k.map(j=>{if(j.id===y){const b=typeof m=="function"?m(j):m;return _.replace&&$_(b)?b:{...j,...b}}return j}))};return{getNodes:()=>r.getState().nodes.map(y=>({...y})),getNode:y=>{var m;return(m=u(y))==null?void 0:m.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:y=[]}=r.getState();return y.map(m=>({...m}))},getEdge:y=>r.getState().edgeLookup.get(y),setNodes:c,setEdges:h,addNodes:y=>{const m=Array.isArray(y)?y:[y];o.nodeQueue.push(_=>[..._,...m])},addEdges:y=>{const m=Array.isArray(y)?y:[y];o.edgeQueue.push(_=>[..._,...m])},toObject:()=>{const{nodes:y=[],edges:m=[],transform:_}=r.getState(),[k,j,b]=_;return{nodes:y.map(E=>({...E})),edges:m.map(E=>({...E})),viewport:{x:k,y:j,zoom:b}}},deleteElements:async({nodes:y=[],edges:m=[]})=>{const{nodes:_,edges:k,onNodesDelete:j,onEdgesDelete:b,triggerNodeChanges:E,triggerEdgeChanges:R,onDelete:w,onBeforeDelete:N}=r.getState(),{nodes:A,edges:$}=await a1({nodesToRemove:y,edgesToRemove:m,nodes:_,edges:k,onBeforeDelete:N}),F=$.length>0,G=A.length>0;if(F){const q=$.map(Zh);b==null||b($),R(q)}if(G){const q=A.map(Zh);j==null||j(A),E(q)}return(G||F)&&(w==null||w({nodes:A,edges:$})),{deletedNodes:A,deletedEdges:$}},getIntersectingNodes:(y,m=!0,_)=>{const k=Nh(y),j=k?y:p(y),b=_!==void 0;return j?(_||r.getState().nodes).filter(E=>{const R=r.getState().nodeLookup.get(E.id);if(R&&!k&&(E.id===y.id||!R.internals.positionAbsolute))return!1;const w=ss(b?E:R),N=Hl(w,j);return m&&N>0||N>=w.width*w.height||N>=j.width*j.height}):[]},isNodeIntersecting:(y,m,_=!0)=>{const j=Nh(y)?y:p(y);if(!j)return!1;const b=Hl(j,m);return _&&b>0||b>=m.width*m.height||b>=j.width*j.height},updateNode:v,updateNodeData:(y,m,_={replace:!1})=>{v(y,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},updateEdge:x,updateEdgeData:(y,m,_={replace:!1})=>{x(y,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},getNodesBounds:y=>{const{nodeLookup:m,nodeOrigin:_}=r.getState();return i1(y,{nodeLookup:m,nodeOrigin:_})},getHandleConnections:({type:y,id:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${y}${m?`-${m}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:y,handleId:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${y?m?`-${y}-${m}`:`-${y}`:""}`))==null?void 0:k.values())??[])},fitView:async y=>{const m=r.getState().fitViewResolver??d1();return r.setState({fitViewQueued:!0,fitViewOptions:y,fitViewResolver:m}),o.nodeQueue.push(_=>[..._]),m.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const tp=t=>t.selected,H_=typeof window<"u"?window:void 0;function B_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ye(),{deleteElements:s}=na(),a=as(t,{actInsideInputWithModifier:!1}),u=as(r,{target:H_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(tp),edges:c.filter(tp)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function V_(t){const r=Ye();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=jc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",mn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const ra={position:"absolute",width:"100%",height:"100%",top:0,left:0},W_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function U_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=di.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:v,translateExtent:x,minZoom:y,maxZoom:m,zoomActivationKeyCode:_,preventScrolling:k=!0,children:j,noWheelClassName:b,noPanClassName:E,onViewportChange:R,isControlledViewport:w,paneClickDistance:N,selectionOnDrag:A}){const $=Ye(),F=L.useRef(null),{userSelectionActive:G,lib:q,connectionInProgress:te}=De(W_,Qe),ee=as(_),ne=L.useRef();V_(F);const K=L.useCallback(C=>{R==null||R({x:C[0],y:C[1],zoom:C[2]}),w||$.setState({transform:C})},[R,w]);return L.useEffect(()=>{if(F.current){ne.current=X1({domNode:F.current,minZoom:y,maxZoom:m,translateExtent:x,viewport:v,onDraggingChange:U=>$.setState(M=>M.paneDragging===U?M:{paneDragging:U}),onPanZoomStart:(U,M)=>{const{onViewportChangeStart:D,onMoveStart:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoom:(U,M)=>{const{onViewportChange:D,onMove:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoomEnd:(U,M)=>{const{onViewportChangeEnd:D,onMoveEnd:H}=$.getState();H==null||H(U,M),D==null||D(M)}});const{x:C,y:V,zoom:W}=ne.current.getViewport();return $.setState({panZoom:ne.current,transform:[C,V,W],domNode:F.current.closest(".react-flow")}),()=>{var U;(U=ne.current)==null||U.destroy()}}},[]),L.useEffect(()=>{var C;(C=ne.current)==null||C.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:ee,preventScrolling:k,noPanClassName:E,userSelectionActive:G,noWheelClassName:b,lib:q,onTransformChange:K,connectionInProgress:te,selectionOnDrag:A,paneClickDistance:N})},[t,r,o,s,a,u,c,h,p,ee,k,E,G,b,q,K,te,A,N]),d.jsx("div",{className:"react-flow__renderer",ref:F,style:ra,children:j})}const Y_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function G_(){const{userSelectionActive:t,userSelectionRect:r}=De(Y_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const qu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},X_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function q_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=is.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:v,onPaneContextMenu:x,onPaneScroll:y,onPaneMouseEnter:m,onPaneMouseMove:_,onPaneMouseLeave:k,children:j}){const b=L.useRef(0),E=Ye(),{userSelectionActive:R,elementsSelectable:w,dragging:N,panBy:A,autoPanSpeed:$}=De(X_,Qe),F=w&&(t||R),G=L.useRef(null),q=L.useRef(),te=L.useRef(new Set),ee=L.useRef(new Set),ne=L.useRef(!1),K=L.useRef(!1),C=L.useRef({x:0,y:0}),V=L.useRef(!1),W=Z=>{if(K.current||ne.current||E.getState().connection.inProgress){K.current=!1,ne.current=!1;return}v==null||v(Z),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},U=Z=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Z.preventDefault();return}x==null||x(Z)},M=y?Z=>y(Z):void 0,D=Z=>{K.current&&(Z.stopPropagation(),K.current=!1)},H=Z=>{var $e,st;if(Z.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:se,transform:me}=E.getState();if(q.current=se==null?void 0:se.getBoundingClientRect(),!q.current)return;const ke=Z.target===G.current;if(!ke&&!!Z.target.closest(".nokey")||!t||!(c&&ke||r)||Z.button!==0||!Z.isPrimary)return;(st=($e=Z.target)==null?void 0:$e.setPointerCapture)==null||st.call($e,Z.pointerId),K.current=!1;const{x:Ne,y:Me}=gn(Z.nativeEvent,q.current),Te=gs({x:Ne,y:Me},me);E.setState({userSelectionRect:{width:0,height:0,startX:Te.x,startY:Te.y,x:Ne,y:Me}}),ke||(Z.stopPropagation(),Z.preventDefault())};function I(Z,se){const{userSelectionRect:me}=E.getState();if(!me)return;const{transform:ke,nodeLookup:ve,edgeLookup:re,connectionLookup:Ne,triggerNodeChanges:Me,triggerEdgeChanges:Te,defaultEdgeOptions:$e}=E.getState(),st={x:me.startX,y:me.startY},{x:lt,y:at}=eo(st,ke),Ge={startX:st.x,startY:st.y,x:Zmt.id)),ee.current=new Set;const gt=($e==null?void 0:$e.selectable)??!0;for(const mt of te.current){const Pt=Ne.get(mt);if(Pt)for(const{edgeId:ut}of Pt.values()){const Je=re.get(ut);Je&&(Je.selectable??gt)&&ee.current.add(ut)}}if(!jh(wt,te.current)){const mt=Gi(ve,te.current,!0);Me(mt)}if(!jh(qt,ee.current)){const mt=Gi(re,ee.current);Te(mt)}E.setState({userSelectionRect:Ge,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!a||!q.current)return;const[Z,se]=kc(C.current,q.current,$);A({x:Z,y:se}).then(me=>{if(!K.current||!me){b.current=requestAnimationFrame(z);return}const{x:ke,y:ve}=C.current;I(ke,ve),b.current=requestAnimationFrame(z)})}const ie=()=>{cancelAnimationFrame(b.current),b.current=0,V.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=Z=>{const{userSelectionRect:se,transform:me,resetSelectedElements:ke}=E.getState();if(!q.current||!se)return;const{x:ve,y:re}=gn(Z.nativeEvent,q.current);C.current={x:ve,y:re};const Ne=eo({x:se.startX,y:se.startY},me);if(!K.current){const Me=r?0:u;if(Math.hypot(ve-Ne.x,re-Ne.y)<=Me)return;ke(),h==null||h(Z)}K.current=!0,V.current||(z(),V.current=!0),I(ve,re)},fe=Z=>{var se,me;if(!F){Z.target===G.current&&E.getState().connection.inProgress&&(ne.current=!0);return}Z.button===0&&((me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),!R&&Z.target===G.current&&E.getState().userSelectionRect&&(W==null||W(Z)),E.setState({userSelectionActive:!1,userSelectionRect:null}),K.current&&(p==null||p(Z),E.setState({nodesSelectionActive:te.current.size>0})),ie())},he=Z=>{var se,me;(me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),ie()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:nt(["react-flow__pane",{draggable:pe,dragging:N,selection:t}]),onClick:F?void 0:qu(W,G),onContextMenu:qu(U,G),onWheel:qu(M,G),onPointerEnter:F?void 0:m,onPointerMove:F?oe:_,onPointerUp:fe,onPointerCancel:F?he:void 0,onPointerDownCapture:F?H:void 0,onClickCapture:F?D:void 0,onPointerLeave:k,ref:G,style:ra,children:[j,d.jsx(G_,{})]})}function hc({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),v=h.get(t);if(!v){p==null||p("012",mn.error012(t));return}r.setState({nodesSelectionActive:!1}),v.selected?(o||v.selected&&c)&&(u({nodes:[v],edges:[]}),requestAnimationFrame(()=>{var x;return(x=s==null?void 0:s.current)==null?void 0:x.blur()})):a([t])}function Bg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ye(),[p,v]=L.useState(!1),x=L.useRef();return L.useEffect(()=>{if(!r)return x.current=L1({getStoreItems:()=>h.getState(),onNodeMouseDown:y=>{hc({id:y,store:h,nodeRef:t})},onDragStart:()=>{v(!0)},onDragStop:()=>{v(!1)}}),()=>{var y;(y=x.current)==null||y.destroy(),x.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!x.current||x.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const K_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Vg(){const t=Ye();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:v,nodeOrigin:x}=t.getState(),y=new Map,m=K_(c),_=a?u[0]:5,k=a?u[1]:5,j=o.direction.x*_*o.factor,b=o.direction.y*k*o.factor;for(const[,E]of v){if(!m(E))continue;let R={x:E.internals.positionAbsolute.x+j,y:E.internals.positionAbsolute.y+b};a&&(R=ps(R,u));const{position:w,positionAbsolute:N}=ag({nodeId:E.id,nextPosition:R,nodeLookup:v,nodeExtent:s,nodeOrigin:x,onError:h});E.position=w,E.internals.positionAbsolute=N,y.set(E.id,E)}p(y)},[])}const Ic=L.createContext(null),Q_=Ic.Provider;Ic.Consumer;const Wg=()=>L.useContext(Ic),Z_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Ug=L.createContext(null);function J_({children:t}){const r=De(Z_,Qe);return d.jsx(Ug.Provider,{value:r,children:t})}function eS(){const t=L.useContext(Ug);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const tS={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},nS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:v}=c;if(!h&&!a)return tS;const x=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:x,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Zi.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:x&&v}};function rS({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:v,onMouseDown:x,onTouchStart:y,...m},_){var V,W;const k=c||null,j=t==="target",b=Ye(),E=Wg(),{connectOnClick:R,noPanClassName:w,rfId:N}=eS(),{connectingFrom:A,connectingTo:$,clickConnecting:F,isPossibleEndHandle:G,connectionInProcess:q,clickConnectionInProcess:te,valid:ee}=De(nS(E,k,t),Qe);E||(W=(V=b.getState()).onError)==null||W.call(V,"010",mn.error010());const ne=U=>{const{defaultEdgeOptions:M,onConnect:D,hasDefaultEdges:H}=b.getState(),I={...M,...U};if(H){const{edges:z,setEdges:ie,onError:oe}=b.getState();ie(A_(I,z,{onError:oe}))}D==null||D(I),h==null||h(I)},K=U=>{if(!E)return;const M=yg(U.nativeEvent);if(a&&(M&&U.button===0||!M)){const D=b.getState();fc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:j,handleId:k,nodeId:E,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...H)=>{var I,z;return(z=(I=b.getState()).onConnectEnd)==null?void 0:z.call(I,...H)},updateConnection:D.updateConnection,onConnect:ne,isValidConnection:o||((...H)=>{var I,z;return((z=(I=b.getState()).isValidConnection)==null?void 0:z.call(I,...H))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}M?x==null||x(U):y==null||y(U)},C=U=>{const{onClickConnectStart:M,onClickConnectEnd:D,connectionClickStartHandle:H,connectionMode:I,isValidConnection:z,lib:ie,rfId:oe,nodeLookup:fe,connection:he}=b.getState();if(!E||!H&&!a)return;if(!H){M==null||M(U.nativeEvent,{nodeId:E,handleId:k,handleType:t}),b.setState({connectionClickStartHandle:{nodeId:E,type:t,id:k}});return}const pe=gg(U.target),Z=o||z,{connection:se,isValid:me}=fc.isValid(U.nativeEvent,{handle:{nodeId:E,id:k,type:t},connectionMode:I,fromNodeId:H.nodeId,fromHandleId:H.id||null,fromType:H.type,isValidConnection:Z,flowId:oe,doc:pe,lib:ie,nodeLookup:fe});me&&se&&ne(se);const ke=structuredClone(he);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,D==null||D(U,ke),b.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":k,"data-nodeid":E,"data-handlepos":r,"data-id":`${N}-${E}-${k}-${t}`,className:nt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",w,v,{source:!j,target:j,connectable:s,connectablestart:a,connectableend:u,clickconnecting:F,connectingfrom:A,connectingto:$,valid:ee,connectionindicator:s&&(!q||G)&&(q||te?u:a)}]),onMouseDown:K,onTouchStart:K,onClick:R?C:void 0,ref:_,...m,children:p})}const no=L.memo(Og(rS));function iS({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(no,{type:"source",position:o,isConnectable:r})]})}function oS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:s=Se.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(no,{type:"source",position:s,isConnectable:r})]})}function sS(){return null}function lS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const Vl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},np={input:iS,default:oS,output:lS,group:sS};function aS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const uS=t=>{const{width:r,height:o,x:s,y:a}=hs(t.nodeLookup,{filter:u=>!!u.selected});return{width:pn(r)?r:null,height:pn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function cS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ye(),{width:a,height:u,transformString:c,userSelectionActive:h}=De(uS,Qe),p=Vg(),v=L.useRef(null);L.useEffect(()=>{var _;o||(_=v.current)==null||_.focus({preventScroll:!0})},[o]);const x=!h&&a!==null&&u!==null;if(Bg({nodeRef:v,disabled:!x}),!x)return null;const y=t?_=>{const k=s.getState().nodes.filter(j=>j.selected);t(_,k)}:void 0,m=_=>{Object.prototype.hasOwnProperty.call(Vl,_.key)&&(_.preventDefault(),p({direction:Vl[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:nt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:v,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:o?void 0:-1,onKeyDown:o?void 0:m,style:{width:a,height:u}})})}const rp=typeof window<"u"?window:void 0,dS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Yg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:v,selectionOnDrag:x,selectionMode:y,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:j,zoomActivationKeyCode:b,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:N,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:G,autoPanOnSelection:q,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,preventScrolling:C,onSelectionContextMenu:V,noWheelClassName:W,noPanClassName:U,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:H}){const{nodesSelectionActive:I,userSelectionActive:z}=De(dS,Qe),ie=as(v,{target:rp}),oe=as(j,{target:rp}),fe=oe||G,he=oe||N,pe=x&&fe!==!0,Z=ie||z||pe;return B_({deleteKeyCode:p,multiSelectionKeyCode:k}),d.jsx(U_,{onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:!ie&&fe,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,zoomActivationKeyCode:b,preventScrolling:C,noWheelClassName:W,noPanClassName:U,onViewportChange:D,isControlledViewport:H,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(q_,{onSelectionStart:m,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:q,isSelecting:!!Z,selectionMode:y,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:pe,children:[t,I&&d.jsx(cS,{onSelectionContextMenu:V,noPanClassName:U,disableKeyboardA11y:M})]})})}Yg.displayName="FlowRenderer";const fS=L.memo(Yg),hS=t=>r=>t?Sc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function pS(t){return De(L.useCallback(hS(t),[t]),Qe)}const gS=t=>t.updateNodeInternals;function mS(){const t=De(gS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function yS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ye(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),v=L.useRef(r),x=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!x||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[x,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const y=v.current!==r,m=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(y||m||_)&&(v.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function vS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:v,nodesFocusable:x,resizeObserver:y,noDragClassName:m,noPanClassName:_,disableKeyboardA11y:k,rfId:j,nodeTypes:b,nodeClickDistance:E,onError:R}){const{node:w,internals:N,isParent:A}=De(Z=>{const se=Z.nodeLookup.get(t),me=Z.parentLookup.has(t);return{node:se,internals:se.internals,isParent:me}},Qe);let $=w.type||"default",F=(b==null?void 0:b[$])||np[$];F===void 0&&(R==null||R("003",mn.error003($)),$="default",F=(b==null?void 0:b.default)||np.default);const G=!!(w.draggable||h&&typeof w.draggable>"u"),q=!!(w.selectable||p&&typeof w.selectable>"u"),te=!!(w.connectable||v&&typeof w.connectable>"u"),ee=!!(w.focusable||x&&typeof w.focusable>"u"),ne=Ye(),K=hg(w),C=yS({node:w,nodeType:$,hasDimensions:K,resizeObserver:y}),V=Bg({nodeRef:C,disabled:w.hidden||!G,noDragClassName:m,handleSelector:w.dragHandle,nodeId:t,isSelectable:q,nodeClickDistance:E}),W=Vg();if(w.hidden)return null;const U=vn(w),M=aS(w),D=q||G||r||o||s||a,H=o?Z=>o(Z,{...N.userNode}):void 0,I=s?Z=>s(Z,{...N.userNode}):void 0,z=a?Z=>a(Z,{...N.userNode}):void 0,ie=u?Z=>u(Z,{...N.userNode}):void 0,oe=c?Z=>c(Z,{...N.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:se,nodeDragThreshold:me}=ne.getState();q&&(!se||!G||me>0)&&hc({id:t,store:ne,nodeRef:C}),r&&r(Z,{...N.userNode})},he=Z=>{if(!(mg(Z.nativeEvent)||k)){if(rg.includes(Z.key)&&q){const se=Z.key==="Escape";hc({id:t,store:ne,unselect:se,nodeRef:C})}else if(G&&w.selected&&Object.prototype.hasOwnProperty.call(Vl,Z.key)){Z.preventDefault();const{ariaLabelConfig:se}=ne.getState();ne.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),W({direction:Vl[Z.key],factor:Z.shiftKey?4:1})}}},pe=()=>{var Ne;if(k||!((Ne=C.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:Z,width:se,height:me,autoPanOnNodeFocus:ke,setCenter:ve}=ne.getState();if(!ke)return;Sc(new Map([[t,w]]),{x:0,y:0,width:se,height:me},Z,!0).length>0||ve(w.position.x+U.width/2,w.position.y+U.height/2,{zoom:Z[2]})};return d.jsx("div",{className:nt(["react-flow__node",`react-flow__node-${$}`,{[_]:G},w.className,{selected:w.selected,selectable:q,parent:A,draggable:G,dragging:V}]),ref:C,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:K?"visible":"hidden",...w.style,...M},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:H,onMouseMove:I,onMouseLeave:z,onContextMenu:ie,onClick:fe,onDoubleClick:oe,onKeyDown:ee?he:void 0,tabIndex:ee?0:void 0,onFocus:ee?pe:void 0,role:w.ariaRole??(ee?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${Ag}-${j}`,"aria-label":w.ariaLabel,...w.domAttributes,children:d.jsx(Q_,{value:t,children:d.jsx(F,{id:t,data:w.data,type:$,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:w.selected??!1,selectable:q,draggable:G,deletable:w.deletable??!0,isConnectable:te,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:V,dragHandle:w.dragHandle,zIndex:N.z,parentId:w.parentId,...U})})})}var xS=L.memo(vS);const wS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Gg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=De(wS,Qe),u=pS(t.onlyRenderVisibleElements),c=mS();return d.jsx("div",{className:"react-flow__nodes",style:ra,children:u.map(h=>d.jsx(xS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Gg.displayName="NodeRenderer";const _S=L.memo(Gg);function SS(t){return De(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&g1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const kS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},NS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ip={[os.Arrow]:kS,[os.ArrowClosed]:NS};function jS(t){const r=Ye();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(ip,t)?ip[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",mn.error009(t)),null)},[t])}const bS=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=jS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},Xg=({defaultColor:t,rfId:r})=>{const o=De(u=>u.edges),s=De(u=>u.defaultEdgeOptions),a=L.useMemo(()=>k1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(bS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Xg.displayName="MarkerDefinitions";var ES=L.memo(Xg);function qg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:v,...x}){const[y,m]=L.useState({x:1,y:0,width:0,height:0}),_=nt(["react-flow__edge-textwrapper",v]),k=L.useRef(null);return L.useEffect(()=>{if(k.current){const j=k.current.getBBox();m({x:j.x,y:j.y,width:j.width,height:j.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-y.width/2} ${r-y.height/2})`,className:_,visibility:y.width?"visible":"hidden",...x,children:[a&&d.jsx("rect",{width:y.width+2*c[0],x:-c[0],y:-c[1],height:y.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:k,style:s,children:o}),p]}):null}qg.displayName="EdgeText";const CS=L.memo(qg);function ms({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:v=20,...x}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...x,d:t,fill:"none",className:nt(["react-flow__edge-path",x.className])}),v?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:v,className:"react-flow__edge-interaction"}):null,s&&pn(r)&&pn(o)?d.jsx(CS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function op({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function Kg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top}){const[c,h]=op({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,v]=op({pos:u,x1:s,y1:a,x2:t,y2:r}),[x,y,m,_]=vg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:v});return[`M${t},${r} C${c},${h} ${p},${v} ${s},${a}`,x,y,m,_]}function Qg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})=>{const[R,w,N]=Kg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),A=t.isInternal?void 0:r;return d.jsx(ms,{id:A,path:R,labelX:w,labelY:N,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})})}const MS=Qg({isInternal:!1}),Zg=Qg({isInternal:!0});MS.displayName="SimpleBezierEdge";Zg.displayName="SimpleBezierEdgeInternal";function Jg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,sourcePosition:_=Se.Bottom,targetPosition:k=Se.Top,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=Bl({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),$=t.isInternal?void 0:r;return d.jsx(ms,{id:$,path:w,labelX:N,labelY:A,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:j,markerStart:b,interactionWidth:R})})}const em=Jg({isInternal:!1}),tm=Jg({isInternal:!0});em.displayName="SmoothStepEdge";tm.displayName="SmoothStepEdgeInternal";function nm(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(em,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const PS=nm({isInternal:!1}),rm=nm({isInternal:!0});PS.displayName="StepEdge";rm.displayName="StepEdgeInternal";function im(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:j})=>{const[b,E,R]=_g({sourceX:o,sourceY:s,targetX:a,targetY:u}),w=t.isInternal?void 0:r;return d.jsx(ms,{id:w,path:b,labelX:E,labelY:R,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:j})})}const IS=im({isInternal:!1}),om=im({isInternal:!0});IS.displayName="StraightEdge";om.displayName="StraightEdgeInternal";function sm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=xg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:E==null?void 0:E.curvature}),$=t.isInternal?void 0:r;return d.jsx(ms,{id:$,path:w,labelX:N,labelY:A,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:R})})}const RS=sm({isInternal:!1}),lm=sm({isInternal:!0});RS.displayName="BezierEdge";lm.displayName="BezierEdgeInternal";const sp={default:lm,straight:om,step:rm,smoothstep:tm,simplebezier:Zg},lp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},TS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,LS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,ap="react-flow__edgeupdater";function up({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:nt([ap,`${ap}-${h}`]),cx:TS(r,s,t),cy:LS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function AS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:v,onReconnectStart:x,onReconnectEnd:y,setReconnecting:m,setUpdateHover:_}){const k=Ye(),j=(N,A)=>{if(N.button!==0)return;const{autoPanOnConnect:$,domNode:F,connectionMode:G,connectionRadius:q,lib:te,onConnectStart:ee,cancelConnection:ne,nodeLookup:K,rfId:C,panBy:V,updateConnection:W}=k.getState(),U=A.type==="target",M=(I,z)=>{m(!1),y==null||y(I,o,A.type,z)},D=I=>v==null?void 0:v(o,I),H=(I,z)=>{m(!0),x==null||x(N,o,A.type),ee==null||ee(I,z)};fc.onPointerDown(N.nativeEvent,{autoPanOnConnect:$,connectionMode:G,connectionRadius:q,domNode:F,handleId:A.id,nodeId:A.nodeId,nodeLookup:K,isTarget:U,edgeUpdaterType:A.type,lib:te,flowId:C,cancelConnection:ne,panBy:V,isValidConnection:(...I)=>{var z,ie;return((ie=(z=k.getState()).isValidConnection)==null?void 0:ie.call(z,...I))??!0},onConnect:D,onConnectStart:H,onConnectEnd:(...I)=>{var z,ie;return(ie=(z=k.getState()).onConnectEnd)==null?void 0:ie.call(z,...I)},onReconnectEnd:M,updateConnection:W,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:N.currentTarget})},b=N=>j(N,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),E=N=>j(N,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),R=()=>_(!0),w=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(up,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:b,onMouseEnter:R,onMouseOut:w,type:"source"}),(t===!0||t==="target")&&d.jsx(up,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:E,onMouseEnter:R,onMouseOut:w,type:"target"})]})}function $S({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,rfId:k,edgeTypes:j,noPanClassName:b,onError:E,disableKeyboardA11y:R}){let w=De(ve=>ve.edgeLookup.get(t));const N=De(ve=>ve.defaultEdgeOptions);w=N?{...N,...w}:w;let A=w.type||"default",$=(j==null?void 0:j[A])||sp[A];$===void 0&&(E==null||E("011",mn.error011(A)),A="default",$=(j==null?void 0:j.default)||sp.default);const F=!!(w.focusable||r&&typeof w.focusable>"u"),G=typeof y<"u"&&(w.reconnectable||o&&typeof w.reconnectable>"u"),q=!!(w.selectable||s&&typeof w.selectable>"u"),te=L.useRef(null),[ee,ne]=L.useState(!1),[K,C]=L.useState(!1),V=Ye(),{zIndex:W=w.zIndex,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z}=De(L.useCallback(ve=>{const re=ve.nodeLookup.get(w.source),Ne=ve.nodeLookup.get(w.target);if(!re||!Ne)return lp;const Me=S1({id:t,sourceNode:re,targetNode:Ne,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:ve.connectionMode,onError:E}),Te=p1({selected:w.selected,zIndex:w.zIndex,sourceNode:re,targetNode:Ne,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||lp,zIndex:Te}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex,E]),Qe),ie=L.useMemo(()=>w.markerStart?`url('#${cc(w.markerStart,k)}')`:void 0,[w.markerStart,k]),oe=L.useMemo(()=>w.markerEnd?`url('#${cc(w.markerEnd,k)}')`:void 0,[w.markerEnd,k]);if(w.hidden||U===null||M===null||D===null||H===null)return null;const fe=ve=>{var Te;const{addSelectedEdges:re,unselectNodesAndEdges:Ne,multiSelectionActive:Me}=V.getState();q&&(V.setState({nodesSelectionActive:!1}),w.selected&&Me?(Ne({nodes:[],edges:[w]}),(Te=te.current)==null||Te.blur()):re([t])),a&&a(ve,w)},he=u?ve=>{u(ve,{...w})}:void 0,pe=c?ve=>{c(ve,{...w})}:void 0,Z=h?ve=>{h(ve,{...w})}:void 0,se=p?ve=>{p(ve,{...w})}:void 0,me=v?ve=>{v(ve,{...w})}:void 0,ke=ve=>{var re;if(!R&&rg.includes(ve.key)&&q){const{unselectNodesAndEdges:Ne,addSelectedEdges:Me}=V.getState();ve.key==="Escape"?((re=te.current)==null||re.blur(),Ne({edges:[w]})):Me([t])}};return d.jsx("svg",{style:{zIndex:W},children:d.jsxs("g",{className:nt(["react-flow__edge",`react-flow__edge-${A}`,w.className,b,{selected:w.selected,animated:w.animated,inactive:!q&&!a,updating:ee,selectable:q}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:Z,onMouseMove:se,onMouseLeave:me,onKeyDown:F?ke:void 0,tabIndex:F?0:void 0,role:w.ariaRole??(F?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":F?`${$g}-${k}`:void 0,ref:te,...w.domAttributes,children:[!K&&d.jsx($,{id:t,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:q,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),G&&d.jsx(AS,{edge:w,isReconnectable:G,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,setUpdateHover:ne,setReconnecting:C})]})})}var zS=L.memo($S);const DS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function am({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:v,onEdgeClick:x,reconnectRadius:y,onEdgeDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:j}){const{edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,onError:w}=De(DS,Qe),N=SS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(ES,{defaultColor:t,rfId:o}),N.map(A=>d.jsx(zS,{id:A,edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,onClick:x,reconnectRadius:y,onDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:w,edgeTypes:s,disableKeyboardA11y:j},A))]})}am.displayName="EdgeRenderer";const OS=L.memo(am),cp=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function FS({children:t}){const r=Ye(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return Fg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=cp(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:cp(s)},children:t})}function HS(t){const r=na(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const BS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function VS(t){const r=De(BS),o=Ye();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function WS(t){return t.connection.inProgress?{...t.connection,to:gs(t.connection.to,t.transform)}:{...t.connection}}function US(t){return WS}function YS(t){const r=US();return De(r,Qe)}const GS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function XS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=De(GS,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:nt(["react-flow__connection",sg(h)]),children:d.jsx(um,{style:r,type:o,CustomComponent:s,isValid:h})})})}const um=({style:t,type:r=Lr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:v,toNode:x,toHandle:y,toPosition:m,pointer:_}=YS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:v.x,toY:v.y,fromPosition:p,toPosition:m,connectionStatus:sg(s),toNode:x,toHandle:y,pointer:_});let k="";const j={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:v.x,targetY:v.y,targetPosition:m};switch(r){case Lr.Bezier:[k]=xg(j);break;case Lr.SimpleBezier:[k]=Kg(j);break;case Lr.Step:[k]=Bl({...j,borderRadius:0});break;case Lr.SmoothStep:[k]=Bl(j);break;default:[k]=_g(j)}return d.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};um.displayName="ConnectionLine";const qS={};function dp(t=qS){L.useRef(t),Ye(),L.useEffect(()=>{},[t])}function KS(){Ye(),L.useRef(!1),L.useEffect(()=>{},[])}function cm({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,onSelectionContextMenu:y,onSelectionStart:m,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:j,connectionLineComponent:b,connectionLineContainerStyle:E,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,deleteKeyCode:G,onlyRenderVisibleElements:q,elementsSelectable:te,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,preventScrolling:V,defaultMarkerColor:W,zoomOnScroll:U,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,zoomOnDoubleClick:z,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneScroll:se,onPaneContextMenu:me,paneClickDistance:ke,nodeClickDistance:ve,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,viewport:ut,onViewportChange:Je,nodesDraggable:An}){return dp(t),dp(r),KS(),HS(o),VS(ut),d.jsx(fS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneContextMenu:me,onPaneScroll:se,paneClickDistance:ke,deleteKeyCode:G,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,elementsSelectable:te,zoomOnScroll:U,zoomOnPinch:M,zoomOnDoubleClick:z,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,onSelectionContextMenu:y,preventScrolling:V,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,onViewportChange:Je,isControlledViewport:!!ut,children:d.jsxs(FS,{children:[d.jsx(OS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,onlyRenderVisibleElements:q,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,defaultMarkerColor:W,noPanClassName:qt,disableKeyboardA11y:gt,rfId:Pt}),d.jsx(XS,{style:j,type:k,component:b,containerStyle:E}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(_S,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,nodeClickDistance:ve,onlyRenderVisibleElements:q,noPanClassName:qt,noDragClassName:Ge,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,nodesDraggable:An}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}cm.displayName="GraphView";const QS=L.memo(cm),ZS=fg(),fp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:v=2,nodeOrigin:x,nodeExtent:y,zIndexMode:m="basic"}={})=>{const _=new Map,k=new Map,j=new Map,b=new Map,E=s??r??[],R=o??t??[],w=x??[0,0],N=y??rs;Ng(j,b,E);const{nodesInitialized:A}=dc(R,_,k,{nodeOrigin:w,nodeExtent:N,zIndexMode:m});let $=[0,0,1];if(c&&a&&u){const F=hs(_,{filter:ee=>!!((ee.width||ee.initialWidth)&&(ee.height||ee.initialHeight))}),{x:G,y:q,zoom:te}=Nc(F,a,u,p,v,(h==null?void 0:h.padding)??.1);$=[G,q,te]}return{rfId:"1",width:a??0,height:u??0,transform:$,nodes:R,nodesInitialized:A,nodeLookup:_,parentLookup:k,edges:E,edgeLookup:b,connectionLookup:j,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:v,translateExtent:rs,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Zi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...og},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:ZS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:ig,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},JS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m})=>d_((_,k)=>{async function j(){const{nodeLookup:b,panZoom:E,fitViewOptions:R,fitViewResolver:w,width:N,height:A,minZoom:$,maxZoom:F}=k();E&&(await l1({nodes:b,width:N,height:A,panZoom:E,minZoom:$,maxZoom:F},R),w==null||w.resolve(!0),_({fitViewResolver:null}))}return{...fp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,defaultNodes:o,defaultEdges:s,zIndexMode:m}),setNodes:b=>{const{nodeLookup:E,parentLookup:R,nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,fitViewQueued:$,zIndexMode:F,nodesSelectionActive:G}=k(),{nodesInitialized:q,hasSelectedNodes:te}=dc(b,E,R,{nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:F}),ee=G&&te;$&&q?(j(),_({nodes:b,nodesInitialized:q,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:ee})):_({nodes:b,nodesInitialized:q,nodesSelectionActive:ee})},setEdges:b=>{const{connectionLookup:E,edgeLookup:R}=k();Ng(E,R,b),_({edges:b})},setDefaultNodesAndEdges:(b,E)=>{if(b){const{setNodes:R}=k();R(b),_({hasDefaultNodes:!0})}if(E){const{setEdges:R}=k();R(E),_({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:E,nodeLookup:R,parentLookup:w,domNode:N,nodeOrigin:A,nodeExtent:$,debug:F,fitViewQueued:G,zIndexMode:q}=k(),{changes:te,updatedInternals:ee}=P1(b,R,w,N,A,$,q);ee&&(b1(R,w,{nodeOrigin:A,nodeExtent:$,zIndexMode:q}),G?(j(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(te==null?void 0:te.length)>0&&(F&&console.log("React Flow: trigger node changes",te),E==null||E(te)))},updateNodePositions:(b,E=!1)=>{const R=[];let w=[];const{nodeLookup:N,triggerNodeChanges:A,connection:$,updateConnection:F,onNodesChangeMiddlewareMap:G}=k();for(const[q,te]of b){const ee=N.get(q),ne=!!(ee!=null&&ee.expandParent&&(ee!=null&&ee.parentId)&&(te!=null&&te.position)),K={id:q,type:"position",position:ne?{x:Math.max(0,te.position.x),y:Math.max(0,te.position.y)}:te.position,dragging:E};if(ee&&$.inProgress&&$.fromNode.id===ee.id){const C=mi(ee,$.fromHandle,Se.Left,!0);F({...$,from:C})}ne&&ee.parentId&&R.push({id:q,parentId:ee.parentId,rect:{...te.internals.positionAbsolute,width:te.measured.width??0,height:te.measured.height??0}}),w.push(K)}if(R.length>0){const{parentLookup:q,nodeOrigin:te}=k(),ee=Pc(R,N,q,te);w.push(...ee)}for(const q of G.values())w=q(w);A(w)},triggerNodeChanges:b=>{const{onNodesChange:E,setNodes:R,nodes:w,hasDefaultNodes:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=R_(b,w);R($)}A&&console.log("React Flow: trigger node changes",b),E==null||E(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:E,setEdges:R,edges:w,hasDefaultEdges:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=T_(b,w);R($)}A&&console.log("React Flow: trigger edge changes",b),E==null||E(b)}},addSelectedNodes:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));N($);return}N(Gi(w,new Set([...b]),!0)),A(Gi(R))},addSelectedEdges:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));A($);return}A(Gi(R,new Set([...b]))),N(Gi(w,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:E}={})=>{const{edges:R,nodes:w,nodeLookup:N,triggerNodeChanges:A,triggerEdgeChanges:$}=k(),F=b||w,G=E||R,q=[];for(const ee of F){if(!ee.selected)continue;const ne=N.get(ee.id);ne&&(ne.selected=!1),q.push(ai(ee.id,!1))}const te=[];for(const ee of G)ee.selected&&te.push(ai(ee.id,!1));A(q),$(te)},setMinZoom:b=>{const{panZoom:E,maxZoom:R}=k();E==null||E.setScaleExtent([b,R]),_({minZoom:b})},setMaxZoom:b=>{const{panZoom:E,minZoom:R}=k();E==null||E.setScaleExtent([R,b]),_({maxZoom:b})},setTranslateExtent:b=>{var E;(E=k().panZoom)==null||E.setTranslateExtent(b),_({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:E,triggerNodeChanges:R,triggerEdgeChanges:w,elementsSelectable:N}=k();if(!N)return;const A=E.reduce((F,G)=>G.selected?[...F,ai(G.id,!1)]:F,[]),$=b.reduce((F,G)=>G.selected?[...F,ai(G.id,!1)]:F,[]);R(A),w($)},setNodeExtent:b=>{const{nodes:E,nodeLookup:R,parentLookup:w,nodeOrigin:N,elevateNodesOnSelect:A,nodeExtent:$,zIndexMode:F}=k();b[0][0]===$[0][0]&&b[0][1]===$[0][1]&&b[1][0]===$[1][0]&&b[1][1]===$[1][1]||(dc(E,R,w,{nodeOrigin:N,nodeExtent:b,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:F}),_({nodeExtent:b}))},panBy:b=>{const{transform:E,width:R,height:w,panZoom:N,translateExtent:A}=k();return I1({delta:b,panZoom:N,transform:E,translateExtent:A,width:R,height:w})},setCenter:async(b,E,R)=>{const{width:w,height:N,maxZoom:A,panZoom:$}=k();if(!$)return!1;const F=typeof(R==null?void 0:R.zoom)<"u"?R.zoom:A;return await $.setViewport({x:w/2-b*F,y:N/2-E*F,zoom:F},{duration:R==null?void 0:R.duration,ease:R==null?void 0:R.ease,interpolate:R==null?void 0:R.interpolate}),!0},cancelConnection:()=>{_({connection:{...og}})},updateConnection:b=>{_({connection:b})},reset:()=>_({...fp()})}},Object.is);function dm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m,children:_}){const[k]=L.useState(()=>JS({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:v,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:x,nodeExtent:y,zIndexMode:m}));return d.jsx(f_,{value:k,children:d.jsx(D_,{children:d.jsx(J_,{children:_})})})}function ek({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:v,maxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_}){return L.useContext(ea)?d.jsx(d.Fragment,{children:t}):d.jsx(dm,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:v,initialMaxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_,children:t})}const tk={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function nk({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:v,onMove:x,onMoveStart:y,onMoveEnd:m,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,onNodeDragStart:F,onNodeDrag:G,onNodeDragStop:q,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onSelectionChange:K,onSelectionDragStart:C,onSelectionDrag:V,onSelectionDragStop:W,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:H,connectionMode:I,connectionLineType:z=Lr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:Z=!1,selectionMode:se=is.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:ke=ls()?"Meta":"Control",zoomActivationKeyCode:ve=ls()?"Meta":"Control",snapToGrid:re,snapGrid:Ne,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Te,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,nodeOrigin:Ge=zg,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt=!0,defaultViewport:mt=j_,minZoom:Pt=.5,maxZoom:ut=2,translateExtent:Je=rs,preventScrolling:An=!0,nodeExtent:Ot,defaultMarkerColor:xn="#b1b1b7",zoomOnScroll:oo=!0,zoomOnPinch:$n=!0,panOnScroll:vi=!1,panOnScrollSpeed:or=.5,panOnScrollMode:$r=di.Free,zoomOnDoubleClick:zn=!0,panOnDrag:zr=!0,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn=1,nodeClickDistance:Fn=0,children:_n,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn=10,onNodesChange:Ht,onEdgesChange:Or,noDragClassName:nn="nodrag",noWheelClassName:Fr="nowheel",noPanClassName:yt="nopan",fitView:Hn,fitViewOptions:ur,connectOnClick:so,attributionPosition:It,proOptions:Bn,defaultEdgeOptions:Hr,elevateNodesOnSelect:jn=!0,elevateEdgesOnSelect:Br=!1,disableKeyboardA11y:xi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:lo,autoPanOnSelection:Vr=!0,autoPanSpeed:wi,connectionRadius:cr,isValidConnection:ao,onError:dr,style:Vn,id:bt,nodeDragThreshold:Wr,connectionDragThreshold:Et,viewport:uo,onViewportChange:Ur,width:Yr,height:Wn,colorMode:Un="light",debug:bn,onScroll:Bt,ariaLabelConfig:_i,zIndexMode:Gr="basic",...fr},hr){const Yn=bt||"1",En=M_(Un),co=L.useCallback(pr=>{pr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Bt==null||Bt(pr)},[Bt]);return d.jsx("div",{"data-testid":"rf__wrapper",...fr,onScroll:co,style:{...Vn,...tk},ref:hr,className:nt(["react-flow",a,En]),id:bt,role:"application",children:d.jsxs(ek,{nodes:t,edges:r,width:Yr,height:Wn,fitView:Hn,fitViewOptions:ur,minZoom:Pt,maxZoom:ut,nodeOrigin:Ge,nodeExtent:Ot,zIndexMode:Gr,children:[d.jsx(C_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt,elevateNodesOnSelect:jn,elevateEdgesOnSelect:Br,minZoom:Pt,maxZoom:ut,nodeExtent:Ot,onNodesChange:Ht,onEdgesChange:Or,snapToGrid:re,snapGrid:Ne,connectionMode:I,translateExtent:Je,connectOnClick:so,defaultEdgeOptions:Hr,fitView:Hn,fitViewOptions:ur,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onNodeDragStart:F,onNodeDrag:G,onNodeDragStop:q,onSelectionDrag:V,onSelectionDragStart:C,onSelectionDragStop:W,onMove:x,onMoveStart:y,onMoveEnd:m,noPanClassName:yt,nodeOrigin:Ge,rfId:Yn,autoPanOnConnect:Ve,autoPanOnNodeDrag:lo,autoPanSpeed:wi,onError:dr,connectionRadius:cr,isValidConnection:ao,selectNodesOnDrag:Te,nodeDragThreshold:Wr,connectionDragThreshold:Et,onBeforeDelete:H,debug:bn,ariaLabelConfig:_i,zIndexMode:Gr}),d.jsx(QS,{onInit:v,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,nodeTypes:u,edgeTypes:c,connectionLineType:z,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:Z,selectionMode:se,deleteKeyCode:he,multiSelectionKeyCode:ke,panActivationKeyCode:me,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:mt,translateExtent:Je,minZoom:Pt,maxZoom:ut,preventScrolling:An,zoomOnScroll:oo,zoomOnPinch:$n,zoomOnDoubleClick:zn,panOnScroll:vi,panOnScrollSpeed:or,panOnScrollMode:$r,panOnDrag:zr,autoPanOnSelection:Vr,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn,nodeClickDistance:Fn,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn,defaultMarkerColor:xn,noDragClassName:nn,noWheelClassName:Fr,noPanClassName:yt,rfId:Yn,disableKeyboardA11y:xi,nodeExtent:Ot,viewport:uo,onViewportChange:Ur,nodesDraggable:$e}),d.jsx(N_,{onSelectionChange:K}),_n,d.jsx(x_,{proOptions:Bn,position:It}),d.jsx(v_,{rfId:Yn,disableKeyboardA11y:xi})]})})}var rk=Og(nk);function ik({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:nt(["react-flow__background-pattern",o,s])})}function ok({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:nt(["react-flow__background-pattern","dots",r])})}var Ar;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Ar||(Ar={}));const sk={[Ar.Dots]:1,[Ar.Lines]:1,[Ar.Cross]:6},lk=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function fm({id:t,variant:r=Ar.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:v,patternClassName:x}){const y=L.useRef(null),{transform:m,patternId:_}=De(lk,Qe),k=s||sk[r],j=r===Ar.Dots,b=r===Ar.Cross,E=Array.isArray(o)?o:[o,o],R=[E[0]*m[2]||1,E[1]*m[2]||1],w=k*m[2],N=Array.isArray(u)?u:[u,u],A=b?[w,w]:R,$=[N[0]*m[2]+A[0]/2,N[1]*m[2]+A[1]/2],F=`${_}${t||""}`;return d.jsxs("svg",{className:nt(["react-flow__background",v]),style:{...p,...ra,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:y,"data-testid":"rf__background",children:[d.jsx("pattern",{id:F,x:m[0]%R[0],y:m[1]%R[1],width:R[0],height:R[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:j?d.jsx(ok,{radius:w/2,className:x}):d.jsx(ik,{dimensions:A,lineWidth:a,variant:r,className:x})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${F})`})]})}fm.displayName="Background";const ak=L.memo(fm);function uk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ck(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 fk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 hk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 jl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:nt(["react-flow__controls-button",r]),...o,children:t})}const pk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function hm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:v,children:x,position:y="bottom-left",orientation:m="vertical","aria-label":_}){const k=Ye(),{isInteractive:j,minZoomReached:b,maxZoomReached:E,ariaLabelConfig:R}=De(pk,Qe),{zoomIn:w,zoomOut:N,fitView:A}=na(),$=()=>{w(),u==null||u()},F=()=>{N(),c==null||c()},G=()=>{A(a),h==null||h()},q=()=>{k.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),p==null||p(!j)},te=m==="horizontal"?"horizontal":"vertical";return d.jsxs(ta,{className:nt(["react-flow__controls",te,v]),position:y,style:t,"data-testid":"rf__controls","aria-label":_??R["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(jl,{onClick:$,className:"react-flow__controls-zoomin",title:R["controls.zoomIn.ariaLabel"],"aria-label":R["controls.zoomIn.ariaLabel"],disabled:E,children:d.jsx(uk,{})}),d.jsx(jl,{onClick:F,className:"react-flow__controls-zoomout",title:R["controls.zoomOut.ariaLabel"],"aria-label":R["controls.zoomOut.ariaLabel"],disabled:b,children:d.jsx(ck,{})})]}),o&&d.jsx(jl,{className:"react-flow__controls-fitview",onClick:G,title:R["controls.fitView.ariaLabel"],"aria-label":R["controls.fitView.ariaLabel"],children:d.jsx(dk,{})}),s&&d.jsx(jl,{className:"react-flow__controls-interactive",onClick:q,title:R["controls.interactive.ariaLabel"],"aria-label":R["controls.interactive.ariaLabel"],children:j?d.jsx(hk,{}):d.jsx(fk,{})}),x]})}hm.displayName="Controls";const gk=L.memo(hm);function mk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:v,borderRadius:x,shapeRendering:y,selected:m,onClick:_}){const{background:k,backgroundColor:j}=u||{},b=c||k||j;return d.jsx("rect",{className:nt(["react-flow__minimap-node",{selected:m},v]),x:r,y:o,rx:x,ry:x,width:s,height:a,style:{fill:b,stroke:h,strokeWidth:p},shapeRendering:y,onClick:_?E=>_(E,t):void 0})}const yk=L.memo(mk),vk=t=>t.nodes.map(r=>r.id),Ku=t=>t instanceof Function?t:()=>t;function xk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=yk,onClick:c}){const h=De(vk,Qe),p=Ku(r),v=Ku(t),x=Ku(o),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(m=>d.jsx(_k,{id:m,nodeColorFunc:p,nodeStrokeColorFunc:v,nodeClassNameFunc:x,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:y},m))})}function wk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:v,x,y,width:m,height:_}=De(k=>{const j=k.nodeLookup.get(t);if(!j)return{node:void 0,x:0,y:0,width:0,height:0};const b=j.internals.userNode,{x:E,y:R}=j.internals.positionAbsolute,{width:w,height:N}=vn(b);return{node:b,x:E,y:R,width:w,height:N}},Qe);return!v||v.hidden||!hg(v)?null:d.jsx(h,{x,y,width:m,height:_,style:v.style,selected:!!v.selected,className:s(v),color:r(v),borderRadius:a,strokeColor:o(v),strokeWidth:u,shapeRendering:c,onClick:p,id:v.id})}const _k=L.memo(wk);var Sk=L.memo(xk);const kk=200,Nk=150,jk=t=>!t.hidden,bk=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?cg(hs(t.nodeLookup,{filter:jk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},hp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,Ek=(t,r)=>hp(t.viewBB,r.viewBB)&&hp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,Ck="react-flow__minimap-desc";function pm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:v,maskStrokeColor:x,maskStrokeWidth:y,position:m="bottom-right",onClick:_,onNodeClick:k,pannable:j=!1,zoomable:b=!1,ariaLabel:E,inversePan:R,zoomStep:w=1,offsetScale:N=5}){const A=Ye(),$=L.useRef(null),{boundingRect:F,viewBB:G,rfId:q,panZoom:te,translateExtent:ee,flowWidth:ne,flowHeight:K,ariaLabelConfig:C}=De(bk,Ek),V=(t==null?void 0:t.width)??kk,W=(t==null?void 0:t.height)??Nk,U=F.width/V,M=F.height/W,D=Math.max(U,M),H=D*V,I=D*W,z=N*D,ie=F.x-(H-F.width)/2-z,oe=F.y-(I-F.height)/2-z,fe=H+z*2,he=I+z*2,pe=`${Ck}-${q}`,Z=L.useRef(0),se=L.useRef();Z.current=D,L.useEffect(()=>{if($.current&&te)return se.current=F1({domNode:$.current,panZoom:te,getTransform:()=>A.getState().transform,getViewScale:()=>Z.current}),()=>{var re;(re=se.current)==null||re.destroy()}},[te]),L.useEffect(()=>{var re;(re=se.current)==null||re.update({translateExtent:ee,width:ne,height:K,inversePan:R,pannable:j,zoomStep:w,zoomable:b})},[j,b,R,w,ee,ne,K]);const me=_?re=>{var Te;const[Ne,Me]=((Te=se.current)==null?void 0:Te.pointer(re))||[0,0];_(re,{x:Ne,y:Me})}:void 0,ke=k?L.useCallback((re,Ne)=>{const Me=A.getState().nodeLookup.get(Ne).internals.userNode;k(re,Me)},[]):void 0,ve=E??C["minimap.ariaLabel"];return d.jsx(ta,{position:m,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof v=="string"?v:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof y=="number"?y*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:nt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:V,height:W,viewBox:`${ie} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:$,onClick:me,children:[ve&&d.jsx("title",{id:pe,children:ve}),d.jsx(Sk,{onClick:ke,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-z},${oe-z}h${fe+z*2}v${he+z*2}h${-fe-z*2}z + M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}pm.displayName="MiniMap";const Mk=L.memo(pm),Pk=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Ik={[to.Line]:"right",[to.Handle]:"bottom-right"};function Rk({nodeId:t,position:r,variant:o=to.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:v=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:y=!1,resizeDirection:m,autoScale:_=!0,shouldResize:k,onResizeStart:j,onResize:b,onResizeEnd:E}){const R=Wg(),w=typeof t=="string"?t:R,N=Ye(),A=L.useRef(null),$=o===to.Handle,F=De(L.useCallback(Pk($&&_),[$,_]),Qe),G=L.useRef(null),q=r??Ik[o];L.useEffect(()=>{if(!(!A.current||!w))return G.current||(G.current=J1({domNode:A.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,domNode:W}=N.getState();return{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,paneDomNode:W}},onChange:(ee,ne)=>{const{triggerNodeChanges:K,nodeLookup:C,parentLookup:V,nodeOrigin:W}=N.getState(),U=[],M={x:ee.x,y:ee.y},D=C.get(w);if(D&&D.expandParent&&D.parentId){const H=D.origin??W,I=ee.width??D.measured.width??0,z=ee.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:I,height:z,...pg({x:ee.x??D.position.x,y:ee.y??D.position.y},{width:I,height:z},D.parentId,C,H)}},oe=Pc([ie],C,V,W);U.push(...oe),M.x=ee.x?Math.max(H[0]*I,ee.x):void 0,M.y=ee.y?Math.max(H[1]*z,ee.y):void 0}if(M.x!==void 0&&M.y!==void 0){const H={id:w,type:"position",position:{...M}};U.push(H)}if(ee.width!==void 0&&ee.height!==void 0){const I={id:w,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:ee.width,height:ee.height}};U.push(I)}for(const H of ne){const I={...H,type:"position"};U.push(I)}K(U)},onEnd:({width:ee,height:ne})=>{const K={id:w,type:"dimensions",resizing:!1,dimensions:{width:ee,height:ne}};N.getState().triggerNodeChanges([K])}})),G.current.update({controlPosition:q,boundaries:{minWidth:h,minHeight:p,maxWidth:v,maxHeight:x},keepAspectRatio:y,resizeDirection:m,onResizeStart:j,onResize:b,onResizeEnd:E,shouldResize:k}),()=>{var ee;(ee=G.current)==null||ee.destroy()}},[q,h,p,v,x,y,j,b,E,k]);const te=q.split("-");return d.jsx("div",{className:nt(["react-flow__resize-control","nodrag",...te,o,s]),ref:A,style:{...a,scale:F,...c&&{[$?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Rk);const Tk={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function ia(t){return Tk[t]??8}const Wl=208,ro=64,Lk=88,Ak=28,$k=8;function zk(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function gm(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const w of t){const N=ia(w.type),A=s.get(N)??[];A.push(w),s.set(N,A)}const u=[...s.keys()].sort((w,N)=>w-N).map(w=>[...s.get(w)??[]].sort((N,A)=>N.name.localeCompare(A.name)||N.id.localeCompare(A.id))),c=new Set(t.map(w=>w.id)),h=new Map,p=new Map;for(const w of t)h.set(w.id,[]),p.set(w.id,[]);for(const w of r)!c.has(w.src)||!c.has(w.dst)||w.src===w.dst||(p.get(w.src).push(w.dst),h.get(w.dst).push(w.src));const v=new Map;u.forEach((w,N)=>{for(const A of w)v.set(A.id,N)});const x=new Map,y=()=>{for(const w of u)w.forEach((N,A)=>x.set(N.id,A))};y();const m=(w,N)=>{const A=w.map(($,F)=>{const G=N($.id).map(te=>x.get(te)).filter(te=>te!==void 0),q=zk(G);return{n:$,bary:Number.isNaN(q)?F:q,name:$.name,id:$.id}});return A.sort(($,F)=>$.bary-F.bary||$.name.localeCompare(F.name)||$.id.localeCompare(F.id)),A.map($=>$.n)},_=w=>N=>v.get(N)===w;for(let w=0;w<$k;w++){for(let N=1;N(h.get(A)??[]).filter(_(N-1))),y();for(let N=u.length-2;N>=0;N--)u[N]=m(u[N],A=>(p.get(A)??[]).filter(_(N+1))),y()}const k=Wl+Lk,j=ro+Ak,b=Math.max(...u.map(w=>w.length),1),E=[];let R=0;for(let w=0;wG.id)),A=new Set((u[w+1]??[]).map(G=>G.id));let $=0;if(A.size)for(const G of r)N.has(G.src)&&A.has(G.dst)&&($+=1);const F=Math.min(48,Math.max(0,($-2)*10));R+=k+F}return u.forEach((w,N)=>{const A=(b-w.length)*j/2;w.forEach(($,F)=>{o.set($.id,{x:E[N]??0,y:A+F*j})})}),o}const Dk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),mm=90,Ok=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),pp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Fk=Math.PI*(3-Math.sqrt(5)),ym=220,Hk=26,Bk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function vm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function BN(t){return pp[t]?pp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Vk(t){return t>=mm?"3d":"2d"}function Wk(t){return t>=mm?"overview":"full"}function Uk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(vm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Ok.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Uk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Gk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function Xk(t,r,o,s){const a=new Set(t.map(j=>j.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const j of r){if(!a.has(j.src)||!a.has(j.dst))continue;const b=u.get(j.src)??[];b.push({dst:j.dst,id:j.id}),u.set(j.src,b);const E=c.get(j.dst)??[];E.push({src:j.src,id:j.id}),c.set(j.dst,E)}const h=new Set(t.filter(j=>Dk.has(j.type)).map(j=>j.id)),p=h.size?h:a,v=new Set,x=[o];for(;x.length;){const j=x.pop();if(!v.has(j)){v.add(j);for(const b of u.get(j)??[])v.has(b.dst)||x.push(b.dst)}}const y=new Set([o]),m=[...p].filter(j=>v.has(j)),_=new Set(m);for(;m.length;){const j=m.pop();y.add(j);for(const b of c.get(j)??[])v.has(b.src)&&!_.has(b.src)&&(_.add(b.src),m.push(b.src))}const k=new Set;for(const j of r)y.has(j.src)&&y.has(j.dst)&&k.add(j.id);return{nodeIds:y,edgeIds:k}}function VN(t){const r=new Map;for(const s of t){const a=ia(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*ym;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Hk*Math.sqrt(h+1),v=h*Fk;o.set(c.id,{x:u,y:p*Math.cos(v),z:p*Math.sin(v)})})}return o}function WN(t){const r=new Map;for(const o of t){const s=ia(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*ym,count:s}))}const bl=16,qk=12,Kk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Qk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),gp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Zk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},mp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],yp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Jk=new Set(["looks_idempotent_on_pk","null","blank"]),eN=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function tN(t){return gp[t]?gp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function nN(t,r,o){const s=new Map(r.map(m=>[m.id,m])),a=[];Kk.has(t.type)&&a.push("sink"),Qk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(m=>m.dst===t.id),h=o.filter(m=>m.src===t.id),p=c.slice(0,bl).map(m=>El(m,s,m.src)),v=h.slice(0,bl).map(m=>El(m,s,m.dst)),x=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,y={type:t.type,typeLabel:Zo(io(t.type)),layer:Bk[ia(t.type)]??"other",purpose:tN(t.type),name:t.name,qualifiedName:t.qualified_name,file:x,context:t.context,roles:a,facts:iN(u).filter(m=>!(m.key==="app"&&m.value===t.context)),inputs:p,outputs:v,extraInputs:Math.max(0,c.length-bl),extraOutputs:Math.max(0,h.length-bl),degreeIn:c.length,degreeOut:h.length,inputKinds:vp(c.map(m=>El(m,s,m.src))),outputKinds:vp(h.map(m=>El(m,s,m.dst))),pathSummary:""};return y.pathSummary=rN(y),y}function vp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function rN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function El(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Zo(io(s.type)):"",edgeType:t.type,edgeLabel:Zo(t.type),inferred:t.confidence<.8}}function iN(t){const r=[...mp.filter(a=>a in t),...Object.keys(t).filter(a=>!mp.includes(a)&&!yp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||yp.has(a)||eN.has(a))continue;s.add(a);const u=oN(a,t[a]);u!=null&&o.push({key:a,label:Zk[a]??Zo(a),value:u})}return o}function oN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Jk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return sN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,qk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function sN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const lN=12,xp=.2,aN=.8,uN=ro;function cN(t,r,o){const s=o??gm(t,r),a=[];for(const h of r){const p=s.get(h.src),v=s.get(h.dst);if(!p||!v)continue;const x=p.y+ro/2,y=v.y+ro/2;if(Math.abs(x-y)${Math.round(_/8)}`})}const u=new Map;for(const h of a){const p=u.get(h.corridor)??[];p.push(h),u.set(h.corridor,p)}const c=new Map;for(const h of u.values()){const p=[...h].sort((y,m)=>y.y0-m.y0||y.y1-m.y1||y.id.localeCompare(m.id)),v=dN(p),x=Math.max(0,...v.values())+1;for(const y of p)c.set(y.id,fN(v.get(y.id)??0,x))}return c}function dN(t){const r=[],o=new Map;for(const s of t){let a=-1;for(let u=0;ur[u]+uN){a=u;break}a<0?(a=r.length,r.push(s.y1)):r[a]=Math.max(r[a],s.y1),o.set(s.id,a)}return o}function fN(t,r){return r<=1?.5:xp+(aN-xp)*t/(r-1)}const hN=new Set,pN=L.lazy(()=>k0(()=>import("./LayeredGraph3D-BSASMssr.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),gN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function mN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(no,{type:"target",position:Se.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:io(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Tr(t.name)}),d.jsx(no,{type:"source",position:Se.Right,isConnectable:!1})]})}const yN={load:mN},vN=new Set(["django","react","stitch","arch"]);function xN({id:t,sourceX:r,sourceY:o,targetX:s,targetY:a,sourcePosition:u,targetPosition:c,style:h,markerEnd:p,markerStart:v,label:x,labelStyle:y,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,data:b,interactionWidth:E}){const[R,w,N]=Bl({sourceX:r,sourceY:o,sourcePosition:u,targetX:s,targetY:a,targetPosition:c,borderRadius:8,stepPosition:(b==null?void 0:b.stepPosition)??.5});return d.jsx(ms,{id:t,path:R,labelX:w,labelY:N,label:x,labelStyle:y,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,style:h,markerEnd:p,markerStart:v,interactionWidth:E})}const wN={loadstep:xN};function _N({topologyKey:t}){const{fitView:r}=na();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function SN(t,r,o=null,s={}){const a=new Map(t.map(v=>[v.id,v])),u=gm(t,r),c=cN(t,r,u),h=t.map(v=>{var m;const x=((m=s.roles)==null?void 0:m[v.id])||[],y=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:v.id,type:"load",position:u.get(v.id)??{x:0,y:0},data:{name:v.name,type:v.type,file:v.file_path,roles:x,dim:y},selected:o===v.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:Wl,height:ro,style:{width:Wl,height:ro}}}),p=r.filter(v=>a.has(v.src)&&a.has(v.dst)).map(v=>{const x=gN[v.weight]||"var(--edge-cheap)",y=!!(o&&(v.src===o||v.dst===o));return{id:v.id,source:v.src,target:v.dst,type:"loadstep",animated:v.weight==="critical",data:{stepPosition:c.get(v.id)??.5},style:{stroke:x,strokeWidth:v.weight==="critical"?2.4:1.2,strokeDasharray:v.confidence<.8?"6 4":void 0},markerEnd:{type:os.ArrowClosed,width:14,height:14,color:x},label:y?v.type.replaceAll("_"," "):void 0,labelStyle:y?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:y?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:y?[3,5]:void 0,labelBgBorderRadius:y?4:void 0}});return{rfNodes:h,rfEdges:p}}function kN({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:v}){const x=nN(t,r,o);return L.useEffect(()=>{const y=m=>{m.key==="Escape"&&s()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:x.typeLabel}),d.jsx("div",{className:"inspector-roles",children:x.roles.map(y=>d.jsx("span",{className:"inspector-chip",children:y},y))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Tr(x.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:x.purpose}),x.context?d.jsx("div",{className:"muted",children:Tr(x.context)}):null,x.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Tr(x.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Tr(x.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",x.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[x.degreeIn," in · ",x.degreeOut," out"]}),x.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:x.pathSummary}):null,x.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:x.facts.map(y=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:y.label}),d.jsx("dd",{children:Tr(y.value)})]},y.key))}):null,d.jsx(wp,{title:"Inputs",testId:"graph-inspector-inputs",links:x.inputs,extra:x.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(wp,{title:"Outputs",testId:"graph-inspector-outputs",links:x.outputs,extra:x.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),a?d.jsx("p",{className:"whatif-hint","data-testid":"whatif-hint",children:v?"Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map.":"Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."}):null,d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",title:"Start a hypothetical walk from this node. Does not use Base/Head.",onClick:()=>a(t.id),children:"What if this changes"}):null,v?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",title:"Hide nodes that are not on a path from here to a sink. Does not start a new walk.",onClick:()=>v(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function wp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Qu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:v,repoPath:x,onOpenFile:y,pinnedId:m,onPin:_}){const[k,j]=L.useState(null),b=a!==void 0?a:k,E=re=>{a===void 0&&j(re),u==null||u(re)},[R,w]=L.useState(null),[N,A]=L.useState(null),[$,F]=L.useState(new Set(vN)),[G,q]=L.useState(!1),[te,ee]=L.useState(""),[ne,K]=L.useState(!1),C=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,V=R??Vk(t.length),W=N??Wk(t.length),U=G?b:null,M=L.useMemo(()=>p?Xk(t,r,p):null,[t,r,p]),D=M?t.filter(re=>M.nodeIds.has(re.id)):t,H=M?r.filter(re=>M.edgeIds.has(re.id)):r,I=L.useMemo(()=>Yk(D,H,{detail:W,families:$,focusId:U,neighborhoodOnly:!!U}),[D,H,W,$,U]),z=L.useMemo(()=>`${I.nodes.map(re=>re.id).join("\0")}|${I.edges.map(re=>re.id).join("\0")}`,[I.nodes,I.edges]),ie=b?t.find(re=>re.id===b)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const re=SN(I.nodes,I.edges,b,{roles:c,testOverlay:h});return C&&(re.rfEdges=re.rfEdges.map(Ne=>({...Ne,animated:!1}))),re},[I.nodes,I.edges,b,C,c,h]);L.useEffect(()=>{if(!s)return;const re=t.find(Ne=>Ne.file_path===s);re&&E(re.id)},[s,t]);const he=L.useMemo(()=>Gk(t,te),[t,te]),pe=(re,Ne)=>{E(Ne.id)},Z=()=>{E(null),q(!1)},se=ie?d.jsx(kN,{node:ie,nodes:t,edges:r,onClose:Z,onWhatIf:o,onSelect:E,onOpenFile:y,pinned:m===ie.id,onPin:_,onIsolate:v?re=>{v(p===re?null:re)}:void 0}):null,me=re=>{F(Ne=>{const Me=new Set(Ne);if(Me.has(re)){if(Me.size===1)return Ne;Me.delete(re)}else Me.add(re);return Me})},ke=L.useMemo(()=>{const re=new Set;for(const Ne of t)re.add(vm(Ne.type));return re},[t]),ve=t.length-I.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:V==="2d"?"active":"","aria-pressed":V==="2d",onClick:()=>w("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:V==="3d"?"active":"","aria-pressed":V==="3d",onClick:()=>w("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:W==="overview"?"active":"","aria-pressed":W==="overview",onClick:()=>A("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:W==="full"?"active":"","aria-pressed":W==="full",onClick:()=>A("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(re=>ke.has(re)).map(re=>d.jsx("button",{type:"button","data-testid":`graph-family-${re}`,className:$.has(re)?"active":"","aria-pressed":$.has(re),onClick:()=>me(re),children:re},re))}),d.jsx("button",{type:"button",className:G?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!b,onClick:()=>q(re=>!re),children:G?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>v==null?void 0:v(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:te,onChange:re=>{ee(re.target.value),K(!0)},onFocus:()=>K(!0),onBlur:()=>window.setTimeout(()=>K(!1),150)}),ne&&te.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(re=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:Ne=>Ne.preventDefault(),onClick:()=>{E(re.id),ee(""),K(!1)},children:[re.name,d.jsx("span",{className:"muted",children:io(re.type)})]})},re.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[I.nodes.length," nodes · ",I.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:V==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(pN,{nodes:I.nodes,edges:I.edges,selectedId:b,neighborIds:U?I.neighborIds:hN,onSelect:re=>{E(re),re||q(!1)}})}),se]}):d.jsxs(dm,{children:[d.jsxs(rk,{nodes:oe,edges:fe,nodeTypes:yN,edgeTypes:wN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:Z,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(_N,{topologyKey:z}),d.jsx(ak,{}),d.jsx(Mk,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(gk,{})]}),se]})})]})}function xm(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function NN(t){localStorage.setItem("loadpath.editor",t)}async function jN(t,r,o,s=xm()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const _p=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],bN=["preset","branch","tag","commit"];function EN(t){var a;if(!(t!=null&&t.git))return[..._p];const r=((a=t.presets)!=null&&a.length?t.presets:_p.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function CN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function MN(t){return bN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function PN(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function Sp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[v,x]=L.useState(!1),[y,m]=L.useState(null),[_,k]=L.useState(0),j=L.useMemo(()=>{const N=EN(u);return y===null?N:CN(N,y)},[u,y]),b=L.useMemo(()=>MN(j),[j]);L.useEffect(()=>{v&&c()},[v,c]),L.useEffect(()=>{k(0)},[y,v]);const E=()=>{x(!1),m(null)},R=N=>{r(N.value),E()},w=N=>{if(N.key==="ArrowDown"){if(N.preventDefault(),!v){x(!0);return}k(A=>Math.min(A+1,Math.max(j.length-1,0)))}else if(N.key==="ArrowUp"){if(N.preventDefault(),!v)return;k(A=>Math.max(A-1,0))}else if(N.key==="Enter"&&v){N.preventDefault();const A=j[_];A&&R(A)}else N.key==="Escape"&&v&&(N.preventDefault(),E())};return d.jsxs("div",{className:"combo",ref:p,onBlur:N=>{N.currentTarget.contains(N.relatedTarget)||E()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":v,"aria-controls":h,"aria-autocomplete":"list",onChange:N=>{r(N.target.value),v&&m(N.target.value)},onKeyDown:w}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":v,onMouseDown:N=>N.preventDefault(),onClick:()=>v?E():x(!0),children:d.jsx(w0,{})})]}),v?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:b.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):b.map(N=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:PN(N.group)}),N.items.map(A=>{const $=j.indexOf(A);return d.jsxs("button",{type:"button",role:"option","aria-selected":$===_,className:$===_?"combo-option active":"combo-option","data-testid":`ref-option-${A.group}`,onMouseDown:F=>F.preventDefault(),onMouseEnter:()=>k($),onClick:()=>R(A),children:[d.jsx("span",{className:"combo-label",children:A.label}),A.detail?d.jsx("span",{className:"combo-detail",children:A.detail}):null]},`${A.group}:${A.value}`)})]},N.group))}):null]})}function IN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[v,x]=L.useState(""),[y,m]=L.useState(!1),_=L.useRef(null),k=L.useRef(0),j=async w=>{const N=k.current+1;k.current=N,m(!0);try{const A=await Pe.browse(w);if(k.current!==N)return;a(A),c(A.path),p(A.is_git?A.path:null),x("")}catch(A){if(k.current!==N)return;x(A instanceof Error?A.message:String(A))}finally{k.current===N&&m(!1)}};L.useEffect(()=>{var w,N;j(t),(w=_.current)==null||w.focus(),(N=_.current)==null||N.select()},[t]);const b=h||(s==null?void 0:s.path)||u,E=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",R=w=>{w.key==="Escape"&&(w.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:R,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:w=>w.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:w=>{w.preventDefault(),j(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:w=>c(w.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),v?d.jsx("div",{className:"error",role:"alert",children:v}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":y,children:s!=null&&s.entries.length?s.entries.map(w=>{const N=h===w.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":N,className:N?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":w.path,onClick:()=>p(w.path),onDoubleClick:()=>void j(w.path),children:[d.jsx(bp,{}),d.jsx("span",{className:"explorer-name",children:w.name}),w.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},w.path)}):d.jsx("div",{className:"muted explorer-empty",children:y?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:b,children:b}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!b,onClick:()=>b&&r(b),children:["Use ",E]})]})]})})}const RN={scan:{start:0,end:20},extract:{start:20,end:88},boot:{start:88,end:94},stitch:{start:94,end:99},skipped:{start:100,end:100},done:{start:100,end:100}},TN=new Set(["scan","extract","boot","stitch"]);function LN(t){const r=t.phase||"";if(!r||r==="idle")return null;const o=RN[r];if(!o)return null;if(o.start===o.end)return o.end;const s=t.total||0;if(s<=0)return o.start;const a=Math.min(1,Math.max(0,(t.done||0)/s));return Math.round(o.start+(o.end-o.start)*a)}function AN(t){return!t.phase||t.phase==="idle"?null:typeof t.percent=="number"&&Number.isFinite(t.percent)?Math.max(0,Math.min(100,Math.round(t.percent))):LN(t)}const Ul=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],$N="obsidian",wm="loadpath.theme";function zN(t){return Ul.some(r=>r.id===t)}function _m(){try{const t=localStorage.getItem(wm)||"";if(zN(t))return t}catch{}return $N}function DN(t){var r;return((r=Ul.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function Sm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=DN(t);try{localStorage.setItem(wm,t)}catch{}}const Zu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:g0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:m0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:y0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:v0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:x0}];function Ju(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function ON(){var fo,ho,Si,po,go,mo,ki,Xr,rn,on;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,v]=L.useState(null),[x,y]=L.useState(null),[m,_]=L.useState(null),[k,j]=L.useState([]),[b,E]=L.useState("review"),[R,w]=L.useState(""),[N,A]=L.useState(""),[$,F]=L.useState(null),[G,q]=L.useState(!1),[te,ee]=L.useState(!1),[ne,K]=L.useState(""),[C,V]=L.useState({}),[W,U]=L.useState([]),[M,D]=L.useState([]),[H,I]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[z,ie]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[oe,fe]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[he,pe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[Z,se]=L.useState(0),[me,ke]=L.useState(""),[ve,re]=L.useState(_m),[Ne,Me]=L.useState(!1),[Te,$e]=L.useState(!1),[st,lt]=L.useState(!1),[at,Ge]=L.useState(null),[wt,qt]=L.useState(null),[gt,mt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[Pt,ut]=L.useState(null),[Je,An]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[Ot,xn]=L.useState([]),[oo,$n]=L.useState(null),[vi,or]=L.useState(null),[$r,zn]=L.useState(null),[zr,sr]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[lr,Ft]=L.useState(null),[ct,Dn]=L.useState(null),[On,wn]=L.useState(!1),[Fn,_n]=L.useState(!1),rt=L.useRef(o);rt.current=o;const Dr=L.useRef(!1);Dr.current=Te;const _t=L.useRef(""),ar=L.useRef(""),Sn=P=>{re(P),Sm(P)},dt=L.useRef(""),He=P=>{dt.current=P,A(P)},kn=P=>{let Y=0,ce=!1;F(0);const je=()=>{Pe.indexProgress(P).then(Ie=>{if(!dt.current)return;if(Ie.phase&&Ie.phase!=="idle"&&Ie.message&&He(Ie.message),TN.has(Ie.phase))ce=!0;else if(!ce)return;const qr=AN(Ie);qr!=null&&(Ie.phase==="scan"&&!Ie.done?Y=qr:Y=Math.max(Y,qr),F(Y))}).catch(()=>{})};je();const Le=window.setInterval(je,250);return()=>{window.clearInterval(Le),F(null)}};L.useEffect(()=>{Pe.settings().then(V).catch(()=>{}).finally(()=>Me(!0)),Pe.repos().then(P=>j(P.repos)).catch(()=>{})},[]);const Nn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const P=o;let Y=!1;return ar.current!==P&&Bn(P),Pe.config(P).then(ce=>{!Y&&rt.current===P&&or(ce)}).catch(()=>{}),Pe.architectureHealth(P).then(ce=>{!Y&&rt.current===P&&zn(ce)}).catch(()=>{}),()=>{Y=!0}},[t,o]);const Ht=P=>{rt.current=P,s(P),localStorage.setItem("loadpath.repo",P),P.trim()!==_t.current&&(_t.current="",Ft(null))},Or=L.useCallback(P=>{const Y=(P??rt.current).trim();return!Y||_t.current===Y?Promise.resolve():(_t.current=Y,Pe.gitRefs(Y).then(ce=>{rt.current.trim()===Y&&Ft(ce)}).catch(()=>{_t.current===Y&&(_t.current="",Ft(null))}))},[]),nn=(P,Y)=>{u(P),h(Y),localStorage.setItem("loadpath.base",P),localStorage.setItem("loadpath.head",Y)},Fr=(P,Y,ce)=>{ie(P),I(Y),localStorage.setItem("loadpath.provider",P),localStorage.setItem("loadpath.scmRepo",Y),ce!==void 0&&(fe(ce),localStorage.setItem("loadpath.prNumber",ce))},yt=P=>{v(P),se(0),Ge(wt&&P.nodes.some(Y=>Y.id===wt)?wt:null),ut(null),$n(null),P.what_if||(y(P),P.id&&localStorage.setItem("loadpath.lastReviewId",P.id))},Hn=async P=>{try{const Y=await Pe.reviews(P);xn(Y.reviews)}catch{xn([])}},ur=async P=>{try{zn(await Pe.architectureHealth(P))}catch{zn(null)}},so=P=>P==="github"?!!C.github_token_set:P==="gitlab"?!!C.gitlab_token_set:!!C.bitbucket_token_set,It=L.useCallback(async(P=z)=>{var Y;try{const ce=await Pe.scmRepos(P);D(ce.repos),(Y=ce.user)!=null&&Y.login&&V(je=>({...je,...P==="github"?{github_user:ce.user.login}:P==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{D([])}},[z]);L.useEffect(()=>{if(t!=="prs")return;let P=!1;return It(z).catch(()=>{P||D([])}),()=>{P=!0}},[t,z,It]),L.useEffect(()=>{if(!ct)return;let P=!1,Y=0;const ce=async()=>{try{const je=await Pe.githubOAuthPoll(ct.flow_id);if(P)return;if(je.status==="complete"){Dn(null);const Le=await Pe.settings();V(Le),K(je.user?`Signed in to GitHub as ${je.user}`:"Signed in to GitHub"),It("github");return}if(je.status==="pending"||je.status==="slow_down"){Y=window.setTimeout(ce,Math.max(je.interval||ct.interval,5)*1e3);return}Dn(null),w(je.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(je){if(P)return;Dn(null),w(je instanceof Error?je.message:String(je))}};return Y=window.setTimeout(ce,Math.max(ct.interval,5)*1e3),()=>{P=!0,window.clearTimeout(Y)}},[ct,It]),L.useEffect(()=>{if(!On)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.bitbucket.connected){wn(!1);const Ie=await Pe.settings();V(Ie),K(Le.bitbucket.user?`Signed in to Bitbucket as ${Le.bitbucket.user}`:"Signed in to Bitbucket"),It("bitbucket");return}if(Date.now()-ce>18e4){wn(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;wn(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[On,It]),L.useEffect(()=>{if(!Fn)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.gitlab.connected){_n(!1);const Ie=await Pe.settings();V(Ie),K(Le.gitlab.user?`Signed in to GitLab as ${Le.gitlab.user}`:"Signed in to GitLab"),It("gitlab");return}if(Date.now()-ce>18e4){_n(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;_n(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[Fn,It]);const Bn=async(P=o,Y=!1)=>{if(!P.trim())return null;ar.current=P,ee(!0);try{const ce=await Pe.architecture(P,!1);rt.current===P&&_(ce);const je=Pe.architectureGraph(P).then(Le=>{rt.current===P&&_(Ie=>Ie&&{...Ie,nodes:Le.nodes,edges:Le.edges,graph_pending:!1})});return je.catch(()=>{}).finally(()=>{rt.current===P&&ee(!1)}),Y&&await je,ce}catch(ce){throw rt.current===P&&ee(!1),ce}},Hr=async P=>{const Y=P.trim();if(!(!Y||Y===rt.current)){if(dt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),K(""),v(null),y(null),_(null),E("architecture"),Ht(Y),q(!0),He(`Loading ${p0(Y)}…`);try{await Promise.all([Bn(Y),Or(Y)])}catch(ce){rt.current===Y&&w(ce instanceof Error?ce.message:String(ce))}finally{rt.current===Y&&(He(""),q(!1))}}},jn=async()=>{if(dt.current||!Nn())return;w(""),K(""),He("Tracing load path…"),Ht(o),nn(a,c);const P=kn(o);try{const Y=await Pe.review(o,a,c,!0,he);yt(Y),E("review"),r("review"),await Pe.repos().then(ce=>j(ce.repos)).catch(()=>{}),await Promise.all([Bn(o),Hn(o),ur(o)])}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{P(),He("")}},Br=async(P=!0)=>{if(dt.current||!Nn())return;w(""),K(""),He(P?"Indexing…":"Full reindex…"),Ht(o);const Y=kn(o);try{await Pe.index(o,P);const ce=await Bn(o);await Pe.repos().then(je=>j(je.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(E("architecture"),r("architecture"))}catch(ce){w(ce instanceof Error?ce.message:String(ce))}finally{Y(),He("")}},xi=async()=>{if(!dt.current&&Nn()){w(""),K(""),He("Detecting layout…"),Ht(o);try{const P=await Pe.init(o);K(P.message),await Pe.repos().then(Y=>j(Y.repos)).catch(()=>{})}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ve=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),K("Copied markdown brief")}catch(P){w(P instanceof Error?P.message:String(P))}},lo=async()=>{if(!dt.current){if(p!=null&&p.what_if){w("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first.");return}if(!(p!=null&&p.markdown)||!H||!oe){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const P=await Pe.postComment(z,H,Number(oe),p.markdown);K(P.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Vr=async()=>{if(!dt.current){w(""),He("Fetching pull requests…");try{const P=await Pe.prs(z,H,"open",o.trim()||void 0);U(P.pull_requests);const Y=M.find(ce=>ce.slug.toLowerCase()===H.trim().toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},wi=async()=>{w("");try{const P=await Pe.githubOAuthStart();Dn(P),Ju(P.verification_uri_complete,"github.com","/login/device")}catch(P){w(P instanceof Error?P.message:String(P))}},cr=async()=>{w("");try{const P=await Pe.bitbucketOAuthStart();wn(!0),Ju(P.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(P){wn(!1),w(P instanceof Error?P.message:String(P))}},ao=async()=>{w("");try{const P=await Pe.gitlabOAuthStart();_n(!0),Ju(P.authorize_url,new URL(P.authorize_url).hostname,"/oauth/authorize")}catch(P){_n(!1),w(P instanceof Error?P.message:String(P))}},dr=async P=>{if(!(dt.current||!o.trim())){w(""),He("Walking what-if path…");try{const Y=await Pe.whatIf(o,P);K(`${Y.title} — ${Y.confidence.level} · ${(Y.sinks||[]).length} sinks`),yt({...Y,markdown:Y.markdown||"",index:Y.index||(p==null?void 0:p.index),workspace:Y.workspace||(p==null?void 0:p.workspace)}),E("review"),r("review")}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},Vn=()=>{if(x){yt(x),E("review"),r("review"),K("Restored the last git-range walk");return}v(null),se(0),Ge(null),ut(null),$n(null),E("architecture"),r("architecture"),K("")},bt=async P=>{var Le;if(dt.current)return;Fr(P.provider,P.repo,String(P.number));const Y=M.find(Ie=>Ie.slug.toLowerCase()===P.repo.toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path),w(""),He(`Fetching ${P.provider} #${P.number}…`);const ce=(Y==null?void 0:Y.local_path)||o,je=ce?kn(ce):()=>{};try{const Ie=await Pe.reviewPr(P.provider,P.repo,P.number,(Y==null?void 0:Y.local_path)||o||void 0);yt(Ie),Ie.pull_request&&typeof Ie.pull_request.repo_path=="string"&&Ht(Ie.pull_request.repo_path),nn(String(Ie.base||P.target_branch),String(Ie.head||P.source_branch)),E("review"),r("review"),typeof((Le=Ie.pull_request)==null?void 0:Le.repo_path)=="string"&&Hn(Ie.pull_request.repo_path)}catch(Ie){nn(P.base_sha||P.target_branch,P.head_sha||P.source_branch),r("review"),w(Ie instanceof Error?Ie.message:String(Ie))}finally{je(),He("")}},Wr=async P=>{w("");try{V(await Pe.oauthDisconnect(P)),z===P&&D([]),K(`Disconnected ${P}`)}catch(Y){w(Y instanceof Error?Y.message:String(Y))}},Et=async P=>{P.preventDefault();const Y=new FormData(P.currentTarget),ce={github_token:String(Y.get("github_token")||""),github_oauth_client_id:String(Y.get("github_oauth_client_id")||""),github_host:String(Y.get("github_host")||""),gitlab_token:String(Y.get("gitlab_token")||""),gitlab_host:String(Y.get("gitlab_host")||""),gitlab_oauth_client_id:String(Y.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(Y.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(Y.get("bitbucket_token")||""),bitbucket_username:String(Y.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(Y.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(Y.get("bitbucket_oauth_client_secret")||""),ai_provider:String(Y.get("ai_provider")||"none"),ai_api_key:String(Y.get("ai_api_key")||""),ai_model:String(Y.get("ai_model")||""),ai_base_url:String(Y.get("ai_base_url")||"")},je=k.length?{...ce,workspaces:k.map(Le=>({path:Le.path,name:Le.name}))}:ce;try{V(await Pe.saveSettings(je)),K("Settings saved on this machine")}catch(Le){w(Le instanceof Error?Le.message:String(Le))}},uo=async()=>{if(!(!p||dt.current)){He("Residual analysis…");try{const P=await Pe.residual(p);ke(P.note)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ur=L.useRef(jn);Ur.current=jn;const Yr=L.useRef(t);Yr.current=t;const Wn=L.useRef(!1);Wn.current=st;const Un=L.useRef(p);Un.current=p;const bn=L.useRef(Z);bn.current=Z,L.useEffect(()=>{const P=localStorage.getItem("loadpath.lastReviewId"),Y=(localStorage.getItem("loadpath.repo")||"").trim();if(!P||!Y){sr(!1);return}let ce=!1;return Pe.getReview(Y,P).then(je=>{ce||(yt(je),nn(je.base||localStorage.getItem("loadpath.base")||"HEAD~1",je.head||localStorage.getItem("loadpath.head")||"HEAD"),Hn(Y),ur(Y))}).catch(()=>{}).finally(()=>{ce||sr(!1)}),()=>{ce=!0}},[]);const Bt=L.useRef("");L.useEffect(()=>{if(!Je||!o.trim())return;let P=!1;const Y=async()=>{try{const je=await Pe.workspaceStatus(o);if(P)return;Bt.current&&je.fingerprint!==Bt.current&&!dt.current&&(pe(!0),localStorage.setItem("loadpath.dirty","1"),Ur.current()),Bt.current=je.fingerprint}catch{}};Y();const ce=window.setInterval(Y,2e3);return()=>{P=!0,window.clearInterval(ce)}},[Je,o]),L.useEffect(()=>{const P=Y=>{var Le;if((Y.metaKey||Y.ctrlKey)&&Y.key.toLowerCase()==="k"){Y.preventDefault(),lt(Ie=>!Ie);return}if(Wn.current){Y.key==="Escape"&&(Y.preventDefault(),lt(!1));return}if(Dr.current){Y.key==="Escape"&&(Y.preventDefault(),$e(!1));return}const ce=Y.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){Y.key==="Escape"&&ce.blur();return}if(Y.key==="Escape"){w(""),K(""),Ge(wt),ut(null);return}if(Y.key==="j"||Y.key==="k"){const Ie=((Le=Un.current)==null?void 0:Le.read_order)||[];if(!Ie.length)return;Y.preventDefault();const Gn=bn.current,qr=Y.key==="j"?Math.min(Ie.length-1,Gn+1):Math.max(0,Gn-1);se(qr);return}const je=Zu.find(Ie=>Ie.shortcut===Y.key);if(je&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey&&r(je.id),(Y.metaKey||Y.ctrlKey)&&Y.key==="Enter"){if(Yr.current==="settings"||Yr.current==="prs"||dt.current)return;Y.preventDefault(),Ur.current()}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[wt]);const _i=async(P,Y)=>{if(!o.trim())return;const ce=await jN(o,P,Y);ce.ok?K(ce.message):w(ce.message)},Gr=async()=>{if(p)try{const P=await Pe.exportHtml(p),Y=URL.createObjectURL(P),ce=document.createElement("a");ce.href=Y,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(Y),K("Saved HTML brief")}catch(P){w(P instanceof Error?P.message:String(P))}},fr=async P=>{if(o.trim()){He("Loading stored review…");try{const Y=await Pe.getReview(o,P);yt(Y),nn(Y.base||a,Y.head||c),E("review"),r("review");const ce=Ot.find(je=>je.id!==P);if(ce)try{$n(await Pe.reviewDiff(o,P,ce.id))}catch{$n(null)}}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},hr={selectedId:at,onSelect:Ge,nodeRoles:p==null?void 0:p.node_roles,testOverlay:gt,isolateSource:Pt,onIsolate:ut,repoPath:o,onOpenFile:_i,pinnedId:wt,onPin:qt},Yn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},...p!=null&&p.what_if?[{id:"exit-whatif",group:"Review",label:x?"Back to git-range walk":"Exit what-if walk",run:Vn}]:[],{id:"index",group:"Run",label:"Index repository",run:()=>void Br(!0)},{id:"watch",group:"Run",label:Je?"Stop watching working tree":"Watch working tree",run:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")}},{id:"tests",group:"Graph",label:gt?"Hide test overlay":"Show test overlay",run:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Gr()},...Zu.map(P=>({id:`tab-${P.id}`,group:"Tabs",label:`Go to ${P.label}`,hint:P.shortcut,run:()=>r(P.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(P=>({id:`node-${P.id}`,group:"Nodes",label:P.name,hint:io(P.type),run:()=>{Ge(P.id),r("graph")}})),...Ot.slice(0,12).map(P=>({id:`hist-${P.id}`,group:"History",label:P.title||P.id,hint:`${P.level||""} ${P.created_at||""}`.trim(),run:()=>void fr(P.id)}))],En=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[b,m,p]),co=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[b,m,p]),pr=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Fe=((p==null?void 0:p.findings)||[]).filter(P=>!P.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Zu.map(P=>{const Y=P.icon,ce=t===P.id;return d.jsxs("button",{type:"button","data-testid":P.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":P.label,onClick:()=>r(P.id),children:[d.jsx(Y,{}),d.jsx("span",{children:P.label})]},P.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:ve,onChange:P=>Sn(P.target.value),children:["dark","light"].map(P=>d.jsx("optgroup",{label:P==="dark"?"Dark":"Light",children:Ul.filter(Y=>Y.group===P).map(Y=>d.jsx("option",{value:Y.id,children:Y.label},Y.id))},P))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:N||pr}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[N?d.jsxs("div",{className:$!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","aria-valuemin":$!=null?0:void 0,"aria-valuemax":$!=null?100:void 0,"aria-valuenow":$??void 0,"data-testid":"progress",children:[d.jsx("i",{style:$!=null?{width:`${$}%`}:void 0}),d.jsx("span",{className:"sr-only",children:N})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[k.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:k.some(P=>P.path===o)?o:"",disabled:!!N,"aria-busy":G,onChange:P=>{P.target.value&&Hr(P.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),k.map(P=>d.jsxs("option",{value:P.path,children:[P.name,P.indexed?` (${P.counts.nodes})`:""]},P.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:P=>{const Y=P.target.value;s(Y),Y.trim()!==_t.current&&(_t.current="",Ft(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>$e(!0),children:d.jsx(bp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(Sp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:P=>nn(P,c),placeholder:"base",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(Sp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:P=>nn(a,P),placeholder:"head",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:he?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":he,onClick:()=>{const P=!he;pe(P),localStorage.setItem("loadpath.dirty",P?"1":"0")},children:he?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:Je?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":Je,onClick:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")},children:Je?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.what_if?"what-if · ":"",p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!N,onClick:xi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!N,onClick:()=>Br(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!N,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[R?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:R}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,ne?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:ne}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>K(""),"aria-label":"Dismiss",children:"×"})]}):null,((fo=p==null?void 0:p.index)!=null&&fo.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((ho=p==null?void 0:p.index)==null?void 0:ho.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Si=p==null?void 0:p.index)==null?void 0:Si.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(po=p==null?void 0:p.workspace)!=null&&po.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,p!=null&&p.what_if?d.jsxs("div",{className:"banner whatif","data-testid":"whatif-banner",children:[d.jsxs("span",{children:["Hypothetical walk from"," ",d.jsx("strong",{children:((go=p.node)==null?void 0:go.name)||"this node"}),". Loadpath ignored Base/Head and asked which sinks would feel this node change — not a filter of the current map."]}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-exit-whatif",onClick:Vn,children:x?"Back to git range":"Back to architecture"})]}):null,G?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:N||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":G||te,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(FN,{review:p,findings:Fe,aiNote:me,busy:!!N,tourIndex:Z,onTour:se,onAskAi:uo,onCopy:Ve,onPost:lo,onSelect:Ge,onOpenFile:_i,onExport:Gr,history:Ot,diff:oo,onReopen:fr,onWaiver:(P,Y)=>{o.trim()&&Pe.addWaiver(o,P,Y||void 0,"from review").then(ce=>{or(ce),K(`Waived ${P} in loadpath.yml`)})}}):zr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Qu,{nodes:p.nodes,edges:p.edges,onWhatIf:dr,focusPath:(mo=p.read_order[Z])==null?void 0:mo.path,...hr}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(HN,{architecture:m,busy:!!N,onReindex:()=>Br(!1),onReview:jn,onSelect:Ge,config:vi,health:$r,onSaveConfig:P=>{Pe.saveConfig(o,P).then(Y=>{or(Y),K("Wrote loadpath.yml")})},onWaiver:(P,Y,ce)=>{Pe.addWaiver(o,P,Y,ce).then(je=>{or(je),K(`Waived ${P}`)})}}):G?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(te||m!=null&&m.graph_pending)&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(ki=m==null?void 0:m.counts)!=null&&ki.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Qu,{nodes:m.nodes,edges:m.edges,onWhatIf:dr,...hr,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":b==="review","data-testid":"graph-mode-review",className:b==="review"?"active":"",onClick:()=>E("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":b==="architecture","data-testid":"graph-mode-architecture",className:b==="architecture"?"active":"",onClick:()=>E("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:gt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":gt,onClick:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")},children:"Tests"})]}),En.length?d.jsx(Qu,{nodes:En,edges:co,onWhatIf:dr,...hr}):te||m!=null&&m.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:z,onChange:P=>Fr(P.target.value,H,oe),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:M.length?"Search your repos":"owner/repo",value:H,onChange:P=>Fr(z,P.target.value,oe),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:M.map(P=>d.jsxs("option",{value:P.slug,children:[P.private?"private":"public",P.local_path?" · local":""]},P.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!N||!so(z),onClick:()=>{It(z)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!N,onClick:Vr,children:"List PRs"})]}),M.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[M.length," ",z," repositor",M.length===1?"y":"ies",z==="github"&&C.github_user?` · @${String(C.github_user)}`:"",z==="gitlab"&&C.gitlab_user?` · @${String(C.gitlab_user)}`:"",z==="bitbucket"&&C.bitbucket_user?` · ${String(C.bitbucket_user)}`:""]}):null,W.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):W.map(P=>{var Y;return d.jsxs("article",{className:"pr","data-testid":`pr-${P.number}`,children:[d.jsxs("h3",{children:["#",P.number," ",P.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${P.draft?"":"open"}`,children:P.draft?"draft":P.state}),d.jsx("span",{children:P.author}),d.jsxs("span",{children:[P.source_branch," → ",P.target_branch]}),P.loadpath?d.jsxs("span",{className:`chip ${P.loadpath.level||""}`,"data-testid":`pr-loadpath-${P.number}`,children:[((Y=P.loadpath.level)==null?void 0:Y.toUpperCase())||"REVIEWED",P.loadpath.contract_break&&P.loadpath.contract_break!=="none"?` · ${P.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:P.url,target:"_blank",rel:"noreferrer",children:["Open on ",P.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${P.number}`,onClick:()=>void bt(P),children:"Review this PR"})]})]},`${P.provider}-${P.number}`)})]}),t==="settings"&&Ne&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Et,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Ul.map(P=>d.jsxs("button",{type:"button","data-theme":P.id,className:ve===P.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${P.id}`,onClick:()=>Sn(P.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:P.label}),d.jsx("div",{className:"group",children:P.group})]},P.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:xm(),onChange:P=>NN(P.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:C.github_token_set?C.github_user?`Signed in as @${String(C.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void Wr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!ct||!C.github_oauth_ready,onClick:()=>void wi(),children:ct?"Waiting for GitHub…":"Sign in with GitHub"})})]}),ct?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:ct.user_code})," at GitHub if the browser did not fill it in."]}):null,C.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(C.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(C.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:C.gitlab_token_set?C.gitlab_user?`Signed in as @${String(C.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void Wr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Fn||!C.gitlab_oauth_ready,onClick:()=>void ao(),children:Fn?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(C.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(C.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:C.bitbucket_token_set?C.bitbucket_user?`Signed in as ${String(C.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void Wr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:On||!C.bitbucket_oauth_ready,onClick:()=>void cr(),children:On?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),C.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(C.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(C.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((Xr=C.ai)==null?void 0:Xr.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((rn=C.ai)==null?void 0:rn.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((on=C.ai)==null?void 0:on.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(d0,{open:st,actions:Yn,onClose:()=>lt(!1)}),Te?d.jsx(IN,{initialPath:o,onClose:()=>$e(!1),onSelect:P=>{if(dt.current){w("Wait for the current job to finish before switching workspace.");return}$e(!1),Hr(P)}}):null]})}function FN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:v,onOpenFile:x,onExport:y,history:m,diff:_,onReopen:k,onWaiver:j}){var E,R,w,N,A,$,F,G,q,te,ee,ne,K,C,V,W,U;const b=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),b.length?d.jsx("ul",{className:"reasons",children:b.map(M=>d.jsx("li",{children:M},M))}):null,t.what_if?d.jsx("span",{className:"chip whatif","data-testid":"whatif-chip",children:"what-if"}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Zo(M)},M)),(E=t.contract_break)!=null&&E.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>j(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(R=t.workspace)!=null&&R.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>x(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(km,{cards:t.deepening}),(N=(w=t.contract_break)==null?void 0:w.reasons)!=null&&N.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),($=(A=t.contract_break.sides)==null?void 0:A.rows)!=null&&$.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(F=t.auth)!=null&&F.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(G=t.suggested_tests)==null?void 0:G.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(q=t.trend)!=null&&q.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",ec(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),m.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:m.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,m.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>k(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?ec(M.created_at):""})]},M.id))]}):null,(ee=(te=t.evolution)==null?void 0:te.notes)!=null&&ee.length||(K=(ne=t.evolution)==null?void 0:ne.hotspots)!=null&&K.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((C=t.evolution)==null?void 0:C.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((V=t.evolution)==null?void 0:V.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:y,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",disabled:s||!!t.what_if,title:t.what_if?"Hypothetical walks are not posted to a pull request":void 0,onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(W=t.codeowners_reviewers)!=null&&W.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function HN({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var x;const v=t.findings.filter(y=>!y.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${ec(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(y=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y.name})," — ",(y.django_apps||[]).join(", ")||"no apps"," ·"," ",(y.owners||[]).join(", ")||"unowned"]},y.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(y=>d.jsx("div",{className:"muted",children:y},y))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:v.length})]}),v.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):v.map(y=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>y.node_id&&a(y.node_id),children:[d.jsx("span",{className:`chip ${y.severity}`,children:y.severity}),y.message]})},y.rule+y.message))]}),d.jsx(km,{cards:t.deepening}),(x=c==null?void 0:c.points)!=null&&x.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(y=>d.jsx("i",{className:y.level||"",title:`${y.level} · ${y.findings} findings`,style:{height:`${8+Math.min(24,(y.findings||0)*4)}px`}},y.id||y.created_at))}),Object.entries(c.contexts).map(([y,m])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y})," — last ",((_=m[m.length-1])==null?void 0:_.findings)??0," findings"]},y)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(f0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((y,m)=>m[1]-y[1]).slice(0,12).map(([y,m])=>d.jsxs("tr",{children:[d.jsx("td",{children:io(y)}),d.jsx("td",{children:m})]},y))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function km({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:h0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}Sm(_m());a0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(ON,{})}));export{Bk as L,WN as a,BN as c,d as j,VN as l,L as r,io as t}; diff --git a/src/loadpath/static/index.html b/src/loadpath/static/index.html index bb56dd1..a80370c 100644 --- a/src/loadpath/static/index.html +++ b/src/loadpath/static/index.html @@ -17,7 +17,7 @@ - + diff --git a/tests/e2e/test_ui_flows.py b/tests/e2e/test_ui_flows.py index 23a2de0..2a37733 100644 --- a/tests/e2e/test_ui_flows.py +++ b/tests/e2e/test_ui_flows.py @@ -559,29 +559,31 @@ def test_ui_architecture_edges_use_distinct_verticals(live_app, browser_page): wait_visible_graph(page) info = page.evaluate( """() => { - const paths = [...document.querySelectorAll('.react-flow__edge-path')].map((p) => p.getAttribute('d') || ''); - const bySx = {}; - for (const d of paths) { - const m = d.match(/^M(-?\\d+\\.?\\d*)/); - const nums = [...d.matchAll(/(-?\\d+\\.?\\d*)/g)].map((mm) => Number(mm[1])); - if (!m || nums.length < 4) continue; - const sx = Math.round(Number(m[1])); - const lastX = nums[nums.length - 2]; - if (lastX <= sx) continue; - const verts = []; + const segs = []; + for (const p of document.querySelectorAll('.react-flow__edge-path')) { + const nums = [...(p.getAttribute('d') || '').matchAll(/(-?\\d+\\.?\\d*)/g)].map((mm) => Number(mm[1])); for (let i = 0; i + 3 < nums.length; i += 2) { - if (Math.abs(nums[i] - nums[i + 2]) < 1 && Math.abs(nums[i + 1] - nums[i + 3]) > 8) { - verts.push(Math.round(nums[i])); + if (Math.abs(nums[i] - nums[i + 2]) < 1 && Math.abs(nums[i + 1] - nums[i + 3]) > 16) { + const y0 = Math.min(nums[i + 1], nums[i + 3]); + const y1 = Math.max(nums[i + 1], nums[i + 3]); + segs.push({ x: Math.round(nums[i]), y0, y1 }); } } - (bySx[sx] ||= []).push(verts); } - return Object.values(bySx).filter((list) => list.length >= 2); + const overlaps = []; + for (let i = 0; i < segs.length; i++) { + for (let j = i + 1; j < segs.length; j++) { + const a = segs[i]; + const b = segs[j]; + if (a.x !== b.x) continue; + if (a.y0 < b.y1 - 4 && b.y0 < a.y1 - 4) overlaps.push({ a, b }); + } + } + return { segCount: segs.length, overlapCount: overlaps.length, overlaps: overlaps.slice(0, 5) }; }""" ) - assert info, "expected multiple left-to-right edges from one column" - distinct = any(len({x for verts in group for x in verts}) > 1 for group in info) - assert distinct, info + assert info["segCount"] > 0, info + assert info["overlapCount"] == 0, info @pytest.mark.playwright diff --git a/ui/src/graphEdges.test.ts b/ui/src/graphEdges.test.ts index ea70b7b..98826bb 100644 --- a/ui/src/graphEdges.test.ts +++ b/ui/src/graphEdges.test.ts @@ -46,13 +46,13 @@ describe("assignEdgeStepPositions", () => { expect(steps.size).toBe(0); }); - it("separates collinear verticals in the same gap even when their y ranges do not overlap", () => { + it("separates stacked route-to-view verticals that would read as one bus", () => { const nodes = [node("r1", "django.route"), node("r2", "django.route"), node("v1", "django.view"), node("v2", "django.view")]; const pos = new Map([ ["r1", { x: 0, y: 0 }], - ["r2", { x: 0, y: 400 }], + ["r2", { x: 0, y: 92 }], ["v1", { x: 296, y: 48 }], - ["v2", { x: 296, y: 448 }], + ["v2", { x: 296, y: 140 }], ]); const edges = [edge("r1", "v1"), edge("r2", "v2")]; const steps = assignEdgeStepPositions(nodes, edges, pos); @@ -60,6 +60,20 @@ describe("assignEdgeStepPositions", () => { expect(steps.get("r2->v2")).toBe(0.8); }); + it("reuses a vertical when two bent edges are far apart in y", () => { + const nodes = [node("r1", "django.route"), node("r2", "django.route"), node("v1", "django.view"), node("v2", "django.view")]; + const pos = new Map([ + ["r1", { x: 0, y: 0 }], + ["r2", { x: 0, y: 400 }], + ["v1", { x: 296, y: 48 }], + ["v2", { x: 296, y: 448 }], + ]); + const edges = [edge("r1", "v1"), edge("r2", "v2")]; + const steps = assignEdgeStepPositions(nodes, edges, pos); + expect(steps.get("r1->v1")).toBe(0.5); + expect(steps.get("r2->v2")).toBe(0.5); + }); + it("spreads lanes between 0.2 and 0.8", () => { expect(stepForLane(0, 1)).toBe(0.5); expect(stepForLane(0, 2)).toBe(0.2); @@ -72,8 +86,8 @@ describe("getSmoothStepPath stepPosition", () => { const shared = { sourceX: 208, sourceY: 32, - targetX: 336, targetY: 120, + targetX: 336, sourcePosition: Position.Right, targetPosition: Position.Left, }; diff --git a/ui/src/graphEdges.ts b/ui/src/graphEdges.ts index bc42ec3..0b5ed9a 100644 --- a/ui/src/graphEdges.ts +++ b/ui/src/graphEdges.ts @@ -1,16 +1,25 @@ -import { GRAPH_NODE_HEIGHT, GRAPH_NODE_WIDTH, layoutNodes, type GraphEdge, type GraphNode } from "./types"; +import { + GRAPH_NODE_HEIGHT, + GRAPH_NODE_WIDTH, + layoutNodes, + type GraphEdge, + type GraphNode, +} from "./types"; const HORIZONTAL_EPS = 12; const STEP_LO = 0.2; const STEP_HI = 0.8; +/** Adjacent stacked steps sit ~one node apart; reuse a vertical only beyond that. */ +const CLEARANCE = GRAPH_NODE_HEIGHT; type Span = { id: string; - sourceY: number; + y0: number; + y1: number; corridor: string; }; -/** Give each bent edge in a column gap its own vertical so parallel routes do not share one x. */ +/** Offset bent edges whose verticals would overlap so parallel routes stay distinct. */ export function assignEdgeStepPositions( nodes: GraphNode[], edges: GraphEdge[], @@ -27,9 +36,12 @@ export function assignEdgeStepPositions( if (Math.abs(sourceY - targetY) < HORIZONTAL_EPS) continue; const sourceX = src.x + GRAPH_NODE_WIDTH; const targetX = dst.x; + const y0 = Math.min(sourceY, targetY); + const y1 = Math.max(sourceY, targetY); spans.push({ id: edge.id, - sourceY, + y0, + y1, corridor: `${Math.round(sourceX / 8)}>${Math.round(targetX / 8)}`, }); } @@ -43,15 +55,39 @@ export function assignEdgeStepPositions( const steps = new Map(); for (const group of groups.values()) { - const sorted = [...group].sort((a, b) => a.sourceY - b.sourceY || a.id.localeCompare(b.id)); - const n = sorted.length; - sorted.forEach((span, i) => { - steps.set(span.id, stepForLane(i, n)); - }); + const sorted = [...group].sort((a, b) => a.y0 - b.y0 || a.y1 - b.y1 || a.id.localeCompare(b.id)); + const laneOf = lanesFor(sorted); + const laneCount = Math.max(0, ...laneOf.values()) + 1; + for (const span of sorted) { + steps.set(span.id, stepForLane(laneOf.get(span.id) ?? 0, laneCount)); + } } return steps; } +/** First-fit coloring: two verticals share an x only when their y ranges stay apart. */ +function lanesFor(spans: Span[]): Map { + const laneEnds: number[] = []; + const laneOf = new Map(); + for (const span of spans) { + let lane = -1; + for (let i = 0; i < laneEnds.length; i++) { + if (span.y0 > laneEnds[i]! + CLEARANCE) { + lane = i; + break; + } + } + if (lane < 0) { + lane = laneEnds.length; + laneEnds.push(span.y1); + } else { + laneEnds[lane] = Math.max(laneEnds[lane]!, span.y1); + } + laneOf.set(span.id, lane); + } + return laneOf; +} + export function stepForLane(lane: number, laneCount: number): number { if (laneCount <= 1) return 0.5; return STEP_LO + ((STEP_HI - STEP_LO) * lane) / (laneCount - 1); From 3b524034abf95c7075e4bec62a6fd7640e11abc0 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 16 Aug 2026 00:47:17 +0000 Subject: [PATCH 12/16] Keep every outgoing edge from a column on shared vertical tracks. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Skip-column links used to pick an independent bend and land on top of the next-column routes. Overlapping y-ranges now share one 0.2–0.8 gutter so stacked buses stay readable. Co-authored-by: zord.lack.net --- ...BSASMssr.js => LayeredGraph3D-BFszTRNF.js} | 2 +- .../{index-BIpkr91b.js => index-vCx0pAT3.js} | 24 +++++++-------- src/loadpath/static/index.html | 2 +- tests/e2e/test_ui_flows.py | 26 +++++++++++++---- ui/src/graphEdges.test.ts | 29 +++++++++++++++++-- ui/src/graphEdges.ts | 19 ++++++++++-- 6 files changed, 78 insertions(+), 24 deletions(-) rename src/loadpath/static/assets/{LayeredGraph3D-BSASMssr.js => LayeredGraph3D-BFszTRNF.js} (99%) rename src/loadpath/static/assets/{index-BIpkr91b.js => index-vCx0pAT3.js} (69%) diff --git a/src/loadpath/static/assets/LayeredGraph3D-BSASMssr.js b/src/loadpath/static/assets/LayeredGraph3D-BFszTRNF.js similarity index 99% rename from src/loadpath/static/assets/LayeredGraph3D-BSASMssr.js rename to src/loadpath/static/assets/LayeredGraph3D-BFszTRNF.js index 6c2aa73..ed965ae 100644 --- a/src/loadpath/static/assets/LayeredGraph3D-BSASMssr.js +++ b/src/loadpath/static/assets/LayeredGraph3D-BFszTRNF.js @@ -1,4 +1,4 @@ -import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-BIpkr91b.js";/** +import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-vCx0pAT3.js";/** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT diff --git a/src/loadpath/static/assets/index-BIpkr91b.js b/src/loadpath/static/assets/index-vCx0pAT3.js similarity index 69% rename from src/loadpath/static/assets/index-BIpkr91b.js rename to src/loadpath/static/assets/index-vCx0pAT3.js index 5b4e9fe..c69088b 100644 --- a/src/loadpath/static/assets/index-BIpkr91b.js +++ b/src/loadpath/static/assets/index-vCx0pAT3.js @@ -1,4 +1,4 @@ -(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function kp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Tu={exports:{}},Uo={},Lu={exports:{}},Re={};/** +(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function Np(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Tu={exports:{}},Uo={},Lu={exports:{}},Re={};/** * @license React * react.production.min.js * @@ -6,7 +6,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var qf;function e0(){if(qf)return Re;qf=1;var t=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),v=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),y=Symbol.iterator;function m(I){return I===null||typeof I!="object"?null:(I=y&&I[y]||I["@@iterator"],typeof I=="function"?I:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,j={};function b(I,z,ie){this.props=I,this.context=z,this.refs=j,this.updater=ie||_}b.prototype.isReactComponent={},b.prototype.setState=function(I,z){if(typeof I!="object"&&typeof I!="function"&&I!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,I,z,"setState")},b.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function E(){}E.prototype=b.prototype;function R(I,z,ie){this.props=I,this.context=z,this.refs=j,this.updater=ie||_}var w=R.prototype=new E;w.constructor=R,k(w,b.prototype),w.isPureReactComponent=!0;var N=Array.isArray,A=Object.prototype.hasOwnProperty,$={current:null},F={key:!0,ref:!0,__self:!0,__source:!0};function G(I,z,ie){var oe,fe={},he=null,pe=null;if(z!=null)for(oe in z.ref!==void 0&&(pe=z.ref),z.key!==void 0&&(he=""+z.key),z)A.call(z,oe)&&!F.hasOwnProperty(oe)&&(fe[oe]=z[oe]);var Z=arguments.length-2;if(Z===1)fe.children=ie;else if(1>>1,z=M[I];if(0>>1;Ia(fe,H))hea(pe,fe)?(M[I]=pe,M[he]=H,I=he):(M[I]=fe,M[oe]=H,I=oe);else if(hea(pe,H))M[I]=pe,M[he]=H,I=he;else break e}}return D}function a(M,D){var H=M.sortIndex-D.sortIndex;return H!==0?H:M.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,h=c.now();t.unstable_now=function(){return c.now()-h}}var p=[],v=[],x=1,y=null,m=3,_=!1,k=!1,j=!1,b=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(M){for(var D=o(v);D!==null;){if(D.callback===null)s(v);else if(D.startTime<=M)s(v),D.sortIndex=D.expirationTime,r(p,D);else break;D=o(v)}}function N(M){if(j=!1,w(M),!k)if(o(p)!==null)k=!0,W(A);else{var D=o(v);D!==null&&U(N,D.startTime-M)}}function A(M,D){k=!1,j&&(j=!1,E(G),G=-1),_=!0;var H=m;try{for(w(D),y=o(p);y!==null&&(!(y.expirationTime>D)||M&&!ee());){var I=y.callback;if(typeof I=="function"){y.callback=null,m=y.priorityLevel;var z=I(y.expirationTime<=D);D=t.unstable_now(),typeof z=="function"?y.callback=z:y===o(p)&&s(p),w(D)}else s(p);y=o(p)}if(y!==null)var ie=!0;else{var oe=o(v);oe!==null&&U(N,oe.startTime-D),ie=!1}return ie}finally{y=null,m=H,_=!1}}var $=!1,F=null,G=-1,q=5,te=-1;function ee(){return!(t.unstable_now()-teM||125I?(M.sortIndex=H,r(v,M),o(p)===null&&M===o(v)&&(j?(E(G),G=-1):j=!0,U(N,H-I))):(M.sortIndex=z,r(p,M),k||_||(k=!0,W(A))),M},t.unstable_shouldYield=ee,t.unstable_wrapCallback=function(M){var D=m;return function(){var H=m;m=D;try{return M.apply(this,arguments)}finally{m=H}}}})(zu)),zu}var eh;function o0(){return eh||(eh=1,$u.exports=i0()),$u.exports}/** + */var Jf;function o0(){return Jf||(Jf=1,(function(t){function r(M,D){var H=M.length;M.push(D);e:for(;0>>1,z=M[I];if(0>>1;Ia(fe,H))hea(pe,fe)?(M[I]=pe,M[he]=H,I=he):(M[I]=fe,M[oe]=H,I=oe);else if(hea(pe,H))M[I]=pe,M[he]=H,I=he;else break e}}return D}function a(M,D){var H=M.sortIndex-D.sortIndex;return H!==0?H:M.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,h=c.now();t.unstable_now=function(){return c.now()-h}}var p=[],v=[],x=1,y=null,m=3,_=!1,k=!1,j=!1,b=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(M){for(var D=o(v);D!==null;){if(D.callback===null)s(v);else if(D.startTime<=M)s(v),D.sortIndex=D.expirationTime,r(p,D);else break;D=o(v)}}function N(M){if(j=!1,w(M),!k)if(o(p)!==null)k=!0,W(A);else{var D=o(v);D!==null&&U(N,D.startTime-M)}}function A(M,D){k=!1,j&&(j=!1,E(G),G=-1),_=!0;var H=m;try{for(w(D),y=o(p);y!==null&&(!(y.expirationTime>D)||M&&!ee());){var I=y.callback;if(typeof I=="function"){y.callback=null,m=y.priorityLevel;var z=I(y.expirationTime<=D);D=t.unstable_now(),typeof z=="function"?y.callback=z:y===o(p)&&s(p),w(D)}else s(p);y=o(p)}if(y!==null)var ie=!0;else{var oe=o(v);oe!==null&&U(N,oe.startTime-D),ie=!1}return ie}finally{y=null,m=H,_=!1}}var $=!1,F=null,G=-1,q=5,te=-1;function ee(){return!(t.unstable_now()-teM||125I?(M.sortIndex=H,r(v,M),o(p)===null&&M===o(v)&&(j?(E(G),G=-1):j=!0,U(N,H-I))):(M.sortIndex=z,r(p,M),k||_||(k=!0,W(A))),M},t.unstable_shouldYield=ee,t.unstable_wrapCallback=function(M){var D=m;return function(){var H=m;m=D;try{return M.apply(this,arguments)}finally{m=H}}}})(zu)),zu}var eh;function s0(){return eh||(eh=1,$u.exports=o0()),$u.exports}/** * @license React * react-dom.production.min.js * @@ -30,14 +30,14 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var th;function s0(){if(th)return zt;th=1;var t=us(),r=o0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,v=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,x={},y={};function m(e){return p.call(y,e)?!0:p.call(x,e)?!1:v.test(e)?y[e]=!0:(x[e]=!0,!1)}function _(e,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function k(e,n,i,l){if(n===null||typeof n>"u"||_(e,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function j(e,n,i,l,f,g,S){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=f,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=g,this.removeEmptyString=S}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){b[e]=new j(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];b[n]=new j(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){b[e]=new j(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){b[e]=new j(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){b[e]=new j(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){b[e]=new j(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){b[e]=new j(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){b[e]=new j(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){b[e]=new j(e,5,!1,e.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function R(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){b[e]=new j(e,1,!1,e.toLowerCase(),null,!1,!1)}),b.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){b[e]=new j(e,1,!1,e.toLowerCase(),null,!0,!0)});function w(e,n,i,l){var f=b.hasOwnProperty(n)?b[n]:null;(f!==null?f.type!==0:l||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,v=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,x={},y={};function m(e){return p.call(y,e)?!0:p.call(x,e)?!1:v.test(e)?y[e]=!0:(x[e]=!0,!1)}function _(e,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function k(e,n,i,l){if(n===null||typeof n>"u"||_(e,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function j(e,n,i,l,f,g,S){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=f,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=g,this.removeEmptyString=S}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){b[e]=new j(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];b[n]=new j(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){b[e]=new j(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){b[e]=new j(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){b[e]=new j(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){b[e]=new j(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){b[e]=new j(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){b[e]=new j(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){b[e]=new j(e,5,!1,e.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function R(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){b[e]=new j(e,1,!1,e.toLowerCase(),null,!1,!1)}),b.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){b[e]=new j(e,1,!1,e.toLowerCase(),null,!0,!0)});function w(e,n,i,l){var f=b.hasOwnProperty(n)?b[n]:null;(f!==null?f.type!==0:l||!(2T||f[S]!==g[T]){var O=` -`+f[S].replace(" at new "," at ");return e.displayName&&O.includes("")&&(O=O.replace("",e.displayName)),O}while(1<=S&&0<=T);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?z(e):""}function fe(e){switch(e.tag){case 5:return z(e.type);case 16:return z("Lazy");case 13:return z("Suspense");case 19:return z("SuspenseList");case 0:case 2:case 15:return e=oe(e.type,!1),e;case 11:return e=oe(e.type.render,!1),e;case 1:return e=oe(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case F:return"Fragment";case $:return"Portal";case q:return"Profiler";case G:return"StrictMode";case K:return"Suspense";case C:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ee:return(e.displayName||"Context")+".Consumer";case te:return(e._context.displayName||"Context")+".Provider";case ne:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case W:n=e._payload,e=e._init;try{return he(e(n))}catch{}}return null}function pe(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===G?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Z(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=se(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function ke(e){e._valueTracker||(e._valueTracker=me(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=se(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function re(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return H({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Z(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Te(e,n){n=n.checked,n!=null&&w(e,"checked",n,!1)}function $e(e,n){Te(e,n);var i=Z(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?lt(e,n.type,i):n.hasOwnProperty("defaultValue")&<(e,n.type,Z(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function st(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function lt(e,n,i){(n!=="number"||re(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var at=Array.isArray;function Ge(e,n,i,l){if(e=e.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=Je.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ot(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var xn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},oo=["Webkit","ms","Moz","O"];Object.keys(xn).forEach(function(e){oo.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),xn[n]=xn[e]})});function $n(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||xn.hasOwnProperty(e)&&xn[e]?(""+n).trim():n+"px"}function vi(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=$n(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,f):e[i]=f}}var or=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function $r(e,n){if(n){if(or[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function zn(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var zr=null;function sr(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var lr=null,Ft=null,ct=null;function Dn(e){if(e=Po(e)){if(typeof lr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=Is(n),lr(e.stateNode,e.type,n))}}function On(e){Ft?ct?ct.push(e):ct=[e]:Ft=e}function wn(){if(Ft){var e=Ft,n=ct;if(ct=Ft=null,Dn(e),n)for(e=0;e>>=0,e===0?32:31-(uo(e)/Ur|0)|0}var Wn=64,Un=4194304;function bn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Bt(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,f=e.suspendedLanes,g=e.pingedLanes,S=i&268435455;if(S!==0){var T=S&~f;T!==0?l=bn(T):(g&=S,g!==0&&(l=bn(g)))}else S=i&~f,S!==0?l=bn(S):g!==0&&(l=bn(g));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,g=n&-n,f>=g||f===16&&(g&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function En(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Et(n),e[n]=i}function co(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=_o),Hc=" ",Bc=!1;function Vc(e,n){switch(e){case"keyup":return qm.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var bi=!1;function Qm(e,n){switch(e){case"compositionend":return Wc(n);case"keypress":return n.which!==32?null:(Bc=!0,Hc);case"textInput":return e=n.data,e===Hc&&Bc?null:e;default:return null}}function Zm(e,n){if(bi)return e==="compositionend"||!ha&&Vc(e,n)?(e=Ac(),ws=la=gr=null,bi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Qc(i)}}function Jc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Jc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function ed(){for(var e=window,n=re();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=re(e.document)}return n}function ma(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function ly(e){var n=ed(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Jc(i.ownerDocument.documentElement,i)){if(l!==null&&ma(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var f=i.textContent.length,g=Math.min(l.start,f);l=l.end===void 0?g:Math.min(l.end,f),!e.extend&&g>l&&(f=l,l=g,g=f),f=Zc(i,g);var S=Zc(i,l);f&&S&&(e.rangeCount!==1||e.anchorNode!==f.node||e.anchorOffset!==f.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),e.removeAllRanges(),g>l?(e.addRange(n),e.extend(S.node,S.offset)):(n.setEnd(S.node,S.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,Ei=null,ya=null,jo=null,va=!1;function td(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;va||Ei==null||Ei!==re(l)||(l=Ei,"selectionStart"in l&&ma(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),jo&&No(jo,l)||(jo=l,l=Cs(ya,"onSelect"),0Ri||(e.current=Pa[Ri],Pa[Ri]=null,Ri--)}function Be(e,n){Ri++,Pa[Ri]=e.current,e.current=n}var xr={},St=vr(xr),Rt=vr(!1),Qr=xr;function Ti(e,n){var i=e.type.contextTypes;if(!i)return xr;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in i)f[g]=n[g];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=f),f}function Tt(e){return e=e.childContextTypes,e!=null}function Rs(){Ue(Rt),Ue(St)}function md(e,n,i){if(St.current!==xr)throw Error(o(168));Be(St,n),Be(Rt,i)}function yd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,pe(e)||"Unknown",f));return H({},i,l)}function Ts(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||xr,Qr=St.current,Be(St,e),Be(Rt,Rt.current),!0}function vd(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=yd(e,n,Qr),l.__reactInternalMemoizedMergedChildContext=e,Ue(Rt),Ue(St),Be(St,e)):Ue(Rt),Be(Rt,i)}var qn=null,Ls=!1,Ia=!1;function xd(e){qn===null?qn=[e]:qn.push(e)}function xy(e){Ls=!0,xd(e)}function wr(){if(!Ia&&qn!==null){Ia=!0;var e=0,n=Fe;try{var i=qn;for(Fe=1;e>=S,f-=S,Kn=1<<32-Et(n)+f|i<Ce?(pt=Ee,Ee=null):pt=Ee.sibling;var Oe=le(X,Ee,Q[Ce],de);if(Oe===null){Ee===null&&(Ee=pt);break}e&&Ee&&Oe.alternate===null&&n(X,Ee),B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe,Ee=pt}if(Ce===Q.length)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;CeCe?(pt=Ee,Ee=null):pt=Ee.sibling;var Mr=le(X,Ee,Oe.value,de);if(Mr===null){Ee===null&&(Ee=pt);break}e&&Ee&&Mr.alternate===null&&n(X,Ee),B=g(Mr,B,Ce),be===null?_e=Mr:be.sibling=Mr,be=Mr,Ee=pt}if(Oe.done)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;!Oe.done;Ce++,Oe=Q.next())Oe=ue(X,Oe.value,de),Oe!==null&&(B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return Xe&&Jr(X,Ce),_e}for(Ee=l(X,Ee);!Oe.done;Ce++,Oe=Q.next())Oe=ge(Ee,X,Ce,Oe.value,de),Oe!==null&&(e&&Oe.alternate!==null&&Ee.delete(Oe.key===null?Ce:Oe.key),B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return e&&Ee.forEach(function(Jy){return n(X,Jy)}),Xe&&Jr(X,Ce),_e}function et(X,B,Q,de){if(typeof Q=="object"&&Q!==null&&Q.type===F&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case A:e:{for(var _e=Q.key,be=B;be!==null;){if(be.key===_e){if(_e=Q.type,_e===F){if(be.tag===7){i(X,be.sibling),B=f(be,Q.props.children),B.return=X,X=B;break e}}else if(be.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===W&&jd(_e)===be.type){i(X,be.sibling),B=f(be,Q.props),B.ref=Io(X,be,Q),B.return=X,X=B;break e}i(X,be);break}else n(X,be);be=be.sibling}Q.type===F?(B=li(Q.props.children,X.mode,de,Q.key),B.return=X,X=B):(de=al(Q.type,Q.key,Q.props,null,X.mode,de),de.ref=Io(X,B,Q),de.return=X,X=de)}return S(X);case $:e:{for(be=Q.key;B!==null;){if(B.key===be)if(B.tag===4&&B.stateNode.containerInfo===Q.containerInfo&&B.stateNode.implementation===Q.implementation){i(X,B.sibling),B=f(B,Q.children||[]),B.return=X,X=B;break e}else{i(X,B);break}else n(X,B);B=B.sibling}B=Cu(Q,X.mode,de),B.return=X,X=B}return S(X);case W:return be=Q._init,et(X,B,be(Q._payload),de)}if(at(Q))return xe(X,B,Q,de);if(D(Q))return we(X,B,Q,de);Ds(X,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"?(Q=""+Q,B!==null&&B.tag===6?(i(X,B.sibling),B=f(B,Q),B.return=X,X=B):(i(X,B),B=Eu(Q,X.mode,de),B.return=X,X=B),S(X)):i(X,B)}return et}var zi=bd(!0),Ed=bd(!1),Os=vr(null),Fs=null,Di=null,za=null;function Da(){za=Di=Fs=null}function Oa(e){var n=Os.current;Ue(Os),e._currentValue=n}function Fa(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function Oi(e,n){Fs=e,za=Di=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Lt=!0),e.firstContext=null)}function Zt(e){var n=e._currentValue;if(za!==e)if(e={context:e,memoizedValue:n,next:null},Di===null){if(Fs===null)throw Error(o(308));Di=e,Fs.dependencies={lanes:0,firstContext:e}}else Di=Di.next=e;return n}var ei=null;function Ha(e){ei===null?ei=[e]:ei.push(e)}function Cd(e,n,i,l){var f=n.interleaved;return f===null?(i.next=i,Ha(n)):(i.next=f.next,f.next=i),n.interleaved=i,Zn(e,l)}function Zn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var _r=!1;function Ba(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Md(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Jn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Sr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(ze&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,Zn(e,i)}return f=l.interleaved,f===null?(n.next=n,Ha(l)):(n.next=f.next,f.next=n),l.interleaved=n,Zn(e,i)}function Hs(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}function Pd(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var S={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?f=g=S:g=g.next=S,i=i.next}while(i!==null);g===null?f=g=n:g=g.next=n}else f=g=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function Bs(e,n,i,l){var f=e.updateQueue;_r=!1;var g=f.firstBaseUpdate,S=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,J=O.next;O.next=null,S===null?g=J:S.next=J,S=O;var ae=e.alternate;ae!==null&&(ae=ae.updateQueue,T=ae.lastBaseUpdate,T!==S&&(T===null?ae.firstBaseUpdate=J:T.next=J,ae.lastBaseUpdate=O))}if(g!==null){var ue=f.baseState;S=0,ae=J=O=null,T=g;do{var le=T.lane,ge=T.eventTime;if((l&le)===le){ae!==null&&(ae=ae.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var xe=e,we=T;switch(le=n,ge=i,we.tag){case 1:if(xe=we.payload,typeof xe=="function"){ue=xe.call(ge,ue,le);break e}ue=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=we.payload,le=typeof xe=="function"?xe.call(ge,ue,le):xe,le==null)break e;ue=H({},ue,le);break e;case 2:_r=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,le=f.effects,le===null?f.effects=[T]:le.push(T))}else ge={eventTime:ge,lane:le,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ae===null?(J=ae=ge,O=ue):ae=ae.next=ge,S|=le;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;le=T,T=le.next,le.next=null,f.lastBaseUpdate=le,f.shared.pending=null}}while(!0);if(ae===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=J,f.lastBaseUpdate=ae,n=f.shared.interleaved,n!==null){f=n;do S|=f.lane,f=f.next;while(f!==n)}else g===null&&(f.shared.lanes=0);ri|=S,e.lanes=S,e.memoizedState=ue}}function Id(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=Ga.transition;Ga.transition={};try{e(!1),n()}finally{Fe=i,Ga.transition=l}}function Kd(){return Jt().memoizedState}function ky(e,n,i){var l=br(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},Qd(e))Zd(n,i);else if(i=Cd(e,n,i,l),i!==null){var f=Mt();dn(i,e,l,f),Jd(i,n,l)}}function Ny(e,n,i){var l=br(e),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(Qd(e))Zd(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,T=g(S,i);if(f.hasEagerState=!0,f.eagerState=T,sn(T,S)){var O=n.interleaved;O===null?(f.next=f,Ha(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=Cd(e,n,f,l),i!==null&&(f=Mt(),dn(i,e,l,f),Jd(i,n,l))}}function Qd(e){var n=e.alternate;return e===Ke||n!==null&&n===Ke}function Zd(e,n){Ao=Us=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Jd(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}var Xs={readContext:Zt,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},jy={readContext:Zt,useCallback:function(e,n){return Pn().memoizedState=[e,n===void 0?null:n],e},useContext:Zt,useEffect:Bd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Ys(4194308,4,Ud.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Ys(4194308,4,e,n)},useInsertionEffect:function(e,n){return Ys(4,2,e,n)},useMemo:function(e,n){var i=Pn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=Pn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=ky.bind(null,Ke,e),[l.memoizedState,e]},useRef:function(e){var n=Pn();return e={current:e},n.memoizedState=e},useState:Fd,useDebugValue:eu,useDeferredValue:function(e){return Pn().memoizedState=e},useTransition:function(){var e=Fd(!1),n=e[0];return e=Sy.bind(null,e[1]),Pn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=Ke,f=Pn();if(Xe){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ht===null)throw Error(o(349));(ni&30)!==0||Ad(l,n,i)}f.memoizedState=i;var g={value:i,getSnapshot:n};return f.queue=g,Bd(zd.bind(null,l,g,e),[e]),l.flags|=2048,Do(9,$d.bind(null,l,g,i,n),void 0,null),i},useId:function(){var e=Pn(),n=ht.identifierPrefix;if(Xe){var i=Qn,l=Kn;i=(l&~(1<<32-Et(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=$o++,0")&&(O=O.replace("",e.displayName)),O}while(1<=S&&0<=T);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?z(e):""}function fe(e){switch(e.tag){case 5:return z(e.type);case 16:return z("Lazy");case 13:return z("Suspense");case 19:return z("SuspenseList");case 0:case 2:case 15:return e=oe(e.type,!1),e;case 11:return e=oe(e.type.render,!1),e;case 1:return e=oe(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case F:return"Fragment";case $:return"Portal";case q:return"Profiler";case G:return"StrictMode";case K:return"Suspense";case C:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ee:return(e.displayName||"Context")+".Consumer";case te:return(e._context.displayName||"Context")+".Provider";case ne:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case W:n=e._payload,e=e._init;try{return he(e(n))}catch{}}return null}function pe(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===G?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Z(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=se(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function ke(e){e._valueTracker||(e._valueTracker=me(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=se(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function re(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return H({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Z(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Te(e,n){n=n.checked,n!=null&&w(e,"checked",n,!1)}function $e(e,n){Te(e,n);var i=Z(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?lt(e,n.type,i):n.hasOwnProperty("defaultValue")&<(e,n.type,Z(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function st(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function lt(e,n,i){(n!=="number"||re(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var at=Array.isArray;function Ge(e,n,i,l){if(e=e.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=Je.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ot(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var xn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},oo=["Webkit","ms","Moz","O"];Object.keys(xn).forEach(function(e){oo.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),xn[n]=xn[e]})});function $n(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||xn.hasOwnProperty(e)&&xn[e]?(""+n).trim():n+"px"}function vi(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=$n(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,f):e[i]=f}}var or=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function $r(e,n){if(n){if(or[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function zn(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var zr=null;function sr(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var lr=null,Ft=null,ct=null;function Dn(e){if(e=Po(e)){if(typeof lr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=Is(n),lr(e.stateNode,e.type,n))}}function On(e){Ft?ct?ct.push(e):ct=[e]:Ft=e}function wn(){if(Ft){var e=Ft,n=ct;if(ct=Ft=null,Dn(e),n)for(e=0;e>>=0,e===0?32:31-(uo(e)/Ur|0)|0}var Wn=64,Un=4194304;function bn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Bt(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,f=e.suspendedLanes,g=e.pingedLanes,S=i&268435455;if(S!==0){var T=S&~f;T!==0?l=bn(T):(g&=S,g!==0&&(l=bn(g)))}else S=i&~f,S!==0?l=bn(S):g!==0&&(l=bn(g));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,g=n&-n,f>=g||f===16&&(g&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function En(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Et(n),e[n]=i}function co(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=_o),Hc=" ",Bc=!1;function Vc(e,n){switch(e){case"keyup":return Km.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var bi=!1;function Zm(e,n){switch(e){case"compositionend":return Wc(n);case"keypress":return n.which!==32?null:(Bc=!0,Hc);case"textInput":return e=n.data,e===Hc&&Bc?null:e;default:return null}}function Jm(e,n){if(bi)return e==="compositionend"||!ha&&Vc(e,n)?(e=Ac(),ws=la=gr=null,bi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Qc(i)}}function Jc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Jc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function ed(){for(var e=window,n=re();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=re(e.document)}return n}function ma(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function ay(e){var n=ed(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Jc(i.ownerDocument.documentElement,i)){if(l!==null&&ma(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var f=i.textContent.length,g=Math.min(l.start,f);l=l.end===void 0?g:Math.min(l.end,f),!e.extend&&g>l&&(f=l,l=g,g=f),f=Zc(i,g);var S=Zc(i,l);f&&S&&(e.rangeCount!==1||e.anchorNode!==f.node||e.anchorOffset!==f.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),e.removeAllRanges(),g>l?(e.addRange(n),e.extend(S.node,S.offset)):(n.setEnd(S.node,S.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,Ei=null,ya=null,jo=null,va=!1;function td(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;va||Ei==null||Ei!==re(l)||(l=Ei,"selectionStart"in l&&ma(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),jo&&No(jo,l)||(jo=l,l=Cs(ya,"onSelect"),0Ri||(e.current=Pa[Ri],Pa[Ri]=null,Ri--)}function Be(e,n){Ri++,Pa[Ri]=e.current,e.current=n}var xr={},St=vr(xr),Rt=vr(!1),Qr=xr;function Ti(e,n){var i=e.type.contextTypes;if(!i)return xr;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in i)f[g]=n[g];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=f),f}function Tt(e){return e=e.childContextTypes,e!=null}function Rs(){Ue(Rt),Ue(St)}function md(e,n,i){if(St.current!==xr)throw Error(o(168));Be(St,n),Be(Rt,i)}function yd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,pe(e)||"Unknown",f));return H({},i,l)}function Ts(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||xr,Qr=St.current,Be(St,e),Be(Rt,Rt.current),!0}function vd(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=yd(e,n,Qr),l.__reactInternalMemoizedMergedChildContext=e,Ue(Rt),Ue(St),Be(St,e)):Ue(Rt),Be(Rt,i)}var qn=null,Ls=!1,Ia=!1;function xd(e){qn===null?qn=[e]:qn.push(e)}function wy(e){Ls=!0,xd(e)}function wr(){if(!Ia&&qn!==null){Ia=!0;var e=0,n=Fe;try{var i=qn;for(Fe=1;e>=S,f-=S,Kn=1<<32-Et(n)+f|i<Ce?(pt=Ee,Ee=null):pt=Ee.sibling;var Oe=le(X,Ee,Q[Ce],de);if(Oe===null){Ee===null&&(Ee=pt);break}e&&Ee&&Oe.alternate===null&&n(X,Ee),B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe,Ee=pt}if(Ce===Q.length)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;CeCe?(pt=Ee,Ee=null):pt=Ee.sibling;var Mr=le(X,Ee,Oe.value,de);if(Mr===null){Ee===null&&(Ee=pt);break}e&&Ee&&Mr.alternate===null&&n(X,Ee),B=g(Mr,B,Ce),be===null?_e=Mr:be.sibling=Mr,be=Mr,Ee=pt}if(Oe.done)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;!Oe.done;Ce++,Oe=Q.next())Oe=ue(X,Oe.value,de),Oe!==null&&(B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return Xe&&Jr(X,Ce),_e}for(Ee=l(X,Ee);!Oe.done;Ce++,Oe=Q.next())Oe=ge(Ee,X,Ce,Oe.value,de),Oe!==null&&(e&&Oe.alternate!==null&&Ee.delete(Oe.key===null?Ce:Oe.key),B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return e&&Ee.forEach(function(e0){return n(X,e0)}),Xe&&Jr(X,Ce),_e}function et(X,B,Q,de){if(typeof Q=="object"&&Q!==null&&Q.type===F&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case A:e:{for(var _e=Q.key,be=B;be!==null;){if(be.key===_e){if(_e=Q.type,_e===F){if(be.tag===7){i(X,be.sibling),B=f(be,Q.props.children),B.return=X,X=B;break e}}else if(be.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===W&&jd(_e)===be.type){i(X,be.sibling),B=f(be,Q.props),B.ref=Io(X,be,Q),B.return=X,X=B;break e}i(X,be);break}else n(X,be);be=be.sibling}Q.type===F?(B=li(Q.props.children,X.mode,de,Q.key),B.return=X,X=B):(de=al(Q.type,Q.key,Q.props,null,X.mode,de),de.ref=Io(X,B,Q),de.return=X,X=de)}return S(X);case $:e:{for(be=Q.key;B!==null;){if(B.key===be)if(B.tag===4&&B.stateNode.containerInfo===Q.containerInfo&&B.stateNode.implementation===Q.implementation){i(X,B.sibling),B=f(B,Q.children||[]),B.return=X,X=B;break e}else{i(X,B);break}else n(X,B);B=B.sibling}B=Cu(Q,X.mode,de),B.return=X,X=B}return S(X);case W:return be=Q._init,et(X,B,be(Q._payload),de)}if(at(Q))return xe(X,B,Q,de);if(D(Q))return we(X,B,Q,de);Ds(X,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"?(Q=""+Q,B!==null&&B.tag===6?(i(X,B.sibling),B=f(B,Q),B.return=X,X=B):(i(X,B),B=Eu(Q,X.mode,de),B.return=X,X=B),S(X)):i(X,B)}return et}var zi=bd(!0),Ed=bd(!1),Os=vr(null),Fs=null,Di=null,za=null;function Da(){za=Di=Fs=null}function Oa(e){var n=Os.current;Ue(Os),e._currentValue=n}function Fa(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function Oi(e,n){Fs=e,za=Di=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Lt=!0),e.firstContext=null)}function Zt(e){var n=e._currentValue;if(za!==e)if(e={context:e,memoizedValue:n,next:null},Di===null){if(Fs===null)throw Error(o(308));Di=e,Fs.dependencies={lanes:0,firstContext:e}}else Di=Di.next=e;return n}var ei=null;function Ha(e){ei===null?ei=[e]:ei.push(e)}function Cd(e,n,i,l){var f=n.interleaved;return f===null?(i.next=i,Ha(n)):(i.next=f.next,f.next=i),n.interleaved=i,Zn(e,l)}function Zn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var _r=!1;function Ba(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Md(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Jn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Sr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(ze&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,Zn(e,i)}return f=l.interleaved,f===null?(n.next=n,Ha(l)):(n.next=f.next,f.next=n),l.interleaved=n,Zn(e,i)}function Hs(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}function Pd(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var S={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?f=g=S:g=g.next=S,i=i.next}while(i!==null);g===null?f=g=n:g=g.next=n}else f=g=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function Bs(e,n,i,l){var f=e.updateQueue;_r=!1;var g=f.firstBaseUpdate,S=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,J=O.next;O.next=null,S===null?g=J:S.next=J,S=O;var ae=e.alternate;ae!==null&&(ae=ae.updateQueue,T=ae.lastBaseUpdate,T!==S&&(T===null?ae.firstBaseUpdate=J:T.next=J,ae.lastBaseUpdate=O))}if(g!==null){var ue=f.baseState;S=0,ae=J=O=null,T=g;do{var le=T.lane,ge=T.eventTime;if((l&le)===le){ae!==null&&(ae=ae.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var xe=e,we=T;switch(le=n,ge=i,we.tag){case 1:if(xe=we.payload,typeof xe=="function"){ue=xe.call(ge,ue,le);break e}ue=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=we.payload,le=typeof xe=="function"?xe.call(ge,ue,le):xe,le==null)break e;ue=H({},ue,le);break e;case 2:_r=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,le=f.effects,le===null?f.effects=[T]:le.push(T))}else ge={eventTime:ge,lane:le,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ae===null?(J=ae=ge,O=ue):ae=ae.next=ge,S|=le;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;le=T,T=le.next,le.next=null,f.lastBaseUpdate=le,f.shared.pending=null}}while(!0);if(ae===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=J,f.lastBaseUpdate=ae,n=f.shared.interleaved,n!==null){f=n;do S|=f.lane,f=f.next;while(f!==n)}else g===null&&(f.shared.lanes=0);ri|=S,e.lanes=S,e.memoizedState=ue}}function Id(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=Ga.transition;Ga.transition={};try{e(!1),n()}finally{Fe=i,Ga.transition=l}}function Kd(){return Jt().memoizedState}function Ny(e,n,i){var l=br(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},Qd(e))Zd(n,i);else if(i=Cd(e,n,i,l),i!==null){var f=Mt();dn(i,e,l,f),Jd(i,n,l)}}function jy(e,n,i){var l=br(e),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(Qd(e))Zd(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,T=g(S,i);if(f.hasEagerState=!0,f.eagerState=T,sn(T,S)){var O=n.interleaved;O===null?(f.next=f,Ha(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=Cd(e,n,f,l),i!==null&&(f=Mt(),dn(i,e,l,f),Jd(i,n,l))}}function Qd(e){var n=e.alternate;return e===Ke||n!==null&&n===Ke}function Zd(e,n){Ao=Us=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Jd(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}var Xs={readContext:Zt,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},by={readContext:Zt,useCallback:function(e,n){return Pn().memoizedState=[e,n===void 0?null:n],e},useContext:Zt,useEffect:Bd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Ys(4194308,4,Ud.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Ys(4194308,4,e,n)},useInsertionEffect:function(e,n){return Ys(4,2,e,n)},useMemo:function(e,n){var i=Pn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=Pn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=Ny.bind(null,Ke,e),[l.memoizedState,e]},useRef:function(e){var n=Pn();return e={current:e},n.memoizedState=e},useState:Fd,useDebugValue:eu,useDeferredValue:function(e){return Pn().memoizedState=e},useTransition:function(){var e=Fd(!1),n=e[0];return e=ky.bind(null,e[1]),Pn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=Ke,f=Pn();if(Xe){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ht===null)throw Error(o(349));(ni&30)!==0||Ad(l,n,i)}f.memoizedState=i;var g={value:i,getSnapshot:n};return f.queue=g,Bd(zd.bind(null,l,g,e),[e]),l.flags|=2048,Do(9,$d.bind(null,l,g,i,n),void 0,null),i},useId:function(){var e=Pn(),n=ht.identifierPrefix;if(Xe){var i=Qn,l=Kn;i=(l&~(1<<32-Et(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=$o++,0<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=S.createElement(i,{is:l.is}):(e=S.createElement(i),i==="select"&&(S=e,l.multiple?S.multiple=!0:l.size&&(S.size=l.size))):e=S.createElementNS(e,i),e[Cn]=n,e[Mo]=l,wf(e,n,!1,!1),n.stateNode=e;e:{switch(S=zn(i,l),i){case"dialog":We("cancel",e),We("close",e),f=l;break;case"iframe":case"object":case"embed":We("load",e),f=l;break;case"video":case"audio":for(f=0;fWi&&(n.flags|=128,l=!0,Oo(g,!1),n.lanes=4194304)}else{if(!l)if(e=Vs(S),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Oo(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Xe)return Nt(n),null}else 2*Ve()-g.renderingStartTime>Wi&&i!==1073741824&&(n.flags|=128,l=!0,Oo(g,!1),n.lanes=4194304);g.isBackwards?(S.sibling=n.child,n.child=S):(i=g.last,i!==null?i.sibling=S:n.child=S,g.last=S)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(Nt(n),null);case 22:case 23:return Nu(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Yt&1073741824)!==0&&(Nt(n),n.subtreeFlags&6&&(n.flags|=8192)):Nt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function Ty(e,n){switch(Ta(n),n.tag){case 1:return Tt(n.type)&&Rs(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Fi(),Ue(Rt),Ue(St),Ya(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Wa(n),null;case 13:if(Ue(qe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));$i()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Fi(),null;case 10:return Oa(n.type._context),null;case 22:case 23:return Nu(),null;case 24:return null;default:return null}}var Zs=!1,jt=!1,Ly=typeof WeakSet=="function"?WeakSet:Set,ye=null;function Bi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Ze(e,n,l)}else i.current=null}function fu(e,n,i){try{i()}catch(l){Ze(e,n,l)}}var kf=!1;function Ay(e,n){if(Na=vs,e=ed(),ma(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,g=l.focusNode;l=l.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var S=0,T=-1,O=-1,J=0,ae=0,ue=e,le=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=S+f),ue!==g||l!==0&&ue.nodeType!==3||(O=S+l),ue.nodeType===3&&(S+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)le=ue,ue=ge;for(;;){if(ue===e)break t;if(le===i&&++J===f&&(T=S),le===g&&++ae===l&&(O=S),(ge=ue.nextSibling)!==null)break;ue=le,le=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(ja={focusedElem:e,selectionRange:i},vs=!1,ye=n;ye!==null;)if(n=ye,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ye=e;else for(;ye!==null;){n=ye;try{var xe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var we=xe.memoizedProps,et=xe.memoizedState,X=n.stateNode,B=X.getSnapshotBeforeUpdate(n.elementType===n.type?we:an(n.type,we),et);X.__reactInternalSnapshotBeforeUpdate=B}break;case 3:var Q=n.stateNode.containerInfo;Q.nodeType===1?Q.textContent="":Q.nodeType===9&&Q.documentElement&&Q.removeChild(Q.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(de){Ze(n,n.return,de)}if(e=n.sibling,e!==null){e.return=n.return,ye=e;break}ye=n.return}return xe=kf,kf=!1,xe}function Fo(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&e)===e){var g=f.destroy;f.destroy=void 0,g!==void 0&&fu(n,i,g)}f=f.next}while(f!==l)}}function Js(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function hu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function Nf(e){var n=e.alternate;n!==null&&(e.alternate=null,Nf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[Cn],delete n[Mo],delete n[Ma],delete n[yy],delete n[vy])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function jf(e){return e.tag===5||e.tag===3||e.tag===4}function bf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||jf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function pu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=Ps));else if(l!==4&&(e=e.child,e!==null))for(pu(e,n,i),e=e.sibling;e!==null;)pu(e,n,i),e=e.sibling}function gu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(gu(e,n,i),e=e.sibling;e!==null;)gu(e,n,i),e=e.sibling}var vt=null,un=!1;function kr(e,n,i){for(i=i.child;i!==null;)Ef(e,n,i),i=i.sibling}function Ef(e,n,i){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(Vn,i)}catch{}switch(i.tag){case 5:jt||Bi(i,n);case 6:var l=vt,f=un;vt=null,kr(e,n,i),vt=l,un=f,vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):vt.removeChild(i.stateNode));break;case 18:vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?Ca(e.parentNode,i):e.nodeType===1&&Ca(e,i),vo(e)):Ca(vt,i.stateNode));break;case 4:l=vt,f=un,vt=i.stateNode.containerInfo,un=!0,kr(e,n,i),vt=l,un=f;break;case 0:case 11:case 14:case 15:if(!jt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var g=f,S=g.destroy;g=g.tag,S!==void 0&&((g&2)!==0||(g&4)!==0)&&fu(i,n,S),f=f.next}while(f!==l)}kr(e,n,i);break;case 1:if(!jt&&(Bi(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Ze(i,n,T)}kr(e,n,i);break;case 21:kr(e,n,i);break;case 22:i.mode&1?(jt=(l=jt)||i.memoizedState!==null,kr(e,n,i),jt=l):kr(e,n,i);break;default:kr(e,n,i)}}function Cf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Ly),n.forEach(function(l){var f=Wy.bind(null,e,l);i.has(l)||(i.add(l),l.then(f,f))})}}function cn(e,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=S),l&=~g}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*zy(l/1960))-l,10e?16:e,jr===null)var l=!1;else{if(e=jr,jr=null,il=0,(ze&6)!==0)throw Error(o(331));var f=ze;for(ze|=4,ye=e.current;ye!==null;){var g=ye,S=g.child;if((ye.flags&16)!==0){var T=g.deletions;if(T!==null){for(var O=0;OVe()-vu?oi(e,0):yu|=i),$t(e,n)}function Hf(e,n){n===0&&((e.mode&1)===0?n=1:(n=Un,Un<<=1,(Un&130023424)===0&&(Un=4194304)));var i=Mt();e=Zn(e,n),e!==null&&(En(e,n,i),$t(e,i))}function Vy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Hf(e,i)}function Wy(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Hf(e,i)}var Bf;Bf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Rt.current)Lt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Lt=!1,Iy(e,n,i);Lt=(e.flags&131072)!==0}else Lt=!1,Xe&&(n.flags&1048576)!==0&&wd(n,$s,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Qs(e,n),e=n.pendingProps;var f=Ti(n,St.current);Oi(n,i),f=qa(null,n,l,e,f,i);var g=Ka();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Tt(l)?(g=!0,Ts(n)):g=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Ba(n),f.updater=qs,n.stateNode=f,f._reactInternals=n,nu(n,l,e,i),n=su(null,n,l,!0,g,i)):(n.tag=0,Xe&&g&&Ra(n),Ct(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Qs(e,n),e=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=Yy(l),e=an(l,e),f){case 0:n=ou(null,n,l,e,i);break e;case 1:n=pf(null,n,l,e,i);break e;case 11:n=uf(null,n,l,e,i);break e;case 14:n=cf(null,n,l,an(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),ou(e,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),pf(e,n,l,f,i);case 3:e:{if(gf(n),e===null)throw Error(o(387));l=n.pendingProps,g=n.memoizedState,f=g.element,Md(e,n),Bs(n,l,null,i);var S=n.memoizedState;if(l=S.element,g.isDehydrated)if(g={element:l,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){f=Hi(Error(o(423)),n),n=mf(e,n,l,i,f);break e}else if(l!==f){f=Hi(Error(o(424)),n),n=mf(e,n,l,i,f);break e}else for(Ut=yr(n.stateNode.containerInfo.firstChild),Wt=n,Xe=!0,ln=null,i=Ed(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if($i(),l===f){n=er(e,n,i);break e}Ct(e,n,l,i)}n=n.child}return n;case 5:return Rd(n),e===null&&Aa(n),l=n.type,f=n.pendingProps,g=e!==null?e.memoizedProps:null,S=f.children,ba(l,f)?S=null:g!==null&&ba(l,g)&&(n.flags|=32),hf(e,n),Ct(e,n,S,i),n.child;case 6:return e===null&&Aa(n),null;case 13:return yf(e,n,i);case 4:return Va(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=zi(n,null,l,i):Ct(e,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),uf(e,n,l,f,i);case 7:return Ct(e,n,n.pendingProps,i),n.child;case 8:return Ct(e,n,n.pendingProps.children,i),n.child;case 12:return Ct(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,g=n.memoizedProps,S=f.value,Be(Os,l._currentValue),l._currentValue=S,g!==null)if(sn(g.value,S)){if(g.children===f.children&&!Rt.current){n=er(e,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var T=g.dependencies;if(T!==null){S=g.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(g.tag===1){O=Jn(-1,i&-i),O.tag=2;var J=g.updateQueue;if(J!==null){J=J.shared;var ae=J.pending;ae===null?O.next=O:(O.next=ae.next,ae.next=O),J.pending=O}}g.lanes|=i,O=g.alternate,O!==null&&(O.lanes|=i),Fa(g.return,i,n),T.lanes|=i;break}O=O.next}}else if(g.tag===10)S=g.type===n.type?null:g.child;else if(g.tag===18){if(S=g.return,S===null)throw Error(o(341));S.lanes|=i,T=S.alternate,T!==null&&(T.lanes|=i),Fa(S,i,n),S=g.sibling}else S=g.child;if(S!==null)S.return=g;else for(S=g;S!==null;){if(S===n){S=null;break}if(g=S.sibling,g!==null){g.return=S.return,S=g;break}S=S.return}g=S}Ct(e,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,Oi(n,i),f=Zt(f),l=l(f),n.flags|=1,Ct(e,n,l,i),n.child;case 14:return l=n.type,f=an(l,n.pendingProps),f=an(l.type,f),cf(e,n,l,f,i);case 15:return df(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),Qs(e,n),n.tag=1,Tt(l)?(e=!0,Ts(n)):e=!1,Oi(n,i),tf(n,l,f),nu(n,l,f,i),su(null,n,l,!0,e,i);case 19:return xf(e,n,i);case 22:return ff(e,n,i)}throw Error(o(156,n.tag))};function Vf(e,n){return Hr(e,n)}function Uy(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tn(e,n,i,l){return new Uy(e,n,i,l)}function bu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Yy(e){if(typeof e=="function")return bu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ne)return 11;if(e===V)return 14}return 2}function Cr(e,n){var i=e.alternate;return i===null?(i=tn(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function al(e,n,i,l,f,g){var S=2;if(l=e,typeof e=="function")bu(e)&&(S=1);else if(typeof e=="string")S=5;else e:switch(e){case F:return li(i.children,f,g,n);case G:S=8,f|=8;break;case q:return e=tn(12,i,n,f|2),e.elementType=q,e.lanes=g,e;case K:return e=tn(13,i,n,f),e.elementType=K,e.lanes=g,e;case C:return e=tn(19,i,n,f),e.elementType=C,e.lanes=g,e;case U:return ul(i,f,g,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case te:S=10;break e;case ee:S=9;break e;case ne:S=11;break e;case V:S=14;break e;case W:S=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=tn(S,i,n,f),n.elementType=e,n.type=l,n.lanes=g,n}function li(e,n,i,l){return e=tn(7,e,l,n),e.lanes=i,e}function ul(e,n,i,l){return e=tn(22,e,l,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function Eu(e,n,i){return e=tn(6,e,null,n),e.lanes=i,e}function Cu(e,n,i){return n=tn(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Gy(e,n,i,l,f){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Yn(0),this.expirationTimes=Yn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Yn(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Mu(e,n,i,l,f,g,S,T,O){return e=new Gy(e,n,i,T,O),n===1?(n=1,g===!0&&(n|=8)):n=0,g=tn(3,null,null,n),e.current=g,g.stateNode=e,g.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ba(g),e}function Xy(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),Au.exports=s0(),Au.exports}var rh;function l0(){if(rh)return ml;rh=1;var t=Np();return ml.createRoot=t.createRoot,ml.hydrateRoot=t.hydrateRoot,ml}var a0=l0();function jp(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Ae(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(jp(s,o.statusText||"Request failed"))}return o.json()}const u0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Pe={health:()=>Ae("/api/health"),settings:()=>Ae("/api/settings"),saveSettings:t=>{const r={...t};for(const o of u0)r[o]===""&&delete r[o];return Ae("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ae("/api/repos"),browse:t=>Ae(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ae(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ae("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ae(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Ae(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:(t,r=!0)=>Ae(`/api/architecture?repo_path=${encodeURIComponent(t)}&graph=${r?"1":"0"}`),architectureGraph:t=>Ae(`/api/architecture/graph?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Ae("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Ae("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Ae("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Ae("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Ae("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Ae(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open",s)=>Ae("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o,repo_path:s||null})}),scmRepos:t=>Ae(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ae("/api/oauth/status"),githubOAuthStart:()=>Ae("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ae("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ae("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Ae("/api/oauth/gitlab/start"),oauthDisconnect:t=>Ae("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ae("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})}),reviews:t=>Ae(`/api/reviews?repo_path=${encodeURIComponent(t)}`),getReview:(t,r)=>Ae(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(t)}`),reviewDiff:(t,r,o)=>Ae(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(t)}&other=${encodeURIComponent(o)}`),config:t=>Ae(`/api/config?repo_path=${encodeURIComponent(t)}`),saveConfig:(t,r)=>Ae("/api/config",{method:"PUT",body:JSON.stringify({repo_path:t,...r})}),addWaiver:(t,r,o,s)=>Ae("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:t,rule:r,node:o||null,reason:s||""})}),marks:(t,r)=>Ae(`/api/marks?repo_path=${encodeURIComponent(t)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:t=>Ae(`/api/architecture/health?repo_path=${encodeURIComponent(t)}`),workspaceStatus:t=>Ae(`/api/workspace/status?repo_path=${encodeURIComponent(t)}`),openEditor:(t,r,o,s)=>Ae("/api/open",{method:"POST",body:JSON.stringify({repo_path:t,path:r,line:o||null,editor:s||null})}),exportHtml:t=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:t})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(jp(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(t,r,o,s)=>Ae("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:t,edges:r,source_id:o,target_id:s||null})})};function c0(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):t}function d0({open:t,actions:r,onClose:o}){const[s,a]=L.useState(""),[u,c]=L.useState(0),h=L.useRef(null),p=L.useMemo(()=>c0(r,s),[r,s]);if(L.useEffect(()=>{if(!t)return;a(""),c(0);const y=window.setTimeout(()=>{var m;return(m=h.current)==null?void 0:m.focus()},0);return()=>window.clearTimeout(y)},[t]),L.useEffect(()=>{c(0)},[s]),!t)return null;const v=p[u],x=y=>{y&&(o(),y.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:y=>{y.target===y.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:y=>a(y.target.value),onKeyDown:y=>{y.key==="Escape"?(y.preventDefault(),o()):y.key==="ArrowDown"?(y.preventDefault(),c(m=>Math.min(p.length-1,m+1))):y.key==="ArrowUp"?(y.preventDefault(),c(m=>Math.max(0,m-1))):y.key==="Enter"&&(y.preventDefault(),x(v))}}),d.jsxs("ul",{children:[p.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,p.slice(0,40).map((y,m)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:m===u?"active":"",onMouseEnter:()=>c(m),onClick:()=>x(y),children:[d.jsx("span",{children:y.label}),y.hint?d.jsx("span",{className:"muted",children:y.hint}):null]})},y.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function f0({config:t,busy:r,onSave:o,onWaiver:s}){const[a,u]=L.useState(t),[c,h]=L.useState(t.available_rules[0]||""),[p,v]=L.useState(""),[x,y]=L.useState("");L.useEffect(()=>{u(t)},[t]);const m=Object.entries(a.contexts||{}),_=(R,w,N)=>{const A=a.contexts[R];if(!A)return;const $=F=>F.split(",").map(G=>G.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[R]:{...A,[w]:w==="name"?N:$(N)}}})},k=(R,w)=>{const N=w.trim();if(!N||N===R)return;const{[R]:A,...$}=a.contexts;A&&u({...a,contexts:{...$,[N]:{...A,name:N}}})},j=()=>{let R=1;for(;a.contexts[`context-${R}`];)R+=1;const w=`context-${R}`;u({...a,contexts:{...a.contexts,[w]:{name:w,django_apps:[],react:[],public_api:[],owners:[]}}})},b=R=>{const{[R]:w,...N}=a.contexts;u({...a,contexts:N})},E=R=>{const w=a.rules.includes(R);u({...a,rules:w?a.rules.filter(N=>N!==R):[...a.rules,R]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),m.map(([R,w])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:R})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:R,"data-testid":`config-context-name-${R}`,onBlur:N=>k(R,N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(w.django_apps||[]).join(", "),onChange:N=>_(R,"django_apps",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(w.react||[]).join(", "),onChange:N=>_(R,"react",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(w.public_api||[]).join(", "),onChange:N=>_(R,"public_api",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(w.owners||[]).join(", "),onChange:N=>_(R,"owners",N.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>b(R),children:"Remove context"})]},R)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:j,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(R),onChange:()=>E(R)}),R]},R))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((R,w)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:R.rule}),R.node?` · ${R.node}`:"",R.reason?` — ${R.reason}`:""]},`${R.rule}:${R.node}:${w}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:R=>h(R.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsx("option",{value:R,children:R},R))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:R=>v(R.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:x,onChange:R=>y(R.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,x),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function Zo(t){return t.replaceAll("_"," ")}function h0(t){return t.replaceAll("_"," ")}function io(t){return t.split(".").pop()||t}function ec(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function p0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Tr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function yi({className:t,children:r}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function g0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function m0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function y0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function v0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function x0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function bp({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function w0({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const _0="modulepreload",S0=function(t,r){return new URL(t,r).href},ih={},k0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(x){return Promise.all(x.map(y=>Promise.resolve(y).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),v=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(x=>{if(x=S0(x,s),x in ih)return;ih[x]=!0;const y=x.endsWith(".css"),m=y?'[rel="stylesheet"]':"";if(!!s)for(let j=h.length-1;j>=0;j--){const b=h[j];if(b.href===x&&(!y||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${x}"]${m}`))return;const k=document.createElement("link");if(k.rel=y?"stylesheet":_0,y||(k.as="script"),k.crossOrigin="",k.href=x,v&&k.setAttribute("nonce",v),document.head.appendChild(k),y)return new Promise((j,b)=>{k.addEventListener("load",j),k.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${x}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function nt(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Yl(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}Cl.prototype=Yl.prototype={constructor:Cl,on:function(t,r){var o=this._,s=j0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),sh.hasOwnProperty(r)?{space:sh[r],local:t}:t}function E0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===tc&&r.documentElement.namespaceURI===tc?r.createElement(t):r.createElementNS(o,t)}}function C0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Ep(t){var r=Gl(t);return(r.local?C0:E0)(r)}function M0(){}function pc(t){return t==null?M0:function(){return this.querySelector(t)}}function P0(t){typeof t!="function"&&(t=pc(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=w&&(w=R+1);!(A=b[w])&&++w=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function tv(t){t||(t=nv);function r(y,m){return y&&m?t(y.__data__,m.__data__):!y-!m}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function rv(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function iv(){return Array.from(this)}function ov(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?mv:typeof r=="function"?vv:yv)(t,r,o??"")):Ki(this.node(),t)}function Ki(t,r){return t.style.getPropertyValue(r)||Rp(t).getComputedStyle(t,null).getPropertyValue(r)}function wv(t){return function(){delete this[t]}}function _v(t,r){return function(){this[t]=r}}function Sv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function kv(t,r){return arguments.length>1?this.each((r==null?wv:typeof r=="function"?Sv:_v)(t,r)):this.node()[t]}function Tp(t){return t.trim().split(/^|\s+/)}function gc(t){return t.classList||new Lp(t)}function Lp(t){this._node=t,this._names=Tp(t.getAttribute("class")||"")}Lp.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Ap(t,r){for(var o=gc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function Qv(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function nc(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:v,dispatch:x}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:v,enumerable:!0,configurable:!0},_:{value:x}})}nc.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function lx(t){return!t.ctrlKey&&!t.button}function ax(){return this.parentNode}function ux(t,r){return r??{x:t.x,y:t.y}}function cx(){return navigator.maxTouchPoints||"ontouchstart"in this}function Hp(){var t=lx,r=ax,o=ux,s=cx,a={},u=Yl("start","drag","end"),c=0,h,p,v,x,y=0;function m(N){N.on("mousedown.drag",_).filter(s).on("touchstart.drag",b).on("touchmove.drag",E,sx).on("touchend.drag touchcancel.drag",R).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(N,A){if(!(x||!t.call(this,N,A))){var $=w(this,r.call(this,N,A),N,A,"mouse");$&&(Gt(N.view).on("mousemove.drag",k,Jo).on("mouseup.drag",j,Jo),Op(N.view),Du(N),v=!1,h=N.clientX,p=N.clientY,$("start",N))}}function k(N){if(Xi(N),!v){var A=N.clientX-h,$=N.clientY-p;v=A*A+$*$>y}a.mouse("drag",N)}function j(N){Gt(N.view).on("mousemove.drag mouseup.drag",null),Fp(N.view,v),Xi(N),a.mouse("end",N)}function b(N,A){if(t.call(this,N,A)){var $=N.changedTouches,F=r.call(this,N,A),G=$.length,q,te;for(q=0;q>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?vl(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?vl(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=fx.exec(t))?new Dt(r[1],r[2],r[3],1):(r=hx.exec(t))?new Dt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=px.exec(t))?vl(r[1],r[2],r[3],r[4]):(r=gx.exec(t))?vl(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=mx.exec(t))?hh(r[1],r[2]/100,r[3]/100,1):(r=yx.exec(t))?hh(r[1],r[2]/100,r[3]/100,r[4]):lh.hasOwnProperty(t)?ch(lh[t]):t==="transparent"?new Dt(NaN,NaN,NaN,0):null}function ch(t){return new Dt(t>>16&255,t>>8&255,t&255,1)}function vl(t,r,o,s){return s<=0&&(t=r=o=NaN),new Dt(t,r,o,s)}function wx(t){return t instanceof ds||(t=fi(t)),t?(t=t.rgb(),new Dt(t.r,t.g,t.b,t.opacity)):new Dt}function rc(t,r,o,s){return arguments.length===1?wx(t):new Dt(t,r,o,s??1)}function Dt(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}mc(Dt,rc,Bp(ds,{brighter(t){return t=t==null?Ll:Math.pow(Ll,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?es:Math.pow(es,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Dt(ci(this.r),ci(this.g),ci(this.b),Al(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:dh,formatHex:dh,formatHex8:_x,formatRgb:fh,toString:fh}));function dh(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}`}function _x(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}${ui((isNaN(this.opacity)?1:this.opacity)*255)}`}function fh(){const t=Al(this.opacity);return`${t===1?"rgb(":"rgba("}${ci(this.r)}, ${ci(this.g)}, ${ci(this.b)}${t===1?")":`, ${t})`}`}function Al(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ci(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ui(t){return t=ci(t),(t<16?"0":"")+t.toString(16)}function hh(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new hn(t,r,o,s)}function Vp(t){if(t instanceof hn)return new hn(t.h,t.s,t.l,t.opacity);if(t instanceof ds||(t=fi(t)),!t)return new hn;if(t instanceof hn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new hn(c,h,p,t.opacity)}function Sx(t,r,o,s){return arguments.length===1?Vp(t):new hn(t,r,o,s??1)}function hn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}mc(hn,Sx,Bp(ds,{brighter(t){return t=t==null?Ll:Math.pow(Ll,t),new hn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?es:Math.pow(es,t),new hn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Dt(Ou(t>=240?t-240:t+120,a,s),Ou(t,a,s),Ou(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new hn(ph(this.h),xl(this.s),xl(this.l),Al(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 t=Al(this.opacity);return`${t===1?"hsl(":"hsla("}${ph(this.h)}, ${xl(this.s)*100}%, ${xl(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ph(t){return t=(t||0)%360,t<0?t+360:t}function xl(t){return Math.max(0,Math.min(1,t||0))}function Ou(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const yc=t=>()=>t;function kx(t,r){return function(o){return t+o*r}}function Nx(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function jx(t){return(t=+t)==1?Wp:function(r,o){return o-r?Nx(r,o,t):yc(isNaN(r)?o:r)}}function Wp(t,r){var o=r-t;return o?kx(t,o):yc(isNaN(t)?r:t)}const $l=(function t(r){var o=jx(r);function s(a,u){var c=o((a=rc(a)).r,(u=rc(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),v=Wp(a.opacity,u.opacity);return function(x){return a.r=c(x),a.g=h(x),a.b=p(x),a.opacity=v(x),a+""}}return s.gamma=t,s})(1);function bx(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:Rn(s,a)})),o=Fu.lastIndex;return o180?x+=360:x-v>180&&(v+=360),m.push({i:y.push(a(y)+"rotate(",null,s)-2,x:Rn(v,x)})):x&&y.push(a(y)+"rotate("+x+s)}function h(v,x,y,m){v!==x?m.push({i:y.push(a(y)+"skewX(",null,s)-2,x:Rn(v,x)}):x&&y.push(a(y)+"skewX("+x+s)}function p(v,x,y,m,_,k){if(v!==y||x!==m){var j=_.push(a(_)+"scale(",null,",",null,")");k.push({i:j-4,x:Rn(v,y)},{i:j-2,x:Rn(x,m)})}else(y!==1||m!==1)&&_.push(a(_)+"scale("+y+","+m+")")}return function(v,x){var y=[],m=[];return v=t(v),x=t(x),u(v.translateX,v.translateY,x.translateX,x.translateY,y,m),c(v.rotate,x.rotate,y,m),h(v.skewX,x.skewX,y,m),p(v.scaleX,v.scaleY,x.scaleX,x.scaleY,y,m),v=x=null,function(_){for(var k=-1,j=m.length,b;++k=0&&t._call.call(void 0,r),t=t._next;--Qi}function yh(){hi=(Dl=ns.now())+Xl,Qi=Xo=0;try{Hx()}finally{Qi=0,Vx(),hi=0}}function Bx(){var t=ns.now(),r=t-Dl;r>Xp&&(Xl-=r,Dl=t)}function Vx(){for(var t,r=zl,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:zl=o);qo=t,sc(s)}function sc(t){if(!Qi){Xo&&(Xo=clearTimeout(Xo));var r=t-hi;r>24?(t<1/0&&(Xo=setTimeout(yh,t-ns.now()-Xl)),Yo&&(Yo=clearInterval(Yo))):(Yo||(Dl=ns.now(),Yo=setInterval(Bx,Xp)),Qi=1,qp(yh))}}function vh(t,r,o){var s=new Ol;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Wx=Yl("start","end","cancel","interrupt"),Ux=[],Qp=0,xh=1,lc=2,Pl=3,wh=4,ac=5,Il=6;function ql(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;Yx(t,o,{name:r,index:s,group:a,on:Wx,tween:Ux,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Qp})}function xc(t,r){var o=yn(t,r);if(o.state>Qp)throw new Error("too late; already scheduled");return o}function Ln(t,r){var o=yn(t,r);if(o.state>Pl)throw new Error("too late; already running");return o}function yn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Yx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=Kp(u,0,o.time);function u(v){o.state=xh,o.timer.restart(c,o.delay,o.time),o.delay<=v&&c(v-o.delay)}function c(v){var x,y,m,_;if(o.state!==xh)return p();for(x in s)if(_=s[x],_.name===o.name){if(_.state===Pl)return vh(c);_.state===wh?(_.state=Il,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete s[x]):+xlc&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function Sw(t,r,o){var s,a,u=_w(r)?xc:Ln;return function(){var c=u(this,t),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function kw(t,r){var o=this._id;return arguments.length<2?yn(this.node(),o).on.on(t):this.each(Sw(o,t,r))}function Nw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function jw(){return this.on("end.remove",Nw(this._id))}function bw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=pc(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function Qw(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function rr(t,r,o){this.k=t,this.x=r,this.y=o}rr.prototype={constructor:rr,scale:function(t){return t===1?this:new rr(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new rr(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Kl=new rr(1,0,0);tg.prototype=rr.prototype;function tg(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Kl;return t.__zoom}function Hu(t){t.stopImmediatePropagation()}function Go(t){t.preventDefault(),t.stopImmediatePropagation()}function Zw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function Jw(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function _h(){return this.__zoom||Kl}function e1(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function t1(){return navigator.maxTouchPoints||"ontouchstart"in this}function n1(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function ng(){var t=Zw,r=Jw,o=n1,s=e1,a=t1,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=Ml,v=Yl("start","zoom","end"),x,y,m,_=500,k=150,j=0,b=10;function E(C){C.property("__zoom",_h).on("wheel.zoom",G,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",te).filter(a).on("touchstart.zoom",ee).on("touchmove.zoom",ne).on("touchend.zoom touchcancel.zoom",K).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(C,V,W,U){var M=C.selection?C.selection():C;M.property("__zoom",_h),C!==M?A(C,V,W,U):M.interrupt().each(function(){$(this,arguments).event(U).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},E.scaleBy=function(C,V,W,U){E.scaleTo(C,function(){var M=this.__zoom.k,D=typeof V=="function"?V.apply(this,arguments):V;return M*D},W,U)},E.scaleTo=function(C,V,W,U){E.transform(C,function(){var M=r.apply(this,arguments),D=this.__zoom,H=W==null?N(M):typeof W=="function"?W.apply(this,arguments):W,I=D.invert(H),z=typeof V=="function"?V.apply(this,arguments):V;return o(w(R(D,z),H,I),M,c)},W,U)},E.translateBy=function(C,V,W,U){E.transform(C,function(){return o(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),r.apply(this,arguments),c)},null,U)},E.translateTo=function(C,V,W,U,M){E.transform(C,function(){var D=r.apply(this,arguments),H=this.__zoom,I=U==null?N(D):typeof U=="function"?U.apply(this,arguments):U;return o(Kl.translate(I[0],I[1]).scale(H.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),D,c)},U,M)};function R(C,V){return V=Math.max(u[0],Math.min(u[1],V)),V===C.k?C:new rr(V,C.x,C.y)}function w(C,V,W){var U=V[0]-W[0]*C.k,M=V[1]-W[1]*C.k;return U===C.x&&M===C.y?C:new rr(C.k,U,M)}function N(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function A(C,V,W,U){C.on("start.zoom",function(){$(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(U).end()}).tween("zoom",function(){var M=this,D=arguments,H=$(M,D).event(U),I=r.apply(M,D),z=W==null?N(I):typeof W=="function"?W.apply(M,D):W,ie=Math.max(I[1][0]-I[0][0],I[1][1]-I[0][1]),oe=M.__zoom,fe=typeof V=="function"?V.apply(M,D):V,he=p(oe.invert(z).concat(ie/oe.k),fe.invert(z).concat(ie/fe.k));return function(pe){if(pe===1)pe=fe;else{var Z=he(pe),se=ie/Z[2];pe=new rr(se,z[0]-Z[0]*se,z[1]-Z[1]*se)}H.zoom(null,pe)}})}function $(C,V,W){return!W&&C.__zooming||new F(C,V)}function F(C,V){this.that=C,this.args=V,this.active=0,this.sourceEvent=null,this.extent=r.apply(C,V),this.taps=0}F.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,V){return this.mouse&&C!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var V=Gt(this.that).datum();v.call(C,this.that,new Qw(C,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:v}),V)}};function G(C,...V){if(!t.apply(this,arguments))return;var W=$(this,V).event(C),U=this.__zoom,M=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,s.apply(this,arguments)))),D=fn(C);if(W.wheel)(W.mouse[0][0]!==D[0]||W.mouse[0][1]!==D[1])&&(W.mouse[1]=U.invert(W.mouse[0]=D)),clearTimeout(W.wheel);else{if(U.k===M)return;W.mouse=[D,U.invert(D)],Rl(this),W.start()}Go(C),W.wheel=setTimeout(H,k),W.zoom("mouse",o(w(R(U,M),W.mouse[0],W.mouse[1]),W.extent,c));function H(){W.wheel=null,W.end()}}function q(C,...V){if(m||!t.apply(this,arguments))return;var W=C.currentTarget,U=$(this,V,!0).event(C),M=Gt(C.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",ie,!0),D=fn(C,W),H=C.clientX,I=C.clientY;Op(C.view),Hu(C),U.mouse=[D,this.__zoom.invert(D)],Rl(this),U.start();function z(oe){if(Go(oe),!U.moved){var fe=oe.clientX-H,he=oe.clientY-I;U.moved=fe*fe+he*he>j}U.event(oe).zoom("mouse",o(w(U.that.__zoom,U.mouse[0]=fn(oe,W),U.mouse[1]),U.extent,c))}function ie(oe){M.on("mousemove.zoom mouseup.zoom",null),Fp(oe.view,U.moved),Go(oe),U.event(oe).end()}}function te(C,...V){if(t.apply(this,arguments)){var W=this.__zoom,U=fn(C.changedTouches?C.changedTouches[0]:C,this),M=W.invert(U),D=W.k*(C.shiftKey?.5:2),H=o(w(R(W,D),U,M),r.apply(this,V),c);Go(C),h>0?Gt(this).transition().duration(h).call(A,H,U,C):Gt(this).call(E.transform,H,U,C)}}function ee(C,...V){if(t.apply(this,arguments)){var W=C.touches,U=W.length,M=$(this,V,C.changedTouches.length===U).event(C),D,H,I,z;for(Hu(C),H=0;H`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},rs=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],rg=["Enter"," ","Escape"],ig={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Zi;(function(t){t.Strict="strict",t.Loose="loose"})(Zi||(Zi={}));var di;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(di||(di={}));var is;(function(t){t.Partial="partial",t.Full="full"})(is||(is={}));const og={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Lr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Lr||(Lr={}));var os;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(os||(os={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const Sh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function sg(t){return t===null?null:t?"valid":"invalid"}const lg=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,r1=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),_c=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),fs=(t,r=[0,0])=>{const{width:o,height:s}=vn(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},i1=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):_c(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,Ql(a,Fl(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?Zl(s):{x:0,y:0,width:0,height:0}},hs=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=Ql(o,Fl(a)),s=!0)}),s?Zl(o):{x:0,y:0,width:0,height:0}},Sc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,v=r.width/a,x=r.height/a,y=[];for(const m of t.values()){const{measured:_,selectable:k=!0,hidden:j=!1}=m;if(c&&!k||j)continue;const b=_.width??m.width??m.initialWidth??0,E=_.height??m.height??m.initialHeight??0,{x:R,y:w}=m.internals.positionAbsolute,N=dg(h,p,v,x,R,w,b,E),A=b*E,$=u&&N>0;(!m.internals.handleBounds||$||N>=A||m.dragging)&&y.push(m)}return y},o1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function s1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=vn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function l1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const h=s1(t,c),p=hs(h),v=Nc(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(v,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function ag({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),h=c.parentId?o.get(c.parentId):void 0,{x:p,y:v}=h?h.internals.positionAbsolute:{x:0,y:0},x=c.origin??s;let y=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",mn.error005());else{const{width:_,height:k}=vn(h);_&&k&&(y=[[p,v],[p+_,v+k]])}else h&&gi(c.extent)&&(y=[[c.extent[0][0]+p,c.extent[0][1]+v],[c.extent[1][0]+p,c.extent[1][1]+v]]);const m=gi(y)?pi(r,y,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",mn.error015())),{position:{x:m.x-p+(c.measured.width??0)*x[0],y:m.y-v+(c.measured.height??0)*x[1]},positionAbsolute:m}}async function a1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(m=>m.id)),c=[];for(const m of o){if(m.deletable===!1)continue;const _=u.has(m.id),k=!_&&m.parentId&&c.find(j=>j.id===m.parentId);(_||k)&&c.push(m)}const h=new Set(r.map(m=>m.id)),p=s.filter(m=>m.deletable!==!1),x=o1(c,p);for(const m of p)h.has(m.id)&&!x.find(k=>k.id===m.id)&&x.push(m);if(!a)return{edges:x,nodes:c};const y=await a({nodes:c,edges:x});return typeof y=="boolean"?y?{edges:x,nodes:c}:{edges:[],nodes:[]}:y}const Ji=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),pi=(t={x:0,y:0},r,o)=>({x:Ji(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:Ji(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function ug(t,r,o){const{width:s,height:a}=vn(o),{x:u,y:c}=o.internals.positionAbsolute;return pi(t,[[u,c],[u+s,c+a]],r)}const kh=(t,r,o)=>to?-Ji(Math.abs(t-o),1,r)/r:0,kc=(t,r,o=15,s=40)=>{const a=kh(t.x,s,r.width-s)*o,u=kh(t.y,s,r.height-s)*o;return[a,u]},Ql=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),uc=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),Zl=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),ss=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:fs(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},Fl=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:fs(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},cg=(t,r)=>Zl(Ql(uc(t),uc(r))),dg=(t,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),v=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*v)},Hl=(t,r)=>dg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),Nh=t=>pn(t.width)&&pn(t.height)&&pn(t.x)&&pn(t.y),pn=t=>!isNaN(t)&&isFinite(t),fg=(t,r)=>(o,s)=>{},ps=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),gs=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(t-o)/a,y:(r-s)/a};return u?ps(h,c):h},eo=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Yi(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function u1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Yi(t,o),a=Yi(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Yi(t.top??t.y??0,o),a=Yi(t.bottom??t.y??0,o),u=Yi(t.left??t.x??0,r),c=Yi(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function c1(t,r,o,s,a,u){const{x:c,y:h}=eo(t,[r,o,s]),{x:p,y:v}=eo({x:t.x+t.width,y:t.y+t.height},[r,o,s]),x=a-p,y=u-v;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(x),bottom:Math.floor(y)}}const Nc=(t,r,o,s,a,u)=>{const c=u1(u,r,o),h=(r-c.x)/t.width,p=(o-c.y)/t.height,v=Math.min(h,p),x=Ji(v,s,a),y=t.x+t.width/2,m=t.y+t.height/2,_=r/2-y*x,k=o/2-m*x,j=c1(t,_,k,x,r,o),b={left:Math.min(j.left-c.left,0),top:Math.min(j.top-c.top,0),right:Math.min(j.right-c.right,0),bottom:Math.min(j.bottom-c.bottom,0)};return{x:_-b.left+b.right,y:k-b.top+b.bottom,zoom:x}},ls=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function gi(t){return t!=null&&t!=="parent"}function vn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function hg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function pg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function jh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function d1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function f1(t){return{...ig,...t||{}}}function Qo(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=gn(t),h=gs({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y:v}=o?ps(h,r):h;return{xSnapped:p,ySnapped:v,...h}}const jc=t=>({width:t.offsetWidth,height:t.offsetHeight}),gg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},h1=["INPUT","SELECT","TEXTAREA"];function mg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:h1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const yg=t=>"clientX"in t,gn=(t,r)=>{var u,c;const o=yg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},bh=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...jc(c)}})};function vg({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=t*.125+a*.375+c*.375+o*.125,v=r*.125+u*.375+h*.375+s*.125,x=Math.abs(p-t),y=Math.abs(v-r);return[p,v,x,y]}function Sl(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function Eh({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case Se.Left:return[r-Sl(r-s,u),o];case Se.Right:return[r+Sl(s-r,u),o];case Se.Top:return[r,o-Sl(o-a,u)];case Se.Bottom:return[r,o+Sl(a-o,u)]}}function xg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top,curvature:c=.25}){const[h,p]=Eh({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[v,x]=Eh({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[y,m,_,k]=vg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:v,targetControlY:x});return[`M${t},${r} C${h},${p} ${v},${x} ${s},${a}`,y,m,_,k]}function wg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const m1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,y1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),v1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",mn.error006()),r;const s=o.getEdgeId||m1;let a;return lg(t)?a={...t}:a={...t,id:s(t)},y1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function _g({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=wg({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,h]}const Ch={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},x1=({source:t,sourcePosition:r=Se.Bottom,target:o})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function w1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:s=Se.Top,center:a,offset:u,stepPosition:c}){const h=Ch[r],p=Ch[s],v={x:t.x+h.x*u,y:t.y+h.y*u},x={x:o.x+p.x*u,y:o.y+p.y*u},y=x1({source:v,sourcePosition:r,target:x}),m=y.x!==0?"x":"y",_=y[m];let k=[],j,b;const E={x:0,y:0},R={x:0,y:0},[,,w,N]=wg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[m]*p[m]===-1){m==="x"?(j=a.x??v.x+(x.x-v.x)*c,b=a.y??(v.y+x.y)/2):(j=a.x??(v.x+x.x)/2,b=a.y??v.y+(x.y-v.y)*c);const G=[{x:j,y:v.y},{x:j,y:x.y}],q=[{x:v.x,y:b},{x:x.x,y:b}];h[m]===_?k=m==="x"?G:q:k=m==="x"?q:G}else{const G=[{x:v.x,y:x.y}],q=[{x:x.x,y:v.y}];if(m==="x"?k=h.x===_?q:G:k=h.y===_?G:q,r===s){const C=Math.abs(t[m]-o[m]);if(C<=u){const V=Math.min(u-1,u-C);h[m]===_?E[m]=(v[m]>t[m]?-1:1)*V:R[m]=(x[m]>o[m]?-1:1)*V}}if(r!==s){const C=m==="x"?"y":"x",V=h[m]===p[C],W=v[C]>x[C],U=v[C]=K?(j=(te.x+ee.x)/2,b=k[0].y):(j=k[0].x,b=(te.y+ee.y)/2)}const A={x:v.x+E.x,y:v.y+E.y},$={x:x.x+R.x,y:x.y+R.y};return[[t,...A.x!==k[0].x||A.y!==k[0].y?[A]:[],...k,...$.x!==k[k.length-1].x||$.y!==k[k.length-1].y?[$]:[],o],j,b,w,N]}function _1(t,r,o,s){const a=Math.min(Mh(t,r)/2,Mh(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const v=t.xo.id===r):t[0])||null}function cc(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function k1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const v=cc(p,r);u.has(v)||(c.push({id:v,color:p.color||o,...p}),u.add(v))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const Sg=1e3,N1=10,bc={nodeOrigin:[0,0],nodeExtent:rs,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},j1={...bc,checkEquality:!0};function Ec(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function b1(t,r,o){const s=Ec(bc,o);for(const a of t.values())if(a.parentId)Mc(a,t,r,s);else{const u=fs(a,s.nodeOrigin),c=gi(a.extent)?a.extent:s.nodeExtent,h=pi(u,c,vn(a));a.internals.positionAbsolute=h}}function E1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function Cc(t){return t==="manual"}function dc(t,r,o,s={}){var x,y;const a=Ec(j1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!Cc(a.zIndexMode)?Sg:0;let p=t.length>0,v=!1;r.clear(),o.clear();for(const m of t){let _=c.get(m.id);if(a.checkEquality&&m===(_==null?void 0:_.internals.userNode))r.set(m.id,_);else{const k=fs(m,a.nodeOrigin),j=gi(m.extent)?m.extent:a.nodeExtent,b=pi(k,j,vn(m));_={...a.defaults,...m,measured:{width:(x=m.measured)==null?void 0:x.width,height:(y=m.measured)==null?void 0:y.height},internals:{positionAbsolute:b,handleBounds:E1(m,_),z:kg(m,h,a.zIndexMode),userNode:m}},r.set(m.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),m.parentId&&Mc(_,r,o,s,u),v||(v=m.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:v}}function C1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function Mc(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=Ec(bc,s),v=t.parentId,x=r.get(v);if(!x){console.warn(`Parent node ${v} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}C1(t,o),a&&!x.parentId&&x.internals.rootParentIndex===void 0&&p==="auto"&&(x.internals.rootParentIndex=++a.i,x.internals.z=x.internals.z+a.i*N1),a&&x.internals.rootParentIndex!==void 0&&(a.i=x.internals.rootParentIndex);const y=u&&!Cc(p)?Sg:0,{x:m,y:_,z:k}=M1(t,x,c,h,y,p),{positionAbsolute:j}=t.internals,b=m!==j.x||_!==j.y;(b||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:b?{x:m,y:_}:j,z:k}})}function kg(t,r,o){const s=pn(t.zIndex)?t.zIndex:0;return Cc(o)?s:s+(t.selected?r:0)}function M1(t,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=vn(t),v=fs(t,o),x=gi(t.extent)?pi(v,t.extent,p):v;let y=pi({x:c+x.x,y:h+x.y},s,p);t.extent==="parent"&&(y=ug(y,p,r));const m=kg(t,a,u),_=r.internals.z??0;return{x:y.x,y:y.y,z:_>=m?_+1:m}}function Pc(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const v=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??ss(p),x=cg(v,h.rect);u.set(h.parentId,{expandedRect:x,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},v)=>{var w;const x=p.internals.positionAbsolute,y=vn(p),m=p.origin??s,_=h.x0||k>0||E||R)&&(a.push({id:v,type:"position",position:{x:p.position.x-_+E,y:p.position.y-k+R}}),(w=o.get(v))==null||w.forEach(N=>{t.some(A=>A.id===N.id)||a.push({id:N.id,type:"position",position:{x:N.position.x+_,y:N.position.y+k}})})),(y.width0){const _=Pc(m,r,o,a);v.push(..._)}return{changes:v,updatedInternals:p}}async function I1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Th(t,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${t}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${t}-${u}`;const v=s.get(c)||new Map;s.set(c,v.set(o,r))}}function Ng(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},v=`${a}-${c}--${u}-${h}`,x=`${u}-${h}--${a}-${c}`;Th("source",p,x,t,a,c),Th("target",p,v,t,u,h),r.set(s.id,s)}}function jg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:jg(o,r):!1}function Lh(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function R1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!jg(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function Bu({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[v,x]of r){const y=(c=o.get(v))==null?void 0:c.internals.userNode;y&&a.push({...y,position:x.position,dragging:s})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function T1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=ps(u,r);return{x:c.x-u.x,y:c.y-u.y}}function L1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,v={x:0,y:0},x=null,y=!1,m=null,_=!1,k=!1,j=null;function b({noDragClassName:R,handleSelector:w,domNode:N,isSelectable:A,nodeId:$,nodeClickDistance:F=0}){m=Gt(N);function G({x:ne,y:K}){const{nodeLookup:C,nodeExtent:V,snapGrid:W,snapToGrid:U,nodeOrigin:M,onNodeDrag:D,onSelectionDrag:H,onError:I,updateNodePositions:z}=r();u={x:ne,y:K};let ie=!1;const oe=h.size>1,fe=oe&&V?uc(hs(h)):null,he=oe&&U?T1({dragItems:h,snapGrid:W,x:ne,y:K}):null;for(const[pe,Z]of h){if(!C.has(pe))continue;let se={x:ne-Z.distance.x,y:K-Z.distance.y};U&&(se=he?{x:Math.round(se.x+he.x),y:Math.round(se.y+he.y)}:ps(se,W));let me=null;if(oe&&V&&!Z.extent&&fe){const{positionAbsolute:re}=Z.internals,Ne=re.x-fe.x+V[0][0],Me=re.x+Z.measured.width-fe.x2+V[1][0],Te=re.y-fe.y+V[0][1],$e=re.y+Z.measured.height-fe.y2+V[1][1];me=[[Ne,Te],[Me,$e]]}const{position:ke,positionAbsolute:ve}=ag({nodeId:pe,nextPosition:se,nodeLookup:C,nodeExtent:me||V,nodeOrigin:M,onError:I});ie=ie||Z.position.x!==ke.x||Z.position.y!==ke.y,Z.position=ke,Z.internals.positionAbsolute=ve}if(k=k||ie,!!ie&&(z(h,!0),j&&(s||D||!$&&H))){const[pe,Z]=Bu({nodeId:$,dragItems:h,nodeLookup:C});s==null||s(j,h,pe,Z),D==null||D(j,pe,Z),$||H==null||H(j,Z)}}async function q(){if(!x)return;const{transform:ne,panBy:K,autoPanSpeed:C,autoPanOnNodeDrag:V}=r();if(!V){p=!1,cancelAnimationFrame(c);return}const[W,U]=kc(v,x,C);(W!==0||U!==0)&&(u.x=(u.x??0)-W/ne[2],u.y=(u.y??0)-U/ne[2],await K({x:W,y:U})&&G(u)),c=requestAnimationFrame(q)}function te(ne){var oe;const{nodeLookup:K,multiSelectionActive:C,nodesDraggable:V,transform:W,snapGrid:U,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:H,onSelectionDragStart:I,unselectNodesAndEdges:z}=r();y=!0,(!D||!A)&&!C&&$&&((oe=K.get($))!=null&&oe.selected||z()),A&&D&&$&&(t==null||t($));const ie=Qo(ne.sourceEvent,{transform:W,snapGrid:U,snapToGrid:M,containerBounds:x});if(u=ie,h=R1(K,V,ie,$),h.size>0&&(o||H||!$&&I)){const[fe,he]=Bu({nodeId:$,dragItems:h,nodeLookup:K});o==null||o(ne.sourceEvent,h,fe,he),H==null||H(ne.sourceEvent,fe,he),$||I==null||I(ne.sourceEvent,he)}}const ee=Hp().clickDistance(F).on("start",ne=>{const{domNode:K,nodeDragThreshold:C,transform:V,snapGrid:W,snapToGrid:U}=r();x=(K==null?void 0:K.getBoundingClientRect())||null,_=!1,k=!1,j=ne.sourceEvent,C===0&&te(ne),u=Qo(ne.sourceEvent,{transform:V,snapGrid:W,snapToGrid:U,containerBounds:x}),v=gn(ne.sourceEvent,x)}).on("drag",ne=>{const{autoPanOnNodeDrag:K,transform:C,snapGrid:V,snapToGrid:W,nodeDragThreshold:U,nodeLookup:M}=r(),D=Qo(ne.sourceEvent,{transform:C,snapGrid:V,snapToGrid:W,containerBounds:x});if(j=ne.sourceEvent,(ne.sourceEvent.type==="touchmove"&&ne.sourceEvent.touches.length>1||$&&!M.has($))&&(_=!0),!_){if(!p&&K&&y&&(p=!0,q()),!y){const H=gn(ne.sourceEvent,x),I=H.x-v.x,z=H.y-v.y;Math.sqrt(I*I+z*z)>U&&te(ne)}(u.x!==D.xSnapped||u.y!==D.ySnapped)&&h&&y&&(v=gn(ne.sourceEvent,x),G(D))}}).on("end",ne=>{if(!y||_){_&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,y=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:K,updateNodePositions:C,onNodeDragStop:V,onSelectionDragStop:W}=r();if(k&&(C(h,!1),k=!1),a||V||!$&&W){const[U,M]=Bu({nodeId:$,dragItems:h,nodeLookup:K,dragging:!1});a==null||a(ne.sourceEvent,h,U,M),V==null||V(ne.sourceEvent,U,M),$||W==null||W(ne.sourceEvent,M)}}}).filter(ne=>{const K=ne.target;return!ne.button&&(!R||!Lh(K,`.${R}`,N))&&(!w||Lh(K,w,N))});m.call(ee)}function E(){m==null||m.on(".drag",null)}return{update:b,destroy:E}}function A1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())Hl(a,ss(u))>0&&s.push(u);return s}const $1=250;function z1(t,r,o,s){var h,p;let a=[],u=1/0;const c=A1(t,o,r+$1);for(const v of c){const x=[...((h=v.internals.handleBounds)==null?void 0:h.source)??[],...((p=v.internals.handleBounds)==null?void 0:p.target)??[]];for(const y of x){if(s.nodeId===y.nodeId&&s.type===y.type&&s.id===y.id)continue;const{x:m,y:_}=mi(v,y,y.position,!0),k=Math.sqrt(Math.pow(m-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const v=s.type==="source"?"target":"source";return a.find(x=>x.type===v)??a[0]}return a[0]}function bg(t,r,o,s,a,u=!1){var v,x,y;const c=s.get(t);if(!c)return null;const h=a==="strict"?(v=c.internals.handleBounds)==null?void 0:v[r]:[...((x=c.internals.handleBounds)==null?void 0:x.source)??[],...((y=c.internals.handleBounds)==null?void 0:y.target)??[]],p=(o?h==null?void 0:h.find(m=>m.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...mi(c,p,p.position,!0)}:p}function Eg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function D1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const Cg=()=>!0;function O1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:v,autoPanOnConnect:x,flowId:y,panBy:m,cancelConnection:_,onConnectStart:k,onConnect:j,onConnectEnd:b,isValidConnection:E=Cg,onReconnectEnd:R,updateConnection:w,getTransform:N,getFromHandle:A,autoPanSpeed:$,dragThreshold:F=1,handleDomNode:G}){const q=gg(t.target);let te=0,ee;const{x:ne,y:K}=gn(t),C=Eg(u,G),V=h==null?void 0:h.getBoundingClientRect();let W=!1;if(!V||!C)return;const U=bg(a,C,s,p,r);if(!U)return;let M=gn(t,V),D=!1,H=null,I=!1,z=null;function ie(){if(!x||!V)return;const[ke,ve]=kc(M,V,$);m({x:ke,y:ve}),te=requestAnimationFrame(ie)}const oe={...U,nodeId:a,type:C,position:U.position},fe=p.get(a);let pe={inProgress:!0,isValid:null,from:mi(fe,oe,Se.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:fe,to:M,toHandle:null,toPosition:Sh[oe.position],toNode:null,pointer:M};function Z(){W=!0,w(pe),k==null||k(t,{nodeId:a,handleId:s,handleType:C})}F===0&&Z();function se(ke){if(!W){const{x:$e,y:st}=gn(ke),lt=$e-ne,at=st-K;if(!(lt*lt+at*at>F*F))return;Z()}if(!A()||!oe){me(ke);return}const ve=N();M=gn(ke,V),ee=z1(gs(M,ve,!1,[1,1]),o,p,oe),D||(ie(),D=!0);const re=Mg(ke,{handle:ee,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:E,doc:q,lib:v,flowId:y,nodeLookup:p});z=re.handleDomNode,H=re.connection,I=D1(!!ee,re.isValid);const Ne=p.get(a),Me=Ne?mi(Ne,oe,Se.Left,!0):pe.from,Te={...pe,from:Me,isValid:I,to:re.toHandle&&I?eo({x:re.toHandle.x,y:re.toHandle.y},ve):M,toHandle:re.toHandle,toPosition:I&&re.toHandle?re.toHandle.position:Sh[oe.position],toNode:re.toHandle?p.get(re.toHandle.nodeId):null,pointer:M};w(Te),pe=Te}function me(ke){if(!("touches"in ke&&ke.touches.length>0)){if(W){(ee||z)&&H&&I&&(j==null||j(H));const{inProgress:ve,...re}=pe,Ne={...re,toPosition:pe.toHandle?pe.toPosition:null};b==null||b(ke,Ne),u&&(R==null||R(ke,Ne))}_(),cancelAnimationFrame(te),D=!1,I=!1,H=null,z=null,q.removeEventListener("mousemove",se),q.removeEventListener("mouseup",me),q.removeEventListener("touchmove",se),q.removeEventListener("touchend",me)}}q.addEventListener("mousemove",se),q.addEventListener("mouseup",me),q.addEventListener("touchmove",se),q.addEventListener("touchend",me)}function Mg(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:v=Cg,nodeLookup:x}){const y=u==="target",m=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=gn(t),j=c.elementFromPoint(_,k),b=j!=null&&j.classList.contains(`${h}-flow__handle`)?j:m,E={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const R=Eg(void 0,b),w=b.getAttribute("data-nodeid"),N=b.getAttribute("data-handleid"),A=b.classList.contains("connectable"),$=b.classList.contains("connectableend");if(!w||!R)return E;const F={source:y?w:s,sourceHandle:y?N:a,target:y?s:w,targetHandle:y?a:N};E.connection=F;const q=A&&$&&(o===Zi.Strict?y&&R==="source"||!y&&R==="target":w!==s||N!==a);E.isValid=q&&v(F),E.toHandle=bg(w,R,N,x,o,!0)}return E}const fc={onPointerDown:O1,isValid:Mg};function F1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Gt(t);function u({translateExtent:h,width:p,height:v,zoomStep:x=1,pannable:y=!0,zoomable:m=!0,inversePan:_=!1}){const k=w=>{if(w.sourceEvent.type!=="wheel"||!r)return;const N=o(),A=w.sourceEvent.ctrlKey&&ls()?10:1,$=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*x,F=N[2]*Math.pow(2,$*A);r.scaleTo(F)};let j=[0,0];const b=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(j=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},E=w=>{const N=o();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!r)return;const A=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],$=[A[0]-j[0],A[1]-j[1]];j=A;const F=s()*Math.max(N[2],Math.log(N[2]))*(_?-1:1),G={x:N[0]-$[0]*F,y:N[1]-$[1]*F},q=[[0,0],[p,v]];r.setViewportConstrained({x:G.x,y:G.y,zoom:N[2]},q,h)},R=ng().on("start",b).on("zoom",y?E:null).on("zoom.wheel",m?k:null);a.call(R,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:fn}}const Jl=t=>({x:t.x,y:t.y,zoom:t.k}),Vu=({x:t,y:r,zoom:o})=>Kl.translate(t,r).scale(o),Rr=(t,r)=>t.target.closest(`.${r}`),Pg=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),H1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Wu=(t,r=0,o=H1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Ig=t=>{const r=t.ctrlKey&&ls()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function B1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:v}){return x=>{if(Rr(x,r))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const y=o.property("__zoom").k||1;if(x.ctrlKey&&c){const b=fn(x),E=Ig(x),R=y*Math.pow(2,E);s.scaleTo(o,R,b,x);return}const m=x.deltaMode===1?20:1;let _=a===di.Vertical?0:x.deltaX*m,k=a===di.Horizontal?0:x.deltaY*m;!ls()&&x.shiftKey&&a!==di.Vertical&&(_=x.deltaY*m,k=0),s.translateBy(o,-(_/y)*u,-(k/y)*u,{internal:!0});const j=Jl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(x,j):(t.isPanScrolling=!0,h==null||h(x,j)),t.panScrollTimeout=setTimeout(()=>{v==null||v(x,j),t.isPanScrolling=!1},150)}}function V1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=Rr(s,t);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function W1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=Jl(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function U1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;t.usedRightMouseButton=!!(o&&Pg(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,Jl(u.transform)))}}function Y1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&Pg(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const p=Jl(c.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function G1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:v,lib:x,connectionInProgress:y}){return m=>{var E;const _=r||o,k=s&&m.ctrlKey,j=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(Rr(m,`${x}-flow__node`)||Rr(m,`${x}-flow__edge`)||Rr(m,`${x}-flow__selection`)||Rr(m,`${x}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!c&&!s||h||y&&!j||Rr(m,p)&&j||Rr(m,v)&&(!j||u&&j&&!r)||!s&&m.ctrlKey&&j)return!1;if(!s&&m.type==="touchstart"&&((E=m.touches)==null?void 0:E.length)>1)return m.preventDefault(),!1;if(!_&&!u&&!k&&j||!a&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(a)&&!a.includes(m.button)&&m.type==="mousedown")return!1;const b=Array.isArray(a)&&a.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||j||t)&&b}}function X1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const v={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=t.getBoundingClientRect();let y=[[0,0],[x.width,x.height]];const m=typeof ResizeObserver<"u"?new ResizeObserver(K=>{const C=K[0];C&&(y=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;m==null||m.observe(t);const _=ng().extent(()=>y).scaleExtent([r,o]).translateExtent(s),k=Gt(t).call(_);N({x:a.x,y:a.y,zoom:Ji(a.zoom,r,o)},[[0,0],[x.width,x.height]],s);const j=k.on("wheel.zoom"),b=k.on("dblclick.zoom");_.wheelDelta(Ig);async function E(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Ml).transform(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function R({noWheelClassName:K,noPanClassName:C,onPaneContextMenu:V,userSelectionActive:W,panOnScroll:U,panOnDrag:M,panOnScrollMode:D,panOnScrollSpeed:H,preventScrolling:I,zoomOnPinch:z,zoomOnScroll:ie,zoomOnDoubleClick:oe,panActivationKeyPressed:fe=!1,zoomActivationKeyPressed:he,lib:pe,onTransformChange:Z,connectionInProgress:se,paneClickDistance:me,selectionOnDrag:ke}){W&&!v.isZoomingOrPanning&&w();const ve=U&&!he&&!W;_.clickDistance(ke?1/0:!pn(me)||me<0?0:me);const re=ve?B1({zoomPanValues:v,noWheelClassName:K,d3Selection:k,d3Zoom:_,panOnScrollMode:D,panOnScrollSpeed:H,zoomOnPinch:z,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):V1({noWheelClassName:K,preventScrolling:I,d3ZoomHandler:j});k.on("wheel.zoom",re,{passive:!1});const Ne=W1({zoomPanValues:v,onDraggingChange:p,onPanZoomStart:c});_.on("start",Ne);const Me=U1({zoomPanValues:v,panOnDrag:M,onPaneContextMenu:!!V,onPanZoom:u,onTransformChange:Z});_.on("zoom",Me);const Te=Y1({zoomPanValues:v,panOnDrag:M,panOnScroll:U,onPaneContextMenu:V,onPanZoomEnd:h,onDraggingChange:p});_.on("end",Te);const $e=G1({panActivationKeyPressed:fe,zoomActivationKeyPressed:he,panOnDrag:M,zoomOnScroll:ie,panOnScroll:U,zoomOnDoubleClick:oe,zoomOnPinch:z,userSelectionActive:W,noPanClassName:C,noWheelClassName:K,lib:pe,connectionInProgress:se});_.filter($e),oe?k.on("dblclick.zoom",b):k.on("dblclick.zoom",null)}function w(){_.on("zoom",null)}async function N(K,C,V){const W=Vu(K),U=_==null?void 0:_.constrain()(W,C,V);return U&&await E(U),U}async function A(K,C){const V=Vu(K);return await E(V,C),V}function $(K){if(k){const C=Vu(K),V=k.property("__zoom");(V.k!==K.zoom||V.x!==K.x||V.y!==K.y)&&(_==null||_.transform(k,C,null,{sync:!0}))}}function F(){const K=k?tg(k.node()):{x:0,y:0,k:1};return{x:K.x,y:K.y,zoom:K.k}}async function G(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Ml).scaleTo(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}async function q(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Ml).scaleBy(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function te(K){_==null||_.scaleExtent(K)}function ee(K){_==null||_.translateExtent(K)}function ne(K){const C=!pn(K)||K<0?0:K;_==null||_.clickDistance(C)}return{update:R,destroy:w,setViewport:A,setViewportConstrained:N,getViewport:F,scaleTo:G,scaleBy:q,setScaleExtent:te,setTranslateExtent:ee,syncViewport:$,setClickDistance:ne}}var to;(function(t){t.Line="line",t.Handle="handle"})(to||(to={}));function q1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function Ah(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function Pr(t,r){return Math.max(0,r-t)}function Ir(t,r){return Math.max(0,t-r)}function kl(t,r,o){return Math.max(0,r-t,t-o)}function $h(t,r){return t?!r:r}function K1(t,r,o,s,a,u,c,h){let{affectsX:p,affectsY:v}=r;const{isHorizontal:x,isVertical:y}=r,m=x&&y,{xSnapped:_,ySnapped:k}=o,{minWidth:j,maxWidth:b,minHeight:E,maxHeight:R}=s,{x:w,y:N,width:A,height:$,aspectRatio:F}=t;let G=Math.floor(x?_-t.pointerX:0),q=Math.floor(y?k-t.pointerY:0);const te=A+(p?-G:G),ee=$+(v?-q:q),ne=-u[0]*A,K=-u[1]*$;let C=kl(te,j,b),V=kl(ee,E,R);if(c){let M=0,D=0;p&&G<0?M=Pr(w+G+ne,c[0][0]):!p&&G>0&&(M=Ir(w+te+ne,c[1][0])),v&&q<0?D=Pr(N+q+K,c[0][1]):!v&&q>0&&(D=Ir(N+ee+K,c[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(h){let M=0,D=0;p&&G>0?M=Ir(w+G,h[0][0]):!p&&G<0&&(M=Pr(w+te,h[1][0])),v&&q>0?D=Ir(N+q,h[0][1]):!v&&q<0&&(D=Pr(N+ee,h[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(a){if(x){const M=kl(te/F,E,R)*F;if(C=Math.max(C,M),c){let D=0;!p&&!v||p&&!v&&m?D=Ir(N+K+te/F,c[1][1])*F:D=Pr(N+K+(p?G:-G)/F,c[0][1])*F,C=Math.max(C,D)}if(h){let D=0;!p&&!v||p&&!v&&m?D=Pr(N+te/F,h[1][1])*F:D=Ir(N+(p?G:-G)/F,h[0][1])*F,C=Math.max(C,D)}}if(y){const M=kl(ee*F,j,b)/F;if(V=Math.max(V,M),c){let D=0;!p&&!v||v&&!p&&m?D=Ir(w+ee*F+ne,c[1][0])/F:D=Pr(w+(v?q:-q)*F+ne,c[0][0])/F,V=Math.max(V,D)}if(h){let D=0;!p&&!v||v&&!p&&m?D=Pr(w+ee*F,h[1][0])/F:D=Ir(w+(v?q:-q)*F,h[0][0])/F,V=Math.max(V,D)}}}q=q+(q<0?V:-V),G=G+(G<0?C:-C),a&&(m?te>ee*F?q=($h(p,v)?-G:G)/F:G=($h(p,v)?-q:q)*F:x?(q=G/F,v=p):(G=q*F,p=v));const W=p?w+G:w,U=v?N+q:N;return{width:A+(p?-G:G),height:$+(v?-q:q),x:u[0]*G*(p?-1:1)+W,y:u[1]*q*(v?-1:1)+U}}const Rg={width:0,height:0,x:0,y:0},Q1={...Rg,pointerX:0,pointerY:0,aspectRatio:1};function Z1(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function J1({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Gt(t);let c={controlDirection:Ah("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:v,boundaries:x,keepAspectRatio:y,resizeDirection:m,onResizeStart:_,onResize:k,onResizeEnd:j,shouldResize:b}){let E={...Rg},R={...Q1};c={boundaries:x,resizeDirection:m,keepAspectRatio:y,controlDirection:Ah(v)};let w,N=null,A=[],$,F,G,q=!1;const te=Hp().on("start",ee=>{const{nodeLookup:ne,transform:K,snapGrid:C,snapToGrid:V,nodeOrigin:W,paneDomNode:U}=o();if(w=ne.get(r),!w)return;N=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:D}=Qo(ee.sourceEvent,{transform:K,snapGrid:C,snapToGrid:V,containerBounds:N});E={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},R={...E,pointerX:M,pointerY:D,aspectRatio:E.width/E.height},$=void 0,F=gi(w.extent)?w.extent:void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&($=ne.get(w.parentId)),$&&w.extent==="parent"&&(F=[[0,0],[$.measured.width,$.measured.height]]),A=[],G=void 0;for(const[H,I]of ne)if(I.parentId===r&&(A.push({id:H,position:{...I.position},extent:I.extent}),I.extent==="parent"||I.expandParent)){const z=Z1(I,w,I.origin??W);G?G=[[Math.min(z[0][0],G[0][0]),Math.min(z[0][1],G[0][1])],[Math.max(z[1][0],G[1][0]),Math.max(z[1][1],G[1][1])]]:G=z}_==null||_(ee,{...E})}).on("drag",ee=>{const{transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V}=o(),W=Qo(ee.sourceEvent,{transform:ne,snapGrid:K,snapToGrid:C,containerBounds:N}),U=[];if(!w)return;const{x:M,y:D,width:H,height:I}=E,z={},ie=w.origin??V,{width:oe,height:fe,x:he,y:pe}=K1(R,c.controlDirection,W,c.boundaries,c.keepAspectRatio,ie,F,G),Z=oe!==H,se=fe!==I,me=he!==M&&Z,ke=pe!==D&&se;if(!me&&!ke&&!Z&&!se)return;if((me||ke||ie[0]===1||ie[1]===1)&&(z.x=me?he:E.x,z.y=ke?pe:E.y,E.x=z.x,E.y=z.y,A.length>0)){const Me=he-M,Te=pe-D;for(const $e of A)$e.position={x:$e.position.x-Me+ie[0]*(oe-H),y:$e.position.y-Te+ie[1]*(fe-I)},U.push($e)}if((Z||se)&&(z.width=Z&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:E.width,z.height=se&&(!c.resizeDirection||c.resizeDirection==="vertical")?fe:E.height,E.width=z.width,E.height=z.height),$&&w.expandParent){const Me=ie[0]*(z.width??0);z.x&&z.x{q&&(j==null||j(ee,{...E}),a==null||a({...E}),q=!1)});u.call(te)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Uu={exports:{}},Yu={},Gu={exports:{}},Xu={};/** +`+g.stack}return{value:e,source:n,stack:f,digest:null}}function ru(e,n,i){return{value:e,source:null,stack:i??null,digest:n??null}}function iu(e,n){try{console.error(n.value)}catch(i){setTimeout(function(){throw i})}}var My=typeof WeakMap=="function"?WeakMap:Map;function rf(e,n,i){i=Jn(-1,i),i.tag=3,i.payload={element:null};var l=n.value;return i.callback=function(){nl||(nl=!0,xu=l),iu(e,n)},i}function of(e,n,i){i=Jn(-1,i),i.tag=3;var l=e.type.getDerivedStateFromError;if(typeof l=="function"){var f=n.value;i.payload=function(){return l(f)},i.callback=function(){iu(e,n)}}var g=e.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(i.callback=function(){iu(e,n),typeof l!="function"&&(Nr===null?Nr=new Set([this]):Nr.add(this));var S=n.stack;this.componentDidCatch(n.value,{componentStack:S!==null?S:""})}),i}function sf(e,n,i){var l=e.pingCache;if(l===null){l=e.pingCache=new My;var f=new Set;l.set(n,f)}else f=l.get(n),f===void 0&&(f=new Set,l.set(n,f));f.has(i)||(f.add(i),e=Vy.bind(null,e,n,i),n.then(e,e))}function lf(e){do{var n;if((n=e.tag===13)&&(n=e.memoizedState,n=n!==null?n.dehydrated!==null:!0),n)return e;e=e.return}while(e!==null);return null}function af(e,n,i,l,f){return(e.mode&1)===0?(e===n?e.flags|=65536:(e.flags|=128,i.flags|=131072,i.flags&=-52805,i.tag===1&&(i.alternate===null?i.tag=17:(n=Jn(-1,1),n.tag=2,Sr(i,n,1))),i.lanes|=1),e):(e.flags|=65536,e.lanes=f,e)}var Py=N.ReactCurrentOwner,Lt=!1;function Ct(e,n,i,l){n.child=e===null?Ed(n,null,i,l):zi(n,e.child,i,l)}function uf(e,n,i,l,f){i=i.render;var g=n.ref;return Oi(n,f),l=qa(e,n,i,l,g,f),i=Ka(),e!==null&&!Lt?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~f,er(e,n,f)):(Xe&&i&&Ra(n),n.flags|=1,Ct(e,n,l,f),n.child)}function cf(e,n,i,l,f){if(e===null){var g=i.type;return typeof g=="function"&&!bu(g)&&g.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(n.tag=15,n.type=g,df(e,n,g,l,f)):(e=al(i.type,null,l,n,n.mode,f),e.ref=n.ref,e.return=n,n.child=e)}if(g=e.child,(e.lanes&f)===0){var S=g.memoizedProps;if(i=i.compare,i=i!==null?i:No,i(S,l)&&e.ref===n.ref)return er(e,n,f)}return n.flags|=1,e=Cr(g,l),e.ref=n.ref,e.return=n,n.child=e}function df(e,n,i,l,f){if(e!==null){var g=e.memoizedProps;if(No(g,l)&&e.ref===n.ref)if(Lt=!1,n.pendingProps=l=g,(e.lanes&f)!==0)(e.flags&131072)!==0&&(Lt=!0);else return n.lanes=e.lanes,er(e,n,f)}return ou(e,n,i,l,f)}function ff(e,n,i){var l=n.pendingProps,f=l.children,g=e!==null?e.memoizedState:null;if(l.mode==="hidden")if((n.mode&1)===0)n.memoizedState={baseLanes:0,cachePool:null,transitions:null},Be(Vi,Yt),Yt|=i;else{if((i&1073741824)===0)return e=g!==null?g.baseLanes|i:i,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:e,cachePool:null,transitions:null},n.updateQueue=null,Be(Vi,Yt),Yt|=e,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=g!==null?g.baseLanes:i,Be(Vi,Yt),Yt|=l}else g!==null?(l=g.baseLanes|i,n.memoizedState=null):l=i,Be(Vi,Yt),Yt|=l;return Ct(e,n,f,i),n.child}function hf(e,n){var i=n.ref;(e===null&&i!==null||e!==null&&e.ref!==i)&&(n.flags|=512,n.flags|=2097152)}function ou(e,n,i,l,f){var g=Tt(i)?Qr:St.current;return g=Ti(n,g),Oi(n,f),i=qa(e,n,i,l,g,f),l=Ka(),e!==null&&!Lt?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~f,er(e,n,f)):(Xe&&l&&Ra(n),n.flags|=1,Ct(e,n,i,f),n.child)}function pf(e,n,i,l,f){if(Tt(i)){var g=!0;Ts(n)}else g=!1;if(Oi(n,f),n.stateNode===null)Qs(e,n),tf(n,i,l),nu(n,i,l,f),l=!0;else if(e===null){var S=n.stateNode,T=n.memoizedProps;S.props=T;var O=S.context,J=i.contextType;typeof J=="object"&&J!==null?J=Zt(J):(J=Tt(i)?Qr:St.current,J=Ti(n,J));var ae=i.getDerivedStateFromProps,ue=typeof ae=="function"||typeof S.getSnapshotBeforeUpdate=="function";ue||typeof S.UNSAFE_componentWillReceiveProps!="function"&&typeof S.componentWillReceiveProps!="function"||(T!==l||O!==J)&&nf(n,S,l,J),_r=!1;var le=n.memoizedState;S.state=le,Bs(n,l,S,f),O=n.memoizedState,T!==l||le!==O||Rt.current||_r?(typeof ae=="function"&&(tu(n,i,ae,l),O=n.memoizedState),(T=_r||ef(n,i,T,l,le,O,J))?(ue||typeof S.UNSAFE_componentWillMount!="function"&&typeof S.componentWillMount!="function"||(typeof S.componentWillMount=="function"&&S.componentWillMount(),typeof S.UNSAFE_componentWillMount=="function"&&S.UNSAFE_componentWillMount()),typeof S.componentDidMount=="function"&&(n.flags|=4194308)):(typeof S.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=l,n.memoizedState=O),S.props=l,S.state=O,S.context=J,l=T):(typeof S.componentDidMount=="function"&&(n.flags|=4194308),l=!1)}else{S=n.stateNode,Md(e,n),T=n.memoizedProps,J=n.type===n.elementType?T:an(n.type,T),S.props=J,ue=n.pendingProps,le=S.context,O=i.contextType,typeof O=="object"&&O!==null?O=Zt(O):(O=Tt(i)?Qr:St.current,O=Ti(n,O));var ge=i.getDerivedStateFromProps;(ae=typeof ge=="function"||typeof S.getSnapshotBeforeUpdate=="function")||typeof S.UNSAFE_componentWillReceiveProps!="function"&&typeof S.componentWillReceiveProps!="function"||(T!==ue||le!==O)&&nf(n,S,l,O),_r=!1,le=n.memoizedState,S.state=le,Bs(n,l,S,f);var xe=n.memoizedState;T!==ue||le!==xe||Rt.current||_r?(typeof ge=="function"&&(tu(n,i,ge,l),xe=n.memoizedState),(J=_r||ef(n,i,J,l,le,xe,O)||!1)?(ae||typeof S.UNSAFE_componentWillUpdate!="function"&&typeof S.componentWillUpdate!="function"||(typeof S.componentWillUpdate=="function"&&S.componentWillUpdate(l,xe,O),typeof S.UNSAFE_componentWillUpdate=="function"&&S.UNSAFE_componentWillUpdate(l,xe,O)),typeof S.componentDidUpdate=="function"&&(n.flags|=4),typeof S.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof S.componentDidUpdate!="function"||T===e.memoizedProps&&le===e.memoizedState||(n.flags|=4),typeof S.getSnapshotBeforeUpdate!="function"||T===e.memoizedProps&&le===e.memoizedState||(n.flags|=1024),n.memoizedProps=l,n.memoizedState=xe),S.props=l,S.state=xe,S.context=O,l=J):(typeof S.componentDidUpdate!="function"||T===e.memoizedProps&&le===e.memoizedState||(n.flags|=4),typeof S.getSnapshotBeforeUpdate!="function"||T===e.memoizedProps&&le===e.memoizedState||(n.flags|=1024),l=!1)}return su(e,n,i,l,g,f)}function su(e,n,i,l,f,g){hf(e,n);var S=(n.flags&128)!==0;if(!l&&!S)return f&&vd(n,i,!1),er(e,n,g);l=n.stateNode,Py.current=n;var T=S&&typeof i.getDerivedStateFromError!="function"?null:l.render();return n.flags|=1,e!==null&&S?(n.child=zi(n,e.child,null,g),n.child=zi(n,null,T,g)):Ct(e,n,T,g),n.memoizedState=l.state,f&&vd(n,i,!0),n.child}function gf(e){var n=e.stateNode;n.pendingContext?md(e,n.pendingContext,n.pendingContext!==n.context):n.context&&md(e,n.context,!1),Va(e,n.containerInfo)}function mf(e,n,i,l,f){return $i(),$a(f),n.flags|=256,Ct(e,n,i,l),n.child}var lu={dehydrated:null,treeContext:null,retryLane:0};function au(e){return{baseLanes:e,cachePool:null,transitions:null}}function yf(e,n,i){var l=n.pendingProps,f=qe.current,g=!1,S=(n.flags&128)!==0,T;if((T=S)||(T=e!==null&&e.memoizedState===null?!1:(f&2)!==0),T?(g=!0,n.flags&=-129):(e===null||e.memoizedState!==null)&&(f|=1),Be(qe,f&1),e===null)return Aa(n),e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?((n.mode&1)===0?n.lanes=1:e.data==="$!"?n.lanes=8:n.lanes=1073741824,null):(S=l.children,e=l.fallback,g?(l=n.mode,g=n.child,S={mode:"hidden",children:S},(l&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=S):g=ul(S,l,0,null),e=li(e,l,i,null),g.return=n,e.return=n,g.sibling=e,n.child=g,n.child.memoizedState=au(i),n.memoizedState=lu,e):uu(n,S));if(f=e.memoizedState,f!==null&&(T=f.dehydrated,T!==null))return Iy(e,n,S,l,T,f,i);if(g){g=l.fallback,S=n.mode,f=e.child,T=f.sibling;var O={mode:"hidden",children:l.children};return(S&1)===0&&n.child!==f?(l=n.child,l.childLanes=0,l.pendingProps=O,n.deletions=null):(l=Cr(f,O),l.subtreeFlags=f.subtreeFlags&14680064),T!==null?g=Cr(T,g):(g=li(g,S,i,null),g.flags|=2),g.return=n,l.return=n,l.sibling=g,n.child=l,l=g,g=n.child,S=e.child.memoizedState,S=S===null?au(i):{baseLanes:S.baseLanes|i,cachePool:null,transitions:S.transitions},g.memoizedState=S,g.childLanes=e.childLanes&~i,n.memoizedState=lu,l}return g=e.child,e=g.sibling,l=Cr(g,{mode:"visible",children:l.children}),(n.mode&1)===0&&(l.lanes=i),l.return=n,l.sibling=null,e!==null&&(i=n.deletions,i===null?(n.deletions=[e],n.flags|=16):i.push(e)),n.child=l,n.memoizedState=null,l}function uu(e,n){return n=ul({mode:"visible",children:n},e.mode,0,null),n.return=e,e.child=n}function Ks(e,n,i,l){return l!==null&&$a(l),zi(n,e.child,null,i),e=uu(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Iy(e,n,i,l,f,g,S){if(i)return n.flags&256?(n.flags&=-257,l=ru(Error(o(422))),Ks(e,n,S,l)):n.memoizedState!==null?(n.child=e.child,n.flags|=128,null):(g=l.fallback,f=n.mode,l=ul({mode:"visible",children:l.children},f,0,null),g=li(g,f,S,null),g.flags|=2,l.return=n,g.return=n,l.sibling=g,n.child=l,(n.mode&1)!==0&&zi(n,e.child,null,S),n.child.memoizedState=au(S),n.memoizedState=lu,g);if((n.mode&1)===0)return Ks(e,n,S,null);if(f.data==="$!"){if(l=f.nextSibling&&f.nextSibling.dataset,l)var T=l.dgst;return l=T,g=Error(o(419)),l=ru(g,l,void 0),Ks(e,n,S,l)}if(T=(S&e.childLanes)!==0,Lt||T){if(l=ht,l!==null){switch(S&-S){case 4:f=2;break;case 16:f=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:f=32;break;case 536870912:f=268435456;break;default:f=0}f=(f&(l.suspendedLanes|S))!==0?0:f,f!==0&&f!==g.retryLane&&(g.retryLane=f,Zn(e,f),dn(l,e,f,-1))}return ju(),l=ru(Error(o(421))),Ks(e,n,S,l)}return f.data==="$?"?(n.flags|=128,n.child=e.child,n=Wy.bind(null,e),f._reactRetry=n,null):(e=g.treeContext,Ut=yr(f.nextSibling),Wt=n,Xe=!0,ln=null,e!==null&&(Kt[Qt++]=Kn,Kt[Qt++]=Qn,Kt[Qt++]=Zr,Kn=e.id,Qn=e.overflow,Zr=n),n=uu(n,l.children),n.flags|=4096,n)}function vf(e,n,i){e.lanes|=n;var l=e.alternate;l!==null&&(l.lanes|=n),Fa(e.return,n,i)}function cu(e,n,i,l,f){var g=e.memoizedState;g===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:l,tail:i,tailMode:f}:(g.isBackwards=n,g.rendering=null,g.renderingStartTime=0,g.last=l,g.tail=i,g.tailMode=f)}function xf(e,n,i){var l=n.pendingProps,f=l.revealOrder,g=l.tail;if(Ct(e,n,l.children,i),l=qe.current,(l&2)!==0)l=l&1|2,n.flags|=128;else{if(e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&vf(e,i,n);else if(e.tag===19)vf(e,i,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}l&=1}if(Be(qe,l),(n.mode&1)===0)n.memoizedState=null;else switch(f){case"forwards":for(i=n.child,f=null;i!==null;)e=i.alternate,e!==null&&Vs(e)===null&&(f=i),i=i.sibling;i=f,i===null?(f=n.child,n.child=null):(f=i.sibling,i.sibling=null),cu(n,!1,f,i,g);break;case"backwards":for(i=null,f=n.child,n.child=null;f!==null;){if(e=f.alternate,e!==null&&Vs(e)===null){n.child=f;break}e=f.sibling,f.sibling=i,i=f,f=e}cu(n,!0,i,null,g);break;case"together":cu(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function Qs(e,n){(n.mode&1)===0&&e!==null&&(e.alternate=null,n.alternate=null,n.flags|=2)}function er(e,n,i){if(e!==null&&(n.dependencies=e.dependencies),ri|=n.lanes,(i&n.childLanes)===0)return null;if(e!==null&&n.child!==e.child)throw Error(o(153));if(n.child!==null){for(e=n.child,i=Cr(e,e.pendingProps),n.child=i,i.return=n;e.sibling!==null;)e=e.sibling,i=i.sibling=Cr(e,e.pendingProps),i.return=n;i.sibling=null}return n.child}function Ry(e,n,i){switch(n.tag){case 3:gf(n),$i();break;case 5:Rd(n);break;case 1:Tt(n.type)&&Ts(n);break;case 4:Va(n,n.stateNode.containerInfo);break;case 10:var l=n.type._context,f=n.memoizedProps.value;Be(Os,l._currentValue),l._currentValue=f;break;case 13:if(l=n.memoizedState,l!==null)return l.dehydrated!==null?(Be(qe,qe.current&1),n.flags|=128,null):(i&n.child.childLanes)!==0?yf(e,n,i):(Be(qe,qe.current&1),e=er(e,n,i),e!==null?e.sibling:null);Be(qe,qe.current&1);break;case 19:if(l=(i&n.childLanes)!==0,(e.flags&128)!==0){if(l)return xf(e,n,i);n.flags|=128}if(f=n.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),Be(qe,qe.current),l)break;return null;case 22:case 23:return n.lanes=0,ff(e,n,i)}return er(e,n,i)}var wf,du,_f,Sf;wf=function(e,n){for(var i=n.child;i!==null;){if(i.tag===5||i.tag===6)e.appendChild(i.stateNode);else if(i.tag!==4&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===n)break;for(;i.sibling===null;){if(i.return===null||i.return===n)return;i=i.return}i.sibling.return=i.return,i=i.sibling}},du=function(){},_f=function(e,n,i,l){var f=e.memoizedProps;if(f!==l){e=n.stateNode,ti(Mn.current);var g=null;switch(i){case"input":f=Ne(e,f),l=Ne(e,l),g=[];break;case"select":f=H({},f,{value:void 0}),l=H({},l,{value:void 0}),g=[];break;case"textarea":f=wt(e,f),l=wt(e,l),g=[];break;default:typeof f.onClick!="function"&&typeof l.onClick=="function"&&(e.onclick=Ps)}$r(i,l);var S;i=null;for(J in f)if(!l.hasOwnProperty(J)&&f.hasOwnProperty(J)&&f[J]!=null)if(J==="style"){var T=f[J];for(S in T)T.hasOwnProperty(S)&&(i||(i={}),i[S]="")}else J!=="dangerouslySetInnerHTML"&&J!=="children"&&J!=="suppressContentEditableWarning"&&J!=="suppressHydrationWarning"&&J!=="autoFocus"&&(a.hasOwnProperty(J)?g||(g=[]):(g=g||[]).push(J,null));for(J in l){var O=l[J];if(T=f!=null?f[J]:void 0,l.hasOwnProperty(J)&&O!==T&&(O!=null||T!=null))if(J==="style")if(T){for(S in T)!T.hasOwnProperty(S)||O&&O.hasOwnProperty(S)||(i||(i={}),i[S]="");for(S in O)O.hasOwnProperty(S)&&T[S]!==O[S]&&(i||(i={}),i[S]=O[S])}else i||(g||(g=[]),g.push(J,i)),i=O;else J==="dangerouslySetInnerHTML"?(O=O?O.__html:void 0,T=T?T.__html:void 0,O!=null&&T!==O&&(g=g||[]).push(J,O)):J==="children"?typeof O!="string"&&typeof O!="number"||(g=g||[]).push(J,""+O):J!=="suppressContentEditableWarning"&&J!=="suppressHydrationWarning"&&(a.hasOwnProperty(J)?(O!=null&&J==="onScroll"&&We("scroll",e),g||T===O||(g=[])):(g=g||[]).push(J,O))}i&&(g=g||[]).push("style",i);var J=g;(n.updateQueue=J)&&(n.flags|=4)}},Sf=function(e,n,i,l){i!==l&&(n.flags|=4)};function Oo(e,n){if(!Xe)switch(e.tailMode){case"hidden":n=e.tail;for(var i=null;n!==null;)n.alternate!==null&&(i=n),n=n.sibling;i===null?e.tail=null:i.sibling=null;break;case"collapsed":i=e.tail;for(var l=null;i!==null;)i.alternate!==null&&(l=i),i=i.sibling;l===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function Nt(e){var n=e.alternate!==null&&e.alternate.child===e.child,i=0,l=0;if(n)for(var f=e.child;f!==null;)i|=f.lanes|f.childLanes,l|=f.subtreeFlags&14680064,l|=f.flags&14680064,f.return=e,f=f.sibling;else for(f=e.child;f!==null;)i|=f.lanes|f.childLanes,l|=f.subtreeFlags,l|=f.flags,f.return=e,f=f.sibling;return e.subtreeFlags|=l,e.childLanes=i,n}function Ty(e,n,i){var l=n.pendingProps;switch(Ta(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Nt(n),null;case 1:return Tt(n.type)&&Rs(),Nt(n),null;case 3:return l=n.stateNode,Fi(),Ue(Rt),Ue(St),Ya(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(zs(n)?n.flags|=4:e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,ln!==null&&(Su(ln),ln=null))),du(e,n),Nt(n),null;case 5:Wa(n);var f=ti(Lo.current);if(i=n.type,e!==null&&n.stateNode!=null)_f(e,n,i,l,f),e.ref!==n.ref&&(n.flags|=512,n.flags|=2097152);else{if(!l){if(n.stateNode===null)throw Error(o(166));return Nt(n),null}if(e=ti(Mn.current),zs(n)){l=n.stateNode,i=n.type;var g=n.memoizedProps;switch(l[Cn]=n,l[Mo]=g,e=(n.mode&1)!==0,i){case"dialog":We("cancel",l),We("close",l);break;case"iframe":case"object":case"embed":We("load",l);break;case"video":case"audio":for(f=0;f<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=S.createElement(i,{is:l.is}):(e=S.createElement(i),i==="select"&&(S=e,l.multiple?S.multiple=!0:l.size&&(S.size=l.size))):e=S.createElementNS(e,i),e[Cn]=n,e[Mo]=l,wf(e,n,!1,!1),n.stateNode=e;e:{switch(S=zn(i,l),i){case"dialog":We("cancel",e),We("close",e),f=l;break;case"iframe":case"object":case"embed":We("load",e),f=l;break;case"video":case"audio":for(f=0;fWi&&(n.flags|=128,l=!0,Oo(g,!1),n.lanes=4194304)}else{if(!l)if(e=Vs(S),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Oo(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Xe)return Nt(n),null}else 2*Ve()-g.renderingStartTime>Wi&&i!==1073741824&&(n.flags|=128,l=!0,Oo(g,!1),n.lanes=4194304);g.isBackwards?(S.sibling=n.child,n.child=S):(i=g.last,i!==null?i.sibling=S:n.child=S,g.last=S)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(Nt(n),null);case 22:case 23:return Nu(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Yt&1073741824)!==0&&(Nt(n),n.subtreeFlags&6&&(n.flags|=8192)):Nt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function Ly(e,n){switch(Ta(n),n.tag){case 1:return Tt(n.type)&&Rs(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Fi(),Ue(Rt),Ue(St),Ya(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Wa(n),null;case 13:if(Ue(qe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));$i()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Fi(),null;case 10:return Oa(n.type._context),null;case 22:case 23:return Nu(),null;case 24:return null;default:return null}}var Zs=!1,jt=!1,Ay=typeof WeakSet=="function"?WeakSet:Set,ye=null;function Bi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Ze(e,n,l)}else i.current=null}function fu(e,n,i){try{i()}catch(l){Ze(e,n,l)}}var kf=!1;function $y(e,n){if(Na=vs,e=ed(),ma(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,g=l.focusNode;l=l.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var S=0,T=-1,O=-1,J=0,ae=0,ue=e,le=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=S+f),ue!==g||l!==0&&ue.nodeType!==3||(O=S+l),ue.nodeType===3&&(S+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)le=ue,ue=ge;for(;;){if(ue===e)break t;if(le===i&&++J===f&&(T=S),le===g&&++ae===l&&(O=S),(ge=ue.nextSibling)!==null)break;ue=le,le=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(ja={focusedElem:e,selectionRange:i},vs=!1,ye=n;ye!==null;)if(n=ye,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ye=e;else for(;ye!==null;){n=ye;try{var xe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var we=xe.memoizedProps,et=xe.memoizedState,X=n.stateNode,B=X.getSnapshotBeforeUpdate(n.elementType===n.type?we:an(n.type,we),et);X.__reactInternalSnapshotBeforeUpdate=B}break;case 3:var Q=n.stateNode.containerInfo;Q.nodeType===1?Q.textContent="":Q.nodeType===9&&Q.documentElement&&Q.removeChild(Q.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(de){Ze(n,n.return,de)}if(e=n.sibling,e!==null){e.return=n.return,ye=e;break}ye=n.return}return xe=kf,kf=!1,xe}function Fo(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&e)===e){var g=f.destroy;f.destroy=void 0,g!==void 0&&fu(n,i,g)}f=f.next}while(f!==l)}}function Js(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function hu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function Nf(e){var n=e.alternate;n!==null&&(e.alternate=null,Nf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[Cn],delete n[Mo],delete n[Ma],delete n[vy],delete n[xy])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function jf(e){return e.tag===5||e.tag===3||e.tag===4}function bf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||jf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function pu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=Ps));else if(l!==4&&(e=e.child,e!==null))for(pu(e,n,i),e=e.sibling;e!==null;)pu(e,n,i),e=e.sibling}function gu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(gu(e,n,i),e=e.sibling;e!==null;)gu(e,n,i),e=e.sibling}var vt=null,un=!1;function kr(e,n,i){for(i=i.child;i!==null;)Ef(e,n,i),i=i.sibling}function Ef(e,n,i){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(Vn,i)}catch{}switch(i.tag){case 5:jt||Bi(i,n);case 6:var l=vt,f=un;vt=null,kr(e,n,i),vt=l,un=f,vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):vt.removeChild(i.stateNode));break;case 18:vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?Ca(e.parentNode,i):e.nodeType===1&&Ca(e,i),vo(e)):Ca(vt,i.stateNode));break;case 4:l=vt,f=un,vt=i.stateNode.containerInfo,un=!0,kr(e,n,i),vt=l,un=f;break;case 0:case 11:case 14:case 15:if(!jt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var g=f,S=g.destroy;g=g.tag,S!==void 0&&((g&2)!==0||(g&4)!==0)&&fu(i,n,S),f=f.next}while(f!==l)}kr(e,n,i);break;case 1:if(!jt&&(Bi(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Ze(i,n,T)}kr(e,n,i);break;case 21:kr(e,n,i);break;case 22:i.mode&1?(jt=(l=jt)||i.memoizedState!==null,kr(e,n,i),jt=l):kr(e,n,i);break;default:kr(e,n,i)}}function Cf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Ay),n.forEach(function(l){var f=Uy.bind(null,e,l);i.has(l)||(i.add(l),l.then(f,f))})}}function cn(e,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=S),l&=~g}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Dy(l/1960))-l,10e?16:e,jr===null)var l=!1;else{if(e=jr,jr=null,il=0,(ze&6)!==0)throw Error(o(331));var f=ze;for(ze|=4,ye=e.current;ye!==null;){var g=ye,S=g.child;if((ye.flags&16)!==0){var T=g.deletions;if(T!==null){for(var O=0;OVe()-vu?oi(e,0):yu|=i),$t(e,n)}function Hf(e,n){n===0&&((e.mode&1)===0?n=1:(n=Un,Un<<=1,(Un&130023424)===0&&(Un=4194304)));var i=Mt();e=Zn(e,n),e!==null&&(En(e,n,i),$t(e,i))}function Wy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Hf(e,i)}function Uy(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Hf(e,i)}var Bf;Bf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Rt.current)Lt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Lt=!1,Ry(e,n,i);Lt=(e.flags&131072)!==0}else Lt=!1,Xe&&(n.flags&1048576)!==0&&wd(n,$s,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Qs(e,n),e=n.pendingProps;var f=Ti(n,St.current);Oi(n,i),f=qa(null,n,l,e,f,i);var g=Ka();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Tt(l)?(g=!0,Ts(n)):g=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Ba(n),f.updater=qs,n.stateNode=f,f._reactInternals=n,nu(n,l,e,i),n=su(null,n,l,!0,g,i)):(n.tag=0,Xe&&g&&Ra(n),Ct(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Qs(e,n),e=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=Gy(l),e=an(l,e),f){case 0:n=ou(null,n,l,e,i);break e;case 1:n=pf(null,n,l,e,i);break e;case 11:n=uf(null,n,l,e,i);break e;case 14:n=cf(null,n,l,an(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),ou(e,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),pf(e,n,l,f,i);case 3:e:{if(gf(n),e===null)throw Error(o(387));l=n.pendingProps,g=n.memoizedState,f=g.element,Md(e,n),Bs(n,l,null,i);var S=n.memoizedState;if(l=S.element,g.isDehydrated)if(g={element:l,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){f=Hi(Error(o(423)),n),n=mf(e,n,l,i,f);break e}else if(l!==f){f=Hi(Error(o(424)),n),n=mf(e,n,l,i,f);break e}else for(Ut=yr(n.stateNode.containerInfo.firstChild),Wt=n,Xe=!0,ln=null,i=Ed(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if($i(),l===f){n=er(e,n,i);break e}Ct(e,n,l,i)}n=n.child}return n;case 5:return Rd(n),e===null&&Aa(n),l=n.type,f=n.pendingProps,g=e!==null?e.memoizedProps:null,S=f.children,ba(l,f)?S=null:g!==null&&ba(l,g)&&(n.flags|=32),hf(e,n),Ct(e,n,S,i),n.child;case 6:return e===null&&Aa(n),null;case 13:return yf(e,n,i);case 4:return Va(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=zi(n,null,l,i):Ct(e,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),uf(e,n,l,f,i);case 7:return Ct(e,n,n.pendingProps,i),n.child;case 8:return Ct(e,n,n.pendingProps.children,i),n.child;case 12:return Ct(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,g=n.memoizedProps,S=f.value,Be(Os,l._currentValue),l._currentValue=S,g!==null)if(sn(g.value,S)){if(g.children===f.children&&!Rt.current){n=er(e,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var T=g.dependencies;if(T!==null){S=g.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(g.tag===1){O=Jn(-1,i&-i),O.tag=2;var J=g.updateQueue;if(J!==null){J=J.shared;var ae=J.pending;ae===null?O.next=O:(O.next=ae.next,ae.next=O),J.pending=O}}g.lanes|=i,O=g.alternate,O!==null&&(O.lanes|=i),Fa(g.return,i,n),T.lanes|=i;break}O=O.next}}else if(g.tag===10)S=g.type===n.type?null:g.child;else if(g.tag===18){if(S=g.return,S===null)throw Error(o(341));S.lanes|=i,T=S.alternate,T!==null&&(T.lanes|=i),Fa(S,i,n),S=g.sibling}else S=g.child;if(S!==null)S.return=g;else for(S=g;S!==null;){if(S===n){S=null;break}if(g=S.sibling,g!==null){g.return=S.return,S=g;break}S=S.return}g=S}Ct(e,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,Oi(n,i),f=Zt(f),l=l(f),n.flags|=1,Ct(e,n,l,i),n.child;case 14:return l=n.type,f=an(l,n.pendingProps),f=an(l.type,f),cf(e,n,l,f,i);case 15:return df(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),Qs(e,n),n.tag=1,Tt(l)?(e=!0,Ts(n)):e=!1,Oi(n,i),tf(n,l,f),nu(n,l,f,i),su(null,n,l,!0,e,i);case 19:return xf(e,n,i);case 22:return ff(e,n,i)}throw Error(o(156,n.tag))};function Vf(e,n){return Hr(e,n)}function Yy(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tn(e,n,i,l){return new Yy(e,n,i,l)}function bu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Gy(e){if(typeof e=="function")return bu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ne)return 11;if(e===V)return 14}return 2}function Cr(e,n){var i=e.alternate;return i===null?(i=tn(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function al(e,n,i,l,f,g){var S=2;if(l=e,typeof e=="function")bu(e)&&(S=1);else if(typeof e=="string")S=5;else e:switch(e){case F:return li(i.children,f,g,n);case G:S=8,f|=8;break;case q:return e=tn(12,i,n,f|2),e.elementType=q,e.lanes=g,e;case K:return e=tn(13,i,n,f),e.elementType=K,e.lanes=g,e;case C:return e=tn(19,i,n,f),e.elementType=C,e.lanes=g,e;case U:return ul(i,f,g,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case te:S=10;break e;case ee:S=9;break e;case ne:S=11;break e;case V:S=14;break e;case W:S=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=tn(S,i,n,f),n.elementType=e,n.type=l,n.lanes=g,n}function li(e,n,i,l){return e=tn(7,e,l,n),e.lanes=i,e}function ul(e,n,i,l){return e=tn(22,e,l,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function Eu(e,n,i){return e=tn(6,e,null,n),e.lanes=i,e}function Cu(e,n,i){return n=tn(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Xy(e,n,i,l,f){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Yn(0),this.expirationTimes=Yn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Yn(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Mu(e,n,i,l,f,g,S,T,O){return e=new Xy(e,n,i,T,O),n===1?(n=1,g===!0&&(n|=8)):n=0,g=tn(3,null,null,n),e.current=g,g.stateNode=e,g.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ba(g),e}function qy(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),Au.exports=l0(),Au.exports}var rh;function a0(){if(rh)return ml;rh=1;var t=jp();return ml.createRoot=t.createRoot,ml.hydrateRoot=t.hydrateRoot,ml}var u0=a0();function bp(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Ae(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(bp(s,o.statusText||"Request failed"))}return o.json()}const c0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Pe={health:()=>Ae("/api/health"),settings:()=>Ae("/api/settings"),saveSettings:t=>{const r={...t};for(const o of c0)r[o]===""&&delete r[o];return Ae("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ae("/api/repos"),browse:t=>Ae(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ae(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ae("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ae(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Ae(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:(t,r=!0)=>Ae(`/api/architecture?repo_path=${encodeURIComponent(t)}&graph=${r?"1":"0"}`),architectureGraph:t=>Ae(`/api/architecture/graph?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Ae("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Ae("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Ae("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Ae("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Ae("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Ae(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open",s)=>Ae("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o,repo_path:s||null})}),scmRepos:t=>Ae(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ae("/api/oauth/status"),githubOAuthStart:()=>Ae("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ae("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ae("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Ae("/api/oauth/gitlab/start"),oauthDisconnect:t=>Ae("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ae("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})}),reviews:t=>Ae(`/api/reviews?repo_path=${encodeURIComponent(t)}`),getReview:(t,r)=>Ae(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(t)}`),reviewDiff:(t,r,o)=>Ae(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(t)}&other=${encodeURIComponent(o)}`),config:t=>Ae(`/api/config?repo_path=${encodeURIComponent(t)}`),saveConfig:(t,r)=>Ae("/api/config",{method:"PUT",body:JSON.stringify({repo_path:t,...r})}),addWaiver:(t,r,o,s)=>Ae("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:t,rule:r,node:o||null,reason:s||""})}),marks:(t,r)=>Ae(`/api/marks?repo_path=${encodeURIComponent(t)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:t=>Ae(`/api/architecture/health?repo_path=${encodeURIComponent(t)}`),workspaceStatus:t=>Ae(`/api/workspace/status?repo_path=${encodeURIComponent(t)}`),openEditor:(t,r,o,s)=>Ae("/api/open",{method:"POST",body:JSON.stringify({repo_path:t,path:r,line:o||null,editor:s||null})}),exportHtml:t=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:t})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(bp(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(t,r,o,s)=>Ae("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:t,edges:r,source_id:o,target_id:s||null})})};function d0(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):t}function f0({open:t,actions:r,onClose:o}){const[s,a]=L.useState(""),[u,c]=L.useState(0),h=L.useRef(null),p=L.useMemo(()=>d0(r,s),[r,s]);if(L.useEffect(()=>{if(!t)return;a(""),c(0);const y=window.setTimeout(()=>{var m;return(m=h.current)==null?void 0:m.focus()},0);return()=>window.clearTimeout(y)},[t]),L.useEffect(()=>{c(0)},[s]),!t)return null;const v=p[u],x=y=>{y&&(o(),y.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:y=>{y.target===y.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:y=>a(y.target.value),onKeyDown:y=>{y.key==="Escape"?(y.preventDefault(),o()):y.key==="ArrowDown"?(y.preventDefault(),c(m=>Math.min(p.length-1,m+1))):y.key==="ArrowUp"?(y.preventDefault(),c(m=>Math.max(0,m-1))):y.key==="Enter"&&(y.preventDefault(),x(v))}}),d.jsxs("ul",{children:[p.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,p.slice(0,40).map((y,m)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:m===u?"active":"",onMouseEnter:()=>c(m),onClick:()=>x(y),children:[d.jsx("span",{children:y.label}),y.hint?d.jsx("span",{className:"muted",children:y.hint}):null]})},y.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function h0({config:t,busy:r,onSave:o,onWaiver:s}){const[a,u]=L.useState(t),[c,h]=L.useState(t.available_rules[0]||""),[p,v]=L.useState(""),[x,y]=L.useState("");L.useEffect(()=>{u(t)},[t]);const m=Object.entries(a.contexts||{}),_=(R,w,N)=>{const A=a.contexts[R];if(!A)return;const $=F=>F.split(",").map(G=>G.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[R]:{...A,[w]:w==="name"?N:$(N)}}})},k=(R,w)=>{const N=w.trim();if(!N||N===R)return;const{[R]:A,...$}=a.contexts;A&&u({...a,contexts:{...$,[N]:{...A,name:N}}})},j=()=>{let R=1;for(;a.contexts[`context-${R}`];)R+=1;const w=`context-${R}`;u({...a,contexts:{...a.contexts,[w]:{name:w,django_apps:[],react:[],public_api:[],owners:[]}}})},b=R=>{const{[R]:w,...N}=a.contexts;u({...a,contexts:N})},E=R=>{const w=a.rules.includes(R);u({...a,rules:w?a.rules.filter(N=>N!==R):[...a.rules,R]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),m.map(([R,w])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:R})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:R,"data-testid":`config-context-name-${R}`,onBlur:N=>k(R,N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(w.django_apps||[]).join(", "),onChange:N=>_(R,"django_apps",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(w.react||[]).join(", "),onChange:N=>_(R,"react",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(w.public_api||[]).join(", "),onChange:N=>_(R,"public_api",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(w.owners||[]).join(", "),onChange:N=>_(R,"owners",N.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>b(R),children:"Remove context"})]},R)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:j,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(R),onChange:()=>E(R)}),R]},R))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((R,w)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:R.rule}),R.node?` · ${R.node}`:"",R.reason?` — ${R.reason}`:""]},`${R.rule}:${R.node}:${w}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:R=>h(R.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsx("option",{value:R,children:R},R))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:R=>v(R.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:x,onChange:R=>y(R.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,x),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function Zo(t){return t.replaceAll("_"," ")}function p0(t){return t.replaceAll("_"," ")}function io(t){return t.split(".").pop()||t}function ec(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function g0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Tr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function yi({className:t,children:r}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function m0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function y0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function v0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function x0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function w0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function Ep({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function _0({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const S0="modulepreload",k0=function(t,r){return new URL(t,r).href},ih={},N0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(x){return Promise.all(x.map(y=>Promise.resolve(y).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),v=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(x=>{if(x=k0(x,s),x in ih)return;ih[x]=!0;const y=x.endsWith(".css"),m=y?'[rel="stylesheet"]':"";if(!!s)for(let j=h.length-1;j>=0;j--){const b=h[j];if(b.href===x&&(!y||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${x}"]${m}`))return;const k=document.createElement("link");if(k.rel=y?"stylesheet":S0,y||(k.as="script"),k.crossOrigin="",k.href=x,v&&k.setAttribute("nonce",v),document.head.appendChild(k),y)return new Promise((j,b)=>{k.addEventListener("load",j),k.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${x}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function nt(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Yl(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}Cl.prototype=Yl.prototype={constructor:Cl,on:function(t,r){var o=this._,s=b0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),sh.hasOwnProperty(r)?{space:sh[r],local:t}:t}function C0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===tc&&r.documentElement.namespaceURI===tc?r.createElement(t):r.createElementNS(o,t)}}function M0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Cp(t){var r=Gl(t);return(r.local?M0:C0)(r)}function P0(){}function pc(t){return t==null?P0:function(){return this.querySelector(t)}}function I0(t){typeof t!="function"&&(t=pc(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=w&&(w=R+1);!(A=b[w])&&++w=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function nv(t){t||(t=rv);function r(y,m){return y&&m?t(y.__data__,m.__data__):!y-!m}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function iv(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function ov(){return Array.from(this)}function sv(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?yv:typeof r=="function"?xv:vv)(t,r,o??"")):Ki(this.node(),t)}function Ki(t,r){return t.style.getPropertyValue(r)||Tp(t).getComputedStyle(t,null).getPropertyValue(r)}function _v(t){return function(){delete this[t]}}function Sv(t,r){return function(){this[t]=r}}function kv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function Nv(t,r){return arguments.length>1?this.each((r==null?_v:typeof r=="function"?kv:Sv)(t,r)):this.node()[t]}function Lp(t){return t.trim().split(/^|\s+/)}function gc(t){return t.classList||new Ap(t)}function Ap(t){this._node=t,this._names=Lp(t.getAttribute("class")||"")}Ap.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function $p(t,r){for(var o=gc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function Zv(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function nc(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:v,dispatch:x}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:v,enumerable:!0,configurable:!0},_:{value:x}})}nc.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function ax(t){return!t.ctrlKey&&!t.button}function ux(){return this.parentNode}function cx(t,r){return r??{x:t.x,y:t.y}}function dx(){return navigator.maxTouchPoints||"ontouchstart"in this}function Bp(){var t=ax,r=ux,o=cx,s=dx,a={},u=Yl("start","drag","end"),c=0,h,p,v,x,y=0;function m(N){N.on("mousedown.drag",_).filter(s).on("touchstart.drag",b).on("touchmove.drag",E,lx).on("touchend.drag touchcancel.drag",R).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(N,A){if(!(x||!t.call(this,N,A))){var $=w(this,r.call(this,N,A),N,A,"mouse");$&&(Gt(N.view).on("mousemove.drag",k,Jo).on("mouseup.drag",j,Jo),Fp(N.view),Du(N),v=!1,h=N.clientX,p=N.clientY,$("start",N))}}function k(N){if(Xi(N),!v){var A=N.clientX-h,$=N.clientY-p;v=A*A+$*$>y}a.mouse("drag",N)}function j(N){Gt(N.view).on("mousemove.drag mouseup.drag",null),Hp(N.view,v),Xi(N),a.mouse("end",N)}function b(N,A){if(t.call(this,N,A)){var $=N.changedTouches,F=r.call(this,N,A),G=$.length,q,te;for(q=0;q>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?vl(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?vl(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=hx.exec(t))?new Dt(r[1],r[2],r[3],1):(r=px.exec(t))?new Dt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=gx.exec(t))?vl(r[1],r[2],r[3],r[4]):(r=mx.exec(t))?vl(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=yx.exec(t))?hh(r[1],r[2]/100,r[3]/100,1):(r=vx.exec(t))?hh(r[1],r[2]/100,r[3]/100,r[4]):lh.hasOwnProperty(t)?ch(lh[t]):t==="transparent"?new Dt(NaN,NaN,NaN,0):null}function ch(t){return new Dt(t>>16&255,t>>8&255,t&255,1)}function vl(t,r,o,s){return s<=0&&(t=r=o=NaN),new Dt(t,r,o,s)}function _x(t){return t instanceof ds||(t=fi(t)),t?(t=t.rgb(),new Dt(t.r,t.g,t.b,t.opacity)):new Dt}function rc(t,r,o,s){return arguments.length===1?_x(t):new Dt(t,r,o,s??1)}function Dt(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}mc(Dt,rc,Vp(ds,{brighter(t){return t=t==null?Ll:Math.pow(Ll,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?es:Math.pow(es,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Dt(ci(this.r),ci(this.g),ci(this.b),Al(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:dh,formatHex:dh,formatHex8:Sx,formatRgb:fh,toString:fh}));function dh(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}`}function Sx(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}${ui((isNaN(this.opacity)?1:this.opacity)*255)}`}function fh(){const t=Al(this.opacity);return`${t===1?"rgb(":"rgba("}${ci(this.r)}, ${ci(this.g)}, ${ci(this.b)}${t===1?")":`, ${t})`}`}function Al(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ci(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ui(t){return t=ci(t),(t<16?"0":"")+t.toString(16)}function hh(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new hn(t,r,o,s)}function Wp(t){if(t instanceof hn)return new hn(t.h,t.s,t.l,t.opacity);if(t instanceof ds||(t=fi(t)),!t)return new hn;if(t instanceof hn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new hn(c,h,p,t.opacity)}function kx(t,r,o,s){return arguments.length===1?Wp(t):new hn(t,r,o,s??1)}function hn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}mc(hn,kx,Vp(ds,{brighter(t){return t=t==null?Ll:Math.pow(Ll,t),new hn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?es:Math.pow(es,t),new hn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Dt(Ou(t>=240?t-240:t+120,a,s),Ou(t,a,s),Ou(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new hn(ph(this.h),xl(this.s),xl(this.l),Al(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 t=Al(this.opacity);return`${t===1?"hsl(":"hsla("}${ph(this.h)}, ${xl(this.s)*100}%, ${xl(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ph(t){return t=(t||0)%360,t<0?t+360:t}function xl(t){return Math.max(0,Math.min(1,t||0))}function Ou(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const yc=t=>()=>t;function Nx(t,r){return function(o){return t+o*r}}function jx(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function bx(t){return(t=+t)==1?Up:function(r,o){return o-r?jx(r,o,t):yc(isNaN(r)?o:r)}}function Up(t,r){var o=r-t;return o?Nx(t,o):yc(isNaN(t)?r:t)}const $l=(function t(r){var o=bx(r);function s(a,u){var c=o((a=rc(a)).r,(u=rc(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),v=Up(a.opacity,u.opacity);return function(x){return a.r=c(x),a.g=h(x),a.b=p(x),a.opacity=v(x),a+""}}return s.gamma=t,s})(1);function Ex(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:Rn(s,a)})),o=Fu.lastIndex;return o180?x+=360:x-v>180&&(v+=360),m.push({i:y.push(a(y)+"rotate(",null,s)-2,x:Rn(v,x)})):x&&y.push(a(y)+"rotate("+x+s)}function h(v,x,y,m){v!==x?m.push({i:y.push(a(y)+"skewX(",null,s)-2,x:Rn(v,x)}):x&&y.push(a(y)+"skewX("+x+s)}function p(v,x,y,m,_,k){if(v!==y||x!==m){var j=_.push(a(_)+"scale(",null,",",null,")");k.push({i:j-4,x:Rn(v,y)},{i:j-2,x:Rn(x,m)})}else(y!==1||m!==1)&&_.push(a(_)+"scale("+y+","+m+")")}return function(v,x){var y=[],m=[];return v=t(v),x=t(x),u(v.translateX,v.translateY,x.translateX,x.translateY,y,m),c(v.rotate,x.rotate,y,m),h(v.skewX,x.skewX,y,m),p(v.scaleX,v.scaleY,x.scaleX,x.scaleY,y,m),v=x=null,function(_){for(var k=-1,j=m.length,b;++k=0&&t._call.call(void 0,r),t=t._next;--Qi}function yh(){hi=(Dl=ns.now())+Xl,Qi=Xo=0;try{Bx()}finally{Qi=0,Wx(),hi=0}}function Vx(){var t=ns.now(),r=t-Dl;r>qp&&(Xl-=r,Dl=t)}function Wx(){for(var t,r=zl,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:zl=o);qo=t,sc(s)}function sc(t){if(!Qi){Xo&&(Xo=clearTimeout(Xo));var r=t-hi;r>24?(t<1/0&&(Xo=setTimeout(yh,t-ns.now()-Xl)),Yo&&(Yo=clearInterval(Yo))):(Yo||(Dl=ns.now(),Yo=setInterval(Vx,qp)),Qi=1,Kp(yh))}}function vh(t,r,o){var s=new Ol;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Ux=Yl("start","end","cancel","interrupt"),Yx=[],Zp=0,xh=1,lc=2,Pl=3,wh=4,ac=5,Il=6;function ql(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;Gx(t,o,{name:r,index:s,group:a,on:Ux,tween:Yx,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Zp})}function xc(t,r){var o=yn(t,r);if(o.state>Zp)throw new Error("too late; already scheduled");return o}function Ln(t,r){var o=yn(t,r);if(o.state>Pl)throw new Error("too late; already running");return o}function yn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Gx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=Qp(u,0,o.time);function u(v){o.state=xh,o.timer.restart(c,o.delay,o.time),o.delay<=v&&c(v-o.delay)}function c(v){var x,y,m,_;if(o.state!==xh)return p();for(x in s)if(_=s[x],_.name===o.name){if(_.state===Pl)return vh(c);_.state===wh?(_.state=Il,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete s[x]):+xlc&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function kw(t,r,o){var s,a,u=Sw(r)?xc:Ln;return function(){var c=u(this,t),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function Nw(t,r){var o=this._id;return arguments.length<2?yn(this.node(),o).on.on(t):this.each(kw(o,t,r))}function jw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function bw(){return this.on("end.remove",jw(this._id))}function Ew(t){var r=this._name,o=this._id;typeof t!="function"&&(t=pc(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function Zw(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function rr(t,r,o){this.k=t,this.x=r,this.y=o}rr.prototype={constructor:rr,scale:function(t){return t===1?this:new rr(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new rr(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Kl=new rr(1,0,0);ng.prototype=rr.prototype;function ng(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Kl;return t.__zoom}function Hu(t){t.stopImmediatePropagation()}function Go(t){t.preventDefault(),t.stopImmediatePropagation()}function Jw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function e1(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function _h(){return this.__zoom||Kl}function t1(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function n1(){return navigator.maxTouchPoints||"ontouchstart"in this}function r1(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function rg(){var t=Jw,r=e1,o=r1,s=t1,a=n1,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=Ml,v=Yl("start","zoom","end"),x,y,m,_=500,k=150,j=0,b=10;function E(C){C.property("__zoom",_h).on("wheel.zoom",G,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",te).filter(a).on("touchstart.zoom",ee).on("touchmove.zoom",ne).on("touchend.zoom touchcancel.zoom",K).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(C,V,W,U){var M=C.selection?C.selection():C;M.property("__zoom",_h),C!==M?A(C,V,W,U):M.interrupt().each(function(){$(this,arguments).event(U).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},E.scaleBy=function(C,V,W,U){E.scaleTo(C,function(){var M=this.__zoom.k,D=typeof V=="function"?V.apply(this,arguments):V;return M*D},W,U)},E.scaleTo=function(C,V,W,U){E.transform(C,function(){var M=r.apply(this,arguments),D=this.__zoom,H=W==null?N(M):typeof W=="function"?W.apply(this,arguments):W,I=D.invert(H),z=typeof V=="function"?V.apply(this,arguments):V;return o(w(R(D,z),H,I),M,c)},W,U)},E.translateBy=function(C,V,W,U){E.transform(C,function(){return o(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),r.apply(this,arguments),c)},null,U)},E.translateTo=function(C,V,W,U,M){E.transform(C,function(){var D=r.apply(this,arguments),H=this.__zoom,I=U==null?N(D):typeof U=="function"?U.apply(this,arguments):U;return o(Kl.translate(I[0],I[1]).scale(H.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),D,c)},U,M)};function R(C,V){return V=Math.max(u[0],Math.min(u[1],V)),V===C.k?C:new rr(V,C.x,C.y)}function w(C,V,W){var U=V[0]-W[0]*C.k,M=V[1]-W[1]*C.k;return U===C.x&&M===C.y?C:new rr(C.k,U,M)}function N(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function A(C,V,W,U){C.on("start.zoom",function(){$(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(U).end()}).tween("zoom",function(){var M=this,D=arguments,H=$(M,D).event(U),I=r.apply(M,D),z=W==null?N(I):typeof W=="function"?W.apply(M,D):W,ie=Math.max(I[1][0]-I[0][0],I[1][1]-I[0][1]),oe=M.__zoom,fe=typeof V=="function"?V.apply(M,D):V,he=p(oe.invert(z).concat(ie/oe.k),fe.invert(z).concat(ie/fe.k));return function(pe){if(pe===1)pe=fe;else{var Z=he(pe),se=ie/Z[2];pe=new rr(se,z[0]-Z[0]*se,z[1]-Z[1]*se)}H.zoom(null,pe)}})}function $(C,V,W){return!W&&C.__zooming||new F(C,V)}function F(C,V){this.that=C,this.args=V,this.active=0,this.sourceEvent=null,this.extent=r.apply(C,V),this.taps=0}F.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,V){return this.mouse&&C!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var V=Gt(this.that).datum();v.call(C,this.that,new Zw(C,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:v}),V)}};function G(C,...V){if(!t.apply(this,arguments))return;var W=$(this,V).event(C),U=this.__zoom,M=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,s.apply(this,arguments)))),D=fn(C);if(W.wheel)(W.mouse[0][0]!==D[0]||W.mouse[0][1]!==D[1])&&(W.mouse[1]=U.invert(W.mouse[0]=D)),clearTimeout(W.wheel);else{if(U.k===M)return;W.mouse=[D,U.invert(D)],Rl(this),W.start()}Go(C),W.wheel=setTimeout(H,k),W.zoom("mouse",o(w(R(U,M),W.mouse[0],W.mouse[1]),W.extent,c));function H(){W.wheel=null,W.end()}}function q(C,...V){if(m||!t.apply(this,arguments))return;var W=C.currentTarget,U=$(this,V,!0).event(C),M=Gt(C.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",ie,!0),D=fn(C,W),H=C.clientX,I=C.clientY;Fp(C.view),Hu(C),U.mouse=[D,this.__zoom.invert(D)],Rl(this),U.start();function z(oe){if(Go(oe),!U.moved){var fe=oe.clientX-H,he=oe.clientY-I;U.moved=fe*fe+he*he>j}U.event(oe).zoom("mouse",o(w(U.that.__zoom,U.mouse[0]=fn(oe,W),U.mouse[1]),U.extent,c))}function ie(oe){M.on("mousemove.zoom mouseup.zoom",null),Hp(oe.view,U.moved),Go(oe),U.event(oe).end()}}function te(C,...V){if(t.apply(this,arguments)){var W=this.__zoom,U=fn(C.changedTouches?C.changedTouches[0]:C,this),M=W.invert(U),D=W.k*(C.shiftKey?.5:2),H=o(w(R(W,D),U,M),r.apply(this,V),c);Go(C),h>0?Gt(this).transition().duration(h).call(A,H,U,C):Gt(this).call(E.transform,H,U,C)}}function ee(C,...V){if(t.apply(this,arguments)){var W=C.touches,U=W.length,M=$(this,V,C.changedTouches.length===U).event(C),D,H,I,z;for(Hu(C),H=0;H`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},rs=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ig=["Enter"," ","Escape"],og={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Zi;(function(t){t.Strict="strict",t.Loose="loose"})(Zi||(Zi={}));var di;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(di||(di={}));var is;(function(t){t.Partial="partial",t.Full="full"})(is||(is={}));const sg={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Lr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Lr||(Lr={}));var os;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(os||(os={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const Sh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function lg(t){return t===null?null:t?"valid":"invalid"}const ag=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,i1=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),_c=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),fs=(t,r=[0,0])=>{const{width:o,height:s}=vn(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},o1=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):_c(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,Ql(a,Fl(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?Zl(s):{x:0,y:0,width:0,height:0}},hs=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=Ql(o,Fl(a)),s=!0)}),s?Zl(o):{x:0,y:0,width:0,height:0}},Sc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,v=r.width/a,x=r.height/a,y=[];for(const m of t.values()){const{measured:_,selectable:k=!0,hidden:j=!1}=m;if(c&&!k||j)continue;const b=_.width??m.width??m.initialWidth??0,E=_.height??m.height??m.initialHeight??0,{x:R,y:w}=m.internals.positionAbsolute,N=fg(h,p,v,x,R,w,b,E),A=b*E,$=u&&N>0;(!m.internals.handleBounds||$||N>=A||m.dragging)&&y.push(m)}return y},s1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function l1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=vn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function a1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const h=l1(t,c),p=hs(h),v=Nc(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(v,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function ug({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),h=c.parentId?o.get(c.parentId):void 0,{x:p,y:v}=h?h.internals.positionAbsolute:{x:0,y:0},x=c.origin??s;let y=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",mn.error005());else{const{width:_,height:k}=vn(h);_&&k&&(y=[[p,v],[p+_,v+k]])}else h&&gi(c.extent)&&(y=[[c.extent[0][0]+p,c.extent[0][1]+v],[c.extent[1][0]+p,c.extent[1][1]+v]]);const m=gi(y)?pi(r,y,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",mn.error015())),{position:{x:m.x-p+(c.measured.width??0)*x[0],y:m.y-v+(c.measured.height??0)*x[1]},positionAbsolute:m}}async function u1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(m=>m.id)),c=[];for(const m of o){if(m.deletable===!1)continue;const _=u.has(m.id),k=!_&&m.parentId&&c.find(j=>j.id===m.parentId);(_||k)&&c.push(m)}const h=new Set(r.map(m=>m.id)),p=s.filter(m=>m.deletable!==!1),x=s1(c,p);for(const m of p)h.has(m.id)&&!x.find(k=>k.id===m.id)&&x.push(m);if(!a)return{edges:x,nodes:c};const y=await a({nodes:c,edges:x});return typeof y=="boolean"?y?{edges:x,nodes:c}:{edges:[],nodes:[]}:y}const Ji=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),pi=(t={x:0,y:0},r,o)=>({x:Ji(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:Ji(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function cg(t,r,o){const{width:s,height:a}=vn(o),{x:u,y:c}=o.internals.positionAbsolute;return pi(t,[[u,c],[u+s,c+a]],r)}const kh=(t,r,o)=>to?-Ji(Math.abs(t-o),1,r)/r:0,kc=(t,r,o=15,s=40)=>{const a=kh(t.x,s,r.width-s)*o,u=kh(t.y,s,r.height-s)*o;return[a,u]},Ql=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),uc=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),Zl=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),ss=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:fs(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},Fl=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:fs(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},dg=(t,r)=>Zl(Ql(uc(t),uc(r))),fg=(t,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),v=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*v)},Hl=(t,r)=>fg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),Nh=t=>pn(t.width)&&pn(t.height)&&pn(t.x)&&pn(t.y),pn=t=>!isNaN(t)&&isFinite(t),hg=(t,r)=>(o,s)=>{},ps=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),gs=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(t-o)/a,y:(r-s)/a};return u?ps(h,c):h},eo=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Yi(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function c1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Yi(t,o),a=Yi(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Yi(t.top??t.y??0,o),a=Yi(t.bottom??t.y??0,o),u=Yi(t.left??t.x??0,r),c=Yi(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function d1(t,r,o,s,a,u){const{x:c,y:h}=eo(t,[r,o,s]),{x:p,y:v}=eo({x:t.x+t.width,y:t.y+t.height},[r,o,s]),x=a-p,y=u-v;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(x),bottom:Math.floor(y)}}const Nc=(t,r,o,s,a,u)=>{const c=c1(u,r,o),h=(r-c.x)/t.width,p=(o-c.y)/t.height,v=Math.min(h,p),x=Ji(v,s,a),y=t.x+t.width/2,m=t.y+t.height/2,_=r/2-y*x,k=o/2-m*x,j=d1(t,_,k,x,r,o),b={left:Math.min(j.left-c.left,0),top:Math.min(j.top-c.top,0),right:Math.min(j.right-c.right,0),bottom:Math.min(j.bottom-c.bottom,0)};return{x:_-b.left+b.right,y:k-b.top+b.bottom,zoom:x}},ls=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function gi(t){return t!=null&&t!=="parent"}function vn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function pg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function gg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function jh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function f1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function h1(t){return{...og,...t||{}}}function Qo(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=gn(t),h=gs({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y:v}=o?ps(h,r):h;return{xSnapped:p,ySnapped:v,...h}}const jc=t=>({width:t.offsetWidth,height:t.offsetHeight}),mg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},p1=["INPUT","SELECT","TEXTAREA"];function yg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:p1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const vg=t=>"clientX"in t,gn=(t,r)=>{var u,c;const o=vg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},bh=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...jc(c)}})};function xg({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=t*.125+a*.375+c*.375+o*.125,v=r*.125+u*.375+h*.375+s*.125,x=Math.abs(p-t),y=Math.abs(v-r);return[p,v,x,y]}function Sl(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function Eh({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case Se.Left:return[r-Sl(r-s,u),o];case Se.Right:return[r+Sl(s-r,u),o];case Se.Top:return[r,o-Sl(o-a,u)];case Se.Bottom:return[r,o+Sl(a-o,u)]}}function wg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top,curvature:c=.25}){const[h,p]=Eh({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[v,x]=Eh({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[y,m,_,k]=xg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:v,targetControlY:x});return[`M${t},${r} C${h},${p} ${v},${x} ${s},${a}`,y,m,_,k]}function _g({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const y1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,v1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),x1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",mn.error006()),r;const s=o.getEdgeId||y1;let a;return ag(t)?a={...t}:a={...t,id:s(t)},v1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function Sg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=_g({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,h]}const Ch={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},w1=({source:t,sourcePosition:r=Se.Bottom,target:o})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function _1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:s=Se.Top,center:a,offset:u,stepPosition:c}){const h=Ch[r],p=Ch[s],v={x:t.x+h.x*u,y:t.y+h.y*u},x={x:o.x+p.x*u,y:o.y+p.y*u},y=w1({source:v,sourcePosition:r,target:x}),m=y.x!==0?"x":"y",_=y[m];let k=[],j,b;const E={x:0,y:0},R={x:0,y:0},[,,w,N]=_g({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[m]*p[m]===-1){m==="x"?(j=a.x??v.x+(x.x-v.x)*c,b=a.y??(v.y+x.y)/2):(j=a.x??(v.x+x.x)/2,b=a.y??v.y+(x.y-v.y)*c);const G=[{x:j,y:v.y},{x:j,y:x.y}],q=[{x:v.x,y:b},{x:x.x,y:b}];h[m]===_?k=m==="x"?G:q:k=m==="x"?q:G}else{const G=[{x:v.x,y:x.y}],q=[{x:x.x,y:v.y}];if(m==="x"?k=h.x===_?q:G:k=h.y===_?G:q,r===s){const C=Math.abs(t[m]-o[m]);if(C<=u){const V=Math.min(u-1,u-C);h[m]===_?E[m]=(v[m]>t[m]?-1:1)*V:R[m]=(x[m]>o[m]?-1:1)*V}}if(r!==s){const C=m==="x"?"y":"x",V=h[m]===p[C],W=v[C]>x[C],U=v[C]=K?(j=(te.x+ee.x)/2,b=k[0].y):(j=k[0].x,b=(te.y+ee.y)/2)}const A={x:v.x+E.x,y:v.y+E.y},$={x:x.x+R.x,y:x.y+R.y};return[[t,...A.x!==k[0].x||A.y!==k[0].y?[A]:[],...k,...$.x!==k[k.length-1].x||$.y!==k[k.length-1].y?[$]:[],o],j,b,w,N]}function S1(t,r,o,s){const a=Math.min(Mh(t,r)/2,Mh(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const v=t.xo.id===r):t[0])||null}function cc(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function N1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const v=cc(p,r);u.has(v)||(c.push({id:v,color:p.color||o,...p}),u.add(v))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const kg=1e3,j1=10,bc={nodeOrigin:[0,0],nodeExtent:rs,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},b1={...bc,checkEquality:!0};function Ec(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function E1(t,r,o){const s=Ec(bc,o);for(const a of t.values())if(a.parentId)Mc(a,t,r,s);else{const u=fs(a,s.nodeOrigin),c=gi(a.extent)?a.extent:s.nodeExtent,h=pi(u,c,vn(a));a.internals.positionAbsolute=h}}function C1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function Cc(t){return t==="manual"}function dc(t,r,o,s={}){var x,y;const a=Ec(b1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!Cc(a.zIndexMode)?kg:0;let p=t.length>0,v=!1;r.clear(),o.clear();for(const m of t){let _=c.get(m.id);if(a.checkEquality&&m===(_==null?void 0:_.internals.userNode))r.set(m.id,_);else{const k=fs(m,a.nodeOrigin),j=gi(m.extent)?m.extent:a.nodeExtent,b=pi(k,j,vn(m));_={...a.defaults,...m,measured:{width:(x=m.measured)==null?void 0:x.width,height:(y=m.measured)==null?void 0:y.height},internals:{positionAbsolute:b,handleBounds:C1(m,_),z:Ng(m,h,a.zIndexMode),userNode:m}},r.set(m.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),m.parentId&&Mc(_,r,o,s,u),v||(v=m.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:v}}function M1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function Mc(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=Ec(bc,s),v=t.parentId,x=r.get(v);if(!x){console.warn(`Parent node ${v} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}M1(t,o),a&&!x.parentId&&x.internals.rootParentIndex===void 0&&p==="auto"&&(x.internals.rootParentIndex=++a.i,x.internals.z=x.internals.z+a.i*j1),a&&x.internals.rootParentIndex!==void 0&&(a.i=x.internals.rootParentIndex);const y=u&&!Cc(p)?kg:0,{x:m,y:_,z:k}=P1(t,x,c,h,y,p),{positionAbsolute:j}=t.internals,b=m!==j.x||_!==j.y;(b||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:b?{x:m,y:_}:j,z:k}})}function Ng(t,r,o){const s=pn(t.zIndex)?t.zIndex:0;return Cc(o)?s:s+(t.selected?r:0)}function P1(t,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=vn(t),v=fs(t,o),x=gi(t.extent)?pi(v,t.extent,p):v;let y=pi({x:c+x.x,y:h+x.y},s,p);t.extent==="parent"&&(y=cg(y,p,r));const m=Ng(t,a,u),_=r.internals.z??0;return{x:y.x,y:y.y,z:_>=m?_+1:m}}function Pc(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const v=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??ss(p),x=dg(v,h.rect);u.set(h.parentId,{expandedRect:x,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},v)=>{var w;const x=p.internals.positionAbsolute,y=vn(p),m=p.origin??s,_=h.x0||k>0||E||R)&&(a.push({id:v,type:"position",position:{x:p.position.x-_+E,y:p.position.y-k+R}}),(w=o.get(v))==null||w.forEach(N=>{t.some(A=>A.id===N.id)||a.push({id:N.id,type:"position",position:{x:N.position.x+_,y:N.position.y+k}})})),(y.width0){const _=Pc(m,r,o,a);v.push(..._)}return{changes:v,updatedInternals:p}}async function R1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Th(t,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${t}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${t}-${u}`;const v=s.get(c)||new Map;s.set(c,v.set(o,r))}}function jg(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},v=`${a}-${c}--${u}-${h}`,x=`${u}-${h}--${a}-${c}`;Th("source",p,x,t,a,c),Th("target",p,v,t,u,h),r.set(s.id,s)}}function bg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:bg(o,r):!1}function Lh(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function T1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!bg(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function Bu({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[v,x]of r){const y=(c=o.get(v))==null?void 0:c.internals.userNode;y&&a.push({...y,position:x.position,dragging:s})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function L1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=ps(u,r);return{x:c.x-u.x,y:c.y-u.y}}function A1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,v={x:0,y:0},x=null,y=!1,m=null,_=!1,k=!1,j=null;function b({noDragClassName:R,handleSelector:w,domNode:N,isSelectable:A,nodeId:$,nodeClickDistance:F=0}){m=Gt(N);function G({x:ne,y:K}){const{nodeLookup:C,nodeExtent:V,snapGrid:W,snapToGrid:U,nodeOrigin:M,onNodeDrag:D,onSelectionDrag:H,onError:I,updateNodePositions:z}=r();u={x:ne,y:K};let ie=!1;const oe=h.size>1,fe=oe&&V?uc(hs(h)):null,he=oe&&U?L1({dragItems:h,snapGrid:W,x:ne,y:K}):null;for(const[pe,Z]of h){if(!C.has(pe))continue;let se={x:ne-Z.distance.x,y:K-Z.distance.y};U&&(se=he?{x:Math.round(se.x+he.x),y:Math.round(se.y+he.y)}:ps(se,W));let me=null;if(oe&&V&&!Z.extent&&fe){const{positionAbsolute:re}=Z.internals,Ne=re.x-fe.x+V[0][0],Me=re.x+Z.measured.width-fe.x2+V[1][0],Te=re.y-fe.y+V[0][1],$e=re.y+Z.measured.height-fe.y2+V[1][1];me=[[Ne,Te],[Me,$e]]}const{position:ke,positionAbsolute:ve}=ug({nodeId:pe,nextPosition:se,nodeLookup:C,nodeExtent:me||V,nodeOrigin:M,onError:I});ie=ie||Z.position.x!==ke.x||Z.position.y!==ke.y,Z.position=ke,Z.internals.positionAbsolute=ve}if(k=k||ie,!!ie&&(z(h,!0),j&&(s||D||!$&&H))){const[pe,Z]=Bu({nodeId:$,dragItems:h,nodeLookup:C});s==null||s(j,h,pe,Z),D==null||D(j,pe,Z),$||H==null||H(j,Z)}}async function q(){if(!x)return;const{transform:ne,panBy:K,autoPanSpeed:C,autoPanOnNodeDrag:V}=r();if(!V){p=!1,cancelAnimationFrame(c);return}const[W,U]=kc(v,x,C);(W!==0||U!==0)&&(u.x=(u.x??0)-W/ne[2],u.y=(u.y??0)-U/ne[2],await K({x:W,y:U})&&G(u)),c=requestAnimationFrame(q)}function te(ne){var oe;const{nodeLookup:K,multiSelectionActive:C,nodesDraggable:V,transform:W,snapGrid:U,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:H,onSelectionDragStart:I,unselectNodesAndEdges:z}=r();y=!0,(!D||!A)&&!C&&$&&((oe=K.get($))!=null&&oe.selected||z()),A&&D&&$&&(t==null||t($));const ie=Qo(ne.sourceEvent,{transform:W,snapGrid:U,snapToGrid:M,containerBounds:x});if(u=ie,h=T1(K,V,ie,$),h.size>0&&(o||H||!$&&I)){const[fe,he]=Bu({nodeId:$,dragItems:h,nodeLookup:K});o==null||o(ne.sourceEvent,h,fe,he),H==null||H(ne.sourceEvent,fe,he),$||I==null||I(ne.sourceEvent,he)}}const ee=Bp().clickDistance(F).on("start",ne=>{const{domNode:K,nodeDragThreshold:C,transform:V,snapGrid:W,snapToGrid:U}=r();x=(K==null?void 0:K.getBoundingClientRect())||null,_=!1,k=!1,j=ne.sourceEvent,C===0&&te(ne),u=Qo(ne.sourceEvent,{transform:V,snapGrid:W,snapToGrid:U,containerBounds:x}),v=gn(ne.sourceEvent,x)}).on("drag",ne=>{const{autoPanOnNodeDrag:K,transform:C,snapGrid:V,snapToGrid:W,nodeDragThreshold:U,nodeLookup:M}=r(),D=Qo(ne.sourceEvent,{transform:C,snapGrid:V,snapToGrid:W,containerBounds:x});if(j=ne.sourceEvent,(ne.sourceEvent.type==="touchmove"&&ne.sourceEvent.touches.length>1||$&&!M.has($))&&(_=!0),!_){if(!p&&K&&y&&(p=!0,q()),!y){const H=gn(ne.sourceEvent,x),I=H.x-v.x,z=H.y-v.y;Math.sqrt(I*I+z*z)>U&&te(ne)}(u.x!==D.xSnapped||u.y!==D.ySnapped)&&h&&y&&(v=gn(ne.sourceEvent,x),G(D))}}).on("end",ne=>{if(!y||_){_&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,y=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:K,updateNodePositions:C,onNodeDragStop:V,onSelectionDragStop:W}=r();if(k&&(C(h,!1),k=!1),a||V||!$&&W){const[U,M]=Bu({nodeId:$,dragItems:h,nodeLookup:K,dragging:!1});a==null||a(ne.sourceEvent,h,U,M),V==null||V(ne.sourceEvent,U,M),$||W==null||W(ne.sourceEvent,M)}}}).filter(ne=>{const K=ne.target;return!ne.button&&(!R||!Lh(K,`.${R}`,N))&&(!w||Lh(K,w,N))});m.call(ee)}function E(){m==null||m.on(".drag",null)}return{update:b,destroy:E}}function $1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())Hl(a,ss(u))>0&&s.push(u);return s}const z1=250;function D1(t,r,o,s){var h,p;let a=[],u=1/0;const c=$1(t,o,r+z1);for(const v of c){const x=[...((h=v.internals.handleBounds)==null?void 0:h.source)??[],...((p=v.internals.handleBounds)==null?void 0:p.target)??[]];for(const y of x){if(s.nodeId===y.nodeId&&s.type===y.type&&s.id===y.id)continue;const{x:m,y:_}=mi(v,y,y.position,!0),k=Math.sqrt(Math.pow(m-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const v=s.type==="source"?"target":"source";return a.find(x=>x.type===v)??a[0]}return a[0]}function Eg(t,r,o,s,a,u=!1){var v,x,y;const c=s.get(t);if(!c)return null;const h=a==="strict"?(v=c.internals.handleBounds)==null?void 0:v[r]:[...((x=c.internals.handleBounds)==null?void 0:x.source)??[],...((y=c.internals.handleBounds)==null?void 0:y.target)??[]],p=(o?h==null?void 0:h.find(m=>m.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...mi(c,p,p.position,!0)}:p}function Cg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function O1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const Mg=()=>!0;function F1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:v,autoPanOnConnect:x,flowId:y,panBy:m,cancelConnection:_,onConnectStart:k,onConnect:j,onConnectEnd:b,isValidConnection:E=Mg,onReconnectEnd:R,updateConnection:w,getTransform:N,getFromHandle:A,autoPanSpeed:$,dragThreshold:F=1,handleDomNode:G}){const q=mg(t.target);let te=0,ee;const{x:ne,y:K}=gn(t),C=Cg(u,G),V=h==null?void 0:h.getBoundingClientRect();let W=!1;if(!V||!C)return;const U=Eg(a,C,s,p,r);if(!U)return;let M=gn(t,V),D=!1,H=null,I=!1,z=null;function ie(){if(!x||!V)return;const[ke,ve]=kc(M,V,$);m({x:ke,y:ve}),te=requestAnimationFrame(ie)}const oe={...U,nodeId:a,type:C,position:U.position},fe=p.get(a);let pe={inProgress:!0,isValid:null,from:mi(fe,oe,Se.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:fe,to:M,toHandle:null,toPosition:Sh[oe.position],toNode:null,pointer:M};function Z(){W=!0,w(pe),k==null||k(t,{nodeId:a,handleId:s,handleType:C})}F===0&&Z();function se(ke){if(!W){const{x:$e,y:st}=gn(ke),lt=$e-ne,at=st-K;if(!(lt*lt+at*at>F*F))return;Z()}if(!A()||!oe){me(ke);return}const ve=N();M=gn(ke,V),ee=D1(gs(M,ve,!1,[1,1]),o,p,oe),D||(ie(),D=!0);const re=Pg(ke,{handle:ee,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:E,doc:q,lib:v,flowId:y,nodeLookup:p});z=re.handleDomNode,H=re.connection,I=O1(!!ee,re.isValid);const Ne=p.get(a),Me=Ne?mi(Ne,oe,Se.Left,!0):pe.from,Te={...pe,from:Me,isValid:I,to:re.toHandle&&I?eo({x:re.toHandle.x,y:re.toHandle.y},ve):M,toHandle:re.toHandle,toPosition:I&&re.toHandle?re.toHandle.position:Sh[oe.position],toNode:re.toHandle?p.get(re.toHandle.nodeId):null,pointer:M};w(Te),pe=Te}function me(ke){if(!("touches"in ke&&ke.touches.length>0)){if(W){(ee||z)&&H&&I&&(j==null||j(H));const{inProgress:ve,...re}=pe,Ne={...re,toPosition:pe.toHandle?pe.toPosition:null};b==null||b(ke,Ne),u&&(R==null||R(ke,Ne))}_(),cancelAnimationFrame(te),D=!1,I=!1,H=null,z=null,q.removeEventListener("mousemove",se),q.removeEventListener("mouseup",me),q.removeEventListener("touchmove",se),q.removeEventListener("touchend",me)}}q.addEventListener("mousemove",se),q.addEventListener("mouseup",me),q.addEventListener("touchmove",se),q.addEventListener("touchend",me)}function Pg(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:v=Mg,nodeLookup:x}){const y=u==="target",m=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=gn(t),j=c.elementFromPoint(_,k),b=j!=null&&j.classList.contains(`${h}-flow__handle`)?j:m,E={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const R=Cg(void 0,b),w=b.getAttribute("data-nodeid"),N=b.getAttribute("data-handleid"),A=b.classList.contains("connectable"),$=b.classList.contains("connectableend");if(!w||!R)return E;const F={source:y?w:s,sourceHandle:y?N:a,target:y?s:w,targetHandle:y?a:N};E.connection=F;const q=A&&$&&(o===Zi.Strict?y&&R==="source"||!y&&R==="target":w!==s||N!==a);E.isValid=q&&v(F),E.toHandle=Eg(w,R,N,x,o,!0)}return E}const fc={onPointerDown:F1,isValid:Pg};function H1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Gt(t);function u({translateExtent:h,width:p,height:v,zoomStep:x=1,pannable:y=!0,zoomable:m=!0,inversePan:_=!1}){const k=w=>{if(w.sourceEvent.type!=="wheel"||!r)return;const N=o(),A=w.sourceEvent.ctrlKey&&ls()?10:1,$=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*x,F=N[2]*Math.pow(2,$*A);r.scaleTo(F)};let j=[0,0];const b=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(j=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},E=w=>{const N=o();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!r)return;const A=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],$=[A[0]-j[0],A[1]-j[1]];j=A;const F=s()*Math.max(N[2],Math.log(N[2]))*(_?-1:1),G={x:N[0]-$[0]*F,y:N[1]-$[1]*F},q=[[0,0],[p,v]];r.setViewportConstrained({x:G.x,y:G.y,zoom:N[2]},q,h)},R=rg().on("start",b).on("zoom",y?E:null).on("zoom.wheel",m?k:null);a.call(R,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:fn}}const Jl=t=>({x:t.x,y:t.y,zoom:t.k}),Vu=({x:t,y:r,zoom:o})=>Kl.translate(t,r).scale(o),Rr=(t,r)=>t.target.closest(`.${r}`),Ig=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),B1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Wu=(t,r=0,o=B1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Rg=t=>{const r=t.ctrlKey&&ls()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function V1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:v}){return x=>{if(Rr(x,r))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const y=o.property("__zoom").k||1;if(x.ctrlKey&&c){const b=fn(x),E=Rg(x),R=y*Math.pow(2,E);s.scaleTo(o,R,b,x);return}const m=x.deltaMode===1?20:1;let _=a===di.Vertical?0:x.deltaX*m,k=a===di.Horizontal?0:x.deltaY*m;!ls()&&x.shiftKey&&a!==di.Vertical&&(_=x.deltaY*m,k=0),s.translateBy(o,-(_/y)*u,-(k/y)*u,{internal:!0});const j=Jl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(x,j):(t.isPanScrolling=!0,h==null||h(x,j)),t.panScrollTimeout=setTimeout(()=>{v==null||v(x,j),t.isPanScrolling=!1},150)}}function W1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=Rr(s,t);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function U1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=Jl(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function Y1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;t.usedRightMouseButton=!!(o&&Ig(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,Jl(u.transform)))}}function G1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&Ig(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const p=Jl(c.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function X1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:v,lib:x,connectionInProgress:y}){return m=>{var E;const _=r||o,k=s&&m.ctrlKey,j=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(Rr(m,`${x}-flow__node`)||Rr(m,`${x}-flow__edge`)||Rr(m,`${x}-flow__selection`)||Rr(m,`${x}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!c&&!s||h||y&&!j||Rr(m,p)&&j||Rr(m,v)&&(!j||u&&j&&!r)||!s&&m.ctrlKey&&j)return!1;if(!s&&m.type==="touchstart"&&((E=m.touches)==null?void 0:E.length)>1)return m.preventDefault(),!1;if(!_&&!u&&!k&&j||!a&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(a)&&!a.includes(m.button)&&m.type==="mousedown")return!1;const b=Array.isArray(a)&&a.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||j||t)&&b}}function q1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const v={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=t.getBoundingClientRect();let y=[[0,0],[x.width,x.height]];const m=typeof ResizeObserver<"u"?new ResizeObserver(K=>{const C=K[0];C&&(y=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;m==null||m.observe(t);const _=rg().extent(()=>y).scaleExtent([r,o]).translateExtent(s),k=Gt(t).call(_);N({x:a.x,y:a.y,zoom:Ji(a.zoom,r,o)},[[0,0],[x.width,x.height]],s);const j=k.on("wheel.zoom"),b=k.on("dblclick.zoom");_.wheelDelta(Rg);async function E(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Ml).transform(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function R({noWheelClassName:K,noPanClassName:C,onPaneContextMenu:V,userSelectionActive:W,panOnScroll:U,panOnDrag:M,panOnScrollMode:D,panOnScrollSpeed:H,preventScrolling:I,zoomOnPinch:z,zoomOnScroll:ie,zoomOnDoubleClick:oe,panActivationKeyPressed:fe=!1,zoomActivationKeyPressed:he,lib:pe,onTransformChange:Z,connectionInProgress:se,paneClickDistance:me,selectionOnDrag:ke}){W&&!v.isZoomingOrPanning&&w();const ve=U&&!he&&!W;_.clickDistance(ke?1/0:!pn(me)||me<0?0:me);const re=ve?V1({zoomPanValues:v,noWheelClassName:K,d3Selection:k,d3Zoom:_,panOnScrollMode:D,panOnScrollSpeed:H,zoomOnPinch:z,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):W1({noWheelClassName:K,preventScrolling:I,d3ZoomHandler:j});k.on("wheel.zoom",re,{passive:!1});const Ne=U1({zoomPanValues:v,onDraggingChange:p,onPanZoomStart:c});_.on("start",Ne);const Me=Y1({zoomPanValues:v,panOnDrag:M,onPaneContextMenu:!!V,onPanZoom:u,onTransformChange:Z});_.on("zoom",Me);const Te=G1({zoomPanValues:v,panOnDrag:M,panOnScroll:U,onPaneContextMenu:V,onPanZoomEnd:h,onDraggingChange:p});_.on("end",Te);const $e=X1({panActivationKeyPressed:fe,zoomActivationKeyPressed:he,panOnDrag:M,zoomOnScroll:ie,panOnScroll:U,zoomOnDoubleClick:oe,zoomOnPinch:z,userSelectionActive:W,noPanClassName:C,noWheelClassName:K,lib:pe,connectionInProgress:se});_.filter($e),oe?k.on("dblclick.zoom",b):k.on("dblclick.zoom",null)}function w(){_.on("zoom",null)}async function N(K,C,V){const W=Vu(K),U=_==null?void 0:_.constrain()(W,C,V);return U&&await E(U),U}async function A(K,C){const V=Vu(K);return await E(V,C),V}function $(K){if(k){const C=Vu(K),V=k.property("__zoom");(V.k!==K.zoom||V.x!==K.x||V.y!==K.y)&&(_==null||_.transform(k,C,null,{sync:!0}))}}function F(){const K=k?ng(k.node()):{x:0,y:0,k:1};return{x:K.x,y:K.y,zoom:K.k}}async function G(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Ml).scaleTo(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}async function q(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Ml).scaleBy(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function te(K){_==null||_.scaleExtent(K)}function ee(K){_==null||_.translateExtent(K)}function ne(K){const C=!pn(K)||K<0?0:K;_==null||_.clickDistance(C)}return{update:R,destroy:w,setViewport:A,setViewportConstrained:N,getViewport:F,scaleTo:G,scaleBy:q,setScaleExtent:te,setTranslateExtent:ee,syncViewport:$,setClickDistance:ne}}var to;(function(t){t.Line="line",t.Handle="handle"})(to||(to={}));function K1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function Ah(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function Pr(t,r){return Math.max(0,r-t)}function Ir(t,r){return Math.max(0,t-r)}function kl(t,r,o){return Math.max(0,r-t,t-o)}function $h(t,r){return t?!r:r}function Q1(t,r,o,s,a,u,c,h){let{affectsX:p,affectsY:v}=r;const{isHorizontal:x,isVertical:y}=r,m=x&&y,{xSnapped:_,ySnapped:k}=o,{minWidth:j,maxWidth:b,minHeight:E,maxHeight:R}=s,{x:w,y:N,width:A,height:$,aspectRatio:F}=t;let G=Math.floor(x?_-t.pointerX:0),q=Math.floor(y?k-t.pointerY:0);const te=A+(p?-G:G),ee=$+(v?-q:q),ne=-u[0]*A,K=-u[1]*$;let C=kl(te,j,b),V=kl(ee,E,R);if(c){let M=0,D=0;p&&G<0?M=Pr(w+G+ne,c[0][0]):!p&&G>0&&(M=Ir(w+te+ne,c[1][0])),v&&q<0?D=Pr(N+q+K,c[0][1]):!v&&q>0&&(D=Ir(N+ee+K,c[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(h){let M=0,D=0;p&&G>0?M=Ir(w+G,h[0][0]):!p&&G<0&&(M=Pr(w+te,h[1][0])),v&&q>0?D=Ir(N+q,h[0][1]):!v&&q<0&&(D=Pr(N+ee,h[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(a){if(x){const M=kl(te/F,E,R)*F;if(C=Math.max(C,M),c){let D=0;!p&&!v||p&&!v&&m?D=Ir(N+K+te/F,c[1][1])*F:D=Pr(N+K+(p?G:-G)/F,c[0][1])*F,C=Math.max(C,D)}if(h){let D=0;!p&&!v||p&&!v&&m?D=Pr(N+te/F,h[1][1])*F:D=Ir(N+(p?G:-G)/F,h[0][1])*F,C=Math.max(C,D)}}if(y){const M=kl(ee*F,j,b)/F;if(V=Math.max(V,M),c){let D=0;!p&&!v||v&&!p&&m?D=Ir(w+ee*F+ne,c[1][0])/F:D=Pr(w+(v?q:-q)*F+ne,c[0][0])/F,V=Math.max(V,D)}if(h){let D=0;!p&&!v||v&&!p&&m?D=Pr(w+ee*F,h[1][0])/F:D=Ir(w+(v?q:-q)*F,h[0][0])/F,V=Math.max(V,D)}}}q=q+(q<0?V:-V),G=G+(G<0?C:-C),a&&(m?te>ee*F?q=($h(p,v)?-G:G)/F:G=($h(p,v)?-q:q)*F:x?(q=G/F,v=p):(G=q*F,p=v));const W=p?w+G:w,U=v?N+q:N;return{width:A+(p?-G:G),height:$+(v?-q:q),x:u[0]*G*(p?-1:1)+W,y:u[1]*q*(v?-1:1)+U}}const Tg={width:0,height:0,x:0,y:0},Z1={...Tg,pointerX:0,pointerY:0,aspectRatio:1};function J1(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function e_({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Gt(t);let c={controlDirection:Ah("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:v,boundaries:x,keepAspectRatio:y,resizeDirection:m,onResizeStart:_,onResize:k,onResizeEnd:j,shouldResize:b}){let E={...Tg},R={...Z1};c={boundaries:x,resizeDirection:m,keepAspectRatio:y,controlDirection:Ah(v)};let w,N=null,A=[],$,F,G,q=!1;const te=Bp().on("start",ee=>{const{nodeLookup:ne,transform:K,snapGrid:C,snapToGrid:V,nodeOrigin:W,paneDomNode:U}=o();if(w=ne.get(r),!w)return;N=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:D}=Qo(ee.sourceEvent,{transform:K,snapGrid:C,snapToGrid:V,containerBounds:N});E={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},R={...E,pointerX:M,pointerY:D,aspectRatio:E.width/E.height},$=void 0,F=gi(w.extent)?w.extent:void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&($=ne.get(w.parentId)),$&&w.extent==="parent"&&(F=[[0,0],[$.measured.width,$.measured.height]]),A=[],G=void 0;for(const[H,I]of ne)if(I.parentId===r&&(A.push({id:H,position:{...I.position},extent:I.extent}),I.extent==="parent"||I.expandParent)){const z=J1(I,w,I.origin??W);G?G=[[Math.min(z[0][0],G[0][0]),Math.min(z[0][1],G[0][1])],[Math.max(z[1][0],G[1][0]),Math.max(z[1][1],G[1][1])]]:G=z}_==null||_(ee,{...E})}).on("drag",ee=>{const{transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V}=o(),W=Qo(ee.sourceEvent,{transform:ne,snapGrid:K,snapToGrid:C,containerBounds:N}),U=[];if(!w)return;const{x:M,y:D,width:H,height:I}=E,z={},ie=w.origin??V,{width:oe,height:fe,x:he,y:pe}=Q1(R,c.controlDirection,W,c.boundaries,c.keepAspectRatio,ie,F,G),Z=oe!==H,se=fe!==I,me=he!==M&&Z,ke=pe!==D&&se;if(!me&&!ke&&!Z&&!se)return;if((me||ke||ie[0]===1||ie[1]===1)&&(z.x=me?he:E.x,z.y=ke?pe:E.y,E.x=z.x,E.y=z.y,A.length>0)){const Me=he-M,Te=pe-D;for(const $e of A)$e.position={x:$e.position.x-Me+ie[0]*(oe-H),y:$e.position.y-Te+ie[1]*(fe-I)},U.push($e)}if((Z||se)&&(z.width=Z&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:E.width,z.height=se&&(!c.resizeDirection||c.resizeDirection==="vertical")?fe:E.height,E.width=z.width,E.height=z.height),$&&w.expandParent){const Me=ie[0]*(z.width??0);z.x&&z.x{q&&(j==null||j(ee,{...E}),a==null||a({...E}),q=!1)});u.call(te)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Uu={exports:{}},Yu={},Gu={exports:{}},Xu={};/** * @license React * use-sync-external-store-shim.production.js * @@ -45,7 +45,7 @@ Error generating stack: `+g.message+` * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var zh;function e_(){if(zh)return Xu;zh=1;var t=us();function r(y,m){return y===m&&(y!==0||1/y===1/m)||y!==y&&m!==m}var o=typeof Object.is=="function"?Object.is:r,s=t.useState,a=t.useEffect,u=t.useLayoutEffect,c=t.useDebugValue;function h(y,m){var _=m(),k=s({inst:{value:_,getSnapshot:m}}),j=k[0].inst,b=k[1];return u(function(){j.value=_,j.getSnapshot=m,p(j)&&b({inst:j})},[y,_,m]),a(function(){return p(j)&&b({inst:j}),y(function(){p(j)&&b({inst:j})})},[y]),c(_),_}function p(y){var m=y.getSnapshot;y=y.value;try{var _=m();return!o(y,_)}catch{return!0}}function v(y,m){return m()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?v:h;return Xu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:x,Xu}var Dh;function t_(){return Dh||(Dh=1,Gu.exports=e_()),Gu.exports}/** + */var zh;function t_(){if(zh)return Xu;zh=1;var t=us();function r(y,m){return y===m&&(y!==0||1/y===1/m)||y!==y&&m!==m}var o=typeof Object.is=="function"?Object.is:r,s=t.useState,a=t.useEffect,u=t.useLayoutEffect,c=t.useDebugValue;function h(y,m){var _=m(),k=s({inst:{value:_,getSnapshot:m}}),j=k[0].inst,b=k[1];return u(function(){j.value=_,j.getSnapshot=m,p(j)&&b({inst:j})},[y,_,m]),a(function(){return p(j)&&b({inst:j}),y(function(){p(j)&&b({inst:j})})},[y]),c(_),_}function p(y){var m=y.getSnapshot;y=y.value;try{var _=m();return!o(y,_)}catch{return!0}}function v(y,m){return m()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?v:h;return Xu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:x,Xu}var Dh;function n_(){return Dh||(Dh=1,Gu.exports=t_()),Gu.exports}/** * @license React * use-sync-external-store-shim/with-selector.production.js * @@ -53,10 +53,10 @@ Error generating stack: `+g.message+` * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Oh;function n_(){if(Oh)return Yu;Oh=1;var t=us(),r=t_();function o(v,x){return v===x&&(v!==0||1/v===1/x)||v!==v&&x!==x}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Yu.useSyncExternalStoreWithSelector=function(v,x,y,m,_){var k=u(null);if(k.current===null){var j={hasValue:!1,value:null};k.current=j}else j=k.current;k=h(function(){function E($){if(!R){if(R=!0,w=$,$=m($),_!==void 0&&j.hasValue){var F=j.value;if(_(F,$))return N=F}return N=$}if(F=N,s(w,$))return F;var G=m($);return _!==void 0&&_(F,G)?(w=$,F):(w=$,N=G)}var R=!1,w,N,A=y===void 0?null:y;return[function(){return E(x())},A===null?void 0:function(){return E(A())}]},[x,y,m,_]);var b=a(v,k[0],k[1]);return c(function(){j.hasValue=!0,j.value=b},[b]),p(b),b},Yu}var Fh;function r_(){return Fh||(Fh=1,Uu.exports=n_()),Uu.exports}var i_=r_();const o_=kp(i_),s_={},Hh=t=>{let r;const o=new Set,s=(x,y)=>{const m=typeof x=="function"?x(r):x;if(!Object.is(m,r)){const _=r;r=y??(typeof m!="object"||m===null)?m:Object.assign({},r,m),o.forEach(k=>k(r,_))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>v,subscribe:x=>(o.add(x),()=>o.delete(x)),destroy:()=>{(s_?"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."),o.clear()}},v=r=t(s,a,p);return p},l_=t=>t?Hh(t):Hh,{useDebugValue:a_}=r0,{useSyncExternalStoreWithSelector:u_}=o_,c_=t=>t;function Tg(t,r=c_,o){const s=u_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return a_(s),s}const Bh=(t,r)=>{const o=l_(t),s=(a,u=r)=>Tg(o,a,u);return Object.assign(s,o),s},d_=(t,r)=>t?Bh(t,r):Bh;function Qe(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}Np();const ea=L.createContext(null),f_=ea.Provider,Lg=mn.error001("react");function De(t,r){const o=L.useContext(ea);if(o===null)throw new Error(Lg);return Tg(o,t,r)}function Ye(){const t=L.useContext(ea);if(t===null)throw new Error(Lg);return L.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Vh={display:"none"},h_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ag="react-flow__node-desc",$g="react-flow__edge-desc",p_="react-flow__aria-live",g_=t=>t.ariaLiveMessage,m_=t=>t.ariaLabelConfig;function y_({rfId:t}){const r=De(g_);return d.jsx("div",{id:`${p_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:h_,children:r})}function v_({rfId:t,disableKeyboardA11y:r}){const o=De(m_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${Ag}-${t}`,style:Vh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${$g}-${t}`,style:Vh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(y_,{rfId:t})]})}const ta=L.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return d.jsx("div",{className:nt(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});ta.displayName="Panel";const Wh="https://reactflow.dev?utm_source=attribution";function x_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:d.jsx(ta,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Wh}`,children:d.jsx("a",{href:Wh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const w_=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},Nl=t=>t.id;function __(t,r){return Qe(t.selectedNodes.map(Nl),r.selectedNodes.map(Nl))&&Qe(t.selectedEdges.map(Nl),r.selectedEdges.map(Nl))}function S_({onSelectionChange:t}){const r=Ye(),{selectedNodes:o,selectedEdges:s}=De(w_,__);return L.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const k_=t=>!!t.onSelectionChangeHandlers;function N_({onSelectionChange:t}){const r=De(k_);return t||r?d.jsx(S_,{onSelectionChange:t}):null}const zg=[0,0],j_={x:0,y:0,zoom:1},b_=["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"],Uh=[...b_,"rfId"],E_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Yh={translateExtent:rs,nodeOrigin:zg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function C_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=De(E_,Qe),v=Ye();L.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{x.current=Yh,h()}),[]);const x=L.useRef(Yh);return L.useEffect(()=>{for(const y of Uh){const m=t[y],_=x.current[y];m!==_&&(typeof t[y]>"u"||(y==="nodes"?r(m):y==="edges"?o(m):y==="minZoom"?s(m):y==="maxZoom"?a(m):y==="translateExtent"?u(m):y==="nodeExtent"?c(m):y==="ariaLabelConfig"?v.setState({ariaLabelConfig:f1(m)}):y==="fitView"?v.setState({fitViewQueued:m}):y==="fitViewOptions"?v.setState({fitViewOptions:m}):v.setState({[y]:m})))}x.current=t},Uh.map(y=>t[y])),null}function Gh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function M_(t){var s;const[r,o]=L.useState(t==="system"?null:t);return L.useEffect(()=>{if(t!=="system"){o(t);return}const a=Gh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=Gh())!=null&&s.matches?"dark":"light"}const Xh=typeof document<"u"?document:null;function as(t=null,r={target:Xh,actInsideInputWithModifier:!0}){const[o,s]=L.useState(!1),a=L.useRef(!1),u=L.useRef(new Set([])),[c,h]=L.useMemo(()=>{if(t!==null){const v=(Array.isArray(t)?t:[t]).filter(y=>typeof y=="string").map(y=>y.replace(/\+/g,` + */var Oh;function r_(){if(Oh)return Yu;Oh=1;var t=us(),r=n_();function o(v,x){return v===x&&(v!==0||1/v===1/x)||v!==v&&x!==x}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Yu.useSyncExternalStoreWithSelector=function(v,x,y,m,_){var k=u(null);if(k.current===null){var j={hasValue:!1,value:null};k.current=j}else j=k.current;k=h(function(){function E($){if(!R){if(R=!0,w=$,$=m($),_!==void 0&&j.hasValue){var F=j.value;if(_(F,$))return N=F}return N=$}if(F=N,s(w,$))return F;var G=m($);return _!==void 0&&_(F,G)?(w=$,F):(w=$,N=G)}var R=!1,w,N,A=y===void 0?null:y;return[function(){return E(x())},A===null?void 0:function(){return E(A())}]},[x,y,m,_]);var b=a(v,k[0],k[1]);return c(function(){j.hasValue=!0,j.value=b},[b]),p(b),b},Yu}var Fh;function i_(){return Fh||(Fh=1,Uu.exports=r_()),Uu.exports}var o_=i_();const s_=Np(o_),l_={},Hh=t=>{let r;const o=new Set,s=(x,y)=>{const m=typeof x=="function"?x(r):x;if(!Object.is(m,r)){const _=r;r=y??(typeof m!="object"||m===null)?m:Object.assign({},r,m),o.forEach(k=>k(r,_))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>v,subscribe:x=>(o.add(x),()=>o.delete(x)),destroy:()=>{(l_?"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."),o.clear()}},v=r=t(s,a,p);return p},a_=t=>t?Hh(t):Hh,{useDebugValue:u_}=i0,{useSyncExternalStoreWithSelector:c_}=s_,d_=t=>t;function Lg(t,r=d_,o){const s=c_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return u_(s),s}const Bh=(t,r)=>{const o=a_(t),s=(a,u=r)=>Lg(o,a,u);return Object.assign(s,o),s},f_=(t,r)=>t?Bh(t,r):Bh;function Qe(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}jp();const ea=L.createContext(null),h_=ea.Provider,Ag=mn.error001("react");function De(t,r){const o=L.useContext(ea);if(o===null)throw new Error(Ag);return Lg(o,t,r)}function Ye(){const t=L.useContext(ea);if(t===null)throw new Error(Ag);return L.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Vh={display:"none"},p_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},$g="react-flow__node-desc",zg="react-flow__edge-desc",g_="react-flow__aria-live",m_=t=>t.ariaLiveMessage,y_=t=>t.ariaLabelConfig;function v_({rfId:t}){const r=De(m_);return d.jsx("div",{id:`${g_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:p_,children:r})}function x_({rfId:t,disableKeyboardA11y:r}){const o=De(y_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${$g}-${t}`,style:Vh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${zg}-${t}`,style:Vh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(v_,{rfId:t})]})}const ta=L.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return d.jsx("div",{className:nt(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});ta.displayName="Panel";const Wh="https://reactflow.dev?utm_source=attribution";function w_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:d.jsx(ta,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Wh}`,children:d.jsx("a",{href:Wh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const __=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},Nl=t=>t.id;function S_(t,r){return Qe(t.selectedNodes.map(Nl),r.selectedNodes.map(Nl))&&Qe(t.selectedEdges.map(Nl),r.selectedEdges.map(Nl))}function k_({onSelectionChange:t}){const r=Ye(),{selectedNodes:o,selectedEdges:s}=De(__,S_);return L.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const N_=t=>!!t.onSelectionChangeHandlers;function j_({onSelectionChange:t}){const r=De(N_);return t||r?d.jsx(k_,{onSelectionChange:t}):null}const Dg=[0,0],b_={x:0,y:0,zoom:1},E_=["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"],Uh=[...E_,"rfId"],C_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Yh={translateExtent:rs,nodeOrigin:Dg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function M_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=De(C_,Qe),v=Ye();L.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{x.current=Yh,h()}),[]);const x=L.useRef(Yh);return L.useEffect(()=>{for(const y of Uh){const m=t[y],_=x.current[y];m!==_&&(typeof t[y]>"u"||(y==="nodes"?r(m):y==="edges"?o(m):y==="minZoom"?s(m):y==="maxZoom"?a(m):y==="translateExtent"?u(m):y==="nodeExtent"?c(m):y==="ariaLabelConfig"?v.setState({ariaLabelConfig:h1(m)}):y==="fitView"?v.setState({fitViewQueued:m}):y==="fitViewOptions"?v.setState({fitViewOptions:m}):v.setState({[y]:m})))}x.current=t},Uh.map(y=>t[y])),null}function Gh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function P_(t){var s;const[r,o]=L.useState(t==="system"?null:t);return L.useEffect(()=>{if(t!=="system"){o(t);return}const a=Gh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=Gh())!=null&&s.matches?"dark":"light"}const Xh=typeof document<"u"?document:null;function as(t=null,r={target:Xh,actInsideInputWithModifier:!0}){const[o,s]=L.useState(!1),a=L.useRef(!1),u=L.useRef(new Set([])),[c,h]=L.useMemo(()=>{if(t!==null){const v=(Array.isArray(t)?t:[t]).filter(y=>typeof y=="string").map(y=>y.replace(/\+/g,` `).replace(` `,` +`).split(` -`)),x=v.reduce((y,m)=>y.concat(...m),[]);return[v,x]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Xh,v=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const x=_=>{var b,E;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!v)&&mg(_))return!1;const j=Kh(_.code,h);if(u.current.add(_[j]),qh(c,u.current,!1)){const R=((E=(b=_.composedPath)==null?void 0:b.call(_))==null?void 0:E[0])||_.target,w=(R==null?void 0:R.nodeName)==="BUTTON"||(R==null?void 0:R.nodeName)==="A";r.preventDefault!==!1&&(a.current||!w)&&_.preventDefault(),s(!0)}},y=_=>{const k=Kh(_.code,h);qh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},m=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",x),p==null||p.addEventListener("keyup",y),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{p==null||p.removeEventListener("keydown",x),p==null||p.removeEventListener("keyup",y),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,s]),o}function qh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Kh(t,r){return r.includes(t)?"code":"key"}const P_=()=>{const t=Ye();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=Nc(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),v={x:r.x-h,y:r.y-p},x=o.snapGrid??a,y=o.snapToGrid??u;return gs(v,s,y,x)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=eo(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function Dg(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)I_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function I_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function R_(t,r){return Dg(t,r)}function T_(t,r){return Dg(t,r)}function ai(t,r){return{id:t,type:"select",selected:r}}function Gi(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(ai(u.id,c)))}return s}function Qh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Zh(t){return{id:t.id,type:"remove"}}const L_=fg();function A_(t,r,o={}){return v1(t,r,{...o,onError:o.onError??L_})}const Jh=t=>r1(t),$_=t=>lg(t);function Og(t){return L.forwardRef(t)}const Fg=typeof window<"u"?L.useLayoutEffect:L.useEffect;function ep(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>z_(()=>o(a=>a+BigInt(1))));return Fg(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function z_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Hg=L.createContext(null);function D_({children:t}){const r=Ye(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:v,hasDefaultNodes:x,onNodesChange:y,nodeLookup:m,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let j=p;for(const E of h)j=typeof E=="function"?E(j):E;let b=Qh({items:j,lookup:m});for(const E of k.values())b=E(b);x&&v(j),b.length>0?y==null||y(b):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:R,setNodes:w}=r.getState();E&&w(R)})},[]),s=ep(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:v,hasDefaultEdges:x,onEdgesChange:y,edgeLookup:m}=r.getState();let _=p;for(const k of h)_=typeof k=="function"?k(_):k;x?v(_):y&&y(Qh({items:_,lookup:m}))},[]),u=ep(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Hg.Provider,{value:c,children:t})}function O_(){const t=L.useContext(Hg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const F_=t=>!!t.panZoom;function na(){const t=P_(),r=Ye(),o=O_(),s=De(F_),a=L.useMemo(()=>{const u=y=>r.getState().nodeLookup.get(y),c=y=>{o.nodeQueue.push(y)},h=y=>{o.edgeQueue.push(y)},p=y=>{var E,R;const{nodeLookup:m,nodeOrigin:_}=r.getState(),k=Jh(y)?y:m.get(y.id),j=k.parentId?pg(k.position,k.measured,k.parentId,m,_):k.position,b={...k,position:j,width:((E=k.measured)==null?void 0:E.width)??k.width,height:((R=k.measured)==null?void 0:R.height)??k.height};return ss(b)},v=(y,m,_={replace:!1})=>{c(k=>k.map(j=>{if(j.id===y){const b=typeof m=="function"?m(j):m;return _.replace&&Jh(b)?b:{...j,...b}}return j}))},x=(y,m,_={replace:!1})=>{h(k=>k.map(j=>{if(j.id===y){const b=typeof m=="function"?m(j):m;return _.replace&&$_(b)?b:{...j,...b}}return j}))};return{getNodes:()=>r.getState().nodes.map(y=>({...y})),getNode:y=>{var m;return(m=u(y))==null?void 0:m.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:y=[]}=r.getState();return y.map(m=>({...m}))},getEdge:y=>r.getState().edgeLookup.get(y),setNodes:c,setEdges:h,addNodes:y=>{const m=Array.isArray(y)?y:[y];o.nodeQueue.push(_=>[..._,...m])},addEdges:y=>{const m=Array.isArray(y)?y:[y];o.edgeQueue.push(_=>[..._,...m])},toObject:()=>{const{nodes:y=[],edges:m=[],transform:_}=r.getState(),[k,j,b]=_;return{nodes:y.map(E=>({...E})),edges:m.map(E=>({...E})),viewport:{x:k,y:j,zoom:b}}},deleteElements:async({nodes:y=[],edges:m=[]})=>{const{nodes:_,edges:k,onNodesDelete:j,onEdgesDelete:b,triggerNodeChanges:E,triggerEdgeChanges:R,onDelete:w,onBeforeDelete:N}=r.getState(),{nodes:A,edges:$}=await a1({nodesToRemove:y,edgesToRemove:m,nodes:_,edges:k,onBeforeDelete:N}),F=$.length>0,G=A.length>0;if(F){const q=$.map(Zh);b==null||b($),R(q)}if(G){const q=A.map(Zh);j==null||j(A),E(q)}return(G||F)&&(w==null||w({nodes:A,edges:$})),{deletedNodes:A,deletedEdges:$}},getIntersectingNodes:(y,m=!0,_)=>{const k=Nh(y),j=k?y:p(y),b=_!==void 0;return j?(_||r.getState().nodes).filter(E=>{const R=r.getState().nodeLookup.get(E.id);if(R&&!k&&(E.id===y.id||!R.internals.positionAbsolute))return!1;const w=ss(b?E:R),N=Hl(w,j);return m&&N>0||N>=w.width*w.height||N>=j.width*j.height}):[]},isNodeIntersecting:(y,m,_=!0)=>{const j=Nh(y)?y:p(y);if(!j)return!1;const b=Hl(j,m);return _&&b>0||b>=m.width*m.height||b>=j.width*j.height},updateNode:v,updateNodeData:(y,m,_={replace:!1})=>{v(y,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},updateEdge:x,updateEdgeData:(y,m,_={replace:!1})=>{x(y,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},getNodesBounds:y=>{const{nodeLookup:m,nodeOrigin:_}=r.getState();return i1(y,{nodeLookup:m,nodeOrigin:_})},getHandleConnections:({type:y,id:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${y}${m?`-${m}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:y,handleId:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${y?m?`-${y}-${m}`:`-${y}`:""}`))==null?void 0:k.values())??[])},fitView:async y=>{const m=r.getState().fitViewResolver??d1();return r.setState({fitViewQueued:!0,fitViewOptions:y,fitViewResolver:m}),o.nodeQueue.push(_=>[..._]),m.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const tp=t=>t.selected,H_=typeof window<"u"?window:void 0;function B_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ye(),{deleteElements:s}=na(),a=as(t,{actInsideInputWithModifier:!1}),u=as(r,{target:H_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(tp),edges:c.filter(tp)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function V_(t){const r=Ye();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=jc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",mn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const ra={position:"absolute",width:"100%",height:"100%",top:0,left:0},W_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function U_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=di.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:v,translateExtent:x,minZoom:y,maxZoom:m,zoomActivationKeyCode:_,preventScrolling:k=!0,children:j,noWheelClassName:b,noPanClassName:E,onViewportChange:R,isControlledViewport:w,paneClickDistance:N,selectionOnDrag:A}){const $=Ye(),F=L.useRef(null),{userSelectionActive:G,lib:q,connectionInProgress:te}=De(W_,Qe),ee=as(_),ne=L.useRef();V_(F);const K=L.useCallback(C=>{R==null||R({x:C[0],y:C[1],zoom:C[2]}),w||$.setState({transform:C})},[R,w]);return L.useEffect(()=>{if(F.current){ne.current=X1({domNode:F.current,minZoom:y,maxZoom:m,translateExtent:x,viewport:v,onDraggingChange:U=>$.setState(M=>M.paneDragging===U?M:{paneDragging:U}),onPanZoomStart:(U,M)=>{const{onViewportChangeStart:D,onMoveStart:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoom:(U,M)=>{const{onViewportChange:D,onMove:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoomEnd:(U,M)=>{const{onViewportChangeEnd:D,onMoveEnd:H}=$.getState();H==null||H(U,M),D==null||D(M)}});const{x:C,y:V,zoom:W}=ne.current.getViewport();return $.setState({panZoom:ne.current,transform:[C,V,W],domNode:F.current.closest(".react-flow")}),()=>{var U;(U=ne.current)==null||U.destroy()}}},[]),L.useEffect(()=>{var C;(C=ne.current)==null||C.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:ee,preventScrolling:k,noPanClassName:E,userSelectionActive:G,noWheelClassName:b,lib:q,onTransformChange:K,connectionInProgress:te,selectionOnDrag:A,paneClickDistance:N})},[t,r,o,s,a,u,c,h,p,ee,k,E,G,b,q,K,te,A,N]),d.jsx("div",{className:"react-flow__renderer",ref:F,style:ra,children:j})}const Y_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function G_(){const{userSelectionActive:t,userSelectionRect:r}=De(Y_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const qu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},X_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function q_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=is.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:v,onPaneContextMenu:x,onPaneScroll:y,onPaneMouseEnter:m,onPaneMouseMove:_,onPaneMouseLeave:k,children:j}){const b=L.useRef(0),E=Ye(),{userSelectionActive:R,elementsSelectable:w,dragging:N,panBy:A,autoPanSpeed:$}=De(X_,Qe),F=w&&(t||R),G=L.useRef(null),q=L.useRef(),te=L.useRef(new Set),ee=L.useRef(new Set),ne=L.useRef(!1),K=L.useRef(!1),C=L.useRef({x:0,y:0}),V=L.useRef(!1),W=Z=>{if(K.current||ne.current||E.getState().connection.inProgress){K.current=!1,ne.current=!1;return}v==null||v(Z),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},U=Z=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Z.preventDefault();return}x==null||x(Z)},M=y?Z=>y(Z):void 0,D=Z=>{K.current&&(Z.stopPropagation(),K.current=!1)},H=Z=>{var $e,st;if(Z.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:se,transform:me}=E.getState();if(q.current=se==null?void 0:se.getBoundingClientRect(),!q.current)return;const ke=Z.target===G.current;if(!ke&&!!Z.target.closest(".nokey")||!t||!(c&&ke||r)||Z.button!==0||!Z.isPrimary)return;(st=($e=Z.target)==null?void 0:$e.setPointerCapture)==null||st.call($e,Z.pointerId),K.current=!1;const{x:Ne,y:Me}=gn(Z.nativeEvent,q.current),Te=gs({x:Ne,y:Me},me);E.setState({userSelectionRect:{width:0,height:0,startX:Te.x,startY:Te.y,x:Ne,y:Me}}),ke||(Z.stopPropagation(),Z.preventDefault())};function I(Z,se){const{userSelectionRect:me}=E.getState();if(!me)return;const{transform:ke,nodeLookup:ve,edgeLookup:re,connectionLookup:Ne,triggerNodeChanges:Me,triggerEdgeChanges:Te,defaultEdgeOptions:$e}=E.getState(),st={x:me.startX,y:me.startY},{x:lt,y:at}=eo(st,ke),Ge={startX:st.x,startY:st.y,x:Zmt.id)),ee.current=new Set;const gt=($e==null?void 0:$e.selectable)??!0;for(const mt of te.current){const Pt=Ne.get(mt);if(Pt)for(const{edgeId:ut}of Pt.values()){const Je=re.get(ut);Je&&(Je.selectable??gt)&&ee.current.add(ut)}}if(!jh(wt,te.current)){const mt=Gi(ve,te.current,!0);Me(mt)}if(!jh(qt,ee.current)){const mt=Gi(re,ee.current);Te(mt)}E.setState({userSelectionRect:Ge,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!a||!q.current)return;const[Z,se]=kc(C.current,q.current,$);A({x:Z,y:se}).then(me=>{if(!K.current||!me){b.current=requestAnimationFrame(z);return}const{x:ke,y:ve}=C.current;I(ke,ve),b.current=requestAnimationFrame(z)})}const ie=()=>{cancelAnimationFrame(b.current),b.current=0,V.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=Z=>{const{userSelectionRect:se,transform:me,resetSelectedElements:ke}=E.getState();if(!q.current||!se)return;const{x:ve,y:re}=gn(Z.nativeEvent,q.current);C.current={x:ve,y:re};const Ne=eo({x:se.startX,y:se.startY},me);if(!K.current){const Me=r?0:u;if(Math.hypot(ve-Ne.x,re-Ne.y)<=Me)return;ke(),h==null||h(Z)}K.current=!0,V.current||(z(),V.current=!0),I(ve,re)},fe=Z=>{var se,me;if(!F){Z.target===G.current&&E.getState().connection.inProgress&&(ne.current=!0);return}Z.button===0&&((me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),!R&&Z.target===G.current&&E.getState().userSelectionRect&&(W==null||W(Z)),E.setState({userSelectionActive:!1,userSelectionRect:null}),K.current&&(p==null||p(Z),E.setState({nodesSelectionActive:te.current.size>0})),ie())},he=Z=>{var se,me;(me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),ie()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:nt(["react-flow__pane",{draggable:pe,dragging:N,selection:t}]),onClick:F?void 0:qu(W,G),onContextMenu:qu(U,G),onWheel:qu(M,G),onPointerEnter:F?void 0:m,onPointerMove:F?oe:_,onPointerUp:fe,onPointerCancel:F?he:void 0,onPointerDownCapture:F?H:void 0,onClickCapture:F?D:void 0,onPointerLeave:k,ref:G,style:ra,children:[j,d.jsx(G_,{})]})}function hc({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),v=h.get(t);if(!v){p==null||p("012",mn.error012(t));return}r.setState({nodesSelectionActive:!1}),v.selected?(o||v.selected&&c)&&(u({nodes:[v],edges:[]}),requestAnimationFrame(()=>{var x;return(x=s==null?void 0:s.current)==null?void 0:x.blur()})):a([t])}function Bg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ye(),[p,v]=L.useState(!1),x=L.useRef();return L.useEffect(()=>{if(!r)return x.current=L1({getStoreItems:()=>h.getState(),onNodeMouseDown:y=>{hc({id:y,store:h,nodeRef:t})},onDragStart:()=>{v(!0)},onDragStop:()=>{v(!1)}}),()=>{var y;(y=x.current)==null||y.destroy(),x.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!x.current||x.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const K_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Vg(){const t=Ye();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:v,nodeOrigin:x}=t.getState(),y=new Map,m=K_(c),_=a?u[0]:5,k=a?u[1]:5,j=o.direction.x*_*o.factor,b=o.direction.y*k*o.factor;for(const[,E]of v){if(!m(E))continue;let R={x:E.internals.positionAbsolute.x+j,y:E.internals.positionAbsolute.y+b};a&&(R=ps(R,u));const{position:w,positionAbsolute:N}=ag({nodeId:E.id,nextPosition:R,nodeLookup:v,nodeExtent:s,nodeOrigin:x,onError:h});E.position=w,E.internals.positionAbsolute=N,y.set(E.id,E)}p(y)},[])}const Ic=L.createContext(null),Q_=Ic.Provider;Ic.Consumer;const Wg=()=>L.useContext(Ic),Z_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Ug=L.createContext(null);function J_({children:t}){const r=De(Z_,Qe);return d.jsx(Ug.Provider,{value:r,children:t})}function eS(){const t=L.useContext(Ug);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const tS={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},nS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:v}=c;if(!h&&!a)return tS;const x=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:x,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Zi.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:x&&v}};function rS({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:v,onMouseDown:x,onTouchStart:y,...m},_){var V,W;const k=c||null,j=t==="target",b=Ye(),E=Wg(),{connectOnClick:R,noPanClassName:w,rfId:N}=eS(),{connectingFrom:A,connectingTo:$,clickConnecting:F,isPossibleEndHandle:G,connectionInProcess:q,clickConnectionInProcess:te,valid:ee}=De(nS(E,k,t),Qe);E||(W=(V=b.getState()).onError)==null||W.call(V,"010",mn.error010());const ne=U=>{const{defaultEdgeOptions:M,onConnect:D,hasDefaultEdges:H}=b.getState(),I={...M,...U};if(H){const{edges:z,setEdges:ie,onError:oe}=b.getState();ie(A_(I,z,{onError:oe}))}D==null||D(I),h==null||h(I)},K=U=>{if(!E)return;const M=yg(U.nativeEvent);if(a&&(M&&U.button===0||!M)){const D=b.getState();fc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:j,handleId:k,nodeId:E,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...H)=>{var I,z;return(z=(I=b.getState()).onConnectEnd)==null?void 0:z.call(I,...H)},updateConnection:D.updateConnection,onConnect:ne,isValidConnection:o||((...H)=>{var I,z;return((z=(I=b.getState()).isValidConnection)==null?void 0:z.call(I,...H))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}M?x==null||x(U):y==null||y(U)},C=U=>{const{onClickConnectStart:M,onClickConnectEnd:D,connectionClickStartHandle:H,connectionMode:I,isValidConnection:z,lib:ie,rfId:oe,nodeLookup:fe,connection:he}=b.getState();if(!E||!H&&!a)return;if(!H){M==null||M(U.nativeEvent,{nodeId:E,handleId:k,handleType:t}),b.setState({connectionClickStartHandle:{nodeId:E,type:t,id:k}});return}const pe=gg(U.target),Z=o||z,{connection:se,isValid:me}=fc.isValid(U.nativeEvent,{handle:{nodeId:E,id:k,type:t},connectionMode:I,fromNodeId:H.nodeId,fromHandleId:H.id||null,fromType:H.type,isValidConnection:Z,flowId:oe,doc:pe,lib:ie,nodeLookup:fe});me&&se&&ne(se);const ke=structuredClone(he);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,D==null||D(U,ke),b.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":k,"data-nodeid":E,"data-handlepos":r,"data-id":`${N}-${E}-${k}-${t}`,className:nt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",w,v,{source:!j,target:j,connectable:s,connectablestart:a,connectableend:u,clickconnecting:F,connectingfrom:A,connectingto:$,valid:ee,connectionindicator:s&&(!q||G)&&(q||te?u:a)}]),onMouseDown:K,onTouchStart:K,onClick:R?C:void 0,ref:_,...m,children:p})}const no=L.memo(Og(rS));function iS({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(no,{type:"source",position:o,isConnectable:r})]})}function oS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:s=Se.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(no,{type:"source",position:s,isConnectable:r})]})}function sS(){return null}function lS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const Vl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},np={input:iS,default:oS,output:lS,group:sS};function aS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const uS=t=>{const{width:r,height:o,x:s,y:a}=hs(t.nodeLookup,{filter:u=>!!u.selected});return{width:pn(r)?r:null,height:pn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function cS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ye(),{width:a,height:u,transformString:c,userSelectionActive:h}=De(uS,Qe),p=Vg(),v=L.useRef(null);L.useEffect(()=>{var _;o||(_=v.current)==null||_.focus({preventScroll:!0})},[o]);const x=!h&&a!==null&&u!==null;if(Bg({nodeRef:v,disabled:!x}),!x)return null;const y=t?_=>{const k=s.getState().nodes.filter(j=>j.selected);t(_,k)}:void 0,m=_=>{Object.prototype.hasOwnProperty.call(Vl,_.key)&&(_.preventDefault(),p({direction:Vl[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:nt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:v,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:o?void 0:-1,onKeyDown:o?void 0:m,style:{width:a,height:u}})})}const rp=typeof window<"u"?window:void 0,dS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Yg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:v,selectionOnDrag:x,selectionMode:y,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:j,zoomActivationKeyCode:b,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:N,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:G,autoPanOnSelection:q,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,preventScrolling:C,onSelectionContextMenu:V,noWheelClassName:W,noPanClassName:U,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:H}){const{nodesSelectionActive:I,userSelectionActive:z}=De(dS,Qe),ie=as(v,{target:rp}),oe=as(j,{target:rp}),fe=oe||G,he=oe||N,pe=x&&fe!==!0,Z=ie||z||pe;return B_({deleteKeyCode:p,multiSelectionKeyCode:k}),d.jsx(U_,{onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:!ie&&fe,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,zoomActivationKeyCode:b,preventScrolling:C,noWheelClassName:W,noPanClassName:U,onViewportChange:D,isControlledViewport:H,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(q_,{onSelectionStart:m,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:q,isSelecting:!!Z,selectionMode:y,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:pe,children:[t,I&&d.jsx(cS,{onSelectionContextMenu:V,noPanClassName:U,disableKeyboardA11y:M})]})})}Yg.displayName="FlowRenderer";const fS=L.memo(Yg),hS=t=>r=>t?Sc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function pS(t){return De(L.useCallback(hS(t),[t]),Qe)}const gS=t=>t.updateNodeInternals;function mS(){const t=De(gS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function yS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ye(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),v=L.useRef(r),x=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!x||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[x,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const y=v.current!==r,m=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(y||m||_)&&(v.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function vS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:v,nodesFocusable:x,resizeObserver:y,noDragClassName:m,noPanClassName:_,disableKeyboardA11y:k,rfId:j,nodeTypes:b,nodeClickDistance:E,onError:R}){const{node:w,internals:N,isParent:A}=De(Z=>{const se=Z.nodeLookup.get(t),me=Z.parentLookup.has(t);return{node:se,internals:se.internals,isParent:me}},Qe);let $=w.type||"default",F=(b==null?void 0:b[$])||np[$];F===void 0&&(R==null||R("003",mn.error003($)),$="default",F=(b==null?void 0:b.default)||np.default);const G=!!(w.draggable||h&&typeof w.draggable>"u"),q=!!(w.selectable||p&&typeof w.selectable>"u"),te=!!(w.connectable||v&&typeof w.connectable>"u"),ee=!!(w.focusable||x&&typeof w.focusable>"u"),ne=Ye(),K=hg(w),C=yS({node:w,nodeType:$,hasDimensions:K,resizeObserver:y}),V=Bg({nodeRef:C,disabled:w.hidden||!G,noDragClassName:m,handleSelector:w.dragHandle,nodeId:t,isSelectable:q,nodeClickDistance:E}),W=Vg();if(w.hidden)return null;const U=vn(w),M=aS(w),D=q||G||r||o||s||a,H=o?Z=>o(Z,{...N.userNode}):void 0,I=s?Z=>s(Z,{...N.userNode}):void 0,z=a?Z=>a(Z,{...N.userNode}):void 0,ie=u?Z=>u(Z,{...N.userNode}):void 0,oe=c?Z=>c(Z,{...N.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:se,nodeDragThreshold:me}=ne.getState();q&&(!se||!G||me>0)&&hc({id:t,store:ne,nodeRef:C}),r&&r(Z,{...N.userNode})},he=Z=>{if(!(mg(Z.nativeEvent)||k)){if(rg.includes(Z.key)&&q){const se=Z.key==="Escape";hc({id:t,store:ne,unselect:se,nodeRef:C})}else if(G&&w.selected&&Object.prototype.hasOwnProperty.call(Vl,Z.key)){Z.preventDefault();const{ariaLabelConfig:se}=ne.getState();ne.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),W({direction:Vl[Z.key],factor:Z.shiftKey?4:1})}}},pe=()=>{var Ne;if(k||!((Ne=C.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:Z,width:se,height:me,autoPanOnNodeFocus:ke,setCenter:ve}=ne.getState();if(!ke)return;Sc(new Map([[t,w]]),{x:0,y:0,width:se,height:me},Z,!0).length>0||ve(w.position.x+U.width/2,w.position.y+U.height/2,{zoom:Z[2]})};return d.jsx("div",{className:nt(["react-flow__node",`react-flow__node-${$}`,{[_]:G},w.className,{selected:w.selected,selectable:q,parent:A,draggable:G,dragging:V}]),ref:C,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:K?"visible":"hidden",...w.style,...M},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:H,onMouseMove:I,onMouseLeave:z,onContextMenu:ie,onClick:fe,onDoubleClick:oe,onKeyDown:ee?he:void 0,tabIndex:ee?0:void 0,onFocus:ee?pe:void 0,role:w.ariaRole??(ee?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${Ag}-${j}`,"aria-label":w.ariaLabel,...w.domAttributes,children:d.jsx(Q_,{value:t,children:d.jsx(F,{id:t,data:w.data,type:$,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:w.selected??!1,selectable:q,draggable:G,deletable:w.deletable??!0,isConnectable:te,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:V,dragHandle:w.dragHandle,zIndex:N.z,parentId:w.parentId,...U})})})}var xS=L.memo(vS);const wS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Gg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=De(wS,Qe),u=pS(t.onlyRenderVisibleElements),c=mS();return d.jsx("div",{className:"react-flow__nodes",style:ra,children:u.map(h=>d.jsx(xS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Gg.displayName="NodeRenderer";const _S=L.memo(Gg);function SS(t){return De(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&g1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const kS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},NS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ip={[os.Arrow]:kS,[os.ArrowClosed]:NS};function jS(t){const r=Ye();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(ip,t)?ip[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",mn.error009(t)),null)},[t])}const bS=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=jS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},Xg=({defaultColor:t,rfId:r})=>{const o=De(u=>u.edges),s=De(u=>u.defaultEdgeOptions),a=L.useMemo(()=>k1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(bS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Xg.displayName="MarkerDefinitions";var ES=L.memo(Xg);function qg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:v,...x}){const[y,m]=L.useState({x:1,y:0,width:0,height:0}),_=nt(["react-flow__edge-textwrapper",v]),k=L.useRef(null);return L.useEffect(()=>{if(k.current){const j=k.current.getBBox();m({x:j.x,y:j.y,width:j.width,height:j.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-y.width/2} ${r-y.height/2})`,className:_,visibility:y.width?"visible":"hidden",...x,children:[a&&d.jsx("rect",{width:y.width+2*c[0],x:-c[0],y:-c[1],height:y.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:k,style:s,children:o}),p]}):null}qg.displayName="EdgeText";const CS=L.memo(qg);function ms({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:v=20,...x}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...x,d:t,fill:"none",className:nt(["react-flow__edge-path",x.className])}),v?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:v,className:"react-flow__edge-interaction"}):null,s&&pn(r)&&pn(o)?d.jsx(CS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function op({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function Kg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top}){const[c,h]=op({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,v]=op({pos:u,x1:s,y1:a,x2:t,y2:r}),[x,y,m,_]=vg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:v});return[`M${t},${r} C${c},${h} ${p},${v} ${s},${a}`,x,y,m,_]}function Qg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})=>{const[R,w,N]=Kg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),A=t.isInternal?void 0:r;return d.jsx(ms,{id:A,path:R,labelX:w,labelY:N,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})})}const MS=Qg({isInternal:!1}),Zg=Qg({isInternal:!0});MS.displayName="SimpleBezierEdge";Zg.displayName="SimpleBezierEdgeInternal";function Jg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,sourcePosition:_=Se.Bottom,targetPosition:k=Se.Top,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=Bl({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),$=t.isInternal?void 0:r;return d.jsx(ms,{id:$,path:w,labelX:N,labelY:A,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:j,markerStart:b,interactionWidth:R})})}const em=Jg({isInternal:!1}),tm=Jg({isInternal:!0});em.displayName="SmoothStepEdge";tm.displayName="SmoothStepEdgeInternal";function nm(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(em,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const PS=nm({isInternal:!1}),rm=nm({isInternal:!0});PS.displayName="StepEdge";rm.displayName="StepEdgeInternal";function im(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:j})=>{const[b,E,R]=_g({sourceX:o,sourceY:s,targetX:a,targetY:u}),w=t.isInternal?void 0:r;return d.jsx(ms,{id:w,path:b,labelX:E,labelY:R,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:j})})}const IS=im({isInternal:!1}),om=im({isInternal:!0});IS.displayName="StraightEdge";om.displayName="StraightEdgeInternal";function sm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=xg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:E==null?void 0:E.curvature}),$=t.isInternal?void 0:r;return d.jsx(ms,{id:$,path:w,labelX:N,labelY:A,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:R})})}const RS=sm({isInternal:!1}),lm=sm({isInternal:!0});RS.displayName="BezierEdge";lm.displayName="BezierEdgeInternal";const sp={default:lm,straight:om,step:rm,smoothstep:tm,simplebezier:Zg},lp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},TS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,LS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,ap="react-flow__edgeupdater";function up({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:nt([ap,`${ap}-${h}`]),cx:TS(r,s,t),cy:LS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function AS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:v,onReconnectStart:x,onReconnectEnd:y,setReconnecting:m,setUpdateHover:_}){const k=Ye(),j=(N,A)=>{if(N.button!==0)return;const{autoPanOnConnect:$,domNode:F,connectionMode:G,connectionRadius:q,lib:te,onConnectStart:ee,cancelConnection:ne,nodeLookup:K,rfId:C,panBy:V,updateConnection:W}=k.getState(),U=A.type==="target",M=(I,z)=>{m(!1),y==null||y(I,o,A.type,z)},D=I=>v==null?void 0:v(o,I),H=(I,z)=>{m(!0),x==null||x(N,o,A.type),ee==null||ee(I,z)};fc.onPointerDown(N.nativeEvent,{autoPanOnConnect:$,connectionMode:G,connectionRadius:q,domNode:F,handleId:A.id,nodeId:A.nodeId,nodeLookup:K,isTarget:U,edgeUpdaterType:A.type,lib:te,flowId:C,cancelConnection:ne,panBy:V,isValidConnection:(...I)=>{var z,ie;return((ie=(z=k.getState()).isValidConnection)==null?void 0:ie.call(z,...I))??!0},onConnect:D,onConnectStart:H,onConnectEnd:(...I)=>{var z,ie;return(ie=(z=k.getState()).onConnectEnd)==null?void 0:ie.call(z,...I)},onReconnectEnd:M,updateConnection:W,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:N.currentTarget})},b=N=>j(N,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),E=N=>j(N,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),R=()=>_(!0),w=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(up,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:b,onMouseEnter:R,onMouseOut:w,type:"source"}),(t===!0||t==="target")&&d.jsx(up,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:E,onMouseEnter:R,onMouseOut:w,type:"target"})]})}function $S({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,rfId:k,edgeTypes:j,noPanClassName:b,onError:E,disableKeyboardA11y:R}){let w=De(ve=>ve.edgeLookup.get(t));const N=De(ve=>ve.defaultEdgeOptions);w=N?{...N,...w}:w;let A=w.type||"default",$=(j==null?void 0:j[A])||sp[A];$===void 0&&(E==null||E("011",mn.error011(A)),A="default",$=(j==null?void 0:j.default)||sp.default);const F=!!(w.focusable||r&&typeof w.focusable>"u"),G=typeof y<"u"&&(w.reconnectable||o&&typeof w.reconnectable>"u"),q=!!(w.selectable||s&&typeof w.selectable>"u"),te=L.useRef(null),[ee,ne]=L.useState(!1),[K,C]=L.useState(!1),V=Ye(),{zIndex:W=w.zIndex,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z}=De(L.useCallback(ve=>{const re=ve.nodeLookup.get(w.source),Ne=ve.nodeLookup.get(w.target);if(!re||!Ne)return lp;const Me=S1({id:t,sourceNode:re,targetNode:Ne,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:ve.connectionMode,onError:E}),Te=p1({selected:w.selected,zIndex:w.zIndex,sourceNode:re,targetNode:Ne,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||lp,zIndex:Te}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex,E]),Qe),ie=L.useMemo(()=>w.markerStart?`url('#${cc(w.markerStart,k)}')`:void 0,[w.markerStart,k]),oe=L.useMemo(()=>w.markerEnd?`url('#${cc(w.markerEnd,k)}')`:void 0,[w.markerEnd,k]);if(w.hidden||U===null||M===null||D===null||H===null)return null;const fe=ve=>{var Te;const{addSelectedEdges:re,unselectNodesAndEdges:Ne,multiSelectionActive:Me}=V.getState();q&&(V.setState({nodesSelectionActive:!1}),w.selected&&Me?(Ne({nodes:[],edges:[w]}),(Te=te.current)==null||Te.blur()):re([t])),a&&a(ve,w)},he=u?ve=>{u(ve,{...w})}:void 0,pe=c?ve=>{c(ve,{...w})}:void 0,Z=h?ve=>{h(ve,{...w})}:void 0,se=p?ve=>{p(ve,{...w})}:void 0,me=v?ve=>{v(ve,{...w})}:void 0,ke=ve=>{var re;if(!R&&rg.includes(ve.key)&&q){const{unselectNodesAndEdges:Ne,addSelectedEdges:Me}=V.getState();ve.key==="Escape"?((re=te.current)==null||re.blur(),Ne({edges:[w]})):Me([t])}};return d.jsx("svg",{style:{zIndex:W},children:d.jsxs("g",{className:nt(["react-flow__edge",`react-flow__edge-${A}`,w.className,b,{selected:w.selected,animated:w.animated,inactive:!q&&!a,updating:ee,selectable:q}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:Z,onMouseMove:se,onMouseLeave:me,onKeyDown:F?ke:void 0,tabIndex:F?0:void 0,role:w.ariaRole??(F?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":F?`${$g}-${k}`:void 0,ref:te,...w.domAttributes,children:[!K&&d.jsx($,{id:t,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:q,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),G&&d.jsx(AS,{edge:w,isReconnectable:G,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,setUpdateHover:ne,setReconnecting:C})]})})}var zS=L.memo($S);const DS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function am({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:v,onEdgeClick:x,reconnectRadius:y,onEdgeDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:j}){const{edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,onError:w}=De(DS,Qe),N=SS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(ES,{defaultColor:t,rfId:o}),N.map(A=>d.jsx(zS,{id:A,edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,onClick:x,reconnectRadius:y,onDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:w,edgeTypes:s,disableKeyboardA11y:j},A))]})}am.displayName="EdgeRenderer";const OS=L.memo(am),cp=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function FS({children:t}){const r=Ye(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return Fg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=cp(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:cp(s)},children:t})}function HS(t){const r=na(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const BS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function VS(t){const r=De(BS),o=Ye();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function WS(t){return t.connection.inProgress?{...t.connection,to:gs(t.connection.to,t.transform)}:{...t.connection}}function US(t){return WS}function YS(t){const r=US();return De(r,Qe)}const GS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function XS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=De(GS,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:nt(["react-flow__connection",sg(h)]),children:d.jsx(um,{style:r,type:o,CustomComponent:s,isValid:h})})})}const um=({style:t,type:r=Lr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:v,toNode:x,toHandle:y,toPosition:m,pointer:_}=YS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:v.x,toY:v.y,fromPosition:p,toPosition:m,connectionStatus:sg(s),toNode:x,toHandle:y,pointer:_});let k="";const j={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:v.x,targetY:v.y,targetPosition:m};switch(r){case Lr.Bezier:[k]=xg(j);break;case Lr.SimpleBezier:[k]=Kg(j);break;case Lr.Step:[k]=Bl({...j,borderRadius:0});break;case Lr.SmoothStep:[k]=Bl(j);break;default:[k]=_g(j)}return d.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};um.displayName="ConnectionLine";const qS={};function dp(t=qS){L.useRef(t),Ye(),L.useEffect(()=>{},[t])}function KS(){Ye(),L.useRef(!1),L.useEffect(()=>{},[])}function cm({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,onSelectionContextMenu:y,onSelectionStart:m,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:j,connectionLineComponent:b,connectionLineContainerStyle:E,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,deleteKeyCode:G,onlyRenderVisibleElements:q,elementsSelectable:te,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,preventScrolling:V,defaultMarkerColor:W,zoomOnScroll:U,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,zoomOnDoubleClick:z,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneScroll:se,onPaneContextMenu:me,paneClickDistance:ke,nodeClickDistance:ve,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,viewport:ut,onViewportChange:Je,nodesDraggable:An}){return dp(t),dp(r),KS(),HS(o),VS(ut),d.jsx(fS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneContextMenu:me,onPaneScroll:se,paneClickDistance:ke,deleteKeyCode:G,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,elementsSelectable:te,zoomOnScroll:U,zoomOnPinch:M,zoomOnDoubleClick:z,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,onSelectionContextMenu:y,preventScrolling:V,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,onViewportChange:Je,isControlledViewport:!!ut,children:d.jsxs(FS,{children:[d.jsx(OS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,onlyRenderVisibleElements:q,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,defaultMarkerColor:W,noPanClassName:qt,disableKeyboardA11y:gt,rfId:Pt}),d.jsx(XS,{style:j,type:k,component:b,containerStyle:E}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(_S,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,nodeClickDistance:ve,onlyRenderVisibleElements:q,noPanClassName:qt,noDragClassName:Ge,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,nodesDraggable:An}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}cm.displayName="GraphView";const QS=L.memo(cm),ZS=fg(),fp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:v=2,nodeOrigin:x,nodeExtent:y,zIndexMode:m="basic"}={})=>{const _=new Map,k=new Map,j=new Map,b=new Map,E=s??r??[],R=o??t??[],w=x??[0,0],N=y??rs;Ng(j,b,E);const{nodesInitialized:A}=dc(R,_,k,{nodeOrigin:w,nodeExtent:N,zIndexMode:m});let $=[0,0,1];if(c&&a&&u){const F=hs(_,{filter:ee=>!!((ee.width||ee.initialWidth)&&(ee.height||ee.initialHeight))}),{x:G,y:q,zoom:te}=Nc(F,a,u,p,v,(h==null?void 0:h.padding)??.1);$=[G,q,te]}return{rfId:"1",width:a??0,height:u??0,transform:$,nodes:R,nodesInitialized:A,nodeLookup:_,parentLookup:k,edges:E,edgeLookup:b,connectionLookup:j,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:v,translateExtent:rs,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Zi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...og},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:ZS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:ig,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},JS=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m})=>d_((_,k)=>{async function j(){const{nodeLookup:b,panZoom:E,fitViewOptions:R,fitViewResolver:w,width:N,height:A,minZoom:$,maxZoom:F}=k();E&&(await l1({nodes:b,width:N,height:A,panZoom:E,minZoom:$,maxZoom:F},R),w==null||w.resolve(!0),_({fitViewResolver:null}))}return{...fp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,defaultNodes:o,defaultEdges:s,zIndexMode:m}),setNodes:b=>{const{nodeLookup:E,parentLookup:R,nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,fitViewQueued:$,zIndexMode:F,nodesSelectionActive:G}=k(),{nodesInitialized:q,hasSelectedNodes:te}=dc(b,E,R,{nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:F}),ee=G&&te;$&&q?(j(),_({nodes:b,nodesInitialized:q,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:ee})):_({nodes:b,nodesInitialized:q,nodesSelectionActive:ee})},setEdges:b=>{const{connectionLookup:E,edgeLookup:R}=k();Ng(E,R,b),_({edges:b})},setDefaultNodesAndEdges:(b,E)=>{if(b){const{setNodes:R}=k();R(b),_({hasDefaultNodes:!0})}if(E){const{setEdges:R}=k();R(E),_({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:E,nodeLookup:R,parentLookup:w,domNode:N,nodeOrigin:A,nodeExtent:$,debug:F,fitViewQueued:G,zIndexMode:q}=k(),{changes:te,updatedInternals:ee}=P1(b,R,w,N,A,$,q);ee&&(b1(R,w,{nodeOrigin:A,nodeExtent:$,zIndexMode:q}),G?(j(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(te==null?void 0:te.length)>0&&(F&&console.log("React Flow: trigger node changes",te),E==null||E(te)))},updateNodePositions:(b,E=!1)=>{const R=[];let w=[];const{nodeLookup:N,triggerNodeChanges:A,connection:$,updateConnection:F,onNodesChangeMiddlewareMap:G}=k();for(const[q,te]of b){const ee=N.get(q),ne=!!(ee!=null&&ee.expandParent&&(ee!=null&&ee.parentId)&&(te!=null&&te.position)),K={id:q,type:"position",position:ne?{x:Math.max(0,te.position.x),y:Math.max(0,te.position.y)}:te.position,dragging:E};if(ee&&$.inProgress&&$.fromNode.id===ee.id){const C=mi(ee,$.fromHandle,Se.Left,!0);F({...$,from:C})}ne&&ee.parentId&&R.push({id:q,parentId:ee.parentId,rect:{...te.internals.positionAbsolute,width:te.measured.width??0,height:te.measured.height??0}}),w.push(K)}if(R.length>0){const{parentLookup:q,nodeOrigin:te}=k(),ee=Pc(R,N,q,te);w.push(...ee)}for(const q of G.values())w=q(w);A(w)},triggerNodeChanges:b=>{const{onNodesChange:E,setNodes:R,nodes:w,hasDefaultNodes:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=R_(b,w);R($)}A&&console.log("React Flow: trigger node changes",b),E==null||E(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:E,setEdges:R,edges:w,hasDefaultEdges:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=T_(b,w);R($)}A&&console.log("React Flow: trigger edge changes",b),E==null||E(b)}},addSelectedNodes:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));N($);return}N(Gi(w,new Set([...b]),!0)),A(Gi(R))},addSelectedEdges:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));A($);return}A(Gi(R,new Set([...b]))),N(Gi(w,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:E}={})=>{const{edges:R,nodes:w,nodeLookup:N,triggerNodeChanges:A,triggerEdgeChanges:$}=k(),F=b||w,G=E||R,q=[];for(const ee of F){if(!ee.selected)continue;const ne=N.get(ee.id);ne&&(ne.selected=!1),q.push(ai(ee.id,!1))}const te=[];for(const ee of G)ee.selected&&te.push(ai(ee.id,!1));A(q),$(te)},setMinZoom:b=>{const{panZoom:E,maxZoom:R}=k();E==null||E.setScaleExtent([b,R]),_({minZoom:b})},setMaxZoom:b=>{const{panZoom:E,minZoom:R}=k();E==null||E.setScaleExtent([R,b]),_({maxZoom:b})},setTranslateExtent:b=>{var E;(E=k().panZoom)==null||E.setTranslateExtent(b),_({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:E,triggerNodeChanges:R,triggerEdgeChanges:w,elementsSelectable:N}=k();if(!N)return;const A=E.reduce((F,G)=>G.selected?[...F,ai(G.id,!1)]:F,[]),$=b.reduce((F,G)=>G.selected?[...F,ai(G.id,!1)]:F,[]);R(A),w($)},setNodeExtent:b=>{const{nodes:E,nodeLookup:R,parentLookup:w,nodeOrigin:N,elevateNodesOnSelect:A,nodeExtent:$,zIndexMode:F}=k();b[0][0]===$[0][0]&&b[0][1]===$[0][1]&&b[1][0]===$[1][0]&&b[1][1]===$[1][1]||(dc(E,R,w,{nodeOrigin:N,nodeExtent:b,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:F}),_({nodeExtent:b}))},panBy:b=>{const{transform:E,width:R,height:w,panZoom:N,translateExtent:A}=k();return I1({delta:b,panZoom:N,transform:E,translateExtent:A,width:R,height:w})},setCenter:async(b,E,R)=>{const{width:w,height:N,maxZoom:A,panZoom:$}=k();if(!$)return!1;const F=typeof(R==null?void 0:R.zoom)<"u"?R.zoom:A;return await $.setViewport({x:w/2-b*F,y:N/2-E*F,zoom:F},{duration:R==null?void 0:R.duration,ease:R==null?void 0:R.ease,interpolate:R==null?void 0:R.interpolate}),!0},cancelConnection:()=>{_({connection:{...og}})},updateConnection:b=>{_({connection:b})},reset:()=>_({...fp()})}},Object.is);function dm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m,children:_}){const[k]=L.useState(()=>JS({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:v,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:x,nodeExtent:y,zIndexMode:m}));return d.jsx(f_,{value:k,children:d.jsx(D_,{children:d.jsx(J_,{children:_})})})}function ek({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:v,maxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_}){return L.useContext(ea)?d.jsx(d.Fragment,{children:t}):d.jsx(dm,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:v,initialMaxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_,children:t})}const tk={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function nk({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:v,onMove:x,onMoveStart:y,onMoveEnd:m,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,onNodeDragStart:F,onNodeDrag:G,onNodeDragStop:q,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onSelectionChange:K,onSelectionDragStart:C,onSelectionDrag:V,onSelectionDragStop:W,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:H,connectionMode:I,connectionLineType:z=Lr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:Z=!1,selectionMode:se=is.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:ke=ls()?"Meta":"Control",zoomActivationKeyCode:ve=ls()?"Meta":"Control",snapToGrid:re,snapGrid:Ne,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Te,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,nodeOrigin:Ge=zg,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt=!0,defaultViewport:mt=j_,minZoom:Pt=.5,maxZoom:ut=2,translateExtent:Je=rs,preventScrolling:An=!0,nodeExtent:Ot,defaultMarkerColor:xn="#b1b1b7",zoomOnScroll:oo=!0,zoomOnPinch:$n=!0,panOnScroll:vi=!1,panOnScrollSpeed:or=.5,panOnScrollMode:$r=di.Free,zoomOnDoubleClick:zn=!0,panOnDrag:zr=!0,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn=1,nodeClickDistance:Fn=0,children:_n,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn=10,onNodesChange:Ht,onEdgesChange:Or,noDragClassName:nn="nodrag",noWheelClassName:Fr="nowheel",noPanClassName:yt="nopan",fitView:Hn,fitViewOptions:ur,connectOnClick:so,attributionPosition:It,proOptions:Bn,defaultEdgeOptions:Hr,elevateNodesOnSelect:jn=!0,elevateEdgesOnSelect:Br=!1,disableKeyboardA11y:xi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:lo,autoPanOnSelection:Vr=!0,autoPanSpeed:wi,connectionRadius:cr,isValidConnection:ao,onError:dr,style:Vn,id:bt,nodeDragThreshold:Wr,connectionDragThreshold:Et,viewport:uo,onViewportChange:Ur,width:Yr,height:Wn,colorMode:Un="light",debug:bn,onScroll:Bt,ariaLabelConfig:_i,zIndexMode:Gr="basic",...fr},hr){const Yn=bt||"1",En=M_(Un),co=L.useCallback(pr=>{pr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Bt==null||Bt(pr)},[Bt]);return d.jsx("div",{"data-testid":"rf__wrapper",...fr,onScroll:co,style:{...Vn,...tk},ref:hr,className:nt(["react-flow",a,En]),id:bt,role:"application",children:d.jsxs(ek,{nodes:t,edges:r,width:Yr,height:Wn,fitView:Hn,fitViewOptions:ur,minZoom:Pt,maxZoom:ut,nodeOrigin:Ge,nodeExtent:Ot,zIndexMode:Gr,children:[d.jsx(C_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt,elevateNodesOnSelect:jn,elevateEdgesOnSelect:Br,minZoom:Pt,maxZoom:ut,nodeExtent:Ot,onNodesChange:Ht,onEdgesChange:Or,snapToGrid:re,snapGrid:Ne,connectionMode:I,translateExtent:Je,connectOnClick:so,defaultEdgeOptions:Hr,fitView:Hn,fitViewOptions:ur,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onNodeDragStart:F,onNodeDrag:G,onNodeDragStop:q,onSelectionDrag:V,onSelectionDragStart:C,onSelectionDragStop:W,onMove:x,onMoveStart:y,onMoveEnd:m,noPanClassName:yt,nodeOrigin:Ge,rfId:Yn,autoPanOnConnect:Ve,autoPanOnNodeDrag:lo,autoPanSpeed:wi,onError:dr,connectionRadius:cr,isValidConnection:ao,selectNodesOnDrag:Te,nodeDragThreshold:Wr,connectionDragThreshold:Et,onBeforeDelete:H,debug:bn,ariaLabelConfig:_i,zIndexMode:Gr}),d.jsx(QS,{onInit:v,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,nodeTypes:u,edgeTypes:c,connectionLineType:z,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:Z,selectionMode:se,deleteKeyCode:he,multiSelectionKeyCode:ke,panActivationKeyCode:me,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:mt,translateExtent:Je,minZoom:Pt,maxZoom:ut,preventScrolling:An,zoomOnScroll:oo,zoomOnPinch:$n,zoomOnDoubleClick:zn,panOnScroll:vi,panOnScrollSpeed:or,panOnScrollMode:$r,panOnDrag:zr,autoPanOnSelection:Vr,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn,nodeClickDistance:Fn,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn,defaultMarkerColor:xn,noDragClassName:nn,noWheelClassName:Fr,noPanClassName:yt,rfId:Yn,disableKeyboardA11y:xi,nodeExtent:Ot,viewport:uo,onViewportChange:Ur,nodesDraggable:$e}),d.jsx(N_,{onSelectionChange:K}),_n,d.jsx(x_,{proOptions:Bn,position:It}),d.jsx(v_,{rfId:Yn,disableKeyboardA11y:xi})]})})}var rk=Og(nk);function ik({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:nt(["react-flow__background-pattern",o,s])})}function ok({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:nt(["react-flow__background-pattern","dots",r])})}var Ar;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Ar||(Ar={}));const sk={[Ar.Dots]:1,[Ar.Lines]:1,[Ar.Cross]:6},lk=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function fm({id:t,variant:r=Ar.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:v,patternClassName:x}){const y=L.useRef(null),{transform:m,patternId:_}=De(lk,Qe),k=s||sk[r],j=r===Ar.Dots,b=r===Ar.Cross,E=Array.isArray(o)?o:[o,o],R=[E[0]*m[2]||1,E[1]*m[2]||1],w=k*m[2],N=Array.isArray(u)?u:[u,u],A=b?[w,w]:R,$=[N[0]*m[2]+A[0]/2,N[1]*m[2]+A[1]/2],F=`${_}${t||""}`;return d.jsxs("svg",{className:nt(["react-flow__background",v]),style:{...p,...ra,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:y,"data-testid":"rf__background",children:[d.jsx("pattern",{id:F,x:m[0]%R[0],y:m[1]%R[1],width:R[0],height:R[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:j?d.jsx(ok,{radius:w/2,className:x}):d.jsx(ik,{dimensions:A,lineWidth:a,variant:r,className:x})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${F})`})]})}fm.displayName="Background";const ak=L.memo(fm);function uk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ck(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 fk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 hk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 jl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:nt(["react-flow__controls-button",r]),...o,children:t})}const pk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function hm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:v,children:x,position:y="bottom-left",orientation:m="vertical","aria-label":_}){const k=Ye(),{isInteractive:j,minZoomReached:b,maxZoomReached:E,ariaLabelConfig:R}=De(pk,Qe),{zoomIn:w,zoomOut:N,fitView:A}=na(),$=()=>{w(),u==null||u()},F=()=>{N(),c==null||c()},G=()=>{A(a),h==null||h()},q=()=>{k.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),p==null||p(!j)},te=m==="horizontal"?"horizontal":"vertical";return d.jsxs(ta,{className:nt(["react-flow__controls",te,v]),position:y,style:t,"data-testid":"rf__controls","aria-label":_??R["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(jl,{onClick:$,className:"react-flow__controls-zoomin",title:R["controls.zoomIn.ariaLabel"],"aria-label":R["controls.zoomIn.ariaLabel"],disabled:E,children:d.jsx(uk,{})}),d.jsx(jl,{onClick:F,className:"react-flow__controls-zoomout",title:R["controls.zoomOut.ariaLabel"],"aria-label":R["controls.zoomOut.ariaLabel"],disabled:b,children:d.jsx(ck,{})})]}),o&&d.jsx(jl,{className:"react-flow__controls-fitview",onClick:G,title:R["controls.fitView.ariaLabel"],"aria-label":R["controls.fitView.ariaLabel"],children:d.jsx(dk,{})}),s&&d.jsx(jl,{className:"react-flow__controls-interactive",onClick:q,title:R["controls.interactive.ariaLabel"],"aria-label":R["controls.interactive.ariaLabel"],children:j?d.jsx(hk,{}):d.jsx(fk,{})}),x]})}hm.displayName="Controls";const gk=L.memo(hm);function mk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:v,borderRadius:x,shapeRendering:y,selected:m,onClick:_}){const{background:k,backgroundColor:j}=u||{},b=c||k||j;return d.jsx("rect",{className:nt(["react-flow__minimap-node",{selected:m},v]),x:r,y:o,rx:x,ry:x,width:s,height:a,style:{fill:b,stroke:h,strokeWidth:p},shapeRendering:y,onClick:_?E=>_(E,t):void 0})}const yk=L.memo(mk),vk=t=>t.nodes.map(r=>r.id),Ku=t=>t instanceof Function?t:()=>t;function xk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=yk,onClick:c}){const h=De(vk,Qe),p=Ku(r),v=Ku(t),x=Ku(o),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(m=>d.jsx(_k,{id:m,nodeColorFunc:p,nodeStrokeColorFunc:v,nodeClassNameFunc:x,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:y},m))})}function wk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:v,x,y,width:m,height:_}=De(k=>{const j=k.nodeLookup.get(t);if(!j)return{node:void 0,x:0,y:0,width:0,height:0};const b=j.internals.userNode,{x:E,y:R}=j.internals.positionAbsolute,{width:w,height:N}=vn(b);return{node:b,x:E,y:R,width:w,height:N}},Qe);return!v||v.hidden||!hg(v)?null:d.jsx(h,{x,y,width:m,height:_,style:v.style,selected:!!v.selected,className:s(v),color:r(v),borderRadius:a,strokeColor:o(v),strokeWidth:u,shapeRendering:c,onClick:p,id:v.id})}const _k=L.memo(wk);var Sk=L.memo(xk);const kk=200,Nk=150,jk=t=>!t.hidden,bk=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?cg(hs(t.nodeLookup,{filter:jk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},hp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,Ek=(t,r)=>hp(t.viewBB,r.viewBB)&&hp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,Ck="react-flow__minimap-desc";function pm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:v,maskStrokeColor:x,maskStrokeWidth:y,position:m="bottom-right",onClick:_,onNodeClick:k,pannable:j=!1,zoomable:b=!1,ariaLabel:E,inversePan:R,zoomStep:w=1,offsetScale:N=5}){const A=Ye(),$=L.useRef(null),{boundingRect:F,viewBB:G,rfId:q,panZoom:te,translateExtent:ee,flowWidth:ne,flowHeight:K,ariaLabelConfig:C}=De(bk,Ek),V=(t==null?void 0:t.width)??kk,W=(t==null?void 0:t.height)??Nk,U=F.width/V,M=F.height/W,D=Math.max(U,M),H=D*V,I=D*W,z=N*D,ie=F.x-(H-F.width)/2-z,oe=F.y-(I-F.height)/2-z,fe=H+z*2,he=I+z*2,pe=`${Ck}-${q}`,Z=L.useRef(0),se=L.useRef();Z.current=D,L.useEffect(()=>{if($.current&&te)return se.current=F1({domNode:$.current,panZoom:te,getTransform:()=>A.getState().transform,getViewScale:()=>Z.current}),()=>{var re;(re=se.current)==null||re.destroy()}},[te]),L.useEffect(()=>{var re;(re=se.current)==null||re.update({translateExtent:ee,width:ne,height:K,inversePan:R,pannable:j,zoomStep:w,zoomable:b})},[j,b,R,w,ee,ne,K]);const me=_?re=>{var Te;const[Ne,Me]=((Te=se.current)==null?void 0:Te.pointer(re))||[0,0];_(re,{x:Ne,y:Me})}:void 0,ke=k?L.useCallback((re,Ne)=>{const Me=A.getState().nodeLookup.get(Ne).internals.userNode;k(re,Me)},[]):void 0,ve=E??C["minimap.ariaLabel"];return d.jsx(ta,{position:m,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof v=="string"?v:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof y=="number"?y*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:nt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:V,height:W,viewBox:`${ie} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:$,onClick:me,children:[ve&&d.jsx("title",{id:pe,children:ve}),d.jsx(Sk,{onClick:ke,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-z},${oe-z}h${fe+z*2}v${he+z*2}h${-fe-z*2}z - M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}pm.displayName="MiniMap";const Mk=L.memo(pm),Pk=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Ik={[to.Line]:"right",[to.Handle]:"bottom-right"};function Rk({nodeId:t,position:r,variant:o=to.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:v=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:y=!1,resizeDirection:m,autoScale:_=!0,shouldResize:k,onResizeStart:j,onResize:b,onResizeEnd:E}){const R=Wg(),w=typeof t=="string"?t:R,N=Ye(),A=L.useRef(null),$=o===to.Handle,F=De(L.useCallback(Pk($&&_),[$,_]),Qe),G=L.useRef(null),q=r??Ik[o];L.useEffect(()=>{if(!(!A.current||!w))return G.current||(G.current=J1({domNode:A.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,domNode:W}=N.getState();return{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,paneDomNode:W}},onChange:(ee,ne)=>{const{triggerNodeChanges:K,nodeLookup:C,parentLookup:V,nodeOrigin:W}=N.getState(),U=[],M={x:ee.x,y:ee.y},D=C.get(w);if(D&&D.expandParent&&D.parentId){const H=D.origin??W,I=ee.width??D.measured.width??0,z=ee.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:I,height:z,...pg({x:ee.x??D.position.x,y:ee.y??D.position.y},{width:I,height:z},D.parentId,C,H)}},oe=Pc([ie],C,V,W);U.push(...oe),M.x=ee.x?Math.max(H[0]*I,ee.x):void 0,M.y=ee.y?Math.max(H[1]*z,ee.y):void 0}if(M.x!==void 0&&M.y!==void 0){const H={id:w,type:"position",position:{...M}};U.push(H)}if(ee.width!==void 0&&ee.height!==void 0){const I={id:w,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:ee.width,height:ee.height}};U.push(I)}for(const H of ne){const I={...H,type:"position"};U.push(I)}K(U)},onEnd:({width:ee,height:ne})=>{const K={id:w,type:"dimensions",resizing:!1,dimensions:{width:ee,height:ne}};N.getState().triggerNodeChanges([K])}})),G.current.update({controlPosition:q,boundaries:{minWidth:h,minHeight:p,maxWidth:v,maxHeight:x},keepAspectRatio:y,resizeDirection:m,onResizeStart:j,onResize:b,onResizeEnd:E,shouldResize:k}),()=>{var ee;(ee=G.current)==null||ee.destroy()}},[q,h,p,v,x,y,j,b,E,k]);const te=q.split("-");return d.jsx("div",{className:nt(["react-flow__resize-control","nodrag",...te,o,s]),ref:A,style:{...a,scale:F,...c&&{[$?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Rk);const Tk={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function ia(t){return Tk[t]??8}const Wl=208,ro=64,Lk=88,Ak=28,$k=8;function zk(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function gm(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const w of t){const N=ia(w.type),A=s.get(N)??[];A.push(w),s.set(N,A)}const u=[...s.keys()].sort((w,N)=>w-N).map(w=>[...s.get(w)??[]].sort((N,A)=>N.name.localeCompare(A.name)||N.id.localeCompare(A.id))),c=new Set(t.map(w=>w.id)),h=new Map,p=new Map;for(const w of t)h.set(w.id,[]),p.set(w.id,[]);for(const w of r)!c.has(w.src)||!c.has(w.dst)||w.src===w.dst||(p.get(w.src).push(w.dst),h.get(w.dst).push(w.src));const v=new Map;u.forEach((w,N)=>{for(const A of w)v.set(A.id,N)});const x=new Map,y=()=>{for(const w of u)w.forEach((N,A)=>x.set(N.id,A))};y();const m=(w,N)=>{const A=w.map(($,F)=>{const G=N($.id).map(te=>x.get(te)).filter(te=>te!==void 0),q=zk(G);return{n:$,bary:Number.isNaN(q)?F:q,name:$.name,id:$.id}});return A.sort(($,F)=>$.bary-F.bary||$.name.localeCompare(F.name)||$.id.localeCompare(F.id)),A.map($=>$.n)},_=w=>N=>v.get(N)===w;for(let w=0;w<$k;w++){for(let N=1;N(h.get(A)??[]).filter(_(N-1))),y();for(let N=u.length-2;N>=0;N--)u[N]=m(u[N],A=>(p.get(A)??[]).filter(_(N+1))),y()}const k=Wl+Lk,j=ro+Ak,b=Math.max(...u.map(w=>w.length),1),E=[];let R=0;for(let w=0;wG.id)),A=new Set((u[w+1]??[]).map(G=>G.id));let $=0;if(A.size)for(const G of r)N.has(G.src)&&A.has(G.dst)&&($+=1);const F=Math.min(48,Math.max(0,($-2)*10));R+=k+F}return u.forEach((w,N)=>{const A=(b-w.length)*j/2;w.forEach(($,F)=>{o.set($.id,{x:E[N]??0,y:A+F*j})})}),o}const Dk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),mm=90,Ok=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),pp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Fk=Math.PI*(3-Math.sqrt(5)),ym=220,Hk=26,Bk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function vm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function BN(t){return pp[t]?pp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Vk(t){return t>=mm?"3d":"2d"}function Wk(t){return t>=mm?"overview":"full"}function Uk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(vm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Ok.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Uk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Gk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function Xk(t,r,o,s){const a=new Set(t.map(j=>j.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const j of r){if(!a.has(j.src)||!a.has(j.dst))continue;const b=u.get(j.src)??[];b.push({dst:j.dst,id:j.id}),u.set(j.src,b);const E=c.get(j.dst)??[];E.push({src:j.src,id:j.id}),c.set(j.dst,E)}const h=new Set(t.filter(j=>Dk.has(j.type)).map(j=>j.id)),p=h.size?h:a,v=new Set,x=[o];for(;x.length;){const j=x.pop();if(!v.has(j)){v.add(j);for(const b of u.get(j)??[])v.has(b.dst)||x.push(b.dst)}}const y=new Set([o]),m=[...p].filter(j=>v.has(j)),_=new Set(m);for(;m.length;){const j=m.pop();y.add(j);for(const b of c.get(j)??[])v.has(b.src)&&!_.has(b.src)&&(_.add(b.src),m.push(b.src))}const k=new Set;for(const j of r)y.has(j.src)&&y.has(j.dst)&&k.add(j.id);return{nodeIds:y,edgeIds:k}}function VN(t){const r=new Map;for(const s of t){const a=ia(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*ym;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Hk*Math.sqrt(h+1),v=h*Fk;o.set(c.id,{x:u,y:p*Math.cos(v),z:p*Math.sin(v)})})}return o}function WN(t){const r=new Map;for(const o of t){const s=ia(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*ym,count:s}))}const bl=16,qk=12,Kk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Qk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),gp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Zk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},mp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],yp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),Jk=new Set(["looks_idempotent_on_pk","null","blank"]),eN=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function tN(t){return gp[t]?gp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function nN(t,r,o){const s=new Map(r.map(m=>[m.id,m])),a=[];Kk.has(t.type)&&a.push("sink"),Qk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(m=>m.dst===t.id),h=o.filter(m=>m.src===t.id),p=c.slice(0,bl).map(m=>El(m,s,m.src)),v=h.slice(0,bl).map(m=>El(m,s,m.dst)),x=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,y={type:t.type,typeLabel:Zo(io(t.type)),layer:Bk[ia(t.type)]??"other",purpose:tN(t.type),name:t.name,qualifiedName:t.qualified_name,file:x,context:t.context,roles:a,facts:iN(u).filter(m=>!(m.key==="app"&&m.value===t.context)),inputs:p,outputs:v,extraInputs:Math.max(0,c.length-bl),extraOutputs:Math.max(0,h.length-bl),degreeIn:c.length,degreeOut:h.length,inputKinds:vp(c.map(m=>El(m,s,m.src))),outputKinds:vp(h.map(m=>El(m,s,m.dst))),pathSummary:""};return y.pathSummary=rN(y),y}function vp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function rN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function El(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Zo(io(s.type)):"",edgeType:t.type,edgeLabel:Zo(t.type),inferred:t.confidence<.8}}function iN(t){const r=[...mp.filter(a=>a in t),...Object.keys(t).filter(a=>!mp.includes(a)&&!yp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||yp.has(a)||eN.has(a))continue;s.add(a);const u=oN(a,t[a]);u!=null&&o.push({key:a,label:Zk[a]??Zo(a),value:u})}return o}function oN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!Jk.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return sN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,qk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function sN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const lN=12,xp=.2,aN=.8,uN=ro;function cN(t,r,o){const s=o??gm(t,r),a=[];for(const h of r){const p=s.get(h.src),v=s.get(h.dst);if(!p||!v)continue;const x=p.y+ro/2,y=v.y+ro/2;if(Math.abs(x-y)${Math.round(_/8)}`})}const u=new Map;for(const h of a){const p=u.get(h.corridor)??[];p.push(h),u.set(h.corridor,p)}const c=new Map;for(const h of u.values()){const p=[...h].sort((y,m)=>y.y0-m.y0||y.y1-m.y1||y.id.localeCompare(m.id)),v=dN(p),x=Math.max(0,...v.values())+1;for(const y of p)c.set(y.id,fN(v.get(y.id)??0,x))}return c}function dN(t){const r=[],o=new Map;for(const s of t){let a=-1;for(let u=0;ur[u]+uN){a=u;break}a<0?(a=r.length,r.push(s.y1)):r[a]=Math.max(r[a],s.y1),o.set(s.id,a)}return o}function fN(t,r){return r<=1?.5:xp+(aN-xp)*t/(r-1)}const hN=new Set,pN=L.lazy(()=>k0(()=>import("./LayeredGraph3D-BSASMssr.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),gN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function mN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(no,{type:"target",position:Se.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:io(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Tr(t.name)}),d.jsx(no,{type:"source",position:Se.Right,isConnectable:!1})]})}const yN={load:mN},vN=new Set(["django","react","stitch","arch"]);function xN({id:t,sourceX:r,sourceY:o,targetX:s,targetY:a,sourcePosition:u,targetPosition:c,style:h,markerEnd:p,markerStart:v,label:x,labelStyle:y,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,data:b,interactionWidth:E}){const[R,w,N]=Bl({sourceX:r,sourceY:o,sourcePosition:u,targetX:s,targetY:a,targetPosition:c,borderRadius:8,stepPosition:(b==null?void 0:b.stepPosition)??.5});return d.jsx(ms,{id:t,path:R,labelX:w,labelY:N,label:x,labelStyle:y,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,style:h,markerEnd:p,markerStart:v,interactionWidth:E})}const wN={loadstep:xN};function _N({topologyKey:t}){const{fitView:r}=na();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function SN(t,r,o=null,s={}){const a=new Map(t.map(v=>[v.id,v])),u=gm(t,r),c=cN(t,r,u),h=t.map(v=>{var m;const x=((m=s.roles)==null?void 0:m[v.id])||[],y=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:v.id,type:"load",position:u.get(v.id)??{x:0,y:0},data:{name:v.name,type:v.type,file:v.file_path,roles:x,dim:y},selected:o===v.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:Wl,height:ro,style:{width:Wl,height:ro}}}),p=r.filter(v=>a.has(v.src)&&a.has(v.dst)).map(v=>{const x=gN[v.weight]||"var(--edge-cheap)",y=!!(o&&(v.src===o||v.dst===o));return{id:v.id,source:v.src,target:v.dst,type:"loadstep",animated:v.weight==="critical",data:{stepPosition:c.get(v.id)??.5},style:{stroke:x,strokeWidth:v.weight==="critical"?2.4:1.2,strokeDasharray:v.confidence<.8?"6 4":void 0},markerEnd:{type:os.ArrowClosed,width:14,height:14,color:x},label:y?v.type.replaceAll("_"," "):void 0,labelStyle:y?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:y?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:y?[3,5]:void 0,labelBgBorderRadius:y?4:void 0}});return{rfNodes:h,rfEdges:p}}function kN({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:v}){const x=nN(t,r,o);return L.useEffect(()=>{const y=m=>{m.key==="Escape"&&s()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:x.typeLabel}),d.jsx("div",{className:"inspector-roles",children:x.roles.map(y=>d.jsx("span",{className:"inspector-chip",children:y},y))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Tr(x.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:x.purpose}),x.context?d.jsx("div",{className:"muted",children:Tr(x.context)}):null,x.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Tr(x.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Tr(x.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",x.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[x.degreeIn," in · ",x.degreeOut," out"]}),x.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:x.pathSummary}):null,x.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:x.facts.map(y=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:y.label}),d.jsx("dd",{children:Tr(y.value)})]},y.key))}):null,d.jsx(wp,{title:"Inputs",testId:"graph-inspector-inputs",links:x.inputs,extra:x.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(wp,{title:"Outputs",testId:"graph-inspector-outputs",links:x.outputs,extra:x.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),a?d.jsx("p",{className:"whatif-hint","data-testid":"whatif-hint",children:v?"Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map.":"Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."}):null,d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",title:"Start a hypothetical walk from this node. Does not use Base/Head.",onClick:()=>a(t.id),children:"What if this changes"}):null,v?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",title:"Hide nodes that are not on a path from here to a sink. Does not start a new walk.",onClick:()=>v(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function wp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Qu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:v,repoPath:x,onOpenFile:y,pinnedId:m,onPin:_}){const[k,j]=L.useState(null),b=a!==void 0?a:k,E=re=>{a===void 0&&j(re),u==null||u(re)},[R,w]=L.useState(null),[N,A]=L.useState(null),[$,F]=L.useState(new Set(vN)),[G,q]=L.useState(!1),[te,ee]=L.useState(""),[ne,K]=L.useState(!1),C=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,V=R??Vk(t.length),W=N??Wk(t.length),U=G?b:null,M=L.useMemo(()=>p?Xk(t,r,p):null,[t,r,p]),D=M?t.filter(re=>M.nodeIds.has(re.id)):t,H=M?r.filter(re=>M.edgeIds.has(re.id)):r,I=L.useMemo(()=>Yk(D,H,{detail:W,families:$,focusId:U,neighborhoodOnly:!!U}),[D,H,W,$,U]),z=L.useMemo(()=>`${I.nodes.map(re=>re.id).join("\0")}|${I.edges.map(re=>re.id).join("\0")}`,[I.nodes,I.edges]),ie=b?t.find(re=>re.id===b)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const re=SN(I.nodes,I.edges,b,{roles:c,testOverlay:h});return C&&(re.rfEdges=re.rfEdges.map(Ne=>({...Ne,animated:!1}))),re},[I.nodes,I.edges,b,C,c,h]);L.useEffect(()=>{if(!s)return;const re=t.find(Ne=>Ne.file_path===s);re&&E(re.id)},[s,t]);const he=L.useMemo(()=>Gk(t,te),[t,te]),pe=(re,Ne)=>{E(Ne.id)},Z=()=>{E(null),q(!1)},se=ie?d.jsx(kN,{node:ie,nodes:t,edges:r,onClose:Z,onWhatIf:o,onSelect:E,onOpenFile:y,pinned:m===ie.id,onPin:_,onIsolate:v?re=>{v(p===re?null:re)}:void 0}):null,me=re=>{F(Ne=>{const Me=new Set(Ne);if(Me.has(re)){if(Me.size===1)return Ne;Me.delete(re)}else Me.add(re);return Me})},ke=L.useMemo(()=>{const re=new Set;for(const Ne of t)re.add(vm(Ne.type));return re},[t]),ve=t.length-I.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:V==="2d"?"active":"","aria-pressed":V==="2d",onClick:()=>w("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:V==="3d"?"active":"","aria-pressed":V==="3d",onClick:()=>w("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:W==="overview"?"active":"","aria-pressed":W==="overview",onClick:()=>A("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:W==="full"?"active":"","aria-pressed":W==="full",onClick:()=>A("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(re=>ke.has(re)).map(re=>d.jsx("button",{type:"button","data-testid":`graph-family-${re}`,className:$.has(re)?"active":"","aria-pressed":$.has(re),onClick:()=>me(re),children:re},re))}),d.jsx("button",{type:"button",className:G?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!b,onClick:()=>q(re=>!re),children:G?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>v==null?void 0:v(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:te,onChange:re=>{ee(re.target.value),K(!0)},onFocus:()=>K(!0),onBlur:()=>window.setTimeout(()=>K(!1),150)}),ne&&te.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(re=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:Ne=>Ne.preventDefault(),onClick:()=>{E(re.id),ee(""),K(!1)},children:[re.name,d.jsx("span",{className:"muted",children:io(re.type)})]})},re.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[I.nodes.length," nodes · ",I.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:V==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(pN,{nodes:I.nodes,edges:I.edges,selectedId:b,neighborIds:U?I.neighborIds:hN,onSelect:re=>{E(re),re||q(!1)}})}),se]}):d.jsxs(dm,{children:[d.jsxs(rk,{nodes:oe,edges:fe,nodeTypes:yN,edgeTypes:wN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:Z,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(_N,{topologyKey:z}),d.jsx(ak,{}),d.jsx(Mk,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(gk,{})]}),se]})})]})}function xm(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function NN(t){localStorage.setItem("loadpath.editor",t)}async function jN(t,r,o,s=xm()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const _p=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],bN=["preset","branch","tag","commit"];function EN(t){var a;if(!(t!=null&&t.git))return[..._p];const r=((a=t.presets)!=null&&a.length?t.presets:_p.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function CN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function MN(t){return bN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function PN(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function Sp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[v,x]=L.useState(!1),[y,m]=L.useState(null),[_,k]=L.useState(0),j=L.useMemo(()=>{const N=EN(u);return y===null?N:CN(N,y)},[u,y]),b=L.useMemo(()=>MN(j),[j]);L.useEffect(()=>{v&&c()},[v,c]),L.useEffect(()=>{k(0)},[y,v]);const E=()=>{x(!1),m(null)},R=N=>{r(N.value),E()},w=N=>{if(N.key==="ArrowDown"){if(N.preventDefault(),!v){x(!0);return}k(A=>Math.min(A+1,Math.max(j.length-1,0)))}else if(N.key==="ArrowUp"){if(N.preventDefault(),!v)return;k(A=>Math.max(A-1,0))}else if(N.key==="Enter"&&v){N.preventDefault();const A=j[_];A&&R(A)}else N.key==="Escape"&&v&&(N.preventDefault(),E())};return d.jsxs("div",{className:"combo",ref:p,onBlur:N=>{N.currentTarget.contains(N.relatedTarget)||E()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":v,"aria-controls":h,"aria-autocomplete":"list",onChange:N=>{r(N.target.value),v&&m(N.target.value)},onKeyDown:w}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":v,onMouseDown:N=>N.preventDefault(),onClick:()=>v?E():x(!0),children:d.jsx(w0,{})})]}),v?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:b.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):b.map(N=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:PN(N.group)}),N.items.map(A=>{const $=j.indexOf(A);return d.jsxs("button",{type:"button",role:"option","aria-selected":$===_,className:$===_?"combo-option active":"combo-option","data-testid":`ref-option-${A.group}`,onMouseDown:F=>F.preventDefault(),onMouseEnter:()=>k($),onClick:()=>R(A),children:[d.jsx("span",{className:"combo-label",children:A.label}),A.detail?d.jsx("span",{className:"combo-detail",children:A.detail}):null]},`${A.group}:${A.value}`)})]},N.group))}):null]})}function IN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[v,x]=L.useState(""),[y,m]=L.useState(!1),_=L.useRef(null),k=L.useRef(0),j=async w=>{const N=k.current+1;k.current=N,m(!0);try{const A=await Pe.browse(w);if(k.current!==N)return;a(A),c(A.path),p(A.is_git?A.path:null),x("")}catch(A){if(k.current!==N)return;x(A instanceof Error?A.message:String(A))}finally{k.current===N&&m(!1)}};L.useEffect(()=>{var w,N;j(t),(w=_.current)==null||w.focus(),(N=_.current)==null||N.select()},[t]);const b=h||(s==null?void 0:s.path)||u,E=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",R=w=>{w.key==="Escape"&&(w.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:R,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:w=>w.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:w=>{w.preventDefault(),j(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:w=>c(w.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),v?d.jsx("div",{className:"error",role:"alert",children:v}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":y,children:s!=null&&s.entries.length?s.entries.map(w=>{const N=h===w.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":N,className:N?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":w.path,onClick:()=>p(w.path),onDoubleClick:()=>void j(w.path),children:[d.jsx(bp,{}),d.jsx("span",{className:"explorer-name",children:w.name}),w.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},w.path)}):d.jsx("div",{className:"muted explorer-empty",children:y?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:b,children:b}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!b,onClick:()=>b&&r(b),children:["Use ",E]})]})]})})}const RN={scan:{start:0,end:20},extract:{start:20,end:88},boot:{start:88,end:94},stitch:{start:94,end:99},skipped:{start:100,end:100},done:{start:100,end:100}},TN=new Set(["scan","extract","boot","stitch"]);function LN(t){const r=t.phase||"";if(!r||r==="idle")return null;const o=RN[r];if(!o)return null;if(o.start===o.end)return o.end;const s=t.total||0;if(s<=0)return o.start;const a=Math.min(1,Math.max(0,(t.done||0)/s));return Math.round(o.start+(o.end-o.start)*a)}function AN(t){return!t.phase||t.phase==="idle"?null:typeof t.percent=="number"&&Number.isFinite(t.percent)?Math.max(0,Math.min(100,Math.round(t.percent))):LN(t)}const Ul=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],$N="obsidian",wm="loadpath.theme";function zN(t){return Ul.some(r=>r.id===t)}function _m(){try{const t=localStorage.getItem(wm)||"";if(zN(t))return t}catch{}return $N}function DN(t){var r;return((r=Ul.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function Sm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=DN(t);try{localStorage.setItem(wm,t)}catch{}}const Zu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:g0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:m0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:y0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:v0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:x0}];function Ju(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function ON(){var fo,ho,Si,po,go,mo,ki,Xr,rn,on;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,v]=L.useState(null),[x,y]=L.useState(null),[m,_]=L.useState(null),[k,j]=L.useState([]),[b,E]=L.useState("review"),[R,w]=L.useState(""),[N,A]=L.useState(""),[$,F]=L.useState(null),[G,q]=L.useState(!1),[te,ee]=L.useState(!1),[ne,K]=L.useState(""),[C,V]=L.useState({}),[W,U]=L.useState([]),[M,D]=L.useState([]),[H,I]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[z,ie]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[oe,fe]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[he,pe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[Z,se]=L.useState(0),[me,ke]=L.useState(""),[ve,re]=L.useState(_m),[Ne,Me]=L.useState(!1),[Te,$e]=L.useState(!1),[st,lt]=L.useState(!1),[at,Ge]=L.useState(null),[wt,qt]=L.useState(null),[gt,mt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[Pt,ut]=L.useState(null),[Je,An]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[Ot,xn]=L.useState([]),[oo,$n]=L.useState(null),[vi,or]=L.useState(null),[$r,zn]=L.useState(null),[zr,sr]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[lr,Ft]=L.useState(null),[ct,Dn]=L.useState(null),[On,wn]=L.useState(!1),[Fn,_n]=L.useState(!1),rt=L.useRef(o);rt.current=o;const Dr=L.useRef(!1);Dr.current=Te;const _t=L.useRef(""),ar=L.useRef(""),Sn=P=>{re(P),Sm(P)},dt=L.useRef(""),He=P=>{dt.current=P,A(P)},kn=P=>{let Y=0,ce=!1;F(0);const je=()=>{Pe.indexProgress(P).then(Ie=>{if(!dt.current)return;if(Ie.phase&&Ie.phase!=="idle"&&Ie.message&&He(Ie.message),TN.has(Ie.phase))ce=!0;else if(!ce)return;const qr=AN(Ie);qr!=null&&(Ie.phase==="scan"&&!Ie.done?Y=qr:Y=Math.max(Y,qr),F(Y))}).catch(()=>{})};je();const Le=window.setInterval(je,250);return()=>{window.clearInterval(Le),F(null)}};L.useEffect(()=>{Pe.settings().then(V).catch(()=>{}).finally(()=>Me(!0)),Pe.repos().then(P=>j(P.repos)).catch(()=>{})},[]);const Nn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const P=o;let Y=!1;return ar.current!==P&&Bn(P),Pe.config(P).then(ce=>{!Y&&rt.current===P&&or(ce)}).catch(()=>{}),Pe.architectureHealth(P).then(ce=>{!Y&&rt.current===P&&zn(ce)}).catch(()=>{}),()=>{Y=!0}},[t,o]);const Ht=P=>{rt.current=P,s(P),localStorage.setItem("loadpath.repo",P),P.trim()!==_t.current&&(_t.current="",Ft(null))},Or=L.useCallback(P=>{const Y=(P??rt.current).trim();return!Y||_t.current===Y?Promise.resolve():(_t.current=Y,Pe.gitRefs(Y).then(ce=>{rt.current.trim()===Y&&Ft(ce)}).catch(()=>{_t.current===Y&&(_t.current="",Ft(null))}))},[]),nn=(P,Y)=>{u(P),h(Y),localStorage.setItem("loadpath.base",P),localStorage.setItem("loadpath.head",Y)},Fr=(P,Y,ce)=>{ie(P),I(Y),localStorage.setItem("loadpath.provider",P),localStorage.setItem("loadpath.scmRepo",Y),ce!==void 0&&(fe(ce),localStorage.setItem("loadpath.prNumber",ce))},yt=P=>{v(P),se(0),Ge(wt&&P.nodes.some(Y=>Y.id===wt)?wt:null),ut(null),$n(null),P.what_if||(y(P),P.id&&localStorage.setItem("loadpath.lastReviewId",P.id))},Hn=async P=>{try{const Y=await Pe.reviews(P);xn(Y.reviews)}catch{xn([])}},ur=async P=>{try{zn(await Pe.architectureHealth(P))}catch{zn(null)}},so=P=>P==="github"?!!C.github_token_set:P==="gitlab"?!!C.gitlab_token_set:!!C.bitbucket_token_set,It=L.useCallback(async(P=z)=>{var Y;try{const ce=await Pe.scmRepos(P);D(ce.repos),(Y=ce.user)!=null&&Y.login&&V(je=>({...je,...P==="github"?{github_user:ce.user.login}:P==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{D([])}},[z]);L.useEffect(()=>{if(t!=="prs")return;let P=!1;return It(z).catch(()=>{P||D([])}),()=>{P=!0}},[t,z,It]),L.useEffect(()=>{if(!ct)return;let P=!1,Y=0;const ce=async()=>{try{const je=await Pe.githubOAuthPoll(ct.flow_id);if(P)return;if(je.status==="complete"){Dn(null);const Le=await Pe.settings();V(Le),K(je.user?`Signed in to GitHub as ${je.user}`:"Signed in to GitHub"),It("github");return}if(je.status==="pending"||je.status==="slow_down"){Y=window.setTimeout(ce,Math.max(je.interval||ct.interval,5)*1e3);return}Dn(null),w(je.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(je){if(P)return;Dn(null),w(je instanceof Error?je.message:String(je))}};return Y=window.setTimeout(ce,Math.max(ct.interval,5)*1e3),()=>{P=!0,window.clearTimeout(Y)}},[ct,It]),L.useEffect(()=>{if(!On)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.bitbucket.connected){wn(!1);const Ie=await Pe.settings();V(Ie),K(Le.bitbucket.user?`Signed in to Bitbucket as ${Le.bitbucket.user}`:"Signed in to Bitbucket"),It("bitbucket");return}if(Date.now()-ce>18e4){wn(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;wn(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[On,It]),L.useEffect(()=>{if(!Fn)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.gitlab.connected){_n(!1);const Ie=await Pe.settings();V(Ie),K(Le.gitlab.user?`Signed in to GitLab as ${Le.gitlab.user}`:"Signed in to GitLab"),It("gitlab");return}if(Date.now()-ce>18e4){_n(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;_n(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[Fn,It]);const Bn=async(P=o,Y=!1)=>{if(!P.trim())return null;ar.current=P,ee(!0);try{const ce=await Pe.architecture(P,!1);rt.current===P&&_(ce);const je=Pe.architectureGraph(P).then(Le=>{rt.current===P&&_(Ie=>Ie&&{...Ie,nodes:Le.nodes,edges:Le.edges,graph_pending:!1})});return je.catch(()=>{}).finally(()=>{rt.current===P&&ee(!1)}),Y&&await je,ce}catch(ce){throw rt.current===P&&ee(!1),ce}},Hr=async P=>{const Y=P.trim();if(!(!Y||Y===rt.current)){if(dt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),K(""),v(null),y(null),_(null),E("architecture"),Ht(Y),q(!0),He(`Loading ${p0(Y)}…`);try{await Promise.all([Bn(Y),Or(Y)])}catch(ce){rt.current===Y&&w(ce instanceof Error?ce.message:String(ce))}finally{rt.current===Y&&(He(""),q(!1))}}},jn=async()=>{if(dt.current||!Nn())return;w(""),K(""),He("Tracing load path…"),Ht(o),nn(a,c);const P=kn(o);try{const Y=await Pe.review(o,a,c,!0,he);yt(Y),E("review"),r("review"),await Pe.repos().then(ce=>j(ce.repos)).catch(()=>{}),await Promise.all([Bn(o),Hn(o),ur(o)])}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{P(),He("")}},Br=async(P=!0)=>{if(dt.current||!Nn())return;w(""),K(""),He(P?"Indexing…":"Full reindex…"),Ht(o);const Y=kn(o);try{await Pe.index(o,P);const ce=await Bn(o);await Pe.repos().then(je=>j(je.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(E("architecture"),r("architecture"))}catch(ce){w(ce instanceof Error?ce.message:String(ce))}finally{Y(),He("")}},xi=async()=>{if(!dt.current&&Nn()){w(""),K(""),He("Detecting layout…"),Ht(o);try{const P=await Pe.init(o);K(P.message),await Pe.repos().then(Y=>j(Y.repos)).catch(()=>{})}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ve=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),K("Copied markdown brief")}catch(P){w(P instanceof Error?P.message:String(P))}},lo=async()=>{if(!dt.current){if(p!=null&&p.what_if){w("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first.");return}if(!(p!=null&&p.markdown)||!H||!oe){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const P=await Pe.postComment(z,H,Number(oe),p.markdown);K(P.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Vr=async()=>{if(!dt.current){w(""),He("Fetching pull requests…");try{const P=await Pe.prs(z,H,"open",o.trim()||void 0);U(P.pull_requests);const Y=M.find(ce=>ce.slug.toLowerCase()===H.trim().toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},wi=async()=>{w("");try{const P=await Pe.githubOAuthStart();Dn(P),Ju(P.verification_uri_complete,"github.com","/login/device")}catch(P){w(P instanceof Error?P.message:String(P))}},cr=async()=>{w("");try{const P=await Pe.bitbucketOAuthStart();wn(!0),Ju(P.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(P){wn(!1),w(P instanceof Error?P.message:String(P))}},ao=async()=>{w("");try{const P=await Pe.gitlabOAuthStart();_n(!0),Ju(P.authorize_url,new URL(P.authorize_url).hostname,"/oauth/authorize")}catch(P){_n(!1),w(P instanceof Error?P.message:String(P))}},dr=async P=>{if(!(dt.current||!o.trim())){w(""),He("Walking what-if path…");try{const Y=await Pe.whatIf(o,P);K(`${Y.title} — ${Y.confidence.level} · ${(Y.sinks||[]).length} sinks`),yt({...Y,markdown:Y.markdown||"",index:Y.index||(p==null?void 0:p.index),workspace:Y.workspace||(p==null?void 0:p.workspace)}),E("review"),r("review")}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},Vn=()=>{if(x){yt(x),E("review"),r("review"),K("Restored the last git-range walk");return}v(null),se(0),Ge(null),ut(null),$n(null),E("architecture"),r("architecture"),K("")},bt=async P=>{var Le;if(dt.current)return;Fr(P.provider,P.repo,String(P.number));const Y=M.find(Ie=>Ie.slug.toLowerCase()===P.repo.toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path),w(""),He(`Fetching ${P.provider} #${P.number}…`);const ce=(Y==null?void 0:Y.local_path)||o,je=ce?kn(ce):()=>{};try{const Ie=await Pe.reviewPr(P.provider,P.repo,P.number,(Y==null?void 0:Y.local_path)||o||void 0);yt(Ie),Ie.pull_request&&typeof Ie.pull_request.repo_path=="string"&&Ht(Ie.pull_request.repo_path),nn(String(Ie.base||P.target_branch),String(Ie.head||P.source_branch)),E("review"),r("review"),typeof((Le=Ie.pull_request)==null?void 0:Le.repo_path)=="string"&&Hn(Ie.pull_request.repo_path)}catch(Ie){nn(P.base_sha||P.target_branch,P.head_sha||P.source_branch),r("review"),w(Ie instanceof Error?Ie.message:String(Ie))}finally{je(),He("")}},Wr=async P=>{w("");try{V(await Pe.oauthDisconnect(P)),z===P&&D([]),K(`Disconnected ${P}`)}catch(Y){w(Y instanceof Error?Y.message:String(Y))}},Et=async P=>{P.preventDefault();const Y=new FormData(P.currentTarget),ce={github_token:String(Y.get("github_token")||""),github_oauth_client_id:String(Y.get("github_oauth_client_id")||""),github_host:String(Y.get("github_host")||""),gitlab_token:String(Y.get("gitlab_token")||""),gitlab_host:String(Y.get("gitlab_host")||""),gitlab_oauth_client_id:String(Y.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(Y.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(Y.get("bitbucket_token")||""),bitbucket_username:String(Y.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(Y.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(Y.get("bitbucket_oauth_client_secret")||""),ai_provider:String(Y.get("ai_provider")||"none"),ai_api_key:String(Y.get("ai_api_key")||""),ai_model:String(Y.get("ai_model")||""),ai_base_url:String(Y.get("ai_base_url")||"")},je=k.length?{...ce,workspaces:k.map(Le=>({path:Le.path,name:Le.name}))}:ce;try{V(await Pe.saveSettings(je)),K("Settings saved on this machine")}catch(Le){w(Le instanceof Error?Le.message:String(Le))}},uo=async()=>{if(!(!p||dt.current)){He("Residual analysis…");try{const P=await Pe.residual(p);ke(P.note)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ur=L.useRef(jn);Ur.current=jn;const Yr=L.useRef(t);Yr.current=t;const Wn=L.useRef(!1);Wn.current=st;const Un=L.useRef(p);Un.current=p;const bn=L.useRef(Z);bn.current=Z,L.useEffect(()=>{const P=localStorage.getItem("loadpath.lastReviewId"),Y=(localStorage.getItem("loadpath.repo")||"").trim();if(!P||!Y){sr(!1);return}let ce=!1;return Pe.getReview(Y,P).then(je=>{ce||(yt(je),nn(je.base||localStorage.getItem("loadpath.base")||"HEAD~1",je.head||localStorage.getItem("loadpath.head")||"HEAD"),Hn(Y),ur(Y))}).catch(()=>{}).finally(()=>{ce||sr(!1)}),()=>{ce=!0}},[]);const Bt=L.useRef("");L.useEffect(()=>{if(!Je||!o.trim())return;let P=!1;const Y=async()=>{try{const je=await Pe.workspaceStatus(o);if(P)return;Bt.current&&je.fingerprint!==Bt.current&&!dt.current&&(pe(!0),localStorage.setItem("loadpath.dirty","1"),Ur.current()),Bt.current=je.fingerprint}catch{}};Y();const ce=window.setInterval(Y,2e3);return()=>{P=!0,window.clearInterval(ce)}},[Je,o]),L.useEffect(()=>{const P=Y=>{var Le;if((Y.metaKey||Y.ctrlKey)&&Y.key.toLowerCase()==="k"){Y.preventDefault(),lt(Ie=>!Ie);return}if(Wn.current){Y.key==="Escape"&&(Y.preventDefault(),lt(!1));return}if(Dr.current){Y.key==="Escape"&&(Y.preventDefault(),$e(!1));return}const ce=Y.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){Y.key==="Escape"&&ce.blur();return}if(Y.key==="Escape"){w(""),K(""),Ge(wt),ut(null);return}if(Y.key==="j"||Y.key==="k"){const Ie=((Le=Un.current)==null?void 0:Le.read_order)||[];if(!Ie.length)return;Y.preventDefault();const Gn=bn.current,qr=Y.key==="j"?Math.min(Ie.length-1,Gn+1):Math.max(0,Gn-1);se(qr);return}const je=Zu.find(Ie=>Ie.shortcut===Y.key);if(je&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey&&r(je.id),(Y.metaKey||Y.ctrlKey)&&Y.key==="Enter"){if(Yr.current==="settings"||Yr.current==="prs"||dt.current)return;Y.preventDefault(),Ur.current()}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[wt]);const _i=async(P,Y)=>{if(!o.trim())return;const ce=await jN(o,P,Y);ce.ok?K(ce.message):w(ce.message)},Gr=async()=>{if(p)try{const P=await Pe.exportHtml(p),Y=URL.createObjectURL(P),ce=document.createElement("a");ce.href=Y,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(Y),K("Saved HTML brief")}catch(P){w(P instanceof Error?P.message:String(P))}},fr=async P=>{if(o.trim()){He("Loading stored review…");try{const Y=await Pe.getReview(o,P);yt(Y),nn(Y.base||a,Y.head||c),E("review"),r("review");const ce=Ot.find(je=>je.id!==P);if(ce)try{$n(await Pe.reviewDiff(o,P,ce.id))}catch{$n(null)}}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},hr={selectedId:at,onSelect:Ge,nodeRoles:p==null?void 0:p.node_roles,testOverlay:gt,isolateSource:Pt,onIsolate:ut,repoPath:o,onOpenFile:_i,pinnedId:wt,onPin:qt},Yn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},...p!=null&&p.what_if?[{id:"exit-whatif",group:"Review",label:x?"Back to git-range walk":"Exit what-if walk",run:Vn}]:[],{id:"index",group:"Run",label:"Index repository",run:()=>void Br(!0)},{id:"watch",group:"Run",label:Je?"Stop watching working tree":"Watch working tree",run:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")}},{id:"tests",group:"Graph",label:gt?"Hide test overlay":"Show test overlay",run:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Gr()},...Zu.map(P=>({id:`tab-${P.id}`,group:"Tabs",label:`Go to ${P.label}`,hint:P.shortcut,run:()=>r(P.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(P=>({id:`node-${P.id}`,group:"Nodes",label:P.name,hint:io(P.type),run:()=>{Ge(P.id),r("graph")}})),...Ot.slice(0,12).map(P=>({id:`hist-${P.id}`,group:"History",label:P.title||P.id,hint:`${P.level||""} ${P.created_at||""}`.trim(),run:()=>void fr(P.id)}))],En=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[b,m,p]),co=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[b,m,p]),pr=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Fe=((p==null?void 0:p.findings)||[]).filter(P=>!P.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Zu.map(P=>{const Y=P.icon,ce=t===P.id;return d.jsxs("button",{type:"button","data-testid":P.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":P.label,onClick:()=>r(P.id),children:[d.jsx(Y,{}),d.jsx("span",{children:P.label})]},P.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:ve,onChange:P=>Sn(P.target.value),children:["dark","light"].map(P=>d.jsx("optgroup",{label:P==="dark"?"Dark":"Light",children:Ul.filter(Y=>Y.group===P).map(Y=>d.jsx("option",{value:Y.id,children:Y.label},Y.id))},P))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:N||pr}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[N?d.jsxs("div",{className:$!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","aria-valuemin":$!=null?0:void 0,"aria-valuemax":$!=null?100:void 0,"aria-valuenow":$??void 0,"data-testid":"progress",children:[d.jsx("i",{style:$!=null?{width:`${$}%`}:void 0}),d.jsx("span",{className:"sr-only",children:N})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[k.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:k.some(P=>P.path===o)?o:"",disabled:!!N,"aria-busy":G,onChange:P=>{P.target.value&&Hr(P.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),k.map(P=>d.jsxs("option",{value:P.path,children:[P.name,P.indexed?` (${P.counts.nodes})`:""]},P.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:P=>{const Y=P.target.value;s(Y),Y.trim()!==_t.current&&(_t.current="",Ft(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>$e(!0),children:d.jsx(bp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(Sp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:P=>nn(P,c),placeholder:"base",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(Sp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:P=>nn(a,P),placeholder:"head",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:he?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":he,onClick:()=>{const P=!he;pe(P),localStorage.setItem("loadpath.dirty",P?"1":"0")},children:he?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:Je?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":Je,onClick:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")},children:Je?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.what_if?"what-if · ":"",p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!N,onClick:xi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!N,onClick:()=>Br(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!N,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[R?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:R}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,ne?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:ne}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>K(""),"aria-label":"Dismiss",children:"×"})]}):null,((fo=p==null?void 0:p.index)!=null&&fo.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((ho=p==null?void 0:p.index)==null?void 0:ho.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Si=p==null?void 0:p.index)==null?void 0:Si.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(po=p==null?void 0:p.workspace)!=null&&po.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,p!=null&&p.what_if?d.jsxs("div",{className:"banner whatif","data-testid":"whatif-banner",children:[d.jsxs("span",{children:["Hypothetical walk from"," ",d.jsx("strong",{children:((go=p.node)==null?void 0:go.name)||"this node"}),". Loadpath ignored Base/Head and asked which sinks would feel this node change — not a filter of the current map."]}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-exit-whatif",onClick:Vn,children:x?"Back to git range":"Back to architecture"})]}):null,G?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:N||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":G||te,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(FN,{review:p,findings:Fe,aiNote:me,busy:!!N,tourIndex:Z,onTour:se,onAskAi:uo,onCopy:Ve,onPost:lo,onSelect:Ge,onOpenFile:_i,onExport:Gr,history:Ot,diff:oo,onReopen:fr,onWaiver:(P,Y)=>{o.trim()&&Pe.addWaiver(o,P,Y||void 0,"from review").then(ce=>{or(ce),K(`Waived ${P} in loadpath.yml`)})}}):zr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Qu,{nodes:p.nodes,edges:p.edges,onWhatIf:dr,focusPath:(mo=p.read_order[Z])==null?void 0:mo.path,...hr}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(HN,{architecture:m,busy:!!N,onReindex:()=>Br(!1),onReview:jn,onSelect:Ge,config:vi,health:$r,onSaveConfig:P=>{Pe.saveConfig(o,P).then(Y=>{or(Y),K("Wrote loadpath.yml")})},onWaiver:(P,Y,ce)=>{Pe.addWaiver(o,P,Y,ce).then(je=>{or(je),K(`Waived ${P}`)})}}):G?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(te||m!=null&&m.graph_pending)&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(ki=m==null?void 0:m.counts)!=null&&ki.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Qu,{nodes:m.nodes,edges:m.edges,onWhatIf:dr,...hr,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":b==="review","data-testid":"graph-mode-review",className:b==="review"?"active":"",onClick:()=>E("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":b==="architecture","data-testid":"graph-mode-architecture",className:b==="architecture"?"active":"",onClick:()=>E("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:gt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":gt,onClick:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")},children:"Tests"})]}),En.length?d.jsx(Qu,{nodes:En,edges:co,onWhatIf:dr,...hr}):te||m!=null&&m.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:z,onChange:P=>Fr(P.target.value,H,oe),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:M.length?"Search your repos":"owner/repo",value:H,onChange:P=>Fr(z,P.target.value,oe),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:M.map(P=>d.jsxs("option",{value:P.slug,children:[P.private?"private":"public",P.local_path?" · local":""]},P.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!N||!so(z),onClick:()=>{It(z)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!N,onClick:Vr,children:"List PRs"})]}),M.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[M.length," ",z," repositor",M.length===1?"y":"ies",z==="github"&&C.github_user?` · @${String(C.github_user)}`:"",z==="gitlab"&&C.gitlab_user?` · @${String(C.gitlab_user)}`:"",z==="bitbucket"&&C.bitbucket_user?` · ${String(C.bitbucket_user)}`:""]}):null,W.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):W.map(P=>{var Y;return d.jsxs("article",{className:"pr","data-testid":`pr-${P.number}`,children:[d.jsxs("h3",{children:["#",P.number," ",P.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${P.draft?"":"open"}`,children:P.draft?"draft":P.state}),d.jsx("span",{children:P.author}),d.jsxs("span",{children:[P.source_branch," → ",P.target_branch]}),P.loadpath?d.jsxs("span",{className:`chip ${P.loadpath.level||""}`,"data-testid":`pr-loadpath-${P.number}`,children:[((Y=P.loadpath.level)==null?void 0:Y.toUpperCase())||"REVIEWED",P.loadpath.contract_break&&P.loadpath.contract_break!=="none"?` · ${P.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:P.url,target:"_blank",rel:"noreferrer",children:["Open on ",P.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${P.number}`,onClick:()=>void bt(P),children:"Review this PR"})]})]},`${P.provider}-${P.number}`)})]}),t==="settings"&&Ne&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Et,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Ul.map(P=>d.jsxs("button",{type:"button","data-theme":P.id,className:ve===P.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${P.id}`,onClick:()=>Sn(P.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:P.label}),d.jsx("div",{className:"group",children:P.group})]},P.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:xm(),onChange:P=>NN(P.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:C.github_token_set?C.github_user?`Signed in as @${String(C.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void Wr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!ct||!C.github_oauth_ready,onClick:()=>void wi(),children:ct?"Waiting for GitHub…":"Sign in with GitHub"})})]}),ct?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:ct.user_code})," at GitHub if the browser did not fill it in."]}):null,C.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(C.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(C.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:C.gitlab_token_set?C.gitlab_user?`Signed in as @${String(C.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void Wr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Fn||!C.gitlab_oauth_ready,onClick:()=>void ao(),children:Fn?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(C.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(C.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:C.bitbucket_token_set?C.bitbucket_user?`Signed in as ${String(C.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void Wr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:On||!C.bitbucket_oauth_ready,onClick:()=>void cr(),children:On?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),C.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(C.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(C.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((Xr=C.ai)==null?void 0:Xr.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((rn=C.ai)==null?void 0:rn.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((on=C.ai)==null?void 0:on.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(d0,{open:st,actions:Yn,onClose:()=>lt(!1)}),Te?d.jsx(IN,{initialPath:o,onClose:()=>$e(!1),onSelect:P=>{if(dt.current){w("Wait for the current job to finish before switching workspace.");return}$e(!1),Hr(P)}}):null]})}function FN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:v,onOpenFile:x,onExport:y,history:m,diff:_,onReopen:k,onWaiver:j}){var E,R,w,N,A,$,F,G,q,te,ee,ne,K,C,V,W,U;const b=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),b.length?d.jsx("ul",{className:"reasons",children:b.map(M=>d.jsx("li",{children:M},M))}):null,t.what_if?d.jsx("span",{className:"chip whatif","data-testid":"whatif-chip",children:"what-if"}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Zo(M)},M)),(E=t.contract_break)!=null&&E.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>j(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(R=t.workspace)!=null&&R.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>x(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(km,{cards:t.deepening}),(N=(w=t.contract_break)==null?void 0:w.reasons)!=null&&N.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),($=(A=t.contract_break.sides)==null?void 0:A.rows)!=null&&$.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(F=t.auth)!=null&&F.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(G=t.suggested_tests)==null?void 0:G.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(q=t.trend)!=null&&q.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",ec(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),m.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:m.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,m.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>k(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?ec(M.created_at):""})]},M.id))]}):null,(ee=(te=t.evolution)==null?void 0:te.notes)!=null&&ee.length||(K=(ne=t.evolution)==null?void 0:ne.hotspots)!=null&&K.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((C=t.evolution)==null?void 0:C.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((V=t.evolution)==null?void 0:V.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:y,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",disabled:s||!!t.what_if,title:t.what_if?"Hypothetical walks are not posted to a pull request":void 0,onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(W=t.codeowners_reviewers)!=null&&W.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function HN({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var x;const v=t.findings.filter(y=>!y.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${ec(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(y=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y.name})," — ",(y.django_apps||[]).join(", ")||"no apps"," ·"," ",(y.owners||[]).join(", ")||"unowned"]},y.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(y=>d.jsx("div",{className:"muted",children:y},y))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:v.length})]}),v.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):v.map(y=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>y.node_id&&a(y.node_id),children:[d.jsx("span",{className:`chip ${y.severity}`,children:y.severity}),y.message]})},y.rule+y.message))]}),d.jsx(km,{cards:t.deepening}),(x=c==null?void 0:c.points)!=null&&x.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(y=>d.jsx("i",{className:y.level||"",title:`${y.level} · ${y.findings} findings`,style:{height:`${8+Math.min(24,(y.findings||0)*4)}px`}},y.id||y.created_at))}),Object.entries(c.contexts).map(([y,m])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y})," — last ",((_=m[m.length-1])==null?void 0:_.findings)??0," findings"]},y)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(f0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((y,m)=>m[1]-y[1]).slice(0,12).map(([y,m])=>d.jsxs("tr",{children:[d.jsx("td",{children:io(y)}),d.jsx("td",{children:m})]},y))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function km({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:h0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}Sm(_m());a0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(ON,{})}));export{Bk as L,WN as a,BN as c,d as j,VN as l,L as r,io as t}; +`)),x=v.reduce((y,m)=>y.concat(...m),[]);return[v,x]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Xh,v=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const x=_=>{var b,E;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!v)&&yg(_))return!1;const j=Kh(_.code,h);if(u.current.add(_[j]),qh(c,u.current,!1)){const R=((E=(b=_.composedPath)==null?void 0:b.call(_))==null?void 0:E[0])||_.target,w=(R==null?void 0:R.nodeName)==="BUTTON"||(R==null?void 0:R.nodeName)==="A";r.preventDefault!==!1&&(a.current||!w)&&_.preventDefault(),s(!0)}},y=_=>{const k=Kh(_.code,h);qh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},m=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",x),p==null||p.addEventListener("keyup",y),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{p==null||p.removeEventListener("keydown",x),p==null||p.removeEventListener("keyup",y),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,s]),o}function qh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Kh(t,r){return r.includes(t)?"code":"key"}const I_=()=>{const t=Ye();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=Nc(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),v={x:r.x-h,y:r.y-p},x=o.snapGrid??a,y=o.snapToGrid??u;return gs(v,s,y,x)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=eo(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function Og(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)R_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function R_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function T_(t,r){return Og(t,r)}function L_(t,r){return Og(t,r)}function ai(t,r){return{id:t,type:"select",selected:r}}function Gi(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(ai(u.id,c)))}return s}function Qh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Zh(t){return{id:t.id,type:"remove"}}const A_=hg();function $_(t,r,o={}){return x1(t,r,{...o,onError:o.onError??A_})}const Jh=t=>i1(t),z_=t=>ag(t);function Fg(t){return L.forwardRef(t)}const Hg=typeof window<"u"?L.useLayoutEffect:L.useEffect;function ep(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>D_(()=>o(a=>a+BigInt(1))));return Hg(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function D_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Bg=L.createContext(null);function O_({children:t}){const r=Ye(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:v,hasDefaultNodes:x,onNodesChange:y,nodeLookup:m,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let j=p;for(const E of h)j=typeof E=="function"?E(j):E;let b=Qh({items:j,lookup:m});for(const E of k.values())b=E(b);x&&v(j),b.length>0?y==null||y(b):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:R,setNodes:w}=r.getState();E&&w(R)})},[]),s=ep(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:v,hasDefaultEdges:x,onEdgesChange:y,edgeLookup:m}=r.getState();let _=p;for(const k of h)_=typeof k=="function"?k(_):k;x?v(_):y&&y(Qh({items:_,lookup:m}))},[]),u=ep(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Bg.Provider,{value:c,children:t})}function F_(){const t=L.useContext(Bg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const H_=t=>!!t.panZoom;function na(){const t=I_(),r=Ye(),o=F_(),s=De(H_),a=L.useMemo(()=>{const u=y=>r.getState().nodeLookup.get(y),c=y=>{o.nodeQueue.push(y)},h=y=>{o.edgeQueue.push(y)},p=y=>{var E,R;const{nodeLookup:m,nodeOrigin:_}=r.getState(),k=Jh(y)?y:m.get(y.id),j=k.parentId?gg(k.position,k.measured,k.parentId,m,_):k.position,b={...k,position:j,width:((E=k.measured)==null?void 0:E.width)??k.width,height:((R=k.measured)==null?void 0:R.height)??k.height};return ss(b)},v=(y,m,_={replace:!1})=>{c(k=>k.map(j=>{if(j.id===y){const b=typeof m=="function"?m(j):m;return _.replace&&Jh(b)?b:{...j,...b}}return j}))},x=(y,m,_={replace:!1})=>{h(k=>k.map(j=>{if(j.id===y){const b=typeof m=="function"?m(j):m;return _.replace&&z_(b)?b:{...j,...b}}return j}))};return{getNodes:()=>r.getState().nodes.map(y=>({...y})),getNode:y=>{var m;return(m=u(y))==null?void 0:m.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:y=[]}=r.getState();return y.map(m=>({...m}))},getEdge:y=>r.getState().edgeLookup.get(y),setNodes:c,setEdges:h,addNodes:y=>{const m=Array.isArray(y)?y:[y];o.nodeQueue.push(_=>[..._,...m])},addEdges:y=>{const m=Array.isArray(y)?y:[y];o.edgeQueue.push(_=>[..._,...m])},toObject:()=>{const{nodes:y=[],edges:m=[],transform:_}=r.getState(),[k,j,b]=_;return{nodes:y.map(E=>({...E})),edges:m.map(E=>({...E})),viewport:{x:k,y:j,zoom:b}}},deleteElements:async({nodes:y=[],edges:m=[]})=>{const{nodes:_,edges:k,onNodesDelete:j,onEdgesDelete:b,triggerNodeChanges:E,triggerEdgeChanges:R,onDelete:w,onBeforeDelete:N}=r.getState(),{nodes:A,edges:$}=await u1({nodesToRemove:y,edgesToRemove:m,nodes:_,edges:k,onBeforeDelete:N}),F=$.length>0,G=A.length>0;if(F){const q=$.map(Zh);b==null||b($),R(q)}if(G){const q=A.map(Zh);j==null||j(A),E(q)}return(G||F)&&(w==null||w({nodes:A,edges:$})),{deletedNodes:A,deletedEdges:$}},getIntersectingNodes:(y,m=!0,_)=>{const k=Nh(y),j=k?y:p(y),b=_!==void 0;return j?(_||r.getState().nodes).filter(E=>{const R=r.getState().nodeLookup.get(E.id);if(R&&!k&&(E.id===y.id||!R.internals.positionAbsolute))return!1;const w=ss(b?E:R),N=Hl(w,j);return m&&N>0||N>=w.width*w.height||N>=j.width*j.height}):[]},isNodeIntersecting:(y,m,_=!0)=>{const j=Nh(y)?y:p(y);if(!j)return!1;const b=Hl(j,m);return _&&b>0||b>=m.width*m.height||b>=j.width*j.height},updateNode:v,updateNodeData:(y,m,_={replace:!1})=>{v(y,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},updateEdge:x,updateEdgeData:(y,m,_={replace:!1})=>{x(y,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},getNodesBounds:y=>{const{nodeLookup:m,nodeOrigin:_}=r.getState();return o1(y,{nodeLookup:m,nodeOrigin:_})},getHandleConnections:({type:y,id:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${y}${m?`-${m}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:y,handleId:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${y?m?`-${y}-${m}`:`-${y}`:""}`))==null?void 0:k.values())??[])},fitView:async y=>{const m=r.getState().fitViewResolver??f1();return r.setState({fitViewQueued:!0,fitViewOptions:y,fitViewResolver:m}),o.nodeQueue.push(_=>[..._]),m.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const tp=t=>t.selected,B_=typeof window<"u"?window:void 0;function V_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ye(),{deleteElements:s}=na(),a=as(t,{actInsideInputWithModifier:!1}),u=as(r,{target:B_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(tp),edges:c.filter(tp)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function W_(t){const r=Ye();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=jc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",mn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const ra={position:"absolute",width:"100%",height:"100%",top:0,left:0},U_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function Y_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=di.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:v,translateExtent:x,minZoom:y,maxZoom:m,zoomActivationKeyCode:_,preventScrolling:k=!0,children:j,noWheelClassName:b,noPanClassName:E,onViewportChange:R,isControlledViewport:w,paneClickDistance:N,selectionOnDrag:A}){const $=Ye(),F=L.useRef(null),{userSelectionActive:G,lib:q,connectionInProgress:te}=De(U_,Qe),ee=as(_),ne=L.useRef();W_(F);const K=L.useCallback(C=>{R==null||R({x:C[0],y:C[1],zoom:C[2]}),w||$.setState({transform:C})},[R,w]);return L.useEffect(()=>{if(F.current){ne.current=q1({domNode:F.current,minZoom:y,maxZoom:m,translateExtent:x,viewport:v,onDraggingChange:U=>$.setState(M=>M.paneDragging===U?M:{paneDragging:U}),onPanZoomStart:(U,M)=>{const{onViewportChangeStart:D,onMoveStart:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoom:(U,M)=>{const{onViewportChange:D,onMove:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoomEnd:(U,M)=>{const{onViewportChangeEnd:D,onMoveEnd:H}=$.getState();H==null||H(U,M),D==null||D(M)}});const{x:C,y:V,zoom:W}=ne.current.getViewport();return $.setState({panZoom:ne.current,transform:[C,V,W],domNode:F.current.closest(".react-flow")}),()=>{var U;(U=ne.current)==null||U.destroy()}}},[]),L.useEffect(()=>{var C;(C=ne.current)==null||C.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:ee,preventScrolling:k,noPanClassName:E,userSelectionActive:G,noWheelClassName:b,lib:q,onTransformChange:K,connectionInProgress:te,selectionOnDrag:A,paneClickDistance:N})},[t,r,o,s,a,u,c,h,p,ee,k,E,G,b,q,K,te,A,N]),d.jsx("div",{className:"react-flow__renderer",ref:F,style:ra,children:j})}const G_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function X_(){const{userSelectionActive:t,userSelectionRect:r}=De(G_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const qu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},q_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function K_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=is.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:v,onPaneContextMenu:x,onPaneScroll:y,onPaneMouseEnter:m,onPaneMouseMove:_,onPaneMouseLeave:k,children:j}){const b=L.useRef(0),E=Ye(),{userSelectionActive:R,elementsSelectable:w,dragging:N,panBy:A,autoPanSpeed:$}=De(q_,Qe),F=w&&(t||R),G=L.useRef(null),q=L.useRef(),te=L.useRef(new Set),ee=L.useRef(new Set),ne=L.useRef(!1),K=L.useRef(!1),C=L.useRef({x:0,y:0}),V=L.useRef(!1),W=Z=>{if(K.current||ne.current||E.getState().connection.inProgress){K.current=!1,ne.current=!1;return}v==null||v(Z),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},U=Z=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Z.preventDefault();return}x==null||x(Z)},M=y?Z=>y(Z):void 0,D=Z=>{K.current&&(Z.stopPropagation(),K.current=!1)},H=Z=>{var $e,st;if(Z.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:se,transform:me}=E.getState();if(q.current=se==null?void 0:se.getBoundingClientRect(),!q.current)return;const ke=Z.target===G.current;if(!ke&&!!Z.target.closest(".nokey")||!t||!(c&&ke||r)||Z.button!==0||!Z.isPrimary)return;(st=($e=Z.target)==null?void 0:$e.setPointerCapture)==null||st.call($e,Z.pointerId),K.current=!1;const{x:Ne,y:Me}=gn(Z.nativeEvent,q.current),Te=gs({x:Ne,y:Me},me);E.setState({userSelectionRect:{width:0,height:0,startX:Te.x,startY:Te.y,x:Ne,y:Me}}),ke||(Z.stopPropagation(),Z.preventDefault())};function I(Z,se){const{userSelectionRect:me}=E.getState();if(!me)return;const{transform:ke,nodeLookup:ve,edgeLookup:re,connectionLookup:Ne,triggerNodeChanges:Me,triggerEdgeChanges:Te,defaultEdgeOptions:$e}=E.getState(),st={x:me.startX,y:me.startY},{x:lt,y:at}=eo(st,ke),Ge={startX:st.x,startY:st.y,x:Zmt.id)),ee.current=new Set;const gt=($e==null?void 0:$e.selectable)??!0;for(const mt of te.current){const Pt=Ne.get(mt);if(Pt)for(const{edgeId:ut}of Pt.values()){const Je=re.get(ut);Je&&(Je.selectable??gt)&&ee.current.add(ut)}}if(!jh(wt,te.current)){const mt=Gi(ve,te.current,!0);Me(mt)}if(!jh(qt,ee.current)){const mt=Gi(re,ee.current);Te(mt)}E.setState({userSelectionRect:Ge,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!a||!q.current)return;const[Z,se]=kc(C.current,q.current,$);A({x:Z,y:se}).then(me=>{if(!K.current||!me){b.current=requestAnimationFrame(z);return}const{x:ke,y:ve}=C.current;I(ke,ve),b.current=requestAnimationFrame(z)})}const ie=()=>{cancelAnimationFrame(b.current),b.current=0,V.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=Z=>{const{userSelectionRect:se,transform:me,resetSelectedElements:ke}=E.getState();if(!q.current||!se)return;const{x:ve,y:re}=gn(Z.nativeEvent,q.current);C.current={x:ve,y:re};const Ne=eo({x:se.startX,y:se.startY},me);if(!K.current){const Me=r?0:u;if(Math.hypot(ve-Ne.x,re-Ne.y)<=Me)return;ke(),h==null||h(Z)}K.current=!0,V.current||(z(),V.current=!0),I(ve,re)},fe=Z=>{var se,me;if(!F){Z.target===G.current&&E.getState().connection.inProgress&&(ne.current=!0);return}Z.button===0&&((me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),!R&&Z.target===G.current&&E.getState().userSelectionRect&&(W==null||W(Z)),E.setState({userSelectionActive:!1,userSelectionRect:null}),K.current&&(p==null||p(Z),E.setState({nodesSelectionActive:te.current.size>0})),ie())},he=Z=>{var se,me;(me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),ie()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:nt(["react-flow__pane",{draggable:pe,dragging:N,selection:t}]),onClick:F?void 0:qu(W,G),onContextMenu:qu(U,G),onWheel:qu(M,G),onPointerEnter:F?void 0:m,onPointerMove:F?oe:_,onPointerUp:fe,onPointerCancel:F?he:void 0,onPointerDownCapture:F?H:void 0,onClickCapture:F?D:void 0,onPointerLeave:k,ref:G,style:ra,children:[j,d.jsx(X_,{})]})}function hc({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),v=h.get(t);if(!v){p==null||p("012",mn.error012(t));return}r.setState({nodesSelectionActive:!1}),v.selected?(o||v.selected&&c)&&(u({nodes:[v],edges:[]}),requestAnimationFrame(()=>{var x;return(x=s==null?void 0:s.current)==null?void 0:x.blur()})):a([t])}function Vg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ye(),[p,v]=L.useState(!1),x=L.useRef();return L.useEffect(()=>{if(!r)return x.current=A1({getStoreItems:()=>h.getState(),onNodeMouseDown:y=>{hc({id:y,store:h,nodeRef:t})},onDragStart:()=>{v(!0)},onDragStop:()=>{v(!1)}}),()=>{var y;(y=x.current)==null||y.destroy(),x.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!x.current||x.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const Q_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Wg(){const t=Ye();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:v,nodeOrigin:x}=t.getState(),y=new Map,m=Q_(c),_=a?u[0]:5,k=a?u[1]:5,j=o.direction.x*_*o.factor,b=o.direction.y*k*o.factor;for(const[,E]of v){if(!m(E))continue;let R={x:E.internals.positionAbsolute.x+j,y:E.internals.positionAbsolute.y+b};a&&(R=ps(R,u));const{position:w,positionAbsolute:N}=ug({nodeId:E.id,nextPosition:R,nodeLookup:v,nodeExtent:s,nodeOrigin:x,onError:h});E.position=w,E.internals.positionAbsolute=N,y.set(E.id,E)}p(y)},[])}const Ic=L.createContext(null),Z_=Ic.Provider;Ic.Consumer;const Ug=()=>L.useContext(Ic),J_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Yg=L.createContext(null);function eS({children:t}){const r=De(J_,Qe);return d.jsx(Yg.Provider,{value:r,children:t})}function tS(){const t=L.useContext(Yg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const nS={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},rS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:v}=c;if(!h&&!a)return nS;const x=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:x,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Zi.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:x&&v}};function iS({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:v,onMouseDown:x,onTouchStart:y,...m},_){var V,W;const k=c||null,j=t==="target",b=Ye(),E=Ug(),{connectOnClick:R,noPanClassName:w,rfId:N}=tS(),{connectingFrom:A,connectingTo:$,clickConnecting:F,isPossibleEndHandle:G,connectionInProcess:q,clickConnectionInProcess:te,valid:ee}=De(rS(E,k,t),Qe);E||(W=(V=b.getState()).onError)==null||W.call(V,"010",mn.error010());const ne=U=>{const{defaultEdgeOptions:M,onConnect:D,hasDefaultEdges:H}=b.getState(),I={...M,...U};if(H){const{edges:z,setEdges:ie,onError:oe}=b.getState();ie($_(I,z,{onError:oe}))}D==null||D(I),h==null||h(I)},K=U=>{if(!E)return;const M=vg(U.nativeEvent);if(a&&(M&&U.button===0||!M)){const D=b.getState();fc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:j,handleId:k,nodeId:E,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...H)=>{var I,z;return(z=(I=b.getState()).onConnectEnd)==null?void 0:z.call(I,...H)},updateConnection:D.updateConnection,onConnect:ne,isValidConnection:o||((...H)=>{var I,z;return((z=(I=b.getState()).isValidConnection)==null?void 0:z.call(I,...H))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}M?x==null||x(U):y==null||y(U)},C=U=>{const{onClickConnectStart:M,onClickConnectEnd:D,connectionClickStartHandle:H,connectionMode:I,isValidConnection:z,lib:ie,rfId:oe,nodeLookup:fe,connection:he}=b.getState();if(!E||!H&&!a)return;if(!H){M==null||M(U.nativeEvent,{nodeId:E,handleId:k,handleType:t}),b.setState({connectionClickStartHandle:{nodeId:E,type:t,id:k}});return}const pe=mg(U.target),Z=o||z,{connection:se,isValid:me}=fc.isValid(U.nativeEvent,{handle:{nodeId:E,id:k,type:t},connectionMode:I,fromNodeId:H.nodeId,fromHandleId:H.id||null,fromType:H.type,isValidConnection:Z,flowId:oe,doc:pe,lib:ie,nodeLookup:fe});me&&se&&ne(se);const ke=structuredClone(he);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,D==null||D(U,ke),b.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":k,"data-nodeid":E,"data-handlepos":r,"data-id":`${N}-${E}-${k}-${t}`,className:nt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",w,v,{source:!j,target:j,connectable:s,connectablestart:a,connectableend:u,clickconnecting:F,connectingfrom:A,connectingto:$,valid:ee,connectionindicator:s&&(!q||G)&&(q||te?u:a)}]),onMouseDown:K,onTouchStart:K,onClick:R?C:void 0,ref:_,...m,children:p})}const no=L.memo(Fg(iS));function oS({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(no,{type:"source",position:o,isConnectable:r})]})}function sS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:s=Se.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(no,{type:"source",position:s,isConnectable:r})]})}function lS(){return null}function aS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const Vl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},np={input:oS,default:sS,output:aS,group:lS};function uS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const cS=t=>{const{width:r,height:o,x:s,y:a}=hs(t.nodeLookup,{filter:u=>!!u.selected});return{width:pn(r)?r:null,height:pn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function dS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ye(),{width:a,height:u,transformString:c,userSelectionActive:h}=De(cS,Qe),p=Wg(),v=L.useRef(null);L.useEffect(()=>{var _;o||(_=v.current)==null||_.focus({preventScroll:!0})},[o]);const x=!h&&a!==null&&u!==null;if(Vg({nodeRef:v,disabled:!x}),!x)return null;const y=t?_=>{const k=s.getState().nodes.filter(j=>j.selected);t(_,k)}:void 0,m=_=>{Object.prototype.hasOwnProperty.call(Vl,_.key)&&(_.preventDefault(),p({direction:Vl[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:nt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:v,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:o?void 0:-1,onKeyDown:o?void 0:m,style:{width:a,height:u}})})}const rp=typeof window<"u"?window:void 0,fS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Gg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:v,selectionOnDrag:x,selectionMode:y,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:j,zoomActivationKeyCode:b,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:N,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:G,autoPanOnSelection:q,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,preventScrolling:C,onSelectionContextMenu:V,noWheelClassName:W,noPanClassName:U,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:H}){const{nodesSelectionActive:I,userSelectionActive:z}=De(fS,Qe),ie=as(v,{target:rp}),oe=as(j,{target:rp}),fe=oe||G,he=oe||N,pe=x&&fe!==!0,Z=ie||z||pe;return V_({deleteKeyCode:p,multiSelectionKeyCode:k}),d.jsx(Y_,{onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:!ie&&fe,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,zoomActivationKeyCode:b,preventScrolling:C,noWheelClassName:W,noPanClassName:U,onViewportChange:D,isControlledViewport:H,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(K_,{onSelectionStart:m,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:q,isSelecting:!!Z,selectionMode:y,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:pe,children:[t,I&&d.jsx(dS,{onSelectionContextMenu:V,noPanClassName:U,disableKeyboardA11y:M})]})})}Gg.displayName="FlowRenderer";const hS=L.memo(Gg),pS=t=>r=>t?Sc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function gS(t){return De(L.useCallback(pS(t),[t]),Qe)}const mS=t=>t.updateNodeInternals;function yS(){const t=De(mS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function vS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ye(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),v=L.useRef(r),x=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!x||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[x,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const y=v.current!==r,m=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(y||m||_)&&(v.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function xS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:v,nodesFocusable:x,resizeObserver:y,noDragClassName:m,noPanClassName:_,disableKeyboardA11y:k,rfId:j,nodeTypes:b,nodeClickDistance:E,onError:R}){const{node:w,internals:N,isParent:A}=De(Z=>{const se=Z.nodeLookup.get(t),me=Z.parentLookup.has(t);return{node:se,internals:se.internals,isParent:me}},Qe);let $=w.type||"default",F=(b==null?void 0:b[$])||np[$];F===void 0&&(R==null||R("003",mn.error003($)),$="default",F=(b==null?void 0:b.default)||np.default);const G=!!(w.draggable||h&&typeof w.draggable>"u"),q=!!(w.selectable||p&&typeof w.selectable>"u"),te=!!(w.connectable||v&&typeof w.connectable>"u"),ee=!!(w.focusable||x&&typeof w.focusable>"u"),ne=Ye(),K=pg(w),C=vS({node:w,nodeType:$,hasDimensions:K,resizeObserver:y}),V=Vg({nodeRef:C,disabled:w.hidden||!G,noDragClassName:m,handleSelector:w.dragHandle,nodeId:t,isSelectable:q,nodeClickDistance:E}),W=Wg();if(w.hidden)return null;const U=vn(w),M=uS(w),D=q||G||r||o||s||a,H=o?Z=>o(Z,{...N.userNode}):void 0,I=s?Z=>s(Z,{...N.userNode}):void 0,z=a?Z=>a(Z,{...N.userNode}):void 0,ie=u?Z=>u(Z,{...N.userNode}):void 0,oe=c?Z=>c(Z,{...N.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:se,nodeDragThreshold:me}=ne.getState();q&&(!se||!G||me>0)&&hc({id:t,store:ne,nodeRef:C}),r&&r(Z,{...N.userNode})},he=Z=>{if(!(yg(Z.nativeEvent)||k)){if(ig.includes(Z.key)&&q){const se=Z.key==="Escape";hc({id:t,store:ne,unselect:se,nodeRef:C})}else if(G&&w.selected&&Object.prototype.hasOwnProperty.call(Vl,Z.key)){Z.preventDefault();const{ariaLabelConfig:se}=ne.getState();ne.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),W({direction:Vl[Z.key],factor:Z.shiftKey?4:1})}}},pe=()=>{var Ne;if(k||!((Ne=C.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:Z,width:se,height:me,autoPanOnNodeFocus:ke,setCenter:ve}=ne.getState();if(!ke)return;Sc(new Map([[t,w]]),{x:0,y:0,width:se,height:me},Z,!0).length>0||ve(w.position.x+U.width/2,w.position.y+U.height/2,{zoom:Z[2]})};return d.jsx("div",{className:nt(["react-flow__node",`react-flow__node-${$}`,{[_]:G},w.className,{selected:w.selected,selectable:q,parent:A,draggable:G,dragging:V}]),ref:C,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:K?"visible":"hidden",...w.style,...M},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:H,onMouseMove:I,onMouseLeave:z,onContextMenu:ie,onClick:fe,onDoubleClick:oe,onKeyDown:ee?he:void 0,tabIndex:ee?0:void 0,onFocus:ee?pe:void 0,role:w.ariaRole??(ee?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${$g}-${j}`,"aria-label":w.ariaLabel,...w.domAttributes,children:d.jsx(Z_,{value:t,children:d.jsx(F,{id:t,data:w.data,type:$,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:w.selected??!1,selectable:q,draggable:G,deletable:w.deletable??!0,isConnectable:te,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:V,dragHandle:w.dragHandle,zIndex:N.z,parentId:w.parentId,...U})})})}var wS=L.memo(xS);const _S=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Xg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=De(_S,Qe),u=gS(t.onlyRenderVisibleElements),c=yS();return d.jsx("div",{className:"react-flow__nodes",style:ra,children:u.map(h=>d.jsx(wS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Xg.displayName="NodeRenderer";const SS=L.memo(Xg);function kS(t){return De(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&m1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const NS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},jS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ip={[os.Arrow]:NS,[os.ArrowClosed]:jS};function bS(t){const r=Ye();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(ip,t)?ip[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",mn.error009(t)),null)},[t])}const ES=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=bS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},qg=({defaultColor:t,rfId:r})=>{const o=De(u=>u.edges),s=De(u=>u.defaultEdgeOptions),a=L.useMemo(()=>N1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(ES,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};qg.displayName="MarkerDefinitions";var CS=L.memo(qg);function Kg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:v,...x}){const[y,m]=L.useState({x:1,y:0,width:0,height:0}),_=nt(["react-flow__edge-textwrapper",v]),k=L.useRef(null);return L.useEffect(()=>{if(k.current){const j=k.current.getBBox();m({x:j.x,y:j.y,width:j.width,height:j.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-y.width/2} ${r-y.height/2})`,className:_,visibility:y.width?"visible":"hidden",...x,children:[a&&d.jsx("rect",{width:y.width+2*c[0],x:-c[0],y:-c[1],height:y.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:k,style:s,children:o}),p]}):null}Kg.displayName="EdgeText";const MS=L.memo(Kg);function ms({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:v=20,...x}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...x,d:t,fill:"none",className:nt(["react-flow__edge-path",x.className])}),v?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:v,className:"react-flow__edge-interaction"}):null,s&&pn(r)&&pn(o)?d.jsx(MS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function op({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function Qg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top}){const[c,h]=op({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,v]=op({pos:u,x1:s,y1:a,x2:t,y2:r}),[x,y,m,_]=xg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:v});return[`M${t},${r} C${c},${h} ${p},${v} ${s},${a}`,x,y,m,_]}function Zg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})=>{const[R,w,N]=Qg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),A=t.isInternal?void 0:r;return d.jsx(ms,{id:A,path:R,labelX:w,labelY:N,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})})}const PS=Zg({isInternal:!1}),Jg=Zg({isInternal:!0});PS.displayName="SimpleBezierEdge";Jg.displayName="SimpleBezierEdgeInternal";function em(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,sourcePosition:_=Se.Bottom,targetPosition:k=Se.Top,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=Bl({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),$=t.isInternal?void 0:r;return d.jsx(ms,{id:$,path:w,labelX:N,labelY:A,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:j,markerStart:b,interactionWidth:R})})}const tm=em({isInternal:!1}),nm=em({isInternal:!0});tm.displayName="SmoothStepEdge";nm.displayName="SmoothStepEdgeInternal";function rm(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(tm,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const IS=rm({isInternal:!1}),im=rm({isInternal:!0});IS.displayName="StepEdge";im.displayName="StepEdgeInternal";function om(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:j})=>{const[b,E,R]=Sg({sourceX:o,sourceY:s,targetX:a,targetY:u}),w=t.isInternal?void 0:r;return d.jsx(ms,{id:w,path:b,labelX:E,labelY:R,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:j})})}const RS=om({isInternal:!1}),sm=om({isInternal:!0});RS.displayName="StraightEdge";sm.displayName="StraightEdgeInternal";function lm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=wg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:E==null?void 0:E.curvature}),$=t.isInternal?void 0:r;return d.jsx(ms,{id:$,path:w,labelX:N,labelY:A,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:R})})}const TS=lm({isInternal:!1}),am=lm({isInternal:!0});TS.displayName="BezierEdge";am.displayName="BezierEdgeInternal";const sp={default:am,straight:sm,step:im,smoothstep:nm,simplebezier:Jg},lp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},LS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,AS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,ap="react-flow__edgeupdater";function up({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:nt([ap,`${ap}-${h}`]),cx:LS(r,s,t),cy:AS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function $S({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:v,onReconnectStart:x,onReconnectEnd:y,setReconnecting:m,setUpdateHover:_}){const k=Ye(),j=(N,A)=>{if(N.button!==0)return;const{autoPanOnConnect:$,domNode:F,connectionMode:G,connectionRadius:q,lib:te,onConnectStart:ee,cancelConnection:ne,nodeLookup:K,rfId:C,panBy:V,updateConnection:W}=k.getState(),U=A.type==="target",M=(I,z)=>{m(!1),y==null||y(I,o,A.type,z)},D=I=>v==null?void 0:v(o,I),H=(I,z)=>{m(!0),x==null||x(N,o,A.type),ee==null||ee(I,z)};fc.onPointerDown(N.nativeEvent,{autoPanOnConnect:$,connectionMode:G,connectionRadius:q,domNode:F,handleId:A.id,nodeId:A.nodeId,nodeLookup:K,isTarget:U,edgeUpdaterType:A.type,lib:te,flowId:C,cancelConnection:ne,panBy:V,isValidConnection:(...I)=>{var z,ie;return((ie=(z=k.getState()).isValidConnection)==null?void 0:ie.call(z,...I))??!0},onConnect:D,onConnectStart:H,onConnectEnd:(...I)=>{var z,ie;return(ie=(z=k.getState()).onConnectEnd)==null?void 0:ie.call(z,...I)},onReconnectEnd:M,updateConnection:W,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:N.currentTarget})},b=N=>j(N,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),E=N=>j(N,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),R=()=>_(!0),w=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(up,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:b,onMouseEnter:R,onMouseOut:w,type:"source"}),(t===!0||t==="target")&&d.jsx(up,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:E,onMouseEnter:R,onMouseOut:w,type:"target"})]})}function zS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,rfId:k,edgeTypes:j,noPanClassName:b,onError:E,disableKeyboardA11y:R}){let w=De(ve=>ve.edgeLookup.get(t));const N=De(ve=>ve.defaultEdgeOptions);w=N?{...N,...w}:w;let A=w.type||"default",$=(j==null?void 0:j[A])||sp[A];$===void 0&&(E==null||E("011",mn.error011(A)),A="default",$=(j==null?void 0:j.default)||sp.default);const F=!!(w.focusable||r&&typeof w.focusable>"u"),G=typeof y<"u"&&(w.reconnectable||o&&typeof w.reconnectable>"u"),q=!!(w.selectable||s&&typeof w.selectable>"u"),te=L.useRef(null),[ee,ne]=L.useState(!1),[K,C]=L.useState(!1),V=Ye(),{zIndex:W=w.zIndex,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z}=De(L.useCallback(ve=>{const re=ve.nodeLookup.get(w.source),Ne=ve.nodeLookup.get(w.target);if(!re||!Ne)return lp;const Me=k1({id:t,sourceNode:re,targetNode:Ne,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:ve.connectionMode,onError:E}),Te=g1({selected:w.selected,zIndex:w.zIndex,sourceNode:re,targetNode:Ne,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||lp,zIndex:Te}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex,E]),Qe),ie=L.useMemo(()=>w.markerStart?`url('#${cc(w.markerStart,k)}')`:void 0,[w.markerStart,k]),oe=L.useMemo(()=>w.markerEnd?`url('#${cc(w.markerEnd,k)}')`:void 0,[w.markerEnd,k]);if(w.hidden||U===null||M===null||D===null||H===null)return null;const fe=ve=>{var Te;const{addSelectedEdges:re,unselectNodesAndEdges:Ne,multiSelectionActive:Me}=V.getState();q&&(V.setState({nodesSelectionActive:!1}),w.selected&&Me?(Ne({nodes:[],edges:[w]}),(Te=te.current)==null||Te.blur()):re([t])),a&&a(ve,w)},he=u?ve=>{u(ve,{...w})}:void 0,pe=c?ve=>{c(ve,{...w})}:void 0,Z=h?ve=>{h(ve,{...w})}:void 0,se=p?ve=>{p(ve,{...w})}:void 0,me=v?ve=>{v(ve,{...w})}:void 0,ke=ve=>{var re;if(!R&&ig.includes(ve.key)&&q){const{unselectNodesAndEdges:Ne,addSelectedEdges:Me}=V.getState();ve.key==="Escape"?((re=te.current)==null||re.blur(),Ne({edges:[w]})):Me([t])}};return d.jsx("svg",{style:{zIndex:W},children:d.jsxs("g",{className:nt(["react-flow__edge",`react-flow__edge-${A}`,w.className,b,{selected:w.selected,animated:w.animated,inactive:!q&&!a,updating:ee,selectable:q}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:Z,onMouseMove:se,onMouseLeave:me,onKeyDown:F?ke:void 0,tabIndex:F?0:void 0,role:w.ariaRole??(F?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":F?`${zg}-${k}`:void 0,ref:te,...w.domAttributes,children:[!K&&d.jsx($,{id:t,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:q,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),G&&d.jsx($S,{edge:w,isReconnectable:G,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,setUpdateHover:ne,setReconnecting:C})]})})}var DS=L.memo(zS);const OS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function um({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:v,onEdgeClick:x,reconnectRadius:y,onEdgeDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:j}){const{edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,onError:w}=De(OS,Qe),N=kS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(CS,{defaultColor:t,rfId:o}),N.map(A=>d.jsx(DS,{id:A,edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,onClick:x,reconnectRadius:y,onDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:w,edgeTypes:s,disableKeyboardA11y:j},A))]})}um.displayName="EdgeRenderer";const FS=L.memo(um),cp=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function HS({children:t}){const r=Ye(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return Hg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=cp(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:cp(s)},children:t})}function BS(t){const r=na(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const VS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function WS(t){const r=De(VS),o=Ye();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function US(t){return t.connection.inProgress?{...t.connection,to:gs(t.connection.to,t.transform)}:{...t.connection}}function YS(t){return US}function GS(t){const r=YS();return De(r,Qe)}const XS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function qS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=De(XS,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:nt(["react-flow__connection",lg(h)]),children:d.jsx(cm,{style:r,type:o,CustomComponent:s,isValid:h})})})}const cm=({style:t,type:r=Lr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:v,toNode:x,toHandle:y,toPosition:m,pointer:_}=GS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:v.x,toY:v.y,fromPosition:p,toPosition:m,connectionStatus:lg(s),toNode:x,toHandle:y,pointer:_});let k="";const j={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:v.x,targetY:v.y,targetPosition:m};switch(r){case Lr.Bezier:[k]=wg(j);break;case Lr.SimpleBezier:[k]=Qg(j);break;case Lr.Step:[k]=Bl({...j,borderRadius:0});break;case Lr.SmoothStep:[k]=Bl(j);break;default:[k]=Sg(j)}return d.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};cm.displayName="ConnectionLine";const KS={};function dp(t=KS){L.useRef(t),Ye(),L.useEffect(()=>{},[t])}function QS(){Ye(),L.useRef(!1),L.useEffect(()=>{},[])}function dm({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,onSelectionContextMenu:y,onSelectionStart:m,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:j,connectionLineComponent:b,connectionLineContainerStyle:E,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,deleteKeyCode:G,onlyRenderVisibleElements:q,elementsSelectable:te,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,preventScrolling:V,defaultMarkerColor:W,zoomOnScroll:U,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,zoomOnDoubleClick:z,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneScroll:se,onPaneContextMenu:me,paneClickDistance:ke,nodeClickDistance:ve,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,viewport:ut,onViewportChange:Je,nodesDraggable:An}){return dp(t),dp(r),QS(),BS(o),WS(ut),d.jsx(hS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneContextMenu:me,onPaneScroll:se,paneClickDistance:ke,deleteKeyCode:G,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,elementsSelectable:te,zoomOnScroll:U,zoomOnPinch:M,zoomOnDoubleClick:z,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,onSelectionContextMenu:y,preventScrolling:V,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,onViewportChange:Je,isControlledViewport:!!ut,children:d.jsxs(HS,{children:[d.jsx(FS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,onlyRenderVisibleElements:q,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,defaultMarkerColor:W,noPanClassName:qt,disableKeyboardA11y:gt,rfId:Pt}),d.jsx(qS,{style:j,type:k,component:b,containerStyle:E}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(SS,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,nodeClickDistance:ve,onlyRenderVisibleElements:q,noPanClassName:qt,noDragClassName:Ge,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,nodesDraggable:An}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}dm.displayName="GraphView";const ZS=L.memo(dm),JS=hg(),fp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:v=2,nodeOrigin:x,nodeExtent:y,zIndexMode:m="basic"}={})=>{const _=new Map,k=new Map,j=new Map,b=new Map,E=s??r??[],R=o??t??[],w=x??[0,0],N=y??rs;jg(j,b,E);const{nodesInitialized:A}=dc(R,_,k,{nodeOrigin:w,nodeExtent:N,zIndexMode:m});let $=[0,0,1];if(c&&a&&u){const F=hs(_,{filter:ee=>!!((ee.width||ee.initialWidth)&&(ee.height||ee.initialHeight))}),{x:G,y:q,zoom:te}=Nc(F,a,u,p,v,(h==null?void 0:h.padding)??.1);$=[G,q,te]}return{rfId:"1",width:a??0,height:u??0,transform:$,nodes:R,nodesInitialized:A,nodeLookup:_,parentLookup:k,edges:E,edgeLookup:b,connectionLookup:j,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:v,translateExtent:rs,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Zi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...sg},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:JS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:og,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},ek=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m})=>f_((_,k)=>{async function j(){const{nodeLookup:b,panZoom:E,fitViewOptions:R,fitViewResolver:w,width:N,height:A,minZoom:$,maxZoom:F}=k();E&&(await a1({nodes:b,width:N,height:A,panZoom:E,minZoom:$,maxZoom:F},R),w==null||w.resolve(!0),_({fitViewResolver:null}))}return{...fp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,defaultNodes:o,defaultEdges:s,zIndexMode:m}),setNodes:b=>{const{nodeLookup:E,parentLookup:R,nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,fitViewQueued:$,zIndexMode:F,nodesSelectionActive:G}=k(),{nodesInitialized:q,hasSelectedNodes:te}=dc(b,E,R,{nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:F}),ee=G&&te;$&&q?(j(),_({nodes:b,nodesInitialized:q,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:ee})):_({nodes:b,nodesInitialized:q,nodesSelectionActive:ee})},setEdges:b=>{const{connectionLookup:E,edgeLookup:R}=k();jg(E,R,b),_({edges:b})},setDefaultNodesAndEdges:(b,E)=>{if(b){const{setNodes:R}=k();R(b),_({hasDefaultNodes:!0})}if(E){const{setEdges:R}=k();R(E),_({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:E,nodeLookup:R,parentLookup:w,domNode:N,nodeOrigin:A,nodeExtent:$,debug:F,fitViewQueued:G,zIndexMode:q}=k(),{changes:te,updatedInternals:ee}=I1(b,R,w,N,A,$,q);ee&&(E1(R,w,{nodeOrigin:A,nodeExtent:$,zIndexMode:q}),G?(j(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(te==null?void 0:te.length)>0&&(F&&console.log("React Flow: trigger node changes",te),E==null||E(te)))},updateNodePositions:(b,E=!1)=>{const R=[];let w=[];const{nodeLookup:N,triggerNodeChanges:A,connection:$,updateConnection:F,onNodesChangeMiddlewareMap:G}=k();for(const[q,te]of b){const ee=N.get(q),ne=!!(ee!=null&&ee.expandParent&&(ee!=null&&ee.parentId)&&(te!=null&&te.position)),K={id:q,type:"position",position:ne?{x:Math.max(0,te.position.x),y:Math.max(0,te.position.y)}:te.position,dragging:E};if(ee&&$.inProgress&&$.fromNode.id===ee.id){const C=mi(ee,$.fromHandle,Se.Left,!0);F({...$,from:C})}ne&&ee.parentId&&R.push({id:q,parentId:ee.parentId,rect:{...te.internals.positionAbsolute,width:te.measured.width??0,height:te.measured.height??0}}),w.push(K)}if(R.length>0){const{parentLookup:q,nodeOrigin:te}=k(),ee=Pc(R,N,q,te);w.push(...ee)}for(const q of G.values())w=q(w);A(w)},triggerNodeChanges:b=>{const{onNodesChange:E,setNodes:R,nodes:w,hasDefaultNodes:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=T_(b,w);R($)}A&&console.log("React Flow: trigger node changes",b),E==null||E(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:E,setEdges:R,edges:w,hasDefaultEdges:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=L_(b,w);R($)}A&&console.log("React Flow: trigger edge changes",b),E==null||E(b)}},addSelectedNodes:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));N($);return}N(Gi(w,new Set([...b]),!0)),A(Gi(R))},addSelectedEdges:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));A($);return}A(Gi(R,new Set([...b]))),N(Gi(w,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:E}={})=>{const{edges:R,nodes:w,nodeLookup:N,triggerNodeChanges:A,triggerEdgeChanges:$}=k(),F=b||w,G=E||R,q=[];for(const ee of F){if(!ee.selected)continue;const ne=N.get(ee.id);ne&&(ne.selected=!1),q.push(ai(ee.id,!1))}const te=[];for(const ee of G)ee.selected&&te.push(ai(ee.id,!1));A(q),$(te)},setMinZoom:b=>{const{panZoom:E,maxZoom:R}=k();E==null||E.setScaleExtent([b,R]),_({minZoom:b})},setMaxZoom:b=>{const{panZoom:E,minZoom:R}=k();E==null||E.setScaleExtent([R,b]),_({maxZoom:b})},setTranslateExtent:b=>{var E;(E=k().panZoom)==null||E.setTranslateExtent(b),_({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:E,triggerNodeChanges:R,triggerEdgeChanges:w,elementsSelectable:N}=k();if(!N)return;const A=E.reduce((F,G)=>G.selected?[...F,ai(G.id,!1)]:F,[]),$=b.reduce((F,G)=>G.selected?[...F,ai(G.id,!1)]:F,[]);R(A),w($)},setNodeExtent:b=>{const{nodes:E,nodeLookup:R,parentLookup:w,nodeOrigin:N,elevateNodesOnSelect:A,nodeExtent:$,zIndexMode:F}=k();b[0][0]===$[0][0]&&b[0][1]===$[0][1]&&b[1][0]===$[1][0]&&b[1][1]===$[1][1]||(dc(E,R,w,{nodeOrigin:N,nodeExtent:b,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:F}),_({nodeExtent:b}))},panBy:b=>{const{transform:E,width:R,height:w,panZoom:N,translateExtent:A}=k();return R1({delta:b,panZoom:N,transform:E,translateExtent:A,width:R,height:w})},setCenter:async(b,E,R)=>{const{width:w,height:N,maxZoom:A,panZoom:$}=k();if(!$)return!1;const F=typeof(R==null?void 0:R.zoom)<"u"?R.zoom:A;return await $.setViewport({x:w/2-b*F,y:N/2-E*F,zoom:F},{duration:R==null?void 0:R.duration,ease:R==null?void 0:R.ease,interpolate:R==null?void 0:R.interpolate}),!0},cancelConnection:()=>{_({connection:{...sg}})},updateConnection:b=>{_({connection:b})},reset:()=>_({...fp()})}},Object.is);function fm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m,children:_}){const[k]=L.useState(()=>ek({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:v,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:x,nodeExtent:y,zIndexMode:m}));return d.jsx(h_,{value:k,children:d.jsx(O_,{children:d.jsx(eS,{children:_})})})}function tk({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:v,maxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_}){return L.useContext(ea)?d.jsx(d.Fragment,{children:t}):d.jsx(fm,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:v,initialMaxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_,children:t})}const nk={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function rk({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:v,onMove:x,onMoveStart:y,onMoveEnd:m,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,onNodeDragStart:F,onNodeDrag:G,onNodeDragStop:q,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onSelectionChange:K,onSelectionDragStart:C,onSelectionDrag:V,onSelectionDragStop:W,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:H,connectionMode:I,connectionLineType:z=Lr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:Z=!1,selectionMode:se=is.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:ke=ls()?"Meta":"Control",zoomActivationKeyCode:ve=ls()?"Meta":"Control",snapToGrid:re,snapGrid:Ne,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Te,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,nodeOrigin:Ge=Dg,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt=!0,defaultViewport:mt=b_,minZoom:Pt=.5,maxZoom:ut=2,translateExtent:Je=rs,preventScrolling:An=!0,nodeExtent:Ot,defaultMarkerColor:xn="#b1b1b7",zoomOnScroll:oo=!0,zoomOnPinch:$n=!0,panOnScroll:vi=!1,panOnScrollSpeed:or=.5,panOnScrollMode:$r=di.Free,zoomOnDoubleClick:zn=!0,panOnDrag:zr=!0,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn=1,nodeClickDistance:Fn=0,children:_n,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn=10,onNodesChange:Ht,onEdgesChange:Or,noDragClassName:nn="nodrag",noWheelClassName:Fr="nowheel",noPanClassName:yt="nopan",fitView:Hn,fitViewOptions:ur,connectOnClick:so,attributionPosition:It,proOptions:Bn,defaultEdgeOptions:Hr,elevateNodesOnSelect:jn=!0,elevateEdgesOnSelect:Br=!1,disableKeyboardA11y:xi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:lo,autoPanOnSelection:Vr=!0,autoPanSpeed:wi,connectionRadius:cr,isValidConnection:ao,onError:dr,style:Vn,id:bt,nodeDragThreshold:Wr,connectionDragThreshold:Et,viewport:uo,onViewportChange:Ur,width:Yr,height:Wn,colorMode:Un="light",debug:bn,onScroll:Bt,ariaLabelConfig:_i,zIndexMode:Gr="basic",...fr},hr){const Yn=bt||"1",En=P_(Un),co=L.useCallback(pr=>{pr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Bt==null||Bt(pr)},[Bt]);return d.jsx("div",{"data-testid":"rf__wrapper",...fr,onScroll:co,style:{...Vn,...nk},ref:hr,className:nt(["react-flow",a,En]),id:bt,role:"application",children:d.jsxs(tk,{nodes:t,edges:r,width:Yr,height:Wn,fitView:Hn,fitViewOptions:ur,minZoom:Pt,maxZoom:ut,nodeOrigin:Ge,nodeExtent:Ot,zIndexMode:Gr,children:[d.jsx(M_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt,elevateNodesOnSelect:jn,elevateEdgesOnSelect:Br,minZoom:Pt,maxZoom:ut,nodeExtent:Ot,onNodesChange:Ht,onEdgesChange:Or,snapToGrid:re,snapGrid:Ne,connectionMode:I,translateExtent:Je,connectOnClick:so,defaultEdgeOptions:Hr,fitView:Hn,fitViewOptions:ur,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onNodeDragStart:F,onNodeDrag:G,onNodeDragStop:q,onSelectionDrag:V,onSelectionDragStart:C,onSelectionDragStop:W,onMove:x,onMoveStart:y,onMoveEnd:m,noPanClassName:yt,nodeOrigin:Ge,rfId:Yn,autoPanOnConnect:Ve,autoPanOnNodeDrag:lo,autoPanSpeed:wi,onError:dr,connectionRadius:cr,isValidConnection:ao,selectNodesOnDrag:Te,nodeDragThreshold:Wr,connectionDragThreshold:Et,onBeforeDelete:H,debug:bn,ariaLabelConfig:_i,zIndexMode:Gr}),d.jsx(ZS,{onInit:v,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,nodeTypes:u,edgeTypes:c,connectionLineType:z,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:Z,selectionMode:se,deleteKeyCode:he,multiSelectionKeyCode:ke,panActivationKeyCode:me,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:mt,translateExtent:Je,minZoom:Pt,maxZoom:ut,preventScrolling:An,zoomOnScroll:oo,zoomOnPinch:$n,zoomOnDoubleClick:zn,panOnScroll:vi,panOnScrollSpeed:or,panOnScrollMode:$r,panOnDrag:zr,autoPanOnSelection:Vr,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn,nodeClickDistance:Fn,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn,defaultMarkerColor:xn,noDragClassName:nn,noWheelClassName:Fr,noPanClassName:yt,rfId:Yn,disableKeyboardA11y:xi,nodeExtent:Ot,viewport:uo,onViewportChange:Ur,nodesDraggable:$e}),d.jsx(j_,{onSelectionChange:K}),_n,d.jsx(w_,{proOptions:Bn,position:It}),d.jsx(x_,{rfId:Yn,disableKeyboardA11y:xi})]})})}var ik=Fg(rk);function ok({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:nt(["react-flow__background-pattern",o,s])})}function sk({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:nt(["react-flow__background-pattern","dots",r])})}var Ar;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Ar||(Ar={}));const lk={[Ar.Dots]:1,[Ar.Lines]:1,[Ar.Cross]:6},ak=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function hm({id:t,variant:r=Ar.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:v,patternClassName:x}){const y=L.useRef(null),{transform:m,patternId:_}=De(ak,Qe),k=s||lk[r],j=r===Ar.Dots,b=r===Ar.Cross,E=Array.isArray(o)?o:[o,o],R=[E[0]*m[2]||1,E[1]*m[2]||1],w=k*m[2],N=Array.isArray(u)?u:[u,u],A=b?[w,w]:R,$=[N[0]*m[2]+A[0]/2,N[1]*m[2]+A[1]/2],F=`${_}${t||""}`;return d.jsxs("svg",{className:nt(["react-flow__background",v]),style:{...p,...ra,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:y,"data-testid":"rf__background",children:[d.jsx("pattern",{id:F,x:m[0]%R[0],y:m[1]%R[1],width:R[0],height:R[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:j?d.jsx(sk,{radius:w/2,className:x}):d.jsx(ok,{dimensions:A,lineWidth:a,variant:r,className:x})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${F})`})]})}hm.displayName="Background";const uk=L.memo(hm);function ck(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function fk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 hk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 pk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 jl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:nt(["react-flow__controls-button",r]),...o,children:t})}const gk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function pm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:v,children:x,position:y="bottom-left",orientation:m="vertical","aria-label":_}){const k=Ye(),{isInteractive:j,minZoomReached:b,maxZoomReached:E,ariaLabelConfig:R}=De(gk,Qe),{zoomIn:w,zoomOut:N,fitView:A}=na(),$=()=>{w(),u==null||u()},F=()=>{N(),c==null||c()},G=()=>{A(a),h==null||h()},q=()=>{k.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),p==null||p(!j)},te=m==="horizontal"?"horizontal":"vertical";return d.jsxs(ta,{className:nt(["react-flow__controls",te,v]),position:y,style:t,"data-testid":"rf__controls","aria-label":_??R["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(jl,{onClick:$,className:"react-flow__controls-zoomin",title:R["controls.zoomIn.ariaLabel"],"aria-label":R["controls.zoomIn.ariaLabel"],disabled:E,children:d.jsx(ck,{})}),d.jsx(jl,{onClick:F,className:"react-flow__controls-zoomout",title:R["controls.zoomOut.ariaLabel"],"aria-label":R["controls.zoomOut.ariaLabel"],disabled:b,children:d.jsx(dk,{})})]}),o&&d.jsx(jl,{className:"react-flow__controls-fitview",onClick:G,title:R["controls.fitView.ariaLabel"],"aria-label":R["controls.fitView.ariaLabel"],children:d.jsx(fk,{})}),s&&d.jsx(jl,{className:"react-flow__controls-interactive",onClick:q,title:R["controls.interactive.ariaLabel"],"aria-label":R["controls.interactive.ariaLabel"],children:j?d.jsx(pk,{}):d.jsx(hk,{})}),x]})}pm.displayName="Controls";const mk=L.memo(pm);function yk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:v,borderRadius:x,shapeRendering:y,selected:m,onClick:_}){const{background:k,backgroundColor:j}=u||{},b=c||k||j;return d.jsx("rect",{className:nt(["react-flow__minimap-node",{selected:m},v]),x:r,y:o,rx:x,ry:x,width:s,height:a,style:{fill:b,stroke:h,strokeWidth:p},shapeRendering:y,onClick:_?E=>_(E,t):void 0})}const vk=L.memo(yk),xk=t=>t.nodes.map(r=>r.id),Ku=t=>t instanceof Function?t:()=>t;function wk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=vk,onClick:c}){const h=De(xk,Qe),p=Ku(r),v=Ku(t),x=Ku(o),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(m=>d.jsx(Sk,{id:m,nodeColorFunc:p,nodeStrokeColorFunc:v,nodeClassNameFunc:x,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:y},m))})}function _k({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:v,x,y,width:m,height:_}=De(k=>{const j=k.nodeLookup.get(t);if(!j)return{node:void 0,x:0,y:0,width:0,height:0};const b=j.internals.userNode,{x:E,y:R}=j.internals.positionAbsolute,{width:w,height:N}=vn(b);return{node:b,x:E,y:R,width:w,height:N}},Qe);return!v||v.hidden||!pg(v)?null:d.jsx(h,{x,y,width:m,height:_,style:v.style,selected:!!v.selected,className:s(v),color:r(v),borderRadius:a,strokeColor:o(v),strokeWidth:u,shapeRendering:c,onClick:p,id:v.id})}const Sk=L.memo(_k);var kk=L.memo(wk);const Nk=200,jk=150,bk=t=>!t.hidden,Ek=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?dg(hs(t.nodeLookup,{filter:bk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},hp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,Ck=(t,r)=>hp(t.viewBB,r.viewBB)&&hp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,Mk="react-flow__minimap-desc";function gm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:v,maskStrokeColor:x,maskStrokeWidth:y,position:m="bottom-right",onClick:_,onNodeClick:k,pannable:j=!1,zoomable:b=!1,ariaLabel:E,inversePan:R,zoomStep:w=1,offsetScale:N=5}){const A=Ye(),$=L.useRef(null),{boundingRect:F,viewBB:G,rfId:q,panZoom:te,translateExtent:ee,flowWidth:ne,flowHeight:K,ariaLabelConfig:C}=De(Ek,Ck),V=(t==null?void 0:t.width)??Nk,W=(t==null?void 0:t.height)??jk,U=F.width/V,M=F.height/W,D=Math.max(U,M),H=D*V,I=D*W,z=N*D,ie=F.x-(H-F.width)/2-z,oe=F.y-(I-F.height)/2-z,fe=H+z*2,he=I+z*2,pe=`${Mk}-${q}`,Z=L.useRef(0),se=L.useRef();Z.current=D,L.useEffect(()=>{if($.current&&te)return se.current=H1({domNode:$.current,panZoom:te,getTransform:()=>A.getState().transform,getViewScale:()=>Z.current}),()=>{var re;(re=se.current)==null||re.destroy()}},[te]),L.useEffect(()=>{var re;(re=se.current)==null||re.update({translateExtent:ee,width:ne,height:K,inversePan:R,pannable:j,zoomStep:w,zoomable:b})},[j,b,R,w,ee,ne,K]);const me=_?re=>{var Te;const[Ne,Me]=((Te=se.current)==null?void 0:Te.pointer(re))||[0,0];_(re,{x:Ne,y:Me})}:void 0,ke=k?L.useCallback((re,Ne)=>{const Me=A.getState().nodeLookup.get(Ne).internals.userNode;k(re,Me)},[]):void 0,ve=E??C["minimap.ariaLabel"];return d.jsx(ta,{position:m,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof v=="string"?v:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof y=="number"?y*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:nt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:V,height:W,viewBox:`${ie} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:$,onClick:me,children:[ve&&d.jsx("title",{id:pe,children:ve}),d.jsx(kk,{onClick:ke,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-z},${oe-z}h${fe+z*2}v${he+z*2}h${-fe-z*2}z + M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}gm.displayName="MiniMap";const Pk=L.memo(gm),Ik=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Rk={[to.Line]:"right",[to.Handle]:"bottom-right"};function Tk({nodeId:t,position:r,variant:o=to.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:v=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:y=!1,resizeDirection:m,autoScale:_=!0,shouldResize:k,onResizeStart:j,onResize:b,onResizeEnd:E}){const R=Ug(),w=typeof t=="string"?t:R,N=Ye(),A=L.useRef(null),$=o===to.Handle,F=De(L.useCallback(Ik($&&_),[$,_]),Qe),G=L.useRef(null),q=r??Rk[o];L.useEffect(()=>{if(!(!A.current||!w))return G.current||(G.current=e_({domNode:A.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,domNode:W}=N.getState();return{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,paneDomNode:W}},onChange:(ee,ne)=>{const{triggerNodeChanges:K,nodeLookup:C,parentLookup:V,nodeOrigin:W}=N.getState(),U=[],M={x:ee.x,y:ee.y},D=C.get(w);if(D&&D.expandParent&&D.parentId){const H=D.origin??W,I=ee.width??D.measured.width??0,z=ee.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:I,height:z,...gg({x:ee.x??D.position.x,y:ee.y??D.position.y},{width:I,height:z},D.parentId,C,H)}},oe=Pc([ie],C,V,W);U.push(...oe),M.x=ee.x?Math.max(H[0]*I,ee.x):void 0,M.y=ee.y?Math.max(H[1]*z,ee.y):void 0}if(M.x!==void 0&&M.y!==void 0){const H={id:w,type:"position",position:{...M}};U.push(H)}if(ee.width!==void 0&&ee.height!==void 0){const I={id:w,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:ee.width,height:ee.height}};U.push(I)}for(const H of ne){const I={...H,type:"position"};U.push(I)}K(U)},onEnd:({width:ee,height:ne})=>{const K={id:w,type:"dimensions",resizing:!1,dimensions:{width:ee,height:ne}};N.getState().triggerNodeChanges([K])}})),G.current.update({controlPosition:q,boundaries:{minWidth:h,minHeight:p,maxWidth:v,maxHeight:x},keepAspectRatio:y,resizeDirection:m,onResizeStart:j,onResize:b,onResizeEnd:E,shouldResize:k}),()=>{var ee;(ee=G.current)==null||ee.destroy()}},[q,h,p,v,x,y,j,b,E,k]);const te=q.split("-");return d.jsx("div",{className:nt(["react-flow__resize-control","nodrag",...te,o,s]),ref:A,style:{...a,scale:F,...c&&{[$?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Tk);const Lk={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function ia(t){return Lk[t]??8}const Wl=208,ro=64,Ak=88,$k=28,zk=8;function Dk(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function mm(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const w of t){const N=ia(w.type),A=s.get(N)??[];A.push(w),s.set(N,A)}const u=[...s.keys()].sort((w,N)=>w-N).map(w=>[...s.get(w)??[]].sort((N,A)=>N.name.localeCompare(A.name)||N.id.localeCompare(A.id))),c=new Set(t.map(w=>w.id)),h=new Map,p=new Map;for(const w of t)h.set(w.id,[]),p.set(w.id,[]);for(const w of r)!c.has(w.src)||!c.has(w.dst)||w.src===w.dst||(p.get(w.src).push(w.dst),h.get(w.dst).push(w.src));const v=new Map;u.forEach((w,N)=>{for(const A of w)v.set(A.id,N)});const x=new Map,y=()=>{for(const w of u)w.forEach((N,A)=>x.set(N.id,A))};y();const m=(w,N)=>{const A=w.map(($,F)=>{const G=N($.id).map(te=>x.get(te)).filter(te=>te!==void 0),q=Dk(G);return{n:$,bary:Number.isNaN(q)?F:q,name:$.name,id:$.id}});return A.sort(($,F)=>$.bary-F.bary||$.name.localeCompare(F.name)||$.id.localeCompare(F.id)),A.map($=>$.n)},_=w=>N=>v.get(N)===w;for(let w=0;w(h.get(A)??[]).filter(_(N-1))),y();for(let N=u.length-2;N>=0;N--)u[N]=m(u[N],A=>(p.get(A)??[]).filter(_(N+1))),y()}const k=Wl+Ak,j=ro+$k,b=Math.max(...u.map(w=>w.length),1),E=[];let R=0;for(let w=0;wG.id)),A=new Set((u[w+1]??[]).map(G=>G.id));let $=0;if(A.size)for(const G of r)N.has(G.src)&&A.has(G.dst)&&($+=1);const F=Math.min(48,Math.max(0,($-2)*10));R+=k+F}return u.forEach((w,N)=>{const A=(b-w.length)*j/2;w.forEach(($,F)=>{o.set($.id,{x:E[N]??0,y:A+F*j})})}),o}const Ok=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),ym=90,Fk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),pp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Hk=Math.PI*(3-Math.sqrt(5)),vm=220,Bk=26,Vk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function xm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function BN(t){return pp[t]?pp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Wk(t){return t>=ym?"3d":"2d"}function Uk(t){return t>=ym?"overview":"full"}function Yk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(xm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Fk.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Yk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Xk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function qk(t,r,o,s){const a=new Set(t.map(j=>j.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const j of r){if(!a.has(j.src)||!a.has(j.dst))continue;const b=u.get(j.src)??[];b.push({dst:j.dst,id:j.id}),u.set(j.src,b);const E=c.get(j.dst)??[];E.push({src:j.src,id:j.id}),c.set(j.dst,E)}const h=new Set(t.filter(j=>Ok.has(j.type)).map(j=>j.id)),p=h.size?h:a,v=new Set,x=[o];for(;x.length;){const j=x.pop();if(!v.has(j)){v.add(j);for(const b of u.get(j)??[])v.has(b.dst)||x.push(b.dst)}}const y=new Set([o]),m=[...p].filter(j=>v.has(j)),_=new Set(m);for(;m.length;){const j=m.pop();y.add(j);for(const b of c.get(j)??[])v.has(b.src)&&!_.has(b.src)&&(_.add(b.src),m.push(b.src))}const k=new Set;for(const j of r)y.has(j.src)&&y.has(j.dst)&&k.add(j.id);return{nodeIds:y,edgeIds:k}}function VN(t){const r=new Map;for(const s of t){const a=ia(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*vm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Bk*Math.sqrt(h+1),v=h*Hk;o.set(c.id,{x:u,y:p*Math.cos(v),z:p*Math.sin(v)})})}return o}function WN(t){const r=new Map;for(const o of t){const s=ia(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*vm,count:s}))}const bl=16,Kk=12,Qk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Zk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),gp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Jk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},mp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],yp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),eN=new Set(["looks_idempotent_on_pk","null","blank"]),tN=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function nN(t){return gp[t]?gp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function rN(t,r,o){const s=new Map(r.map(m=>[m.id,m])),a=[];Qk.has(t.type)&&a.push("sink"),Zk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(m=>m.dst===t.id),h=o.filter(m=>m.src===t.id),p=c.slice(0,bl).map(m=>El(m,s,m.src)),v=h.slice(0,bl).map(m=>El(m,s,m.dst)),x=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,y={type:t.type,typeLabel:Zo(io(t.type)),layer:Vk[ia(t.type)]??"other",purpose:nN(t.type),name:t.name,qualifiedName:t.qualified_name,file:x,context:t.context,roles:a,facts:oN(u).filter(m=>!(m.key==="app"&&m.value===t.context)),inputs:p,outputs:v,extraInputs:Math.max(0,c.length-bl),extraOutputs:Math.max(0,h.length-bl),degreeIn:c.length,degreeOut:h.length,inputKinds:vp(c.map(m=>El(m,s,m.src))),outputKinds:vp(h.map(m=>El(m,s,m.dst))),pathSummary:""};return y.pathSummary=iN(y),y}function vp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function iN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function El(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Zo(io(s.type)):"",edgeType:t.type,edgeLabel:Zo(t.type),inferred:t.confidence<.8}}function oN(t){const r=[...mp.filter(a=>a in t),...Object.keys(t).filter(a=>!mp.includes(a)&&!yp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||yp.has(a)||tN.has(a))continue;s.add(a);const u=sN(a,t[a]);u!=null&&o.push({key:a,label:Jk[a]??Zo(a),value:u})}return o}function sN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!eN.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return lN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Kk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function lN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const xp=12,wp=.2,aN=.8,uN=ro;function cN(t,r,o){const s=o??mm(t,r),a=[];for(const h of r){const p=s.get(h.src),v=s.get(h.dst);if(!p||!v)continue;const x=p.y+ro/2,y=v.y+ro/2;if(Math.abs(x-y)m.y0-_.y0||m.y1-_.y1||m.id.localeCompare(_.id)),v=dN(p),x=Math.max(0,...v.values())+1,y=Math.min(...p.map(m=>m.targetX-m.sourceX));for(const m of p){const _=v.get(m.id)??0,k=fN(_,x),j=m.targetX-m.sourceX;if(Math.abs(j-y)<.5){c.set(m.id,k);continue}const b=m.sourceX+y*k;c.set(m.id,Math.min(.92,Math.max(.08,(b-m.sourceX)/j)))}}return c}function dN(t){const r=[],o=new Map;for(const s of t){let a=-1;for(let u=0;ur[u]+uN){a=u;break}a<0?(a=r.length,r.push(s.y1)):r[a]=Math.max(r[a],s.y1),o.set(s.id,a)}return o}function fN(t,r){return r<=1?.5:wp+(aN-wp)*t/(r-1)}const hN=new Set,pN=L.lazy(()=>N0(()=>import("./LayeredGraph3D-BFszTRNF.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),gN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function mN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(no,{type:"target",position:Se.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:io(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Tr(t.name)}),d.jsx(no,{type:"source",position:Se.Right,isConnectable:!1})]})}const yN={load:mN},vN=new Set(["django","react","stitch","arch"]);function xN({id:t,sourceX:r,sourceY:o,targetX:s,targetY:a,sourcePosition:u,targetPosition:c,style:h,markerEnd:p,markerStart:v,label:x,labelStyle:y,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,data:b,interactionWidth:E}){const[R,w,N]=Bl({sourceX:r,sourceY:o,sourcePosition:u,targetX:s,targetY:a,targetPosition:c,borderRadius:8,stepPosition:(b==null?void 0:b.stepPosition)??.5});return d.jsx(ms,{id:t,path:R,labelX:w,labelY:N,label:x,labelStyle:y,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,style:h,markerEnd:p,markerStart:v,interactionWidth:E})}const wN={loadstep:xN};function _N({topologyKey:t}){const{fitView:r}=na();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function SN(t,r,o=null,s={}){const a=new Map(t.map(v=>[v.id,v])),u=mm(t,r),c=cN(t,r,u),h=t.map(v=>{var m;const x=((m=s.roles)==null?void 0:m[v.id])||[],y=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:v.id,type:"load",position:u.get(v.id)??{x:0,y:0},data:{name:v.name,type:v.type,file:v.file_path,roles:x,dim:y},selected:o===v.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:Wl,height:ro,style:{width:Wl,height:ro}}}),p=r.filter(v=>a.has(v.src)&&a.has(v.dst)).map(v=>{const x=gN[v.weight]||"var(--edge-cheap)",y=!!(o&&(v.src===o||v.dst===o));return{id:v.id,source:v.src,target:v.dst,type:"loadstep",animated:v.weight==="critical",data:{stepPosition:c.get(v.id)??.5},style:{stroke:x,strokeWidth:v.weight==="critical"?2.4:1.2,strokeDasharray:v.confidence<.8?"6 4":void 0},markerEnd:{type:os.ArrowClosed,width:14,height:14,color:x},label:y?v.type.replaceAll("_"," "):void 0,labelStyle:y?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:y?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:y?[3,5]:void 0,labelBgBorderRadius:y?4:void 0}});return{rfNodes:h,rfEdges:p}}function kN({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:v}){const x=rN(t,r,o);return L.useEffect(()=>{const y=m=>{m.key==="Escape"&&s()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:x.typeLabel}),d.jsx("div",{className:"inspector-roles",children:x.roles.map(y=>d.jsx("span",{className:"inspector-chip",children:y},y))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Tr(x.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:x.purpose}),x.context?d.jsx("div",{className:"muted",children:Tr(x.context)}):null,x.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Tr(x.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Tr(x.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",x.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[x.degreeIn," in · ",x.degreeOut," out"]}),x.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:x.pathSummary}):null,x.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:x.facts.map(y=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:y.label}),d.jsx("dd",{children:Tr(y.value)})]},y.key))}):null,d.jsx(_p,{title:"Inputs",testId:"graph-inspector-inputs",links:x.inputs,extra:x.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(_p,{title:"Outputs",testId:"graph-inspector-outputs",links:x.outputs,extra:x.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),a?d.jsx("p",{className:"whatif-hint","data-testid":"whatif-hint",children:v?"Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map.":"Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."}):null,d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",title:"Start a hypothetical walk from this node. Does not use Base/Head.",onClick:()=>a(t.id),children:"What if this changes"}):null,v?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",title:"Hide nodes that are not on a path from here to a sink. Does not start a new walk.",onClick:()=>v(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function _p({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Qu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:v,repoPath:x,onOpenFile:y,pinnedId:m,onPin:_}){const[k,j]=L.useState(null),b=a!==void 0?a:k,E=re=>{a===void 0&&j(re),u==null||u(re)},[R,w]=L.useState(null),[N,A]=L.useState(null),[$,F]=L.useState(new Set(vN)),[G,q]=L.useState(!1),[te,ee]=L.useState(""),[ne,K]=L.useState(!1),C=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,V=R??Wk(t.length),W=N??Uk(t.length),U=G?b:null,M=L.useMemo(()=>p?qk(t,r,p):null,[t,r,p]),D=M?t.filter(re=>M.nodeIds.has(re.id)):t,H=M?r.filter(re=>M.edgeIds.has(re.id)):r,I=L.useMemo(()=>Gk(D,H,{detail:W,families:$,focusId:U,neighborhoodOnly:!!U}),[D,H,W,$,U]),z=L.useMemo(()=>`${I.nodes.map(re=>re.id).join("\0")}|${I.edges.map(re=>re.id).join("\0")}`,[I.nodes,I.edges]),ie=b?t.find(re=>re.id===b)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const re=SN(I.nodes,I.edges,b,{roles:c,testOverlay:h});return C&&(re.rfEdges=re.rfEdges.map(Ne=>({...Ne,animated:!1}))),re},[I.nodes,I.edges,b,C,c,h]);L.useEffect(()=>{if(!s)return;const re=t.find(Ne=>Ne.file_path===s);re&&E(re.id)},[s,t]);const he=L.useMemo(()=>Xk(t,te),[t,te]),pe=(re,Ne)=>{E(Ne.id)},Z=()=>{E(null),q(!1)},se=ie?d.jsx(kN,{node:ie,nodes:t,edges:r,onClose:Z,onWhatIf:o,onSelect:E,onOpenFile:y,pinned:m===ie.id,onPin:_,onIsolate:v?re=>{v(p===re?null:re)}:void 0}):null,me=re=>{F(Ne=>{const Me=new Set(Ne);if(Me.has(re)){if(Me.size===1)return Ne;Me.delete(re)}else Me.add(re);return Me})},ke=L.useMemo(()=>{const re=new Set;for(const Ne of t)re.add(xm(Ne.type));return re},[t]),ve=t.length-I.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:V==="2d"?"active":"","aria-pressed":V==="2d",onClick:()=>w("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:V==="3d"?"active":"","aria-pressed":V==="3d",onClick:()=>w("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:W==="overview"?"active":"","aria-pressed":W==="overview",onClick:()=>A("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:W==="full"?"active":"","aria-pressed":W==="full",onClick:()=>A("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(re=>ke.has(re)).map(re=>d.jsx("button",{type:"button","data-testid":`graph-family-${re}`,className:$.has(re)?"active":"","aria-pressed":$.has(re),onClick:()=>me(re),children:re},re))}),d.jsx("button",{type:"button",className:G?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!b,onClick:()=>q(re=>!re),children:G?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>v==null?void 0:v(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:te,onChange:re=>{ee(re.target.value),K(!0)},onFocus:()=>K(!0),onBlur:()=>window.setTimeout(()=>K(!1),150)}),ne&&te.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(re=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:Ne=>Ne.preventDefault(),onClick:()=>{E(re.id),ee(""),K(!1)},children:[re.name,d.jsx("span",{className:"muted",children:io(re.type)})]})},re.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[I.nodes.length," nodes · ",I.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:V==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(pN,{nodes:I.nodes,edges:I.edges,selectedId:b,neighborIds:U?I.neighborIds:hN,onSelect:re=>{E(re),re||q(!1)}})}),se]}):d.jsxs(fm,{children:[d.jsxs(ik,{nodes:oe,edges:fe,nodeTypes:yN,edgeTypes:wN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:Z,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(_N,{topologyKey:z}),d.jsx(uk,{}),d.jsx(Pk,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(mk,{})]}),se]})})]})}function wm(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function NN(t){localStorage.setItem("loadpath.editor",t)}async function jN(t,r,o,s=wm()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const Sp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],bN=["preset","branch","tag","commit"];function EN(t){var a;if(!(t!=null&&t.git))return[...Sp];const r=((a=t.presets)!=null&&a.length?t.presets:Sp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function CN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function MN(t){return bN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function PN(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function kp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[v,x]=L.useState(!1),[y,m]=L.useState(null),[_,k]=L.useState(0),j=L.useMemo(()=>{const N=EN(u);return y===null?N:CN(N,y)},[u,y]),b=L.useMemo(()=>MN(j),[j]);L.useEffect(()=>{v&&c()},[v,c]),L.useEffect(()=>{k(0)},[y,v]);const E=()=>{x(!1),m(null)},R=N=>{r(N.value),E()},w=N=>{if(N.key==="ArrowDown"){if(N.preventDefault(),!v){x(!0);return}k(A=>Math.min(A+1,Math.max(j.length-1,0)))}else if(N.key==="ArrowUp"){if(N.preventDefault(),!v)return;k(A=>Math.max(A-1,0))}else if(N.key==="Enter"&&v){N.preventDefault();const A=j[_];A&&R(A)}else N.key==="Escape"&&v&&(N.preventDefault(),E())};return d.jsxs("div",{className:"combo",ref:p,onBlur:N=>{N.currentTarget.contains(N.relatedTarget)||E()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":v,"aria-controls":h,"aria-autocomplete":"list",onChange:N=>{r(N.target.value),v&&m(N.target.value)},onKeyDown:w}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":v,onMouseDown:N=>N.preventDefault(),onClick:()=>v?E():x(!0),children:d.jsx(_0,{})})]}),v?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:b.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):b.map(N=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:PN(N.group)}),N.items.map(A=>{const $=j.indexOf(A);return d.jsxs("button",{type:"button",role:"option","aria-selected":$===_,className:$===_?"combo-option active":"combo-option","data-testid":`ref-option-${A.group}`,onMouseDown:F=>F.preventDefault(),onMouseEnter:()=>k($),onClick:()=>R(A),children:[d.jsx("span",{className:"combo-label",children:A.label}),A.detail?d.jsx("span",{className:"combo-detail",children:A.detail}):null]},`${A.group}:${A.value}`)})]},N.group))}):null]})}function IN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[v,x]=L.useState(""),[y,m]=L.useState(!1),_=L.useRef(null),k=L.useRef(0),j=async w=>{const N=k.current+1;k.current=N,m(!0);try{const A=await Pe.browse(w);if(k.current!==N)return;a(A),c(A.path),p(A.is_git?A.path:null),x("")}catch(A){if(k.current!==N)return;x(A instanceof Error?A.message:String(A))}finally{k.current===N&&m(!1)}};L.useEffect(()=>{var w,N;j(t),(w=_.current)==null||w.focus(),(N=_.current)==null||N.select()},[t]);const b=h||(s==null?void 0:s.path)||u,E=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",R=w=>{w.key==="Escape"&&(w.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:R,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:w=>w.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:w=>{w.preventDefault(),j(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:w=>c(w.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),v?d.jsx("div",{className:"error",role:"alert",children:v}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":y,children:s!=null&&s.entries.length?s.entries.map(w=>{const N=h===w.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":N,className:N?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":w.path,onClick:()=>p(w.path),onDoubleClick:()=>void j(w.path),children:[d.jsx(Ep,{}),d.jsx("span",{className:"explorer-name",children:w.name}),w.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},w.path)}):d.jsx("div",{className:"muted explorer-empty",children:y?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:b,children:b}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!b,onClick:()=>b&&r(b),children:["Use ",E]})]})]})})}const RN={scan:{start:0,end:20},extract:{start:20,end:88},boot:{start:88,end:94},stitch:{start:94,end:99},skipped:{start:100,end:100},done:{start:100,end:100}},TN=new Set(["scan","extract","boot","stitch"]);function LN(t){const r=t.phase||"";if(!r||r==="idle")return null;const o=RN[r];if(!o)return null;if(o.start===o.end)return o.end;const s=t.total||0;if(s<=0)return o.start;const a=Math.min(1,Math.max(0,(t.done||0)/s));return Math.round(o.start+(o.end-o.start)*a)}function AN(t){return!t.phase||t.phase==="idle"?null:typeof t.percent=="number"&&Number.isFinite(t.percent)?Math.max(0,Math.min(100,Math.round(t.percent))):LN(t)}const Ul=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],$N="obsidian",_m="loadpath.theme";function zN(t){return Ul.some(r=>r.id===t)}function Sm(){try{const t=localStorage.getItem(_m)||"";if(zN(t))return t}catch{}return $N}function DN(t){var r;return((r=Ul.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function km(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=DN(t);try{localStorage.setItem(_m,t)}catch{}}const Zu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:m0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:y0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:v0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:x0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:w0}];function Ju(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function ON(){var fo,ho,Si,po,go,mo,ki,Xr,rn,on;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,v]=L.useState(null),[x,y]=L.useState(null),[m,_]=L.useState(null),[k,j]=L.useState([]),[b,E]=L.useState("review"),[R,w]=L.useState(""),[N,A]=L.useState(""),[$,F]=L.useState(null),[G,q]=L.useState(!1),[te,ee]=L.useState(!1),[ne,K]=L.useState(""),[C,V]=L.useState({}),[W,U]=L.useState([]),[M,D]=L.useState([]),[H,I]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[z,ie]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[oe,fe]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[he,pe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[Z,se]=L.useState(0),[me,ke]=L.useState(""),[ve,re]=L.useState(Sm),[Ne,Me]=L.useState(!1),[Te,$e]=L.useState(!1),[st,lt]=L.useState(!1),[at,Ge]=L.useState(null),[wt,qt]=L.useState(null),[gt,mt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[Pt,ut]=L.useState(null),[Je,An]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[Ot,xn]=L.useState([]),[oo,$n]=L.useState(null),[vi,or]=L.useState(null),[$r,zn]=L.useState(null),[zr,sr]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[lr,Ft]=L.useState(null),[ct,Dn]=L.useState(null),[On,wn]=L.useState(!1),[Fn,_n]=L.useState(!1),rt=L.useRef(o);rt.current=o;const Dr=L.useRef(!1);Dr.current=Te;const _t=L.useRef(""),ar=L.useRef(""),Sn=P=>{re(P),km(P)},dt=L.useRef(""),He=P=>{dt.current=P,A(P)},kn=P=>{let Y=0,ce=!1;F(0);const je=()=>{Pe.indexProgress(P).then(Ie=>{if(!dt.current)return;if(Ie.phase&&Ie.phase!=="idle"&&Ie.message&&He(Ie.message),TN.has(Ie.phase))ce=!0;else if(!ce)return;const qr=AN(Ie);qr!=null&&(Ie.phase==="scan"&&!Ie.done?Y=qr:Y=Math.max(Y,qr),F(Y))}).catch(()=>{})};je();const Le=window.setInterval(je,250);return()=>{window.clearInterval(Le),F(null)}};L.useEffect(()=>{Pe.settings().then(V).catch(()=>{}).finally(()=>Me(!0)),Pe.repos().then(P=>j(P.repos)).catch(()=>{})},[]);const Nn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const P=o;let Y=!1;return ar.current!==P&&Bn(P),Pe.config(P).then(ce=>{!Y&&rt.current===P&&or(ce)}).catch(()=>{}),Pe.architectureHealth(P).then(ce=>{!Y&&rt.current===P&&zn(ce)}).catch(()=>{}),()=>{Y=!0}},[t,o]);const Ht=P=>{rt.current=P,s(P),localStorage.setItem("loadpath.repo",P),P.trim()!==_t.current&&(_t.current="",Ft(null))},Or=L.useCallback(P=>{const Y=(P??rt.current).trim();return!Y||_t.current===Y?Promise.resolve():(_t.current=Y,Pe.gitRefs(Y).then(ce=>{rt.current.trim()===Y&&Ft(ce)}).catch(()=>{_t.current===Y&&(_t.current="",Ft(null))}))},[]),nn=(P,Y)=>{u(P),h(Y),localStorage.setItem("loadpath.base",P),localStorage.setItem("loadpath.head",Y)},Fr=(P,Y,ce)=>{ie(P),I(Y),localStorage.setItem("loadpath.provider",P),localStorage.setItem("loadpath.scmRepo",Y),ce!==void 0&&(fe(ce),localStorage.setItem("loadpath.prNumber",ce))},yt=P=>{v(P),se(0),Ge(wt&&P.nodes.some(Y=>Y.id===wt)?wt:null),ut(null),$n(null),P.what_if||(y(P),P.id&&localStorage.setItem("loadpath.lastReviewId",P.id))},Hn=async P=>{try{const Y=await Pe.reviews(P);xn(Y.reviews)}catch{xn([])}},ur=async P=>{try{zn(await Pe.architectureHealth(P))}catch{zn(null)}},so=P=>P==="github"?!!C.github_token_set:P==="gitlab"?!!C.gitlab_token_set:!!C.bitbucket_token_set,It=L.useCallback(async(P=z)=>{var Y;try{const ce=await Pe.scmRepos(P);D(ce.repos),(Y=ce.user)!=null&&Y.login&&V(je=>({...je,...P==="github"?{github_user:ce.user.login}:P==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{D([])}},[z]);L.useEffect(()=>{if(t!=="prs")return;let P=!1;return It(z).catch(()=>{P||D([])}),()=>{P=!0}},[t,z,It]),L.useEffect(()=>{if(!ct)return;let P=!1,Y=0;const ce=async()=>{try{const je=await Pe.githubOAuthPoll(ct.flow_id);if(P)return;if(je.status==="complete"){Dn(null);const Le=await Pe.settings();V(Le),K(je.user?`Signed in to GitHub as ${je.user}`:"Signed in to GitHub"),It("github");return}if(je.status==="pending"||je.status==="slow_down"){Y=window.setTimeout(ce,Math.max(je.interval||ct.interval,5)*1e3);return}Dn(null),w(je.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(je){if(P)return;Dn(null),w(je instanceof Error?je.message:String(je))}};return Y=window.setTimeout(ce,Math.max(ct.interval,5)*1e3),()=>{P=!0,window.clearTimeout(Y)}},[ct,It]),L.useEffect(()=>{if(!On)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.bitbucket.connected){wn(!1);const Ie=await Pe.settings();V(Ie),K(Le.bitbucket.user?`Signed in to Bitbucket as ${Le.bitbucket.user}`:"Signed in to Bitbucket"),It("bitbucket");return}if(Date.now()-ce>18e4){wn(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;wn(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[On,It]),L.useEffect(()=>{if(!Fn)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.gitlab.connected){_n(!1);const Ie=await Pe.settings();V(Ie),K(Le.gitlab.user?`Signed in to GitLab as ${Le.gitlab.user}`:"Signed in to GitLab"),It("gitlab");return}if(Date.now()-ce>18e4){_n(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;_n(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[Fn,It]);const Bn=async(P=o,Y=!1)=>{if(!P.trim())return null;ar.current=P,ee(!0);try{const ce=await Pe.architecture(P,!1);rt.current===P&&_(ce);const je=Pe.architectureGraph(P).then(Le=>{rt.current===P&&_(Ie=>Ie&&{...Ie,nodes:Le.nodes,edges:Le.edges,graph_pending:!1})});return je.catch(()=>{}).finally(()=>{rt.current===P&&ee(!1)}),Y&&await je,ce}catch(ce){throw rt.current===P&&ee(!1),ce}},Hr=async P=>{const Y=P.trim();if(!(!Y||Y===rt.current)){if(dt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),K(""),v(null),y(null),_(null),E("architecture"),Ht(Y),q(!0),He(`Loading ${g0(Y)}…`);try{await Promise.all([Bn(Y),Or(Y)])}catch(ce){rt.current===Y&&w(ce instanceof Error?ce.message:String(ce))}finally{rt.current===Y&&(He(""),q(!1))}}},jn=async()=>{if(dt.current||!Nn())return;w(""),K(""),He("Tracing load path…"),Ht(o),nn(a,c);const P=kn(o);try{const Y=await Pe.review(o,a,c,!0,he);yt(Y),E("review"),r("review"),await Pe.repos().then(ce=>j(ce.repos)).catch(()=>{}),await Promise.all([Bn(o),Hn(o),ur(o)])}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{P(),He("")}},Br=async(P=!0)=>{if(dt.current||!Nn())return;w(""),K(""),He(P?"Indexing…":"Full reindex…"),Ht(o);const Y=kn(o);try{await Pe.index(o,P);const ce=await Bn(o);await Pe.repos().then(je=>j(je.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(E("architecture"),r("architecture"))}catch(ce){w(ce instanceof Error?ce.message:String(ce))}finally{Y(),He("")}},xi=async()=>{if(!dt.current&&Nn()){w(""),K(""),He("Detecting layout…"),Ht(o);try{const P=await Pe.init(o);K(P.message),await Pe.repos().then(Y=>j(Y.repos)).catch(()=>{})}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ve=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),K("Copied markdown brief")}catch(P){w(P instanceof Error?P.message:String(P))}},lo=async()=>{if(!dt.current){if(p!=null&&p.what_if){w("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first.");return}if(!(p!=null&&p.markdown)||!H||!oe){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const P=await Pe.postComment(z,H,Number(oe),p.markdown);K(P.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Vr=async()=>{if(!dt.current){w(""),He("Fetching pull requests…");try{const P=await Pe.prs(z,H,"open",o.trim()||void 0);U(P.pull_requests);const Y=M.find(ce=>ce.slug.toLowerCase()===H.trim().toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},wi=async()=>{w("");try{const P=await Pe.githubOAuthStart();Dn(P),Ju(P.verification_uri_complete,"github.com","/login/device")}catch(P){w(P instanceof Error?P.message:String(P))}},cr=async()=>{w("");try{const P=await Pe.bitbucketOAuthStart();wn(!0),Ju(P.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(P){wn(!1),w(P instanceof Error?P.message:String(P))}},ao=async()=>{w("");try{const P=await Pe.gitlabOAuthStart();_n(!0),Ju(P.authorize_url,new URL(P.authorize_url).hostname,"/oauth/authorize")}catch(P){_n(!1),w(P instanceof Error?P.message:String(P))}},dr=async P=>{if(!(dt.current||!o.trim())){w(""),He("Walking what-if path…");try{const Y=await Pe.whatIf(o,P);K(`${Y.title} — ${Y.confidence.level} · ${(Y.sinks||[]).length} sinks`),yt({...Y,markdown:Y.markdown||"",index:Y.index||(p==null?void 0:p.index),workspace:Y.workspace||(p==null?void 0:p.workspace)}),E("review"),r("review")}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},Vn=()=>{if(x){yt(x),E("review"),r("review"),K("Restored the last git-range walk");return}v(null),se(0),Ge(null),ut(null),$n(null),E("architecture"),r("architecture"),K("")},bt=async P=>{var Le;if(dt.current)return;Fr(P.provider,P.repo,String(P.number));const Y=M.find(Ie=>Ie.slug.toLowerCase()===P.repo.toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path),w(""),He(`Fetching ${P.provider} #${P.number}…`);const ce=(Y==null?void 0:Y.local_path)||o,je=ce?kn(ce):()=>{};try{const Ie=await Pe.reviewPr(P.provider,P.repo,P.number,(Y==null?void 0:Y.local_path)||o||void 0);yt(Ie),Ie.pull_request&&typeof Ie.pull_request.repo_path=="string"&&Ht(Ie.pull_request.repo_path),nn(String(Ie.base||P.target_branch),String(Ie.head||P.source_branch)),E("review"),r("review"),typeof((Le=Ie.pull_request)==null?void 0:Le.repo_path)=="string"&&Hn(Ie.pull_request.repo_path)}catch(Ie){nn(P.base_sha||P.target_branch,P.head_sha||P.source_branch),r("review"),w(Ie instanceof Error?Ie.message:String(Ie))}finally{je(),He("")}},Wr=async P=>{w("");try{V(await Pe.oauthDisconnect(P)),z===P&&D([]),K(`Disconnected ${P}`)}catch(Y){w(Y instanceof Error?Y.message:String(Y))}},Et=async P=>{P.preventDefault();const Y=new FormData(P.currentTarget),ce={github_token:String(Y.get("github_token")||""),github_oauth_client_id:String(Y.get("github_oauth_client_id")||""),github_host:String(Y.get("github_host")||""),gitlab_token:String(Y.get("gitlab_token")||""),gitlab_host:String(Y.get("gitlab_host")||""),gitlab_oauth_client_id:String(Y.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(Y.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(Y.get("bitbucket_token")||""),bitbucket_username:String(Y.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(Y.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(Y.get("bitbucket_oauth_client_secret")||""),ai_provider:String(Y.get("ai_provider")||"none"),ai_api_key:String(Y.get("ai_api_key")||""),ai_model:String(Y.get("ai_model")||""),ai_base_url:String(Y.get("ai_base_url")||"")},je=k.length?{...ce,workspaces:k.map(Le=>({path:Le.path,name:Le.name}))}:ce;try{V(await Pe.saveSettings(je)),K("Settings saved on this machine")}catch(Le){w(Le instanceof Error?Le.message:String(Le))}},uo=async()=>{if(!(!p||dt.current)){He("Residual analysis…");try{const P=await Pe.residual(p);ke(P.note)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ur=L.useRef(jn);Ur.current=jn;const Yr=L.useRef(t);Yr.current=t;const Wn=L.useRef(!1);Wn.current=st;const Un=L.useRef(p);Un.current=p;const bn=L.useRef(Z);bn.current=Z,L.useEffect(()=>{const P=localStorage.getItem("loadpath.lastReviewId"),Y=(localStorage.getItem("loadpath.repo")||"").trim();if(!P||!Y){sr(!1);return}let ce=!1;return Pe.getReview(Y,P).then(je=>{ce||(yt(je),nn(je.base||localStorage.getItem("loadpath.base")||"HEAD~1",je.head||localStorage.getItem("loadpath.head")||"HEAD"),Hn(Y),ur(Y))}).catch(()=>{}).finally(()=>{ce||sr(!1)}),()=>{ce=!0}},[]);const Bt=L.useRef("");L.useEffect(()=>{if(!Je||!o.trim())return;let P=!1;const Y=async()=>{try{const je=await Pe.workspaceStatus(o);if(P)return;Bt.current&&je.fingerprint!==Bt.current&&!dt.current&&(pe(!0),localStorage.setItem("loadpath.dirty","1"),Ur.current()),Bt.current=je.fingerprint}catch{}};Y();const ce=window.setInterval(Y,2e3);return()=>{P=!0,window.clearInterval(ce)}},[Je,o]),L.useEffect(()=>{const P=Y=>{var Le;if((Y.metaKey||Y.ctrlKey)&&Y.key.toLowerCase()==="k"){Y.preventDefault(),lt(Ie=>!Ie);return}if(Wn.current){Y.key==="Escape"&&(Y.preventDefault(),lt(!1));return}if(Dr.current){Y.key==="Escape"&&(Y.preventDefault(),$e(!1));return}const ce=Y.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){Y.key==="Escape"&&ce.blur();return}if(Y.key==="Escape"){w(""),K(""),Ge(wt),ut(null);return}if(Y.key==="j"||Y.key==="k"){const Ie=((Le=Un.current)==null?void 0:Le.read_order)||[];if(!Ie.length)return;Y.preventDefault();const Gn=bn.current,qr=Y.key==="j"?Math.min(Ie.length-1,Gn+1):Math.max(0,Gn-1);se(qr);return}const je=Zu.find(Ie=>Ie.shortcut===Y.key);if(je&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey&&r(je.id),(Y.metaKey||Y.ctrlKey)&&Y.key==="Enter"){if(Yr.current==="settings"||Yr.current==="prs"||dt.current)return;Y.preventDefault(),Ur.current()}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[wt]);const _i=async(P,Y)=>{if(!o.trim())return;const ce=await jN(o,P,Y);ce.ok?K(ce.message):w(ce.message)},Gr=async()=>{if(p)try{const P=await Pe.exportHtml(p),Y=URL.createObjectURL(P),ce=document.createElement("a");ce.href=Y,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(Y),K("Saved HTML brief")}catch(P){w(P instanceof Error?P.message:String(P))}},fr=async P=>{if(o.trim()){He("Loading stored review…");try{const Y=await Pe.getReview(o,P);yt(Y),nn(Y.base||a,Y.head||c),E("review"),r("review");const ce=Ot.find(je=>je.id!==P);if(ce)try{$n(await Pe.reviewDiff(o,P,ce.id))}catch{$n(null)}}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},hr={selectedId:at,onSelect:Ge,nodeRoles:p==null?void 0:p.node_roles,testOverlay:gt,isolateSource:Pt,onIsolate:ut,repoPath:o,onOpenFile:_i,pinnedId:wt,onPin:qt},Yn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},...p!=null&&p.what_if?[{id:"exit-whatif",group:"Review",label:x?"Back to git-range walk":"Exit what-if walk",run:Vn}]:[],{id:"index",group:"Run",label:"Index repository",run:()=>void Br(!0)},{id:"watch",group:"Run",label:Je?"Stop watching working tree":"Watch working tree",run:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")}},{id:"tests",group:"Graph",label:gt?"Hide test overlay":"Show test overlay",run:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Gr()},...Zu.map(P=>({id:`tab-${P.id}`,group:"Tabs",label:`Go to ${P.label}`,hint:P.shortcut,run:()=>r(P.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(P=>({id:`node-${P.id}`,group:"Nodes",label:P.name,hint:io(P.type),run:()=>{Ge(P.id),r("graph")}})),...Ot.slice(0,12).map(P=>({id:`hist-${P.id}`,group:"History",label:P.title||P.id,hint:`${P.level||""} ${P.created_at||""}`.trim(),run:()=>void fr(P.id)}))],En=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[b,m,p]),co=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[b,m,p]),pr=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Fe=((p==null?void 0:p.findings)||[]).filter(P=>!P.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Zu.map(P=>{const Y=P.icon,ce=t===P.id;return d.jsxs("button",{type:"button","data-testid":P.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":P.label,onClick:()=>r(P.id),children:[d.jsx(Y,{}),d.jsx("span",{children:P.label})]},P.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:ve,onChange:P=>Sn(P.target.value),children:["dark","light"].map(P=>d.jsx("optgroup",{label:P==="dark"?"Dark":"Light",children:Ul.filter(Y=>Y.group===P).map(Y=>d.jsx("option",{value:Y.id,children:Y.label},Y.id))},P))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:N||pr}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[N?d.jsxs("div",{className:$!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","aria-valuemin":$!=null?0:void 0,"aria-valuemax":$!=null?100:void 0,"aria-valuenow":$??void 0,"data-testid":"progress",children:[d.jsx("i",{style:$!=null?{width:`${$}%`}:void 0}),d.jsx("span",{className:"sr-only",children:N})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[k.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:k.some(P=>P.path===o)?o:"",disabled:!!N,"aria-busy":G,onChange:P=>{P.target.value&&Hr(P.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),k.map(P=>d.jsxs("option",{value:P.path,children:[P.name,P.indexed?` (${P.counts.nodes})`:""]},P.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:P=>{const Y=P.target.value;s(Y),Y.trim()!==_t.current&&(_t.current="",Ft(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>$e(!0),children:d.jsx(Ep,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(kp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:P=>nn(P,c),placeholder:"base",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(kp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:P=>nn(a,P),placeholder:"head",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:he?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":he,onClick:()=>{const P=!he;pe(P),localStorage.setItem("loadpath.dirty",P?"1":"0")},children:he?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:Je?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":Je,onClick:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")},children:Je?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.what_if?"what-if · ":"",p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!N,onClick:xi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!N,onClick:()=>Br(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!N,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[R?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:R}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,ne?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:ne}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>K(""),"aria-label":"Dismiss",children:"×"})]}):null,((fo=p==null?void 0:p.index)!=null&&fo.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((ho=p==null?void 0:p.index)==null?void 0:ho.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Si=p==null?void 0:p.index)==null?void 0:Si.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(po=p==null?void 0:p.workspace)!=null&&po.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,p!=null&&p.what_if?d.jsxs("div",{className:"banner whatif","data-testid":"whatif-banner",children:[d.jsxs("span",{children:["Hypothetical walk from"," ",d.jsx("strong",{children:((go=p.node)==null?void 0:go.name)||"this node"}),". Loadpath ignored Base/Head and asked which sinks would feel this node change — not a filter of the current map."]}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-exit-whatif",onClick:Vn,children:x?"Back to git range":"Back to architecture"})]}):null,G?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:N||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":G||te,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(FN,{review:p,findings:Fe,aiNote:me,busy:!!N,tourIndex:Z,onTour:se,onAskAi:uo,onCopy:Ve,onPost:lo,onSelect:Ge,onOpenFile:_i,onExport:Gr,history:Ot,diff:oo,onReopen:fr,onWaiver:(P,Y)=>{o.trim()&&Pe.addWaiver(o,P,Y||void 0,"from review").then(ce=>{or(ce),K(`Waived ${P} in loadpath.yml`)})}}):zr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Qu,{nodes:p.nodes,edges:p.edges,onWhatIf:dr,focusPath:(mo=p.read_order[Z])==null?void 0:mo.path,...hr}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(HN,{architecture:m,busy:!!N,onReindex:()=>Br(!1),onReview:jn,onSelect:Ge,config:vi,health:$r,onSaveConfig:P=>{Pe.saveConfig(o,P).then(Y=>{or(Y),K("Wrote loadpath.yml")})},onWaiver:(P,Y,ce)=>{Pe.addWaiver(o,P,Y,ce).then(je=>{or(je),K(`Waived ${P}`)})}}):G?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(te||m!=null&&m.graph_pending)&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(ki=m==null?void 0:m.counts)!=null&&ki.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Qu,{nodes:m.nodes,edges:m.edges,onWhatIf:dr,...hr,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":b==="review","data-testid":"graph-mode-review",className:b==="review"?"active":"",onClick:()=>E("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":b==="architecture","data-testid":"graph-mode-architecture",className:b==="architecture"?"active":"",onClick:()=>E("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:gt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":gt,onClick:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")},children:"Tests"})]}),En.length?d.jsx(Qu,{nodes:En,edges:co,onWhatIf:dr,...hr}):te||m!=null&&m.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:z,onChange:P=>Fr(P.target.value,H,oe),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:M.length?"Search your repos":"owner/repo",value:H,onChange:P=>Fr(z,P.target.value,oe),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:M.map(P=>d.jsxs("option",{value:P.slug,children:[P.private?"private":"public",P.local_path?" · local":""]},P.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!N||!so(z),onClick:()=>{It(z)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!N,onClick:Vr,children:"List PRs"})]}),M.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[M.length," ",z," repositor",M.length===1?"y":"ies",z==="github"&&C.github_user?` · @${String(C.github_user)}`:"",z==="gitlab"&&C.gitlab_user?` · @${String(C.gitlab_user)}`:"",z==="bitbucket"&&C.bitbucket_user?` · ${String(C.bitbucket_user)}`:""]}):null,W.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):W.map(P=>{var Y;return d.jsxs("article",{className:"pr","data-testid":`pr-${P.number}`,children:[d.jsxs("h3",{children:["#",P.number," ",P.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${P.draft?"":"open"}`,children:P.draft?"draft":P.state}),d.jsx("span",{children:P.author}),d.jsxs("span",{children:[P.source_branch," → ",P.target_branch]}),P.loadpath?d.jsxs("span",{className:`chip ${P.loadpath.level||""}`,"data-testid":`pr-loadpath-${P.number}`,children:[((Y=P.loadpath.level)==null?void 0:Y.toUpperCase())||"REVIEWED",P.loadpath.contract_break&&P.loadpath.contract_break!=="none"?` · ${P.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:P.url,target:"_blank",rel:"noreferrer",children:["Open on ",P.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${P.number}`,onClick:()=>void bt(P),children:"Review this PR"})]})]},`${P.provider}-${P.number}`)})]}),t==="settings"&&Ne&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Et,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Ul.map(P=>d.jsxs("button",{type:"button","data-theme":P.id,className:ve===P.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${P.id}`,onClick:()=>Sn(P.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:P.label}),d.jsx("div",{className:"group",children:P.group})]},P.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:wm(),onChange:P=>NN(P.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:C.github_token_set?C.github_user?`Signed in as @${String(C.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void Wr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!ct||!C.github_oauth_ready,onClick:()=>void wi(),children:ct?"Waiting for GitHub…":"Sign in with GitHub"})})]}),ct?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:ct.user_code})," at GitHub if the browser did not fill it in."]}):null,C.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(C.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(C.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:C.gitlab_token_set?C.gitlab_user?`Signed in as @${String(C.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void Wr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Fn||!C.gitlab_oauth_ready,onClick:()=>void ao(),children:Fn?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(C.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(C.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:C.bitbucket_token_set?C.bitbucket_user?`Signed in as ${String(C.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void Wr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:On||!C.bitbucket_oauth_ready,onClick:()=>void cr(),children:On?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),C.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(C.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(C.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((Xr=C.ai)==null?void 0:Xr.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((rn=C.ai)==null?void 0:rn.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((on=C.ai)==null?void 0:on.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(f0,{open:st,actions:Yn,onClose:()=>lt(!1)}),Te?d.jsx(IN,{initialPath:o,onClose:()=>$e(!1),onSelect:P=>{if(dt.current){w("Wait for the current job to finish before switching workspace.");return}$e(!1),Hr(P)}}):null]})}function FN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:v,onOpenFile:x,onExport:y,history:m,diff:_,onReopen:k,onWaiver:j}){var E,R,w,N,A,$,F,G,q,te,ee,ne,K,C,V,W,U;const b=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),b.length?d.jsx("ul",{className:"reasons",children:b.map(M=>d.jsx("li",{children:M},M))}):null,t.what_if?d.jsx("span",{className:"chip whatif","data-testid":"whatif-chip",children:"what-if"}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Zo(M)},M)),(E=t.contract_break)!=null&&E.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>j(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(R=t.workspace)!=null&&R.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>x(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(Nm,{cards:t.deepening}),(N=(w=t.contract_break)==null?void 0:w.reasons)!=null&&N.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),($=(A=t.contract_break.sides)==null?void 0:A.rows)!=null&&$.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(F=t.auth)!=null&&F.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(G=t.suggested_tests)==null?void 0:G.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(q=t.trend)!=null&&q.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",ec(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),m.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:m.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,m.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>k(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?ec(M.created_at):""})]},M.id))]}):null,(ee=(te=t.evolution)==null?void 0:te.notes)!=null&&ee.length||(K=(ne=t.evolution)==null?void 0:ne.hotspots)!=null&&K.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((C=t.evolution)==null?void 0:C.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((V=t.evolution)==null?void 0:V.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:y,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",disabled:s||!!t.what_if,title:t.what_if?"Hypothetical walks are not posted to a pull request":void 0,onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(W=t.codeowners_reviewers)!=null&&W.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function HN({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var x;const v=t.findings.filter(y=>!y.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${ec(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(y=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y.name})," — ",(y.django_apps||[]).join(", ")||"no apps"," ·"," ",(y.owners||[]).join(", ")||"unowned"]},y.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(y=>d.jsx("div",{className:"muted",children:y},y))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:v.length})]}),v.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):v.map(y=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>y.node_id&&a(y.node_id),children:[d.jsx("span",{className:`chip ${y.severity}`,children:y.severity}),y.message]})},y.rule+y.message))]}),d.jsx(Nm,{cards:t.deepening}),(x=c==null?void 0:c.points)!=null&&x.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(y=>d.jsx("i",{className:y.level||"",title:`${y.level} · ${y.findings} findings`,style:{height:`${8+Math.min(24,(y.findings||0)*4)}px`}},y.id||y.created_at))}),Object.entries(c.contexts).map(([y,m])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y})," — last ",((_=m[m.length-1])==null?void 0:_.findings)??0," findings"]},y)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(h0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((y,m)=>m[1]-y[1]).slice(0,12).map(([y,m])=>d.jsxs("tr",{children:[d.jsx("td",{children:io(y)}),d.jsx("td",{children:m})]},y))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function Nm({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:p0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}km(Sm());u0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(ON,{})}));export{Vk as L,WN as a,BN as c,d as j,VN as l,L as r,io as t}; diff --git a/src/loadpath/static/index.html b/src/loadpath/static/index.html index a80370c..a57b62d 100644 --- a/src/loadpath/static/index.html +++ b/src/loadpath/static/index.html @@ -17,7 +17,7 @@ - + diff --git a/tests/e2e/test_ui_flows.py b/tests/e2e/test_ui_flows.py index 2a37733..9027068 100644 --- a/tests/e2e/test_ui_flows.py +++ b/tests/e2e/test_ui_flows.py @@ -559,14 +559,28 @@ def test_ui_architecture_edges_use_distinct_verticals(live_app, browser_page): wait_visible_graph(page) info = page.evaluate( """() => { + const pointsOf = (d) => { + const pts = []; + const re = /([MLQC])([^MLQC]*)/g; + let m; + while ((m = re.exec(d))) { + const nums = [...m[2].matchAll(/-?\\d+\\.?\\d*/g)].map(Number); + if (m[1] === 'Q' && nums.length >= 4) pts.push({ x: nums[2], y: nums[3] }); + else if (m[1] === 'C' && nums.length >= 6) pts.push({ x: nums[4], y: nums[5] }); + else { + for (let i = 0; i + 1 < nums.length; i += 2) pts.push({ x: nums[i], y: nums[i + 1] }); + } + } + return pts; + }; const segs = []; for (const p of document.querySelectorAll('.react-flow__edge-path')) { - const nums = [...(p.getAttribute('d') || '').matchAll(/(-?\\d+\\.?\\d*)/g)].map((mm) => Number(mm[1])); - for (let i = 0; i + 3 < nums.length; i += 2) { - if (Math.abs(nums[i] - nums[i + 2]) < 1 && Math.abs(nums[i + 1] - nums[i + 3]) > 16) { - const y0 = Math.min(nums[i + 1], nums[i + 3]); - const y1 = Math.max(nums[i + 1], nums[i + 3]); - segs.push({ x: Math.round(nums[i]), y0, y1 }); + const pts = pointsOf(p.getAttribute('d') || ''); + for (let i = 0; i + 1 < pts.length; i++) { + const a = pts[i]; + const b = pts[i + 1]; + if (Math.abs(a.x - b.x) < 1 && Math.abs(a.y - b.y) > 16) { + segs.push({ x: Math.round(a.x), y0: Math.min(a.y, b.y), y1: Math.max(a.y, b.y) }); } } } diff --git a/ui/src/graphEdges.test.ts b/ui/src/graphEdges.test.ts index 98826bb..d32a11b 100644 --- a/ui/src/graphEdges.test.ts +++ b/ui/src/graphEdges.test.ts @@ -56,8 +56,8 @@ describe("assignEdgeStepPositions", () => { ]); const edges = [edge("r1", "v1"), edge("r2", "v2")]; const steps = assignEdgeStepPositions(nodes, edges, pos); - expect(steps.get("r1->v1")).toBe(0.2); - expect(steps.get("r2->v2")).toBe(0.8); + expect(steps.get("r1->v1")).toBeCloseTo(0.2); + expect(steps.get("r2->v2")).toBeCloseTo(0.8); }); it("reuses a vertical when two bent edges are far apart in y", () => { @@ -74,6 +74,31 @@ describe("assignEdgeStepPositions", () => { expect(steps.get("r2->v2")).toBe(0.5); }); + it("puts skip-column and next-column edges on the same pixel tracks", () => { + const nodes = [ + node("r1", "django.route"), + node("r2", "django.route"), + node("u", "django.url_name"), + node("v1", "django.view"), + node("v2", "django.view"), + ]; + const pos = new Map([ + ["r1", { x: 0, y: 0 }], + ["r2", { x: 0, y: 92 }], + ["u", { x: 296, y: 0 }], + ["v1", { x: 592, y: 184 }], + ["v2", { x: 592, y: 276 }], + ]); + const edges = [edge("r1", "v1"), edge("r2", "u")]; + const steps = assignEdgeStepPositions(nodes, edges, pos); + const srcX = 208; + const nextCol = 296; + const skipCol = 592; + const xNext = srcX + (nextCol - srcX) * (steps.get("r2->u") ?? 0); + const xSkip = srcX + (skipCol - srcX) * (steps.get("r1->v1") ?? 0); + expect(Math.abs(xNext - xSkip)).toBeGreaterThan(40); + }); + it("spreads lanes between 0.2 and 0.8", () => { expect(stepForLane(0, 1)).toBe(0.5); expect(stepForLane(0, 2)).toBe(0.2); diff --git a/ui/src/graphEdges.ts b/ui/src/graphEdges.ts index 0b5ed9a..5f3323e 100644 --- a/ui/src/graphEdges.ts +++ b/ui/src/graphEdges.ts @@ -16,6 +16,8 @@ type Span = { id: string; y0: number; y1: number; + sourceX: number; + targetX: number; corridor: string; }; @@ -36,13 +38,17 @@ export function assignEdgeStepPositions( if (Math.abs(sourceY - targetY) < HORIZONTAL_EPS) continue; const sourceX = src.x + GRAPH_NODE_WIDTH; const targetX = dst.x; + const gap = targetX - sourceX; + if (gap < HORIZONTAL_EPS) continue; const y0 = Math.min(sourceY, targetY); const y1 = Math.max(sourceY, targetY); spans.push({ id: edge.id, y0, y1, - corridor: `${Math.round(sourceX / 8)}>${Math.round(targetX / 8)}`, + sourceX, + targetX, + corridor: `${Math.round(sourceX / 8)}`, }); } @@ -58,8 +64,17 @@ export function assignEdgeStepPositions( const sorted = [...group].sort((a, b) => a.y0 - b.y0 || a.y1 - b.y1 || a.id.localeCompare(b.id)); const laneOf = lanesFor(sorted); const laneCount = Math.max(0, ...laneOf.values()) + 1; + const minDx = Math.min(...sorted.map((span) => span.targetX - span.sourceX)); for (const span of sorted) { - steps.set(span.id, stepForLane(laneOf.get(span.id) ?? 0, laneCount)); + const lane = laneOf.get(span.id) ?? 0; + const t = stepForLane(lane, laneCount); + const denom = span.targetX - span.sourceX; + if (Math.abs(denom - minDx) < 0.5) { + steps.set(span.id, t); + continue; + } + const laneX = span.sourceX + minDx * t; + steps.set(span.id, Math.min(0.92, Math.max(0.08, (laneX - span.sourceX) / denom))); } } return steps; From 65621786cb5790a6571944503936dcc1f6a889ee Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 16 Aug 2026 00:49:11 +0000 Subject: [PATCH 13/16] Bend skip-column edges in the first column gap. A lone route-to-view skip used the midpoint of the whole jump, so its vertical sat on the next column's tracks. Lanes now stay in the gutter immediately after the source column. Co-authored-by: zord.lack.net --- ...BFszTRNF.js => LayeredGraph3D-XtGMK0TN.js} | 2 +- src/loadpath/static/assets/index-CXcahMbK.js | 62 +++++++++++++++++++ src/loadpath/static/assets/index-vCx0pAT3.js | 62 ------------------- src/loadpath/static/index.html | 2 +- ui/src/graphEdges.test.ts | 18 ++++++ ui/src/graphEdges.ts | 19 ++++-- 6 files changed, 96 insertions(+), 69 deletions(-) rename src/loadpath/static/assets/{LayeredGraph3D-BFszTRNF.js => LayeredGraph3D-XtGMK0TN.js} (99%) create mode 100644 src/loadpath/static/assets/index-CXcahMbK.js delete mode 100644 src/loadpath/static/assets/index-vCx0pAT3.js diff --git a/src/loadpath/static/assets/LayeredGraph3D-BFszTRNF.js b/src/loadpath/static/assets/LayeredGraph3D-XtGMK0TN.js similarity index 99% rename from src/loadpath/static/assets/LayeredGraph3D-BFszTRNF.js rename to src/loadpath/static/assets/LayeredGraph3D-XtGMK0TN.js index ed965ae..bade4f0 100644 --- a/src/loadpath/static/assets/LayeredGraph3D-BFszTRNF.js +++ b/src/loadpath/static/assets/LayeredGraph3D-XtGMK0TN.js @@ -1,4 +1,4 @@ -import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-vCx0pAT3.js";/** +import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-CXcahMbK.js";/** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT diff --git a/src/loadpath/static/assets/index-CXcahMbK.js b/src/loadpath/static/assets/index-CXcahMbK.js new file mode 100644 index 0000000..6fec883 --- /dev/null +++ b/src/loadpath/static/assets/index-CXcahMbK.js @@ -0,0 +1,62 @@ +(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function jp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Tu={exports:{}},Uo={},Lu={exports:{}},Re={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Kf;function n0(){if(Kf)return Re;Kf=1;var t=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),v=Symbol.iterator;function m(I){return I===null||typeof I!="object"?null:(I=v&&I[v]||I["@@iterator"],typeof I=="function"?I:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,j={};function b(I,z,ie){this.props=I,this.context=z,this.refs=j,this.updater=ie||_}b.prototype.isReactComponent={},b.prototype.setState=function(I,z){if(typeof I!="object"&&typeof I!="function"&&I!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,I,z,"setState")},b.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function E(){}E.prototype=b.prototype;function R(I,z,ie){this.props=I,this.context=z,this.refs=j,this.updater=ie||_}var w=R.prototype=new E;w.constructor=R,k(w,b.prototype),w.isPureReactComponent=!0;var N=Array.isArray,A=Object.prototype.hasOwnProperty,$={current:null},F={key:!0,ref:!0,__self:!0,__source:!0};function X(I,z,ie){var oe,fe={},he=null,pe=null;if(z!=null)for(oe in z.ref!==void 0&&(pe=z.ref),z.key!==void 0&&(he=""+z.key),z)A.call(z,oe)&&!F.hasOwnProperty(oe)&&(fe[oe]=z[oe]);var Z=arguments.length-2;if(Z===1)fe.children=ie;else if(1>>1,z=M[I];if(0>>1;Ia(fe,H))hea(pe,fe)?(M[I]=pe,M[he]=H,I=he):(M[I]=fe,M[oe]=H,I=oe);else if(hea(pe,H))M[I]=pe,M[he]=H,I=he;else break e}}return D}function a(M,D){var H=M.sortIndex-D.sortIndex;return H!==0?H:M.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,h=c.now();t.unstable_now=function(){return c.now()-h}}var p=[],y=[],x=1,v=null,m=3,_=!1,k=!1,j=!1,b=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(M){for(var D=o(y);D!==null;){if(D.callback===null)s(y);else if(D.startTime<=M)s(y),D.sortIndex=D.expirationTime,r(p,D);else break;D=o(y)}}function N(M){if(j=!1,w(M),!k)if(o(p)!==null)k=!0,W(A);else{var D=o(y);D!==null&&U(N,D.startTime-M)}}function A(M,D){k=!1,j&&(j=!1,E(X),X=-1),_=!0;var H=m;try{for(w(D),v=o(p);v!==null&&(!(v.expirationTime>D)||M&&!ee());){var I=v.callback;if(typeof I=="function"){v.callback=null,m=v.priorityLevel;var z=I(v.expirationTime<=D);D=t.unstable_now(),typeof z=="function"?v.callback=z:v===o(p)&&s(p),w(D)}else s(p);v=o(p)}if(v!==null)var ie=!0;else{var oe=o(y);oe!==null&&U(N,oe.startTime-D),ie=!1}return ie}finally{v=null,m=H,_=!1}}var $=!1,F=null,X=-1,q=5,te=-1;function ee(){return!(t.unstable_now()-teM||125I?(M.sortIndex=H,r(y,M),o(p)===null&&M===o(y)&&(j?(E(X),X=-1):j=!0,U(N,H-I))):(M.sortIndex=z,r(p,M),k||_||(k=!0,W(A))),M},t.unstable_shouldYield=ee,t.unstable_wrapCallback=function(M){var D=m;return function(){var H=m;m=D;try{return M.apply(this,arguments)}finally{m=H}}}})(zu)),zu}var th;function l0(){return th||(th=1,$u.exports=s0()),$u.exports}/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var nh;function a0(){if(nh)return zt;nh=1;var t=cs(),r=l0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,y=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,x={},v={};function m(e){return p.call(v,e)?!0:p.call(x,e)?!1:y.test(e)?v[e]=!0:(x[e]=!0,!1)}function _(e,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function k(e,n,i,l){if(n===null||typeof n>"u"||_(e,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function j(e,n,i,l,f,g,S){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=f,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=g,this.removeEmptyString=S}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){b[e]=new j(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];b[n]=new j(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){b[e]=new j(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){b[e]=new j(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){b[e]=new j(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){b[e]=new j(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){b[e]=new j(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){b[e]=new j(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){b[e]=new j(e,5,!1,e.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function R(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){b[e]=new j(e,1,!1,e.toLowerCase(),null,!1,!1)}),b.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){b[e]=new j(e,1,!1,e.toLowerCase(),null,!0,!0)});function w(e,n,i,l){var f=b.hasOwnProperty(n)?b[n]:null;(f!==null?f.type!==0:l||!(2T||f[S]!==g[T]){var O=` +`+f[S].replace(" at new "," at ");return e.displayName&&O.includes("")&&(O=O.replace("",e.displayName)),O}while(1<=S&&0<=T);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?z(e):""}function fe(e){switch(e.tag){case 5:return z(e.type);case 16:return z("Lazy");case 13:return z("Suspense");case 19:return z("SuspenseList");case 0:case 2:case 15:return e=oe(e.type,!1),e;case 11:return e=oe(e.type.render,!1),e;case 1:return e=oe(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case F:return"Fragment";case $:return"Portal";case q:return"Profiler";case X:return"StrictMode";case K:return"Suspense";case C:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ee:return(e.displayName||"Context")+".Consumer";case te:return(e._context.displayName||"Context")+".Provider";case ne:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case W:n=e._payload,e=e._init;try{return he(e(n))}catch{}}return null}function pe(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===X?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Z(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=se(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function ke(e){e._valueTracker||(e._valueTracker=me(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=se(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function re(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return H({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Z(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Te(e,n){n=n.checked,n!=null&&w(e,"checked",n,!1)}function $e(e,n){Te(e,n);var i=Z(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?lt(e,n.type,i):n.hasOwnProperty("defaultValue")&<(e,n.type,Z(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function st(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function lt(e,n,i){(n!=="number"||re(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var at=Array.isArray;function Xe(e,n,i,l){if(e=e.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=Je.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ot(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var xn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},oo=["Webkit","ms","Moz","O"];Object.keys(xn).forEach(function(e){oo.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),xn[n]=xn[e]})});function $n(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||xn.hasOwnProperty(e)&&xn[e]?(""+n).trim():n+"px"}function vi(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=$n(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,f):e[i]=f}}var or=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function $r(e,n){if(n){if(or[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function zn(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var zr=null;function sr(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var lr=null,Ft=null,ct=null;function Dn(e){if(e=Po(e)){if(typeof lr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=Rs(n),lr(e.stateNode,e.type,n))}}function On(e){Ft?ct?ct.push(e):ct=[e]:Ft=e}function wn(){if(Ft){var e=Ft,n=ct;if(ct=Ft=null,Dn(e),n)for(e=0;e>>=0,e===0?32:31-(uo(e)/Ur|0)|0}var Wn=64,Un=4194304;function bn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Bt(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,f=e.suspendedLanes,g=e.pingedLanes,S=i&268435455;if(S!==0){var T=S&~f;T!==0?l=bn(T):(g&=S,g!==0&&(l=bn(g)))}else S=i&~f,S!==0?l=bn(S):g!==0&&(l=bn(g));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,g=n&-n,f>=g||f===16&&(g&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function En(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Et(n),e[n]=i}function co(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=_o),Bc=" ",Vc=!1;function Wc(e,n){switch(e){case"keyup":return Qm.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Uc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var bi=!1;function Jm(e,n){switch(e){case"compositionend":return Uc(n);case"keypress":return n.which!==32?null:(Vc=!0,Bc);case"textInput":return e=n.data,e===Bc&&Vc?null:e;default:return null}}function ey(e,n){if(bi)return e==="compositionend"||!ha&&Wc(e,n)?(e=$c(),_s=la=gr=null,bi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Zc(i)}}function ed(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?ed(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function td(){for(var e=window,n=re();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=re(e.document)}return n}function ma(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function uy(e){var n=td(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&ed(i.ownerDocument.documentElement,i)){if(l!==null&&ma(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var f=i.textContent.length,g=Math.min(l.start,f);l=l.end===void 0?g:Math.min(l.end,f),!e.extend&&g>l&&(f=l,l=g,g=f),f=Jc(i,g);var S=Jc(i,l);f&&S&&(e.rangeCount!==1||e.anchorNode!==f.node||e.anchorOffset!==f.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),e.removeAllRanges(),g>l?(e.addRange(n),e.extend(S.node,S.offset)):(n.setEnd(S.node,S.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,Ei=null,ya=null,jo=null,va=!1;function nd(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;va||Ei==null||Ei!==re(l)||(l=Ei,"selectionStart"in l&&ma(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),jo&&No(jo,l)||(jo=l,l=Ms(ya,"onSelect"),0Ri||(e.current=Pa[Ri],Pa[Ri]=null,Ri--)}function Be(e,n){Ri++,Pa[Ri]=e.current,e.current=n}var xr={},St=vr(xr),Rt=vr(!1),Qr=xr;function Ti(e,n){var i=e.type.contextTypes;if(!i)return xr;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in i)f[g]=n[g];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=f),f}function Tt(e){return e=e.childContextTypes,e!=null}function Ts(){Ue(Rt),Ue(St)}function yd(e,n,i){if(St.current!==xr)throw Error(o(168));Be(St,n),Be(Rt,i)}function vd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,pe(e)||"Unknown",f));return H({},i,l)}function Ls(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||xr,Qr=St.current,Be(St,e),Be(Rt,Rt.current),!0}function xd(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=vd(e,n,Qr),l.__reactInternalMemoizedMergedChildContext=e,Ue(Rt),Ue(St),Be(St,e)):Ue(Rt),Be(Rt,i)}var qn=null,As=!1,Ia=!1;function wd(e){qn===null?qn=[e]:qn.push(e)}function _y(e){As=!0,wd(e)}function wr(){if(!Ia&&qn!==null){Ia=!0;var e=0,n=Fe;try{var i=qn;for(Fe=1;e>=S,f-=S,Kn=1<<32-Et(n)+f|i<Ce?(pt=Ee,Ee=null):pt=Ee.sibling;var Oe=le(G,Ee,Q[Ce],de);if(Oe===null){Ee===null&&(Ee=pt);break}e&&Ee&&Oe.alternate===null&&n(G,Ee),B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe,Ee=pt}if(Ce===Q.length)return i(G,Ee),Ge&&Jr(G,Ce),_e;if(Ee===null){for(;CeCe?(pt=Ee,Ee=null):pt=Ee.sibling;var Mr=le(G,Ee,Oe.value,de);if(Mr===null){Ee===null&&(Ee=pt);break}e&&Ee&&Mr.alternate===null&&n(G,Ee),B=g(Mr,B,Ce),be===null?_e=Mr:be.sibling=Mr,be=Mr,Ee=pt}if(Oe.done)return i(G,Ee),Ge&&Jr(G,Ce),_e;if(Ee===null){for(;!Oe.done;Ce++,Oe=Q.next())Oe=ue(G,Oe.value,de),Oe!==null&&(B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return Ge&&Jr(G,Ce),_e}for(Ee=l(G,Ee);!Oe.done;Ce++,Oe=Q.next())Oe=ge(Ee,G,Ce,Oe.value,de),Oe!==null&&(e&&Oe.alternate!==null&&Ee.delete(Oe.key===null?Ce:Oe.key),B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return e&&Ee.forEach(function(t0){return n(G,t0)}),Ge&&Jr(G,Ce),_e}function et(G,B,Q,de){if(typeof Q=="object"&&Q!==null&&Q.type===F&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case A:e:{for(var _e=Q.key,be=B;be!==null;){if(be.key===_e){if(_e=Q.type,_e===F){if(be.tag===7){i(G,be.sibling),B=f(be,Q.props.children),B.return=G,G=B;break e}}else if(be.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===W&&bd(_e)===be.type){i(G,be.sibling),B=f(be,Q.props),B.ref=Io(G,be,Q),B.return=G,G=B;break e}i(G,be);break}else n(G,be);be=be.sibling}Q.type===F?(B=li(Q.props.children,G.mode,de,Q.key),B.return=G,G=B):(de=ul(Q.type,Q.key,Q.props,null,G.mode,de),de.ref=Io(G,B,Q),de.return=G,G=de)}return S(G);case $:e:{for(be=Q.key;B!==null;){if(B.key===be)if(B.tag===4&&B.stateNode.containerInfo===Q.containerInfo&&B.stateNode.implementation===Q.implementation){i(G,B.sibling),B=f(B,Q.children||[]),B.return=G,G=B;break e}else{i(G,B);break}else n(G,B);B=B.sibling}B=Cu(Q,G.mode,de),B.return=G,G=B}return S(G);case W:return be=Q._init,et(G,B,be(Q._payload),de)}if(at(Q))return xe(G,B,Q,de);if(D(Q))return we(G,B,Q,de);Os(G,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"?(Q=""+Q,B!==null&&B.tag===6?(i(G,B.sibling),B=f(B,Q),B.return=G,G=B):(i(G,B),B=Eu(Q,G.mode,de),B.return=G,G=B),S(G)):i(G,B)}return et}var zi=Ed(!0),Cd=Ed(!1),Fs=vr(null),Hs=null,Di=null,za=null;function Da(){za=Di=Hs=null}function Oa(e){var n=Fs.current;Ue(Fs),e._currentValue=n}function Fa(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function Oi(e,n){Hs=e,za=Di=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Lt=!0),e.firstContext=null)}function Zt(e){var n=e._currentValue;if(za!==e)if(e={context:e,memoizedValue:n,next:null},Di===null){if(Hs===null)throw Error(o(308));Di=e,Hs.dependencies={lanes:0,firstContext:e}}else Di=Di.next=e;return n}var ei=null;function Ha(e){ei===null?ei=[e]:ei.push(e)}function Md(e,n,i,l){var f=n.interleaved;return f===null?(i.next=i,Ha(n)):(i.next=f.next,f.next=i),n.interleaved=i,Zn(e,l)}function Zn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var _r=!1;function Ba(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Pd(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Jn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Sr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(ze&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,Zn(e,i)}return f=l.interleaved,f===null?(n.next=n,Ha(l)):(n.next=f.next,f.next=n),l.interleaved=n,Zn(e,i)}function Bs(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}function Id(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var S={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?f=g=S:g=g.next=S,i=i.next}while(i!==null);g===null?f=g=n:g=g.next=n}else f=g=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function Vs(e,n,i,l){var f=e.updateQueue;_r=!1;var g=f.firstBaseUpdate,S=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,J=O.next;O.next=null,S===null?g=J:S.next=J,S=O;var ae=e.alternate;ae!==null&&(ae=ae.updateQueue,T=ae.lastBaseUpdate,T!==S&&(T===null?ae.firstBaseUpdate=J:T.next=J,ae.lastBaseUpdate=O))}if(g!==null){var ue=f.baseState;S=0,ae=J=O=null,T=g;do{var le=T.lane,ge=T.eventTime;if((l&le)===le){ae!==null&&(ae=ae.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var xe=e,we=T;switch(le=n,ge=i,we.tag){case 1:if(xe=we.payload,typeof xe=="function"){ue=xe.call(ge,ue,le);break e}ue=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=we.payload,le=typeof xe=="function"?xe.call(ge,ue,le):xe,le==null)break e;ue=H({},ue,le);break e;case 2:_r=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,le=f.effects,le===null?f.effects=[T]:le.push(T))}else ge={eventTime:ge,lane:le,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ae===null?(J=ae=ge,O=ue):ae=ae.next=ge,S|=le;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;le=T,T=le.next,le.next=null,f.lastBaseUpdate=le,f.shared.pending=null}}while(!0);if(ae===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=J,f.lastBaseUpdate=ae,n=f.shared.interleaved,n!==null){f=n;do S|=f.lane,f=f.next;while(f!==n)}else g===null&&(f.shared.lanes=0);ri|=S,e.lanes=S,e.memoizedState=ue}}function Rd(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=Xa.transition;Xa.transition={};try{e(!1),n()}finally{Fe=i,Xa.transition=l}}function Qd(){return Jt().memoizedState}function jy(e,n,i){var l=br(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},Zd(e))Jd(n,i);else if(i=Md(e,n,i,l),i!==null){var f=Mt();dn(i,e,l,f),ef(i,n,l)}}function by(e,n,i){var l=br(e),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(Zd(e))Jd(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,T=g(S,i);if(f.hasEagerState=!0,f.eagerState=T,sn(T,S)){var O=n.interleaved;O===null?(f.next=f,Ha(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=Md(e,n,f,l),i!==null&&(f=Mt(),dn(i,e,l,f),ef(i,n,l))}}function Zd(e){var n=e.alternate;return e===Ke||n!==null&&n===Ke}function Jd(e,n){Ao=Ys=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function ef(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}var qs={readContext:Zt,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},Ey={readContext:Zt,useCallback:function(e,n){return Pn().memoizedState=[e,n===void 0?null:n],e},useContext:Zt,useEffect:Vd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Xs(4194308,4,Yd.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Xs(4194308,4,e,n)},useInsertionEffect:function(e,n){return Xs(4,2,e,n)},useMemo:function(e,n){var i=Pn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=Pn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=jy.bind(null,Ke,e),[l.memoizedState,e]},useRef:function(e){var n=Pn();return e={current:e},n.memoizedState=e},useState:Hd,useDebugValue:eu,useDeferredValue:function(e){return Pn().memoizedState=e},useTransition:function(){var e=Hd(!1),n=e[0];return e=Ny.bind(null,e[1]),Pn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=Ke,f=Pn();if(Ge){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ht===null)throw Error(o(349));(ni&30)!==0||$d(l,n,i)}f.memoizedState=i;var g={value:i,getSnapshot:n};return f.queue=g,Vd(Dd.bind(null,l,g,e),[e]),l.flags|=2048,Do(9,zd.bind(null,l,g,i,n),void 0,null),i},useId:function(){var e=Pn(),n=ht.identifierPrefix;if(Ge){var i=Qn,l=Kn;i=(l&~(1<<32-Et(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=$o++,0<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=S.createElement(i,{is:l.is}):(e=S.createElement(i),i==="select"&&(S=e,l.multiple?S.multiple=!0:l.size&&(S.size=l.size))):e=S.createElementNS(e,i),e[Cn]=n,e[Mo]=l,_f(e,n,!1,!1),n.stateNode=e;e:{switch(S=zn(i,l),i){case"dialog":We("cancel",e),We("close",e),f=l;break;case"iframe":case"object":case"embed":We("load",e),f=l;break;case"video":case"audio":for(f=0;fWi&&(n.flags|=128,l=!0,Oo(g,!1),n.lanes=4194304)}else{if(!l)if(e=Ws(S),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Oo(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Ge)return Nt(n),null}else 2*Ve()-g.renderingStartTime>Wi&&i!==1073741824&&(n.flags|=128,l=!0,Oo(g,!1),n.lanes=4194304);g.isBackwards?(S.sibling=n.child,n.child=S):(i=g.last,i!==null?i.sibling=S:n.child=S,g.last=S)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(Nt(n),null);case 22:case 23:return Nu(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Yt&1073741824)!==0&&(Nt(n),n.subtreeFlags&6&&(n.flags|=8192)):Nt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function Ay(e,n){switch(Ta(n),n.tag){case 1:return Tt(n.type)&&Ts(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Fi(),Ue(Rt),Ue(St),Ya(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Wa(n),null;case 13:if(Ue(qe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));$i()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Fi(),null;case 10:return Oa(n.type._context),null;case 22:case 23:return Nu(),null;case 24:return null;default:return null}}var Js=!1,jt=!1,$y=typeof WeakSet=="function"?WeakSet:Set,ye=null;function Bi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Ze(e,n,l)}else i.current=null}function fu(e,n,i){try{i()}catch(l){Ze(e,n,l)}}var Nf=!1;function zy(e,n){if(Na=xs,e=td(),ma(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,g=l.focusNode;l=l.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var S=0,T=-1,O=-1,J=0,ae=0,ue=e,le=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=S+f),ue!==g||l!==0&&ue.nodeType!==3||(O=S+l),ue.nodeType===3&&(S+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)le=ue,ue=ge;for(;;){if(ue===e)break t;if(le===i&&++J===f&&(T=S),le===g&&++ae===l&&(O=S),(ge=ue.nextSibling)!==null)break;ue=le,le=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(ja={focusedElem:e,selectionRange:i},xs=!1,ye=n;ye!==null;)if(n=ye,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ye=e;else for(;ye!==null;){n=ye;try{var xe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var we=xe.memoizedProps,et=xe.memoizedState,G=n.stateNode,B=G.getSnapshotBeforeUpdate(n.elementType===n.type?we:an(n.type,we),et);G.__reactInternalSnapshotBeforeUpdate=B}break;case 3:var Q=n.stateNode.containerInfo;Q.nodeType===1?Q.textContent="":Q.nodeType===9&&Q.documentElement&&Q.removeChild(Q.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(de){Ze(n,n.return,de)}if(e=n.sibling,e!==null){e.return=n.return,ye=e;break}ye=n.return}return xe=Nf,Nf=!1,xe}function Fo(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&e)===e){var g=f.destroy;f.destroy=void 0,g!==void 0&&fu(n,i,g)}f=f.next}while(f!==l)}}function el(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function hu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function jf(e){var n=e.alternate;n!==null&&(e.alternate=null,jf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[Cn],delete n[Mo],delete n[Ma],delete n[xy],delete n[wy])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function bf(e){return e.tag===5||e.tag===3||e.tag===4}function Ef(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||bf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function pu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=Is));else if(l!==4&&(e=e.child,e!==null))for(pu(e,n,i),e=e.sibling;e!==null;)pu(e,n,i),e=e.sibling}function gu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(gu(e,n,i),e=e.sibling;e!==null;)gu(e,n,i),e=e.sibling}var vt=null,un=!1;function kr(e,n,i){for(i=i.child;i!==null;)Cf(e,n,i),i=i.sibling}function Cf(e,n,i){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(Vn,i)}catch{}switch(i.tag){case 5:jt||Bi(i,n);case 6:var l=vt,f=un;vt=null,kr(e,n,i),vt=l,un=f,vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):vt.removeChild(i.stateNode));break;case 18:vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?Ca(e.parentNode,i):e.nodeType===1&&Ca(e,i),vo(e)):Ca(vt,i.stateNode));break;case 4:l=vt,f=un,vt=i.stateNode.containerInfo,un=!0,kr(e,n,i),vt=l,un=f;break;case 0:case 11:case 14:case 15:if(!jt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var g=f,S=g.destroy;g=g.tag,S!==void 0&&((g&2)!==0||(g&4)!==0)&&fu(i,n,S),f=f.next}while(f!==l)}kr(e,n,i);break;case 1:if(!jt&&(Bi(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Ze(i,n,T)}kr(e,n,i);break;case 21:kr(e,n,i);break;case 22:i.mode&1?(jt=(l=jt)||i.memoizedState!==null,kr(e,n,i),jt=l):kr(e,n,i);break;default:kr(e,n,i)}}function Mf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new $y),n.forEach(function(l){var f=Yy.bind(null,e,l);i.has(l)||(i.add(l),l.then(f,f))})}}function cn(e,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=S),l&=~g}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Oy(l/1960))-l,10e?16:e,jr===null)var l=!1;else{if(e=jr,jr=null,ol=0,(ze&6)!==0)throw Error(o(331));var f=ze;for(ze|=4,ye=e.current;ye!==null;){var g=ye,S=g.child;if((ye.flags&16)!==0){var T=g.deletions;if(T!==null){for(var O=0;OVe()-vu?oi(e,0):yu|=i),$t(e,n)}function Bf(e,n){n===0&&((e.mode&1)===0?n=1:(n=Un,Un<<=1,(Un&130023424)===0&&(Un=4194304)));var i=Mt();e=Zn(e,n),e!==null&&(En(e,n,i),$t(e,i))}function Uy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Bf(e,i)}function Yy(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Bf(e,i)}var Vf;Vf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Rt.current)Lt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Lt=!1,Ty(e,n,i);Lt=(e.flags&131072)!==0}else Lt=!1,Ge&&(n.flags&1048576)!==0&&_d(n,zs,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Zs(e,n),e=n.pendingProps;var f=Ti(n,St.current);Oi(n,i),f=qa(null,n,l,e,f,i);var g=Ka();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Tt(l)?(g=!0,Ls(n)):g=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Ba(n),f.updater=Ks,n.stateNode=f,f._reactInternals=n,nu(n,l,e,i),n=su(null,n,l,!0,g,i)):(n.tag=0,Ge&&g&&Ra(n),Ct(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Zs(e,n),e=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=Gy(l),e=an(l,e),f){case 0:n=ou(null,n,l,e,i);break e;case 1:n=gf(null,n,l,e,i);break e;case 11:n=cf(null,n,l,e,i);break e;case 14:n=df(null,n,l,an(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),ou(e,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),gf(e,n,l,f,i);case 3:e:{if(mf(n),e===null)throw Error(o(387));l=n.pendingProps,g=n.memoizedState,f=g.element,Pd(e,n),Vs(n,l,null,i);var S=n.memoizedState;if(l=S.element,g.isDehydrated)if(g={element:l,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){f=Hi(Error(o(423)),n),n=yf(e,n,l,i,f);break e}else if(l!==f){f=Hi(Error(o(424)),n),n=yf(e,n,l,i,f);break e}else for(Ut=yr(n.stateNode.containerInfo.firstChild),Wt=n,Ge=!0,ln=null,i=Cd(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if($i(),l===f){n=er(e,n,i);break e}Ct(e,n,l,i)}n=n.child}return n;case 5:return Td(n),e===null&&Aa(n),l=n.type,f=n.pendingProps,g=e!==null?e.memoizedProps:null,S=f.children,ba(l,f)?S=null:g!==null&&ba(l,g)&&(n.flags|=32),pf(e,n),Ct(e,n,S,i),n.child;case 6:return e===null&&Aa(n),null;case 13:return vf(e,n,i);case 4:return Va(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=zi(n,null,l,i):Ct(e,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),cf(e,n,l,f,i);case 7:return Ct(e,n,n.pendingProps,i),n.child;case 8:return Ct(e,n,n.pendingProps.children,i),n.child;case 12:return Ct(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,g=n.memoizedProps,S=f.value,Be(Fs,l._currentValue),l._currentValue=S,g!==null)if(sn(g.value,S)){if(g.children===f.children&&!Rt.current){n=er(e,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var T=g.dependencies;if(T!==null){S=g.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(g.tag===1){O=Jn(-1,i&-i),O.tag=2;var J=g.updateQueue;if(J!==null){J=J.shared;var ae=J.pending;ae===null?O.next=O:(O.next=ae.next,ae.next=O),J.pending=O}}g.lanes|=i,O=g.alternate,O!==null&&(O.lanes|=i),Fa(g.return,i,n),T.lanes|=i;break}O=O.next}}else if(g.tag===10)S=g.type===n.type?null:g.child;else if(g.tag===18){if(S=g.return,S===null)throw Error(o(341));S.lanes|=i,T=S.alternate,T!==null&&(T.lanes|=i),Fa(S,i,n),S=g.sibling}else S=g.child;if(S!==null)S.return=g;else for(S=g;S!==null;){if(S===n){S=null;break}if(g=S.sibling,g!==null){g.return=S.return,S=g;break}S=S.return}g=S}Ct(e,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,Oi(n,i),f=Zt(f),l=l(f),n.flags|=1,Ct(e,n,l,i),n.child;case 14:return l=n.type,f=an(l,n.pendingProps),f=an(l.type,f),df(e,n,l,f,i);case 15:return ff(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),Zs(e,n),n.tag=1,Tt(l)?(e=!0,Ls(n)):e=!1,Oi(n,i),nf(n,l,f),nu(n,l,f,i),su(null,n,l,!0,e,i);case 19:return wf(e,n,i);case 22:return hf(e,n,i)}throw Error(o(156,n.tag))};function Wf(e,n){return Hr(e,n)}function Xy(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tn(e,n,i,l){return new Xy(e,n,i,l)}function bu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Gy(e){if(typeof e=="function")return bu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ne)return 11;if(e===V)return 14}return 2}function Cr(e,n){var i=e.alternate;return i===null?(i=tn(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function ul(e,n,i,l,f,g){var S=2;if(l=e,typeof e=="function")bu(e)&&(S=1);else if(typeof e=="string")S=5;else e:switch(e){case F:return li(i.children,f,g,n);case X:S=8,f|=8;break;case q:return e=tn(12,i,n,f|2),e.elementType=q,e.lanes=g,e;case K:return e=tn(13,i,n,f),e.elementType=K,e.lanes=g,e;case C:return e=tn(19,i,n,f),e.elementType=C,e.lanes=g,e;case U:return cl(i,f,g,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case te:S=10;break e;case ee:S=9;break e;case ne:S=11;break e;case V:S=14;break e;case W:S=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=tn(S,i,n,f),n.elementType=e,n.type=l,n.lanes=g,n}function li(e,n,i,l){return e=tn(7,e,l,n),e.lanes=i,e}function cl(e,n,i,l){return e=tn(22,e,l,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function Eu(e,n,i){return e=tn(6,e,null,n),e.lanes=i,e}function Cu(e,n,i){return n=tn(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function qy(e,n,i,l,f){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Yn(0),this.expirationTimes=Yn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Yn(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Mu(e,n,i,l,f,g,S,T,O){return e=new qy(e,n,i,T,O),n===1?(n=1,g===!0&&(n|=8)):n=0,g=tn(3,null,null,n),e.current=g,g.stateNode=e,g.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ba(g),e}function Ky(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),Au.exports=a0(),Au.exports}var ih;function u0(){if(ih)return yl;ih=1;var t=bp();return yl.createRoot=t.createRoot,yl.hydrateRoot=t.hydrateRoot,yl}var c0=u0();function Ep(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Ae(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(Ep(s,o.statusText||"Request failed"))}return o.json()}const d0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Pe={health:()=>Ae("/api/health"),settings:()=>Ae("/api/settings"),saveSettings:t=>{const r={...t};for(const o of d0)r[o]===""&&delete r[o];return Ae("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ae("/api/repos"),browse:t=>Ae(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ae(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ae("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ae(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Ae(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:(t,r=!0)=>Ae(`/api/architecture?repo_path=${encodeURIComponent(t)}&graph=${r?"1":"0"}`),architectureGraph:t=>Ae(`/api/architecture/graph?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Ae("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Ae("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Ae("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Ae("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Ae("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Ae(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open",s)=>Ae("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o,repo_path:s||null})}),scmRepos:t=>Ae(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ae("/api/oauth/status"),githubOAuthStart:()=>Ae("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ae("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ae("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Ae("/api/oauth/gitlab/start"),oauthDisconnect:t=>Ae("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ae("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})}),reviews:t=>Ae(`/api/reviews?repo_path=${encodeURIComponent(t)}`),getReview:(t,r)=>Ae(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(t)}`),reviewDiff:(t,r,o)=>Ae(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(t)}&other=${encodeURIComponent(o)}`),config:t=>Ae(`/api/config?repo_path=${encodeURIComponent(t)}`),saveConfig:(t,r)=>Ae("/api/config",{method:"PUT",body:JSON.stringify({repo_path:t,...r})}),addWaiver:(t,r,o,s)=>Ae("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:t,rule:r,node:o||null,reason:s||""})}),marks:(t,r)=>Ae(`/api/marks?repo_path=${encodeURIComponent(t)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:t=>Ae(`/api/architecture/health?repo_path=${encodeURIComponent(t)}`),workspaceStatus:t=>Ae(`/api/workspace/status?repo_path=${encodeURIComponent(t)}`),openEditor:(t,r,o,s)=>Ae("/api/open",{method:"POST",body:JSON.stringify({repo_path:t,path:r,line:o||null,editor:s||null})}),exportHtml:t=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:t})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(Ep(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(t,r,o,s)=>Ae("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:t,edges:r,source_id:o,target_id:s||null})})};function f0(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):t}function h0({open:t,actions:r,onClose:o}){const[s,a]=L.useState(""),[u,c]=L.useState(0),h=L.useRef(null),p=L.useMemo(()=>f0(r,s),[r,s]);if(L.useEffect(()=>{if(!t)return;a(""),c(0);const v=window.setTimeout(()=>{var m;return(m=h.current)==null?void 0:m.focus()},0);return()=>window.clearTimeout(v)},[t]),L.useEffect(()=>{c(0)},[s]),!t)return null;const y=p[u],x=v=>{v&&(o(),v.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:v=>{v.target===v.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:v=>a(v.target.value),onKeyDown:v=>{v.key==="Escape"?(v.preventDefault(),o()):v.key==="ArrowDown"?(v.preventDefault(),c(m=>Math.min(p.length-1,m+1))):v.key==="ArrowUp"?(v.preventDefault(),c(m=>Math.max(0,m-1))):v.key==="Enter"&&(v.preventDefault(),x(y))}}),d.jsxs("ul",{children:[p.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,p.slice(0,40).map((v,m)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:m===u?"active":"",onMouseEnter:()=>c(m),onClick:()=>x(v),children:[d.jsx("span",{children:v.label}),v.hint?d.jsx("span",{className:"muted",children:v.hint}):null]})},v.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function p0({config:t,busy:r,onSave:o,onWaiver:s}){const[a,u]=L.useState(t),[c,h]=L.useState(t.available_rules[0]||""),[p,y]=L.useState(""),[x,v]=L.useState("");L.useEffect(()=>{u(t)},[t]);const m=Object.entries(a.contexts||{}),_=(R,w,N)=>{const A=a.contexts[R];if(!A)return;const $=F=>F.split(",").map(X=>X.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[R]:{...A,[w]:w==="name"?N:$(N)}}})},k=(R,w)=>{const N=w.trim();if(!N||N===R)return;const{[R]:A,...$}=a.contexts;A&&u({...a,contexts:{...$,[N]:{...A,name:N}}})},j=()=>{let R=1;for(;a.contexts[`context-${R}`];)R+=1;const w=`context-${R}`;u({...a,contexts:{...a.contexts,[w]:{name:w,django_apps:[],react:[],public_api:[],owners:[]}}})},b=R=>{const{[R]:w,...N}=a.contexts;u({...a,contexts:N})},E=R=>{const w=a.rules.includes(R);u({...a,rules:w?a.rules.filter(N=>N!==R):[...a.rules,R]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),m.map(([R,w])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:R})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:R,"data-testid":`config-context-name-${R}`,onBlur:N=>k(R,N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(w.django_apps||[]).join(", "),onChange:N=>_(R,"django_apps",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(w.react||[]).join(", "),onChange:N=>_(R,"react",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(w.public_api||[]).join(", "),onChange:N=>_(R,"public_api",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(w.owners||[]).join(", "),onChange:N=>_(R,"owners",N.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>b(R),children:"Remove context"})]},R)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:j,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(R),onChange:()=>E(R)}),R]},R))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((R,w)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:R.rule}),R.node?` · ${R.node}`:"",R.reason?` — ${R.reason}`:""]},`${R.rule}:${R.node}:${w}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:R=>h(R.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsx("option",{value:R,children:R},R))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:R=>y(R.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:x,onChange:R=>v(R.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,x),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function Zo(t){return t.replaceAll("_"," ")}function g0(t){return t.replaceAll("_"," ")}function io(t){return t.split(".").pop()||t}function ec(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function m0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Tr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function yi({className:t,children:r}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function y0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function v0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function x0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function w0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function _0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function Cp({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function S0({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const k0="modulepreload",N0=function(t,r){return new URL(t,r).href},oh={},j0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(x){return Promise.all(x.map(v=>Promise.resolve(v).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),y=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(x=>{if(x=N0(x,s),x in oh)return;oh[x]=!0;const v=x.endsWith(".css"),m=v?'[rel="stylesheet"]':"";if(!!s)for(let j=h.length-1;j>=0;j--){const b=h[j];if(b.href===x&&(!v||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${x}"]${m}`))return;const k=document.createElement("link");if(k.rel=v?"stylesheet":k0,v||(k.as="script"),k.crossOrigin="",k.href=x,y&&k.setAttribute("nonce",y),document.head.appendChild(k),v)return new Promise((j,b)=>{k.addEventListener("load",j),k.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${x}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function nt(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Yl(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}Ml.prototype=Yl.prototype={constructor:Ml,on:function(t,r){var o=this._,s=E0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),lh.hasOwnProperty(r)?{space:lh[r],local:t}:t}function M0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===tc&&r.documentElement.namespaceURI===tc?r.createElement(t):r.createElementNS(o,t)}}function P0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Mp(t){var r=Xl(t);return(r.local?P0:M0)(r)}function I0(){}function gc(t){return t==null?I0:function(){return this.querySelector(t)}}function R0(t){typeof t!="function"&&(t=gc(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=w&&(w=R+1);!(A=b[w])&&++w=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function rv(t){t||(t=iv);function r(v,m){return v&&m?t(v.__data__,m.__data__):!v-!m}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function ov(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function sv(){return Array.from(this)}function lv(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?vv:typeof r=="function"?wv:xv)(t,r,o??"")):Ki(this.node(),t)}function Ki(t,r){return t.style.getPropertyValue(r)||Lp(t).getComputedStyle(t,null).getPropertyValue(r)}function Sv(t){return function(){delete this[t]}}function kv(t,r){return function(){this[t]=r}}function Nv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function jv(t,r){return arguments.length>1?this.each((r==null?Sv:typeof r=="function"?Nv:kv)(t,r)):this.node()[t]}function Ap(t){return t.trim().split(/^|\s+/)}function mc(t){return t.classList||new $p(t)}function $p(t){this._node=t,this._names=Ap(t.getAttribute("class")||"")}$p.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function zp(t,r){for(var o=mc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function Jv(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function nc(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:y,dispatch:x}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:y,enumerable:!0,configurable:!0},_:{value:x}})}nc.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function ux(t){return!t.ctrlKey&&!t.button}function cx(){return this.parentNode}function dx(t,r){return r??{x:t.x,y:t.y}}function fx(){return navigator.maxTouchPoints||"ontouchstart"in this}function Vp(){var t=ux,r=cx,o=dx,s=fx,a={},u=Yl("start","drag","end"),c=0,h,p,y,x,v=0;function m(N){N.on("mousedown.drag",_).filter(s).on("touchstart.drag",b).on("touchmove.drag",E,ax).on("touchend.drag touchcancel.drag",R).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(N,A){if(!(x||!t.call(this,N,A))){var $=w(this,r.call(this,N,A),N,A,"mouse");$&&(Xt(N.view).on("mousemove.drag",k,Jo).on("mouseup.drag",j,Jo),Hp(N.view),Du(N),y=!1,h=N.clientX,p=N.clientY,$("start",N))}}function k(N){if(Gi(N),!y){var A=N.clientX-h,$=N.clientY-p;y=A*A+$*$>v}a.mouse("drag",N)}function j(N){Xt(N.view).on("mousemove.drag mouseup.drag",null),Bp(N.view,y),Gi(N),a.mouse("end",N)}function b(N,A){if(t.call(this,N,A)){var $=N.changedTouches,F=r.call(this,N,A),X=$.length,q,te;for(q=0;q>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?xl(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?xl(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=px.exec(t))?new Dt(r[1],r[2],r[3],1):(r=gx.exec(t))?new Dt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=mx.exec(t))?xl(r[1],r[2],r[3],r[4]):(r=yx.exec(t))?xl(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=vx.exec(t))?ph(r[1],r[2]/100,r[3]/100,1):(r=xx.exec(t))?ph(r[1],r[2]/100,r[3]/100,r[4]):ah.hasOwnProperty(t)?dh(ah[t]):t==="transparent"?new Dt(NaN,NaN,NaN,0):null}function dh(t){return new Dt(t>>16&255,t>>8&255,t&255,1)}function xl(t,r,o,s){return s<=0&&(t=r=o=NaN),new Dt(t,r,o,s)}function Sx(t){return t instanceof fs||(t=fi(t)),t?(t=t.rgb(),new Dt(t.r,t.g,t.b,t.opacity)):new Dt}function rc(t,r,o,s){return arguments.length===1?Sx(t):new Dt(t,r,o,s??1)}function Dt(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}yc(Dt,rc,Wp(fs,{brighter(t){return t=t==null?Al:Math.pow(Al,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?es:Math.pow(es,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Dt(ci(this.r),ci(this.g),ci(this.b),$l(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:fh,formatHex:fh,formatHex8:kx,formatRgb:hh,toString:hh}));function fh(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}`}function kx(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}${ui((isNaN(this.opacity)?1:this.opacity)*255)}`}function hh(){const t=$l(this.opacity);return`${t===1?"rgb(":"rgba("}${ci(this.r)}, ${ci(this.g)}, ${ci(this.b)}${t===1?")":`, ${t})`}`}function $l(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ci(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ui(t){return t=ci(t),(t<16?"0":"")+t.toString(16)}function ph(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new hn(t,r,o,s)}function Up(t){if(t instanceof hn)return new hn(t.h,t.s,t.l,t.opacity);if(t instanceof fs||(t=fi(t)),!t)return new hn;if(t instanceof hn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new hn(c,h,p,t.opacity)}function Nx(t,r,o,s){return arguments.length===1?Up(t):new hn(t,r,o,s??1)}function hn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}yc(hn,Nx,Wp(fs,{brighter(t){return t=t==null?Al:Math.pow(Al,t),new hn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?es:Math.pow(es,t),new hn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Dt(Ou(t>=240?t-240:t+120,a,s),Ou(t,a,s),Ou(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new hn(gh(this.h),wl(this.s),wl(this.l),$l(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 t=$l(this.opacity);return`${t===1?"hsl(":"hsla("}${gh(this.h)}, ${wl(this.s)*100}%, ${wl(this.l)*100}%${t===1?")":`, ${t})`}`}}));function gh(t){return t=(t||0)%360,t<0?t+360:t}function wl(t){return Math.max(0,Math.min(1,t||0))}function Ou(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const vc=t=>()=>t;function jx(t,r){return function(o){return t+o*r}}function bx(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function Ex(t){return(t=+t)==1?Yp:function(r,o){return o-r?bx(r,o,t):vc(isNaN(r)?o:r)}}function Yp(t,r){var o=r-t;return o?jx(t,o):vc(isNaN(t)?r:t)}const zl=(function t(r){var o=Ex(r);function s(a,u){var c=o((a=rc(a)).r,(u=rc(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),y=Yp(a.opacity,u.opacity);return function(x){return a.r=c(x),a.g=h(x),a.b=p(x),a.opacity=y(x),a+""}}return s.gamma=t,s})(1);function Cx(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:Rn(s,a)})),o=Fu.lastIndex;return o180?x+=360:x-y>180&&(y+=360),m.push({i:v.push(a(v)+"rotate(",null,s)-2,x:Rn(y,x)})):x&&v.push(a(v)+"rotate("+x+s)}function h(y,x,v,m){y!==x?m.push({i:v.push(a(v)+"skewX(",null,s)-2,x:Rn(y,x)}):x&&v.push(a(v)+"skewX("+x+s)}function p(y,x,v,m,_,k){if(y!==v||x!==m){var j=_.push(a(_)+"scale(",null,",",null,")");k.push({i:j-4,x:Rn(y,v)},{i:j-2,x:Rn(x,m)})}else(v!==1||m!==1)&&_.push(a(_)+"scale("+v+","+m+")")}return function(y,x){var v=[],m=[];return y=t(y),x=t(x),u(y.translateX,y.translateY,x.translateX,x.translateY,v,m),c(y.rotate,x.rotate,v,m),h(y.skewX,x.skewX,v,m),p(y.scaleX,y.scaleY,x.scaleX,x.scaleY,v,m),y=x=null,function(_){for(var k=-1,j=m.length,b;++k=0&&t._call.call(void 0,r),t=t._next;--Qi}function vh(){hi=(Ol=ns.now())+Gl,Qi=Go=0;try{Vx()}finally{Qi=0,Ux(),hi=0}}function Wx(){var t=ns.now(),r=t-Ol;r>Kp&&(Gl-=r,Ol=t)}function Ux(){for(var t,r=Dl,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:Dl=o);qo=t,sc(s)}function sc(t){if(!Qi){Go&&(Go=clearTimeout(Go));var r=t-hi;r>24?(t<1/0&&(Go=setTimeout(vh,t-ns.now()-Gl)),Yo&&(Yo=clearInterval(Yo))):(Yo||(Ol=ns.now(),Yo=setInterval(Wx,Kp)),Qi=1,Qp(vh))}}function xh(t,r,o){var s=new Fl;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Yx=Yl("start","end","cancel","interrupt"),Xx=[],Jp=0,wh=1,lc=2,Il=3,_h=4,ac=5,Rl=6;function ql(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;Gx(t,o,{name:r,index:s,group:a,on:Yx,tween:Xx,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Jp})}function wc(t,r){var o=yn(t,r);if(o.state>Jp)throw new Error("too late; already scheduled");return o}function Ln(t,r){var o=yn(t,r);if(o.state>Il)throw new Error("too late; already running");return o}function yn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Gx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=Zp(u,0,o.time);function u(y){o.state=wh,o.timer.restart(c,o.delay,o.time),o.delay<=y&&c(y-o.delay)}function c(y){var x,v,m,_;if(o.state!==wh)return p();for(x in s)if(_=s[x],_.name===o.name){if(_.state===Il)return xh(c);_.state===_h?(_.state=Rl,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete s[x]):+xlc&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function Nw(t,r,o){var s,a,u=kw(r)?wc:Ln;return function(){var c=u(this,t),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function jw(t,r){var o=this._id;return arguments.length<2?yn(this.node(),o).on.on(t):this.each(Nw(o,t,r))}function bw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function Ew(){return this.on("end.remove",bw(this._id))}function Cw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=gc(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function Jw(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function rr(t,r,o){this.k=t,this.x=r,this.y=o}rr.prototype={constructor:rr,scale:function(t){return t===1?this:new rr(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new rr(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Kl=new rr(1,0,0);rg.prototype=rr.prototype;function rg(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Kl;return t.__zoom}function Hu(t){t.stopImmediatePropagation()}function Xo(t){t.preventDefault(),t.stopImmediatePropagation()}function e1(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function t1(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function Sh(){return this.__zoom||Kl}function n1(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function r1(){return navigator.maxTouchPoints||"ontouchstart"in this}function i1(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function ig(){var t=e1,r=t1,o=i1,s=n1,a=r1,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=Pl,y=Yl("start","zoom","end"),x,v,m,_=500,k=150,j=0,b=10;function E(C){C.property("__zoom",Sh).on("wheel.zoom",X,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",te).filter(a).on("touchstart.zoom",ee).on("touchmove.zoom",ne).on("touchend.zoom touchcancel.zoom",K).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(C,V,W,U){var M=C.selection?C.selection():C;M.property("__zoom",Sh),C!==M?A(C,V,W,U):M.interrupt().each(function(){$(this,arguments).event(U).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},E.scaleBy=function(C,V,W,U){E.scaleTo(C,function(){var M=this.__zoom.k,D=typeof V=="function"?V.apply(this,arguments):V;return M*D},W,U)},E.scaleTo=function(C,V,W,U){E.transform(C,function(){var M=r.apply(this,arguments),D=this.__zoom,H=W==null?N(M):typeof W=="function"?W.apply(this,arguments):W,I=D.invert(H),z=typeof V=="function"?V.apply(this,arguments):V;return o(w(R(D,z),H,I),M,c)},W,U)},E.translateBy=function(C,V,W,U){E.transform(C,function(){return o(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),r.apply(this,arguments),c)},null,U)},E.translateTo=function(C,V,W,U,M){E.transform(C,function(){var D=r.apply(this,arguments),H=this.__zoom,I=U==null?N(D):typeof U=="function"?U.apply(this,arguments):U;return o(Kl.translate(I[0],I[1]).scale(H.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),D,c)},U,M)};function R(C,V){return V=Math.max(u[0],Math.min(u[1],V)),V===C.k?C:new rr(V,C.x,C.y)}function w(C,V,W){var U=V[0]-W[0]*C.k,M=V[1]-W[1]*C.k;return U===C.x&&M===C.y?C:new rr(C.k,U,M)}function N(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function A(C,V,W,U){C.on("start.zoom",function(){$(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(U).end()}).tween("zoom",function(){var M=this,D=arguments,H=$(M,D).event(U),I=r.apply(M,D),z=W==null?N(I):typeof W=="function"?W.apply(M,D):W,ie=Math.max(I[1][0]-I[0][0],I[1][1]-I[0][1]),oe=M.__zoom,fe=typeof V=="function"?V.apply(M,D):V,he=p(oe.invert(z).concat(ie/oe.k),fe.invert(z).concat(ie/fe.k));return function(pe){if(pe===1)pe=fe;else{var Z=he(pe),se=ie/Z[2];pe=new rr(se,z[0]-Z[0]*se,z[1]-Z[1]*se)}H.zoom(null,pe)}})}function $(C,V,W){return!W&&C.__zooming||new F(C,V)}function F(C,V){this.that=C,this.args=V,this.active=0,this.sourceEvent=null,this.extent=r.apply(C,V),this.taps=0}F.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,V){return this.mouse&&C!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var V=Xt(this.that).datum();y.call(C,this.that,new Jw(C,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:y}),V)}};function X(C,...V){if(!t.apply(this,arguments))return;var W=$(this,V).event(C),U=this.__zoom,M=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,s.apply(this,arguments)))),D=fn(C);if(W.wheel)(W.mouse[0][0]!==D[0]||W.mouse[0][1]!==D[1])&&(W.mouse[1]=U.invert(W.mouse[0]=D)),clearTimeout(W.wheel);else{if(U.k===M)return;W.mouse=[D,U.invert(D)],Tl(this),W.start()}Xo(C),W.wheel=setTimeout(H,k),W.zoom("mouse",o(w(R(U,M),W.mouse[0],W.mouse[1]),W.extent,c));function H(){W.wheel=null,W.end()}}function q(C,...V){if(m||!t.apply(this,arguments))return;var W=C.currentTarget,U=$(this,V,!0).event(C),M=Xt(C.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",ie,!0),D=fn(C,W),H=C.clientX,I=C.clientY;Hp(C.view),Hu(C),U.mouse=[D,this.__zoom.invert(D)],Tl(this),U.start();function z(oe){if(Xo(oe),!U.moved){var fe=oe.clientX-H,he=oe.clientY-I;U.moved=fe*fe+he*he>j}U.event(oe).zoom("mouse",o(w(U.that.__zoom,U.mouse[0]=fn(oe,W),U.mouse[1]),U.extent,c))}function ie(oe){M.on("mousemove.zoom mouseup.zoom",null),Bp(oe.view,U.moved),Xo(oe),U.event(oe).end()}}function te(C,...V){if(t.apply(this,arguments)){var W=this.__zoom,U=fn(C.changedTouches?C.changedTouches[0]:C,this),M=W.invert(U),D=W.k*(C.shiftKey?.5:2),H=o(w(R(W,D),U,M),r.apply(this,V),c);Xo(C),h>0?Xt(this).transition().duration(h).call(A,H,U,C):Xt(this).call(E.transform,H,U,C)}}function ee(C,...V){if(t.apply(this,arguments)){var W=C.touches,U=W.length,M=$(this,V,C.changedTouches.length===U).event(C),D,H,I,z;for(Hu(C),H=0;H`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},rs=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],og=["Enter"," ","Escape"],sg={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Zi;(function(t){t.Strict="strict",t.Loose="loose"})(Zi||(Zi={}));var di;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(di||(di={}));var is;(function(t){t.Partial="partial",t.Full="full"})(is||(is={}));const lg={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Lr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Lr||(Lr={}));var os;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(os||(os={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const kh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function ag(t){return t===null?null:t?"valid":"invalid"}const ug=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,o1=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),Sc=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),hs=(t,r=[0,0])=>{const{width:o,height:s}=vn(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},s1=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):Sc(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,Ql(a,Hl(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?Zl(s):{x:0,y:0,width:0,height:0}},ps=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=Ql(o,Hl(a)),s=!0)}),s?Zl(o):{x:0,y:0,width:0,height:0}},kc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,y=r.width/a,x=r.height/a,v=[];for(const m of t.values()){const{measured:_,selectable:k=!0,hidden:j=!1}=m;if(c&&!k||j)continue;const b=_.width??m.width??m.initialWidth??0,E=_.height??m.height??m.initialHeight??0,{x:R,y:w}=m.internals.positionAbsolute,N=hg(h,p,y,x,R,w,b,E),A=b*E,$=u&&N>0;(!m.internals.handleBounds||$||N>=A||m.dragging)&&v.push(m)}return v},l1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function a1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=vn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function u1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const h=a1(t,c),p=ps(h),y=jc(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(y,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function cg({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),h=c.parentId?o.get(c.parentId):void 0,{x:p,y}=h?h.internals.positionAbsolute:{x:0,y:0},x=c.origin??s;let v=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",mn.error005());else{const{width:_,height:k}=vn(h);_&&k&&(v=[[p,y],[p+_,y+k]])}else h&&gi(c.extent)&&(v=[[c.extent[0][0]+p,c.extent[0][1]+y],[c.extent[1][0]+p,c.extent[1][1]+y]]);const m=gi(v)?pi(r,v,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",mn.error015())),{position:{x:m.x-p+(c.measured.width??0)*x[0],y:m.y-y+(c.measured.height??0)*x[1]},positionAbsolute:m}}async function c1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(m=>m.id)),c=[];for(const m of o){if(m.deletable===!1)continue;const _=u.has(m.id),k=!_&&m.parentId&&c.find(j=>j.id===m.parentId);(_||k)&&c.push(m)}const h=new Set(r.map(m=>m.id)),p=s.filter(m=>m.deletable!==!1),x=l1(c,p);for(const m of p)h.has(m.id)&&!x.find(k=>k.id===m.id)&&x.push(m);if(!a)return{edges:x,nodes:c};const v=await a({nodes:c,edges:x});return typeof v=="boolean"?v?{edges:x,nodes:c}:{edges:[],nodes:[]}:v}const Ji=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),pi=(t={x:0,y:0},r,o)=>({x:Ji(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:Ji(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function dg(t,r,o){const{width:s,height:a}=vn(o),{x:u,y:c}=o.internals.positionAbsolute;return pi(t,[[u,c],[u+s,c+a]],r)}const Nh=(t,r,o)=>to?-Ji(Math.abs(t-o),1,r)/r:0,Nc=(t,r,o=15,s=40)=>{const a=Nh(t.x,s,r.width-s)*o,u=Nh(t.y,s,r.height-s)*o;return[a,u]},Ql=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),uc=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),Zl=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),ss=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=Sc(t)?t.internals.positionAbsolute:hs(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},Hl=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=Sc(t)?t.internals.positionAbsolute:hs(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},fg=(t,r)=>Zl(Ql(uc(t),uc(r))),hg=(t,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),y=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*y)},Bl=(t,r)=>hg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),jh=t=>pn(t.width)&&pn(t.height)&&pn(t.x)&&pn(t.y),pn=t=>!isNaN(t)&&isFinite(t),pg=(t,r)=>(o,s)=>{},gs=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),ms=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(t-o)/a,y:(r-s)/a};return u?gs(h,c):h},eo=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Yi(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function d1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Yi(t,o),a=Yi(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Yi(t.top??t.y??0,o),a=Yi(t.bottom??t.y??0,o),u=Yi(t.left??t.x??0,r),c=Yi(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function f1(t,r,o,s,a,u){const{x:c,y:h}=eo(t,[r,o,s]),{x:p,y}=eo({x:t.x+t.width,y:t.y+t.height},[r,o,s]),x=a-p,v=u-y;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(x),bottom:Math.floor(v)}}const jc=(t,r,o,s,a,u)=>{const c=d1(u,r,o),h=(r-c.x)/t.width,p=(o-c.y)/t.height,y=Math.min(h,p),x=Ji(y,s,a),v=t.x+t.width/2,m=t.y+t.height/2,_=r/2-v*x,k=o/2-m*x,j=f1(t,_,k,x,r,o),b={left:Math.min(j.left-c.left,0),top:Math.min(j.top-c.top,0),right:Math.min(j.right-c.right,0),bottom:Math.min(j.bottom-c.bottom,0)};return{x:_-b.left+b.right,y:k-b.top+b.bottom,zoom:x}},ls=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function gi(t){return t!=null&&t!=="parent"}function vn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function gg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function mg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function bh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function h1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function p1(t){return{...sg,...t||{}}}function Qo(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=gn(t),h=ms({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y}=o?gs(h,r):h;return{xSnapped:p,ySnapped:y,...h}}const bc=t=>({width:t.offsetWidth,height:t.offsetHeight}),yg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},g1=["INPUT","SELECT","TEXTAREA"];function vg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:g1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const xg=t=>"clientX"in t,gn=(t,r)=>{var u,c;const o=xg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},Eh=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...bc(c)}})};function wg({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=t*.125+a*.375+c*.375+o*.125,y=r*.125+u*.375+h*.375+s*.125,x=Math.abs(p-t),v=Math.abs(y-r);return[p,y,x,v]}function kl(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function Ch({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case Se.Left:return[r-kl(r-s,u),o];case Se.Right:return[r+kl(s-r,u),o];case Se.Top:return[r,o-kl(o-a,u)];case Se.Bottom:return[r,o+kl(a-o,u)]}}function _g({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top,curvature:c=.25}){const[h,p]=Ch({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[y,x]=Ch({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[v,m,_,k]=wg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:y,targetControlY:x});return[`M${t},${r} C${h},${p} ${y},${x} ${s},${a}`,v,m,_,k]}function Sg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const v1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,x1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),w1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",mn.error006()),r;const s=o.getEdgeId||v1;let a;return ug(t)?a={...t}:a={...t,id:s(t)},x1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function kg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=Sg({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,h]}const Mh={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},_1=({source:t,sourcePosition:r=Se.Bottom,target:o})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function S1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:s=Se.Top,center:a,offset:u,stepPosition:c}){const h=Mh[r],p=Mh[s],y={x:t.x+h.x*u,y:t.y+h.y*u},x={x:o.x+p.x*u,y:o.y+p.y*u},v=_1({source:y,sourcePosition:r,target:x}),m=v.x!==0?"x":"y",_=v[m];let k=[],j,b;const E={x:0,y:0},R={x:0,y:0},[,,w,N]=Sg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[m]*p[m]===-1){m==="x"?(j=a.x??y.x+(x.x-y.x)*c,b=a.y??(y.y+x.y)/2):(j=a.x??(y.x+x.x)/2,b=a.y??y.y+(x.y-y.y)*c);const X=[{x:j,y:y.y},{x:j,y:x.y}],q=[{x:y.x,y:b},{x:x.x,y:b}];h[m]===_?k=m==="x"?X:q:k=m==="x"?q:X}else{const X=[{x:y.x,y:x.y}],q=[{x:x.x,y:y.y}];if(m==="x"?k=h.x===_?q:X:k=h.y===_?X:q,r===s){const C=Math.abs(t[m]-o[m]);if(C<=u){const V=Math.min(u-1,u-C);h[m]===_?E[m]=(y[m]>t[m]?-1:1)*V:R[m]=(x[m]>o[m]?-1:1)*V}}if(r!==s){const C=m==="x"?"y":"x",V=h[m]===p[C],W=y[C]>x[C],U=y[C]=K?(j=(te.x+ee.x)/2,b=k[0].y):(j=k[0].x,b=(te.y+ee.y)/2)}const A={x:y.x+E.x,y:y.y+E.y},$={x:x.x+R.x,y:x.y+R.y};return[[t,...A.x!==k[0].x||A.y!==k[0].y?[A]:[],...k,...$.x!==k[k.length-1].x||$.y!==k[k.length-1].y?[$]:[],o],j,b,w,N]}function k1(t,r,o,s){const a=Math.min(Ph(t,r)/2,Ph(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const y=t.xo.id===r):t[0])||null}function cc(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function j1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const y=cc(p,r);u.has(y)||(c.push({id:y,color:p.color||o,...p}),u.add(y))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const Ng=1e3,b1=10,Ec={nodeOrigin:[0,0],nodeExtent:rs,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},E1={...Ec,checkEquality:!0};function Cc(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function C1(t,r,o){const s=Cc(Ec,o);for(const a of t.values())if(a.parentId)Pc(a,t,r,s);else{const u=hs(a,s.nodeOrigin),c=gi(a.extent)?a.extent:s.nodeExtent,h=pi(u,c,vn(a));a.internals.positionAbsolute=h}}function M1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function Mc(t){return t==="manual"}function dc(t,r,o,s={}){var x,v;const a=Cc(E1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!Mc(a.zIndexMode)?Ng:0;let p=t.length>0,y=!1;r.clear(),o.clear();for(const m of t){let _=c.get(m.id);if(a.checkEquality&&m===(_==null?void 0:_.internals.userNode))r.set(m.id,_);else{const k=hs(m,a.nodeOrigin),j=gi(m.extent)?m.extent:a.nodeExtent,b=pi(k,j,vn(m));_={...a.defaults,...m,measured:{width:(x=m.measured)==null?void 0:x.width,height:(v=m.measured)==null?void 0:v.height},internals:{positionAbsolute:b,handleBounds:M1(m,_),z:jg(m,h,a.zIndexMode),userNode:m}},r.set(m.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),m.parentId&&Pc(_,r,o,s,u),y||(y=m.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:y}}function P1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function Pc(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=Cc(Ec,s),y=t.parentId,x=r.get(y);if(!x){console.warn(`Parent node ${y} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}P1(t,o),a&&!x.parentId&&x.internals.rootParentIndex===void 0&&p==="auto"&&(x.internals.rootParentIndex=++a.i,x.internals.z=x.internals.z+a.i*b1),a&&x.internals.rootParentIndex!==void 0&&(a.i=x.internals.rootParentIndex);const v=u&&!Mc(p)?Ng:0,{x:m,y:_,z:k}=I1(t,x,c,h,v,p),{positionAbsolute:j}=t.internals,b=m!==j.x||_!==j.y;(b||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:b?{x:m,y:_}:j,z:k}})}function jg(t,r,o){const s=pn(t.zIndex)?t.zIndex:0;return Mc(o)?s:s+(t.selected?r:0)}function I1(t,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=vn(t),y=hs(t,o),x=gi(t.extent)?pi(y,t.extent,p):y;let v=pi({x:c+x.x,y:h+x.y},s,p);t.extent==="parent"&&(v=dg(v,p,r));const m=jg(t,a,u),_=r.internals.z??0;return{x:v.x,y:v.y,z:_>=m?_+1:m}}function Ic(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const y=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??ss(p),x=fg(y,h.rect);u.set(h.parentId,{expandedRect:x,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},y)=>{var w;const x=p.internals.positionAbsolute,v=vn(p),m=p.origin??s,_=h.x0||k>0||E||R)&&(a.push({id:y,type:"position",position:{x:p.position.x-_+E,y:p.position.y-k+R}}),(w=o.get(y))==null||w.forEach(N=>{t.some(A=>A.id===N.id)||a.push({id:N.id,type:"position",position:{x:N.position.x+_,y:N.position.y+k}})})),(v.width0){const _=Ic(m,r,o,a);y.push(..._)}return{changes:y,updatedInternals:p}}async function T1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Lh(t,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${t}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${t}-${u}`;const y=s.get(c)||new Map;s.set(c,y.set(o,r))}}function bg(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},y=`${a}-${c}--${u}-${h}`,x=`${u}-${h}--${a}-${c}`;Lh("source",p,x,t,a,c),Lh("target",p,y,t,u,h),r.set(s.id,s)}}function Eg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:Eg(o,r):!1}function Ah(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function L1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!Eg(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function Bu({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[y,x]of r){const v=(c=o.get(y))==null?void 0:c.internals.userNode;v&&a.push({...v,position:x.position,dragging:s})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function A1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=gs(u,r);return{x:c.x-u.x,y:c.y-u.y}}function $1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,y={x:0,y:0},x=null,v=!1,m=null,_=!1,k=!1,j=null;function b({noDragClassName:R,handleSelector:w,domNode:N,isSelectable:A,nodeId:$,nodeClickDistance:F=0}){m=Xt(N);function X({x:ne,y:K}){const{nodeLookup:C,nodeExtent:V,snapGrid:W,snapToGrid:U,nodeOrigin:M,onNodeDrag:D,onSelectionDrag:H,onError:I,updateNodePositions:z}=r();u={x:ne,y:K};let ie=!1;const oe=h.size>1,fe=oe&&V?uc(ps(h)):null,he=oe&&U?A1({dragItems:h,snapGrid:W,x:ne,y:K}):null;for(const[pe,Z]of h){if(!C.has(pe))continue;let se={x:ne-Z.distance.x,y:K-Z.distance.y};U&&(se=he?{x:Math.round(se.x+he.x),y:Math.round(se.y+he.y)}:gs(se,W));let me=null;if(oe&&V&&!Z.extent&&fe){const{positionAbsolute:re}=Z.internals,Ne=re.x-fe.x+V[0][0],Me=re.x+Z.measured.width-fe.x2+V[1][0],Te=re.y-fe.y+V[0][1],$e=re.y+Z.measured.height-fe.y2+V[1][1];me=[[Ne,Te],[Me,$e]]}const{position:ke,positionAbsolute:ve}=cg({nodeId:pe,nextPosition:se,nodeLookup:C,nodeExtent:me||V,nodeOrigin:M,onError:I});ie=ie||Z.position.x!==ke.x||Z.position.y!==ke.y,Z.position=ke,Z.internals.positionAbsolute=ve}if(k=k||ie,!!ie&&(z(h,!0),j&&(s||D||!$&&H))){const[pe,Z]=Bu({nodeId:$,dragItems:h,nodeLookup:C});s==null||s(j,h,pe,Z),D==null||D(j,pe,Z),$||H==null||H(j,Z)}}async function q(){if(!x)return;const{transform:ne,panBy:K,autoPanSpeed:C,autoPanOnNodeDrag:V}=r();if(!V){p=!1,cancelAnimationFrame(c);return}const[W,U]=Nc(y,x,C);(W!==0||U!==0)&&(u.x=(u.x??0)-W/ne[2],u.y=(u.y??0)-U/ne[2],await K({x:W,y:U})&&X(u)),c=requestAnimationFrame(q)}function te(ne){var oe;const{nodeLookup:K,multiSelectionActive:C,nodesDraggable:V,transform:W,snapGrid:U,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:H,onSelectionDragStart:I,unselectNodesAndEdges:z}=r();v=!0,(!D||!A)&&!C&&$&&((oe=K.get($))!=null&&oe.selected||z()),A&&D&&$&&(t==null||t($));const ie=Qo(ne.sourceEvent,{transform:W,snapGrid:U,snapToGrid:M,containerBounds:x});if(u=ie,h=L1(K,V,ie,$),h.size>0&&(o||H||!$&&I)){const[fe,he]=Bu({nodeId:$,dragItems:h,nodeLookup:K});o==null||o(ne.sourceEvent,h,fe,he),H==null||H(ne.sourceEvent,fe,he),$||I==null||I(ne.sourceEvent,he)}}const ee=Vp().clickDistance(F).on("start",ne=>{const{domNode:K,nodeDragThreshold:C,transform:V,snapGrid:W,snapToGrid:U}=r();x=(K==null?void 0:K.getBoundingClientRect())||null,_=!1,k=!1,j=ne.sourceEvent,C===0&&te(ne),u=Qo(ne.sourceEvent,{transform:V,snapGrid:W,snapToGrid:U,containerBounds:x}),y=gn(ne.sourceEvent,x)}).on("drag",ne=>{const{autoPanOnNodeDrag:K,transform:C,snapGrid:V,snapToGrid:W,nodeDragThreshold:U,nodeLookup:M}=r(),D=Qo(ne.sourceEvent,{transform:C,snapGrid:V,snapToGrid:W,containerBounds:x});if(j=ne.sourceEvent,(ne.sourceEvent.type==="touchmove"&&ne.sourceEvent.touches.length>1||$&&!M.has($))&&(_=!0),!_){if(!p&&K&&v&&(p=!0,q()),!v){const H=gn(ne.sourceEvent,x),I=H.x-y.x,z=H.y-y.y;Math.sqrt(I*I+z*z)>U&&te(ne)}(u.x!==D.xSnapped||u.y!==D.ySnapped)&&h&&v&&(y=gn(ne.sourceEvent,x),X(D))}}).on("end",ne=>{if(!v||_){_&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,v=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:K,updateNodePositions:C,onNodeDragStop:V,onSelectionDragStop:W}=r();if(k&&(C(h,!1),k=!1),a||V||!$&&W){const[U,M]=Bu({nodeId:$,dragItems:h,nodeLookup:K,dragging:!1});a==null||a(ne.sourceEvent,h,U,M),V==null||V(ne.sourceEvent,U,M),$||W==null||W(ne.sourceEvent,M)}}}).filter(ne=>{const K=ne.target;return!ne.button&&(!R||!Ah(K,`.${R}`,N))&&(!w||Ah(K,w,N))});m.call(ee)}function E(){m==null||m.on(".drag",null)}return{update:b,destroy:E}}function z1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())Bl(a,ss(u))>0&&s.push(u);return s}const D1=250;function O1(t,r,o,s){var h,p;let a=[],u=1/0;const c=z1(t,o,r+D1);for(const y of c){const x=[...((h=y.internals.handleBounds)==null?void 0:h.source)??[],...((p=y.internals.handleBounds)==null?void 0:p.target)??[]];for(const v of x){if(s.nodeId===v.nodeId&&s.type===v.type&&s.id===v.id)continue;const{x:m,y:_}=mi(y,v,v.position,!0),k=Math.sqrt(Math.pow(m-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const y=s.type==="source"?"target":"source";return a.find(x=>x.type===y)??a[0]}return a[0]}function Cg(t,r,o,s,a,u=!1){var y,x,v;const c=s.get(t);if(!c)return null;const h=a==="strict"?(y=c.internals.handleBounds)==null?void 0:y[r]:[...((x=c.internals.handleBounds)==null?void 0:x.source)??[],...((v=c.internals.handleBounds)==null?void 0:v.target)??[]],p=(o?h==null?void 0:h.find(m=>m.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...mi(c,p,p.position,!0)}:p}function Mg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function F1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const Pg=()=>!0;function H1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:y,autoPanOnConnect:x,flowId:v,panBy:m,cancelConnection:_,onConnectStart:k,onConnect:j,onConnectEnd:b,isValidConnection:E=Pg,onReconnectEnd:R,updateConnection:w,getTransform:N,getFromHandle:A,autoPanSpeed:$,dragThreshold:F=1,handleDomNode:X}){const q=yg(t.target);let te=0,ee;const{x:ne,y:K}=gn(t),C=Mg(u,X),V=h==null?void 0:h.getBoundingClientRect();let W=!1;if(!V||!C)return;const U=Cg(a,C,s,p,r);if(!U)return;let M=gn(t,V),D=!1,H=null,I=!1,z=null;function ie(){if(!x||!V)return;const[ke,ve]=Nc(M,V,$);m({x:ke,y:ve}),te=requestAnimationFrame(ie)}const oe={...U,nodeId:a,type:C,position:U.position},fe=p.get(a);let pe={inProgress:!0,isValid:null,from:mi(fe,oe,Se.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:fe,to:M,toHandle:null,toPosition:kh[oe.position],toNode:null,pointer:M};function Z(){W=!0,w(pe),k==null||k(t,{nodeId:a,handleId:s,handleType:C})}F===0&&Z();function se(ke){if(!W){const{x:$e,y:st}=gn(ke),lt=$e-ne,at=st-K;if(!(lt*lt+at*at>F*F))return;Z()}if(!A()||!oe){me(ke);return}const ve=N();M=gn(ke,V),ee=O1(ms(M,ve,!1,[1,1]),o,p,oe),D||(ie(),D=!0);const re=Ig(ke,{handle:ee,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:E,doc:q,lib:y,flowId:v,nodeLookup:p});z=re.handleDomNode,H=re.connection,I=F1(!!ee,re.isValid);const Ne=p.get(a),Me=Ne?mi(Ne,oe,Se.Left,!0):pe.from,Te={...pe,from:Me,isValid:I,to:re.toHandle&&I?eo({x:re.toHandle.x,y:re.toHandle.y},ve):M,toHandle:re.toHandle,toPosition:I&&re.toHandle?re.toHandle.position:kh[oe.position],toNode:re.toHandle?p.get(re.toHandle.nodeId):null,pointer:M};w(Te),pe=Te}function me(ke){if(!("touches"in ke&&ke.touches.length>0)){if(W){(ee||z)&&H&&I&&(j==null||j(H));const{inProgress:ve,...re}=pe,Ne={...re,toPosition:pe.toHandle?pe.toPosition:null};b==null||b(ke,Ne),u&&(R==null||R(ke,Ne))}_(),cancelAnimationFrame(te),D=!1,I=!1,H=null,z=null,q.removeEventListener("mousemove",se),q.removeEventListener("mouseup",me),q.removeEventListener("touchmove",se),q.removeEventListener("touchend",me)}}q.addEventListener("mousemove",se),q.addEventListener("mouseup",me),q.addEventListener("touchmove",se),q.addEventListener("touchend",me)}function Ig(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:y=Pg,nodeLookup:x}){const v=u==="target",m=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=gn(t),j=c.elementFromPoint(_,k),b=j!=null&&j.classList.contains(`${h}-flow__handle`)?j:m,E={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const R=Mg(void 0,b),w=b.getAttribute("data-nodeid"),N=b.getAttribute("data-handleid"),A=b.classList.contains("connectable"),$=b.classList.contains("connectableend");if(!w||!R)return E;const F={source:v?w:s,sourceHandle:v?N:a,target:v?s:w,targetHandle:v?a:N};E.connection=F;const q=A&&$&&(o===Zi.Strict?v&&R==="source"||!v&&R==="target":w!==s||N!==a);E.isValid=q&&y(F),E.toHandle=Cg(w,R,N,x,o,!0)}return E}const fc={onPointerDown:H1,isValid:Ig};function B1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Xt(t);function u({translateExtent:h,width:p,height:y,zoomStep:x=1,pannable:v=!0,zoomable:m=!0,inversePan:_=!1}){const k=w=>{if(w.sourceEvent.type!=="wheel"||!r)return;const N=o(),A=w.sourceEvent.ctrlKey&&ls()?10:1,$=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*x,F=N[2]*Math.pow(2,$*A);r.scaleTo(F)};let j=[0,0];const b=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(j=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},E=w=>{const N=o();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!r)return;const A=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],$=[A[0]-j[0],A[1]-j[1]];j=A;const F=s()*Math.max(N[2],Math.log(N[2]))*(_?-1:1),X={x:N[0]-$[0]*F,y:N[1]-$[1]*F},q=[[0,0],[p,y]];r.setViewportConstrained({x:X.x,y:X.y,zoom:N[2]},q,h)},R=ig().on("start",b).on("zoom",v?E:null).on("zoom.wheel",m?k:null);a.call(R,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:fn}}const Jl=t=>({x:t.x,y:t.y,zoom:t.k}),Vu=({x:t,y:r,zoom:o})=>Kl.translate(t,r).scale(o),Rr=(t,r)=>t.target.closest(`.${r}`),Rg=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),V1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Wu=(t,r=0,o=V1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Tg=t=>{const r=t.ctrlKey&&ls()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function W1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:y}){return x=>{if(Rr(x,r))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const v=o.property("__zoom").k||1;if(x.ctrlKey&&c){const b=fn(x),E=Tg(x),R=v*Math.pow(2,E);s.scaleTo(o,R,b,x);return}const m=x.deltaMode===1?20:1;let _=a===di.Vertical?0:x.deltaX*m,k=a===di.Horizontal?0:x.deltaY*m;!ls()&&x.shiftKey&&a!==di.Vertical&&(_=x.deltaY*m,k=0),s.translateBy(o,-(_/v)*u,-(k/v)*u,{internal:!0});const j=Jl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(x,j):(t.isPanScrolling=!0,h==null||h(x,j)),t.panScrollTimeout=setTimeout(()=>{y==null||y(x,j),t.isPanScrolling=!1},150)}}function U1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=Rr(s,t);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function Y1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=Jl(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function X1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;t.usedRightMouseButton=!!(o&&Rg(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,Jl(u.transform)))}}function G1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&Rg(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const p=Jl(c.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function q1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:y,lib:x,connectionInProgress:v}){return m=>{var E;const _=r||o,k=s&&m.ctrlKey,j=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(Rr(m,`${x}-flow__node`)||Rr(m,`${x}-flow__edge`)||Rr(m,`${x}-flow__selection`)||Rr(m,`${x}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!c&&!s||h||v&&!j||Rr(m,p)&&j||Rr(m,y)&&(!j||u&&j&&!r)||!s&&m.ctrlKey&&j)return!1;if(!s&&m.type==="touchstart"&&((E=m.touches)==null?void 0:E.length)>1)return m.preventDefault(),!1;if(!_&&!u&&!k&&j||!a&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(a)&&!a.includes(m.button)&&m.type==="mousedown")return!1;const b=Array.isArray(a)&&a.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||j||t)&&b}}function K1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const y={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=t.getBoundingClientRect();let v=[[0,0],[x.width,x.height]];const m=typeof ResizeObserver<"u"?new ResizeObserver(K=>{const C=K[0];C&&(v=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;m==null||m.observe(t);const _=ig().extent(()=>v).scaleExtent([r,o]).translateExtent(s),k=Xt(t).call(_);N({x:a.x,y:a.y,zoom:Ji(a.zoom,r,o)},[[0,0],[x.width,x.height]],s);const j=k.on("wheel.zoom"),b=k.on("dblclick.zoom");_.wheelDelta(Tg);async function E(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Pl).transform(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function R({noWheelClassName:K,noPanClassName:C,onPaneContextMenu:V,userSelectionActive:W,panOnScroll:U,panOnDrag:M,panOnScrollMode:D,panOnScrollSpeed:H,preventScrolling:I,zoomOnPinch:z,zoomOnScroll:ie,zoomOnDoubleClick:oe,panActivationKeyPressed:fe=!1,zoomActivationKeyPressed:he,lib:pe,onTransformChange:Z,connectionInProgress:se,paneClickDistance:me,selectionOnDrag:ke}){W&&!y.isZoomingOrPanning&&w();const ve=U&&!he&&!W;_.clickDistance(ke?1/0:!pn(me)||me<0?0:me);const re=ve?W1({zoomPanValues:y,noWheelClassName:K,d3Selection:k,d3Zoom:_,panOnScrollMode:D,panOnScrollSpeed:H,zoomOnPinch:z,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):U1({noWheelClassName:K,preventScrolling:I,d3ZoomHandler:j});k.on("wheel.zoom",re,{passive:!1});const Ne=Y1({zoomPanValues:y,onDraggingChange:p,onPanZoomStart:c});_.on("start",Ne);const Me=X1({zoomPanValues:y,panOnDrag:M,onPaneContextMenu:!!V,onPanZoom:u,onTransformChange:Z});_.on("zoom",Me);const Te=G1({zoomPanValues:y,panOnDrag:M,panOnScroll:U,onPaneContextMenu:V,onPanZoomEnd:h,onDraggingChange:p});_.on("end",Te);const $e=q1({panActivationKeyPressed:fe,zoomActivationKeyPressed:he,panOnDrag:M,zoomOnScroll:ie,panOnScroll:U,zoomOnDoubleClick:oe,zoomOnPinch:z,userSelectionActive:W,noPanClassName:C,noWheelClassName:K,lib:pe,connectionInProgress:se});_.filter($e),oe?k.on("dblclick.zoom",b):k.on("dblclick.zoom",null)}function w(){_.on("zoom",null)}async function N(K,C,V){const W=Vu(K),U=_==null?void 0:_.constrain()(W,C,V);return U&&await E(U),U}async function A(K,C){const V=Vu(K);return await E(V,C),V}function $(K){if(k){const C=Vu(K),V=k.property("__zoom");(V.k!==K.zoom||V.x!==K.x||V.y!==K.y)&&(_==null||_.transform(k,C,null,{sync:!0}))}}function F(){const K=k?rg(k.node()):{x:0,y:0,k:1};return{x:K.x,y:K.y,zoom:K.k}}async function X(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Pl).scaleTo(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}async function q(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Pl).scaleBy(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function te(K){_==null||_.scaleExtent(K)}function ee(K){_==null||_.translateExtent(K)}function ne(K){const C=!pn(K)||K<0?0:K;_==null||_.clickDistance(C)}return{update:R,destroy:w,setViewport:A,setViewportConstrained:N,getViewport:F,scaleTo:X,scaleBy:q,setScaleExtent:te,setTranslateExtent:ee,syncViewport:$,setClickDistance:ne}}var to;(function(t){t.Line="line",t.Handle="handle"})(to||(to={}));function Q1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function $h(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function Pr(t,r){return Math.max(0,r-t)}function Ir(t,r){return Math.max(0,t-r)}function Nl(t,r,o){return Math.max(0,r-t,t-o)}function zh(t,r){return t?!r:r}function Z1(t,r,o,s,a,u,c,h){let{affectsX:p,affectsY:y}=r;const{isHorizontal:x,isVertical:v}=r,m=x&&v,{xSnapped:_,ySnapped:k}=o,{minWidth:j,maxWidth:b,minHeight:E,maxHeight:R}=s,{x:w,y:N,width:A,height:$,aspectRatio:F}=t;let X=Math.floor(x?_-t.pointerX:0),q=Math.floor(v?k-t.pointerY:0);const te=A+(p?-X:X),ee=$+(y?-q:q),ne=-u[0]*A,K=-u[1]*$;let C=Nl(te,j,b),V=Nl(ee,E,R);if(c){let M=0,D=0;p&&X<0?M=Pr(w+X+ne,c[0][0]):!p&&X>0&&(M=Ir(w+te+ne,c[1][0])),y&&q<0?D=Pr(N+q+K,c[0][1]):!y&&q>0&&(D=Ir(N+ee+K,c[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(h){let M=0,D=0;p&&X>0?M=Ir(w+X,h[0][0]):!p&&X<0&&(M=Pr(w+te,h[1][0])),y&&q>0?D=Ir(N+q,h[0][1]):!y&&q<0&&(D=Pr(N+ee,h[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(a){if(x){const M=Nl(te/F,E,R)*F;if(C=Math.max(C,M),c){let D=0;!p&&!y||p&&!y&&m?D=Ir(N+K+te/F,c[1][1])*F:D=Pr(N+K+(p?X:-X)/F,c[0][1])*F,C=Math.max(C,D)}if(h){let D=0;!p&&!y||p&&!y&&m?D=Pr(N+te/F,h[1][1])*F:D=Ir(N+(p?X:-X)/F,h[0][1])*F,C=Math.max(C,D)}}if(v){const M=Nl(ee*F,j,b)/F;if(V=Math.max(V,M),c){let D=0;!p&&!y||y&&!p&&m?D=Ir(w+ee*F+ne,c[1][0])/F:D=Pr(w+(y?q:-q)*F+ne,c[0][0])/F,V=Math.max(V,D)}if(h){let D=0;!p&&!y||y&&!p&&m?D=Pr(w+ee*F,h[1][0])/F:D=Ir(w+(y?q:-q)*F,h[0][0])/F,V=Math.max(V,D)}}}q=q+(q<0?V:-V),X=X+(X<0?C:-C),a&&(m?te>ee*F?q=(zh(p,y)?-X:X)/F:X=(zh(p,y)?-q:q)*F:x?(q=X/F,y=p):(X=q*F,p=y));const W=p?w+X:w,U=y?N+q:N;return{width:A+(p?-X:X),height:$+(y?-q:q),x:u[0]*X*(p?-1:1)+W,y:u[1]*q*(y?-1:1)+U}}const Lg={width:0,height:0,x:0,y:0},J1={...Lg,pointerX:0,pointerY:0,aspectRatio:1};function e_(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function t_({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Xt(t);let c={controlDirection:$h("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:y,boundaries:x,keepAspectRatio:v,resizeDirection:m,onResizeStart:_,onResize:k,onResizeEnd:j,shouldResize:b}){let E={...Lg},R={...J1};c={boundaries:x,resizeDirection:m,keepAspectRatio:v,controlDirection:$h(y)};let w,N=null,A=[],$,F,X,q=!1;const te=Vp().on("start",ee=>{const{nodeLookup:ne,transform:K,snapGrid:C,snapToGrid:V,nodeOrigin:W,paneDomNode:U}=o();if(w=ne.get(r),!w)return;N=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:D}=Qo(ee.sourceEvent,{transform:K,snapGrid:C,snapToGrid:V,containerBounds:N});E={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},R={...E,pointerX:M,pointerY:D,aspectRatio:E.width/E.height},$=void 0,F=gi(w.extent)?w.extent:void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&($=ne.get(w.parentId)),$&&w.extent==="parent"&&(F=[[0,0],[$.measured.width,$.measured.height]]),A=[],X=void 0;for(const[H,I]of ne)if(I.parentId===r&&(A.push({id:H,position:{...I.position},extent:I.extent}),I.extent==="parent"||I.expandParent)){const z=e_(I,w,I.origin??W);X?X=[[Math.min(z[0][0],X[0][0]),Math.min(z[0][1],X[0][1])],[Math.max(z[1][0],X[1][0]),Math.max(z[1][1],X[1][1])]]:X=z}_==null||_(ee,{...E})}).on("drag",ee=>{const{transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V}=o(),W=Qo(ee.sourceEvent,{transform:ne,snapGrid:K,snapToGrid:C,containerBounds:N}),U=[];if(!w)return;const{x:M,y:D,width:H,height:I}=E,z={},ie=w.origin??V,{width:oe,height:fe,x:he,y:pe}=Z1(R,c.controlDirection,W,c.boundaries,c.keepAspectRatio,ie,F,X),Z=oe!==H,se=fe!==I,me=he!==M&&Z,ke=pe!==D&&se;if(!me&&!ke&&!Z&&!se)return;if((me||ke||ie[0]===1||ie[1]===1)&&(z.x=me?he:E.x,z.y=ke?pe:E.y,E.x=z.x,E.y=z.y,A.length>0)){const Me=he-M,Te=pe-D;for(const $e of A)$e.position={x:$e.position.x-Me+ie[0]*(oe-H),y:$e.position.y-Te+ie[1]*(fe-I)},U.push($e)}if((Z||se)&&(z.width=Z&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:E.width,z.height=se&&(!c.resizeDirection||c.resizeDirection==="vertical")?fe:E.height,E.width=z.width,E.height=z.height),$&&w.expandParent){const Me=ie[0]*(z.width??0);z.x&&z.x{q&&(j==null||j(ee,{...E}),a==null||a({...E}),q=!1)});u.call(te)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Uu={exports:{}},Yu={},Xu={exports:{}},Gu={};/** + * @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 Dh;function n_(){if(Dh)return Gu;Dh=1;var t=cs();function r(v,m){return v===m&&(v!==0||1/v===1/m)||v!==v&&m!==m}var o=typeof Object.is=="function"?Object.is:r,s=t.useState,a=t.useEffect,u=t.useLayoutEffect,c=t.useDebugValue;function h(v,m){var _=m(),k=s({inst:{value:_,getSnapshot:m}}),j=k[0].inst,b=k[1];return u(function(){j.value=_,j.getSnapshot=m,p(j)&&b({inst:j})},[v,_,m]),a(function(){return p(j)&&b({inst:j}),v(function(){p(j)&&b({inst:j})})},[v]),c(_),_}function p(v){var m=v.getSnapshot;v=v.value;try{var _=m();return!o(v,_)}catch{return!0}}function y(v,m){return m()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:h;return Gu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:x,Gu}var Oh;function r_(){return Oh||(Oh=1,Xu.exports=n_()),Xu.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 Fh;function i_(){if(Fh)return Yu;Fh=1;var t=cs(),r=r_();function o(y,x){return y===x&&(y!==0||1/y===1/x)||y!==y&&x!==x}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Yu.useSyncExternalStoreWithSelector=function(y,x,v,m,_){var k=u(null);if(k.current===null){var j={hasValue:!1,value:null};k.current=j}else j=k.current;k=h(function(){function E($){if(!R){if(R=!0,w=$,$=m($),_!==void 0&&j.hasValue){var F=j.value;if(_(F,$))return N=F}return N=$}if(F=N,s(w,$))return F;var X=m($);return _!==void 0&&_(F,X)?(w=$,F):(w=$,N=X)}var R=!1,w,N,A=v===void 0?null:v;return[function(){return E(x())},A===null?void 0:function(){return E(A())}]},[x,v,m,_]);var b=a(y,k[0],k[1]);return c(function(){j.hasValue=!0,j.value=b},[b]),p(b),b},Yu}var Hh;function o_(){return Hh||(Hh=1,Uu.exports=i_()),Uu.exports}var s_=o_();const l_=jp(s_),a_={},Bh=t=>{let r;const o=new Set,s=(x,v)=>{const m=typeof x=="function"?x(r):x;if(!Object.is(m,r)){const _=r;r=v??(typeof m!="object"||m===null)?m:Object.assign({},r,m),o.forEach(k=>k(r,_))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>y,subscribe:x=>(o.add(x),()=>o.delete(x)),destroy:()=>{(a_?"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."),o.clear()}},y=r=t(s,a,p);return p},u_=t=>t?Bh(t):Bh,{useDebugValue:c_}=o0,{useSyncExternalStoreWithSelector:d_}=l_,f_=t=>t;function Ag(t,r=f_,o){const s=d_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return c_(s),s}const Vh=(t,r)=>{const o=u_(t),s=(a,u=r)=>Ag(o,a,u);return Object.assign(s,o),s},h_=(t,r)=>t?Vh(t,r):Vh;function Qe(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}bp();const ea=L.createContext(null),p_=ea.Provider,$g=mn.error001("react");function De(t,r){const o=L.useContext(ea);if(o===null)throw new Error($g);return Ag(o,t,r)}function Ye(){const t=L.useContext(ea);if(t===null)throw new Error($g);return L.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Wh={display:"none"},g_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},zg="react-flow__node-desc",Dg="react-flow__edge-desc",m_="react-flow__aria-live",y_=t=>t.ariaLiveMessage,v_=t=>t.ariaLabelConfig;function x_({rfId:t}){const r=De(y_);return d.jsx("div",{id:`${m_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:g_,children:r})}function w_({rfId:t,disableKeyboardA11y:r}){const o=De(v_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${zg}-${t}`,style:Wh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${Dg}-${t}`,style:Wh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(x_,{rfId:t})]})}const ta=L.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return d.jsx("div",{className:nt(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});ta.displayName="Panel";const Uh="https://reactflow.dev?utm_source=attribution";function __({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:d.jsx(ta,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Uh}`,children:d.jsx("a",{href:Uh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const S_=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},jl=t=>t.id;function k_(t,r){return Qe(t.selectedNodes.map(jl),r.selectedNodes.map(jl))&&Qe(t.selectedEdges.map(jl),r.selectedEdges.map(jl))}function N_({onSelectionChange:t}){const r=Ye(),{selectedNodes:o,selectedEdges:s}=De(S_,k_);return L.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const j_=t=>!!t.onSelectionChangeHandlers;function b_({onSelectionChange:t}){const r=De(j_);return t||r?d.jsx(N_,{onSelectionChange:t}):null}const Og=[0,0],E_={x:0,y:0,zoom:1},C_=["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"],Yh=[...C_,"rfId"],M_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Xh={translateExtent:rs,nodeOrigin:Og,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function P_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=De(M_,Qe),y=Ye();L.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{x.current=Xh,h()}),[]);const x=L.useRef(Xh);return L.useEffect(()=>{for(const v of Yh){const m=t[v],_=x.current[v];m!==_&&(typeof t[v]>"u"||(v==="nodes"?r(m):v==="edges"?o(m):v==="minZoom"?s(m):v==="maxZoom"?a(m):v==="translateExtent"?u(m):v==="nodeExtent"?c(m):v==="ariaLabelConfig"?y.setState({ariaLabelConfig:p1(m)}):v==="fitView"?y.setState({fitViewQueued:m}):v==="fitViewOptions"?y.setState({fitViewOptions:m}):y.setState({[v]:m})))}x.current=t},Yh.map(v=>t[v])),null}function Gh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function I_(t){var s;const[r,o]=L.useState(t==="system"?null:t);return L.useEffect(()=>{if(t!=="system"){o(t);return}const a=Gh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=Gh())!=null&&s.matches?"dark":"light"}const qh=typeof document<"u"?document:null;function as(t=null,r={target:qh,actInsideInputWithModifier:!0}){const[o,s]=L.useState(!1),a=L.useRef(!1),u=L.useRef(new Set([])),[c,h]=L.useMemo(()=>{if(t!==null){const y=(Array.isArray(t)?t:[t]).filter(v=>typeof v=="string").map(v=>v.replace(/\+/g,` +`).replace(` + +`,` ++`).split(` +`)),x=y.reduce((v,m)=>v.concat(...m),[]);return[y,x]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??qh,y=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const x=_=>{var b,E;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!y)&&vg(_))return!1;const j=Qh(_.code,h);if(u.current.add(_[j]),Kh(c,u.current,!1)){const R=((E=(b=_.composedPath)==null?void 0:b.call(_))==null?void 0:E[0])||_.target,w=(R==null?void 0:R.nodeName)==="BUTTON"||(R==null?void 0:R.nodeName)==="A";r.preventDefault!==!1&&(a.current||!w)&&_.preventDefault(),s(!0)}},v=_=>{const k=Qh(_.code,h);Kh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},m=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",x),p==null||p.addEventListener("keyup",v),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{p==null||p.removeEventListener("keydown",x),p==null||p.removeEventListener("keyup",v),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,s]),o}function Kh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Qh(t,r){return r.includes(t)?"code":"key"}const R_=()=>{const t=Ye();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=jc(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),y={x:r.x-h,y:r.y-p},x=o.snapGrid??a,v=o.snapToGrid??u;return ms(y,s,v,x)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=eo(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function Fg(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)T_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function T_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function L_(t,r){return Fg(t,r)}function A_(t,r){return Fg(t,r)}function ai(t,r){return{id:t,type:"select",selected:r}}function Xi(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(ai(u.id,c)))}return s}function Zh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Jh(t){return{id:t.id,type:"remove"}}const $_=pg();function z_(t,r,o={}){return w1(t,r,{...o,onError:o.onError??$_})}const ep=t=>o1(t),D_=t=>ug(t);function Hg(t){return L.forwardRef(t)}const Bg=typeof window<"u"?L.useLayoutEffect:L.useEffect;function tp(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>O_(()=>o(a=>a+BigInt(1))));return Bg(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function O_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Vg=L.createContext(null);function F_({children:t}){const r=Ye(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:y,hasDefaultNodes:x,onNodesChange:v,nodeLookup:m,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let j=p;for(const E of h)j=typeof E=="function"?E(j):E;let b=Zh({items:j,lookup:m});for(const E of k.values())b=E(b);x&&y(j),b.length>0?v==null||v(b):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:R,setNodes:w}=r.getState();E&&w(R)})},[]),s=tp(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:y,hasDefaultEdges:x,onEdgesChange:v,edgeLookup:m}=r.getState();let _=p;for(const k of h)_=typeof k=="function"?k(_):k;x?y(_):v&&v(Zh({items:_,lookup:m}))},[]),u=tp(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Vg.Provider,{value:c,children:t})}function H_(){const t=L.useContext(Vg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const B_=t=>!!t.panZoom;function na(){const t=R_(),r=Ye(),o=H_(),s=De(B_),a=L.useMemo(()=>{const u=v=>r.getState().nodeLookup.get(v),c=v=>{o.nodeQueue.push(v)},h=v=>{o.edgeQueue.push(v)},p=v=>{var E,R;const{nodeLookup:m,nodeOrigin:_}=r.getState(),k=ep(v)?v:m.get(v.id),j=k.parentId?mg(k.position,k.measured,k.parentId,m,_):k.position,b={...k,position:j,width:((E=k.measured)==null?void 0:E.width)??k.width,height:((R=k.measured)==null?void 0:R.height)??k.height};return ss(b)},y=(v,m,_={replace:!1})=>{c(k=>k.map(j=>{if(j.id===v){const b=typeof m=="function"?m(j):m;return _.replace&&ep(b)?b:{...j,...b}}return j}))},x=(v,m,_={replace:!1})=>{h(k=>k.map(j=>{if(j.id===v){const b=typeof m=="function"?m(j):m;return _.replace&&D_(b)?b:{...j,...b}}return j}))};return{getNodes:()=>r.getState().nodes.map(v=>({...v})),getNode:v=>{var m;return(m=u(v))==null?void 0:m.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:v=[]}=r.getState();return v.map(m=>({...m}))},getEdge:v=>r.getState().edgeLookup.get(v),setNodes:c,setEdges:h,addNodes:v=>{const m=Array.isArray(v)?v:[v];o.nodeQueue.push(_=>[..._,...m])},addEdges:v=>{const m=Array.isArray(v)?v:[v];o.edgeQueue.push(_=>[..._,...m])},toObject:()=>{const{nodes:v=[],edges:m=[],transform:_}=r.getState(),[k,j,b]=_;return{nodes:v.map(E=>({...E})),edges:m.map(E=>({...E})),viewport:{x:k,y:j,zoom:b}}},deleteElements:async({nodes:v=[],edges:m=[]})=>{const{nodes:_,edges:k,onNodesDelete:j,onEdgesDelete:b,triggerNodeChanges:E,triggerEdgeChanges:R,onDelete:w,onBeforeDelete:N}=r.getState(),{nodes:A,edges:$}=await c1({nodesToRemove:v,edgesToRemove:m,nodes:_,edges:k,onBeforeDelete:N}),F=$.length>0,X=A.length>0;if(F){const q=$.map(Jh);b==null||b($),R(q)}if(X){const q=A.map(Jh);j==null||j(A),E(q)}return(X||F)&&(w==null||w({nodes:A,edges:$})),{deletedNodes:A,deletedEdges:$}},getIntersectingNodes:(v,m=!0,_)=>{const k=jh(v),j=k?v:p(v),b=_!==void 0;return j?(_||r.getState().nodes).filter(E=>{const R=r.getState().nodeLookup.get(E.id);if(R&&!k&&(E.id===v.id||!R.internals.positionAbsolute))return!1;const w=ss(b?E:R),N=Bl(w,j);return m&&N>0||N>=w.width*w.height||N>=j.width*j.height}):[]},isNodeIntersecting:(v,m,_=!0)=>{const j=jh(v)?v:p(v);if(!j)return!1;const b=Bl(j,m);return _&&b>0||b>=m.width*m.height||b>=j.width*j.height},updateNode:y,updateNodeData:(v,m,_={replace:!1})=>{y(v,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},updateEdge:x,updateEdgeData:(v,m,_={replace:!1})=>{x(v,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},getNodesBounds:v=>{const{nodeLookup:m,nodeOrigin:_}=r.getState();return s1(v,{nodeLookup:m,nodeOrigin:_})},getHandleConnections:({type:v,id:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${v}${m?`-${m}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:v,handleId:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${v?m?`-${v}-${m}`:`-${v}`:""}`))==null?void 0:k.values())??[])},fitView:async v=>{const m=r.getState().fitViewResolver??h1();return r.setState({fitViewQueued:!0,fitViewOptions:v,fitViewResolver:m}),o.nodeQueue.push(_=>[..._]),m.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const np=t=>t.selected,V_=typeof window<"u"?window:void 0;function W_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ye(),{deleteElements:s}=na(),a=as(t,{actInsideInputWithModifier:!1}),u=as(r,{target:V_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(np),edges:c.filter(np)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function U_(t){const r=Ye();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=bc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",mn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const ra={position:"absolute",width:"100%",height:"100%",top:0,left:0},Y_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function X_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=di.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:y,translateExtent:x,minZoom:v,maxZoom:m,zoomActivationKeyCode:_,preventScrolling:k=!0,children:j,noWheelClassName:b,noPanClassName:E,onViewportChange:R,isControlledViewport:w,paneClickDistance:N,selectionOnDrag:A}){const $=Ye(),F=L.useRef(null),{userSelectionActive:X,lib:q,connectionInProgress:te}=De(Y_,Qe),ee=as(_),ne=L.useRef();U_(F);const K=L.useCallback(C=>{R==null||R({x:C[0],y:C[1],zoom:C[2]}),w||$.setState({transform:C})},[R,w]);return L.useEffect(()=>{if(F.current){ne.current=K1({domNode:F.current,minZoom:v,maxZoom:m,translateExtent:x,viewport:y,onDraggingChange:U=>$.setState(M=>M.paneDragging===U?M:{paneDragging:U}),onPanZoomStart:(U,M)=>{const{onViewportChangeStart:D,onMoveStart:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoom:(U,M)=>{const{onViewportChange:D,onMove:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoomEnd:(U,M)=>{const{onViewportChangeEnd:D,onMoveEnd:H}=$.getState();H==null||H(U,M),D==null||D(M)}});const{x:C,y:V,zoom:W}=ne.current.getViewport();return $.setState({panZoom:ne.current,transform:[C,V,W],domNode:F.current.closest(".react-flow")}),()=>{var U;(U=ne.current)==null||U.destroy()}}},[]),L.useEffect(()=>{var C;(C=ne.current)==null||C.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:ee,preventScrolling:k,noPanClassName:E,userSelectionActive:X,noWheelClassName:b,lib:q,onTransformChange:K,connectionInProgress:te,selectionOnDrag:A,paneClickDistance:N})},[t,r,o,s,a,u,c,h,p,ee,k,E,X,b,q,K,te,A,N]),d.jsx("div",{className:"react-flow__renderer",ref:F,style:ra,children:j})}const G_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function q_(){const{userSelectionActive:t,userSelectionRect:r}=De(G_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const qu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},K_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function Q_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=is.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:y,onPaneContextMenu:x,onPaneScroll:v,onPaneMouseEnter:m,onPaneMouseMove:_,onPaneMouseLeave:k,children:j}){const b=L.useRef(0),E=Ye(),{userSelectionActive:R,elementsSelectable:w,dragging:N,panBy:A,autoPanSpeed:$}=De(K_,Qe),F=w&&(t||R),X=L.useRef(null),q=L.useRef(),te=L.useRef(new Set),ee=L.useRef(new Set),ne=L.useRef(!1),K=L.useRef(!1),C=L.useRef({x:0,y:0}),V=L.useRef(!1),W=Z=>{if(K.current||ne.current||E.getState().connection.inProgress){K.current=!1,ne.current=!1;return}y==null||y(Z),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},U=Z=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Z.preventDefault();return}x==null||x(Z)},M=v?Z=>v(Z):void 0,D=Z=>{K.current&&(Z.stopPropagation(),K.current=!1)},H=Z=>{var $e,st;if(Z.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:se,transform:me}=E.getState();if(q.current=se==null?void 0:se.getBoundingClientRect(),!q.current)return;const ke=Z.target===X.current;if(!ke&&!!Z.target.closest(".nokey")||!t||!(c&&ke||r)||Z.button!==0||!Z.isPrimary)return;(st=($e=Z.target)==null?void 0:$e.setPointerCapture)==null||st.call($e,Z.pointerId),K.current=!1;const{x:Ne,y:Me}=gn(Z.nativeEvent,q.current),Te=ms({x:Ne,y:Me},me);E.setState({userSelectionRect:{width:0,height:0,startX:Te.x,startY:Te.y,x:Ne,y:Me}}),ke||(Z.stopPropagation(),Z.preventDefault())};function I(Z,se){const{userSelectionRect:me}=E.getState();if(!me)return;const{transform:ke,nodeLookup:ve,edgeLookup:re,connectionLookup:Ne,triggerNodeChanges:Me,triggerEdgeChanges:Te,defaultEdgeOptions:$e}=E.getState(),st={x:me.startX,y:me.startY},{x:lt,y:at}=eo(st,ke),Xe={startX:st.x,startY:st.y,x:Zmt.id)),ee.current=new Set;const gt=($e==null?void 0:$e.selectable)??!0;for(const mt of te.current){const Pt=Ne.get(mt);if(Pt)for(const{edgeId:ut}of Pt.values()){const Je=re.get(ut);Je&&(Je.selectable??gt)&&ee.current.add(ut)}}if(!bh(wt,te.current)){const mt=Xi(ve,te.current,!0);Me(mt)}if(!bh(qt,ee.current)){const mt=Xi(re,ee.current);Te(mt)}E.setState({userSelectionRect:Xe,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!a||!q.current)return;const[Z,se]=Nc(C.current,q.current,$);A({x:Z,y:se}).then(me=>{if(!K.current||!me){b.current=requestAnimationFrame(z);return}const{x:ke,y:ve}=C.current;I(ke,ve),b.current=requestAnimationFrame(z)})}const ie=()=>{cancelAnimationFrame(b.current),b.current=0,V.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=Z=>{const{userSelectionRect:se,transform:me,resetSelectedElements:ke}=E.getState();if(!q.current||!se)return;const{x:ve,y:re}=gn(Z.nativeEvent,q.current);C.current={x:ve,y:re};const Ne=eo({x:se.startX,y:se.startY},me);if(!K.current){const Me=r?0:u;if(Math.hypot(ve-Ne.x,re-Ne.y)<=Me)return;ke(),h==null||h(Z)}K.current=!0,V.current||(z(),V.current=!0),I(ve,re)},fe=Z=>{var se,me;if(!F){Z.target===X.current&&E.getState().connection.inProgress&&(ne.current=!0);return}Z.button===0&&((me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),!R&&Z.target===X.current&&E.getState().userSelectionRect&&(W==null||W(Z)),E.setState({userSelectionActive:!1,userSelectionRect:null}),K.current&&(p==null||p(Z),E.setState({nodesSelectionActive:te.current.size>0})),ie())},he=Z=>{var se,me;(me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),ie()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:nt(["react-flow__pane",{draggable:pe,dragging:N,selection:t}]),onClick:F?void 0:qu(W,X),onContextMenu:qu(U,X),onWheel:qu(M,X),onPointerEnter:F?void 0:m,onPointerMove:F?oe:_,onPointerUp:fe,onPointerCancel:F?he:void 0,onPointerDownCapture:F?H:void 0,onClickCapture:F?D:void 0,onPointerLeave:k,ref:X,style:ra,children:[j,d.jsx(q_,{})]})}function hc({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),y=h.get(t);if(!y){p==null||p("012",mn.error012(t));return}r.setState({nodesSelectionActive:!1}),y.selected?(o||y.selected&&c)&&(u({nodes:[y],edges:[]}),requestAnimationFrame(()=>{var x;return(x=s==null?void 0:s.current)==null?void 0:x.blur()})):a([t])}function Wg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ye(),[p,y]=L.useState(!1),x=L.useRef();return L.useEffect(()=>{if(!r)return x.current=$1({getStoreItems:()=>h.getState(),onNodeMouseDown:v=>{hc({id:v,store:h,nodeRef:t})},onDragStart:()=>{y(!0)},onDragStop:()=>{y(!1)}}),()=>{var v;(v=x.current)==null||v.destroy(),x.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!x.current||x.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const Z_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Ug(){const t=Ye();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:y,nodeOrigin:x}=t.getState(),v=new Map,m=Z_(c),_=a?u[0]:5,k=a?u[1]:5,j=o.direction.x*_*o.factor,b=o.direction.y*k*o.factor;for(const[,E]of y){if(!m(E))continue;let R={x:E.internals.positionAbsolute.x+j,y:E.internals.positionAbsolute.y+b};a&&(R=gs(R,u));const{position:w,positionAbsolute:N}=cg({nodeId:E.id,nextPosition:R,nodeLookup:y,nodeExtent:s,nodeOrigin:x,onError:h});E.position=w,E.internals.positionAbsolute=N,v.set(E.id,E)}p(v)},[])}const Rc=L.createContext(null),J_=Rc.Provider;Rc.Consumer;const Yg=()=>L.useContext(Rc),eS=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Xg=L.createContext(null);function tS({children:t}){const r=De(eS,Qe);return d.jsx(Xg.Provider,{value:r,children:t})}function nS(){const t=L.useContext(Xg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const rS={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},iS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:y}=c;if(!h&&!a)return rS;const x=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:x,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Zi.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:x&&y}};function oS({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:y,onMouseDown:x,onTouchStart:v,...m},_){var V,W;const k=c||null,j=t==="target",b=Ye(),E=Yg(),{connectOnClick:R,noPanClassName:w,rfId:N}=nS(),{connectingFrom:A,connectingTo:$,clickConnecting:F,isPossibleEndHandle:X,connectionInProcess:q,clickConnectionInProcess:te,valid:ee}=De(iS(E,k,t),Qe);E||(W=(V=b.getState()).onError)==null||W.call(V,"010",mn.error010());const ne=U=>{const{defaultEdgeOptions:M,onConnect:D,hasDefaultEdges:H}=b.getState(),I={...M,...U};if(H){const{edges:z,setEdges:ie,onError:oe}=b.getState();ie(z_(I,z,{onError:oe}))}D==null||D(I),h==null||h(I)},K=U=>{if(!E)return;const M=xg(U.nativeEvent);if(a&&(M&&U.button===0||!M)){const D=b.getState();fc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:j,handleId:k,nodeId:E,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...H)=>{var I,z;return(z=(I=b.getState()).onConnectEnd)==null?void 0:z.call(I,...H)},updateConnection:D.updateConnection,onConnect:ne,isValidConnection:o||((...H)=>{var I,z;return((z=(I=b.getState()).isValidConnection)==null?void 0:z.call(I,...H))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}M?x==null||x(U):v==null||v(U)},C=U=>{const{onClickConnectStart:M,onClickConnectEnd:D,connectionClickStartHandle:H,connectionMode:I,isValidConnection:z,lib:ie,rfId:oe,nodeLookup:fe,connection:he}=b.getState();if(!E||!H&&!a)return;if(!H){M==null||M(U.nativeEvent,{nodeId:E,handleId:k,handleType:t}),b.setState({connectionClickStartHandle:{nodeId:E,type:t,id:k}});return}const pe=yg(U.target),Z=o||z,{connection:se,isValid:me}=fc.isValid(U.nativeEvent,{handle:{nodeId:E,id:k,type:t},connectionMode:I,fromNodeId:H.nodeId,fromHandleId:H.id||null,fromType:H.type,isValidConnection:Z,flowId:oe,doc:pe,lib:ie,nodeLookup:fe});me&&se&&ne(se);const ke=structuredClone(he);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,D==null||D(U,ke),b.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":k,"data-nodeid":E,"data-handlepos":r,"data-id":`${N}-${E}-${k}-${t}`,className:nt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",w,y,{source:!j,target:j,connectable:s,connectablestart:a,connectableend:u,clickconnecting:F,connectingfrom:A,connectingto:$,valid:ee,connectionindicator:s&&(!q||X)&&(q||te?u:a)}]),onMouseDown:K,onTouchStart:K,onClick:R?C:void 0,ref:_,...m,children:p})}const no=L.memo(Hg(oS));function sS({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(no,{type:"source",position:o,isConnectable:r})]})}function lS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:s=Se.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(no,{type:"source",position:s,isConnectable:r})]})}function aS(){return null}function uS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const Wl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},rp={input:sS,default:lS,output:uS,group:aS};function cS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const dS=t=>{const{width:r,height:o,x:s,y:a}=ps(t.nodeLookup,{filter:u=>!!u.selected});return{width:pn(r)?r:null,height:pn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function fS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ye(),{width:a,height:u,transformString:c,userSelectionActive:h}=De(dS,Qe),p=Ug(),y=L.useRef(null);L.useEffect(()=>{var _;o||(_=y.current)==null||_.focus({preventScroll:!0})},[o]);const x=!h&&a!==null&&u!==null;if(Wg({nodeRef:y,disabled:!x}),!x)return null;const v=t?_=>{const k=s.getState().nodes.filter(j=>j.selected);t(_,k)}:void 0,m=_=>{Object.prototype.hasOwnProperty.call(Wl,_.key)&&(_.preventDefault(),p({direction:Wl[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:nt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:y,className:"react-flow__nodesselection-rect",onContextMenu:v,tabIndex:o?void 0:-1,onKeyDown:o?void 0:m,style:{width:a,height:u}})})}const ip=typeof window<"u"?window:void 0,hS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Gg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:y,selectionOnDrag:x,selectionMode:v,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:j,zoomActivationKeyCode:b,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:N,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:X,autoPanOnSelection:q,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,preventScrolling:C,onSelectionContextMenu:V,noWheelClassName:W,noPanClassName:U,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:H}){const{nodesSelectionActive:I,userSelectionActive:z}=De(hS,Qe),ie=as(y,{target:ip}),oe=as(j,{target:ip}),fe=oe||X,he=oe||N,pe=x&&fe!==!0,Z=ie||z||pe;return W_({deleteKeyCode:p,multiSelectionKeyCode:k}),d.jsx(X_,{onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:!ie&&fe,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,zoomActivationKeyCode:b,preventScrolling:C,noWheelClassName:W,noPanClassName:U,onViewportChange:D,isControlledViewport:H,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(Q_,{onSelectionStart:m,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:q,isSelecting:!!Z,selectionMode:v,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:pe,children:[t,I&&d.jsx(fS,{onSelectionContextMenu:V,noPanClassName:U,disableKeyboardA11y:M})]})})}Gg.displayName="FlowRenderer";const pS=L.memo(Gg),gS=t=>r=>t?kc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function mS(t){return De(L.useCallback(gS(t),[t]),Qe)}const yS=t=>t.updateNodeInternals;function vS(){const t=De(yS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function xS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ye(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),y=L.useRef(r),x=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!x||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[x,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const v=y.current!==r,m=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(v||m||_)&&(y.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function wS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:y,nodesFocusable:x,resizeObserver:v,noDragClassName:m,noPanClassName:_,disableKeyboardA11y:k,rfId:j,nodeTypes:b,nodeClickDistance:E,onError:R}){const{node:w,internals:N,isParent:A}=De(Z=>{const se=Z.nodeLookup.get(t),me=Z.parentLookup.has(t);return{node:se,internals:se.internals,isParent:me}},Qe);let $=w.type||"default",F=(b==null?void 0:b[$])||rp[$];F===void 0&&(R==null||R("003",mn.error003($)),$="default",F=(b==null?void 0:b.default)||rp.default);const X=!!(w.draggable||h&&typeof w.draggable>"u"),q=!!(w.selectable||p&&typeof w.selectable>"u"),te=!!(w.connectable||y&&typeof w.connectable>"u"),ee=!!(w.focusable||x&&typeof w.focusable>"u"),ne=Ye(),K=gg(w),C=xS({node:w,nodeType:$,hasDimensions:K,resizeObserver:v}),V=Wg({nodeRef:C,disabled:w.hidden||!X,noDragClassName:m,handleSelector:w.dragHandle,nodeId:t,isSelectable:q,nodeClickDistance:E}),W=Ug();if(w.hidden)return null;const U=vn(w),M=cS(w),D=q||X||r||o||s||a,H=o?Z=>o(Z,{...N.userNode}):void 0,I=s?Z=>s(Z,{...N.userNode}):void 0,z=a?Z=>a(Z,{...N.userNode}):void 0,ie=u?Z=>u(Z,{...N.userNode}):void 0,oe=c?Z=>c(Z,{...N.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:se,nodeDragThreshold:me}=ne.getState();q&&(!se||!X||me>0)&&hc({id:t,store:ne,nodeRef:C}),r&&r(Z,{...N.userNode})},he=Z=>{if(!(vg(Z.nativeEvent)||k)){if(og.includes(Z.key)&&q){const se=Z.key==="Escape";hc({id:t,store:ne,unselect:se,nodeRef:C})}else if(X&&w.selected&&Object.prototype.hasOwnProperty.call(Wl,Z.key)){Z.preventDefault();const{ariaLabelConfig:se}=ne.getState();ne.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),W({direction:Wl[Z.key],factor:Z.shiftKey?4:1})}}},pe=()=>{var Ne;if(k||!((Ne=C.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:Z,width:se,height:me,autoPanOnNodeFocus:ke,setCenter:ve}=ne.getState();if(!ke)return;kc(new Map([[t,w]]),{x:0,y:0,width:se,height:me},Z,!0).length>0||ve(w.position.x+U.width/2,w.position.y+U.height/2,{zoom:Z[2]})};return d.jsx("div",{className:nt(["react-flow__node",`react-flow__node-${$}`,{[_]:X},w.className,{selected:w.selected,selectable:q,parent:A,draggable:X,dragging:V}]),ref:C,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:K?"visible":"hidden",...w.style,...M},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:H,onMouseMove:I,onMouseLeave:z,onContextMenu:ie,onClick:fe,onDoubleClick:oe,onKeyDown:ee?he:void 0,tabIndex:ee?0:void 0,onFocus:ee?pe:void 0,role:w.ariaRole??(ee?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${zg}-${j}`,"aria-label":w.ariaLabel,...w.domAttributes,children:d.jsx(J_,{value:t,children:d.jsx(F,{id:t,data:w.data,type:$,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:w.selected??!1,selectable:q,draggable:X,deletable:w.deletable??!0,isConnectable:te,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:V,dragHandle:w.dragHandle,zIndex:N.z,parentId:w.parentId,...U})})})}var _S=L.memo(wS);const SS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function qg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=De(SS,Qe),u=mS(t.onlyRenderVisibleElements),c=vS();return d.jsx("div",{className:"react-flow__nodes",style:ra,children:u.map(h=>d.jsx(_S,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}qg.displayName="NodeRenderer";const kS=L.memo(qg);function NS(t){return De(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&y1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const jS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},bS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},op={[os.Arrow]:jS,[os.ArrowClosed]:bS};function ES(t){const r=Ye();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(op,t)?op[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",mn.error009(t)),null)},[t])}const CS=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=ES(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},Kg=({defaultColor:t,rfId:r})=>{const o=De(u=>u.edges),s=De(u=>u.defaultEdgeOptions),a=L.useMemo(()=>j1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(CS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Kg.displayName="MarkerDefinitions";var MS=L.memo(Kg);function Qg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:y,...x}){const[v,m]=L.useState({x:1,y:0,width:0,height:0}),_=nt(["react-flow__edge-textwrapper",y]),k=L.useRef(null);return L.useEffect(()=>{if(k.current){const j=k.current.getBBox();m({x:j.x,y:j.y,width:j.width,height:j.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-v.width/2} ${r-v.height/2})`,className:_,visibility:v.width?"visible":"hidden",...x,children:[a&&d.jsx("rect",{width:v.width+2*c[0],x:-c[0],y:-c[1],height:v.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:v.height/2,dy:"0.3em",ref:k,style:s,children:o}),p]}):null}Qg.displayName="EdgeText";const PS=L.memo(Qg);function ys({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:y=20,...x}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...x,d:t,fill:"none",className:nt(["react-flow__edge-path",x.className])}),y?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:y,className:"react-flow__edge-interaction"}):null,s&&pn(r)&&pn(o)?d.jsx(PS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function sp({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function Zg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top}){const[c,h]=sp({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,y]=sp({pos:u,x1:s,y1:a,x2:t,y2:r}),[x,v,m,_]=wg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:y});return[`M${t},${r} C${c},${h} ${p},${y} ${s},${a}`,x,v,m,_]}function Jg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})=>{const[R,w,N]=Zg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),A=t.isInternal?void 0:r;return d.jsx(ys,{id:A,path:R,labelX:w,labelY:N,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})})}const IS=Jg({isInternal:!1}),em=Jg({isInternal:!0});IS.displayName="SimpleBezierEdge";em.displayName="SimpleBezierEdgeInternal";function tm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,sourcePosition:_=Se.Bottom,targetPosition:k=Se.Top,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=Vl({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),$=t.isInternal?void 0:r;return d.jsx(ys,{id:$,path:w,labelX:N,labelY:A,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,markerEnd:j,markerStart:b,interactionWidth:R})})}const nm=tm({isInternal:!1}),rm=tm({isInternal:!0});nm.displayName="SmoothStepEdge";rm.displayName="SmoothStepEdgeInternal";function im(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(nm,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const RS=im({isInternal:!1}),om=im({isInternal:!0});RS.displayName="StepEdge";om.displayName="StepEdgeInternal";function sm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,markerEnd:_,markerStart:k,interactionWidth:j})=>{const[b,E,R]=kg({sourceX:o,sourceY:s,targetX:a,targetY:u}),w=t.isInternal?void 0:r;return d.jsx(ys,{id:w,path:b,labelX:E,labelY:R,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,markerEnd:_,markerStart:k,interactionWidth:j})})}const TS=sm({isInternal:!1}),lm=sm({isInternal:!0});TS.displayName="StraightEdge";lm.displayName="StraightEdgeInternal";function am(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=_g({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:E==null?void 0:E.curvature}),$=t.isInternal?void 0:r;return d.jsx(ys,{id:$,path:w,labelX:N,labelY:A,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:R})})}const LS=am({isInternal:!1}),um=am({isInternal:!0});LS.displayName="BezierEdge";um.displayName="BezierEdgeInternal";const lp={default:um,straight:lm,step:om,smoothstep:rm,simplebezier:em},ap={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},AS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,$S=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,up="react-flow__edgeupdater";function cp({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:nt([up,`${up}-${h}`]),cx:AS(r,s,t),cy:$S(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function zS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:y,onReconnectStart:x,onReconnectEnd:v,setReconnecting:m,setUpdateHover:_}){const k=Ye(),j=(N,A)=>{if(N.button!==0)return;const{autoPanOnConnect:$,domNode:F,connectionMode:X,connectionRadius:q,lib:te,onConnectStart:ee,cancelConnection:ne,nodeLookup:K,rfId:C,panBy:V,updateConnection:W}=k.getState(),U=A.type==="target",M=(I,z)=>{m(!1),v==null||v(I,o,A.type,z)},D=I=>y==null?void 0:y(o,I),H=(I,z)=>{m(!0),x==null||x(N,o,A.type),ee==null||ee(I,z)};fc.onPointerDown(N.nativeEvent,{autoPanOnConnect:$,connectionMode:X,connectionRadius:q,domNode:F,handleId:A.id,nodeId:A.nodeId,nodeLookup:K,isTarget:U,edgeUpdaterType:A.type,lib:te,flowId:C,cancelConnection:ne,panBy:V,isValidConnection:(...I)=>{var z,ie;return((ie=(z=k.getState()).isValidConnection)==null?void 0:ie.call(z,...I))??!0},onConnect:D,onConnectStart:H,onConnectEnd:(...I)=>{var z,ie;return(ie=(z=k.getState()).onConnectEnd)==null?void 0:ie.call(z,...I)},onReconnectEnd:M,updateConnection:W,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:N.currentTarget})},b=N=>j(N,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),E=N=>j(N,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),R=()=>_(!0),w=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(cp,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:b,onMouseEnter:R,onMouseOut:w,type:"source"}),(t===!0||t==="target")&&d.jsx(cp,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:E,onMouseEnter:R,onMouseOut:w,type:"target"})]})}function DS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,reconnectRadius:x,onReconnect:v,onReconnectStart:m,onReconnectEnd:_,rfId:k,edgeTypes:j,noPanClassName:b,onError:E,disableKeyboardA11y:R}){let w=De(ve=>ve.edgeLookup.get(t));const N=De(ve=>ve.defaultEdgeOptions);w=N?{...N,...w}:w;let A=w.type||"default",$=(j==null?void 0:j[A])||lp[A];$===void 0&&(E==null||E("011",mn.error011(A)),A="default",$=(j==null?void 0:j.default)||lp.default);const F=!!(w.focusable||r&&typeof w.focusable>"u"),X=typeof v<"u"&&(w.reconnectable||o&&typeof w.reconnectable>"u"),q=!!(w.selectable||s&&typeof w.selectable>"u"),te=L.useRef(null),[ee,ne]=L.useState(!1),[K,C]=L.useState(!1),V=Ye(),{zIndex:W=w.zIndex,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z}=De(L.useCallback(ve=>{const re=ve.nodeLookup.get(w.source),Ne=ve.nodeLookup.get(w.target);if(!re||!Ne)return ap;const Me=N1({id:t,sourceNode:re,targetNode:Ne,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:ve.connectionMode,onError:E}),Te=m1({selected:w.selected,zIndex:w.zIndex,sourceNode:re,targetNode:Ne,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||ap,zIndex:Te}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex,E]),Qe),ie=L.useMemo(()=>w.markerStart?`url('#${cc(w.markerStart,k)}')`:void 0,[w.markerStart,k]),oe=L.useMemo(()=>w.markerEnd?`url('#${cc(w.markerEnd,k)}')`:void 0,[w.markerEnd,k]);if(w.hidden||U===null||M===null||D===null||H===null)return null;const fe=ve=>{var Te;const{addSelectedEdges:re,unselectNodesAndEdges:Ne,multiSelectionActive:Me}=V.getState();q&&(V.setState({nodesSelectionActive:!1}),w.selected&&Me?(Ne({nodes:[],edges:[w]}),(Te=te.current)==null||Te.blur()):re([t])),a&&a(ve,w)},he=u?ve=>{u(ve,{...w})}:void 0,pe=c?ve=>{c(ve,{...w})}:void 0,Z=h?ve=>{h(ve,{...w})}:void 0,se=p?ve=>{p(ve,{...w})}:void 0,me=y?ve=>{y(ve,{...w})}:void 0,ke=ve=>{var re;if(!R&&og.includes(ve.key)&&q){const{unselectNodesAndEdges:Ne,addSelectedEdges:Me}=V.getState();ve.key==="Escape"?((re=te.current)==null||re.blur(),Ne({edges:[w]})):Me([t])}};return d.jsx("svg",{style:{zIndex:W},children:d.jsxs("g",{className:nt(["react-flow__edge",`react-flow__edge-${A}`,w.className,b,{selected:w.selected,animated:w.animated,inactive:!q&&!a,updating:ee,selectable:q}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:Z,onMouseMove:se,onMouseLeave:me,onKeyDown:F?ke:void 0,tabIndex:F?0:void 0,role:w.ariaRole??(F?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":F?`${Dg}-${k}`:void 0,ref:te,...w.domAttributes,children:[!K&&d.jsx($,{id:t,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:q,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),X&&d.jsx(zS,{edge:w,isReconnectable:X,reconnectRadius:x,onReconnect:v,onReconnectStart:m,onReconnectEnd:_,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,setUpdateHover:ne,setReconnecting:C})]})})}var OS=L.memo(DS);const FS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function cm({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:y,onEdgeClick:x,reconnectRadius:v,onEdgeDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:j}){const{edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,onError:w}=De(FS,Qe),N=NS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(MS,{defaultColor:t,rfId:o}),N.map(A=>d.jsx(OS,{id:A,edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,onClick:x,reconnectRadius:v,onDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:w,edgeTypes:s,disableKeyboardA11y:j},A))]})}cm.displayName="EdgeRenderer";const HS=L.memo(cm),dp=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function BS({children:t}){const r=Ye(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return Bg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=dp(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:dp(s)},children:t})}function VS(t){const r=na(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const WS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function US(t){const r=De(WS),o=Ye();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function YS(t){return t.connection.inProgress?{...t.connection,to:ms(t.connection.to,t.transform)}:{...t.connection}}function XS(t){return YS}function GS(t){const r=XS();return De(r,Qe)}const qS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function KS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=De(qS,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:nt(["react-flow__connection",ag(h)]),children:d.jsx(dm,{style:r,type:o,CustomComponent:s,isValid:h})})})}const dm=({style:t,type:r=Lr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:y,toNode:x,toHandle:v,toPosition:m,pointer:_}=GS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:y.x,toY:y.y,fromPosition:p,toPosition:m,connectionStatus:ag(s),toNode:x,toHandle:v,pointer:_});let k="";const j={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:y.x,targetY:y.y,targetPosition:m};switch(r){case Lr.Bezier:[k]=_g(j);break;case Lr.SimpleBezier:[k]=Zg(j);break;case Lr.Step:[k]=Vl({...j,borderRadius:0});break;case Lr.SmoothStep:[k]=Vl(j);break;default:[k]=kg(j)}return d.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};dm.displayName="ConnectionLine";const QS={};function fp(t=QS){L.useRef(t),Ye(),L.useEffect(()=>{},[t])}function ZS(){Ye(),L.useRef(!1),L.useEffect(()=>{},[])}function fm({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:x,onSelectionContextMenu:v,onSelectionStart:m,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:j,connectionLineComponent:b,connectionLineContainerStyle:E,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,deleteKeyCode:X,onlyRenderVisibleElements:q,elementsSelectable:te,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,preventScrolling:V,defaultMarkerColor:W,zoomOnScroll:U,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,zoomOnDoubleClick:z,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneScroll:se,onPaneContextMenu:me,paneClickDistance:ke,nodeClickDistance:ve,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,noDragClassName:Xe,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,viewport:ut,onViewportChange:Je,nodesDraggable:An}){return fp(t),fp(r),ZS(),VS(o),US(ut),d.jsx(pS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneContextMenu:me,onPaneScroll:se,paneClickDistance:ke,deleteKeyCode:X,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,elementsSelectable:te,zoomOnScroll:U,zoomOnPinch:M,zoomOnDoubleClick:z,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,onSelectionContextMenu:v,preventScrolling:V,noDragClassName:Xe,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,onViewportChange:Je,isControlledViewport:!!ut,children:d.jsxs(BS,{children:[d.jsx(HS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,onlyRenderVisibleElements:q,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,defaultMarkerColor:W,noPanClassName:qt,disableKeyboardA11y:gt,rfId:Pt}),d.jsx(KS,{style:j,type:k,component:b,containerStyle:E}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(kS,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:x,nodeClickDistance:ve,onlyRenderVisibleElements:q,noPanClassName:qt,noDragClassName:Xe,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,nodesDraggable:An}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}fm.displayName="GraphView";const JS=L.memo(fm),ek=pg(),hp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:y=2,nodeOrigin:x,nodeExtent:v,zIndexMode:m="basic"}={})=>{const _=new Map,k=new Map,j=new Map,b=new Map,E=s??r??[],R=o??t??[],w=x??[0,0],N=v??rs;bg(j,b,E);const{nodesInitialized:A}=dc(R,_,k,{nodeOrigin:w,nodeExtent:N,zIndexMode:m});let $=[0,0,1];if(c&&a&&u){const F=ps(_,{filter:ee=>!!((ee.width||ee.initialWidth)&&(ee.height||ee.initialHeight))}),{x:X,y:q,zoom:te}=jc(F,a,u,p,y,(h==null?void 0:h.padding)??.1);$=[X,q,te]}return{rfId:"1",width:a??0,height:u??0,transform:$,nodes:R,nodesInitialized:A,nodeLookup:_,parentLookup:k,edges:E,edgeLookup:b,connectionLookup:j,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:y,translateExtent:rs,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Zi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...lg},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:ek,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:sg,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},tk=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:x,nodeExtent:v,zIndexMode:m})=>h_((_,k)=>{async function j(){const{nodeLookup:b,panZoom:E,fitViewOptions:R,fitViewResolver:w,width:N,height:A,minZoom:$,maxZoom:F}=k();E&&(await u1({nodes:b,width:N,height:A,panZoom:E,minZoom:$,maxZoom:F},R),w==null||w.resolve(!0),_({fitViewResolver:null}))}return{...hp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:x,nodeExtent:v,defaultNodes:o,defaultEdges:s,zIndexMode:m}),setNodes:b=>{const{nodeLookup:E,parentLookup:R,nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,fitViewQueued:$,zIndexMode:F,nodesSelectionActive:X}=k(),{nodesInitialized:q,hasSelectedNodes:te}=dc(b,E,R,{nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:F}),ee=X&&te;$&&q?(j(),_({nodes:b,nodesInitialized:q,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:ee})):_({nodes:b,nodesInitialized:q,nodesSelectionActive:ee})},setEdges:b=>{const{connectionLookup:E,edgeLookup:R}=k();bg(E,R,b),_({edges:b})},setDefaultNodesAndEdges:(b,E)=>{if(b){const{setNodes:R}=k();R(b),_({hasDefaultNodes:!0})}if(E){const{setEdges:R}=k();R(E),_({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:E,nodeLookup:R,parentLookup:w,domNode:N,nodeOrigin:A,nodeExtent:$,debug:F,fitViewQueued:X,zIndexMode:q}=k(),{changes:te,updatedInternals:ee}=R1(b,R,w,N,A,$,q);ee&&(C1(R,w,{nodeOrigin:A,nodeExtent:$,zIndexMode:q}),X?(j(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(te==null?void 0:te.length)>0&&(F&&console.log("React Flow: trigger node changes",te),E==null||E(te)))},updateNodePositions:(b,E=!1)=>{const R=[];let w=[];const{nodeLookup:N,triggerNodeChanges:A,connection:$,updateConnection:F,onNodesChangeMiddlewareMap:X}=k();for(const[q,te]of b){const ee=N.get(q),ne=!!(ee!=null&&ee.expandParent&&(ee!=null&&ee.parentId)&&(te!=null&&te.position)),K={id:q,type:"position",position:ne?{x:Math.max(0,te.position.x),y:Math.max(0,te.position.y)}:te.position,dragging:E};if(ee&&$.inProgress&&$.fromNode.id===ee.id){const C=mi(ee,$.fromHandle,Se.Left,!0);F({...$,from:C})}ne&&ee.parentId&&R.push({id:q,parentId:ee.parentId,rect:{...te.internals.positionAbsolute,width:te.measured.width??0,height:te.measured.height??0}}),w.push(K)}if(R.length>0){const{parentLookup:q,nodeOrigin:te}=k(),ee=Ic(R,N,q,te);w.push(...ee)}for(const q of X.values())w=q(w);A(w)},triggerNodeChanges:b=>{const{onNodesChange:E,setNodes:R,nodes:w,hasDefaultNodes:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=L_(b,w);R($)}A&&console.log("React Flow: trigger node changes",b),E==null||E(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:E,setEdges:R,edges:w,hasDefaultEdges:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=A_(b,w);R($)}A&&console.log("React Flow: trigger edge changes",b),E==null||E(b)}},addSelectedNodes:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));N($);return}N(Xi(w,new Set([...b]),!0)),A(Xi(R))},addSelectedEdges:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));A($);return}A(Xi(R,new Set([...b]))),N(Xi(w,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:E}={})=>{const{edges:R,nodes:w,nodeLookup:N,triggerNodeChanges:A,triggerEdgeChanges:$}=k(),F=b||w,X=E||R,q=[];for(const ee of F){if(!ee.selected)continue;const ne=N.get(ee.id);ne&&(ne.selected=!1),q.push(ai(ee.id,!1))}const te=[];for(const ee of X)ee.selected&&te.push(ai(ee.id,!1));A(q),$(te)},setMinZoom:b=>{const{panZoom:E,maxZoom:R}=k();E==null||E.setScaleExtent([b,R]),_({minZoom:b})},setMaxZoom:b=>{const{panZoom:E,minZoom:R}=k();E==null||E.setScaleExtent([R,b]),_({maxZoom:b})},setTranslateExtent:b=>{var E;(E=k().panZoom)==null||E.setTranslateExtent(b),_({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:E,triggerNodeChanges:R,triggerEdgeChanges:w,elementsSelectable:N}=k();if(!N)return;const A=E.reduce((F,X)=>X.selected?[...F,ai(X.id,!1)]:F,[]),$=b.reduce((F,X)=>X.selected?[...F,ai(X.id,!1)]:F,[]);R(A),w($)},setNodeExtent:b=>{const{nodes:E,nodeLookup:R,parentLookup:w,nodeOrigin:N,elevateNodesOnSelect:A,nodeExtent:$,zIndexMode:F}=k();b[0][0]===$[0][0]&&b[0][1]===$[0][1]&&b[1][0]===$[1][0]&&b[1][1]===$[1][1]||(dc(E,R,w,{nodeOrigin:N,nodeExtent:b,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:F}),_({nodeExtent:b}))},panBy:b=>{const{transform:E,width:R,height:w,panZoom:N,translateExtent:A}=k();return T1({delta:b,panZoom:N,transform:E,translateExtent:A,width:R,height:w})},setCenter:async(b,E,R)=>{const{width:w,height:N,maxZoom:A,panZoom:$}=k();if(!$)return!1;const F=typeof(R==null?void 0:R.zoom)<"u"?R.zoom:A;return await $.setViewport({x:w/2-b*F,y:N/2-E*F,zoom:F},{duration:R==null?void 0:R.duration,ease:R==null?void 0:R.ease,interpolate:R==null?void 0:R.interpolate}),!0},cancelConnection:()=>{_({connection:{...lg}})},updateConnection:b=>{_({connection:b})},reset:()=>_({...hp()})}},Object.is);function hm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:y,nodeOrigin:x,nodeExtent:v,zIndexMode:m,children:_}){const[k]=L.useState(()=>tk({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:y,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:x,nodeExtent:v,zIndexMode:m}));return d.jsx(p_,{value:k,children:d.jsx(F_,{children:d.jsx(tS,{children:_})})})}function nk({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:y,maxZoom:x,nodeOrigin:v,nodeExtent:m,zIndexMode:_}){return L.useContext(ea)?d.jsx(d.Fragment,{children:t}):d.jsx(hm,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:y,initialMaxZoom:x,nodeOrigin:v,nodeExtent:m,zIndexMode:_,children:t})}const rk={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function ik({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:y,onMove:x,onMoveStart:v,onMoveEnd:m,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,onNodeDragStart:F,onNodeDrag:X,onNodeDragStop:q,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onSelectionChange:K,onSelectionDragStart:C,onSelectionDrag:V,onSelectionDragStop:W,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:H,connectionMode:I,connectionLineType:z=Lr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:Z=!1,selectionMode:se=is.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:ke=ls()?"Meta":"Control",zoomActivationKeyCode:ve=ls()?"Meta":"Control",snapToGrid:re,snapGrid:Ne,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Te,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,nodeOrigin:Xe=Og,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt=!0,defaultViewport:mt=E_,minZoom:Pt=.5,maxZoom:ut=2,translateExtent:Je=rs,preventScrolling:An=!0,nodeExtent:Ot,defaultMarkerColor:xn="#b1b1b7",zoomOnScroll:oo=!0,zoomOnPinch:$n=!0,panOnScroll:vi=!1,panOnScrollSpeed:or=.5,panOnScrollMode:$r=di.Free,zoomOnDoubleClick:zn=!0,panOnDrag:zr=!0,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn=1,nodeClickDistance:Fn=0,children:_n,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn=10,onNodesChange:Ht,onEdgesChange:Or,noDragClassName:nn="nodrag",noWheelClassName:Fr="nowheel",noPanClassName:yt="nopan",fitView:Hn,fitViewOptions:ur,connectOnClick:so,attributionPosition:It,proOptions:Bn,defaultEdgeOptions:Hr,elevateNodesOnSelect:jn=!0,elevateEdgesOnSelect:Br=!1,disableKeyboardA11y:xi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:lo,autoPanOnSelection:Vr=!0,autoPanSpeed:wi,connectionRadius:cr,isValidConnection:ao,onError:dr,style:Vn,id:bt,nodeDragThreshold:Wr,connectionDragThreshold:Et,viewport:uo,onViewportChange:Ur,width:Yr,height:Wn,colorMode:Un="light",debug:bn,onScroll:Bt,ariaLabelConfig:_i,zIndexMode:Xr="basic",...fr},hr){const Yn=bt||"1",En=I_(Un),co=L.useCallback(pr=>{pr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Bt==null||Bt(pr)},[Bt]);return d.jsx("div",{"data-testid":"rf__wrapper",...fr,onScroll:co,style:{...Vn,...rk},ref:hr,className:nt(["react-flow",a,En]),id:bt,role:"application",children:d.jsxs(nk,{nodes:t,edges:r,width:Yr,height:Wn,fitView:Hn,fitViewOptions:ur,minZoom:Pt,maxZoom:ut,nodeOrigin:Xe,nodeExtent:Ot,zIndexMode:Xr,children:[d.jsx(P_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt,elevateNodesOnSelect:jn,elevateEdgesOnSelect:Br,minZoom:Pt,maxZoom:ut,nodeExtent:Ot,onNodesChange:Ht,onEdgesChange:Or,snapToGrid:re,snapGrid:Ne,connectionMode:I,translateExtent:Je,connectOnClick:so,defaultEdgeOptions:Hr,fitView:Hn,fitViewOptions:ur,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onNodeDragStart:F,onNodeDrag:X,onNodeDragStop:q,onSelectionDrag:V,onSelectionDragStart:C,onSelectionDragStop:W,onMove:x,onMoveStart:v,onMoveEnd:m,noPanClassName:yt,nodeOrigin:Xe,rfId:Yn,autoPanOnConnect:Ve,autoPanOnNodeDrag:lo,autoPanSpeed:wi,onError:dr,connectionRadius:cr,isValidConnection:ao,selectNodesOnDrag:Te,nodeDragThreshold:Wr,connectionDragThreshold:Et,onBeforeDelete:H,debug:bn,ariaLabelConfig:_i,zIndexMode:Xr}),d.jsx(JS,{onInit:y,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,nodeTypes:u,edgeTypes:c,connectionLineType:z,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:Z,selectionMode:se,deleteKeyCode:he,multiSelectionKeyCode:ke,panActivationKeyCode:me,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:mt,translateExtent:Je,minZoom:Pt,maxZoom:ut,preventScrolling:An,zoomOnScroll:oo,zoomOnPinch:$n,zoomOnDoubleClick:zn,panOnScroll:vi,panOnScrollSpeed:or,panOnScrollMode:$r,panOnDrag:zr,autoPanOnSelection:Vr,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn,nodeClickDistance:Fn,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn,defaultMarkerColor:xn,noDragClassName:nn,noWheelClassName:Fr,noPanClassName:yt,rfId:Yn,disableKeyboardA11y:xi,nodeExtent:Ot,viewport:uo,onViewportChange:Ur,nodesDraggable:$e}),d.jsx(b_,{onSelectionChange:K}),_n,d.jsx(__,{proOptions:Bn,position:It}),d.jsx(w_,{rfId:Yn,disableKeyboardA11y:xi})]})})}var ok=Hg(ik);function sk({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:nt(["react-flow__background-pattern",o,s])})}function lk({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:nt(["react-flow__background-pattern","dots",r])})}var Ar;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Ar||(Ar={}));const ak={[Ar.Dots]:1,[Ar.Lines]:1,[Ar.Cross]:6},uk=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function pm({id:t,variant:r=Ar.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:y,patternClassName:x}){const v=L.useRef(null),{transform:m,patternId:_}=De(uk,Qe),k=s||ak[r],j=r===Ar.Dots,b=r===Ar.Cross,E=Array.isArray(o)?o:[o,o],R=[E[0]*m[2]||1,E[1]*m[2]||1],w=k*m[2],N=Array.isArray(u)?u:[u,u],A=b?[w,w]:R,$=[N[0]*m[2]+A[0]/2,N[1]*m[2]+A[1]/2],F=`${_}${t||""}`;return d.jsxs("svg",{className:nt(["react-flow__background",y]),style:{...p,...ra,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:v,"data-testid":"rf__background",children:[d.jsx("pattern",{id:F,x:m[0]%R[0],y:m[1]%R[1],width:R[0],height:R[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:j?d.jsx(lk,{radius:w/2,className:x}):d.jsx(sk,{dimensions:A,lineWidth:a,variant:r,className:x})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${F})`})]})}pm.displayName="Background";const ck=L.memo(pm);function dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function fk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function hk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 pk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 gk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 bl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:nt(["react-flow__controls-button",r]),...o,children:t})}const mk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function gm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:y,children:x,position:v="bottom-left",orientation:m="vertical","aria-label":_}){const k=Ye(),{isInteractive:j,minZoomReached:b,maxZoomReached:E,ariaLabelConfig:R}=De(mk,Qe),{zoomIn:w,zoomOut:N,fitView:A}=na(),$=()=>{w(),u==null||u()},F=()=>{N(),c==null||c()},X=()=>{A(a),h==null||h()},q=()=>{k.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),p==null||p(!j)},te=m==="horizontal"?"horizontal":"vertical";return d.jsxs(ta,{className:nt(["react-flow__controls",te,y]),position:v,style:t,"data-testid":"rf__controls","aria-label":_??R["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(bl,{onClick:$,className:"react-flow__controls-zoomin",title:R["controls.zoomIn.ariaLabel"],"aria-label":R["controls.zoomIn.ariaLabel"],disabled:E,children:d.jsx(dk,{})}),d.jsx(bl,{onClick:F,className:"react-flow__controls-zoomout",title:R["controls.zoomOut.ariaLabel"],"aria-label":R["controls.zoomOut.ariaLabel"],disabled:b,children:d.jsx(fk,{})})]}),o&&d.jsx(bl,{className:"react-flow__controls-fitview",onClick:X,title:R["controls.fitView.ariaLabel"],"aria-label":R["controls.fitView.ariaLabel"],children:d.jsx(hk,{})}),s&&d.jsx(bl,{className:"react-flow__controls-interactive",onClick:q,title:R["controls.interactive.ariaLabel"],"aria-label":R["controls.interactive.ariaLabel"],children:j?d.jsx(gk,{}):d.jsx(pk,{})}),x]})}gm.displayName="Controls";const yk=L.memo(gm);function vk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:y,borderRadius:x,shapeRendering:v,selected:m,onClick:_}){const{background:k,backgroundColor:j}=u||{},b=c||k||j;return d.jsx("rect",{className:nt(["react-flow__minimap-node",{selected:m},y]),x:r,y:o,rx:x,ry:x,width:s,height:a,style:{fill:b,stroke:h,strokeWidth:p},shapeRendering:v,onClick:_?E=>_(E,t):void 0})}const xk=L.memo(vk),wk=t=>t.nodes.map(r=>r.id),Ku=t=>t instanceof Function?t:()=>t;function _k({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=xk,onClick:c}){const h=De(wk,Qe),p=Ku(r),y=Ku(t),x=Ku(o),v=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(m=>d.jsx(kk,{id:m,nodeColorFunc:p,nodeStrokeColorFunc:y,nodeClassNameFunc:x,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:v},m))})}function Sk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:y,x,y:v,width:m,height:_}=De(k=>{const j=k.nodeLookup.get(t);if(!j)return{node:void 0,x:0,y:0,width:0,height:0};const b=j.internals.userNode,{x:E,y:R}=j.internals.positionAbsolute,{width:w,height:N}=vn(b);return{node:b,x:E,y:R,width:w,height:N}},Qe);return!y||y.hidden||!gg(y)?null:d.jsx(h,{x,y:v,width:m,height:_,style:y.style,selected:!!y.selected,className:s(y),color:r(y),borderRadius:a,strokeColor:o(y),strokeWidth:u,shapeRendering:c,onClick:p,id:y.id})}const kk=L.memo(Sk);var Nk=L.memo(_k);const jk=200,bk=150,Ek=t=>!t.hidden,Ck=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?fg(ps(t.nodeLookup,{filter:Ek}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},pp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,Mk=(t,r)=>pp(t.viewBB,r.viewBB)&&pp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,Pk="react-flow__minimap-desc";function mm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:y,maskStrokeColor:x,maskStrokeWidth:v,position:m="bottom-right",onClick:_,onNodeClick:k,pannable:j=!1,zoomable:b=!1,ariaLabel:E,inversePan:R,zoomStep:w=1,offsetScale:N=5}){const A=Ye(),$=L.useRef(null),{boundingRect:F,viewBB:X,rfId:q,panZoom:te,translateExtent:ee,flowWidth:ne,flowHeight:K,ariaLabelConfig:C}=De(Ck,Mk),V=(t==null?void 0:t.width)??jk,W=(t==null?void 0:t.height)??bk,U=F.width/V,M=F.height/W,D=Math.max(U,M),H=D*V,I=D*W,z=N*D,ie=F.x-(H-F.width)/2-z,oe=F.y-(I-F.height)/2-z,fe=H+z*2,he=I+z*2,pe=`${Pk}-${q}`,Z=L.useRef(0),se=L.useRef();Z.current=D,L.useEffect(()=>{if($.current&&te)return se.current=B1({domNode:$.current,panZoom:te,getTransform:()=>A.getState().transform,getViewScale:()=>Z.current}),()=>{var re;(re=se.current)==null||re.destroy()}},[te]),L.useEffect(()=>{var re;(re=se.current)==null||re.update({translateExtent:ee,width:ne,height:K,inversePan:R,pannable:j,zoomStep:w,zoomable:b})},[j,b,R,w,ee,ne,K]);const me=_?re=>{var Te;const[Ne,Me]=((Te=se.current)==null?void 0:Te.pointer(re))||[0,0];_(re,{x:Ne,y:Me})}:void 0,ke=k?L.useCallback((re,Ne)=>{const Me=A.getState().nodeLookup.get(Ne).internals.userNode;k(re,Me)},[]):void 0,ve=E??C["minimap.ariaLabel"];return d.jsx(ta,{position:m,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof y=="string"?y:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof v=="number"?v*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:nt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:V,height:W,viewBox:`${ie} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:$,onClick:me,children:[ve&&d.jsx("title",{id:pe,children:ve}),d.jsx(Nk,{onClick:ke,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-z},${oe-z}h${fe+z*2}v${he+z*2}h${-fe-z*2}z + M${X.x},${X.y}h${X.width}v${X.height}h${-X.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}mm.displayName="MiniMap";const Ik=L.memo(mm),Rk=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Tk={[to.Line]:"right",[to.Handle]:"bottom-right"};function Lk({nodeId:t,position:r,variant:o=to.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:y=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:v=!1,resizeDirection:m,autoScale:_=!0,shouldResize:k,onResizeStart:j,onResize:b,onResizeEnd:E}){const R=Yg(),w=typeof t=="string"?t:R,N=Ye(),A=L.useRef(null),$=o===to.Handle,F=De(L.useCallback(Rk($&&_),[$,_]),Qe),X=L.useRef(null),q=r??Tk[o];L.useEffect(()=>{if(!(!A.current||!w))return X.current||(X.current=t_({domNode:A.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,domNode:W}=N.getState();return{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,paneDomNode:W}},onChange:(ee,ne)=>{const{triggerNodeChanges:K,nodeLookup:C,parentLookup:V,nodeOrigin:W}=N.getState(),U=[],M={x:ee.x,y:ee.y},D=C.get(w);if(D&&D.expandParent&&D.parentId){const H=D.origin??W,I=ee.width??D.measured.width??0,z=ee.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:I,height:z,...mg({x:ee.x??D.position.x,y:ee.y??D.position.y},{width:I,height:z},D.parentId,C,H)}},oe=Ic([ie],C,V,W);U.push(...oe),M.x=ee.x?Math.max(H[0]*I,ee.x):void 0,M.y=ee.y?Math.max(H[1]*z,ee.y):void 0}if(M.x!==void 0&&M.y!==void 0){const H={id:w,type:"position",position:{...M}};U.push(H)}if(ee.width!==void 0&&ee.height!==void 0){const I={id:w,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:ee.width,height:ee.height}};U.push(I)}for(const H of ne){const I={...H,type:"position"};U.push(I)}K(U)},onEnd:({width:ee,height:ne})=>{const K={id:w,type:"dimensions",resizing:!1,dimensions:{width:ee,height:ne}};N.getState().triggerNodeChanges([K])}})),X.current.update({controlPosition:q,boundaries:{minWidth:h,minHeight:p,maxWidth:y,maxHeight:x},keepAspectRatio:v,resizeDirection:m,onResizeStart:j,onResize:b,onResizeEnd:E,shouldResize:k}),()=>{var ee;(ee=X.current)==null||ee.destroy()}},[q,h,p,y,x,v,j,b,E,k]);const te=q.split("-");return d.jsx("div",{className:nt(["react-flow__resize-control","nodrag",...te,o,s]),ref:A,style:{...a,scale:F,...c&&{[$?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Lk);const Ak={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function ia(t){return Ak[t]??8}const us=208,ro=64,pc=88,$k=28,zk=8;function Dk(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function ym(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const w of t){const N=ia(w.type),A=s.get(N)??[];A.push(w),s.set(N,A)}const u=[...s.keys()].sort((w,N)=>w-N).map(w=>[...s.get(w)??[]].sort((N,A)=>N.name.localeCompare(A.name)||N.id.localeCompare(A.id))),c=new Set(t.map(w=>w.id)),h=new Map,p=new Map;for(const w of t)h.set(w.id,[]),p.set(w.id,[]);for(const w of r)!c.has(w.src)||!c.has(w.dst)||w.src===w.dst||(p.get(w.src).push(w.dst),h.get(w.dst).push(w.src));const y=new Map;u.forEach((w,N)=>{for(const A of w)y.set(A.id,N)});const x=new Map,v=()=>{for(const w of u)w.forEach((N,A)=>x.set(N.id,A))};v();const m=(w,N)=>{const A=w.map(($,F)=>{const X=N($.id).map(te=>x.get(te)).filter(te=>te!==void 0),q=Dk(X);return{n:$,bary:Number.isNaN(q)?F:q,name:$.name,id:$.id}});return A.sort(($,F)=>$.bary-F.bary||$.name.localeCompare(F.name)||$.id.localeCompare(F.id)),A.map($=>$.n)},_=w=>N=>y.get(N)===w;for(let w=0;w(h.get(A)??[]).filter(_(N-1))),v();for(let N=u.length-2;N>=0;N--)u[N]=m(u[N],A=>(p.get(A)??[]).filter(_(N+1))),v()}const k=us+pc,j=ro+$k,b=Math.max(...u.map(w=>w.length),1),E=[];let R=0;for(let w=0;wX.id)),A=new Set((u[w+1]??[]).map(X=>X.id));let $=0;if(A.size)for(const X of r)N.has(X.src)&&A.has(X.dst)&&($+=1);const F=Math.min(48,Math.max(0,($-2)*10));R+=k+F}return u.forEach((w,N)=>{const A=(b-w.length)*j/2;w.forEach(($,F)=>{o.set($.id,{x:E[N]??0,y:A+F*j})})}),o}const Ok=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),vm=90,Fk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),gp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Hk=Math.PI*(3-Math.sqrt(5)),xm=220,Bk=26,Vk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function wm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function VN(t){return gp[t]?gp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Wk(t){return t>=vm?"3d":"2d"}function Uk(t){return t>=vm?"overview":"full"}function Yk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(wm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Fk.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Yk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Gk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function qk(t,r,o,s){const a=new Set(t.map(j=>j.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const j of r){if(!a.has(j.src)||!a.has(j.dst))continue;const b=u.get(j.src)??[];b.push({dst:j.dst,id:j.id}),u.set(j.src,b);const E=c.get(j.dst)??[];E.push({src:j.src,id:j.id}),c.set(j.dst,E)}const h=new Set(t.filter(j=>Ok.has(j.type)).map(j=>j.id)),p=h.size?h:a,y=new Set,x=[o];for(;x.length;){const j=x.pop();if(!y.has(j)){y.add(j);for(const b of u.get(j)??[])y.has(b.dst)||x.push(b.dst)}}const v=new Set([o]),m=[...p].filter(j=>y.has(j)),_=new Set(m);for(;m.length;){const j=m.pop();v.add(j);for(const b of c.get(j)??[])y.has(b.src)&&!_.has(b.src)&&(_.add(b.src),m.push(b.src))}const k=new Set;for(const j of r)v.has(j.src)&&v.has(j.dst)&&k.add(j.id);return{nodeIds:v,edgeIds:k}}function WN(t){const r=new Map;for(const s of t){const a=ia(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*xm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Bk*Math.sqrt(h+1),y=h*Hk;o.set(c.id,{x:u,y:p*Math.cos(y),z:p*Math.sin(y)})})}return o}function UN(t){const r=new Map;for(const o of t){const s=ia(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*xm,count:s}))}const El=16,Kk=12,Qk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Zk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),mp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Jk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},yp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],vp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),eN=new Set(["looks_idempotent_on_pk","null","blank"]),tN=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function nN(t){return mp[t]?mp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function rN(t,r,o){const s=new Map(r.map(m=>[m.id,m])),a=[];Qk.has(t.type)&&a.push("sink"),Zk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(m=>m.dst===t.id),h=o.filter(m=>m.src===t.id),p=c.slice(0,El).map(m=>Cl(m,s,m.src)),y=h.slice(0,El).map(m=>Cl(m,s,m.dst)),x=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,v={type:t.type,typeLabel:Zo(io(t.type)),layer:Vk[ia(t.type)]??"other",purpose:nN(t.type),name:t.name,qualifiedName:t.qualified_name,file:x,context:t.context,roles:a,facts:oN(u).filter(m=>!(m.key==="app"&&m.value===t.context)),inputs:p,outputs:y,extraInputs:Math.max(0,c.length-El),extraOutputs:Math.max(0,h.length-El),degreeIn:c.length,degreeOut:h.length,inputKinds:xp(c.map(m=>Cl(m,s,m.src))),outputKinds:xp(h.map(m=>Cl(m,s,m.dst))),pathSummary:""};return v.pathSummary=iN(v),v}function xp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function iN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function Cl(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Zo(io(s.type)):"",edgeType:t.type,edgeLabel:Zo(t.type),inferred:t.confidence<.8}}function oN(t){const r=[...yp.filter(a=>a in t),...Object.keys(t).filter(a=>!yp.includes(a)&&!vp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||vp.has(a)||tN.has(a))continue;s.add(a);const u=sN(a,t[a]);u!=null&&o.push({key:a,label:Jk[a]??Zo(a),value:u})}return o}function sN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!eN.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return lN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Kk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function lN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const wp=12,_p=.2,aN=.8,uN=ro;function cN(t,r,o){const s=o??ym(t,r),a=[...new Set([...s.values()].map(p=>p.x))].sort((p,y)=>p-y),u=[];for(const p of r){const y=s.get(p.src),x=s.get(p.dst);if(!y||!x)continue;const v=y.y+ro/2,m=x.y+ro/2;if(Math.abs(v-m)k.y0-j.y0||k.y1-j.y1||k.id.localeCompare(j.id)),x=fN(y),v=Math.max(0,...x.values())+1,m=y[0].sourceX,_=dN(a,m);for(const k of y){const j=hN(x.get(k.id)??0,v),b=k.targetX-k.sourceX;if(Math.abs(b-_)<.5){h.set(k.id,j);continue}const E=k.sourceX+_*j;h.set(k.id,Math.min(.92,Math.max(.08,(E-k.sourceX)/b)))}}return h}function dN(t,r){const o=r-us,s=t.find(a=>a>o+1);return s===void 0?pc:Math.max(pc,s-r)}function fN(t){const r=[],o=new Map;for(const s of t){let a=-1;for(let u=0;ur[u]+uN){a=u;break}a<0?(a=r.length,r.push(s.y1)):r[a]=Math.max(r[a],s.y1),o.set(s.id,a)}return o}function hN(t,r){return r<=1?.5:_p+(aN-_p)*t/(r-1)}const pN=new Set,gN=L.lazy(()=>j0(()=>import("./LayeredGraph3D-XtGMK0TN.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),mN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function yN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(no,{type:"target",position:Se.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:io(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Tr(t.name)}),d.jsx(no,{type:"source",position:Se.Right,isConnectable:!1})]})}const vN={load:yN},xN=new Set(["django","react","stitch","arch"]);function wN({id:t,sourceX:r,sourceY:o,targetX:s,targetY:a,sourcePosition:u,targetPosition:c,style:h,markerEnd:p,markerStart:y,label:x,labelStyle:v,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,data:b,interactionWidth:E}){const[R,w,N]=Vl({sourceX:r,sourceY:o,sourcePosition:u,targetX:s,targetY:a,targetPosition:c,borderRadius:8,stepPosition:(b==null?void 0:b.stepPosition)??.5});return d.jsx(ys,{id:t,path:R,labelX:w,labelY:N,label:x,labelStyle:v,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,style:h,markerEnd:p,markerStart:y,interactionWidth:E})}const _N={loadstep:wN};function SN({topologyKey:t}){const{fitView:r}=na();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function kN(t,r,o=null,s={}){const a=new Map(t.map(y=>[y.id,y])),u=ym(t,r),c=cN(t,r,u),h=t.map(y=>{var m;const x=((m=s.roles)==null?void 0:m[y.id])||[],v=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:y.id,type:"load",position:u.get(y.id)??{x:0,y:0},data:{name:y.name,type:y.type,file:y.file_path,roles:x,dim:v},selected:o===y.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:us,height:ro,style:{width:us,height:ro}}}),p=r.filter(y=>a.has(y.src)&&a.has(y.dst)).map(y=>{const x=mN[y.weight]||"var(--edge-cheap)",v=!!(o&&(y.src===o||y.dst===o));return{id:y.id,source:y.src,target:y.dst,type:"loadstep",animated:y.weight==="critical",data:{stepPosition:c.get(y.id)??.5},style:{stroke:x,strokeWidth:y.weight==="critical"?2.4:1.2,strokeDasharray:y.confidence<.8?"6 4":void 0},markerEnd:{type:os.ArrowClosed,width:14,height:14,color:x},label:v?y.type.replaceAll("_"," "):void 0,labelStyle:v?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:v?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:v?[3,5]:void 0,labelBgBorderRadius:v?4:void 0}});return{rfNodes:h,rfEdges:p}}function NN({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:y}){const x=rN(t,r,o);return L.useEffect(()=>{const v=m=>{m.key==="Escape"&&s()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:x.typeLabel}),d.jsx("div",{className:"inspector-roles",children:x.roles.map(v=>d.jsx("span",{className:"inspector-chip",children:v},v))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Tr(x.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:x.purpose}),x.context?d.jsx("div",{className:"muted",children:Tr(x.context)}):null,x.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Tr(x.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Tr(x.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",x.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[x.degreeIn," in · ",x.degreeOut," out"]}),x.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:x.pathSummary}):null,x.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:x.facts.map(v=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:v.label}),d.jsx("dd",{children:Tr(v.value)})]},v.key))}):null,d.jsx(Sp,{title:"Inputs",testId:"graph-inspector-inputs",links:x.inputs,extra:x.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(Sp,{title:"Outputs",testId:"graph-inspector-outputs",links:x.outputs,extra:x.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),a?d.jsx("p",{className:"whatif-hint","data-testid":"whatif-hint",children:y?"Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map.":"Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."}):null,d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",title:"Start a hypothetical walk from this node. Does not use Base/Head.",onClick:()=>a(t.id),children:"What if this changes"}):null,y?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",title:"Hide nodes that are not on a path from here to a sink. Does not start a new walk.",onClick:()=>y(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function Sp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Qu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:y,repoPath:x,onOpenFile:v,pinnedId:m,onPin:_}){const[k,j]=L.useState(null),b=a!==void 0?a:k,E=re=>{a===void 0&&j(re),u==null||u(re)},[R,w]=L.useState(null),[N,A]=L.useState(null),[$,F]=L.useState(new Set(xN)),[X,q]=L.useState(!1),[te,ee]=L.useState(""),[ne,K]=L.useState(!1),C=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,V=R??Wk(t.length),W=N??Uk(t.length),U=X?b:null,M=L.useMemo(()=>p?qk(t,r,p):null,[t,r,p]),D=M?t.filter(re=>M.nodeIds.has(re.id)):t,H=M?r.filter(re=>M.edgeIds.has(re.id)):r,I=L.useMemo(()=>Xk(D,H,{detail:W,families:$,focusId:U,neighborhoodOnly:!!U}),[D,H,W,$,U]),z=L.useMemo(()=>`${I.nodes.map(re=>re.id).join("\0")}|${I.edges.map(re=>re.id).join("\0")}`,[I.nodes,I.edges]),ie=b?t.find(re=>re.id===b)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const re=kN(I.nodes,I.edges,b,{roles:c,testOverlay:h});return C&&(re.rfEdges=re.rfEdges.map(Ne=>({...Ne,animated:!1}))),re},[I.nodes,I.edges,b,C,c,h]);L.useEffect(()=>{if(!s)return;const re=t.find(Ne=>Ne.file_path===s);re&&E(re.id)},[s,t]);const he=L.useMemo(()=>Gk(t,te),[t,te]),pe=(re,Ne)=>{E(Ne.id)},Z=()=>{E(null),q(!1)},se=ie?d.jsx(NN,{node:ie,nodes:t,edges:r,onClose:Z,onWhatIf:o,onSelect:E,onOpenFile:v,pinned:m===ie.id,onPin:_,onIsolate:y?re=>{y(p===re?null:re)}:void 0}):null,me=re=>{F(Ne=>{const Me=new Set(Ne);if(Me.has(re)){if(Me.size===1)return Ne;Me.delete(re)}else Me.add(re);return Me})},ke=L.useMemo(()=>{const re=new Set;for(const Ne of t)re.add(wm(Ne.type));return re},[t]),ve=t.length-I.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:V==="2d"?"active":"","aria-pressed":V==="2d",onClick:()=>w("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:V==="3d"?"active":"","aria-pressed":V==="3d",onClick:()=>w("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:W==="overview"?"active":"","aria-pressed":W==="overview",onClick:()=>A("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:W==="full"?"active":"","aria-pressed":W==="full",onClick:()=>A("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(re=>ke.has(re)).map(re=>d.jsx("button",{type:"button","data-testid":`graph-family-${re}`,className:$.has(re)?"active":"","aria-pressed":$.has(re),onClick:()=>me(re),children:re},re))}),d.jsx("button",{type:"button",className:X?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!b,onClick:()=>q(re=>!re),children:X?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>y==null?void 0:y(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:te,onChange:re=>{ee(re.target.value),K(!0)},onFocus:()=>K(!0),onBlur:()=>window.setTimeout(()=>K(!1),150)}),ne&&te.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(re=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:Ne=>Ne.preventDefault(),onClick:()=>{E(re.id),ee(""),K(!1)},children:[re.name,d.jsx("span",{className:"muted",children:io(re.type)})]})},re.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[I.nodes.length," nodes · ",I.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:V==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(gN,{nodes:I.nodes,edges:I.edges,selectedId:b,neighborIds:U?I.neighborIds:pN,onSelect:re=>{E(re),re||q(!1)}})}),se]}):d.jsxs(hm,{children:[d.jsxs(ok,{nodes:oe,edges:fe,nodeTypes:vN,edgeTypes:_N,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:Z,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(SN,{topologyKey:z}),d.jsx(ck,{}),d.jsx(Ik,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(yk,{})]}),se]})})]})}function _m(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function jN(t){localStorage.setItem("loadpath.editor",t)}async function bN(t,r,o,s=_m()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const kp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],EN=["preset","branch","tag","commit"];function CN(t){var a;if(!(t!=null&&t.git))return[...kp];const r=((a=t.presets)!=null&&a.length?t.presets:kp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function MN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function PN(t){return EN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function IN(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function Np({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[y,x]=L.useState(!1),[v,m]=L.useState(null),[_,k]=L.useState(0),j=L.useMemo(()=>{const N=CN(u);return v===null?N:MN(N,v)},[u,v]),b=L.useMemo(()=>PN(j),[j]);L.useEffect(()=>{y&&c()},[y,c]),L.useEffect(()=>{k(0)},[v,y]);const E=()=>{x(!1),m(null)},R=N=>{r(N.value),E()},w=N=>{if(N.key==="ArrowDown"){if(N.preventDefault(),!y){x(!0);return}k(A=>Math.min(A+1,Math.max(j.length-1,0)))}else if(N.key==="ArrowUp"){if(N.preventDefault(),!y)return;k(A=>Math.max(A-1,0))}else if(N.key==="Enter"&&y){N.preventDefault();const A=j[_];A&&R(A)}else N.key==="Escape"&&y&&(N.preventDefault(),E())};return d.jsxs("div",{className:"combo",ref:p,onBlur:N=>{N.currentTarget.contains(N.relatedTarget)||E()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":y,"aria-controls":h,"aria-autocomplete":"list",onChange:N=>{r(N.target.value),y&&m(N.target.value)},onKeyDown:w}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":y,onMouseDown:N=>N.preventDefault(),onClick:()=>y?E():x(!0),children:d.jsx(S0,{})})]}),y?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:b.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):b.map(N=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:IN(N.group)}),N.items.map(A=>{const $=j.indexOf(A);return d.jsxs("button",{type:"button",role:"option","aria-selected":$===_,className:$===_?"combo-option active":"combo-option","data-testid":`ref-option-${A.group}`,onMouseDown:F=>F.preventDefault(),onMouseEnter:()=>k($),onClick:()=>R(A),children:[d.jsx("span",{className:"combo-label",children:A.label}),A.detail?d.jsx("span",{className:"combo-detail",children:A.detail}):null]},`${A.group}:${A.value}`)})]},N.group))}):null]})}function RN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[y,x]=L.useState(""),[v,m]=L.useState(!1),_=L.useRef(null),k=L.useRef(0),j=async w=>{const N=k.current+1;k.current=N,m(!0);try{const A=await Pe.browse(w);if(k.current!==N)return;a(A),c(A.path),p(A.is_git?A.path:null),x("")}catch(A){if(k.current!==N)return;x(A instanceof Error?A.message:String(A))}finally{k.current===N&&m(!1)}};L.useEffect(()=>{var w,N;j(t),(w=_.current)==null||w.focus(),(N=_.current)==null||N.select()},[t]);const b=h||(s==null?void 0:s.path)||u,E=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",R=w=>{w.key==="Escape"&&(w.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:R,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:w=>w.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:w=>{w.preventDefault(),j(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:w=>c(w.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),y?d.jsx("div",{className:"error",role:"alert",children:y}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":v,children:s!=null&&s.entries.length?s.entries.map(w=>{const N=h===w.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":N,className:N?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":w.path,onClick:()=>p(w.path),onDoubleClick:()=>void j(w.path),children:[d.jsx(Cp,{}),d.jsx("span",{className:"explorer-name",children:w.name}),w.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},w.path)}):d.jsx("div",{className:"muted explorer-empty",children:v?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:b,children:b}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!b,onClick:()=>b&&r(b),children:["Use ",E]})]})]})})}const TN={scan:{start:0,end:20},extract:{start:20,end:88},boot:{start:88,end:94},stitch:{start:94,end:99},skipped:{start:100,end:100},done:{start:100,end:100}},LN=new Set(["scan","extract","boot","stitch"]);function AN(t){const r=t.phase||"";if(!r||r==="idle")return null;const o=TN[r];if(!o)return null;if(o.start===o.end)return o.end;const s=t.total||0;if(s<=0)return o.start;const a=Math.min(1,Math.max(0,(t.done||0)/s));return Math.round(o.start+(o.end-o.start)*a)}function $N(t){return!t.phase||t.phase==="idle"?null:typeof t.percent=="number"&&Number.isFinite(t.percent)?Math.max(0,Math.min(100,Math.round(t.percent))):AN(t)}const Ul=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],zN="obsidian",Sm="loadpath.theme";function DN(t){return Ul.some(r=>r.id===t)}function km(){try{const t=localStorage.getItem(Sm)||"";if(DN(t))return t}catch{}return zN}function ON(t){var r;return((r=Ul.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function Nm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=ON(t);try{localStorage.setItem(Sm,t)}catch{}}const Zu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:y0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:v0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:x0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:w0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:_0}];function Ju(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function FN(){var fo,ho,Si,po,go,mo,ki,Gr,rn,on;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,y]=L.useState(null),[x,v]=L.useState(null),[m,_]=L.useState(null),[k,j]=L.useState([]),[b,E]=L.useState("review"),[R,w]=L.useState(""),[N,A]=L.useState(""),[$,F]=L.useState(null),[X,q]=L.useState(!1),[te,ee]=L.useState(!1),[ne,K]=L.useState(""),[C,V]=L.useState({}),[W,U]=L.useState([]),[M,D]=L.useState([]),[H,I]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[z,ie]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[oe,fe]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[he,pe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[Z,se]=L.useState(0),[me,ke]=L.useState(""),[ve,re]=L.useState(km),[Ne,Me]=L.useState(!1),[Te,$e]=L.useState(!1),[st,lt]=L.useState(!1),[at,Xe]=L.useState(null),[wt,qt]=L.useState(null),[gt,mt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[Pt,ut]=L.useState(null),[Je,An]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[Ot,xn]=L.useState([]),[oo,$n]=L.useState(null),[vi,or]=L.useState(null),[$r,zn]=L.useState(null),[zr,sr]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[lr,Ft]=L.useState(null),[ct,Dn]=L.useState(null),[On,wn]=L.useState(!1),[Fn,_n]=L.useState(!1),rt=L.useRef(o);rt.current=o;const Dr=L.useRef(!1);Dr.current=Te;const _t=L.useRef(""),ar=L.useRef(""),Sn=P=>{re(P),Nm(P)},dt=L.useRef(""),He=P=>{dt.current=P,A(P)},kn=P=>{let Y=0,ce=!1;F(0);const je=()=>{Pe.indexProgress(P).then(Ie=>{if(!dt.current)return;if(Ie.phase&&Ie.phase!=="idle"&&Ie.message&&He(Ie.message),LN.has(Ie.phase))ce=!0;else if(!ce)return;const qr=$N(Ie);qr!=null&&(Ie.phase==="scan"&&!Ie.done?Y=qr:Y=Math.max(Y,qr),F(Y))}).catch(()=>{})};je();const Le=window.setInterval(je,250);return()=>{window.clearInterval(Le),F(null)}};L.useEffect(()=>{Pe.settings().then(V).catch(()=>{}).finally(()=>Me(!0)),Pe.repos().then(P=>j(P.repos)).catch(()=>{})},[]);const Nn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const P=o;let Y=!1;return ar.current!==P&&Bn(P),Pe.config(P).then(ce=>{!Y&&rt.current===P&&or(ce)}).catch(()=>{}),Pe.architectureHealth(P).then(ce=>{!Y&&rt.current===P&&zn(ce)}).catch(()=>{}),()=>{Y=!0}},[t,o]);const Ht=P=>{rt.current=P,s(P),localStorage.setItem("loadpath.repo",P),P.trim()!==_t.current&&(_t.current="",Ft(null))},Or=L.useCallback(P=>{const Y=(P??rt.current).trim();return!Y||_t.current===Y?Promise.resolve():(_t.current=Y,Pe.gitRefs(Y).then(ce=>{rt.current.trim()===Y&&Ft(ce)}).catch(()=>{_t.current===Y&&(_t.current="",Ft(null))}))},[]),nn=(P,Y)=>{u(P),h(Y),localStorage.setItem("loadpath.base",P),localStorage.setItem("loadpath.head",Y)},Fr=(P,Y,ce)=>{ie(P),I(Y),localStorage.setItem("loadpath.provider",P),localStorage.setItem("loadpath.scmRepo",Y),ce!==void 0&&(fe(ce),localStorage.setItem("loadpath.prNumber",ce))},yt=P=>{y(P),se(0),Xe(wt&&P.nodes.some(Y=>Y.id===wt)?wt:null),ut(null),$n(null),P.what_if||(v(P),P.id&&localStorage.setItem("loadpath.lastReviewId",P.id))},Hn=async P=>{try{const Y=await Pe.reviews(P);xn(Y.reviews)}catch{xn([])}},ur=async P=>{try{zn(await Pe.architectureHealth(P))}catch{zn(null)}},so=P=>P==="github"?!!C.github_token_set:P==="gitlab"?!!C.gitlab_token_set:!!C.bitbucket_token_set,It=L.useCallback(async(P=z)=>{var Y;try{const ce=await Pe.scmRepos(P);D(ce.repos),(Y=ce.user)!=null&&Y.login&&V(je=>({...je,...P==="github"?{github_user:ce.user.login}:P==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{D([])}},[z]);L.useEffect(()=>{if(t!=="prs")return;let P=!1;return It(z).catch(()=>{P||D([])}),()=>{P=!0}},[t,z,It]),L.useEffect(()=>{if(!ct)return;let P=!1,Y=0;const ce=async()=>{try{const je=await Pe.githubOAuthPoll(ct.flow_id);if(P)return;if(je.status==="complete"){Dn(null);const Le=await Pe.settings();V(Le),K(je.user?`Signed in to GitHub as ${je.user}`:"Signed in to GitHub"),It("github");return}if(je.status==="pending"||je.status==="slow_down"){Y=window.setTimeout(ce,Math.max(je.interval||ct.interval,5)*1e3);return}Dn(null),w(je.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(je){if(P)return;Dn(null),w(je instanceof Error?je.message:String(je))}};return Y=window.setTimeout(ce,Math.max(ct.interval,5)*1e3),()=>{P=!0,window.clearTimeout(Y)}},[ct,It]),L.useEffect(()=>{if(!On)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.bitbucket.connected){wn(!1);const Ie=await Pe.settings();V(Ie),K(Le.bitbucket.user?`Signed in to Bitbucket as ${Le.bitbucket.user}`:"Signed in to Bitbucket"),It("bitbucket");return}if(Date.now()-ce>18e4){wn(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;wn(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[On,It]),L.useEffect(()=>{if(!Fn)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.gitlab.connected){_n(!1);const Ie=await Pe.settings();V(Ie),K(Le.gitlab.user?`Signed in to GitLab as ${Le.gitlab.user}`:"Signed in to GitLab"),It("gitlab");return}if(Date.now()-ce>18e4){_n(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;_n(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[Fn,It]);const Bn=async(P=o,Y=!1)=>{if(!P.trim())return null;ar.current=P,ee(!0);try{const ce=await Pe.architecture(P,!1);rt.current===P&&_(ce);const je=Pe.architectureGraph(P).then(Le=>{rt.current===P&&_(Ie=>Ie&&{...Ie,nodes:Le.nodes,edges:Le.edges,graph_pending:!1})});return je.catch(()=>{}).finally(()=>{rt.current===P&&ee(!1)}),Y&&await je,ce}catch(ce){throw rt.current===P&&ee(!1),ce}},Hr=async P=>{const Y=P.trim();if(!(!Y||Y===rt.current)){if(dt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),K(""),y(null),v(null),_(null),E("architecture"),Ht(Y),q(!0),He(`Loading ${m0(Y)}…`);try{await Promise.all([Bn(Y),Or(Y)])}catch(ce){rt.current===Y&&w(ce instanceof Error?ce.message:String(ce))}finally{rt.current===Y&&(He(""),q(!1))}}},jn=async()=>{if(dt.current||!Nn())return;w(""),K(""),He("Tracing load path…"),Ht(o),nn(a,c);const P=kn(o);try{const Y=await Pe.review(o,a,c,!0,he);yt(Y),E("review"),r("review"),await Pe.repos().then(ce=>j(ce.repos)).catch(()=>{}),await Promise.all([Bn(o),Hn(o),ur(o)])}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{P(),He("")}},Br=async(P=!0)=>{if(dt.current||!Nn())return;w(""),K(""),He(P?"Indexing…":"Full reindex…"),Ht(o);const Y=kn(o);try{await Pe.index(o,P);const ce=await Bn(o);await Pe.repos().then(je=>j(je.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(E("architecture"),r("architecture"))}catch(ce){w(ce instanceof Error?ce.message:String(ce))}finally{Y(),He("")}},xi=async()=>{if(!dt.current&&Nn()){w(""),K(""),He("Detecting layout…"),Ht(o);try{const P=await Pe.init(o);K(P.message),await Pe.repos().then(Y=>j(Y.repos)).catch(()=>{})}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ve=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),K("Copied markdown brief")}catch(P){w(P instanceof Error?P.message:String(P))}},lo=async()=>{if(!dt.current){if(p!=null&&p.what_if){w("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first.");return}if(!(p!=null&&p.markdown)||!H||!oe){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const P=await Pe.postComment(z,H,Number(oe),p.markdown);K(P.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Vr=async()=>{if(!dt.current){w(""),He("Fetching pull requests…");try{const P=await Pe.prs(z,H,"open",o.trim()||void 0);U(P.pull_requests);const Y=M.find(ce=>ce.slug.toLowerCase()===H.trim().toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},wi=async()=>{w("");try{const P=await Pe.githubOAuthStart();Dn(P),Ju(P.verification_uri_complete,"github.com","/login/device")}catch(P){w(P instanceof Error?P.message:String(P))}},cr=async()=>{w("");try{const P=await Pe.bitbucketOAuthStart();wn(!0),Ju(P.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(P){wn(!1),w(P instanceof Error?P.message:String(P))}},ao=async()=>{w("");try{const P=await Pe.gitlabOAuthStart();_n(!0),Ju(P.authorize_url,new URL(P.authorize_url).hostname,"/oauth/authorize")}catch(P){_n(!1),w(P instanceof Error?P.message:String(P))}},dr=async P=>{if(!(dt.current||!o.trim())){w(""),He("Walking what-if path…");try{const Y=await Pe.whatIf(o,P);K(`${Y.title} — ${Y.confidence.level} · ${(Y.sinks||[]).length} sinks`),yt({...Y,markdown:Y.markdown||"",index:Y.index||(p==null?void 0:p.index),workspace:Y.workspace||(p==null?void 0:p.workspace)}),E("review"),r("review")}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},Vn=()=>{if(x){yt(x),E("review"),r("review"),K("Restored the last git-range walk");return}y(null),se(0),Xe(null),ut(null),$n(null),E("architecture"),r("architecture"),K("")},bt=async P=>{var Le;if(dt.current)return;Fr(P.provider,P.repo,String(P.number));const Y=M.find(Ie=>Ie.slug.toLowerCase()===P.repo.toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path),w(""),He(`Fetching ${P.provider} #${P.number}…`);const ce=(Y==null?void 0:Y.local_path)||o,je=ce?kn(ce):()=>{};try{const Ie=await Pe.reviewPr(P.provider,P.repo,P.number,(Y==null?void 0:Y.local_path)||o||void 0);yt(Ie),Ie.pull_request&&typeof Ie.pull_request.repo_path=="string"&&Ht(Ie.pull_request.repo_path),nn(String(Ie.base||P.target_branch),String(Ie.head||P.source_branch)),E("review"),r("review"),typeof((Le=Ie.pull_request)==null?void 0:Le.repo_path)=="string"&&Hn(Ie.pull_request.repo_path)}catch(Ie){nn(P.base_sha||P.target_branch,P.head_sha||P.source_branch),r("review"),w(Ie instanceof Error?Ie.message:String(Ie))}finally{je(),He("")}},Wr=async P=>{w("");try{V(await Pe.oauthDisconnect(P)),z===P&&D([]),K(`Disconnected ${P}`)}catch(Y){w(Y instanceof Error?Y.message:String(Y))}},Et=async P=>{P.preventDefault();const Y=new FormData(P.currentTarget),ce={github_token:String(Y.get("github_token")||""),github_oauth_client_id:String(Y.get("github_oauth_client_id")||""),github_host:String(Y.get("github_host")||""),gitlab_token:String(Y.get("gitlab_token")||""),gitlab_host:String(Y.get("gitlab_host")||""),gitlab_oauth_client_id:String(Y.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(Y.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(Y.get("bitbucket_token")||""),bitbucket_username:String(Y.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(Y.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(Y.get("bitbucket_oauth_client_secret")||""),ai_provider:String(Y.get("ai_provider")||"none"),ai_api_key:String(Y.get("ai_api_key")||""),ai_model:String(Y.get("ai_model")||""),ai_base_url:String(Y.get("ai_base_url")||"")},je=k.length?{...ce,workspaces:k.map(Le=>({path:Le.path,name:Le.name}))}:ce;try{V(await Pe.saveSettings(je)),K("Settings saved on this machine")}catch(Le){w(Le instanceof Error?Le.message:String(Le))}},uo=async()=>{if(!(!p||dt.current)){He("Residual analysis…");try{const P=await Pe.residual(p);ke(P.note)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ur=L.useRef(jn);Ur.current=jn;const Yr=L.useRef(t);Yr.current=t;const Wn=L.useRef(!1);Wn.current=st;const Un=L.useRef(p);Un.current=p;const bn=L.useRef(Z);bn.current=Z,L.useEffect(()=>{const P=localStorage.getItem("loadpath.lastReviewId"),Y=(localStorage.getItem("loadpath.repo")||"").trim();if(!P||!Y){sr(!1);return}let ce=!1;return Pe.getReview(Y,P).then(je=>{ce||(yt(je),nn(je.base||localStorage.getItem("loadpath.base")||"HEAD~1",je.head||localStorage.getItem("loadpath.head")||"HEAD"),Hn(Y),ur(Y))}).catch(()=>{}).finally(()=>{ce||sr(!1)}),()=>{ce=!0}},[]);const Bt=L.useRef("");L.useEffect(()=>{if(!Je||!o.trim())return;let P=!1;const Y=async()=>{try{const je=await Pe.workspaceStatus(o);if(P)return;Bt.current&&je.fingerprint!==Bt.current&&!dt.current&&(pe(!0),localStorage.setItem("loadpath.dirty","1"),Ur.current()),Bt.current=je.fingerprint}catch{}};Y();const ce=window.setInterval(Y,2e3);return()=>{P=!0,window.clearInterval(ce)}},[Je,o]),L.useEffect(()=>{const P=Y=>{var Le;if((Y.metaKey||Y.ctrlKey)&&Y.key.toLowerCase()==="k"){Y.preventDefault(),lt(Ie=>!Ie);return}if(Wn.current){Y.key==="Escape"&&(Y.preventDefault(),lt(!1));return}if(Dr.current){Y.key==="Escape"&&(Y.preventDefault(),$e(!1));return}const ce=Y.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){Y.key==="Escape"&&ce.blur();return}if(Y.key==="Escape"){w(""),K(""),Xe(wt),ut(null);return}if(Y.key==="j"||Y.key==="k"){const Ie=((Le=Un.current)==null?void 0:Le.read_order)||[];if(!Ie.length)return;Y.preventDefault();const Xn=bn.current,qr=Y.key==="j"?Math.min(Ie.length-1,Xn+1):Math.max(0,Xn-1);se(qr);return}const je=Zu.find(Ie=>Ie.shortcut===Y.key);if(je&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey&&r(je.id),(Y.metaKey||Y.ctrlKey)&&Y.key==="Enter"){if(Yr.current==="settings"||Yr.current==="prs"||dt.current)return;Y.preventDefault(),Ur.current()}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[wt]);const _i=async(P,Y)=>{if(!o.trim())return;const ce=await bN(o,P,Y);ce.ok?K(ce.message):w(ce.message)},Xr=async()=>{if(p)try{const P=await Pe.exportHtml(p),Y=URL.createObjectURL(P),ce=document.createElement("a");ce.href=Y,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(Y),K("Saved HTML brief")}catch(P){w(P instanceof Error?P.message:String(P))}},fr=async P=>{if(o.trim()){He("Loading stored review…");try{const Y=await Pe.getReview(o,P);yt(Y),nn(Y.base||a,Y.head||c),E("review"),r("review");const ce=Ot.find(je=>je.id!==P);if(ce)try{$n(await Pe.reviewDiff(o,P,ce.id))}catch{$n(null)}}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},hr={selectedId:at,onSelect:Xe,nodeRoles:p==null?void 0:p.node_roles,testOverlay:gt,isolateSource:Pt,onIsolate:ut,repoPath:o,onOpenFile:_i,pinnedId:wt,onPin:qt},Yn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},...p!=null&&p.what_if?[{id:"exit-whatif",group:"Review",label:x?"Back to git-range walk":"Exit what-if walk",run:Vn}]:[],{id:"index",group:"Run",label:"Index repository",run:()=>void Br(!0)},{id:"watch",group:"Run",label:Je?"Stop watching working tree":"Watch working tree",run:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")}},{id:"tests",group:"Graph",label:gt?"Hide test overlay":"Show test overlay",run:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Xr()},...Zu.map(P=>({id:`tab-${P.id}`,group:"Tabs",label:`Go to ${P.label}`,hint:P.shortcut,run:()=>r(P.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(P=>({id:`node-${P.id}`,group:"Nodes",label:P.name,hint:io(P.type),run:()=>{Xe(P.id),r("graph")}})),...Ot.slice(0,12).map(P=>({id:`hist-${P.id}`,group:"History",label:P.title||P.id,hint:`${P.level||""} ${P.created_at||""}`.trim(),run:()=>void fr(P.id)}))],En=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[b,m,p]),co=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[b,m,p]),pr=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Fe=((p==null?void 0:p.findings)||[]).filter(P=>!P.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Zu.map(P=>{const Y=P.icon,ce=t===P.id;return d.jsxs("button",{type:"button","data-testid":P.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":P.label,onClick:()=>r(P.id),children:[d.jsx(Y,{}),d.jsx("span",{children:P.label})]},P.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:ve,onChange:P=>Sn(P.target.value),children:["dark","light"].map(P=>d.jsx("optgroup",{label:P==="dark"?"Dark":"Light",children:Ul.filter(Y=>Y.group===P).map(Y=>d.jsx("option",{value:Y.id,children:Y.label},Y.id))},P))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:N||pr}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[N?d.jsxs("div",{className:$!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","aria-valuemin":$!=null?0:void 0,"aria-valuemax":$!=null?100:void 0,"aria-valuenow":$??void 0,"data-testid":"progress",children:[d.jsx("i",{style:$!=null?{width:`${$}%`}:void 0}),d.jsx("span",{className:"sr-only",children:N})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[k.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:k.some(P=>P.path===o)?o:"",disabled:!!N,"aria-busy":X,onChange:P=>{P.target.value&&Hr(P.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),k.map(P=>d.jsxs("option",{value:P.path,children:[P.name,P.indexed?` (${P.counts.nodes})`:""]},P.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:P=>{const Y=P.target.value;s(Y),Y.trim()!==_t.current&&(_t.current="",Ft(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>$e(!0),children:d.jsx(Cp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(Np,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:P=>nn(P,c),placeholder:"base",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(Np,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:P=>nn(a,P),placeholder:"head",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:he?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":he,onClick:()=>{const P=!he;pe(P),localStorage.setItem("loadpath.dirty",P?"1":"0")},children:he?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:Je?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":Je,onClick:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")},children:Je?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.what_if?"what-if · ":"",p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!N,onClick:xi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!N,onClick:()=>Br(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!N,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[R?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:R}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,ne?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:ne}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>K(""),"aria-label":"Dismiss",children:"×"})]}):null,((fo=p==null?void 0:p.index)!=null&&fo.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((ho=p==null?void 0:p.index)==null?void 0:ho.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Si=p==null?void 0:p.index)==null?void 0:Si.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(po=p==null?void 0:p.workspace)!=null&&po.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,p!=null&&p.what_if?d.jsxs("div",{className:"banner whatif","data-testid":"whatif-banner",children:[d.jsxs("span",{children:["Hypothetical walk from"," ",d.jsx("strong",{children:((go=p.node)==null?void 0:go.name)||"this node"}),". Loadpath ignored Base/Head and asked which sinks would feel this node change — not a filter of the current map."]}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-exit-whatif",onClick:Vn,children:x?"Back to git range":"Back to architecture"})]}):null,X?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:N||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":X||te,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(HN,{review:p,findings:Fe,aiNote:me,busy:!!N,tourIndex:Z,onTour:se,onAskAi:uo,onCopy:Ve,onPost:lo,onSelect:Xe,onOpenFile:_i,onExport:Xr,history:Ot,diff:oo,onReopen:fr,onWaiver:(P,Y)=>{o.trim()&&Pe.addWaiver(o,P,Y||void 0,"from review").then(ce=>{or(ce),K(`Waived ${P} in loadpath.yml`)})}}):zr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Qu,{nodes:p.nodes,edges:p.edges,onWhatIf:dr,focusPath:(mo=p.read_order[Z])==null?void 0:mo.path,...hr}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(BN,{architecture:m,busy:!!N,onReindex:()=>Br(!1),onReview:jn,onSelect:Xe,config:vi,health:$r,onSaveConfig:P=>{Pe.saveConfig(o,P).then(Y=>{or(Y),K("Wrote loadpath.yml")})},onWaiver:(P,Y,ce)=>{Pe.addWaiver(o,P,Y,ce).then(je=>{or(je),K(`Waived ${P}`)})}}):X?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(te||m!=null&&m.graph_pending)&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(ki=m==null?void 0:m.counts)!=null&&ki.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Qu,{nodes:m.nodes,edges:m.edges,onWhatIf:dr,...hr,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":b==="review","data-testid":"graph-mode-review",className:b==="review"?"active":"",onClick:()=>E("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":b==="architecture","data-testid":"graph-mode-architecture",className:b==="architecture"?"active":"",onClick:()=>E("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:gt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":gt,onClick:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")},children:"Tests"})]}),En.length?d.jsx(Qu,{nodes:En,edges:co,onWhatIf:dr,...hr}):te||m!=null&&m.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:z,onChange:P=>Fr(P.target.value,H,oe),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:M.length?"Search your repos":"owner/repo",value:H,onChange:P=>Fr(z,P.target.value,oe),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:M.map(P=>d.jsxs("option",{value:P.slug,children:[P.private?"private":"public",P.local_path?" · local":""]},P.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!N||!so(z),onClick:()=>{It(z)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!N,onClick:Vr,children:"List PRs"})]}),M.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[M.length," ",z," repositor",M.length===1?"y":"ies",z==="github"&&C.github_user?` · @${String(C.github_user)}`:"",z==="gitlab"&&C.gitlab_user?` · @${String(C.gitlab_user)}`:"",z==="bitbucket"&&C.bitbucket_user?` · ${String(C.bitbucket_user)}`:""]}):null,W.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):W.map(P=>{var Y;return d.jsxs("article",{className:"pr","data-testid":`pr-${P.number}`,children:[d.jsxs("h3",{children:["#",P.number," ",P.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${P.draft?"":"open"}`,children:P.draft?"draft":P.state}),d.jsx("span",{children:P.author}),d.jsxs("span",{children:[P.source_branch," → ",P.target_branch]}),P.loadpath?d.jsxs("span",{className:`chip ${P.loadpath.level||""}`,"data-testid":`pr-loadpath-${P.number}`,children:[((Y=P.loadpath.level)==null?void 0:Y.toUpperCase())||"REVIEWED",P.loadpath.contract_break&&P.loadpath.contract_break!=="none"?` · ${P.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:P.url,target:"_blank",rel:"noreferrer",children:["Open on ",P.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${P.number}`,onClick:()=>void bt(P),children:"Review this PR"})]})]},`${P.provider}-${P.number}`)})]}),t==="settings"&&Ne&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Et,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Ul.map(P=>d.jsxs("button",{type:"button","data-theme":P.id,className:ve===P.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${P.id}`,onClick:()=>Sn(P.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:P.label}),d.jsx("div",{className:"group",children:P.group})]},P.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:_m(),onChange:P=>jN(P.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:C.github_token_set?C.github_user?`Signed in as @${String(C.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void Wr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!ct||!C.github_oauth_ready,onClick:()=>void wi(),children:ct?"Waiting for GitHub…":"Sign in with GitHub"})})]}),ct?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:ct.user_code})," at GitHub if the browser did not fill it in."]}):null,C.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(C.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(C.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:C.gitlab_token_set?C.gitlab_user?`Signed in as @${String(C.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void Wr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Fn||!C.gitlab_oauth_ready,onClick:()=>void ao(),children:Fn?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(C.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(C.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:C.bitbucket_token_set?C.bitbucket_user?`Signed in as ${String(C.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void Wr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:On||!C.bitbucket_oauth_ready,onClick:()=>void cr(),children:On?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),C.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(C.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(C.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((Gr=C.ai)==null?void 0:Gr.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((rn=C.ai)==null?void 0:rn.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((on=C.ai)==null?void 0:on.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(h0,{open:st,actions:Yn,onClose:()=>lt(!1)}),Te?d.jsx(RN,{initialPath:o,onClose:()=>$e(!1),onSelect:P=>{if(dt.current){w("Wait for the current job to finish before switching workspace.");return}$e(!1),Hr(P)}}):null]})}function HN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:y,onOpenFile:x,onExport:v,history:m,diff:_,onReopen:k,onWaiver:j}){var E,R,w,N,A,$,F,X,q,te,ee,ne,K,C,V,W,U;const b=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),b.length?d.jsx("ul",{className:"reasons",children:b.map(M=>d.jsx("li",{children:M},M))}):null,t.what_if?d.jsx("span",{className:"chip whatif","data-testid":"whatif-chip",children:"what-if"}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Zo(M)},M)),(E=t.contract_break)!=null&&E.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&y(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>j(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(R=t.workspace)!=null&&R.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>x(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&y(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(jm,{cards:t.deepening}),(N=(w=t.contract_break)==null?void 0:w.reasons)!=null&&N.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),($=(A=t.contract_break.sides)==null?void 0:A.rows)!=null&&$.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(F=t.auth)!=null&&F.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(X=t.suggested_tests)==null?void 0:X.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(q=t.trend)!=null&&q.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",ec(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),m.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:m.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,m.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>k(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?ec(M.created_at):""})]},M.id))]}):null,(ee=(te=t.evolution)==null?void 0:te.notes)!=null&&ee.length||(K=(ne=t.evolution)==null?void 0:ne.hotspots)!=null&&K.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((C=t.evolution)==null?void 0:C.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((V=t.evolution)==null?void 0:V.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:v,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",disabled:s||!!t.what_if,title:t.what_if?"Hypothetical walks are not posted to a pull request":void 0,onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(W=t.codeowners_reviewers)!=null&&W.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function BN({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var x;const y=t.findings.filter(v=>!v.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${ec(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(v=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:v.name})," — ",(v.django_apps||[]).join(", ")||"no apps"," ·"," ",(v.owners||[]).join(", ")||"unowned"]},v.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(v=>d.jsx("div",{className:"muted",children:v},v))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:y.length})]}),y.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):y.map(v=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>v.node_id&&a(v.node_id),children:[d.jsx("span",{className:`chip ${v.severity}`,children:v.severity}),v.message]})},v.rule+v.message))]}),d.jsx(jm,{cards:t.deepening}),(x=c==null?void 0:c.points)!=null&&x.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(v=>d.jsx("i",{className:v.level||"",title:`${v.level} · ${v.findings} findings`,style:{height:`${8+Math.min(24,(v.findings||0)*4)}px`}},v.id||v.created_at))}),Object.entries(c.contexts).map(([v,m])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:v})," — last ",((_=m[m.length-1])==null?void 0:_.findings)??0," findings"]},v)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(p0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((v,m)=>m[1]-v[1]).slice(0,12).map(([v,m])=>d.jsxs("tr",{children:[d.jsx("td",{children:io(v)}),d.jsx("td",{children:m})]},v))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function jm({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:g0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}Nm(km());c0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(FN,{})}));export{Vk as L,UN as a,VN as c,d as j,WN as l,L as r,io as t}; diff --git a/src/loadpath/static/assets/index-vCx0pAT3.js b/src/loadpath/static/assets/index-vCx0pAT3.js deleted file mode 100644 index c69088b..0000000 --- a/src/loadpath/static/assets/index-vCx0pAT3.js +++ /dev/null @@ -1,62 +0,0 @@ -(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function Np(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Tu={exports:{}},Uo={},Lu={exports:{}},Re={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var qf;function t0(){if(qf)return Re;qf=1;var t=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),v=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),y=Symbol.iterator;function m(I){return I===null||typeof I!="object"?null:(I=y&&I[y]||I["@@iterator"],typeof I=="function"?I:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,j={};function b(I,z,ie){this.props=I,this.context=z,this.refs=j,this.updater=ie||_}b.prototype.isReactComponent={},b.prototype.setState=function(I,z){if(typeof I!="object"&&typeof I!="function"&&I!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,I,z,"setState")},b.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function E(){}E.prototype=b.prototype;function R(I,z,ie){this.props=I,this.context=z,this.refs=j,this.updater=ie||_}var w=R.prototype=new E;w.constructor=R,k(w,b.prototype),w.isPureReactComponent=!0;var N=Array.isArray,A=Object.prototype.hasOwnProperty,$={current:null},F={key:!0,ref:!0,__self:!0,__source:!0};function G(I,z,ie){var oe,fe={},he=null,pe=null;if(z!=null)for(oe in z.ref!==void 0&&(pe=z.ref),z.key!==void 0&&(he=""+z.key),z)A.call(z,oe)&&!F.hasOwnProperty(oe)&&(fe[oe]=z[oe]);var Z=arguments.length-2;if(Z===1)fe.children=ie;else if(1>>1,z=M[I];if(0>>1;Ia(fe,H))hea(pe,fe)?(M[I]=pe,M[he]=H,I=he):(M[I]=fe,M[oe]=H,I=oe);else if(hea(pe,H))M[I]=pe,M[he]=H,I=he;else break e}}return D}function a(M,D){var H=M.sortIndex-D.sortIndex;return H!==0?H:M.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,h=c.now();t.unstable_now=function(){return c.now()-h}}var p=[],v=[],x=1,y=null,m=3,_=!1,k=!1,j=!1,b=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(M){for(var D=o(v);D!==null;){if(D.callback===null)s(v);else if(D.startTime<=M)s(v),D.sortIndex=D.expirationTime,r(p,D);else break;D=o(v)}}function N(M){if(j=!1,w(M),!k)if(o(p)!==null)k=!0,W(A);else{var D=o(v);D!==null&&U(N,D.startTime-M)}}function A(M,D){k=!1,j&&(j=!1,E(G),G=-1),_=!0;var H=m;try{for(w(D),y=o(p);y!==null&&(!(y.expirationTime>D)||M&&!ee());){var I=y.callback;if(typeof I=="function"){y.callback=null,m=y.priorityLevel;var z=I(y.expirationTime<=D);D=t.unstable_now(),typeof z=="function"?y.callback=z:y===o(p)&&s(p),w(D)}else s(p);y=o(p)}if(y!==null)var ie=!0;else{var oe=o(v);oe!==null&&U(N,oe.startTime-D),ie=!1}return ie}finally{y=null,m=H,_=!1}}var $=!1,F=null,G=-1,q=5,te=-1;function ee(){return!(t.unstable_now()-teM||125I?(M.sortIndex=H,r(v,M),o(p)===null&&M===o(v)&&(j?(E(G),G=-1):j=!0,U(N,H-I))):(M.sortIndex=z,r(p,M),k||_||(k=!0,W(A))),M},t.unstable_shouldYield=ee,t.unstable_wrapCallback=function(M){var D=m;return function(){var H=m;m=D;try{return M.apply(this,arguments)}finally{m=H}}}})(zu)),zu}var eh;function s0(){return eh||(eh=1,$u.exports=o0()),$u.exports}/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var th;function l0(){if(th)return zt;th=1;var t=us(),r=s0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,v=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,x={},y={};function m(e){return p.call(y,e)?!0:p.call(x,e)?!1:v.test(e)?y[e]=!0:(x[e]=!0,!1)}function _(e,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function k(e,n,i,l){if(n===null||typeof n>"u"||_(e,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function j(e,n,i,l,f,g,S){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=f,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=g,this.removeEmptyString=S}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){b[e]=new j(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];b[n]=new j(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){b[e]=new j(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){b[e]=new j(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){b[e]=new j(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){b[e]=new j(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){b[e]=new j(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){b[e]=new j(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){b[e]=new j(e,5,!1,e.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function R(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){b[e]=new j(e,1,!1,e.toLowerCase(),null,!1,!1)}),b.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){b[e]=new j(e,1,!1,e.toLowerCase(),null,!0,!0)});function w(e,n,i,l){var f=b.hasOwnProperty(n)?b[n]:null;(f!==null?f.type!==0:l||!(2T||f[S]!==g[T]){var O=` -`+f[S].replace(" at new "," at ");return e.displayName&&O.includes("")&&(O=O.replace("",e.displayName)),O}while(1<=S&&0<=T);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?z(e):""}function fe(e){switch(e.tag){case 5:return z(e.type);case 16:return z("Lazy");case 13:return z("Suspense");case 19:return z("SuspenseList");case 0:case 2:case 15:return e=oe(e.type,!1),e;case 11:return e=oe(e.type.render,!1),e;case 1:return e=oe(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case F:return"Fragment";case $:return"Portal";case q:return"Profiler";case G:return"StrictMode";case K:return"Suspense";case C:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ee:return(e.displayName||"Context")+".Consumer";case te:return(e._context.displayName||"Context")+".Provider";case ne:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case W:n=e._payload,e=e._init;try{return he(e(n))}catch{}}return null}function pe(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===G?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Z(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=se(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function ke(e){e._valueTracker||(e._valueTracker=me(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=se(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function re(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return H({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Z(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Te(e,n){n=n.checked,n!=null&&w(e,"checked",n,!1)}function $e(e,n){Te(e,n);var i=Z(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?lt(e,n.type,i):n.hasOwnProperty("defaultValue")&<(e,n.type,Z(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function st(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function lt(e,n,i){(n!=="number"||re(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var at=Array.isArray;function Ge(e,n,i,l){if(e=e.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=Je.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ot(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var xn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},oo=["Webkit","ms","Moz","O"];Object.keys(xn).forEach(function(e){oo.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),xn[n]=xn[e]})});function $n(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||xn.hasOwnProperty(e)&&xn[e]?(""+n).trim():n+"px"}function vi(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=$n(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,f):e[i]=f}}var or=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function $r(e,n){if(n){if(or[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function zn(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var zr=null;function sr(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var lr=null,Ft=null,ct=null;function Dn(e){if(e=Po(e)){if(typeof lr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=Is(n),lr(e.stateNode,e.type,n))}}function On(e){Ft?ct?ct.push(e):ct=[e]:Ft=e}function wn(){if(Ft){var e=Ft,n=ct;if(ct=Ft=null,Dn(e),n)for(e=0;e>>=0,e===0?32:31-(uo(e)/Ur|0)|0}var Wn=64,Un=4194304;function bn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Bt(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,f=e.suspendedLanes,g=e.pingedLanes,S=i&268435455;if(S!==0){var T=S&~f;T!==0?l=bn(T):(g&=S,g!==0&&(l=bn(g)))}else S=i&~f,S!==0?l=bn(S):g!==0&&(l=bn(g));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,g=n&-n,f>=g||f===16&&(g&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function En(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Et(n),e[n]=i}function co(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=_o),Hc=" ",Bc=!1;function Vc(e,n){switch(e){case"keyup":return Km.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var bi=!1;function Zm(e,n){switch(e){case"compositionend":return Wc(n);case"keypress":return n.which!==32?null:(Bc=!0,Hc);case"textInput":return e=n.data,e===Hc&&Bc?null:e;default:return null}}function Jm(e,n){if(bi)return e==="compositionend"||!ha&&Vc(e,n)?(e=Ac(),ws=la=gr=null,bi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Qc(i)}}function Jc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Jc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function ed(){for(var e=window,n=re();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=re(e.document)}return n}function ma(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function ay(e){var n=ed(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&Jc(i.ownerDocument.documentElement,i)){if(l!==null&&ma(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var f=i.textContent.length,g=Math.min(l.start,f);l=l.end===void 0?g:Math.min(l.end,f),!e.extend&&g>l&&(f=l,l=g,g=f),f=Zc(i,g);var S=Zc(i,l);f&&S&&(e.rangeCount!==1||e.anchorNode!==f.node||e.anchorOffset!==f.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),e.removeAllRanges(),g>l?(e.addRange(n),e.extend(S.node,S.offset)):(n.setEnd(S.node,S.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,Ei=null,ya=null,jo=null,va=!1;function td(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;va||Ei==null||Ei!==re(l)||(l=Ei,"selectionStart"in l&&ma(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),jo&&No(jo,l)||(jo=l,l=Cs(ya,"onSelect"),0Ri||(e.current=Pa[Ri],Pa[Ri]=null,Ri--)}function Be(e,n){Ri++,Pa[Ri]=e.current,e.current=n}var xr={},St=vr(xr),Rt=vr(!1),Qr=xr;function Ti(e,n){var i=e.type.contextTypes;if(!i)return xr;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in i)f[g]=n[g];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=f),f}function Tt(e){return e=e.childContextTypes,e!=null}function Rs(){Ue(Rt),Ue(St)}function md(e,n,i){if(St.current!==xr)throw Error(o(168));Be(St,n),Be(Rt,i)}function yd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,pe(e)||"Unknown",f));return H({},i,l)}function Ts(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||xr,Qr=St.current,Be(St,e),Be(Rt,Rt.current),!0}function vd(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=yd(e,n,Qr),l.__reactInternalMemoizedMergedChildContext=e,Ue(Rt),Ue(St),Be(St,e)):Ue(Rt),Be(Rt,i)}var qn=null,Ls=!1,Ia=!1;function xd(e){qn===null?qn=[e]:qn.push(e)}function wy(e){Ls=!0,xd(e)}function wr(){if(!Ia&&qn!==null){Ia=!0;var e=0,n=Fe;try{var i=qn;for(Fe=1;e>=S,f-=S,Kn=1<<32-Et(n)+f|i<Ce?(pt=Ee,Ee=null):pt=Ee.sibling;var Oe=le(X,Ee,Q[Ce],de);if(Oe===null){Ee===null&&(Ee=pt);break}e&&Ee&&Oe.alternate===null&&n(X,Ee),B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe,Ee=pt}if(Ce===Q.length)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;CeCe?(pt=Ee,Ee=null):pt=Ee.sibling;var Mr=le(X,Ee,Oe.value,de);if(Mr===null){Ee===null&&(Ee=pt);break}e&&Ee&&Mr.alternate===null&&n(X,Ee),B=g(Mr,B,Ce),be===null?_e=Mr:be.sibling=Mr,be=Mr,Ee=pt}if(Oe.done)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;!Oe.done;Ce++,Oe=Q.next())Oe=ue(X,Oe.value,de),Oe!==null&&(B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return Xe&&Jr(X,Ce),_e}for(Ee=l(X,Ee);!Oe.done;Ce++,Oe=Q.next())Oe=ge(Ee,X,Ce,Oe.value,de),Oe!==null&&(e&&Oe.alternate!==null&&Ee.delete(Oe.key===null?Ce:Oe.key),B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return e&&Ee.forEach(function(e0){return n(X,e0)}),Xe&&Jr(X,Ce),_e}function et(X,B,Q,de){if(typeof Q=="object"&&Q!==null&&Q.type===F&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case A:e:{for(var _e=Q.key,be=B;be!==null;){if(be.key===_e){if(_e=Q.type,_e===F){if(be.tag===7){i(X,be.sibling),B=f(be,Q.props.children),B.return=X,X=B;break e}}else if(be.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===W&&jd(_e)===be.type){i(X,be.sibling),B=f(be,Q.props),B.ref=Io(X,be,Q),B.return=X,X=B;break e}i(X,be);break}else n(X,be);be=be.sibling}Q.type===F?(B=li(Q.props.children,X.mode,de,Q.key),B.return=X,X=B):(de=al(Q.type,Q.key,Q.props,null,X.mode,de),de.ref=Io(X,B,Q),de.return=X,X=de)}return S(X);case $:e:{for(be=Q.key;B!==null;){if(B.key===be)if(B.tag===4&&B.stateNode.containerInfo===Q.containerInfo&&B.stateNode.implementation===Q.implementation){i(X,B.sibling),B=f(B,Q.children||[]),B.return=X,X=B;break e}else{i(X,B);break}else n(X,B);B=B.sibling}B=Cu(Q,X.mode,de),B.return=X,X=B}return S(X);case W:return be=Q._init,et(X,B,be(Q._payload),de)}if(at(Q))return xe(X,B,Q,de);if(D(Q))return we(X,B,Q,de);Ds(X,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"?(Q=""+Q,B!==null&&B.tag===6?(i(X,B.sibling),B=f(B,Q),B.return=X,X=B):(i(X,B),B=Eu(Q,X.mode,de),B.return=X,X=B),S(X)):i(X,B)}return et}var zi=bd(!0),Ed=bd(!1),Os=vr(null),Fs=null,Di=null,za=null;function Da(){za=Di=Fs=null}function Oa(e){var n=Os.current;Ue(Os),e._currentValue=n}function Fa(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function Oi(e,n){Fs=e,za=Di=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Lt=!0),e.firstContext=null)}function Zt(e){var n=e._currentValue;if(za!==e)if(e={context:e,memoizedValue:n,next:null},Di===null){if(Fs===null)throw Error(o(308));Di=e,Fs.dependencies={lanes:0,firstContext:e}}else Di=Di.next=e;return n}var ei=null;function Ha(e){ei===null?ei=[e]:ei.push(e)}function Cd(e,n,i,l){var f=n.interleaved;return f===null?(i.next=i,Ha(n)):(i.next=f.next,f.next=i),n.interleaved=i,Zn(e,l)}function Zn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var _r=!1;function Ba(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Md(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Jn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Sr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(ze&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,Zn(e,i)}return f=l.interleaved,f===null?(n.next=n,Ha(l)):(n.next=f.next,f.next=n),l.interleaved=n,Zn(e,i)}function Hs(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}function Pd(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var S={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?f=g=S:g=g.next=S,i=i.next}while(i!==null);g===null?f=g=n:g=g.next=n}else f=g=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function Bs(e,n,i,l){var f=e.updateQueue;_r=!1;var g=f.firstBaseUpdate,S=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,J=O.next;O.next=null,S===null?g=J:S.next=J,S=O;var ae=e.alternate;ae!==null&&(ae=ae.updateQueue,T=ae.lastBaseUpdate,T!==S&&(T===null?ae.firstBaseUpdate=J:T.next=J,ae.lastBaseUpdate=O))}if(g!==null){var ue=f.baseState;S=0,ae=J=O=null,T=g;do{var le=T.lane,ge=T.eventTime;if((l&le)===le){ae!==null&&(ae=ae.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var xe=e,we=T;switch(le=n,ge=i,we.tag){case 1:if(xe=we.payload,typeof xe=="function"){ue=xe.call(ge,ue,le);break e}ue=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=we.payload,le=typeof xe=="function"?xe.call(ge,ue,le):xe,le==null)break e;ue=H({},ue,le);break e;case 2:_r=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,le=f.effects,le===null?f.effects=[T]:le.push(T))}else ge={eventTime:ge,lane:le,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ae===null?(J=ae=ge,O=ue):ae=ae.next=ge,S|=le;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;le=T,T=le.next,le.next=null,f.lastBaseUpdate=le,f.shared.pending=null}}while(!0);if(ae===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=J,f.lastBaseUpdate=ae,n=f.shared.interleaved,n!==null){f=n;do S|=f.lane,f=f.next;while(f!==n)}else g===null&&(f.shared.lanes=0);ri|=S,e.lanes=S,e.memoizedState=ue}}function Id(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=Ga.transition;Ga.transition={};try{e(!1),n()}finally{Fe=i,Ga.transition=l}}function Kd(){return Jt().memoizedState}function Ny(e,n,i){var l=br(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},Qd(e))Zd(n,i);else if(i=Cd(e,n,i,l),i!==null){var f=Mt();dn(i,e,l,f),Jd(i,n,l)}}function jy(e,n,i){var l=br(e),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(Qd(e))Zd(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,T=g(S,i);if(f.hasEagerState=!0,f.eagerState=T,sn(T,S)){var O=n.interleaved;O===null?(f.next=f,Ha(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=Cd(e,n,f,l),i!==null&&(f=Mt(),dn(i,e,l,f),Jd(i,n,l))}}function Qd(e){var n=e.alternate;return e===Ke||n!==null&&n===Ke}function Zd(e,n){Ao=Us=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function Jd(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}var Xs={readContext:Zt,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},by={readContext:Zt,useCallback:function(e,n){return Pn().memoizedState=[e,n===void 0?null:n],e},useContext:Zt,useEffect:Bd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Ys(4194308,4,Ud.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Ys(4194308,4,e,n)},useInsertionEffect:function(e,n){return Ys(4,2,e,n)},useMemo:function(e,n){var i=Pn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=Pn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=Ny.bind(null,Ke,e),[l.memoizedState,e]},useRef:function(e){var n=Pn();return e={current:e},n.memoizedState=e},useState:Fd,useDebugValue:eu,useDeferredValue:function(e){return Pn().memoizedState=e},useTransition:function(){var e=Fd(!1),n=e[0];return e=ky.bind(null,e[1]),Pn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=Ke,f=Pn();if(Xe){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ht===null)throw Error(o(349));(ni&30)!==0||Ad(l,n,i)}f.memoizedState=i;var g={value:i,getSnapshot:n};return f.queue=g,Bd(zd.bind(null,l,g,e),[e]),l.flags|=2048,Do(9,$d.bind(null,l,g,i,n),void 0,null),i},useId:function(){var e=Pn(),n=ht.identifierPrefix;if(Xe){var i=Qn,l=Kn;i=(l&~(1<<32-Et(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=$o++,0<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=S.createElement(i,{is:l.is}):(e=S.createElement(i),i==="select"&&(S=e,l.multiple?S.multiple=!0:l.size&&(S.size=l.size))):e=S.createElementNS(e,i),e[Cn]=n,e[Mo]=l,wf(e,n,!1,!1),n.stateNode=e;e:{switch(S=zn(i,l),i){case"dialog":We("cancel",e),We("close",e),f=l;break;case"iframe":case"object":case"embed":We("load",e),f=l;break;case"video":case"audio":for(f=0;fWi&&(n.flags|=128,l=!0,Oo(g,!1),n.lanes=4194304)}else{if(!l)if(e=Vs(S),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Oo(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Xe)return Nt(n),null}else 2*Ve()-g.renderingStartTime>Wi&&i!==1073741824&&(n.flags|=128,l=!0,Oo(g,!1),n.lanes=4194304);g.isBackwards?(S.sibling=n.child,n.child=S):(i=g.last,i!==null?i.sibling=S:n.child=S,g.last=S)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(Nt(n),null);case 22:case 23:return Nu(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Yt&1073741824)!==0&&(Nt(n),n.subtreeFlags&6&&(n.flags|=8192)):Nt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function Ly(e,n){switch(Ta(n),n.tag){case 1:return Tt(n.type)&&Rs(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Fi(),Ue(Rt),Ue(St),Ya(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Wa(n),null;case 13:if(Ue(qe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));$i()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Fi(),null;case 10:return Oa(n.type._context),null;case 22:case 23:return Nu(),null;case 24:return null;default:return null}}var Zs=!1,jt=!1,Ay=typeof WeakSet=="function"?WeakSet:Set,ye=null;function Bi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Ze(e,n,l)}else i.current=null}function fu(e,n,i){try{i()}catch(l){Ze(e,n,l)}}var kf=!1;function $y(e,n){if(Na=vs,e=ed(),ma(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,g=l.focusNode;l=l.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var S=0,T=-1,O=-1,J=0,ae=0,ue=e,le=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=S+f),ue!==g||l!==0&&ue.nodeType!==3||(O=S+l),ue.nodeType===3&&(S+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)le=ue,ue=ge;for(;;){if(ue===e)break t;if(le===i&&++J===f&&(T=S),le===g&&++ae===l&&(O=S),(ge=ue.nextSibling)!==null)break;ue=le,le=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(ja={focusedElem:e,selectionRange:i},vs=!1,ye=n;ye!==null;)if(n=ye,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ye=e;else for(;ye!==null;){n=ye;try{var xe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var we=xe.memoizedProps,et=xe.memoizedState,X=n.stateNode,B=X.getSnapshotBeforeUpdate(n.elementType===n.type?we:an(n.type,we),et);X.__reactInternalSnapshotBeforeUpdate=B}break;case 3:var Q=n.stateNode.containerInfo;Q.nodeType===1?Q.textContent="":Q.nodeType===9&&Q.documentElement&&Q.removeChild(Q.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(de){Ze(n,n.return,de)}if(e=n.sibling,e!==null){e.return=n.return,ye=e;break}ye=n.return}return xe=kf,kf=!1,xe}function Fo(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&e)===e){var g=f.destroy;f.destroy=void 0,g!==void 0&&fu(n,i,g)}f=f.next}while(f!==l)}}function Js(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function hu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function Nf(e){var n=e.alternate;n!==null&&(e.alternate=null,Nf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[Cn],delete n[Mo],delete n[Ma],delete n[vy],delete n[xy])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function jf(e){return e.tag===5||e.tag===3||e.tag===4}function bf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||jf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function pu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=Ps));else if(l!==4&&(e=e.child,e!==null))for(pu(e,n,i),e=e.sibling;e!==null;)pu(e,n,i),e=e.sibling}function gu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(gu(e,n,i),e=e.sibling;e!==null;)gu(e,n,i),e=e.sibling}var vt=null,un=!1;function kr(e,n,i){for(i=i.child;i!==null;)Ef(e,n,i),i=i.sibling}function Ef(e,n,i){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(Vn,i)}catch{}switch(i.tag){case 5:jt||Bi(i,n);case 6:var l=vt,f=un;vt=null,kr(e,n,i),vt=l,un=f,vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):vt.removeChild(i.stateNode));break;case 18:vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?Ca(e.parentNode,i):e.nodeType===1&&Ca(e,i),vo(e)):Ca(vt,i.stateNode));break;case 4:l=vt,f=un,vt=i.stateNode.containerInfo,un=!0,kr(e,n,i),vt=l,un=f;break;case 0:case 11:case 14:case 15:if(!jt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var g=f,S=g.destroy;g=g.tag,S!==void 0&&((g&2)!==0||(g&4)!==0)&&fu(i,n,S),f=f.next}while(f!==l)}kr(e,n,i);break;case 1:if(!jt&&(Bi(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Ze(i,n,T)}kr(e,n,i);break;case 21:kr(e,n,i);break;case 22:i.mode&1?(jt=(l=jt)||i.memoizedState!==null,kr(e,n,i),jt=l):kr(e,n,i);break;default:kr(e,n,i)}}function Cf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new Ay),n.forEach(function(l){var f=Uy.bind(null,e,l);i.has(l)||(i.add(l),l.then(f,f))})}}function cn(e,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=S),l&=~g}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Dy(l/1960))-l,10e?16:e,jr===null)var l=!1;else{if(e=jr,jr=null,il=0,(ze&6)!==0)throw Error(o(331));var f=ze;for(ze|=4,ye=e.current;ye!==null;){var g=ye,S=g.child;if((ye.flags&16)!==0){var T=g.deletions;if(T!==null){for(var O=0;OVe()-vu?oi(e,0):yu|=i),$t(e,n)}function Hf(e,n){n===0&&((e.mode&1)===0?n=1:(n=Un,Un<<=1,(Un&130023424)===0&&(Un=4194304)));var i=Mt();e=Zn(e,n),e!==null&&(En(e,n,i),$t(e,i))}function Wy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Hf(e,i)}function Uy(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Hf(e,i)}var Bf;Bf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Rt.current)Lt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Lt=!1,Ry(e,n,i);Lt=(e.flags&131072)!==0}else Lt=!1,Xe&&(n.flags&1048576)!==0&&wd(n,$s,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Qs(e,n),e=n.pendingProps;var f=Ti(n,St.current);Oi(n,i),f=qa(null,n,l,e,f,i);var g=Ka();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Tt(l)?(g=!0,Ts(n)):g=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Ba(n),f.updater=qs,n.stateNode=f,f._reactInternals=n,nu(n,l,e,i),n=su(null,n,l,!0,g,i)):(n.tag=0,Xe&&g&&Ra(n),Ct(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Qs(e,n),e=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=Gy(l),e=an(l,e),f){case 0:n=ou(null,n,l,e,i);break e;case 1:n=pf(null,n,l,e,i);break e;case 11:n=uf(null,n,l,e,i);break e;case 14:n=cf(null,n,l,an(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),ou(e,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),pf(e,n,l,f,i);case 3:e:{if(gf(n),e===null)throw Error(o(387));l=n.pendingProps,g=n.memoizedState,f=g.element,Md(e,n),Bs(n,l,null,i);var S=n.memoizedState;if(l=S.element,g.isDehydrated)if(g={element:l,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){f=Hi(Error(o(423)),n),n=mf(e,n,l,i,f);break e}else if(l!==f){f=Hi(Error(o(424)),n),n=mf(e,n,l,i,f);break e}else for(Ut=yr(n.stateNode.containerInfo.firstChild),Wt=n,Xe=!0,ln=null,i=Ed(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if($i(),l===f){n=er(e,n,i);break e}Ct(e,n,l,i)}n=n.child}return n;case 5:return Rd(n),e===null&&Aa(n),l=n.type,f=n.pendingProps,g=e!==null?e.memoizedProps:null,S=f.children,ba(l,f)?S=null:g!==null&&ba(l,g)&&(n.flags|=32),hf(e,n),Ct(e,n,S,i),n.child;case 6:return e===null&&Aa(n),null;case 13:return yf(e,n,i);case 4:return Va(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=zi(n,null,l,i):Ct(e,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),uf(e,n,l,f,i);case 7:return Ct(e,n,n.pendingProps,i),n.child;case 8:return Ct(e,n,n.pendingProps.children,i),n.child;case 12:return Ct(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,g=n.memoizedProps,S=f.value,Be(Os,l._currentValue),l._currentValue=S,g!==null)if(sn(g.value,S)){if(g.children===f.children&&!Rt.current){n=er(e,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var T=g.dependencies;if(T!==null){S=g.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(g.tag===1){O=Jn(-1,i&-i),O.tag=2;var J=g.updateQueue;if(J!==null){J=J.shared;var ae=J.pending;ae===null?O.next=O:(O.next=ae.next,ae.next=O),J.pending=O}}g.lanes|=i,O=g.alternate,O!==null&&(O.lanes|=i),Fa(g.return,i,n),T.lanes|=i;break}O=O.next}}else if(g.tag===10)S=g.type===n.type?null:g.child;else if(g.tag===18){if(S=g.return,S===null)throw Error(o(341));S.lanes|=i,T=S.alternate,T!==null&&(T.lanes|=i),Fa(S,i,n),S=g.sibling}else S=g.child;if(S!==null)S.return=g;else for(S=g;S!==null;){if(S===n){S=null;break}if(g=S.sibling,g!==null){g.return=S.return,S=g;break}S=S.return}g=S}Ct(e,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,Oi(n,i),f=Zt(f),l=l(f),n.flags|=1,Ct(e,n,l,i),n.child;case 14:return l=n.type,f=an(l,n.pendingProps),f=an(l.type,f),cf(e,n,l,f,i);case 15:return df(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),Qs(e,n),n.tag=1,Tt(l)?(e=!0,Ts(n)):e=!1,Oi(n,i),tf(n,l,f),nu(n,l,f,i),su(null,n,l,!0,e,i);case 19:return xf(e,n,i);case 22:return ff(e,n,i)}throw Error(o(156,n.tag))};function Vf(e,n){return Hr(e,n)}function Yy(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tn(e,n,i,l){return new Yy(e,n,i,l)}function bu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Gy(e){if(typeof e=="function")return bu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ne)return 11;if(e===V)return 14}return 2}function Cr(e,n){var i=e.alternate;return i===null?(i=tn(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function al(e,n,i,l,f,g){var S=2;if(l=e,typeof e=="function")bu(e)&&(S=1);else if(typeof e=="string")S=5;else e:switch(e){case F:return li(i.children,f,g,n);case G:S=8,f|=8;break;case q:return e=tn(12,i,n,f|2),e.elementType=q,e.lanes=g,e;case K:return e=tn(13,i,n,f),e.elementType=K,e.lanes=g,e;case C:return e=tn(19,i,n,f),e.elementType=C,e.lanes=g,e;case U:return ul(i,f,g,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case te:S=10;break e;case ee:S=9;break e;case ne:S=11;break e;case V:S=14;break e;case W:S=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=tn(S,i,n,f),n.elementType=e,n.type=l,n.lanes=g,n}function li(e,n,i,l){return e=tn(7,e,l,n),e.lanes=i,e}function ul(e,n,i,l){return e=tn(22,e,l,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function Eu(e,n,i){return e=tn(6,e,null,n),e.lanes=i,e}function Cu(e,n,i){return n=tn(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Xy(e,n,i,l,f){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Yn(0),this.expirationTimes=Yn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Yn(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Mu(e,n,i,l,f,g,S,T,O){return e=new Xy(e,n,i,T,O),n===1?(n=1,g===!0&&(n|=8)):n=0,g=tn(3,null,null,n),e.current=g,g.stateNode=e,g.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ba(g),e}function qy(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),Au.exports=l0(),Au.exports}var rh;function a0(){if(rh)return ml;rh=1;var t=jp();return ml.createRoot=t.createRoot,ml.hydrateRoot=t.hydrateRoot,ml}var u0=a0();function bp(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Ae(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(bp(s,o.statusText||"Request failed"))}return o.json()}const c0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Pe={health:()=>Ae("/api/health"),settings:()=>Ae("/api/settings"),saveSettings:t=>{const r={...t};for(const o of c0)r[o]===""&&delete r[o];return Ae("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ae("/api/repos"),browse:t=>Ae(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ae(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ae("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ae(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Ae(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:(t,r=!0)=>Ae(`/api/architecture?repo_path=${encodeURIComponent(t)}&graph=${r?"1":"0"}`),architectureGraph:t=>Ae(`/api/architecture/graph?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Ae("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Ae("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Ae("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Ae("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Ae("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Ae(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open",s)=>Ae("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o,repo_path:s||null})}),scmRepos:t=>Ae(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ae("/api/oauth/status"),githubOAuthStart:()=>Ae("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ae("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ae("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Ae("/api/oauth/gitlab/start"),oauthDisconnect:t=>Ae("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ae("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})}),reviews:t=>Ae(`/api/reviews?repo_path=${encodeURIComponent(t)}`),getReview:(t,r)=>Ae(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(t)}`),reviewDiff:(t,r,o)=>Ae(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(t)}&other=${encodeURIComponent(o)}`),config:t=>Ae(`/api/config?repo_path=${encodeURIComponent(t)}`),saveConfig:(t,r)=>Ae("/api/config",{method:"PUT",body:JSON.stringify({repo_path:t,...r})}),addWaiver:(t,r,o,s)=>Ae("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:t,rule:r,node:o||null,reason:s||""})}),marks:(t,r)=>Ae(`/api/marks?repo_path=${encodeURIComponent(t)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:t=>Ae(`/api/architecture/health?repo_path=${encodeURIComponent(t)}`),workspaceStatus:t=>Ae(`/api/workspace/status?repo_path=${encodeURIComponent(t)}`),openEditor:(t,r,o,s)=>Ae("/api/open",{method:"POST",body:JSON.stringify({repo_path:t,path:r,line:o||null,editor:s||null})}),exportHtml:t=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:t})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(bp(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(t,r,o,s)=>Ae("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:t,edges:r,source_id:o,target_id:s||null})})};function d0(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):t}function f0({open:t,actions:r,onClose:o}){const[s,a]=L.useState(""),[u,c]=L.useState(0),h=L.useRef(null),p=L.useMemo(()=>d0(r,s),[r,s]);if(L.useEffect(()=>{if(!t)return;a(""),c(0);const y=window.setTimeout(()=>{var m;return(m=h.current)==null?void 0:m.focus()},0);return()=>window.clearTimeout(y)},[t]),L.useEffect(()=>{c(0)},[s]),!t)return null;const v=p[u],x=y=>{y&&(o(),y.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:y=>{y.target===y.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:y=>a(y.target.value),onKeyDown:y=>{y.key==="Escape"?(y.preventDefault(),o()):y.key==="ArrowDown"?(y.preventDefault(),c(m=>Math.min(p.length-1,m+1))):y.key==="ArrowUp"?(y.preventDefault(),c(m=>Math.max(0,m-1))):y.key==="Enter"&&(y.preventDefault(),x(v))}}),d.jsxs("ul",{children:[p.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,p.slice(0,40).map((y,m)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:m===u?"active":"",onMouseEnter:()=>c(m),onClick:()=>x(y),children:[d.jsx("span",{children:y.label}),y.hint?d.jsx("span",{className:"muted",children:y.hint}):null]})},y.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function h0({config:t,busy:r,onSave:o,onWaiver:s}){const[a,u]=L.useState(t),[c,h]=L.useState(t.available_rules[0]||""),[p,v]=L.useState(""),[x,y]=L.useState("");L.useEffect(()=>{u(t)},[t]);const m=Object.entries(a.contexts||{}),_=(R,w,N)=>{const A=a.contexts[R];if(!A)return;const $=F=>F.split(",").map(G=>G.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[R]:{...A,[w]:w==="name"?N:$(N)}}})},k=(R,w)=>{const N=w.trim();if(!N||N===R)return;const{[R]:A,...$}=a.contexts;A&&u({...a,contexts:{...$,[N]:{...A,name:N}}})},j=()=>{let R=1;for(;a.contexts[`context-${R}`];)R+=1;const w=`context-${R}`;u({...a,contexts:{...a.contexts,[w]:{name:w,django_apps:[],react:[],public_api:[],owners:[]}}})},b=R=>{const{[R]:w,...N}=a.contexts;u({...a,contexts:N})},E=R=>{const w=a.rules.includes(R);u({...a,rules:w?a.rules.filter(N=>N!==R):[...a.rules,R]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),m.map(([R,w])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:R})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:R,"data-testid":`config-context-name-${R}`,onBlur:N=>k(R,N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(w.django_apps||[]).join(", "),onChange:N=>_(R,"django_apps",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(w.react||[]).join(", "),onChange:N=>_(R,"react",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(w.public_api||[]).join(", "),onChange:N=>_(R,"public_api",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(w.owners||[]).join(", "),onChange:N=>_(R,"owners",N.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>b(R),children:"Remove context"})]},R)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:j,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(R),onChange:()=>E(R)}),R]},R))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((R,w)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:R.rule}),R.node?` · ${R.node}`:"",R.reason?` — ${R.reason}`:""]},`${R.rule}:${R.node}:${w}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:R=>h(R.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsx("option",{value:R,children:R},R))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:R=>v(R.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:x,onChange:R=>y(R.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,x),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function Zo(t){return t.replaceAll("_"," ")}function p0(t){return t.replaceAll("_"," ")}function io(t){return t.split(".").pop()||t}function ec(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function g0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Tr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function yi({className:t,children:r}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function m0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function y0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function v0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function x0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function w0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function Ep({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function _0({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const S0="modulepreload",k0=function(t,r){return new URL(t,r).href},ih={},N0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(x){return Promise.all(x.map(y=>Promise.resolve(y).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),v=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(x=>{if(x=k0(x,s),x in ih)return;ih[x]=!0;const y=x.endsWith(".css"),m=y?'[rel="stylesheet"]':"";if(!!s)for(let j=h.length-1;j>=0;j--){const b=h[j];if(b.href===x&&(!y||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${x}"]${m}`))return;const k=document.createElement("link");if(k.rel=y?"stylesheet":S0,y||(k.as="script"),k.crossOrigin="",k.href=x,v&&k.setAttribute("nonce",v),document.head.appendChild(k),y)return new Promise((j,b)=>{k.addEventListener("load",j),k.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${x}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function nt(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Yl(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}Cl.prototype=Yl.prototype={constructor:Cl,on:function(t,r){var o=this._,s=b0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),sh.hasOwnProperty(r)?{space:sh[r],local:t}:t}function C0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===tc&&r.documentElement.namespaceURI===tc?r.createElement(t):r.createElementNS(o,t)}}function M0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Cp(t){var r=Gl(t);return(r.local?M0:C0)(r)}function P0(){}function pc(t){return t==null?P0:function(){return this.querySelector(t)}}function I0(t){typeof t!="function"&&(t=pc(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=w&&(w=R+1);!(A=b[w])&&++w=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function nv(t){t||(t=rv);function r(y,m){return y&&m?t(y.__data__,m.__data__):!y-!m}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function iv(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function ov(){return Array.from(this)}function sv(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?yv:typeof r=="function"?xv:vv)(t,r,o??"")):Ki(this.node(),t)}function Ki(t,r){return t.style.getPropertyValue(r)||Tp(t).getComputedStyle(t,null).getPropertyValue(r)}function _v(t){return function(){delete this[t]}}function Sv(t,r){return function(){this[t]=r}}function kv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function Nv(t,r){return arguments.length>1?this.each((r==null?_v:typeof r=="function"?kv:Sv)(t,r)):this.node()[t]}function Lp(t){return t.trim().split(/^|\s+/)}function gc(t){return t.classList||new Ap(t)}function Ap(t){this._node=t,this._names=Lp(t.getAttribute("class")||"")}Ap.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function $p(t,r){for(var o=gc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function Zv(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function nc(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:v,dispatch:x}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:v,enumerable:!0,configurable:!0},_:{value:x}})}nc.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function ax(t){return!t.ctrlKey&&!t.button}function ux(){return this.parentNode}function cx(t,r){return r??{x:t.x,y:t.y}}function dx(){return navigator.maxTouchPoints||"ontouchstart"in this}function Bp(){var t=ax,r=ux,o=cx,s=dx,a={},u=Yl("start","drag","end"),c=0,h,p,v,x,y=0;function m(N){N.on("mousedown.drag",_).filter(s).on("touchstart.drag",b).on("touchmove.drag",E,lx).on("touchend.drag touchcancel.drag",R).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(N,A){if(!(x||!t.call(this,N,A))){var $=w(this,r.call(this,N,A),N,A,"mouse");$&&(Gt(N.view).on("mousemove.drag",k,Jo).on("mouseup.drag",j,Jo),Fp(N.view),Du(N),v=!1,h=N.clientX,p=N.clientY,$("start",N))}}function k(N){if(Xi(N),!v){var A=N.clientX-h,$=N.clientY-p;v=A*A+$*$>y}a.mouse("drag",N)}function j(N){Gt(N.view).on("mousemove.drag mouseup.drag",null),Hp(N.view,v),Xi(N),a.mouse("end",N)}function b(N,A){if(t.call(this,N,A)){var $=N.changedTouches,F=r.call(this,N,A),G=$.length,q,te;for(q=0;q>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?vl(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?vl(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=hx.exec(t))?new Dt(r[1],r[2],r[3],1):(r=px.exec(t))?new Dt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=gx.exec(t))?vl(r[1],r[2],r[3],r[4]):(r=mx.exec(t))?vl(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=yx.exec(t))?hh(r[1],r[2]/100,r[3]/100,1):(r=vx.exec(t))?hh(r[1],r[2]/100,r[3]/100,r[4]):lh.hasOwnProperty(t)?ch(lh[t]):t==="transparent"?new Dt(NaN,NaN,NaN,0):null}function ch(t){return new Dt(t>>16&255,t>>8&255,t&255,1)}function vl(t,r,o,s){return s<=0&&(t=r=o=NaN),new Dt(t,r,o,s)}function _x(t){return t instanceof ds||(t=fi(t)),t?(t=t.rgb(),new Dt(t.r,t.g,t.b,t.opacity)):new Dt}function rc(t,r,o,s){return arguments.length===1?_x(t):new Dt(t,r,o,s??1)}function Dt(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}mc(Dt,rc,Vp(ds,{brighter(t){return t=t==null?Ll:Math.pow(Ll,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?es:Math.pow(es,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Dt(ci(this.r),ci(this.g),ci(this.b),Al(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:dh,formatHex:dh,formatHex8:Sx,formatRgb:fh,toString:fh}));function dh(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}`}function Sx(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}${ui((isNaN(this.opacity)?1:this.opacity)*255)}`}function fh(){const t=Al(this.opacity);return`${t===1?"rgb(":"rgba("}${ci(this.r)}, ${ci(this.g)}, ${ci(this.b)}${t===1?")":`, ${t})`}`}function Al(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ci(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ui(t){return t=ci(t),(t<16?"0":"")+t.toString(16)}function hh(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new hn(t,r,o,s)}function Wp(t){if(t instanceof hn)return new hn(t.h,t.s,t.l,t.opacity);if(t instanceof ds||(t=fi(t)),!t)return new hn;if(t instanceof hn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new hn(c,h,p,t.opacity)}function kx(t,r,o,s){return arguments.length===1?Wp(t):new hn(t,r,o,s??1)}function hn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}mc(hn,kx,Vp(ds,{brighter(t){return t=t==null?Ll:Math.pow(Ll,t),new hn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?es:Math.pow(es,t),new hn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Dt(Ou(t>=240?t-240:t+120,a,s),Ou(t,a,s),Ou(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new hn(ph(this.h),xl(this.s),xl(this.l),Al(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 t=Al(this.opacity);return`${t===1?"hsl(":"hsla("}${ph(this.h)}, ${xl(this.s)*100}%, ${xl(this.l)*100}%${t===1?")":`, ${t})`}`}}));function ph(t){return t=(t||0)%360,t<0?t+360:t}function xl(t){return Math.max(0,Math.min(1,t||0))}function Ou(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const yc=t=>()=>t;function Nx(t,r){return function(o){return t+o*r}}function jx(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function bx(t){return(t=+t)==1?Up:function(r,o){return o-r?jx(r,o,t):yc(isNaN(r)?o:r)}}function Up(t,r){var o=r-t;return o?Nx(t,o):yc(isNaN(t)?r:t)}const $l=(function t(r){var o=bx(r);function s(a,u){var c=o((a=rc(a)).r,(u=rc(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),v=Up(a.opacity,u.opacity);return function(x){return a.r=c(x),a.g=h(x),a.b=p(x),a.opacity=v(x),a+""}}return s.gamma=t,s})(1);function Ex(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:Rn(s,a)})),o=Fu.lastIndex;return o180?x+=360:x-v>180&&(v+=360),m.push({i:y.push(a(y)+"rotate(",null,s)-2,x:Rn(v,x)})):x&&y.push(a(y)+"rotate("+x+s)}function h(v,x,y,m){v!==x?m.push({i:y.push(a(y)+"skewX(",null,s)-2,x:Rn(v,x)}):x&&y.push(a(y)+"skewX("+x+s)}function p(v,x,y,m,_,k){if(v!==y||x!==m){var j=_.push(a(_)+"scale(",null,",",null,")");k.push({i:j-4,x:Rn(v,y)},{i:j-2,x:Rn(x,m)})}else(y!==1||m!==1)&&_.push(a(_)+"scale("+y+","+m+")")}return function(v,x){var y=[],m=[];return v=t(v),x=t(x),u(v.translateX,v.translateY,x.translateX,x.translateY,y,m),c(v.rotate,x.rotate,y,m),h(v.skewX,x.skewX,y,m),p(v.scaleX,v.scaleY,x.scaleX,x.scaleY,y,m),v=x=null,function(_){for(var k=-1,j=m.length,b;++k=0&&t._call.call(void 0,r),t=t._next;--Qi}function yh(){hi=(Dl=ns.now())+Xl,Qi=Xo=0;try{Bx()}finally{Qi=0,Wx(),hi=0}}function Vx(){var t=ns.now(),r=t-Dl;r>qp&&(Xl-=r,Dl=t)}function Wx(){for(var t,r=zl,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:zl=o);qo=t,sc(s)}function sc(t){if(!Qi){Xo&&(Xo=clearTimeout(Xo));var r=t-hi;r>24?(t<1/0&&(Xo=setTimeout(yh,t-ns.now()-Xl)),Yo&&(Yo=clearInterval(Yo))):(Yo||(Dl=ns.now(),Yo=setInterval(Vx,qp)),Qi=1,Kp(yh))}}function vh(t,r,o){var s=new Ol;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Ux=Yl("start","end","cancel","interrupt"),Yx=[],Zp=0,xh=1,lc=2,Pl=3,wh=4,ac=5,Il=6;function ql(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;Gx(t,o,{name:r,index:s,group:a,on:Ux,tween:Yx,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Zp})}function xc(t,r){var o=yn(t,r);if(o.state>Zp)throw new Error("too late; already scheduled");return o}function Ln(t,r){var o=yn(t,r);if(o.state>Pl)throw new Error("too late; already running");return o}function yn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Gx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=Qp(u,0,o.time);function u(v){o.state=xh,o.timer.restart(c,o.delay,o.time),o.delay<=v&&c(v-o.delay)}function c(v){var x,y,m,_;if(o.state!==xh)return p();for(x in s)if(_=s[x],_.name===o.name){if(_.state===Pl)return vh(c);_.state===wh?(_.state=Il,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete s[x]):+xlc&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function kw(t,r,o){var s,a,u=Sw(r)?xc:Ln;return function(){var c=u(this,t),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function Nw(t,r){var o=this._id;return arguments.length<2?yn(this.node(),o).on.on(t):this.each(kw(o,t,r))}function jw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function bw(){return this.on("end.remove",jw(this._id))}function Ew(t){var r=this._name,o=this._id;typeof t!="function"&&(t=pc(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function Zw(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function rr(t,r,o){this.k=t,this.x=r,this.y=o}rr.prototype={constructor:rr,scale:function(t){return t===1?this:new rr(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new rr(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Kl=new rr(1,0,0);ng.prototype=rr.prototype;function ng(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Kl;return t.__zoom}function Hu(t){t.stopImmediatePropagation()}function Go(t){t.preventDefault(),t.stopImmediatePropagation()}function Jw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function e1(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function _h(){return this.__zoom||Kl}function t1(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function n1(){return navigator.maxTouchPoints||"ontouchstart"in this}function r1(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function rg(){var t=Jw,r=e1,o=r1,s=t1,a=n1,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=Ml,v=Yl("start","zoom","end"),x,y,m,_=500,k=150,j=0,b=10;function E(C){C.property("__zoom",_h).on("wheel.zoom",G,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",te).filter(a).on("touchstart.zoom",ee).on("touchmove.zoom",ne).on("touchend.zoom touchcancel.zoom",K).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(C,V,W,U){var M=C.selection?C.selection():C;M.property("__zoom",_h),C!==M?A(C,V,W,U):M.interrupt().each(function(){$(this,arguments).event(U).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},E.scaleBy=function(C,V,W,U){E.scaleTo(C,function(){var M=this.__zoom.k,D=typeof V=="function"?V.apply(this,arguments):V;return M*D},W,U)},E.scaleTo=function(C,V,W,U){E.transform(C,function(){var M=r.apply(this,arguments),D=this.__zoom,H=W==null?N(M):typeof W=="function"?W.apply(this,arguments):W,I=D.invert(H),z=typeof V=="function"?V.apply(this,arguments):V;return o(w(R(D,z),H,I),M,c)},W,U)},E.translateBy=function(C,V,W,U){E.transform(C,function(){return o(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),r.apply(this,arguments),c)},null,U)},E.translateTo=function(C,V,W,U,M){E.transform(C,function(){var D=r.apply(this,arguments),H=this.__zoom,I=U==null?N(D):typeof U=="function"?U.apply(this,arguments):U;return o(Kl.translate(I[0],I[1]).scale(H.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),D,c)},U,M)};function R(C,V){return V=Math.max(u[0],Math.min(u[1],V)),V===C.k?C:new rr(V,C.x,C.y)}function w(C,V,W){var U=V[0]-W[0]*C.k,M=V[1]-W[1]*C.k;return U===C.x&&M===C.y?C:new rr(C.k,U,M)}function N(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function A(C,V,W,U){C.on("start.zoom",function(){$(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(U).end()}).tween("zoom",function(){var M=this,D=arguments,H=$(M,D).event(U),I=r.apply(M,D),z=W==null?N(I):typeof W=="function"?W.apply(M,D):W,ie=Math.max(I[1][0]-I[0][0],I[1][1]-I[0][1]),oe=M.__zoom,fe=typeof V=="function"?V.apply(M,D):V,he=p(oe.invert(z).concat(ie/oe.k),fe.invert(z).concat(ie/fe.k));return function(pe){if(pe===1)pe=fe;else{var Z=he(pe),se=ie/Z[2];pe=new rr(se,z[0]-Z[0]*se,z[1]-Z[1]*se)}H.zoom(null,pe)}})}function $(C,V,W){return!W&&C.__zooming||new F(C,V)}function F(C,V){this.that=C,this.args=V,this.active=0,this.sourceEvent=null,this.extent=r.apply(C,V),this.taps=0}F.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,V){return this.mouse&&C!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var V=Gt(this.that).datum();v.call(C,this.that,new Zw(C,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:v}),V)}};function G(C,...V){if(!t.apply(this,arguments))return;var W=$(this,V).event(C),U=this.__zoom,M=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,s.apply(this,arguments)))),D=fn(C);if(W.wheel)(W.mouse[0][0]!==D[0]||W.mouse[0][1]!==D[1])&&(W.mouse[1]=U.invert(W.mouse[0]=D)),clearTimeout(W.wheel);else{if(U.k===M)return;W.mouse=[D,U.invert(D)],Rl(this),W.start()}Go(C),W.wheel=setTimeout(H,k),W.zoom("mouse",o(w(R(U,M),W.mouse[0],W.mouse[1]),W.extent,c));function H(){W.wheel=null,W.end()}}function q(C,...V){if(m||!t.apply(this,arguments))return;var W=C.currentTarget,U=$(this,V,!0).event(C),M=Gt(C.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",ie,!0),D=fn(C,W),H=C.clientX,I=C.clientY;Fp(C.view),Hu(C),U.mouse=[D,this.__zoom.invert(D)],Rl(this),U.start();function z(oe){if(Go(oe),!U.moved){var fe=oe.clientX-H,he=oe.clientY-I;U.moved=fe*fe+he*he>j}U.event(oe).zoom("mouse",o(w(U.that.__zoom,U.mouse[0]=fn(oe,W),U.mouse[1]),U.extent,c))}function ie(oe){M.on("mousemove.zoom mouseup.zoom",null),Hp(oe.view,U.moved),Go(oe),U.event(oe).end()}}function te(C,...V){if(t.apply(this,arguments)){var W=this.__zoom,U=fn(C.changedTouches?C.changedTouches[0]:C,this),M=W.invert(U),D=W.k*(C.shiftKey?.5:2),H=o(w(R(W,D),U,M),r.apply(this,V),c);Go(C),h>0?Gt(this).transition().duration(h).call(A,H,U,C):Gt(this).call(E.transform,H,U,C)}}function ee(C,...V){if(t.apply(this,arguments)){var W=C.touches,U=W.length,M=$(this,V,C.changedTouches.length===U).event(C),D,H,I,z;for(Hu(C),H=0;H`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},rs=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ig=["Enter"," ","Escape"],og={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Zi;(function(t){t.Strict="strict",t.Loose="loose"})(Zi||(Zi={}));var di;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(di||(di={}));var is;(function(t){t.Partial="partial",t.Full="full"})(is||(is={}));const sg={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Lr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Lr||(Lr={}));var os;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(os||(os={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const Sh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function lg(t){return t===null?null:t?"valid":"invalid"}const ag=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,i1=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),_c=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),fs=(t,r=[0,0])=>{const{width:o,height:s}=vn(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},o1=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):_c(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,Ql(a,Fl(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?Zl(s):{x:0,y:0,width:0,height:0}},hs=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=Ql(o,Fl(a)),s=!0)}),s?Zl(o):{x:0,y:0,width:0,height:0}},Sc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,v=r.width/a,x=r.height/a,y=[];for(const m of t.values()){const{measured:_,selectable:k=!0,hidden:j=!1}=m;if(c&&!k||j)continue;const b=_.width??m.width??m.initialWidth??0,E=_.height??m.height??m.initialHeight??0,{x:R,y:w}=m.internals.positionAbsolute,N=fg(h,p,v,x,R,w,b,E),A=b*E,$=u&&N>0;(!m.internals.handleBounds||$||N>=A||m.dragging)&&y.push(m)}return y},s1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function l1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=vn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function a1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const h=l1(t,c),p=hs(h),v=Nc(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(v,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function ug({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),h=c.parentId?o.get(c.parentId):void 0,{x:p,y:v}=h?h.internals.positionAbsolute:{x:0,y:0},x=c.origin??s;let y=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",mn.error005());else{const{width:_,height:k}=vn(h);_&&k&&(y=[[p,v],[p+_,v+k]])}else h&&gi(c.extent)&&(y=[[c.extent[0][0]+p,c.extent[0][1]+v],[c.extent[1][0]+p,c.extent[1][1]+v]]);const m=gi(y)?pi(r,y,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",mn.error015())),{position:{x:m.x-p+(c.measured.width??0)*x[0],y:m.y-v+(c.measured.height??0)*x[1]},positionAbsolute:m}}async function u1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(m=>m.id)),c=[];for(const m of o){if(m.deletable===!1)continue;const _=u.has(m.id),k=!_&&m.parentId&&c.find(j=>j.id===m.parentId);(_||k)&&c.push(m)}const h=new Set(r.map(m=>m.id)),p=s.filter(m=>m.deletable!==!1),x=s1(c,p);for(const m of p)h.has(m.id)&&!x.find(k=>k.id===m.id)&&x.push(m);if(!a)return{edges:x,nodes:c};const y=await a({nodes:c,edges:x});return typeof y=="boolean"?y?{edges:x,nodes:c}:{edges:[],nodes:[]}:y}const Ji=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),pi=(t={x:0,y:0},r,o)=>({x:Ji(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:Ji(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function cg(t,r,o){const{width:s,height:a}=vn(o),{x:u,y:c}=o.internals.positionAbsolute;return pi(t,[[u,c],[u+s,c+a]],r)}const kh=(t,r,o)=>to?-Ji(Math.abs(t-o),1,r)/r:0,kc=(t,r,o=15,s=40)=>{const a=kh(t.x,s,r.width-s)*o,u=kh(t.y,s,r.height-s)*o;return[a,u]},Ql=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),uc=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),Zl=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),ss=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:fs(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},Fl=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=_c(t)?t.internals.positionAbsolute:fs(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},dg=(t,r)=>Zl(Ql(uc(t),uc(r))),fg=(t,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),v=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*v)},Hl=(t,r)=>fg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),Nh=t=>pn(t.width)&&pn(t.height)&&pn(t.x)&&pn(t.y),pn=t=>!isNaN(t)&&isFinite(t),hg=(t,r)=>(o,s)=>{},ps=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),gs=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(t-o)/a,y:(r-s)/a};return u?ps(h,c):h},eo=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Yi(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function c1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Yi(t,o),a=Yi(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Yi(t.top??t.y??0,o),a=Yi(t.bottom??t.y??0,o),u=Yi(t.left??t.x??0,r),c=Yi(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function d1(t,r,o,s,a,u){const{x:c,y:h}=eo(t,[r,o,s]),{x:p,y:v}=eo({x:t.x+t.width,y:t.y+t.height},[r,o,s]),x=a-p,y=u-v;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(x),bottom:Math.floor(y)}}const Nc=(t,r,o,s,a,u)=>{const c=c1(u,r,o),h=(r-c.x)/t.width,p=(o-c.y)/t.height,v=Math.min(h,p),x=Ji(v,s,a),y=t.x+t.width/2,m=t.y+t.height/2,_=r/2-y*x,k=o/2-m*x,j=d1(t,_,k,x,r,o),b={left:Math.min(j.left-c.left,0),top:Math.min(j.top-c.top,0),right:Math.min(j.right-c.right,0),bottom:Math.min(j.bottom-c.bottom,0)};return{x:_-b.left+b.right,y:k-b.top+b.bottom,zoom:x}},ls=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function gi(t){return t!=null&&t!=="parent"}function vn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function pg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function gg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function jh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function f1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function h1(t){return{...og,...t||{}}}function Qo(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=gn(t),h=gs({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y:v}=o?ps(h,r):h;return{xSnapped:p,ySnapped:v,...h}}const jc=t=>({width:t.offsetWidth,height:t.offsetHeight}),mg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},p1=["INPUT","SELECT","TEXTAREA"];function yg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:p1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const vg=t=>"clientX"in t,gn=(t,r)=>{var u,c;const o=vg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},bh=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...jc(c)}})};function xg({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=t*.125+a*.375+c*.375+o*.125,v=r*.125+u*.375+h*.375+s*.125,x=Math.abs(p-t),y=Math.abs(v-r);return[p,v,x,y]}function Sl(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function Eh({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case Se.Left:return[r-Sl(r-s,u),o];case Se.Right:return[r+Sl(s-r,u),o];case Se.Top:return[r,o-Sl(o-a,u)];case Se.Bottom:return[r,o+Sl(a-o,u)]}}function wg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top,curvature:c=.25}){const[h,p]=Eh({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[v,x]=Eh({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[y,m,_,k]=xg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:v,targetControlY:x});return[`M${t},${r} C${h},${p} ${v},${x} ${s},${a}`,y,m,_,k]}function _g({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const y1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,v1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),x1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",mn.error006()),r;const s=o.getEdgeId||y1;let a;return ag(t)?a={...t}:a={...t,id:s(t)},v1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function Sg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=_g({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,h]}const Ch={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},w1=({source:t,sourcePosition:r=Se.Bottom,target:o})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function _1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:s=Se.Top,center:a,offset:u,stepPosition:c}){const h=Ch[r],p=Ch[s],v={x:t.x+h.x*u,y:t.y+h.y*u},x={x:o.x+p.x*u,y:o.y+p.y*u},y=w1({source:v,sourcePosition:r,target:x}),m=y.x!==0?"x":"y",_=y[m];let k=[],j,b;const E={x:0,y:0},R={x:0,y:0},[,,w,N]=_g({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[m]*p[m]===-1){m==="x"?(j=a.x??v.x+(x.x-v.x)*c,b=a.y??(v.y+x.y)/2):(j=a.x??(v.x+x.x)/2,b=a.y??v.y+(x.y-v.y)*c);const G=[{x:j,y:v.y},{x:j,y:x.y}],q=[{x:v.x,y:b},{x:x.x,y:b}];h[m]===_?k=m==="x"?G:q:k=m==="x"?q:G}else{const G=[{x:v.x,y:x.y}],q=[{x:x.x,y:v.y}];if(m==="x"?k=h.x===_?q:G:k=h.y===_?G:q,r===s){const C=Math.abs(t[m]-o[m]);if(C<=u){const V=Math.min(u-1,u-C);h[m]===_?E[m]=(v[m]>t[m]?-1:1)*V:R[m]=(x[m]>o[m]?-1:1)*V}}if(r!==s){const C=m==="x"?"y":"x",V=h[m]===p[C],W=v[C]>x[C],U=v[C]=K?(j=(te.x+ee.x)/2,b=k[0].y):(j=k[0].x,b=(te.y+ee.y)/2)}const A={x:v.x+E.x,y:v.y+E.y},$={x:x.x+R.x,y:x.y+R.y};return[[t,...A.x!==k[0].x||A.y!==k[0].y?[A]:[],...k,...$.x!==k[k.length-1].x||$.y!==k[k.length-1].y?[$]:[],o],j,b,w,N]}function S1(t,r,o,s){const a=Math.min(Mh(t,r)/2,Mh(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const v=t.xo.id===r):t[0])||null}function cc(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function N1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const v=cc(p,r);u.has(v)||(c.push({id:v,color:p.color||o,...p}),u.add(v))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const kg=1e3,j1=10,bc={nodeOrigin:[0,0],nodeExtent:rs,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},b1={...bc,checkEquality:!0};function Ec(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function E1(t,r,o){const s=Ec(bc,o);for(const a of t.values())if(a.parentId)Mc(a,t,r,s);else{const u=fs(a,s.nodeOrigin),c=gi(a.extent)?a.extent:s.nodeExtent,h=pi(u,c,vn(a));a.internals.positionAbsolute=h}}function C1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function Cc(t){return t==="manual"}function dc(t,r,o,s={}){var x,y;const a=Ec(b1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!Cc(a.zIndexMode)?kg:0;let p=t.length>0,v=!1;r.clear(),o.clear();for(const m of t){let _=c.get(m.id);if(a.checkEquality&&m===(_==null?void 0:_.internals.userNode))r.set(m.id,_);else{const k=fs(m,a.nodeOrigin),j=gi(m.extent)?m.extent:a.nodeExtent,b=pi(k,j,vn(m));_={...a.defaults,...m,measured:{width:(x=m.measured)==null?void 0:x.width,height:(y=m.measured)==null?void 0:y.height},internals:{positionAbsolute:b,handleBounds:C1(m,_),z:Ng(m,h,a.zIndexMode),userNode:m}},r.set(m.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),m.parentId&&Mc(_,r,o,s,u),v||(v=m.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:v}}function M1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function Mc(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=Ec(bc,s),v=t.parentId,x=r.get(v);if(!x){console.warn(`Parent node ${v} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}M1(t,o),a&&!x.parentId&&x.internals.rootParentIndex===void 0&&p==="auto"&&(x.internals.rootParentIndex=++a.i,x.internals.z=x.internals.z+a.i*j1),a&&x.internals.rootParentIndex!==void 0&&(a.i=x.internals.rootParentIndex);const y=u&&!Cc(p)?kg:0,{x:m,y:_,z:k}=P1(t,x,c,h,y,p),{positionAbsolute:j}=t.internals,b=m!==j.x||_!==j.y;(b||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:b?{x:m,y:_}:j,z:k}})}function Ng(t,r,o){const s=pn(t.zIndex)?t.zIndex:0;return Cc(o)?s:s+(t.selected?r:0)}function P1(t,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=vn(t),v=fs(t,o),x=gi(t.extent)?pi(v,t.extent,p):v;let y=pi({x:c+x.x,y:h+x.y},s,p);t.extent==="parent"&&(y=cg(y,p,r));const m=Ng(t,a,u),_=r.internals.z??0;return{x:y.x,y:y.y,z:_>=m?_+1:m}}function Pc(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const v=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??ss(p),x=dg(v,h.rect);u.set(h.parentId,{expandedRect:x,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},v)=>{var w;const x=p.internals.positionAbsolute,y=vn(p),m=p.origin??s,_=h.x0||k>0||E||R)&&(a.push({id:v,type:"position",position:{x:p.position.x-_+E,y:p.position.y-k+R}}),(w=o.get(v))==null||w.forEach(N=>{t.some(A=>A.id===N.id)||a.push({id:N.id,type:"position",position:{x:N.position.x+_,y:N.position.y+k}})})),(y.width0){const _=Pc(m,r,o,a);v.push(..._)}return{changes:v,updatedInternals:p}}async function R1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Th(t,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${t}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${t}-${u}`;const v=s.get(c)||new Map;s.set(c,v.set(o,r))}}function jg(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},v=`${a}-${c}--${u}-${h}`,x=`${u}-${h}--${a}-${c}`;Th("source",p,x,t,a,c),Th("target",p,v,t,u,h),r.set(s.id,s)}}function bg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:bg(o,r):!1}function Lh(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function T1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!bg(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function Bu({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[v,x]of r){const y=(c=o.get(v))==null?void 0:c.internals.userNode;y&&a.push({...y,position:x.position,dragging:s})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function L1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=ps(u,r);return{x:c.x-u.x,y:c.y-u.y}}function A1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,v={x:0,y:0},x=null,y=!1,m=null,_=!1,k=!1,j=null;function b({noDragClassName:R,handleSelector:w,domNode:N,isSelectable:A,nodeId:$,nodeClickDistance:F=0}){m=Gt(N);function G({x:ne,y:K}){const{nodeLookup:C,nodeExtent:V,snapGrid:W,snapToGrid:U,nodeOrigin:M,onNodeDrag:D,onSelectionDrag:H,onError:I,updateNodePositions:z}=r();u={x:ne,y:K};let ie=!1;const oe=h.size>1,fe=oe&&V?uc(hs(h)):null,he=oe&&U?L1({dragItems:h,snapGrid:W,x:ne,y:K}):null;for(const[pe,Z]of h){if(!C.has(pe))continue;let se={x:ne-Z.distance.x,y:K-Z.distance.y};U&&(se=he?{x:Math.round(se.x+he.x),y:Math.round(se.y+he.y)}:ps(se,W));let me=null;if(oe&&V&&!Z.extent&&fe){const{positionAbsolute:re}=Z.internals,Ne=re.x-fe.x+V[0][0],Me=re.x+Z.measured.width-fe.x2+V[1][0],Te=re.y-fe.y+V[0][1],$e=re.y+Z.measured.height-fe.y2+V[1][1];me=[[Ne,Te],[Me,$e]]}const{position:ke,positionAbsolute:ve}=ug({nodeId:pe,nextPosition:se,nodeLookup:C,nodeExtent:me||V,nodeOrigin:M,onError:I});ie=ie||Z.position.x!==ke.x||Z.position.y!==ke.y,Z.position=ke,Z.internals.positionAbsolute=ve}if(k=k||ie,!!ie&&(z(h,!0),j&&(s||D||!$&&H))){const[pe,Z]=Bu({nodeId:$,dragItems:h,nodeLookup:C});s==null||s(j,h,pe,Z),D==null||D(j,pe,Z),$||H==null||H(j,Z)}}async function q(){if(!x)return;const{transform:ne,panBy:K,autoPanSpeed:C,autoPanOnNodeDrag:V}=r();if(!V){p=!1,cancelAnimationFrame(c);return}const[W,U]=kc(v,x,C);(W!==0||U!==0)&&(u.x=(u.x??0)-W/ne[2],u.y=(u.y??0)-U/ne[2],await K({x:W,y:U})&&G(u)),c=requestAnimationFrame(q)}function te(ne){var oe;const{nodeLookup:K,multiSelectionActive:C,nodesDraggable:V,transform:W,snapGrid:U,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:H,onSelectionDragStart:I,unselectNodesAndEdges:z}=r();y=!0,(!D||!A)&&!C&&$&&((oe=K.get($))!=null&&oe.selected||z()),A&&D&&$&&(t==null||t($));const ie=Qo(ne.sourceEvent,{transform:W,snapGrid:U,snapToGrid:M,containerBounds:x});if(u=ie,h=T1(K,V,ie,$),h.size>0&&(o||H||!$&&I)){const[fe,he]=Bu({nodeId:$,dragItems:h,nodeLookup:K});o==null||o(ne.sourceEvent,h,fe,he),H==null||H(ne.sourceEvent,fe,he),$||I==null||I(ne.sourceEvent,he)}}const ee=Bp().clickDistance(F).on("start",ne=>{const{domNode:K,nodeDragThreshold:C,transform:V,snapGrid:W,snapToGrid:U}=r();x=(K==null?void 0:K.getBoundingClientRect())||null,_=!1,k=!1,j=ne.sourceEvent,C===0&&te(ne),u=Qo(ne.sourceEvent,{transform:V,snapGrid:W,snapToGrid:U,containerBounds:x}),v=gn(ne.sourceEvent,x)}).on("drag",ne=>{const{autoPanOnNodeDrag:K,transform:C,snapGrid:V,snapToGrid:W,nodeDragThreshold:U,nodeLookup:M}=r(),D=Qo(ne.sourceEvent,{transform:C,snapGrid:V,snapToGrid:W,containerBounds:x});if(j=ne.sourceEvent,(ne.sourceEvent.type==="touchmove"&&ne.sourceEvent.touches.length>1||$&&!M.has($))&&(_=!0),!_){if(!p&&K&&y&&(p=!0,q()),!y){const H=gn(ne.sourceEvent,x),I=H.x-v.x,z=H.y-v.y;Math.sqrt(I*I+z*z)>U&&te(ne)}(u.x!==D.xSnapped||u.y!==D.ySnapped)&&h&&y&&(v=gn(ne.sourceEvent,x),G(D))}}).on("end",ne=>{if(!y||_){_&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,y=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:K,updateNodePositions:C,onNodeDragStop:V,onSelectionDragStop:W}=r();if(k&&(C(h,!1),k=!1),a||V||!$&&W){const[U,M]=Bu({nodeId:$,dragItems:h,nodeLookup:K,dragging:!1});a==null||a(ne.sourceEvent,h,U,M),V==null||V(ne.sourceEvent,U,M),$||W==null||W(ne.sourceEvent,M)}}}).filter(ne=>{const K=ne.target;return!ne.button&&(!R||!Lh(K,`.${R}`,N))&&(!w||Lh(K,w,N))});m.call(ee)}function E(){m==null||m.on(".drag",null)}return{update:b,destroy:E}}function $1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())Hl(a,ss(u))>0&&s.push(u);return s}const z1=250;function D1(t,r,o,s){var h,p;let a=[],u=1/0;const c=$1(t,o,r+z1);for(const v of c){const x=[...((h=v.internals.handleBounds)==null?void 0:h.source)??[],...((p=v.internals.handleBounds)==null?void 0:p.target)??[]];for(const y of x){if(s.nodeId===y.nodeId&&s.type===y.type&&s.id===y.id)continue;const{x:m,y:_}=mi(v,y,y.position,!0),k=Math.sqrt(Math.pow(m-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const v=s.type==="source"?"target":"source";return a.find(x=>x.type===v)??a[0]}return a[0]}function Eg(t,r,o,s,a,u=!1){var v,x,y;const c=s.get(t);if(!c)return null;const h=a==="strict"?(v=c.internals.handleBounds)==null?void 0:v[r]:[...((x=c.internals.handleBounds)==null?void 0:x.source)??[],...((y=c.internals.handleBounds)==null?void 0:y.target)??[]],p=(o?h==null?void 0:h.find(m=>m.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...mi(c,p,p.position,!0)}:p}function Cg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function O1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const Mg=()=>!0;function F1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:v,autoPanOnConnect:x,flowId:y,panBy:m,cancelConnection:_,onConnectStart:k,onConnect:j,onConnectEnd:b,isValidConnection:E=Mg,onReconnectEnd:R,updateConnection:w,getTransform:N,getFromHandle:A,autoPanSpeed:$,dragThreshold:F=1,handleDomNode:G}){const q=mg(t.target);let te=0,ee;const{x:ne,y:K}=gn(t),C=Cg(u,G),V=h==null?void 0:h.getBoundingClientRect();let W=!1;if(!V||!C)return;const U=Eg(a,C,s,p,r);if(!U)return;let M=gn(t,V),D=!1,H=null,I=!1,z=null;function ie(){if(!x||!V)return;const[ke,ve]=kc(M,V,$);m({x:ke,y:ve}),te=requestAnimationFrame(ie)}const oe={...U,nodeId:a,type:C,position:U.position},fe=p.get(a);let pe={inProgress:!0,isValid:null,from:mi(fe,oe,Se.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:fe,to:M,toHandle:null,toPosition:Sh[oe.position],toNode:null,pointer:M};function Z(){W=!0,w(pe),k==null||k(t,{nodeId:a,handleId:s,handleType:C})}F===0&&Z();function se(ke){if(!W){const{x:$e,y:st}=gn(ke),lt=$e-ne,at=st-K;if(!(lt*lt+at*at>F*F))return;Z()}if(!A()||!oe){me(ke);return}const ve=N();M=gn(ke,V),ee=D1(gs(M,ve,!1,[1,1]),o,p,oe),D||(ie(),D=!0);const re=Pg(ke,{handle:ee,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:E,doc:q,lib:v,flowId:y,nodeLookup:p});z=re.handleDomNode,H=re.connection,I=O1(!!ee,re.isValid);const Ne=p.get(a),Me=Ne?mi(Ne,oe,Se.Left,!0):pe.from,Te={...pe,from:Me,isValid:I,to:re.toHandle&&I?eo({x:re.toHandle.x,y:re.toHandle.y},ve):M,toHandle:re.toHandle,toPosition:I&&re.toHandle?re.toHandle.position:Sh[oe.position],toNode:re.toHandle?p.get(re.toHandle.nodeId):null,pointer:M};w(Te),pe=Te}function me(ke){if(!("touches"in ke&&ke.touches.length>0)){if(W){(ee||z)&&H&&I&&(j==null||j(H));const{inProgress:ve,...re}=pe,Ne={...re,toPosition:pe.toHandle?pe.toPosition:null};b==null||b(ke,Ne),u&&(R==null||R(ke,Ne))}_(),cancelAnimationFrame(te),D=!1,I=!1,H=null,z=null,q.removeEventListener("mousemove",se),q.removeEventListener("mouseup",me),q.removeEventListener("touchmove",se),q.removeEventListener("touchend",me)}}q.addEventListener("mousemove",se),q.addEventListener("mouseup",me),q.addEventListener("touchmove",se),q.addEventListener("touchend",me)}function Pg(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:v=Mg,nodeLookup:x}){const y=u==="target",m=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=gn(t),j=c.elementFromPoint(_,k),b=j!=null&&j.classList.contains(`${h}-flow__handle`)?j:m,E={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const R=Cg(void 0,b),w=b.getAttribute("data-nodeid"),N=b.getAttribute("data-handleid"),A=b.classList.contains("connectable"),$=b.classList.contains("connectableend");if(!w||!R)return E;const F={source:y?w:s,sourceHandle:y?N:a,target:y?s:w,targetHandle:y?a:N};E.connection=F;const q=A&&$&&(o===Zi.Strict?y&&R==="source"||!y&&R==="target":w!==s||N!==a);E.isValid=q&&v(F),E.toHandle=Eg(w,R,N,x,o,!0)}return E}const fc={onPointerDown:F1,isValid:Pg};function H1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Gt(t);function u({translateExtent:h,width:p,height:v,zoomStep:x=1,pannable:y=!0,zoomable:m=!0,inversePan:_=!1}){const k=w=>{if(w.sourceEvent.type!=="wheel"||!r)return;const N=o(),A=w.sourceEvent.ctrlKey&&ls()?10:1,$=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*x,F=N[2]*Math.pow(2,$*A);r.scaleTo(F)};let j=[0,0];const b=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(j=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},E=w=>{const N=o();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!r)return;const A=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],$=[A[0]-j[0],A[1]-j[1]];j=A;const F=s()*Math.max(N[2],Math.log(N[2]))*(_?-1:1),G={x:N[0]-$[0]*F,y:N[1]-$[1]*F},q=[[0,0],[p,v]];r.setViewportConstrained({x:G.x,y:G.y,zoom:N[2]},q,h)},R=rg().on("start",b).on("zoom",y?E:null).on("zoom.wheel",m?k:null);a.call(R,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:fn}}const Jl=t=>({x:t.x,y:t.y,zoom:t.k}),Vu=({x:t,y:r,zoom:o})=>Kl.translate(t,r).scale(o),Rr=(t,r)=>t.target.closest(`.${r}`),Ig=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),B1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Wu=(t,r=0,o=B1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Rg=t=>{const r=t.ctrlKey&&ls()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function V1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:v}){return x=>{if(Rr(x,r))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const y=o.property("__zoom").k||1;if(x.ctrlKey&&c){const b=fn(x),E=Rg(x),R=y*Math.pow(2,E);s.scaleTo(o,R,b,x);return}const m=x.deltaMode===1?20:1;let _=a===di.Vertical?0:x.deltaX*m,k=a===di.Horizontal?0:x.deltaY*m;!ls()&&x.shiftKey&&a!==di.Vertical&&(_=x.deltaY*m,k=0),s.translateBy(o,-(_/y)*u,-(k/y)*u,{internal:!0});const j=Jl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(x,j):(t.isPanScrolling=!0,h==null||h(x,j)),t.panScrollTimeout=setTimeout(()=>{v==null||v(x,j),t.isPanScrolling=!1},150)}}function W1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=Rr(s,t);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function U1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=Jl(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function Y1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;t.usedRightMouseButton=!!(o&&Ig(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,Jl(u.transform)))}}function G1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&Ig(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const p=Jl(c.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function X1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:v,lib:x,connectionInProgress:y}){return m=>{var E;const _=r||o,k=s&&m.ctrlKey,j=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(Rr(m,`${x}-flow__node`)||Rr(m,`${x}-flow__edge`)||Rr(m,`${x}-flow__selection`)||Rr(m,`${x}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!c&&!s||h||y&&!j||Rr(m,p)&&j||Rr(m,v)&&(!j||u&&j&&!r)||!s&&m.ctrlKey&&j)return!1;if(!s&&m.type==="touchstart"&&((E=m.touches)==null?void 0:E.length)>1)return m.preventDefault(),!1;if(!_&&!u&&!k&&j||!a&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(a)&&!a.includes(m.button)&&m.type==="mousedown")return!1;const b=Array.isArray(a)&&a.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||j||t)&&b}}function q1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const v={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=t.getBoundingClientRect();let y=[[0,0],[x.width,x.height]];const m=typeof ResizeObserver<"u"?new ResizeObserver(K=>{const C=K[0];C&&(y=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;m==null||m.observe(t);const _=rg().extent(()=>y).scaleExtent([r,o]).translateExtent(s),k=Gt(t).call(_);N({x:a.x,y:a.y,zoom:Ji(a.zoom,r,o)},[[0,0],[x.width,x.height]],s);const j=k.on("wheel.zoom"),b=k.on("dblclick.zoom");_.wheelDelta(Rg);async function E(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Ml).transform(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function R({noWheelClassName:K,noPanClassName:C,onPaneContextMenu:V,userSelectionActive:W,panOnScroll:U,panOnDrag:M,panOnScrollMode:D,panOnScrollSpeed:H,preventScrolling:I,zoomOnPinch:z,zoomOnScroll:ie,zoomOnDoubleClick:oe,panActivationKeyPressed:fe=!1,zoomActivationKeyPressed:he,lib:pe,onTransformChange:Z,connectionInProgress:se,paneClickDistance:me,selectionOnDrag:ke}){W&&!v.isZoomingOrPanning&&w();const ve=U&&!he&&!W;_.clickDistance(ke?1/0:!pn(me)||me<0?0:me);const re=ve?V1({zoomPanValues:v,noWheelClassName:K,d3Selection:k,d3Zoom:_,panOnScrollMode:D,panOnScrollSpeed:H,zoomOnPinch:z,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):W1({noWheelClassName:K,preventScrolling:I,d3ZoomHandler:j});k.on("wheel.zoom",re,{passive:!1});const Ne=U1({zoomPanValues:v,onDraggingChange:p,onPanZoomStart:c});_.on("start",Ne);const Me=Y1({zoomPanValues:v,panOnDrag:M,onPaneContextMenu:!!V,onPanZoom:u,onTransformChange:Z});_.on("zoom",Me);const Te=G1({zoomPanValues:v,panOnDrag:M,panOnScroll:U,onPaneContextMenu:V,onPanZoomEnd:h,onDraggingChange:p});_.on("end",Te);const $e=X1({panActivationKeyPressed:fe,zoomActivationKeyPressed:he,panOnDrag:M,zoomOnScroll:ie,panOnScroll:U,zoomOnDoubleClick:oe,zoomOnPinch:z,userSelectionActive:W,noPanClassName:C,noWheelClassName:K,lib:pe,connectionInProgress:se});_.filter($e),oe?k.on("dblclick.zoom",b):k.on("dblclick.zoom",null)}function w(){_.on("zoom",null)}async function N(K,C,V){const W=Vu(K),U=_==null?void 0:_.constrain()(W,C,V);return U&&await E(U),U}async function A(K,C){const V=Vu(K);return await E(V,C),V}function $(K){if(k){const C=Vu(K),V=k.property("__zoom");(V.k!==K.zoom||V.x!==K.x||V.y!==K.y)&&(_==null||_.transform(k,C,null,{sync:!0}))}}function F(){const K=k?ng(k.node()):{x:0,y:0,k:1};return{x:K.x,y:K.y,zoom:K.k}}async function G(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Ml).scaleTo(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}async function q(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Ml).scaleBy(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function te(K){_==null||_.scaleExtent(K)}function ee(K){_==null||_.translateExtent(K)}function ne(K){const C=!pn(K)||K<0?0:K;_==null||_.clickDistance(C)}return{update:R,destroy:w,setViewport:A,setViewportConstrained:N,getViewport:F,scaleTo:G,scaleBy:q,setScaleExtent:te,setTranslateExtent:ee,syncViewport:$,setClickDistance:ne}}var to;(function(t){t.Line="line",t.Handle="handle"})(to||(to={}));function K1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function Ah(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function Pr(t,r){return Math.max(0,r-t)}function Ir(t,r){return Math.max(0,t-r)}function kl(t,r,o){return Math.max(0,r-t,t-o)}function $h(t,r){return t?!r:r}function Q1(t,r,o,s,a,u,c,h){let{affectsX:p,affectsY:v}=r;const{isHorizontal:x,isVertical:y}=r,m=x&&y,{xSnapped:_,ySnapped:k}=o,{minWidth:j,maxWidth:b,minHeight:E,maxHeight:R}=s,{x:w,y:N,width:A,height:$,aspectRatio:F}=t;let G=Math.floor(x?_-t.pointerX:0),q=Math.floor(y?k-t.pointerY:0);const te=A+(p?-G:G),ee=$+(v?-q:q),ne=-u[0]*A,K=-u[1]*$;let C=kl(te,j,b),V=kl(ee,E,R);if(c){let M=0,D=0;p&&G<0?M=Pr(w+G+ne,c[0][0]):!p&&G>0&&(M=Ir(w+te+ne,c[1][0])),v&&q<0?D=Pr(N+q+K,c[0][1]):!v&&q>0&&(D=Ir(N+ee+K,c[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(h){let M=0,D=0;p&&G>0?M=Ir(w+G,h[0][0]):!p&&G<0&&(M=Pr(w+te,h[1][0])),v&&q>0?D=Ir(N+q,h[0][1]):!v&&q<0&&(D=Pr(N+ee,h[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(a){if(x){const M=kl(te/F,E,R)*F;if(C=Math.max(C,M),c){let D=0;!p&&!v||p&&!v&&m?D=Ir(N+K+te/F,c[1][1])*F:D=Pr(N+K+(p?G:-G)/F,c[0][1])*F,C=Math.max(C,D)}if(h){let D=0;!p&&!v||p&&!v&&m?D=Pr(N+te/F,h[1][1])*F:D=Ir(N+(p?G:-G)/F,h[0][1])*F,C=Math.max(C,D)}}if(y){const M=kl(ee*F,j,b)/F;if(V=Math.max(V,M),c){let D=0;!p&&!v||v&&!p&&m?D=Ir(w+ee*F+ne,c[1][0])/F:D=Pr(w+(v?q:-q)*F+ne,c[0][0])/F,V=Math.max(V,D)}if(h){let D=0;!p&&!v||v&&!p&&m?D=Pr(w+ee*F,h[1][0])/F:D=Ir(w+(v?q:-q)*F,h[0][0])/F,V=Math.max(V,D)}}}q=q+(q<0?V:-V),G=G+(G<0?C:-C),a&&(m?te>ee*F?q=($h(p,v)?-G:G)/F:G=($h(p,v)?-q:q)*F:x?(q=G/F,v=p):(G=q*F,p=v));const W=p?w+G:w,U=v?N+q:N;return{width:A+(p?-G:G),height:$+(v?-q:q),x:u[0]*G*(p?-1:1)+W,y:u[1]*q*(v?-1:1)+U}}const Tg={width:0,height:0,x:0,y:0},Z1={...Tg,pointerX:0,pointerY:0,aspectRatio:1};function J1(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function e_({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Gt(t);let c={controlDirection:Ah("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:v,boundaries:x,keepAspectRatio:y,resizeDirection:m,onResizeStart:_,onResize:k,onResizeEnd:j,shouldResize:b}){let E={...Tg},R={...Z1};c={boundaries:x,resizeDirection:m,keepAspectRatio:y,controlDirection:Ah(v)};let w,N=null,A=[],$,F,G,q=!1;const te=Bp().on("start",ee=>{const{nodeLookup:ne,transform:K,snapGrid:C,snapToGrid:V,nodeOrigin:W,paneDomNode:U}=o();if(w=ne.get(r),!w)return;N=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:D}=Qo(ee.sourceEvent,{transform:K,snapGrid:C,snapToGrid:V,containerBounds:N});E={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},R={...E,pointerX:M,pointerY:D,aspectRatio:E.width/E.height},$=void 0,F=gi(w.extent)?w.extent:void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&($=ne.get(w.parentId)),$&&w.extent==="parent"&&(F=[[0,0],[$.measured.width,$.measured.height]]),A=[],G=void 0;for(const[H,I]of ne)if(I.parentId===r&&(A.push({id:H,position:{...I.position},extent:I.extent}),I.extent==="parent"||I.expandParent)){const z=J1(I,w,I.origin??W);G?G=[[Math.min(z[0][0],G[0][0]),Math.min(z[0][1],G[0][1])],[Math.max(z[1][0],G[1][0]),Math.max(z[1][1],G[1][1])]]:G=z}_==null||_(ee,{...E})}).on("drag",ee=>{const{transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V}=o(),W=Qo(ee.sourceEvent,{transform:ne,snapGrid:K,snapToGrid:C,containerBounds:N}),U=[];if(!w)return;const{x:M,y:D,width:H,height:I}=E,z={},ie=w.origin??V,{width:oe,height:fe,x:he,y:pe}=Q1(R,c.controlDirection,W,c.boundaries,c.keepAspectRatio,ie,F,G),Z=oe!==H,se=fe!==I,me=he!==M&&Z,ke=pe!==D&&se;if(!me&&!ke&&!Z&&!se)return;if((me||ke||ie[0]===1||ie[1]===1)&&(z.x=me?he:E.x,z.y=ke?pe:E.y,E.x=z.x,E.y=z.y,A.length>0)){const Me=he-M,Te=pe-D;for(const $e of A)$e.position={x:$e.position.x-Me+ie[0]*(oe-H),y:$e.position.y-Te+ie[1]*(fe-I)},U.push($e)}if((Z||se)&&(z.width=Z&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:E.width,z.height=se&&(!c.resizeDirection||c.resizeDirection==="vertical")?fe:E.height,E.width=z.width,E.height=z.height),$&&w.expandParent){const Me=ie[0]*(z.width??0);z.x&&z.x{q&&(j==null||j(ee,{...E}),a==null||a({...E}),q=!1)});u.call(te)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Uu={exports:{}},Yu={},Gu={exports:{}},Xu={};/** - * @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 zh;function t_(){if(zh)return Xu;zh=1;var t=us();function r(y,m){return y===m&&(y!==0||1/y===1/m)||y!==y&&m!==m}var o=typeof Object.is=="function"?Object.is:r,s=t.useState,a=t.useEffect,u=t.useLayoutEffect,c=t.useDebugValue;function h(y,m){var _=m(),k=s({inst:{value:_,getSnapshot:m}}),j=k[0].inst,b=k[1];return u(function(){j.value=_,j.getSnapshot=m,p(j)&&b({inst:j})},[y,_,m]),a(function(){return p(j)&&b({inst:j}),y(function(){p(j)&&b({inst:j})})},[y]),c(_),_}function p(y){var m=y.getSnapshot;y=y.value;try{var _=m();return!o(y,_)}catch{return!0}}function v(y,m){return m()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?v:h;return Xu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:x,Xu}var Dh;function n_(){return Dh||(Dh=1,Gu.exports=t_()),Gu.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 Oh;function r_(){if(Oh)return Yu;Oh=1;var t=us(),r=n_();function o(v,x){return v===x&&(v!==0||1/v===1/x)||v!==v&&x!==x}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Yu.useSyncExternalStoreWithSelector=function(v,x,y,m,_){var k=u(null);if(k.current===null){var j={hasValue:!1,value:null};k.current=j}else j=k.current;k=h(function(){function E($){if(!R){if(R=!0,w=$,$=m($),_!==void 0&&j.hasValue){var F=j.value;if(_(F,$))return N=F}return N=$}if(F=N,s(w,$))return F;var G=m($);return _!==void 0&&_(F,G)?(w=$,F):(w=$,N=G)}var R=!1,w,N,A=y===void 0?null:y;return[function(){return E(x())},A===null?void 0:function(){return E(A())}]},[x,y,m,_]);var b=a(v,k[0],k[1]);return c(function(){j.hasValue=!0,j.value=b},[b]),p(b),b},Yu}var Fh;function i_(){return Fh||(Fh=1,Uu.exports=r_()),Uu.exports}var o_=i_();const s_=Np(o_),l_={},Hh=t=>{let r;const o=new Set,s=(x,y)=>{const m=typeof x=="function"?x(r):x;if(!Object.is(m,r)){const _=r;r=y??(typeof m!="object"||m===null)?m:Object.assign({},r,m),o.forEach(k=>k(r,_))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>v,subscribe:x=>(o.add(x),()=>o.delete(x)),destroy:()=>{(l_?"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."),o.clear()}},v=r=t(s,a,p);return p},a_=t=>t?Hh(t):Hh,{useDebugValue:u_}=i0,{useSyncExternalStoreWithSelector:c_}=s_,d_=t=>t;function Lg(t,r=d_,o){const s=c_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return u_(s),s}const Bh=(t,r)=>{const o=a_(t),s=(a,u=r)=>Lg(o,a,u);return Object.assign(s,o),s},f_=(t,r)=>t?Bh(t,r):Bh;function Qe(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}jp();const ea=L.createContext(null),h_=ea.Provider,Ag=mn.error001("react");function De(t,r){const o=L.useContext(ea);if(o===null)throw new Error(Ag);return Lg(o,t,r)}function Ye(){const t=L.useContext(ea);if(t===null)throw new Error(Ag);return L.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Vh={display:"none"},p_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},$g="react-flow__node-desc",zg="react-flow__edge-desc",g_="react-flow__aria-live",m_=t=>t.ariaLiveMessage,y_=t=>t.ariaLabelConfig;function v_({rfId:t}){const r=De(m_);return d.jsx("div",{id:`${g_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:p_,children:r})}function x_({rfId:t,disableKeyboardA11y:r}){const o=De(y_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${$g}-${t}`,style:Vh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${zg}-${t}`,style:Vh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(v_,{rfId:t})]})}const ta=L.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return d.jsx("div",{className:nt(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});ta.displayName="Panel";const Wh="https://reactflow.dev?utm_source=attribution";function w_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:d.jsx(ta,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Wh}`,children:d.jsx("a",{href:Wh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const __=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},Nl=t=>t.id;function S_(t,r){return Qe(t.selectedNodes.map(Nl),r.selectedNodes.map(Nl))&&Qe(t.selectedEdges.map(Nl),r.selectedEdges.map(Nl))}function k_({onSelectionChange:t}){const r=Ye(),{selectedNodes:o,selectedEdges:s}=De(__,S_);return L.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const N_=t=>!!t.onSelectionChangeHandlers;function j_({onSelectionChange:t}){const r=De(N_);return t||r?d.jsx(k_,{onSelectionChange:t}):null}const Dg=[0,0],b_={x:0,y:0,zoom:1},E_=["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"],Uh=[...E_,"rfId"],C_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Yh={translateExtent:rs,nodeOrigin:Dg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function M_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=De(C_,Qe),v=Ye();L.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{x.current=Yh,h()}),[]);const x=L.useRef(Yh);return L.useEffect(()=>{for(const y of Uh){const m=t[y],_=x.current[y];m!==_&&(typeof t[y]>"u"||(y==="nodes"?r(m):y==="edges"?o(m):y==="minZoom"?s(m):y==="maxZoom"?a(m):y==="translateExtent"?u(m):y==="nodeExtent"?c(m):y==="ariaLabelConfig"?v.setState({ariaLabelConfig:h1(m)}):y==="fitView"?v.setState({fitViewQueued:m}):y==="fitViewOptions"?v.setState({fitViewOptions:m}):v.setState({[y]:m})))}x.current=t},Uh.map(y=>t[y])),null}function Gh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function P_(t){var s;const[r,o]=L.useState(t==="system"?null:t);return L.useEffect(()=>{if(t!=="system"){o(t);return}const a=Gh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=Gh())!=null&&s.matches?"dark":"light"}const Xh=typeof document<"u"?document:null;function as(t=null,r={target:Xh,actInsideInputWithModifier:!0}){const[o,s]=L.useState(!1),a=L.useRef(!1),u=L.useRef(new Set([])),[c,h]=L.useMemo(()=>{if(t!==null){const v=(Array.isArray(t)?t:[t]).filter(y=>typeof y=="string").map(y=>y.replace(/\+/g,` -`).replace(` - -`,` -+`).split(` -`)),x=v.reduce((y,m)=>y.concat(...m),[]);return[v,x]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Xh,v=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const x=_=>{var b,E;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!v)&&yg(_))return!1;const j=Kh(_.code,h);if(u.current.add(_[j]),qh(c,u.current,!1)){const R=((E=(b=_.composedPath)==null?void 0:b.call(_))==null?void 0:E[0])||_.target,w=(R==null?void 0:R.nodeName)==="BUTTON"||(R==null?void 0:R.nodeName)==="A";r.preventDefault!==!1&&(a.current||!w)&&_.preventDefault(),s(!0)}},y=_=>{const k=Kh(_.code,h);qh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},m=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",x),p==null||p.addEventListener("keyup",y),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{p==null||p.removeEventListener("keydown",x),p==null||p.removeEventListener("keyup",y),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,s]),o}function qh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Kh(t,r){return r.includes(t)?"code":"key"}const I_=()=>{const t=Ye();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=Nc(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),v={x:r.x-h,y:r.y-p},x=o.snapGrid??a,y=o.snapToGrid??u;return gs(v,s,y,x)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=eo(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function Og(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)R_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function R_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function T_(t,r){return Og(t,r)}function L_(t,r){return Og(t,r)}function ai(t,r){return{id:t,type:"select",selected:r}}function Gi(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(ai(u.id,c)))}return s}function Qh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Zh(t){return{id:t.id,type:"remove"}}const A_=hg();function $_(t,r,o={}){return x1(t,r,{...o,onError:o.onError??A_})}const Jh=t=>i1(t),z_=t=>ag(t);function Fg(t){return L.forwardRef(t)}const Hg=typeof window<"u"?L.useLayoutEffect:L.useEffect;function ep(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>D_(()=>o(a=>a+BigInt(1))));return Hg(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function D_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Bg=L.createContext(null);function O_({children:t}){const r=Ye(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:v,hasDefaultNodes:x,onNodesChange:y,nodeLookup:m,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let j=p;for(const E of h)j=typeof E=="function"?E(j):E;let b=Qh({items:j,lookup:m});for(const E of k.values())b=E(b);x&&v(j),b.length>0?y==null||y(b):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:R,setNodes:w}=r.getState();E&&w(R)})},[]),s=ep(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:v,hasDefaultEdges:x,onEdgesChange:y,edgeLookup:m}=r.getState();let _=p;for(const k of h)_=typeof k=="function"?k(_):k;x?v(_):y&&y(Qh({items:_,lookup:m}))},[]),u=ep(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Bg.Provider,{value:c,children:t})}function F_(){const t=L.useContext(Bg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const H_=t=>!!t.panZoom;function na(){const t=I_(),r=Ye(),o=F_(),s=De(H_),a=L.useMemo(()=>{const u=y=>r.getState().nodeLookup.get(y),c=y=>{o.nodeQueue.push(y)},h=y=>{o.edgeQueue.push(y)},p=y=>{var E,R;const{nodeLookup:m,nodeOrigin:_}=r.getState(),k=Jh(y)?y:m.get(y.id),j=k.parentId?gg(k.position,k.measured,k.parentId,m,_):k.position,b={...k,position:j,width:((E=k.measured)==null?void 0:E.width)??k.width,height:((R=k.measured)==null?void 0:R.height)??k.height};return ss(b)},v=(y,m,_={replace:!1})=>{c(k=>k.map(j=>{if(j.id===y){const b=typeof m=="function"?m(j):m;return _.replace&&Jh(b)?b:{...j,...b}}return j}))},x=(y,m,_={replace:!1})=>{h(k=>k.map(j=>{if(j.id===y){const b=typeof m=="function"?m(j):m;return _.replace&&z_(b)?b:{...j,...b}}return j}))};return{getNodes:()=>r.getState().nodes.map(y=>({...y})),getNode:y=>{var m;return(m=u(y))==null?void 0:m.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:y=[]}=r.getState();return y.map(m=>({...m}))},getEdge:y=>r.getState().edgeLookup.get(y),setNodes:c,setEdges:h,addNodes:y=>{const m=Array.isArray(y)?y:[y];o.nodeQueue.push(_=>[..._,...m])},addEdges:y=>{const m=Array.isArray(y)?y:[y];o.edgeQueue.push(_=>[..._,...m])},toObject:()=>{const{nodes:y=[],edges:m=[],transform:_}=r.getState(),[k,j,b]=_;return{nodes:y.map(E=>({...E})),edges:m.map(E=>({...E})),viewport:{x:k,y:j,zoom:b}}},deleteElements:async({nodes:y=[],edges:m=[]})=>{const{nodes:_,edges:k,onNodesDelete:j,onEdgesDelete:b,triggerNodeChanges:E,triggerEdgeChanges:R,onDelete:w,onBeforeDelete:N}=r.getState(),{nodes:A,edges:$}=await u1({nodesToRemove:y,edgesToRemove:m,nodes:_,edges:k,onBeforeDelete:N}),F=$.length>0,G=A.length>0;if(F){const q=$.map(Zh);b==null||b($),R(q)}if(G){const q=A.map(Zh);j==null||j(A),E(q)}return(G||F)&&(w==null||w({nodes:A,edges:$})),{deletedNodes:A,deletedEdges:$}},getIntersectingNodes:(y,m=!0,_)=>{const k=Nh(y),j=k?y:p(y),b=_!==void 0;return j?(_||r.getState().nodes).filter(E=>{const R=r.getState().nodeLookup.get(E.id);if(R&&!k&&(E.id===y.id||!R.internals.positionAbsolute))return!1;const w=ss(b?E:R),N=Hl(w,j);return m&&N>0||N>=w.width*w.height||N>=j.width*j.height}):[]},isNodeIntersecting:(y,m,_=!0)=>{const j=Nh(y)?y:p(y);if(!j)return!1;const b=Hl(j,m);return _&&b>0||b>=m.width*m.height||b>=j.width*j.height},updateNode:v,updateNodeData:(y,m,_={replace:!1})=>{v(y,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},updateEdge:x,updateEdgeData:(y,m,_={replace:!1})=>{x(y,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},getNodesBounds:y=>{const{nodeLookup:m,nodeOrigin:_}=r.getState();return o1(y,{nodeLookup:m,nodeOrigin:_})},getHandleConnections:({type:y,id:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${y}${m?`-${m}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:y,handleId:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${y?m?`-${y}-${m}`:`-${y}`:""}`))==null?void 0:k.values())??[])},fitView:async y=>{const m=r.getState().fitViewResolver??f1();return r.setState({fitViewQueued:!0,fitViewOptions:y,fitViewResolver:m}),o.nodeQueue.push(_=>[..._]),m.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const tp=t=>t.selected,B_=typeof window<"u"?window:void 0;function V_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ye(),{deleteElements:s}=na(),a=as(t,{actInsideInputWithModifier:!1}),u=as(r,{target:B_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(tp),edges:c.filter(tp)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function W_(t){const r=Ye();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=jc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",mn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const ra={position:"absolute",width:"100%",height:"100%",top:0,left:0},U_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function Y_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=di.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:v,translateExtent:x,minZoom:y,maxZoom:m,zoomActivationKeyCode:_,preventScrolling:k=!0,children:j,noWheelClassName:b,noPanClassName:E,onViewportChange:R,isControlledViewport:w,paneClickDistance:N,selectionOnDrag:A}){const $=Ye(),F=L.useRef(null),{userSelectionActive:G,lib:q,connectionInProgress:te}=De(U_,Qe),ee=as(_),ne=L.useRef();W_(F);const K=L.useCallback(C=>{R==null||R({x:C[0],y:C[1],zoom:C[2]}),w||$.setState({transform:C})},[R,w]);return L.useEffect(()=>{if(F.current){ne.current=q1({domNode:F.current,minZoom:y,maxZoom:m,translateExtent:x,viewport:v,onDraggingChange:U=>$.setState(M=>M.paneDragging===U?M:{paneDragging:U}),onPanZoomStart:(U,M)=>{const{onViewportChangeStart:D,onMoveStart:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoom:(U,M)=>{const{onViewportChange:D,onMove:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoomEnd:(U,M)=>{const{onViewportChangeEnd:D,onMoveEnd:H}=$.getState();H==null||H(U,M),D==null||D(M)}});const{x:C,y:V,zoom:W}=ne.current.getViewport();return $.setState({panZoom:ne.current,transform:[C,V,W],domNode:F.current.closest(".react-flow")}),()=>{var U;(U=ne.current)==null||U.destroy()}}},[]),L.useEffect(()=>{var C;(C=ne.current)==null||C.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:ee,preventScrolling:k,noPanClassName:E,userSelectionActive:G,noWheelClassName:b,lib:q,onTransformChange:K,connectionInProgress:te,selectionOnDrag:A,paneClickDistance:N})},[t,r,o,s,a,u,c,h,p,ee,k,E,G,b,q,K,te,A,N]),d.jsx("div",{className:"react-flow__renderer",ref:F,style:ra,children:j})}const G_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function X_(){const{userSelectionActive:t,userSelectionRect:r}=De(G_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const qu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},q_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function K_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=is.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:v,onPaneContextMenu:x,onPaneScroll:y,onPaneMouseEnter:m,onPaneMouseMove:_,onPaneMouseLeave:k,children:j}){const b=L.useRef(0),E=Ye(),{userSelectionActive:R,elementsSelectable:w,dragging:N,panBy:A,autoPanSpeed:$}=De(q_,Qe),F=w&&(t||R),G=L.useRef(null),q=L.useRef(),te=L.useRef(new Set),ee=L.useRef(new Set),ne=L.useRef(!1),K=L.useRef(!1),C=L.useRef({x:0,y:0}),V=L.useRef(!1),W=Z=>{if(K.current||ne.current||E.getState().connection.inProgress){K.current=!1,ne.current=!1;return}v==null||v(Z),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},U=Z=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Z.preventDefault();return}x==null||x(Z)},M=y?Z=>y(Z):void 0,D=Z=>{K.current&&(Z.stopPropagation(),K.current=!1)},H=Z=>{var $e,st;if(Z.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:se,transform:me}=E.getState();if(q.current=se==null?void 0:se.getBoundingClientRect(),!q.current)return;const ke=Z.target===G.current;if(!ke&&!!Z.target.closest(".nokey")||!t||!(c&&ke||r)||Z.button!==0||!Z.isPrimary)return;(st=($e=Z.target)==null?void 0:$e.setPointerCapture)==null||st.call($e,Z.pointerId),K.current=!1;const{x:Ne,y:Me}=gn(Z.nativeEvent,q.current),Te=gs({x:Ne,y:Me},me);E.setState({userSelectionRect:{width:0,height:0,startX:Te.x,startY:Te.y,x:Ne,y:Me}}),ke||(Z.stopPropagation(),Z.preventDefault())};function I(Z,se){const{userSelectionRect:me}=E.getState();if(!me)return;const{transform:ke,nodeLookup:ve,edgeLookup:re,connectionLookup:Ne,triggerNodeChanges:Me,triggerEdgeChanges:Te,defaultEdgeOptions:$e}=E.getState(),st={x:me.startX,y:me.startY},{x:lt,y:at}=eo(st,ke),Ge={startX:st.x,startY:st.y,x:Zmt.id)),ee.current=new Set;const gt=($e==null?void 0:$e.selectable)??!0;for(const mt of te.current){const Pt=Ne.get(mt);if(Pt)for(const{edgeId:ut}of Pt.values()){const Je=re.get(ut);Je&&(Je.selectable??gt)&&ee.current.add(ut)}}if(!jh(wt,te.current)){const mt=Gi(ve,te.current,!0);Me(mt)}if(!jh(qt,ee.current)){const mt=Gi(re,ee.current);Te(mt)}E.setState({userSelectionRect:Ge,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!a||!q.current)return;const[Z,se]=kc(C.current,q.current,$);A({x:Z,y:se}).then(me=>{if(!K.current||!me){b.current=requestAnimationFrame(z);return}const{x:ke,y:ve}=C.current;I(ke,ve),b.current=requestAnimationFrame(z)})}const ie=()=>{cancelAnimationFrame(b.current),b.current=0,V.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=Z=>{const{userSelectionRect:se,transform:me,resetSelectedElements:ke}=E.getState();if(!q.current||!se)return;const{x:ve,y:re}=gn(Z.nativeEvent,q.current);C.current={x:ve,y:re};const Ne=eo({x:se.startX,y:se.startY},me);if(!K.current){const Me=r?0:u;if(Math.hypot(ve-Ne.x,re-Ne.y)<=Me)return;ke(),h==null||h(Z)}K.current=!0,V.current||(z(),V.current=!0),I(ve,re)},fe=Z=>{var se,me;if(!F){Z.target===G.current&&E.getState().connection.inProgress&&(ne.current=!0);return}Z.button===0&&((me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),!R&&Z.target===G.current&&E.getState().userSelectionRect&&(W==null||W(Z)),E.setState({userSelectionActive:!1,userSelectionRect:null}),K.current&&(p==null||p(Z),E.setState({nodesSelectionActive:te.current.size>0})),ie())},he=Z=>{var se,me;(me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),ie()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:nt(["react-flow__pane",{draggable:pe,dragging:N,selection:t}]),onClick:F?void 0:qu(W,G),onContextMenu:qu(U,G),onWheel:qu(M,G),onPointerEnter:F?void 0:m,onPointerMove:F?oe:_,onPointerUp:fe,onPointerCancel:F?he:void 0,onPointerDownCapture:F?H:void 0,onClickCapture:F?D:void 0,onPointerLeave:k,ref:G,style:ra,children:[j,d.jsx(X_,{})]})}function hc({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),v=h.get(t);if(!v){p==null||p("012",mn.error012(t));return}r.setState({nodesSelectionActive:!1}),v.selected?(o||v.selected&&c)&&(u({nodes:[v],edges:[]}),requestAnimationFrame(()=>{var x;return(x=s==null?void 0:s.current)==null?void 0:x.blur()})):a([t])}function Vg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ye(),[p,v]=L.useState(!1),x=L.useRef();return L.useEffect(()=>{if(!r)return x.current=A1({getStoreItems:()=>h.getState(),onNodeMouseDown:y=>{hc({id:y,store:h,nodeRef:t})},onDragStart:()=>{v(!0)},onDragStop:()=>{v(!1)}}),()=>{var y;(y=x.current)==null||y.destroy(),x.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!x.current||x.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const Q_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Wg(){const t=Ye();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:v,nodeOrigin:x}=t.getState(),y=new Map,m=Q_(c),_=a?u[0]:5,k=a?u[1]:5,j=o.direction.x*_*o.factor,b=o.direction.y*k*o.factor;for(const[,E]of v){if(!m(E))continue;let R={x:E.internals.positionAbsolute.x+j,y:E.internals.positionAbsolute.y+b};a&&(R=ps(R,u));const{position:w,positionAbsolute:N}=ug({nodeId:E.id,nextPosition:R,nodeLookup:v,nodeExtent:s,nodeOrigin:x,onError:h});E.position=w,E.internals.positionAbsolute=N,y.set(E.id,E)}p(y)},[])}const Ic=L.createContext(null),Z_=Ic.Provider;Ic.Consumer;const Ug=()=>L.useContext(Ic),J_=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Yg=L.createContext(null);function eS({children:t}){const r=De(J_,Qe);return d.jsx(Yg.Provider,{value:r,children:t})}function tS(){const t=L.useContext(Yg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const nS={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},rS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:v}=c;if(!h&&!a)return nS;const x=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:x,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Zi.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:x&&v}};function iS({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:v,onMouseDown:x,onTouchStart:y,...m},_){var V,W;const k=c||null,j=t==="target",b=Ye(),E=Ug(),{connectOnClick:R,noPanClassName:w,rfId:N}=tS(),{connectingFrom:A,connectingTo:$,clickConnecting:F,isPossibleEndHandle:G,connectionInProcess:q,clickConnectionInProcess:te,valid:ee}=De(rS(E,k,t),Qe);E||(W=(V=b.getState()).onError)==null||W.call(V,"010",mn.error010());const ne=U=>{const{defaultEdgeOptions:M,onConnect:D,hasDefaultEdges:H}=b.getState(),I={...M,...U};if(H){const{edges:z,setEdges:ie,onError:oe}=b.getState();ie($_(I,z,{onError:oe}))}D==null||D(I),h==null||h(I)},K=U=>{if(!E)return;const M=vg(U.nativeEvent);if(a&&(M&&U.button===0||!M)){const D=b.getState();fc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:j,handleId:k,nodeId:E,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...H)=>{var I,z;return(z=(I=b.getState()).onConnectEnd)==null?void 0:z.call(I,...H)},updateConnection:D.updateConnection,onConnect:ne,isValidConnection:o||((...H)=>{var I,z;return((z=(I=b.getState()).isValidConnection)==null?void 0:z.call(I,...H))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}M?x==null||x(U):y==null||y(U)},C=U=>{const{onClickConnectStart:M,onClickConnectEnd:D,connectionClickStartHandle:H,connectionMode:I,isValidConnection:z,lib:ie,rfId:oe,nodeLookup:fe,connection:he}=b.getState();if(!E||!H&&!a)return;if(!H){M==null||M(U.nativeEvent,{nodeId:E,handleId:k,handleType:t}),b.setState({connectionClickStartHandle:{nodeId:E,type:t,id:k}});return}const pe=mg(U.target),Z=o||z,{connection:se,isValid:me}=fc.isValid(U.nativeEvent,{handle:{nodeId:E,id:k,type:t},connectionMode:I,fromNodeId:H.nodeId,fromHandleId:H.id||null,fromType:H.type,isValidConnection:Z,flowId:oe,doc:pe,lib:ie,nodeLookup:fe});me&&se&&ne(se);const ke=structuredClone(he);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,D==null||D(U,ke),b.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":k,"data-nodeid":E,"data-handlepos":r,"data-id":`${N}-${E}-${k}-${t}`,className:nt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",w,v,{source:!j,target:j,connectable:s,connectablestart:a,connectableend:u,clickconnecting:F,connectingfrom:A,connectingto:$,valid:ee,connectionindicator:s&&(!q||G)&&(q||te?u:a)}]),onMouseDown:K,onTouchStart:K,onClick:R?C:void 0,ref:_,...m,children:p})}const no=L.memo(Fg(iS));function oS({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(no,{type:"source",position:o,isConnectable:r})]})}function sS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:s=Se.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(no,{type:"source",position:s,isConnectable:r})]})}function lS(){return null}function aS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const Vl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},np={input:oS,default:sS,output:aS,group:lS};function uS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const cS=t=>{const{width:r,height:o,x:s,y:a}=hs(t.nodeLookup,{filter:u=>!!u.selected});return{width:pn(r)?r:null,height:pn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function dS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ye(),{width:a,height:u,transformString:c,userSelectionActive:h}=De(cS,Qe),p=Wg(),v=L.useRef(null);L.useEffect(()=>{var _;o||(_=v.current)==null||_.focus({preventScroll:!0})},[o]);const x=!h&&a!==null&&u!==null;if(Vg({nodeRef:v,disabled:!x}),!x)return null;const y=t?_=>{const k=s.getState().nodes.filter(j=>j.selected);t(_,k)}:void 0,m=_=>{Object.prototype.hasOwnProperty.call(Vl,_.key)&&(_.preventDefault(),p({direction:Vl[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:nt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:v,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:o?void 0:-1,onKeyDown:o?void 0:m,style:{width:a,height:u}})})}const rp=typeof window<"u"?window:void 0,fS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Gg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:v,selectionOnDrag:x,selectionMode:y,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:j,zoomActivationKeyCode:b,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:N,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:G,autoPanOnSelection:q,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,preventScrolling:C,onSelectionContextMenu:V,noWheelClassName:W,noPanClassName:U,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:H}){const{nodesSelectionActive:I,userSelectionActive:z}=De(fS,Qe),ie=as(v,{target:rp}),oe=as(j,{target:rp}),fe=oe||G,he=oe||N,pe=x&&fe!==!0,Z=ie||z||pe;return V_({deleteKeyCode:p,multiSelectionKeyCode:k}),d.jsx(Y_,{onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:!ie&&fe,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,zoomActivationKeyCode:b,preventScrolling:C,noWheelClassName:W,noPanClassName:U,onViewportChange:D,isControlledViewport:H,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(K_,{onSelectionStart:m,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:q,isSelecting:!!Z,selectionMode:y,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:pe,children:[t,I&&d.jsx(dS,{onSelectionContextMenu:V,noPanClassName:U,disableKeyboardA11y:M})]})})}Gg.displayName="FlowRenderer";const hS=L.memo(Gg),pS=t=>r=>t?Sc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function gS(t){return De(L.useCallback(pS(t),[t]),Qe)}const mS=t=>t.updateNodeInternals;function yS(){const t=De(mS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function vS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ye(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),v=L.useRef(r),x=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!x||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[x,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const y=v.current!==r,m=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(y||m||_)&&(v.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function xS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:v,nodesFocusable:x,resizeObserver:y,noDragClassName:m,noPanClassName:_,disableKeyboardA11y:k,rfId:j,nodeTypes:b,nodeClickDistance:E,onError:R}){const{node:w,internals:N,isParent:A}=De(Z=>{const se=Z.nodeLookup.get(t),me=Z.parentLookup.has(t);return{node:se,internals:se.internals,isParent:me}},Qe);let $=w.type||"default",F=(b==null?void 0:b[$])||np[$];F===void 0&&(R==null||R("003",mn.error003($)),$="default",F=(b==null?void 0:b.default)||np.default);const G=!!(w.draggable||h&&typeof w.draggable>"u"),q=!!(w.selectable||p&&typeof w.selectable>"u"),te=!!(w.connectable||v&&typeof w.connectable>"u"),ee=!!(w.focusable||x&&typeof w.focusable>"u"),ne=Ye(),K=pg(w),C=vS({node:w,nodeType:$,hasDimensions:K,resizeObserver:y}),V=Vg({nodeRef:C,disabled:w.hidden||!G,noDragClassName:m,handleSelector:w.dragHandle,nodeId:t,isSelectable:q,nodeClickDistance:E}),W=Wg();if(w.hidden)return null;const U=vn(w),M=uS(w),D=q||G||r||o||s||a,H=o?Z=>o(Z,{...N.userNode}):void 0,I=s?Z=>s(Z,{...N.userNode}):void 0,z=a?Z=>a(Z,{...N.userNode}):void 0,ie=u?Z=>u(Z,{...N.userNode}):void 0,oe=c?Z=>c(Z,{...N.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:se,nodeDragThreshold:me}=ne.getState();q&&(!se||!G||me>0)&&hc({id:t,store:ne,nodeRef:C}),r&&r(Z,{...N.userNode})},he=Z=>{if(!(yg(Z.nativeEvent)||k)){if(ig.includes(Z.key)&&q){const se=Z.key==="Escape";hc({id:t,store:ne,unselect:se,nodeRef:C})}else if(G&&w.selected&&Object.prototype.hasOwnProperty.call(Vl,Z.key)){Z.preventDefault();const{ariaLabelConfig:se}=ne.getState();ne.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),W({direction:Vl[Z.key],factor:Z.shiftKey?4:1})}}},pe=()=>{var Ne;if(k||!((Ne=C.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:Z,width:se,height:me,autoPanOnNodeFocus:ke,setCenter:ve}=ne.getState();if(!ke)return;Sc(new Map([[t,w]]),{x:0,y:0,width:se,height:me},Z,!0).length>0||ve(w.position.x+U.width/2,w.position.y+U.height/2,{zoom:Z[2]})};return d.jsx("div",{className:nt(["react-flow__node",`react-flow__node-${$}`,{[_]:G},w.className,{selected:w.selected,selectable:q,parent:A,draggable:G,dragging:V}]),ref:C,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:K?"visible":"hidden",...w.style,...M},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:H,onMouseMove:I,onMouseLeave:z,onContextMenu:ie,onClick:fe,onDoubleClick:oe,onKeyDown:ee?he:void 0,tabIndex:ee?0:void 0,onFocus:ee?pe:void 0,role:w.ariaRole??(ee?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${$g}-${j}`,"aria-label":w.ariaLabel,...w.domAttributes,children:d.jsx(Z_,{value:t,children:d.jsx(F,{id:t,data:w.data,type:$,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:w.selected??!1,selectable:q,draggable:G,deletable:w.deletable??!0,isConnectable:te,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:V,dragHandle:w.dragHandle,zIndex:N.z,parentId:w.parentId,...U})})})}var wS=L.memo(xS);const _S=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Xg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=De(_S,Qe),u=gS(t.onlyRenderVisibleElements),c=yS();return d.jsx("div",{className:"react-flow__nodes",style:ra,children:u.map(h=>d.jsx(wS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Xg.displayName="NodeRenderer";const SS=L.memo(Xg);function kS(t){return De(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&m1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const NS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},jS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ip={[os.Arrow]:NS,[os.ArrowClosed]:jS};function bS(t){const r=Ye();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(ip,t)?ip[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",mn.error009(t)),null)},[t])}const ES=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=bS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},qg=({defaultColor:t,rfId:r})=>{const o=De(u=>u.edges),s=De(u=>u.defaultEdgeOptions),a=L.useMemo(()=>N1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(ES,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};qg.displayName="MarkerDefinitions";var CS=L.memo(qg);function Kg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:v,...x}){const[y,m]=L.useState({x:1,y:0,width:0,height:0}),_=nt(["react-flow__edge-textwrapper",v]),k=L.useRef(null);return L.useEffect(()=>{if(k.current){const j=k.current.getBBox();m({x:j.x,y:j.y,width:j.width,height:j.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-y.width/2} ${r-y.height/2})`,className:_,visibility:y.width?"visible":"hidden",...x,children:[a&&d.jsx("rect",{width:y.width+2*c[0],x:-c[0],y:-c[1],height:y.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:k,style:s,children:o}),p]}):null}Kg.displayName="EdgeText";const MS=L.memo(Kg);function ms({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:v=20,...x}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...x,d:t,fill:"none",className:nt(["react-flow__edge-path",x.className])}),v?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:v,className:"react-flow__edge-interaction"}):null,s&&pn(r)&&pn(o)?d.jsx(MS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function op({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function Qg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top}){const[c,h]=op({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,v]=op({pos:u,x1:s,y1:a,x2:t,y2:r}),[x,y,m,_]=xg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:v});return[`M${t},${r} C${c},${h} ${p},${v} ${s},${a}`,x,y,m,_]}function Zg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})=>{const[R,w,N]=Qg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),A=t.isInternal?void 0:r;return d.jsx(ms,{id:A,path:R,labelX:w,labelY:N,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})})}const PS=Zg({isInternal:!1}),Jg=Zg({isInternal:!0});PS.displayName="SimpleBezierEdge";Jg.displayName="SimpleBezierEdgeInternal";function em(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,sourcePosition:_=Se.Bottom,targetPosition:k=Se.Top,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=Bl({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),$=t.isInternal?void 0:r;return d.jsx(ms,{id:$,path:w,labelX:N,labelY:A,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:j,markerStart:b,interactionWidth:R})})}const tm=em({isInternal:!1}),nm=em({isInternal:!0});tm.displayName="SmoothStepEdge";nm.displayName="SmoothStepEdgeInternal";function rm(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(tm,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const IS=rm({isInternal:!1}),im=rm({isInternal:!0});IS.displayName="StepEdge";im.displayName="StepEdgeInternal";function om(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:j})=>{const[b,E,R]=Sg({sourceX:o,sourceY:s,targetX:a,targetY:u}),w=t.isInternal?void 0:r;return d.jsx(ms,{id:w,path:b,labelX:E,labelY:R,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:v,labelBgPadding:x,labelBgBorderRadius:y,style:m,markerEnd:_,markerStart:k,interactionWidth:j})})}const RS=om({isInternal:!1}),sm=om({isInternal:!0});RS.displayName="StraightEdge";sm.displayName="StraightEdgeInternal";function lm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=wg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:E==null?void 0:E.curvature}),$=t.isInternal?void 0:r;return d.jsx(ms,{id:$,path:w,labelX:N,labelY:A,label:p,labelStyle:v,labelShowBg:x,labelBgStyle:y,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:R})})}const TS=lm({isInternal:!1}),am=lm({isInternal:!0});TS.displayName="BezierEdge";am.displayName="BezierEdgeInternal";const sp={default:am,straight:sm,step:im,smoothstep:nm,simplebezier:Jg},lp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},LS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,AS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,ap="react-flow__edgeupdater";function up({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:nt([ap,`${ap}-${h}`]),cx:LS(r,s,t),cy:AS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function $S({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:v,onReconnectStart:x,onReconnectEnd:y,setReconnecting:m,setUpdateHover:_}){const k=Ye(),j=(N,A)=>{if(N.button!==0)return;const{autoPanOnConnect:$,domNode:F,connectionMode:G,connectionRadius:q,lib:te,onConnectStart:ee,cancelConnection:ne,nodeLookup:K,rfId:C,panBy:V,updateConnection:W}=k.getState(),U=A.type==="target",M=(I,z)=>{m(!1),y==null||y(I,o,A.type,z)},D=I=>v==null?void 0:v(o,I),H=(I,z)=>{m(!0),x==null||x(N,o,A.type),ee==null||ee(I,z)};fc.onPointerDown(N.nativeEvent,{autoPanOnConnect:$,connectionMode:G,connectionRadius:q,domNode:F,handleId:A.id,nodeId:A.nodeId,nodeLookup:K,isTarget:U,edgeUpdaterType:A.type,lib:te,flowId:C,cancelConnection:ne,panBy:V,isValidConnection:(...I)=>{var z,ie;return((ie=(z=k.getState()).isValidConnection)==null?void 0:ie.call(z,...I))??!0},onConnect:D,onConnectStart:H,onConnectEnd:(...I)=>{var z,ie;return(ie=(z=k.getState()).onConnectEnd)==null?void 0:ie.call(z,...I)},onReconnectEnd:M,updateConnection:W,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:N.currentTarget})},b=N=>j(N,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),E=N=>j(N,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),R=()=>_(!0),w=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(up,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:b,onMouseEnter:R,onMouseOut:w,type:"source"}),(t===!0||t==="target")&&d.jsx(up,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:E,onMouseEnter:R,onMouseOut:w,type:"target"})]})}function zS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,rfId:k,edgeTypes:j,noPanClassName:b,onError:E,disableKeyboardA11y:R}){let w=De(ve=>ve.edgeLookup.get(t));const N=De(ve=>ve.defaultEdgeOptions);w=N?{...N,...w}:w;let A=w.type||"default",$=(j==null?void 0:j[A])||sp[A];$===void 0&&(E==null||E("011",mn.error011(A)),A="default",$=(j==null?void 0:j.default)||sp.default);const F=!!(w.focusable||r&&typeof w.focusable>"u"),G=typeof y<"u"&&(w.reconnectable||o&&typeof w.reconnectable>"u"),q=!!(w.selectable||s&&typeof w.selectable>"u"),te=L.useRef(null),[ee,ne]=L.useState(!1),[K,C]=L.useState(!1),V=Ye(),{zIndex:W=w.zIndex,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z}=De(L.useCallback(ve=>{const re=ve.nodeLookup.get(w.source),Ne=ve.nodeLookup.get(w.target);if(!re||!Ne)return lp;const Me=k1({id:t,sourceNode:re,targetNode:Ne,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:ve.connectionMode,onError:E}),Te=g1({selected:w.selected,zIndex:w.zIndex,sourceNode:re,targetNode:Ne,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||lp,zIndex:Te}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex,E]),Qe),ie=L.useMemo(()=>w.markerStart?`url('#${cc(w.markerStart,k)}')`:void 0,[w.markerStart,k]),oe=L.useMemo(()=>w.markerEnd?`url('#${cc(w.markerEnd,k)}')`:void 0,[w.markerEnd,k]);if(w.hidden||U===null||M===null||D===null||H===null)return null;const fe=ve=>{var Te;const{addSelectedEdges:re,unselectNodesAndEdges:Ne,multiSelectionActive:Me}=V.getState();q&&(V.setState({nodesSelectionActive:!1}),w.selected&&Me?(Ne({nodes:[],edges:[w]}),(Te=te.current)==null||Te.blur()):re([t])),a&&a(ve,w)},he=u?ve=>{u(ve,{...w})}:void 0,pe=c?ve=>{c(ve,{...w})}:void 0,Z=h?ve=>{h(ve,{...w})}:void 0,se=p?ve=>{p(ve,{...w})}:void 0,me=v?ve=>{v(ve,{...w})}:void 0,ke=ve=>{var re;if(!R&&ig.includes(ve.key)&&q){const{unselectNodesAndEdges:Ne,addSelectedEdges:Me}=V.getState();ve.key==="Escape"?((re=te.current)==null||re.blur(),Ne({edges:[w]})):Me([t])}};return d.jsx("svg",{style:{zIndex:W},children:d.jsxs("g",{className:nt(["react-flow__edge",`react-flow__edge-${A}`,w.className,b,{selected:w.selected,animated:w.animated,inactive:!q&&!a,updating:ee,selectable:q}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:Z,onMouseMove:se,onMouseLeave:me,onKeyDown:F?ke:void 0,tabIndex:F?0:void 0,role:w.ariaRole??(F?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":F?`${zg}-${k}`:void 0,ref:te,...w.domAttributes,children:[!K&&d.jsx($,{id:t,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:q,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),G&&d.jsx($S,{edge:w,isReconnectable:G,reconnectRadius:x,onReconnect:y,onReconnectStart:m,onReconnectEnd:_,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,setUpdateHover:ne,setReconnecting:C})]})})}var DS=L.memo(zS);const OS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function um({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:v,onEdgeClick:x,reconnectRadius:y,onEdgeDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:j}){const{edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,onError:w}=De(OS,Qe),N=kS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(CS,{defaultColor:t,rfId:o}),N.map(A=>d.jsx(DS,{id:A,edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:v,onClick:x,reconnectRadius:y,onDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:w,edgeTypes:s,disableKeyboardA11y:j},A))]})}um.displayName="EdgeRenderer";const FS=L.memo(um),cp=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function HS({children:t}){const r=Ye(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return Hg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=cp(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:cp(s)},children:t})}function BS(t){const r=na(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const VS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function WS(t){const r=De(VS),o=Ye();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function US(t){return t.connection.inProgress?{...t.connection,to:gs(t.connection.to,t.transform)}:{...t.connection}}function YS(t){return US}function GS(t){const r=YS();return De(r,Qe)}const XS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function qS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=De(XS,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:nt(["react-flow__connection",lg(h)]),children:d.jsx(cm,{style:r,type:o,CustomComponent:s,isValid:h})})})}const cm=({style:t,type:r=Lr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:v,toNode:x,toHandle:y,toPosition:m,pointer:_}=GS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:v.x,toY:v.y,fromPosition:p,toPosition:m,connectionStatus:lg(s),toNode:x,toHandle:y,pointer:_});let k="";const j={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:v.x,targetY:v.y,targetPosition:m};switch(r){case Lr.Bezier:[k]=wg(j);break;case Lr.SimpleBezier:[k]=Qg(j);break;case Lr.Step:[k]=Bl({...j,borderRadius:0});break;case Lr.SmoothStep:[k]=Bl(j);break;default:[k]=Sg(j)}return d.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};cm.displayName="ConnectionLine";const KS={};function dp(t=KS){L.useRef(t),Ye(),L.useEffect(()=>{},[t])}function QS(){Ye(),L.useRef(!1),L.useEffect(()=>{},[])}function dm({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,onSelectionContextMenu:y,onSelectionStart:m,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:j,connectionLineComponent:b,connectionLineContainerStyle:E,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,deleteKeyCode:G,onlyRenderVisibleElements:q,elementsSelectable:te,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,preventScrolling:V,defaultMarkerColor:W,zoomOnScroll:U,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,zoomOnDoubleClick:z,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneScroll:se,onPaneContextMenu:me,paneClickDistance:ke,nodeClickDistance:ve,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,viewport:ut,onViewportChange:Je,nodesDraggable:An}){return dp(t),dp(r),QS(),BS(o),WS(ut),d.jsx(hS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneContextMenu:me,onPaneScroll:se,paneClickDistance:ke,deleteKeyCode:G,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,elementsSelectable:te,zoomOnScroll:U,zoomOnPinch:M,zoomOnDoubleClick:z,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,onSelectionContextMenu:y,preventScrolling:V,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,onViewportChange:Je,isControlledViewport:!!ut,children:d.jsxs(HS,{children:[d.jsx(FS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,onlyRenderVisibleElements:q,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,defaultMarkerColor:W,noPanClassName:qt,disableKeyboardA11y:gt,rfId:Pt}),d.jsx(qS,{style:j,type:k,component:b,containerStyle:E}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(SS,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:v,onNodeContextMenu:x,nodeClickDistance:ve,onlyRenderVisibleElements:q,noPanClassName:qt,noDragClassName:Ge,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,nodesDraggable:An}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}dm.displayName="GraphView";const ZS=L.memo(dm),JS=hg(),fp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:v=2,nodeOrigin:x,nodeExtent:y,zIndexMode:m="basic"}={})=>{const _=new Map,k=new Map,j=new Map,b=new Map,E=s??r??[],R=o??t??[],w=x??[0,0],N=y??rs;jg(j,b,E);const{nodesInitialized:A}=dc(R,_,k,{nodeOrigin:w,nodeExtent:N,zIndexMode:m});let $=[0,0,1];if(c&&a&&u){const F=hs(_,{filter:ee=>!!((ee.width||ee.initialWidth)&&(ee.height||ee.initialHeight))}),{x:G,y:q,zoom:te}=Nc(F,a,u,p,v,(h==null?void 0:h.padding)??.1);$=[G,q,te]}return{rfId:"1",width:a??0,height:u??0,transform:$,nodes:R,nodesInitialized:A,nodeLookup:_,parentLookup:k,edges:E,edgeLookup:b,connectionLookup:j,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:v,translateExtent:rs,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Zi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...sg},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:JS,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:og,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},ek=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m})=>f_((_,k)=>{async function j(){const{nodeLookup:b,panZoom:E,fitViewOptions:R,fitViewResolver:w,width:N,height:A,minZoom:$,maxZoom:F}=k();E&&(await a1({nodes:b,width:N,height:A,panZoom:E,minZoom:$,maxZoom:F},R),w==null||w.resolve(!0),_({fitViewResolver:null}))}return{...fp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:v,nodeOrigin:x,nodeExtent:y,defaultNodes:o,defaultEdges:s,zIndexMode:m}),setNodes:b=>{const{nodeLookup:E,parentLookup:R,nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,fitViewQueued:$,zIndexMode:F,nodesSelectionActive:G}=k(),{nodesInitialized:q,hasSelectedNodes:te}=dc(b,E,R,{nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:F}),ee=G&&te;$&&q?(j(),_({nodes:b,nodesInitialized:q,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:ee})):_({nodes:b,nodesInitialized:q,nodesSelectionActive:ee})},setEdges:b=>{const{connectionLookup:E,edgeLookup:R}=k();jg(E,R,b),_({edges:b})},setDefaultNodesAndEdges:(b,E)=>{if(b){const{setNodes:R}=k();R(b),_({hasDefaultNodes:!0})}if(E){const{setEdges:R}=k();R(E),_({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:E,nodeLookup:R,parentLookup:w,domNode:N,nodeOrigin:A,nodeExtent:$,debug:F,fitViewQueued:G,zIndexMode:q}=k(),{changes:te,updatedInternals:ee}=I1(b,R,w,N,A,$,q);ee&&(E1(R,w,{nodeOrigin:A,nodeExtent:$,zIndexMode:q}),G?(j(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(te==null?void 0:te.length)>0&&(F&&console.log("React Flow: trigger node changes",te),E==null||E(te)))},updateNodePositions:(b,E=!1)=>{const R=[];let w=[];const{nodeLookup:N,triggerNodeChanges:A,connection:$,updateConnection:F,onNodesChangeMiddlewareMap:G}=k();for(const[q,te]of b){const ee=N.get(q),ne=!!(ee!=null&&ee.expandParent&&(ee!=null&&ee.parentId)&&(te!=null&&te.position)),K={id:q,type:"position",position:ne?{x:Math.max(0,te.position.x),y:Math.max(0,te.position.y)}:te.position,dragging:E};if(ee&&$.inProgress&&$.fromNode.id===ee.id){const C=mi(ee,$.fromHandle,Se.Left,!0);F({...$,from:C})}ne&&ee.parentId&&R.push({id:q,parentId:ee.parentId,rect:{...te.internals.positionAbsolute,width:te.measured.width??0,height:te.measured.height??0}}),w.push(K)}if(R.length>0){const{parentLookup:q,nodeOrigin:te}=k(),ee=Pc(R,N,q,te);w.push(...ee)}for(const q of G.values())w=q(w);A(w)},triggerNodeChanges:b=>{const{onNodesChange:E,setNodes:R,nodes:w,hasDefaultNodes:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=T_(b,w);R($)}A&&console.log("React Flow: trigger node changes",b),E==null||E(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:E,setEdges:R,edges:w,hasDefaultEdges:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=L_(b,w);R($)}A&&console.log("React Flow: trigger edge changes",b),E==null||E(b)}},addSelectedNodes:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));N($);return}N(Gi(w,new Set([...b]),!0)),A(Gi(R))},addSelectedEdges:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));A($);return}A(Gi(R,new Set([...b]))),N(Gi(w,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:E}={})=>{const{edges:R,nodes:w,nodeLookup:N,triggerNodeChanges:A,triggerEdgeChanges:$}=k(),F=b||w,G=E||R,q=[];for(const ee of F){if(!ee.selected)continue;const ne=N.get(ee.id);ne&&(ne.selected=!1),q.push(ai(ee.id,!1))}const te=[];for(const ee of G)ee.selected&&te.push(ai(ee.id,!1));A(q),$(te)},setMinZoom:b=>{const{panZoom:E,maxZoom:R}=k();E==null||E.setScaleExtent([b,R]),_({minZoom:b})},setMaxZoom:b=>{const{panZoom:E,minZoom:R}=k();E==null||E.setScaleExtent([R,b]),_({maxZoom:b})},setTranslateExtent:b=>{var E;(E=k().panZoom)==null||E.setTranslateExtent(b),_({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:E,triggerNodeChanges:R,triggerEdgeChanges:w,elementsSelectable:N}=k();if(!N)return;const A=E.reduce((F,G)=>G.selected?[...F,ai(G.id,!1)]:F,[]),$=b.reduce((F,G)=>G.selected?[...F,ai(G.id,!1)]:F,[]);R(A),w($)},setNodeExtent:b=>{const{nodes:E,nodeLookup:R,parentLookup:w,nodeOrigin:N,elevateNodesOnSelect:A,nodeExtent:$,zIndexMode:F}=k();b[0][0]===$[0][0]&&b[0][1]===$[0][1]&&b[1][0]===$[1][0]&&b[1][1]===$[1][1]||(dc(E,R,w,{nodeOrigin:N,nodeExtent:b,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:F}),_({nodeExtent:b}))},panBy:b=>{const{transform:E,width:R,height:w,panZoom:N,translateExtent:A}=k();return R1({delta:b,panZoom:N,transform:E,translateExtent:A,width:R,height:w})},setCenter:async(b,E,R)=>{const{width:w,height:N,maxZoom:A,panZoom:$}=k();if(!$)return!1;const F=typeof(R==null?void 0:R.zoom)<"u"?R.zoom:A;return await $.setViewport({x:w/2-b*F,y:N/2-E*F,zoom:F},{duration:R==null?void 0:R.duration,ease:R==null?void 0:R.ease,interpolate:R==null?void 0:R.interpolate}),!0},cancelConnection:()=>{_({connection:{...sg}})},updateConnection:b=>{_({connection:b})},reset:()=>_({...fp()})}},Object.is);function fm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:v,nodeOrigin:x,nodeExtent:y,zIndexMode:m,children:_}){const[k]=L.useState(()=>ek({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:v,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:x,nodeExtent:y,zIndexMode:m}));return d.jsx(h_,{value:k,children:d.jsx(O_,{children:d.jsx(eS,{children:_})})})}function tk({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:v,maxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_}){return L.useContext(ea)?d.jsx(d.Fragment,{children:t}):d.jsx(fm,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:v,initialMaxZoom:x,nodeOrigin:y,nodeExtent:m,zIndexMode:_,children:t})}const nk={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function rk({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:v,onMove:x,onMoveStart:y,onMoveEnd:m,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,onNodeDragStart:F,onNodeDrag:G,onNodeDragStop:q,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onSelectionChange:K,onSelectionDragStart:C,onSelectionDrag:V,onSelectionDragStop:W,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:H,connectionMode:I,connectionLineType:z=Lr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:Z=!1,selectionMode:se=is.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:ke=ls()?"Meta":"Control",zoomActivationKeyCode:ve=ls()?"Meta":"Control",snapToGrid:re,snapGrid:Ne,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Te,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,nodeOrigin:Ge=Dg,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt=!0,defaultViewport:mt=b_,minZoom:Pt=.5,maxZoom:ut=2,translateExtent:Je=rs,preventScrolling:An=!0,nodeExtent:Ot,defaultMarkerColor:xn="#b1b1b7",zoomOnScroll:oo=!0,zoomOnPinch:$n=!0,panOnScroll:vi=!1,panOnScrollSpeed:or=.5,panOnScrollMode:$r=di.Free,zoomOnDoubleClick:zn=!0,panOnDrag:zr=!0,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn=1,nodeClickDistance:Fn=0,children:_n,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn=10,onNodesChange:Ht,onEdgesChange:Or,noDragClassName:nn="nodrag",noWheelClassName:Fr="nowheel",noPanClassName:yt="nopan",fitView:Hn,fitViewOptions:ur,connectOnClick:so,attributionPosition:It,proOptions:Bn,defaultEdgeOptions:Hr,elevateNodesOnSelect:jn=!0,elevateEdgesOnSelect:Br=!1,disableKeyboardA11y:xi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:lo,autoPanOnSelection:Vr=!0,autoPanSpeed:wi,connectionRadius:cr,isValidConnection:ao,onError:dr,style:Vn,id:bt,nodeDragThreshold:Wr,connectionDragThreshold:Et,viewport:uo,onViewportChange:Ur,width:Yr,height:Wn,colorMode:Un="light",debug:bn,onScroll:Bt,ariaLabelConfig:_i,zIndexMode:Gr="basic",...fr},hr){const Yn=bt||"1",En=P_(Un),co=L.useCallback(pr=>{pr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Bt==null||Bt(pr)},[Bt]);return d.jsx("div",{"data-testid":"rf__wrapper",...fr,onScroll:co,style:{...Vn,...nk},ref:hr,className:nt(["react-flow",a,En]),id:bt,role:"application",children:d.jsxs(tk,{nodes:t,edges:r,width:Yr,height:Wn,fitView:Hn,fitViewOptions:ur,minZoom:Pt,maxZoom:ut,nodeOrigin:Ge,nodeExtent:Ot,zIndexMode:Gr,children:[d.jsx(M_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt,elevateNodesOnSelect:jn,elevateEdgesOnSelect:Br,minZoom:Pt,maxZoom:ut,nodeExtent:Ot,onNodesChange:Ht,onEdgesChange:Or,snapToGrid:re,snapGrid:Ne,connectionMode:I,translateExtent:Je,connectOnClick:so,defaultEdgeOptions:Hr,fitView:Hn,fitViewOptions:ur,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onNodeDragStart:F,onNodeDrag:G,onNodeDragStop:q,onSelectionDrag:V,onSelectionDragStart:C,onSelectionDragStop:W,onMove:x,onMoveStart:y,onMoveEnd:m,noPanClassName:yt,nodeOrigin:Ge,rfId:Yn,autoPanOnConnect:Ve,autoPanOnNodeDrag:lo,autoPanSpeed:wi,onError:dr,connectionRadius:cr,isValidConnection:ao,selectNodesOnDrag:Te,nodeDragThreshold:Wr,connectionDragThreshold:Et,onBeforeDelete:H,debug:bn,ariaLabelConfig:_i,zIndexMode:Gr}),d.jsx(ZS,{onInit:v,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,nodeTypes:u,edgeTypes:c,connectionLineType:z,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:Z,selectionMode:se,deleteKeyCode:he,multiSelectionKeyCode:ke,panActivationKeyCode:me,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:mt,translateExtent:Je,minZoom:Pt,maxZoom:ut,preventScrolling:An,zoomOnScroll:oo,zoomOnPinch:$n,zoomOnDoubleClick:zn,panOnScroll:vi,panOnScrollSpeed:or,panOnScrollMode:$r,panOnDrag:zr,autoPanOnSelection:Vr,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn,nodeClickDistance:Fn,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn,defaultMarkerColor:xn,noDragClassName:nn,noWheelClassName:Fr,noPanClassName:yt,rfId:Yn,disableKeyboardA11y:xi,nodeExtent:Ot,viewport:uo,onViewportChange:Ur,nodesDraggable:$e}),d.jsx(j_,{onSelectionChange:K}),_n,d.jsx(w_,{proOptions:Bn,position:It}),d.jsx(x_,{rfId:Yn,disableKeyboardA11y:xi})]})})}var ik=Fg(rk);function ok({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:nt(["react-flow__background-pattern",o,s])})}function sk({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:nt(["react-flow__background-pattern","dots",r])})}var Ar;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Ar||(Ar={}));const lk={[Ar.Dots]:1,[Ar.Lines]:1,[Ar.Cross]:6},ak=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function hm({id:t,variant:r=Ar.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:v,patternClassName:x}){const y=L.useRef(null),{transform:m,patternId:_}=De(ak,Qe),k=s||lk[r],j=r===Ar.Dots,b=r===Ar.Cross,E=Array.isArray(o)?o:[o,o],R=[E[0]*m[2]||1,E[1]*m[2]||1],w=k*m[2],N=Array.isArray(u)?u:[u,u],A=b?[w,w]:R,$=[N[0]*m[2]+A[0]/2,N[1]*m[2]+A[1]/2],F=`${_}${t||""}`;return d.jsxs("svg",{className:nt(["react-flow__background",v]),style:{...p,...ra,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:y,"data-testid":"rf__background",children:[d.jsx("pattern",{id:F,x:m[0]%R[0],y:m[1]%R[1],width:R[0],height:R[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:j?d.jsx(sk,{radius:w/2,className:x}):d.jsx(ok,{dimensions:A,lineWidth:a,variant:r,className:x})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${F})`})]})}hm.displayName="Background";const uk=L.memo(hm);function ck(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function fk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 hk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 pk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 jl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:nt(["react-flow__controls-button",r]),...o,children:t})}const gk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function pm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:v,children:x,position:y="bottom-left",orientation:m="vertical","aria-label":_}){const k=Ye(),{isInteractive:j,minZoomReached:b,maxZoomReached:E,ariaLabelConfig:R}=De(gk,Qe),{zoomIn:w,zoomOut:N,fitView:A}=na(),$=()=>{w(),u==null||u()},F=()=>{N(),c==null||c()},G=()=>{A(a),h==null||h()},q=()=>{k.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),p==null||p(!j)},te=m==="horizontal"?"horizontal":"vertical";return d.jsxs(ta,{className:nt(["react-flow__controls",te,v]),position:y,style:t,"data-testid":"rf__controls","aria-label":_??R["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(jl,{onClick:$,className:"react-flow__controls-zoomin",title:R["controls.zoomIn.ariaLabel"],"aria-label":R["controls.zoomIn.ariaLabel"],disabled:E,children:d.jsx(ck,{})}),d.jsx(jl,{onClick:F,className:"react-flow__controls-zoomout",title:R["controls.zoomOut.ariaLabel"],"aria-label":R["controls.zoomOut.ariaLabel"],disabled:b,children:d.jsx(dk,{})})]}),o&&d.jsx(jl,{className:"react-flow__controls-fitview",onClick:G,title:R["controls.fitView.ariaLabel"],"aria-label":R["controls.fitView.ariaLabel"],children:d.jsx(fk,{})}),s&&d.jsx(jl,{className:"react-flow__controls-interactive",onClick:q,title:R["controls.interactive.ariaLabel"],"aria-label":R["controls.interactive.ariaLabel"],children:j?d.jsx(pk,{}):d.jsx(hk,{})}),x]})}pm.displayName="Controls";const mk=L.memo(pm);function yk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:v,borderRadius:x,shapeRendering:y,selected:m,onClick:_}){const{background:k,backgroundColor:j}=u||{},b=c||k||j;return d.jsx("rect",{className:nt(["react-flow__minimap-node",{selected:m},v]),x:r,y:o,rx:x,ry:x,width:s,height:a,style:{fill:b,stroke:h,strokeWidth:p},shapeRendering:y,onClick:_?E=>_(E,t):void 0})}const vk=L.memo(yk),xk=t=>t.nodes.map(r=>r.id),Ku=t=>t instanceof Function?t:()=>t;function wk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=vk,onClick:c}){const h=De(xk,Qe),p=Ku(r),v=Ku(t),x=Ku(o),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(m=>d.jsx(Sk,{id:m,nodeColorFunc:p,nodeStrokeColorFunc:v,nodeClassNameFunc:x,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:y},m))})}function _k({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:v,x,y,width:m,height:_}=De(k=>{const j=k.nodeLookup.get(t);if(!j)return{node:void 0,x:0,y:0,width:0,height:0};const b=j.internals.userNode,{x:E,y:R}=j.internals.positionAbsolute,{width:w,height:N}=vn(b);return{node:b,x:E,y:R,width:w,height:N}},Qe);return!v||v.hidden||!pg(v)?null:d.jsx(h,{x,y,width:m,height:_,style:v.style,selected:!!v.selected,className:s(v),color:r(v),borderRadius:a,strokeColor:o(v),strokeWidth:u,shapeRendering:c,onClick:p,id:v.id})}const Sk=L.memo(_k);var kk=L.memo(wk);const Nk=200,jk=150,bk=t=>!t.hidden,Ek=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?dg(hs(t.nodeLookup,{filter:bk}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},hp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,Ck=(t,r)=>hp(t.viewBB,r.viewBB)&&hp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,Mk="react-flow__minimap-desc";function gm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:v,maskStrokeColor:x,maskStrokeWidth:y,position:m="bottom-right",onClick:_,onNodeClick:k,pannable:j=!1,zoomable:b=!1,ariaLabel:E,inversePan:R,zoomStep:w=1,offsetScale:N=5}){const A=Ye(),$=L.useRef(null),{boundingRect:F,viewBB:G,rfId:q,panZoom:te,translateExtent:ee,flowWidth:ne,flowHeight:K,ariaLabelConfig:C}=De(Ek,Ck),V=(t==null?void 0:t.width)??Nk,W=(t==null?void 0:t.height)??jk,U=F.width/V,M=F.height/W,D=Math.max(U,M),H=D*V,I=D*W,z=N*D,ie=F.x-(H-F.width)/2-z,oe=F.y-(I-F.height)/2-z,fe=H+z*2,he=I+z*2,pe=`${Mk}-${q}`,Z=L.useRef(0),se=L.useRef();Z.current=D,L.useEffect(()=>{if($.current&&te)return se.current=H1({domNode:$.current,panZoom:te,getTransform:()=>A.getState().transform,getViewScale:()=>Z.current}),()=>{var re;(re=se.current)==null||re.destroy()}},[te]),L.useEffect(()=>{var re;(re=se.current)==null||re.update({translateExtent:ee,width:ne,height:K,inversePan:R,pannable:j,zoomStep:w,zoomable:b})},[j,b,R,w,ee,ne,K]);const me=_?re=>{var Te;const[Ne,Me]=((Te=se.current)==null?void 0:Te.pointer(re))||[0,0];_(re,{x:Ne,y:Me})}:void 0,ke=k?L.useCallback((re,Ne)=>{const Me=A.getState().nodeLookup.get(Ne).internals.userNode;k(re,Me)},[]):void 0,ve=E??C["minimap.ariaLabel"];return d.jsx(ta,{position:m,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof v=="string"?v:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof y=="number"?y*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:nt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:V,height:W,viewBox:`${ie} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:$,onClick:me,children:[ve&&d.jsx("title",{id:pe,children:ve}),d.jsx(kk,{onClick:ke,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-z},${oe-z}h${fe+z*2}v${he+z*2}h${-fe-z*2}z - M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}gm.displayName="MiniMap";const Pk=L.memo(gm),Ik=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Rk={[to.Line]:"right",[to.Handle]:"bottom-right"};function Tk({nodeId:t,position:r,variant:o=to.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:v=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:y=!1,resizeDirection:m,autoScale:_=!0,shouldResize:k,onResizeStart:j,onResize:b,onResizeEnd:E}){const R=Ug(),w=typeof t=="string"?t:R,N=Ye(),A=L.useRef(null),$=o===to.Handle,F=De(L.useCallback(Ik($&&_),[$,_]),Qe),G=L.useRef(null),q=r??Rk[o];L.useEffect(()=>{if(!(!A.current||!w))return G.current||(G.current=e_({domNode:A.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,domNode:W}=N.getState();return{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,paneDomNode:W}},onChange:(ee,ne)=>{const{triggerNodeChanges:K,nodeLookup:C,parentLookup:V,nodeOrigin:W}=N.getState(),U=[],M={x:ee.x,y:ee.y},D=C.get(w);if(D&&D.expandParent&&D.parentId){const H=D.origin??W,I=ee.width??D.measured.width??0,z=ee.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:I,height:z,...gg({x:ee.x??D.position.x,y:ee.y??D.position.y},{width:I,height:z},D.parentId,C,H)}},oe=Pc([ie],C,V,W);U.push(...oe),M.x=ee.x?Math.max(H[0]*I,ee.x):void 0,M.y=ee.y?Math.max(H[1]*z,ee.y):void 0}if(M.x!==void 0&&M.y!==void 0){const H={id:w,type:"position",position:{...M}};U.push(H)}if(ee.width!==void 0&&ee.height!==void 0){const I={id:w,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:ee.width,height:ee.height}};U.push(I)}for(const H of ne){const I={...H,type:"position"};U.push(I)}K(U)},onEnd:({width:ee,height:ne})=>{const K={id:w,type:"dimensions",resizing:!1,dimensions:{width:ee,height:ne}};N.getState().triggerNodeChanges([K])}})),G.current.update({controlPosition:q,boundaries:{minWidth:h,minHeight:p,maxWidth:v,maxHeight:x},keepAspectRatio:y,resizeDirection:m,onResizeStart:j,onResize:b,onResizeEnd:E,shouldResize:k}),()=>{var ee;(ee=G.current)==null||ee.destroy()}},[q,h,p,v,x,y,j,b,E,k]);const te=q.split("-");return d.jsx("div",{className:nt(["react-flow__resize-control","nodrag",...te,o,s]),ref:A,style:{...a,scale:F,...c&&{[$?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Tk);const Lk={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function ia(t){return Lk[t]??8}const Wl=208,ro=64,Ak=88,$k=28,zk=8;function Dk(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function mm(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const w of t){const N=ia(w.type),A=s.get(N)??[];A.push(w),s.set(N,A)}const u=[...s.keys()].sort((w,N)=>w-N).map(w=>[...s.get(w)??[]].sort((N,A)=>N.name.localeCompare(A.name)||N.id.localeCompare(A.id))),c=new Set(t.map(w=>w.id)),h=new Map,p=new Map;for(const w of t)h.set(w.id,[]),p.set(w.id,[]);for(const w of r)!c.has(w.src)||!c.has(w.dst)||w.src===w.dst||(p.get(w.src).push(w.dst),h.get(w.dst).push(w.src));const v=new Map;u.forEach((w,N)=>{for(const A of w)v.set(A.id,N)});const x=new Map,y=()=>{for(const w of u)w.forEach((N,A)=>x.set(N.id,A))};y();const m=(w,N)=>{const A=w.map(($,F)=>{const G=N($.id).map(te=>x.get(te)).filter(te=>te!==void 0),q=Dk(G);return{n:$,bary:Number.isNaN(q)?F:q,name:$.name,id:$.id}});return A.sort(($,F)=>$.bary-F.bary||$.name.localeCompare(F.name)||$.id.localeCompare(F.id)),A.map($=>$.n)},_=w=>N=>v.get(N)===w;for(let w=0;w(h.get(A)??[]).filter(_(N-1))),y();for(let N=u.length-2;N>=0;N--)u[N]=m(u[N],A=>(p.get(A)??[]).filter(_(N+1))),y()}const k=Wl+Ak,j=ro+$k,b=Math.max(...u.map(w=>w.length),1),E=[];let R=0;for(let w=0;wG.id)),A=new Set((u[w+1]??[]).map(G=>G.id));let $=0;if(A.size)for(const G of r)N.has(G.src)&&A.has(G.dst)&&($+=1);const F=Math.min(48,Math.max(0,($-2)*10));R+=k+F}return u.forEach((w,N)=>{const A=(b-w.length)*j/2;w.forEach(($,F)=>{o.set($.id,{x:E[N]??0,y:A+F*j})})}),o}const Ok=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),ym=90,Fk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),pp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Hk=Math.PI*(3-Math.sqrt(5)),vm=220,Bk=26,Vk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function xm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function BN(t){return pp[t]?pp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Wk(t){return t>=ym?"3d":"2d"}function Uk(t){return t>=ym?"overview":"full"}function Yk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(xm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Fk.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Yk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Xk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function qk(t,r,o,s){const a=new Set(t.map(j=>j.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const j of r){if(!a.has(j.src)||!a.has(j.dst))continue;const b=u.get(j.src)??[];b.push({dst:j.dst,id:j.id}),u.set(j.src,b);const E=c.get(j.dst)??[];E.push({src:j.src,id:j.id}),c.set(j.dst,E)}const h=new Set(t.filter(j=>Ok.has(j.type)).map(j=>j.id)),p=h.size?h:a,v=new Set,x=[o];for(;x.length;){const j=x.pop();if(!v.has(j)){v.add(j);for(const b of u.get(j)??[])v.has(b.dst)||x.push(b.dst)}}const y=new Set([o]),m=[...p].filter(j=>v.has(j)),_=new Set(m);for(;m.length;){const j=m.pop();y.add(j);for(const b of c.get(j)??[])v.has(b.src)&&!_.has(b.src)&&(_.add(b.src),m.push(b.src))}const k=new Set;for(const j of r)y.has(j.src)&&y.has(j.dst)&&k.add(j.id);return{nodeIds:y,edgeIds:k}}function VN(t){const r=new Map;for(const s of t){const a=ia(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*vm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Bk*Math.sqrt(h+1),v=h*Hk;o.set(c.id,{x:u,y:p*Math.cos(v),z:p*Math.sin(v)})})}return o}function WN(t){const r=new Map;for(const o of t){const s=ia(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*vm,count:s}))}const bl=16,Kk=12,Qk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Zk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),gp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Jk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},mp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],yp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),eN=new Set(["looks_idempotent_on_pk","null","blank"]),tN=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function nN(t){return gp[t]?gp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function rN(t,r,o){const s=new Map(r.map(m=>[m.id,m])),a=[];Qk.has(t.type)&&a.push("sink"),Zk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(m=>m.dst===t.id),h=o.filter(m=>m.src===t.id),p=c.slice(0,bl).map(m=>El(m,s,m.src)),v=h.slice(0,bl).map(m=>El(m,s,m.dst)),x=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,y={type:t.type,typeLabel:Zo(io(t.type)),layer:Vk[ia(t.type)]??"other",purpose:nN(t.type),name:t.name,qualifiedName:t.qualified_name,file:x,context:t.context,roles:a,facts:oN(u).filter(m=>!(m.key==="app"&&m.value===t.context)),inputs:p,outputs:v,extraInputs:Math.max(0,c.length-bl),extraOutputs:Math.max(0,h.length-bl),degreeIn:c.length,degreeOut:h.length,inputKinds:vp(c.map(m=>El(m,s,m.src))),outputKinds:vp(h.map(m=>El(m,s,m.dst))),pathSummary:""};return y.pathSummary=iN(y),y}function vp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function iN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function El(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Zo(io(s.type)):"",edgeType:t.type,edgeLabel:Zo(t.type),inferred:t.confidence<.8}}function oN(t){const r=[...mp.filter(a=>a in t),...Object.keys(t).filter(a=>!mp.includes(a)&&!yp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||yp.has(a)||tN.has(a))continue;s.add(a);const u=sN(a,t[a]);u!=null&&o.push({key:a,label:Jk[a]??Zo(a),value:u})}return o}function sN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!eN.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return lN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Kk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function lN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const xp=12,wp=.2,aN=.8,uN=ro;function cN(t,r,o){const s=o??mm(t,r),a=[];for(const h of r){const p=s.get(h.src),v=s.get(h.dst);if(!p||!v)continue;const x=p.y+ro/2,y=v.y+ro/2;if(Math.abs(x-y)m.y0-_.y0||m.y1-_.y1||m.id.localeCompare(_.id)),v=dN(p),x=Math.max(0,...v.values())+1,y=Math.min(...p.map(m=>m.targetX-m.sourceX));for(const m of p){const _=v.get(m.id)??0,k=fN(_,x),j=m.targetX-m.sourceX;if(Math.abs(j-y)<.5){c.set(m.id,k);continue}const b=m.sourceX+y*k;c.set(m.id,Math.min(.92,Math.max(.08,(b-m.sourceX)/j)))}}return c}function dN(t){const r=[],o=new Map;for(const s of t){let a=-1;for(let u=0;ur[u]+uN){a=u;break}a<0?(a=r.length,r.push(s.y1)):r[a]=Math.max(r[a],s.y1),o.set(s.id,a)}return o}function fN(t,r){return r<=1?.5:wp+(aN-wp)*t/(r-1)}const hN=new Set,pN=L.lazy(()=>N0(()=>import("./LayeredGraph3D-BFszTRNF.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),gN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function mN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(no,{type:"target",position:Se.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:io(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Tr(t.name)}),d.jsx(no,{type:"source",position:Se.Right,isConnectable:!1})]})}const yN={load:mN},vN=new Set(["django","react","stitch","arch"]);function xN({id:t,sourceX:r,sourceY:o,targetX:s,targetY:a,sourcePosition:u,targetPosition:c,style:h,markerEnd:p,markerStart:v,label:x,labelStyle:y,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,data:b,interactionWidth:E}){const[R,w,N]=Bl({sourceX:r,sourceY:o,sourcePosition:u,targetX:s,targetY:a,targetPosition:c,borderRadius:8,stepPosition:(b==null?void 0:b.stepPosition)??.5});return d.jsx(ms,{id:t,path:R,labelX:w,labelY:N,label:x,labelStyle:y,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,style:h,markerEnd:p,markerStart:v,interactionWidth:E})}const wN={loadstep:xN};function _N({topologyKey:t}){const{fitView:r}=na();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function SN(t,r,o=null,s={}){const a=new Map(t.map(v=>[v.id,v])),u=mm(t,r),c=cN(t,r,u),h=t.map(v=>{var m;const x=((m=s.roles)==null?void 0:m[v.id])||[],y=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:v.id,type:"load",position:u.get(v.id)??{x:0,y:0},data:{name:v.name,type:v.type,file:v.file_path,roles:x,dim:y},selected:o===v.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:Wl,height:ro,style:{width:Wl,height:ro}}}),p=r.filter(v=>a.has(v.src)&&a.has(v.dst)).map(v=>{const x=gN[v.weight]||"var(--edge-cheap)",y=!!(o&&(v.src===o||v.dst===o));return{id:v.id,source:v.src,target:v.dst,type:"loadstep",animated:v.weight==="critical",data:{stepPosition:c.get(v.id)??.5},style:{stroke:x,strokeWidth:v.weight==="critical"?2.4:1.2,strokeDasharray:v.confidence<.8?"6 4":void 0},markerEnd:{type:os.ArrowClosed,width:14,height:14,color:x},label:y?v.type.replaceAll("_"," "):void 0,labelStyle:y?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:y?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:y?[3,5]:void 0,labelBgBorderRadius:y?4:void 0}});return{rfNodes:h,rfEdges:p}}function kN({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:v}){const x=rN(t,r,o);return L.useEffect(()=>{const y=m=>{m.key==="Escape"&&s()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:x.typeLabel}),d.jsx("div",{className:"inspector-roles",children:x.roles.map(y=>d.jsx("span",{className:"inspector-chip",children:y},y))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Tr(x.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:x.purpose}),x.context?d.jsx("div",{className:"muted",children:Tr(x.context)}):null,x.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Tr(x.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Tr(x.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",x.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[x.degreeIn," in · ",x.degreeOut," out"]}),x.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:x.pathSummary}):null,x.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:x.facts.map(y=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:y.label}),d.jsx("dd",{children:Tr(y.value)})]},y.key))}):null,d.jsx(_p,{title:"Inputs",testId:"graph-inspector-inputs",links:x.inputs,extra:x.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(_p,{title:"Outputs",testId:"graph-inspector-outputs",links:x.outputs,extra:x.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),a?d.jsx("p",{className:"whatif-hint","data-testid":"whatif-hint",children:v?"Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map.":"Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."}):null,d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",title:"Start a hypothetical walk from this node. Does not use Base/Head.",onClick:()=>a(t.id),children:"What if this changes"}):null,v?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",title:"Hide nodes that are not on a path from here to a sink. Does not start a new walk.",onClick:()=>v(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function _p({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Qu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:v,repoPath:x,onOpenFile:y,pinnedId:m,onPin:_}){const[k,j]=L.useState(null),b=a!==void 0?a:k,E=re=>{a===void 0&&j(re),u==null||u(re)},[R,w]=L.useState(null),[N,A]=L.useState(null),[$,F]=L.useState(new Set(vN)),[G,q]=L.useState(!1),[te,ee]=L.useState(""),[ne,K]=L.useState(!1),C=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,V=R??Wk(t.length),W=N??Uk(t.length),U=G?b:null,M=L.useMemo(()=>p?qk(t,r,p):null,[t,r,p]),D=M?t.filter(re=>M.nodeIds.has(re.id)):t,H=M?r.filter(re=>M.edgeIds.has(re.id)):r,I=L.useMemo(()=>Gk(D,H,{detail:W,families:$,focusId:U,neighborhoodOnly:!!U}),[D,H,W,$,U]),z=L.useMemo(()=>`${I.nodes.map(re=>re.id).join("\0")}|${I.edges.map(re=>re.id).join("\0")}`,[I.nodes,I.edges]),ie=b?t.find(re=>re.id===b)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const re=SN(I.nodes,I.edges,b,{roles:c,testOverlay:h});return C&&(re.rfEdges=re.rfEdges.map(Ne=>({...Ne,animated:!1}))),re},[I.nodes,I.edges,b,C,c,h]);L.useEffect(()=>{if(!s)return;const re=t.find(Ne=>Ne.file_path===s);re&&E(re.id)},[s,t]);const he=L.useMemo(()=>Xk(t,te),[t,te]),pe=(re,Ne)=>{E(Ne.id)},Z=()=>{E(null),q(!1)},se=ie?d.jsx(kN,{node:ie,nodes:t,edges:r,onClose:Z,onWhatIf:o,onSelect:E,onOpenFile:y,pinned:m===ie.id,onPin:_,onIsolate:v?re=>{v(p===re?null:re)}:void 0}):null,me=re=>{F(Ne=>{const Me=new Set(Ne);if(Me.has(re)){if(Me.size===1)return Ne;Me.delete(re)}else Me.add(re);return Me})},ke=L.useMemo(()=>{const re=new Set;for(const Ne of t)re.add(xm(Ne.type));return re},[t]),ve=t.length-I.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:V==="2d"?"active":"","aria-pressed":V==="2d",onClick:()=>w("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:V==="3d"?"active":"","aria-pressed":V==="3d",onClick:()=>w("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:W==="overview"?"active":"","aria-pressed":W==="overview",onClick:()=>A("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:W==="full"?"active":"","aria-pressed":W==="full",onClick:()=>A("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(re=>ke.has(re)).map(re=>d.jsx("button",{type:"button","data-testid":`graph-family-${re}`,className:$.has(re)?"active":"","aria-pressed":$.has(re),onClick:()=>me(re),children:re},re))}),d.jsx("button",{type:"button",className:G?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!b,onClick:()=>q(re=>!re),children:G?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>v==null?void 0:v(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:te,onChange:re=>{ee(re.target.value),K(!0)},onFocus:()=>K(!0),onBlur:()=>window.setTimeout(()=>K(!1),150)}),ne&&te.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(re=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:Ne=>Ne.preventDefault(),onClick:()=>{E(re.id),ee(""),K(!1)},children:[re.name,d.jsx("span",{className:"muted",children:io(re.type)})]})},re.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[I.nodes.length," nodes · ",I.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:V==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(pN,{nodes:I.nodes,edges:I.edges,selectedId:b,neighborIds:U?I.neighborIds:hN,onSelect:re=>{E(re),re||q(!1)}})}),se]}):d.jsxs(fm,{children:[d.jsxs(ik,{nodes:oe,edges:fe,nodeTypes:yN,edgeTypes:wN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:Z,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(_N,{topologyKey:z}),d.jsx(uk,{}),d.jsx(Pk,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(mk,{})]}),se]})})]})}function wm(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function NN(t){localStorage.setItem("loadpath.editor",t)}async function jN(t,r,o,s=wm()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const Sp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],bN=["preset","branch","tag","commit"];function EN(t){var a;if(!(t!=null&&t.git))return[...Sp];const r=((a=t.presets)!=null&&a.length?t.presets:Sp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function CN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function MN(t){return bN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function PN(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function kp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[v,x]=L.useState(!1),[y,m]=L.useState(null),[_,k]=L.useState(0),j=L.useMemo(()=>{const N=EN(u);return y===null?N:CN(N,y)},[u,y]),b=L.useMemo(()=>MN(j),[j]);L.useEffect(()=>{v&&c()},[v,c]),L.useEffect(()=>{k(0)},[y,v]);const E=()=>{x(!1),m(null)},R=N=>{r(N.value),E()},w=N=>{if(N.key==="ArrowDown"){if(N.preventDefault(),!v){x(!0);return}k(A=>Math.min(A+1,Math.max(j.length-1,0)))}else if(N.key==="ArrowUp"){if(N.preventDefault(),!v)return;k(A=>Math.max(A-1,0))}else if(N.key==="Enter"&&v){N.preventDefault();const A=j[_];A&&R(A)}else N.key==="Escape"&&v&&(N.preventDefault(),E())};return d.jsxs("div",{className:"combo",ref:p,onBlur:N=>{N.currentTarget.contains(N.relatedTarget)||E()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":v,"aria-controls":h,"aria-autocomplete":"list",onChange:N=>{r(N.target.value),v&&m(N.target.value)},onKeyDown:w}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":v,onMouseDown:N=>N.preventDefault(),onClick:()=>v?E():x(!0),children:d.jsx(_0,{})})]}),v?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:b.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):b.map(N=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:PN(N.group)}),N.items.map(A=>{const $=j.indexOf(A);return d.jsxs("button",{type:"button",role:"option","aria-selected":$===_,className:$===_?"combo-option active":"combo-option","data-testid":`ref-option-${A.group}`,onMouseDown:F=>F.preventDefault(),onMouseEnter:()=>k($),onClick:()=>R(A),children:[d.jsx("span",{className:"combo-label",children:A.label}),A.detail?d.jsx("span",{className:"combo-detail",children:A.detail}):null]},`${A.group}:${A.value}`)})]},N.group))}):null]})}function IN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[v,x]=L.useState(""),[y,m]=L.useState(!1),_=L.useRef(null),k=L.useRef(0),j=async w=>{const N=k.current+1;k.current=N,m(!0);try{const A=await Pe.browse(w);if(k.current!==N)return;a(A),c(A.path),p(A.is_git?A.path:null),x("")}catch(A){if(k.current!==N)return;x(A instanceof Error?A.message:String(A))}finally{k.current===N&&m(!1)}};L.useEffect(()=>{var w,N;j(t),(w=_.current)==null||w.focus(),(N=_.current)==null||N.select()},[t]);const b=h||(s==null?void 0:s.path)||u,E=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",R=w=>{w.key==="Escape"&&(w.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:R,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:w=>w.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:w=>{w.preventDefault(),j(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:w=>c(w.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),v?d.jsx("div",{className:"error",role:"alert",children:v}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":y,children:s!=null&&s.entries.length?s.entries.map(w=>{const N=h===w.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":N,className:N?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":w.path,onClick:()=>p(w.path),onDoubleClick:()=>void j(w.path),children:[d.jsx(Ep,{}),d.jsx("span",{className:"explorer-name",children:w.name}),w.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},w.path)}):d.jsx("div",{className:"muted explorer-empty",children:y?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:b,children:b}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!b,onClick:()=>b&&r(b),children:["Use ",E]})]})]})})}const RN={scan:{start:0,end:20},extract:{start:20,end:88},boot:{start:88,end:94},stitch:{start:94,end:99},skipped:{start:100,end:100},done:{start:100,end:100}},TN=new Set(["scan","extract","boot","stitch"]);function LN(t){const r=t.phase||"";if(!r||r==="idle")return null;const o=RN[r];if(!o)return null;if(o.start===o.end)return o.end;const s=t.total||0;if(s<=0)return o.start;const a=Math.min(1,Math.max(0,(t.done||0)/s));return Math.round(o.start+(o.end-o.start)*a)}function AN(t){return!t.phase||t.phase==="idle"?null:typeof t.percent=="number"&&Number.isFinite(t.percent)?Math.max(0,Math.min(100,Math.round(t.percent))):LN(t)}const Ul=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],$N="obsidian",_m="loadpath.theme";function zN(t){return Ul.some(r=>r.id===t)}function Sm(){try{const t=localStorage.getItem(_m)||"";if(zN(t))return t}catch{}return $N}function DN(t){var r;return((r=Ul.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function km(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=DN(t);try{localStorage.setItem(_m,t)}catch{}}const Zu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:m0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:y0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:v0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:x0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:w0}];function Ju(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function ON(){var fo,ho,Si,po,go,mo,ki,Xr,rn,on;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,v]=L.useState(null),[x,y]=L.useState(null),[m,_]=L.useState(null),[k,j]=L.useState([]),[b,E]=L.useState("review"),[R,w]=L.useState(""),[N,A]=L.useState(""),[$,F]=L.useState(null),[G,q]=L.useState(!1),[te,ee]=L.useState(!1),[ne,K]=L.useState(""),[C,V]=L.useState({}),[W,U]=L.useState([]),[M,D]=L.useState([]),[H,I]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[z,ie]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[oe,fe]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[he,pe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[Z,se]=L.useState(0),[me,ke]=L.useState(""),[ve,re]=L.useState(Sm),[Ne,Me]=L.useState(!1),[Te,$e]=L.useState(!1),[st,lt]=L.useState(!1),[at,Ge]=L.useState(null),[wt,qt]=L.useState(null),[gt,mt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[Pt,ut]=L.useState(null),[Je,An]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[Ot,xn]=L.useState([]),[oo,$n]=L.useState(null),[vi,or]=L.useState(null),[$r,zn]=L.useState(null),[zr,sr]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[lr,Ft]=L.useState(null),[ct,Dn]=L.useState(null),[On,wn]=L.useState(!1),[Fn,_n]=L.useState(!1),rt=L.useRef(o);rt.current=o;const Dr=L.useRef(!1);Dr.current=Te;const _t=L.useRef(""),ar=L.useRef(""),Sn=P=>{re(P),km(P)},dt=L.useRef(""),He=P=>{dt.current=P,A(P)},kn=P=>{let Y=0,ce=!1;F(0);const je=()=>{Pe.indexProgress(P).then(Ie=>{if(!dt.current)return;if(Ie.phase&&Ie.phase!=="idle"&&Ie.message&&He(Ie.message),TN.has(Ie.phase))ce=!0;else if(!ce)return;const qr=AN(Ie);qr!=null&&(Ie.phase==="scan"&&!Ie.done?Y=qr:Y=Math.max(Y,qr),F(Y))}).catch(()=>{})};je();const Le=window.setInterval(je,250);return()=>{window.clearInterval(Le),F(null)}};L.useEffect(()=>{Pe.settings().then(V).catch(()=>{}).finally(()=>Me(!0)),Pe.repos().then(P=>j(P.repos)).catch(()=>{})},[]);const Nn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const P=o;let Y=!1;return ar.current!==P&&Bn(P),Pe.config(P).then(ce=>{!Y&&rt.current===P&&or(ce)}).catch(()=>{}),Pe.architectureHealth(P).then(ce=>{!Y&&rt.current===P&&zn(ce)}).catch(()=>{}),()=>{Y=!0}},[t,o]);const Ht=P=>{rt.current=P,s(P),localStorage.setItem("loadpath.repo",P),P.trim()!==_t.current&&(_t.current="",Ft(null))},Or=L.useCallback(P=>{const Y=(P??rt.current).trim();return!Y||_t.current===Y?Promise.resolve():(_t.current=Y,Pe.gitRefs(Y).then(ce=>{rt.current.trim()===Y&&Ft(ce)}).catch(()=>{_t.current===Y&&(_t.current="",Ft(null))}))},[]),nn=(P,Y)=>{u(P),h(Y),localStorage.setItem("loadpath.base",P),localStorage.setItem("loadpath.head",Y)},Fr=(P,Y,ce)=>{ie(P),I(Y),localStorage.setItem("loadpath.provider",P),localStorage.setItem("loadpath.scmRepo",Y),ce!==void 0&&(fe(ce),localStorage.setItem("loadpath.prNumber",ce))},yt=P=>{v(P),se(0),Ge(wt&&P.nodes.some(Y=>Y.id===wt)?wt:null),ut(null),$n(null),P.what_if||(y(P),P.id&&localStorage.setItem("loadpath.lastReviewId",P.id))},Hn=async P=>{try{const Y=await Pe.reviews(P);xn(Y.reviews)}catch{xn([])}},ur=async P=>{try{zn(await Pe.architectureHealth(P))}catch{zn(null)}},so=P=>P==="github"?!!C.github_token_set:P==="gitlab"?!!C.gitlab_token_set:!!C.bitbucket_token_set,It=L.useCallback(async(P=z)=>{var Y;try{const ce=await Pe.scmRepos(P);D(ce.repos),(Y=ce.user)!=null&&Y.login&&V(je=>({...je,...P==="github"?{github_user:ce.user.login}:P==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{D([])}},[z]);L.useEffect(()=>{if(t!=="prs")return;let P=!1;return It(z).catch(()=>{P||D([])}),()=>{P=!0}},[t,z,It]),L.useEffect(()=>{if(!ct)return;let P=!1,Y=0;const ce=async()=>{try{const je=await Pe.githubOAuthPoll(ct.flow_id);if(P)return;if(je.status==="complete"){Dn(null);const Le=await Pe.settings();V(Le),K(je.user?`Signed in to GitHub as ${je.user}`:"Signed in to GitHub"),It("github");return}if(je.status==="pending"||je.status==="slow_down"){Y=window.setTimeout(ce,Math.max(je.interval||ct.interval,5)*1e3);return}Dn(null),w(je.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(je){if(P)return;Dn(null),w(je instanceof Error?je.message:String(je))}};return Y=window.setTimeout(ce,Math.max(ct.interval,5)*1e3),()=>{P=!0,window.clearTimeout(Y)}},[ct,It]),L.useEffect(()=>{if(!On)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.bitbucket.connected){wn(!1);const Ie=await Pe.settings();V(Ie),K(Le.bitbucket.user?`Signed in to Bitbucket as ${Le.bitbucket.user}`:"Signed in to Bitbucket"),It("bitbucket");return}if(Date.now()-ce>18e4){wn(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;wn(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[On,It]),L.useEffect(()=>{if(!Fn)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.gitlab.connected){_n(!1);const Ie=await Pe.settings();V(Ie),K(Le.gitlab.user?`Signed in to GitLab as ${Le.gitlab.user}`:"Signed in to GitLab"),It("gitlab");return}if(Date.now()-ce>18e4){_n(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;_n(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[Fn,It]);const Bn=async(P=o,Y=!1)=>{if(!P.trim())return null;ar.current=P,ee(!0);try{const ce=await Pe.architecture(P,!1);rt.current===P&&_(ce);const je=Pe.architectureGraph(P).then(Le=>{rt.current===P&&_(Ie=>Ie&&{...Ie,nodes:Le.nodes,edges:Le.edges,graph_pending:!1})});return je.catch(()=>{}).finally(()=>{rt.current===P&&ee(!1)}),Y&&await je,ce}catch(ce){throw rt.current===P&&ee(!1),ce}},Hr=async P=>{const Y=P.trim();if(!(!Y||Y===rt.current)){if(dt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),K(""),v(null),y(null),_(null),E("architecture"),Ht(Y),q(!0),He(`Loading ${g0(Y)}…`);try{await Promise.all([Bn(Y),Or(Y)])}catch(ce){rt.current===Y&&w(ce instanceof Error?ce.message:String(ce))}finally{rt.current===Y&&(He(""),q(!1))}}},jn=async()=>{if(dt.current||!Nn())return;w(""),K(""),He("Tracing load path…"),Ht(o),nn(a,c);const P=kn(o);try{const Y=await Pe.review(o,a,c,!0,he);yt(Y),E("review"),r("review"),await Pe.repos().then(ce=>j(ce.repos)).catch(()=>{}),await Promise.all([Bn(o),Hn(o),ur(o)])}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{P(),He("")}},Br=async(P=!0)=>{if(dt.current||!Nn())return;w(""),K(""),He(P?"Indexing…":"Full reindex…"),Ht(o);const Y=kn(o);try{await Pe.index(o,P);const ce=await Bn(o);await Pe.repos().then(je=>j(je.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(E("architecture"),r("architecture"))}catch(ce){w(ce instanceof Error?ce.message:String(ce))}finally{Y(),He("")}},xi=async()=>{if(!dt.current&&Nn()){w(""),K(""),He("Detecting layout…"),Ht(o);try{const P=await Pe.init(o);K(P.message),await Pe.repos().then(Y=>j(Y.repos)).catch(()=>{})}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ve=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),K("Copied markdown brief")}catch(P){w(P instanceof Error?P.message:String(P))}},lo=async()=>{if(!dt.current){if(p!=null&&p.what_if){w("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first.");return}if(!(p!=null&&p.markdown)||!H||!oe){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const P=await Pe.postComment(z,H,Number(oe),p.markdown);K(P.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Vr=async()=>{if(!dt.current){w(""),He("Fetching pull requests…");try{const P=await Pe.prs(z,H,"open",o.trim()||void 0);U(P.pull_requests);const Y=M.find(ce=>ce.slug.toLowerCase()===H.trim().toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},wi=async()=>{w("");try{const P=await Pe.githubOAuthStart();Dn(P),Ju(P.verification_uri_complete,"github.com","/login/device")}catch(P){w(P instanceof Error?P.message:String(P))}},cr=async()=>{w("");try{const P=await Pe.bitbucketOAuthStart();wn(!0),Ju(P.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(P){wn(!1),w(P instanceof Error?P.message:String(P))}},ao=async()=>{w("");try{const P=await Pe.gitlabOAuthStart();_n(!0),Ju(P.authorize_url,new URL(P.authorize_url).hostname,"/oauth/authorize")}catch(P){_n(!1),w(P instanceof Error?P.message:String(P))}},dr=async P=>{if(!(dt.current||!o.trim())){w(""),He("Walking what-if path…");try{const Y=await Pe.whatIf(o,P);K(`${Y.title} — ${Y.confidence.level} · ${(Y.sinks||[]).length} sinks`),yt({...Y,markdown:Y.markdown||"",index:Y.index||(p==null?void 0:p.index),workspace:Y.workspace||(p==null?void 0:p.workspace)}),E("review"),r("review")}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},Vn=()=>{if(x){yt(x),E("review"),r("review"),K("Restored the last git-range walk");return}v(null),se(0),Ge(null),ut(null),$n(null),E("architecture"),r("architecture"),K("")},bt=async P=>{var Le;if(dt.current)return;Fr(P.provider,P.repo,String(P.number));const Y=M.find(Ie=>Ie.slug.toLowerCase()===P.repo.toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path),w(""),He(`Fetching ${P.provider} #${P.number}…`);const ce=(Y==null?void 0:Y.local_path)||o,je=ce?kn(ce):()=>{};try{const Ie=await Pe.reviewPr(P.provider,P.repo,P.number,(Y==null?void 0:Y.local_path)||o||void 0);yt(Ie),Ie.pull_request&&typeof Ie.pull_request.repo_path=="string"&&Ht(Ie.pull_request.repo_path),nn(String(Ie.base||P.target_branch),String(Ie.head||P.source_branch)),E("review"),r("review"),typeof((Le=Ie.pull_request)==null?void 0:Le.repo_path)=="string"&&Hn(Ie.pull_request.repo_path)}catch(Ie){nn(P.base_sha||P.target_branch,P.head_sha||P.source_branch),r("review"),w(Ie instanceof Error?Ie.message:String(Ie))}finally{je(),He("")}},Wr=async P=>{w("");try{V(await Pe.oauthDisconnect(P)),z===P&&D([]),K(`Disconnected ${P}`)}catch(Y){w(Y instanceof Error?Y.message:String(Y))}},Et=async P=>{P.preventDefault();const Y=new FormData(P.currentTarget),ce={github_token:String(Y.get("github_token")||""),github_oauth_client_id:String(Y.get("github_oauth_client_id")||""),github_host:String(Y.get("github_host")||""),gitlab_token:String(Y.get("gitlab_token")||""),gitlab_host:String(Y.get("gitlab_host")||""),gitlab_oauth_client_id:String(Y.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(Y.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(Y.get("bitbucket_token")||""),bitbucket_username:String(Y.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(Y.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(Y.get("bitbucket_oauth_client_secret")||""),ai_provider:String(Y.get("ai_provider")||"none"),ai_api_key:String(Y.get("ai_api_key")||""),ai_model:String(Y.get("ai_model")||""),ai_base_url:String(Y.get("ai_base_url")||"")},je=k.length?{...ce,workspaces:k.map(Le=>({path:Le.path,name:Le.name}))}:ce;try{V(await Pe.saveSettings(je)),K("Settings saved on this machine")}catch(Le){w(Le instanceof Error?Le.message:String(Le))}},uo=async()=>{if(!(!p||dt.current)){He("Residual analysis…");try{const P=await Pe.residual(p);ke(P.note)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ur=L.useRef(jn);Ur.current=jn;const Yr=L.useRef(t);Yr.current=t;const Wn=L.useRef(!1);Wn.current=st;const Un=L.useRef(p);Un.current=p;const bn=L.useRef(Z);bn.current=Z,L.useEffect(()=>{const P=localStorage.getItem("loadpath.lastReviewId"),Y=(localStorage.getItem("loadpath.repo")||"").trim();if(!P||!Y){sr(!1);return}let ce=!1;return Pe.getReview(Y,P).then(je=>{ce||(yt(je),nn(je.base||localStorage.getItem("loadpath.base")||"HEAD~1",je.head||localStorage.getItem("loadpath.head")||"HEAD"),Hn(Y),ur(Y))}).catch(()=>{}).finally(()=>{ce||sr(!1)}),()=>{ce=!0}},[]);const Bt=L.useRef("");L.useEffect(()=>{if(!Je||!o.trim())return;let P=!1;const Y=async()=>{try{const je=await Pe.workspaceStatus(o);if(P)return;Bt.current&&je.fingerprint!==Bt.current&&!dt.current&&(pe(!0),localStorage.setItem("loadpath.dirty","1"),Ur.current()),Bt.current=je.fingerprint}catch{}};Y();const ce=window.setInterval(Y,2e3);return()=>{P=!0,window.clearInterval(ce)}},[Je,o]),L.useEffect(()=>{const P=Y=>{var Le;if((Y.metaKey||Y.ctrlKey)&&Y.key.toLowerCase()==="k"){Y.preventDefault(),lt(Ie=>!Ie);return}if(Wn.current){Y.key==="Escape"&&(Y.preventDefault(),lt(!1));return}if(Dr.current){Y.key==="Escape"&&(Y.preventDefault(),$e(!1));return}const ce=Y.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){Y.key==="Escape"&&ce.blur();return}if(Y.key==="Escape"){w(""),K(""),Ge(wt),ut(null);return}if(Y.key==="j"||Y.key==="k"){const Ie=((Le=Un.current)==null?void 0:Le.read_order)||[];if(!Ie.length)return;Y.preventDefault();const Gn=bn.current,qr=Y.key==="j"?Math.min(Ie.length-1,Gn+1):Math.max(0,Gn-1);se(qr);return}const je=Zu.find(Ie=>Ie.shortcut===Y.key);if(je&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey&&r(je.id),(Y.metaKey||Y.ctrlKey)&&Y.key==="Enter"){if(Yr.current==="settings"||Yr.current==="prs"||dt.current)return;Y.preventDefault(),Ur.current()}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[wt]);const _i=async(P,Y)=>{if(!o.trim())return;const ce=await jN(o,P,Y);ce.ok?K(ce.message):w(ce.message)},Gr=async()=>{if(p)try{const P=await Pe.exportHtml(p),Y=URL.createObjectURL(P),ce=document.createElement("a");ce.href=Y,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(Y),K("Saved HTML brief")}catch(P){w(P instanceof Error?P.message:String(P))}},fr=async P=>{if(o.trim()){He("Loading stored review…");try{const Y=await Pe.getReview(o,P);yt(Y),nn(Y.base||a,Y.head||c),E("review"),r("review");const ce=Ot.find(je=>je.id!==P);if(ce)try{$n(await Pe.reviewDiff(o,P,ce.id))}catch{$n(null)}}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},hr={selectedId:at,onSelect:Ge,nodeRoles:p==null?void 0:p.node_roles,testOverlay:gt,isolateSource:Pt,onIsolate:ut,repoPath:o,onOpenFile:_i,pinnedId:wt,onPin:qt},Yn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},...p!=null&&p.what_if?[{id:"exit-whatif",group:"Review",label:x?"Back to git-range walk":"Exit what-if walk",run:Vn}]:[],{id:"index",group:"Run",label:"Index repository",run:()=>void Br(!0)},{id:"watch",group:"Run",label:Je?"Stop watching working tree":"Watch working tree",run:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")}},{id:"tests",group:"Graph",label:gt?"Hide test overlay":"Show test overlay",run:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Gr()},...Zu.map(P=>({id:`tab-${P.id}`,group:"Tabs",label:`Go to ${P.label}`,hint:P.shortcut,run:()=>r(P.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(P=>({id:`node-${P.id}`,group:"Nodes",label:P.name,hint:io(P.type),run:()=>{Ge(P.id),r("graph")}})),...Ot.slice(0,12).map(P=>({id:`hist-${P.id}`,group:"History",label:P.title||P.id,hint:`${P.level||""} ${P.created_at||""}`.trim(),run:()=>void fr(P.id)}))],En=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[b,m,p]),co=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[b,m,p]),pr=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Fe=((p==null?void 0:p.findings)||[]).filter(P=>!P.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Zu.map(P=>{const Y=P.icon,ce=t===P.id;return d.jsxs("button",{type:"button","data-testid":P.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":P.label,onClick:()=>r(P.id),children:[d.jsx(Y,{}),d.jsx("span",{children:P.label})]},P.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:ve,onChange:P=>Sn(P.target.value),children:["dark","light"].map(P=>d.jsx("optgroup",{label:P==="dark"?"Dark":"Light",children:Ul.filter(Y=>Y.group===P).map(Y=>d.jsx("option",{value:Y.id,children:Y.label},Y.id))},P))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:N||pr}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[N?d.jsxs("div",{className:$!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","aria-valuemin":$!=null?0:void 0,"aria-valuemax":$!=null?100:void 0,"aria-valuenow":$??void 0,"data-testid":"progress",children:[d.jsx("i",{style:$!=null?{width:`${$}%`}:void 0}),d.jsx("span",{className:"sr-only",children:N})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[k.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:k.some(P=>P.path===o)?o:"",disabled:!!N,"aria-busy":G,onChange:P=>{P.target.value&&Hr(P.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),k.map(P=>d.jsxs("option",{value:P.path,children:[P.name,P.indexed?` (${P.counts.nodes})`:""]},P.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:P=>{const Y=P.target.value;s(Y),Y.trim()!==_t.current&&(_t.current="",Ft(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>$e(!0),children:d.jsx(Ep,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(kp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:P=>nn(P,c),placeholder:"base",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(kp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:P=>nn(a,P),placeholder:"head",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:he?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":he,onClick:()=>{const P=!he;pe(P),localStorage.setItem("loadpath.dirty",P?"1":"0")},children:he?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:Je?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":Je,onClick:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")},children:Je?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.what_if?"what-if · ":"",p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!N,onClick:xi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!N,onClick:()=>Br(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!N,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[R?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:R}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,ne?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:ne}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>K(""),"aria-label":"Dismiss",children:"×"})]}):null,((fo=p==null?void 0:p.index)!=null&&fo.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((ho=p==null?void 0:p.index)==null?void 0:ho.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Si=p==null?void 0:p.index)==null?void 0:Si.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(po=p==null?void 0:p.workspace)!=null&&po.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,p!=null&&p.what_if?d.jsxs("div",{className:"banner whatif","data-testid":"whatif-banner",children:[d.jsxs("span",{children:["Hypothetical walk from"," ",d.jsx("strong",{children:((go=p.node)==null?void 0:go.name)||"this node"}),". Loadpath ignored Base/Head and asked which sinks would feel this node change — not a filter of the current map."]}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-exit-whatif",onClick:Vn,children:x?"Back to git range":"Back to architecture"})]}):null,G?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:N||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":G||te,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(FN,{review:p,findings:Fe,aiNote:me,busy:!!N,tourIndex:Z,onTour:se,onAskAi:uo,onCopy:Ve,onPost:lo,onSelect:Ge,onOpenFile:_i,onExport:Gr,history:Ot,diff:oo,onReopen:fr,onWaiver:(P,Y)=>{o.trim()&&Pe.addWaiver(o,P,Y||void 0,"from review").then(ce=>{or(ce),K(`Waived ${P} in loadpath.yml`)})}}):zr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Qu,{nodes:p.nodes,edges:p.edges,onWhatIf:dr,focusPath:(mo=p.read_order[Z])==null?void 0:mo.path,...hr}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(HN,{architecture:m,busy:!!N,onReindex:()=>Br(!1),onReview:jn,onSelect:Ge,config:vi,health:$r,onSaveConfig:P=>{Pe.saveConfig(o,P).then(Y=>{or(Y),K("Wrote loadpath.yml")})},onWaiver:(P,Y,ce)=>{Pe.addWaiver(o,P,Y,ce).then(je=>{or(je),K(`Waived ${P}`)})}}):G?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(te||m!=null&&m.graph_pending)&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(ki=m==null?void 0:m.counts)!=null&&ki.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Qu,{nodes:m.nodes,edges:m.edges,onWhatIf:dr,...hr,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":b==="review","data-testid":"graph-mode-review",className:b==="review"?"active":"",onClick:()=>E("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":b==="architecture","data-testid":"graph-mode-architecture",className:b==="architecture"?"active":"",onClick:()=>E("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:gt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":gt,onClick:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")},children:"Tests"})]}),En.length?d.jsx(Qu,{nodes:En,edges:co,onWhatIf:dr,...hr}):te||m!=null&&m.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:z,onChange:P=>Fr(P.target.value,H,oe),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:M.length?"Search your repos":"owner/repo",value:H,onChange:P=>Fr(z,P.target.value,oe),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:M.map(P=>d.jsxs("option",{value:P.slug,children:[P.private?"private":"public",P.local_path?" · local":""]},P.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!N||!so(z),onClick:()=>{It(z)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!N,onClick:Vr,children:"List PRs"})]}),M.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[M.length," ",z," repositor",M.length===1?"y":"ies",z==="github"&&C.github_user?` · @${String(C.github_user)}`:"",z==="gitlab"&&C.gitlab_user?` · @${String(C.gitlab_user)}`:"",z==="bitbucket"&&C.bitbucket_user?` · ${String(C.bitbucket_user)}`:""]}):null,W.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):W.map(P=>{var Y;return d.jsxs("article",{className:"pr","data-testid":`pr-${P.number}`,children:[d.jsxs("h3",{children:["#",P.number," ",P.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${P.draft?"":"open"}`,children:P.draft?"draft":P.state}),d.jsx("span",{children:P.author}),d.jsxs("span",{children:[P.source_branch," → ",P.target_branch]}),P.loadpath?d.jsxs("span",{className:`chip ${P.loadpath.level||""}`,"data-testid":`pr-loadpath-${P.number}`,children:[((Y=P.loadpath.level)==null?void 0:Y.toUpperCase())||"REVIEWED",P.loadpath.contract_break&&P.loadpath.contract_break!=="none"?` · ${P.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:P.url,target:"_blank",rel:"noreferrer",children:["Open on ",P.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${P.number}`,onClick:()=>void bt(P),children:"Review this PR"})]})]},`${P.provider}-${P.number}`)})]}),t==="settings"&&Ne&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Et,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Ul.map(P=>d.jsxs("button",{type:"button","data-theme":P.id,className:ve===P.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${P.id}`,onClick:()=>Sn(P.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:P.label}),d.jsx("div",{className:"group",children:P.group})]},P.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:wm(),onChange:P=>NN(P.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:C.github_token_set?C.github_user?`Signed in as @${String(C.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void Wr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!ct||!C.github_oauth_ready,onClick:()=>void wi(),children:ct?"Waiting for GitHub…":"Sign in with GitHub"})})]}),ct?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:ct.user_code})," at GitHub if the browser did not fill it in."]}):null,C.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(C.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(C.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:C.gitlab_token_set?C.gitlab_user?`Signed in as @${String(C.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void Wr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Fn||!C.gitlab_oauth_ready,onClick:()=>void ao(),children:Fn?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(C.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(C.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:C.bitbucket_token_set?C.bitbucket_user?`Signed in as ${String(C.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void Wr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:On||!C.bitbucket_oauth_ready,onClick:()=>void cr(),children:On?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),C.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(C.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(C.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((Xr=C.ai)==null?void 0:Xr.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((rn=C.ai)==null?void 0:rn.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((on=C.ai)==null?void 0:on.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(f0,{open:st,actions:Yn,onClose:()=>lt(!1)}),Te?d.jsx(IN,{initialPath:o,onClose:()=>$e(!1),onSelect:P=>{if(dt.current){w("Wait for the current job to finish before switching workspace.");return}$e(!1),Hr(P)}}):null]})}function FN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:v,onOpenFile:x,onExport:y,history:m,diff:_,onReopen:k,onWaiver:j}){var E,R,w,N,A,$,F,G,q,te,ee,ne,K,C,V,W,U;const b=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),b.length?d.jsx("ul",{className:"reasons",children:b.map(M=>d.jsx("li",{children:M},M))}):null,t.what_if?d.jsx("span",{className:"chip whatif","data-testid":"whatif-chip",children:"what-if"}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Zo(M)},M)),(E=t.contract_break)!=null&&E.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>j(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(R=t.workspace)!=null&&R.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>x(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&v(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(Nm,{cards:t.deepening}),(N=(w=t.contract_break)==null?void 0:w.reasons)!=null&&N.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),($=(A=t.contract_break.sides)==null?void 0:A.rows)!=null&&$.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(F=t.auth)!=null&&F.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(G=t.suggested_tests)==null?void 0:G.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(q=t.trend)!=null&&q.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",ec(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),m.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:m.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,m.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>k(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?ec(M.created_at):""})]},M.id))]}):null,(ee=(te=t.evolution)==null?void 0:te.notes)!=null&&ee.length||(K=(ne=t.evolution)==null?void 0:ne.hotspots)!=null&&K.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((C=t.evolution)==null?void 0:C.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((V=t.evolution)==null?void 0:V.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:y,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",disabled:s||!!t.what_if,title:t.what_if?"Hypothetical walks are not posted to a pull request":void 0,onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(W=t.codeowners_reviewers)!=null&&W.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function HN({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var x;const v=t.findings.filter(y=>!y.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${ec(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(y=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y.name})," — ",(y.django_apps||[]).join(", ")||"no apps"," ·"," ",(y.owners||[]).join(", ")||"unowned"]},y.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(y=>d.jsx("div",{className:"muted",children:y},y))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:v.length})]}),v.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):v.map(y=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>y.node_id&&a(y.node_id),children:[d.jsx("span",{className:`chip ${y.severity}`,children:y.severity}),y.message]})},y.rule+y.message))]}),d.jsx(Nm,{cards:t.deepening}),(x=c==null?void 0:c.points)!=null&&x.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(y=>d.jsx("i",{className:y.level||"",title:`${y.level} · ${y.findings} findings`,style:{height:`${8+Math.min(24,(y.findings||0)*4)}px`}},y.id||y.created_at))}),Object.entries(c.contexts).map(([y,m])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:y})," — last ",((_=m[m.length-1])==null?void 0:_.findings)??0," findings"]},y)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(h0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((y,m)=>m[1]-y[1]).slice(0,12).map(([y,m])=>d.jsxs("tr",{children:[d.jsx("td",{children:io(y)}),d.jsx("td",{children:m})]},y))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function Nm({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:p0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}km(Sm());u0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(ON,{})}));export{Vk as L,WN as a,BN as c,d as j,VN as l,L as r,io as t}; diff --git a/src/loadpath/static/index.html b/src/loadpath/static/index.html index a57b62d..0e95751 100644 --- a/src/loadpath/static/index.html +++ b/src/loadpath/static/index.html @@ -17,7 +17,7 @@ - + diff --git a/ui/src/graphEdges.test.ts b/ui/src/graphEdges.test.ts index d32a11b..4f68e1f 100644 --- a/ui/src/graphEdges.test.ts +++ b/ui/src/graphEdges.test.ts @@ -99,6 +99,24 @@ describe("assignEdgeStepPositions", () => { expect(Math.abs(xNext - xSkip)).toBeGreaterThan(40); }); + it("bends skip-column edges in the first gap so they do not sit on the next column", () => { + const nodes = [ + node("r", "django.route"), + node("u", "django.url_name"), + node("v", "django.view"), + ]; + const pos = new Map([ + ["r", { x: 0, y: 0 }], + ["u", { x: 296, y: 92 }], + ["v", { x: 592, y: 184 }], + ]); + const steps = assignEdgeStepPositions(nodes, [edge("r", "v")], pos); + const step = steps.get("r->v") ?? 0.5; + const srcX = 208; + const laneX = srcX + (592 - srcX) * step; + expect(laneX).toBeLessThan(296); + }); + it("spreads lanes between 0.2 and 0.8", () => { expect(stepForLane(0, 1)).toBe(0.5); expect(stepForLane(0, 2)).toBe(0.2); diff --git a/ui/src/graphEdges.ts b/ui/src/graphEdges.ts index 5f3323e..f06d07a 100644 --- a/ui/src/graphEdges.ts +++ b/ui/src/graphEdges.ts @@ -1,4 +1,5 @@ import { + GRAPH_COL_GAP, GRAPH_NODE_HEIGHT, GRAPH_NODE_WIDTH, layoutNodes, @@ -28,6 +29,7 @@ export function assignEdgeStepPositions( pos?: Map, ): Map { const placed = pos ?? layoutNodes(nodes, edges); + const colXs = [...new Set([...placed.values()].map((p) => p.x))].sort((a, b) => a - b); const spans: Span[] = []; for (const edge of edges) { const src = placed.get(edge.src); @@ -64,22 +66,29 @@ export function assignEdgeStepPositions( const sorted = [...group].sort((a, b) => a.y0 - b.y0 || a.y1 - b.y1 || a.id.localeCompare(b.id)); const laneOf = lanesFor(sorted); const laneCount = Math.max(0, ...laneOf.values()) + 1; - const minDx = Math.min(...sorted.map((span) => span.targetX - span.sourceX)); + const sourceX = sorted[0]!.sourceX; + const gutter = gapAfter(colXs, sourceX); for (const span of sorted) { - const lane = laneOf.get(span.id) ?? 0; - const t = stepForLane(lane, laneCount); + const t = stepForLane(laneOf.get(span.id) ?? 0, laneCount); const denom = span.targetX - span.sourceX; - if (Math.abs(denom - minDx) < 0.5) { + if (Math.abs(denom - gutter) < 0.5) { steps.set(span.id, t); continue; } - const laneX = span.sourceX + minDx * t; + const laneX = span.sourceX + gutter * t; steps.set(span.id, Math.min(0.92, Math.max(0.08, (laneX - span.sourceX) / denom))); } } return steps; } +function gapAfter(colXs: number[], sourceX: number): number { + const colX = sourceX - GRAPH_NODE_WIDTH; + const next = colXs.find((x) => x > colX + 1); + if (next === undefined) return GRAPH_COL_GAP; + return Math.max(GRAPH_COL_GAP, next - sourceX); +} + /** First-fit coloring: two verticals share an x only when their y ranges stay apart. */ function lanesFor(spans: Span[]): Map { const laneEnds: number[] = []; From 4681163caf487ea23804f9154d0630f14ff79d6d Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 16 Aug 2026 00:53:55 +0000 Subject: [PATCH 14/16] Stop clamping skip-column bends onto the same vertical. A 0.08 floor made several long edges share one x just past the handle offset. Lane x is now inverted through the smooth-step formula so stacked skips stay in distinct first-gap tracks. Co-authored-by: zord.lack.net --- ...XtGMK0TN.js => LayeredGraph3D-CprfGADt.js} | 2 +- .../{index-CXcahMbK.js => index-C5rEgtEu.js} | 24 +++++++------- src/loadpath/static/index.html | 2 +- tests/e2e/test_ui_flows.py | 5 +++ ui/src/graphEdges.test.ts | 32 +++++++++++++++---- ui/src/graphEdges.ts | 18 +++++++---- 6 files changed, 56 insertions(+), 27 deletions(-) rename src/loadpath/static/assets/{LayeredGraph3D-XtGMK0TN.js => LayeredGraph3D-CprfGADt.js} (99%) rename src/loadpath/static/assets/{index-CXcahMbK.js => index-C5rEgtEu.js} (56%) diff --git a/src/loadpath/static/assets/LayeredGraph3D-XtGMK0TN.js b/src/loadpath/static/assets/LayeredGraph3D-CprfGADt.js similarity index 99% rename from src/loadpath/static/assets/LayeredGraph3D-XtGMK0TN.js rename to src/loadpath/static/assets/LayeredGraph3D-CprfGADt.js index bade4f0..69bacbd 100644 --- a/src/loadpath/static/assets/LayeredGraph3D-XtGMK0TN.js +++ b/src/loadpath/static/assets/LayeredGraph3D-CprfGADt.js @@ -1,4 +1,4 @@ -import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-CXcahMbK.js";/** +import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-C5rEgtEu.js";/** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT diff --git a/src/loadpath/static/assets/index-CXcahMbK.js b/src/loadpath/static/assets/index-C5rEgtEu.js similarity index 56% rename from src/loadpath/static/assets/index-CXcahMbK.js rename to src/loadpath/static/assets/index-C5rEgtEu.js index 6fec883..705298e 100644 --- a/src/loadpath/static/assets/index-CXcahMbK.js +++ b/src/loadpath/static/assets/index-C5rEgtEu.js @@ -1,4 +1,4 @@ -(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function jp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Tu={exports:{}},Uo={},Lu={exports:{}},Re={};/** +(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function bp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Lu={exports:{}},Uo={},Au={exports:{}},Re={};/** * @license React * react.production.min.js * @@ -6,7 +6,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Kf;function n0(){if(Kf)return Re;Kf=1;var t=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),v=Symbol.iterator;function m(I){return I===null||typeof I!="object"?null:(I=v&&I[v]||I["@@iterator"],typeof I=="function"?I:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,j={};function b(I,z,ie){this.props=I,this.context=z,this.refs=j,this.updater=ie||_}b.prototype.isReactComponent={},b.prototype.setState=function(I,z){if(typeof I!="object"&&typeof I!="function"&&I!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,I,z,"setState")},b.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function E(){}E.prototype=b.prototype;function R(I,z,ie){this.props=I,this.context=z,this.refs=j,this.updater=ie||_}var w=R.prototype=new E;w.constructor=R,k(w,b.prototype),w.isPureReactComponent=!0;var N=Array.isArray,A=Object.prototype.hasOwnProperty,$={current:null},F={key:!0,ref:!0,__self:!0,__source:!0};function X(I,z,ie){var oe,fe={},he=null,pe=null;if(z!=null)for(oe in z.ref!==void 0&&(pe=z.ref),z.key!==void 0&&(he=""+z.key),z)A.call(z,oe)&&!F.hasOwnProperty(oe)&&(fe[oe]=z[oe]);var Z=arguments.length-2;if(Z===1)fe.children=ie;else if(1>>1,z=M[I];if(0>>1;Ia(fe,H))hea(pe,fe)?(M[I]=pe,M[he]=H,I=he):(M[I]=fe,M[oe]=H,I=oe);else if(hea(pe,H))M[I]=pe,M[he]=H,I=he;else break e}}return D}function a(M,D){var H=M.sortIndex-D.sortIndex;return H!==0?H:M.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,h=c.now();t.unstable_now=function(){return c.now()-h}}var p=[],y=[],x=1,v=null,m=3,_=!1,k=!1,j=!1,b=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(M){for(var D=o(y);D!==null;){if(D.callback===null)s(y);else if(D.startTime<=M)s(y),D.sortIndex=D.expirationTime,r(p,D);else break;D=o(y)}}function N(M){if(j=!1,w(M),!k)if(o(p)!==null)k=!0,W(A);else{var D=o(y);D!==null&&U(N,D.startTime-M)}}function A(M,D){k=!1,j&&(j=!1,E(X),X=-1),_=!0;var H=m;try{for(w(D),v=o(p);v!==null&&(!(v.expirationTime>D)||M&&!ee());){var I=v.callback;if(typeof I=="function"){v.callback=null,m=v.priorityLevel;var z=I(v.expirationTime<=D);D=t.unstable_now(),typeof z=="function"?v.callback=z:v===o(p)&&s(p),w(D)}else s(p);v=o(p)}if(v!==null)var ie=!0;else{var oe=o(y);oe!==null&&U(N,oe.startTime-D),ie=!1}return ie}finally{v=null,m=H,_=!1}}var $=!1,F=null,X=-1,q=5,te=-1;function ee(){return!(t.unstable_now()-teM||125I?(M.sortIndex=H,r(y,M),o(p)===null&&M===o(y)&&(j?(E(X),X=-1):j=!0,U(N,H-I))):(M.sortIndex=z,r(p,M),k||_||(k=!0,W(A))),M},t.unstable_shouldYield=ee,t.unstable_wrapCallback=function(M){var D=m;return function(){var H=m;m=D;try{return M.apply(this,arguments)}finally{m=H}}}})(zu)),zu}var th;function l0(){return th||(th=1,$u.exports=s0()),$u.exports}/** + */var th;function l0(){return th||(th=1,(function(t){function r(M,D){var H=M.length;M.push(D);e:for(;0>>1,z=M[I];if(0>>1;Ia(fe,H))hea(pe,fe)?(M[I]=pe,M[he]=H,I=he):(M[I]=fe,M[oe]=H,I=oe);else if(hea(pe,H))M[I]=pe,M[he]=H,I=he;else break e}}return D}function a(M,D){var H=M.sortIndex-D.sortIndex;return H!==0?H:M.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,h=c.now();t.unstable_now=function(){return c.now()-h}}var p=[],y=[],x=1,v=null,m=3,_=!1,k=!1,j=!1,b=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(M){for(var D=o(y);D!==null;){if(D.callback===null)s(y);else if(D.startTime<=M)s(y),D.sortIndex=D.expirationTime,r(p,D);else break;D=o(y)}}function N(M){if(j=!1,w(M),!k)if(o(p)!==null)k=!0,W(A);else{var D=o(y);D!==null&&U(N,D.startTime-M)}}function A(M,D){k=!1,j&&(j=!1,E(G),G=-1),_=!0;var H=m;try{for(w(D),v=o(p);v!==null&&(!(v.expirationTime>D)||M&&!ee());){var I=v.callback;if(typeof I=="function"){v.callback=null,m=v.priorityLevel;var z=I(v.expirationTime<=D);D=t.unstable_now(),typeof z=="function"?v.callback=z:v===o(p)&&s(p),w(D)}else s(p);v=o(p)}if(v!==null)var ie=!0;else{var oe=o(y);oe!==null&&U(N,oe.startTime-D),ie=!1}return ie}finally{v=null,m=H,_=!1}}var $=!1,F=null,G=-1,q=5,te=-1;function ee(){return!(t.unstable_now()-teM||125I?(M.sortIndex=H,r(y,M),o(p)===null&&M===o(y)&&(j?(E(G),G=-1):j=!0,U(N,H-I))):(M.sortIndex=z,r(p,M),k||_||(k=!0,W(A))),M},t.unstable_shouldYield=ee,t.unstable_wrapCallback=function(M){var D=m;return function(){var H=m;m=D;try{return M.apply(this,arguments)}finally{m=H}}}})(Du)),Du}var nh;function a0(){return nh||(nh=1,zu.exports=l0()),zu.exports}/** * @license React * react-dom.production.min.js * @@ -30,14 +30,14 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var nh;function a0(){if(nh)return zt;nh=1;var t=cs(),r=l0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,y=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,x={},v={};function m(e){return p.call(v,e)?!0:p.call(x,e)?!1:y.test(e)?v[e]=!0:(x[e]=!0,!1)}function _(e,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function k(e,n,i,l){if(n===null||typeof n>"u"||_(e,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function j(e,n,i,l,f,g,S){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=f,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=g,this.removeEmptyString=S}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){b[e]=new j(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];b[n]=new j(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){b[e]=new j(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){b[e]=new j(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){b[e]=new j(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){b[e]=new j(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){b[e]=new j(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){b[e]=new j(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){b[e]=new j(e,5,!1,e.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function R(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){b[e]=new j(e,1,!1,e.toLowerCase(),null,!1,!1)}),b.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){b[e]=new j(e,1,!1,e.toLowerCase(),null,!0,!0)});function w(e,n,i,l){var f=b.hasOwnProperty(n)?b[n]:null;(f!==null?f.type!==0:l||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,y=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,x={},v={};function m(e){return p.call(v,e)?!0:p.call(x,e)?!1:y.test(e)?v[e]=!0:(x[e]=!0,!1)}function _(e,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function k(e,n,i,l){if(n===null||typeof n>"u"||_(e,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function j(e,n,i,l,f,g,S){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=f,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=g,this.removeEmptyString=S}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){b[e]=new j(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];b[n]=new j(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){b[e]=new j(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){b[e]=new j(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){b[e]=new j(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){b[e]=new j(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){b[e]=new j(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){b[e]=new j(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){b[e]=new j(e,5,!1,e.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function R(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){b[e]=new j(e,1,!1,e.toLowerCase(),null,!1,!1)}),b.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){b[e]=new j(e,1,!1,e.toLowerCase(),null,!0,!0)});function w(e,n,i,l){var f=b.hasOwnProperty(n)?b[n]:null;(f!==null?f.type!==0:l||!(2T||f[S]!==g[T]){var O=` -`+f[S].replace(" at new "," at ");return e.displayName&&O.includes("")&&(O=O.replace("",e.displayName)),O}while(1<=S&&0<=T);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?z(e):""}function fe(e){switch(e.tag){case 5:return z(e.type);case 16:return z("Lazy");case 13:return z("Suspense");case 19:return z("SuspenseList");case 0:case 2:case 15:return e=oe(e.type,!1),e;case 11:return e=oe(e.type.render,!1),e;case 1:return e=oe(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case F:return"Fragment";case $:return"Portal";case q:return"Profiler";case X:return"StrictMode";case K:return"Suspense";case C:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ee:return(e.displayName||"Context")+".Consumer";case te:return(e._context.displayName||"Context")+".Provider";case ne:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case W:n=e._payload,e=e._init;try{return he(e(n))}catch{}}return null}function pe(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===X?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Z(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=se(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function ke(e){e._valueTracker||(e._valueTracker=me(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=se(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function re(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return H({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Z(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Te(e,n){n=n.checked,n!=null&&w(e,"checked",n,!1)}function $e(e,n){Te(e,n);var i=Z(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?lt(e,n.type,i):n.hasOwnProperty("defaultValue")&<(e,n.type,Z(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function st(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function lt(e,n,i){(n!=="number"||re(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var at=Array.isArray;function Xe(e,n,i,l){if(e=e.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=Je.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ot(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var xn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},oo=["Webkit","ms","Moz","O"];Object.keys(xn).forEach(function(e){oo.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),xn[n]=xn[e]})});function $n(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||xn.hasOwnProperty(e)&&xn[e]?(""+n).trim():n+"px"}function vi(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=$n(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,f):e[i]=f}}var or=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function $r(e,n){if(n){if(or[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function zn(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var zr=null;function sr(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var lr=null,Ft=null,ct=null;function Dn(e){if(e=Po(e)){if(typeof lr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=Rs(n),lr(e.stateNode,e.type,n))}}function On(e){Ft?ct?ct.push(e):ct=[e]:Ft=e}function wn(){if(Ft){var e=Ft,n=ct;if(ct=Ft=null,Dn(e),n)for(e=0;e>>=0,e===0?32:31-(uo(e)/Ur|0)|0}var Wn=64,Un=4194304;function bn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Bt(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,f=e.suspendedLanes,g=e.pingedLanes,S=i&268435455;if(S!==0){var T=S&~f;T!==0?l=bn(T):(g&=S,g!==0&&(l=bn(g)))}else S=i&~f,S!==0?l=bn(S):g!==0&&(l=bn(g));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,g=n&-n,f>=g||f===16&&(g&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function En(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Et(n),e[n]=i}function co(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=_o),Bc=" ",Vc=!1;function Wc(e,n){switch(e){case"keyup":return Qm.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Uc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var bi=!1;function Jm(e,n){switch(e){case"compositionend":return Uc(n);case"keypress":return n.which!==32?null:(Vc=!0,Bc);case"textInput":return e=n.data,e===Bc&&Vc?null:e;default:return null}}function ey(e,n){if(bi)return e==="compositionend"||!ha&&Wc(e,n)?(e=$c(),_s=la=gr=null,bi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Zc(i)}}function ed(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?ed(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function td(){for(var e=window,n=re();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=re(e.document)}return n}function ma(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function uy(e){var n=td(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&ed(i.ownerDocument.documentElement,i)){if(l!==null&&ma(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var f=i.textContent.length,g=Math.min(l.start,f);l=l.end===void 0?g:Math.min(l.end,f),!e.extend&&g>l&&(f=l,l=g,g=f),f=Jc(i,g);var S=Jc(i,l);f&&S&&(e.rangeCount!==1||e.anchorNode!==f.node||e.anchorOffset!==f.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),e.removeAllRanges(),g>l?(e.addRange(n),e.extend(S.node,S.offset)):(n.setEnd(S.node,S.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,Ei=null,ya=null,jo=null,va=!1;function nd(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;va||Ei==null||Ei!==re(l)||(l=Ei,"selectionStart"in l&&ma(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),jo&&No(jo,l)||(jo=l,l=Ms(ya,"onSelect"),0Ri||(e.current=Pa[Ri],Pa[Ri]=null,Ri--)}function Be(e,n){Ri++,Pa[Ri]=e.current,e.current=n}var xr={},St=vr(xr),Rt=vr(!1),Qr=xr;function Ti(e,n){var i=e.type.contextTypes;if(!i)return xr;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in i)f[g]=n[g];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=f),f}function Tt(e){return e=e.childContextTypes,e!=null}function Ts(){Ue(Rt),Ue(St)}function yd(e,n,i){if(St.current!==xr)throw Error(o(168));Be(St,n),Be(Rt,i)}function vd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,pe(e)||"Unknown",f));return H({},i,l)}function Ls(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||xr,Qr=St.current,Be(St,e),Be(Rt,Rt.current),!0}function xd(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=vd(e,n,Qr),l.__reactInternalMemoizedMergedChildContext=e,Ue(Rt),Ue(St),Be(St,e)):Ue(Rt),Be(Rt,i)}var qn=null,As=!1,Ia=!1;function wd(e){qn===null?qn=[e]:qn.push(e)}function _y(e){As=!0,wd(e)}function wr(){if(!Ia&&qn!==null){Ia=!0;var e=0,n=Fe;try{var i=qn;for(Fe=1;e>=S,f-=S,Kn=1<<32-Et(n)+f|i<Ce?(pt=Ee,Ee=null):pt=Ee.sibling;var Oe=le(G,Ee,Q[Ce],de);if(Oe===null){Ee===null&&(Ee=pt);break}e&&Ee&&Oe.alternate===null&&n(G,Ee),B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe,Ee=pt}if(Ce===Q.length)return i(G,Ee),Ge&&Jr(G,Ce),_e;if(Ee===null){for(;CeCe?(pt=Ee,Ee=null):pt=Ee.sibling;var Mr=le(G,Ee,Oe.value,de);if(Mr===null){Ee===null&&(Ee=pt);break}e&&Ee&&Mr.alternate===null&&n(G,Ee),B=g(Mr,B,Ce),be===null?_e=Mr:be.sibling=Mr,be=Mr,Ee=pt}if(Oe.done)return i(G,Ee),Ge&&Jr(G,Ce),_e;if(Ee===null){for(;!Oe.done;Ce++,Oe=Q.next())Oe=ue(G,Oe.value,de),Oe!==null&&(B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return Ge&&Jr(G,Ce),_e}for(Ee=l(G,Ee);!Oe.done;Ce++,Oe=Q.next())Oe=ge(Ee,G,Ce,Oe.value,de),Oe!==null&&(e&&Oe.alternate!==null&&Ee.delete(Oe.key===null?Ce:Oe.key),B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return e&&Ee.forEach(function(t0){return n(G,t0)}),Ge&&Jr(G,Ce),_e}function et(G,B,Q,de){if(typeof Q=="object"&&Q!==null&&Q.type===F&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case A:e:{for(var _e=Q.key,be=B;be!==null;){if(be.key===_e){if(_e=Q.type,_e===F){if(be.tag===7){i(G,be.sibling),B=f(be,Q.props.children),B.return=G,G=B;break e}}else if(be.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===W&&bd(_e)===be.type){i(G,be.sibling),B=f(be,Q.props),B.ref=Io(G,be,Q),B.return=G,G=B;break e}i(G,be);break}else n(G,be);be=be.sibling}Q.type===F?(B=li(Q.props.children,G.mode,de,Q.key),B.return=G,G=B):(de=ul(Q.type,Q.key,Q.props,null,G.mode,de),de.ref=Io(G,B,Q),de.return=G,G=de)}return S(G);case $:e:{for(be=Q.key;B!==null;){if(B.key===be)if(B.tag===4&&B.stateNode.containerInfo===Q.containerInfo&&B.stateNode.implementation===Q.implementation){i(G,B.sibling),B=f(B,Q.children||[]),B.return=G,G=B;break e}else{i(G,B);break}else n(G,B);B=B.sibling}B=Cu(Q,G.mode,de),B.return=G,G=B}return S(G);case W:return be=Q._init,et(G,B,be(Q._payload),de)}if(at(Q))return xe(G,B,Q,de);if(D(Q))return we(G,B,Q,de);Os(G,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"?(Q=""+Q,B!==null&&B.tag===6?(i(G,B.sibling),B=f(B,Q),B.return=G,G=B):(i(G,B),B=Eu(Q,G.mode,de),B.return=G,G=B),S(G)):i(G,B)}return et}var zi=Ed(!0),Cd=Ed(!1),Fs=vr(null),Hs=null,Di=null,za=null;function Da(){za=Di=Hs=null}function Oa(e){var n=Fs.current;Ue(Fs),e._currentValue=n}function Fa(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function Oi(e,n){Hs=e,za=Di=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Lt=!0),e.firstContext=null)}function Zt(e){var n=e._currentValue;if(za!==e)if(e={context:e,memoizedValue:n,next:null},Di===null){if(Hs===null)throw Error(o(308));Di=e,Hs.dependencies={lanes:0,firstContext:e}}else Di=Di.next=e;return n}var ei=null;function Ha(e){ei===null?ei=[e]:ei.push(e)}function Md(e,n,i,l){var f=n.interleaved;return f===null?(i.next=i,Ha(n)):(i.next=f.next,f.next=i),n.interleaved=i,Zn(e,l)}function Zn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var _r=!1;function Ba(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Pd(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Jn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Sr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(ze&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,Zn(e,i)}return f=l.interleaved,f===null?(n.next=n,Ha(l)):(n.next=f.next,f.next=n),l.interleaved=n,Zn(e,i)}function Bs(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}function Id(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var S={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?f=g=S:g=g.next=S,i=i.next}while(i!==null);g===null?f=g=n:g=g.next=n}else f=g=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function Vs(e,n,i,l){var f=e.updateQueue;_r=!1;var g=f.firstBaseUpdate,S=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,J=O.next;O.next=null,S===null?g=J:S.next=J,S=O;var ae=e.alternate;ae!==null&&(ae=ae.updateQueue,T=ae.lastBaseUpdate,T!==S&&(T===null?ae.firstBaseUpdate=J:T.next=J,ae.lastBaseUpdate=O))}if(g!==null){var ue=f.baseState;S=0,ae=J=O=null,T=g;do{var le=T.lane,ge=T.eventTime;if((l&le)===le){ae!==null&&(ae=ae.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var xe=e,we=T;switch(le=n,ge=i,we.tag){case 1:if(xe=we.payload,typeof xe=="function"){ue=xe.call(ge,ue,le);break e}ue=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=we.payload,le=typeof xe=="function"?xe.call(ge,ue,le):xe,le==null)break e;ue=H({},ue,le);break e;case 2:_r=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,le=f.effects,le===null?f.effects=[T]:le.push(T))}else ge={eventTime:ge,lane:le,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ae===null?(J=ae=ge,O=ue):ae=ae.next=ge,S|=le;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;le=T,T=le.next,le.next=null,f.lastBaseUpdate=le,f.shared.pending=null}}while(!0);if(ae===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=J,f.lastBaseUpdate=ae,n=f.shared.interleaved,n!==null){f=n;do S|=f.lane,f=f.next;while(f!==n)}else g===null&&(f.shared.lanes=0);ri|=S,e.lanes=S,e.memoizedState=ue}}function Rd(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=Xa.transition;Xa.transition={};try{e(!1),n()}finally{Fe=i,Xa.transition=l}}function Qd(){return Jt().memoizedState}function jy(e,n,i){var l=br(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},Zd(e))Jd(n,i);else if(i=Md(e,n,i,l),i!==null){var f=Mt();dn(i,e,l,f),ef(i,n,l)}}function by(e,n,i){var l=br(e),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(Zd(e))Jd(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,T=g(S,i);if(f.hasEagerState=!0,f.eagerState=T,sn(T,S)){var O=n.interleaved;O===null?(f.next=f,Ha(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=Md(e,n,f,l),i!==null&&(f=Mt(),dn(i,e,l,f),ef(i,n,l))}}function Zd(e){var n=e.alternate;return e===Ke||n!==null&&n===Ke}function Jd(e,n){Ao=Ys=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function ef(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}var qs={readContext:Zt,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},Ey={readContext:Zt,useCallback:function(e,n){return Pn().memoizedState=[e,n===void 0?null:n],e},useContext:Zt,useEffect:Vd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Xs(4194308,4,Yd.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Xs(4194308,4,e,n)},useInsertionEffect:function(e,n){return Xs(4,2,e,n)},useMemo:function(e,n){var i=Pn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=Pn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=jy.bind(null,Ke,e),[l.memoizedState,e]},useRef:function(e){var n=Pn();return e={current:e},n.memoizedState=e},useState:Hd,useDebugValue:eu,useDeferredValue:function(e){return Pn().memoizedState=e},useTransition:function(){var e=Hd(!1),n=e[0];return e=Ny.bind(null,e[1]),Pn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=Ke,f=Pn();if(Ge){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ht===null)throw Error(o(349));(ni&30)!==0||$d(l,n,i)}f.memoizedState=i;var g={value:i,getSnapshot:n};return f.queue=g,Vd(Dd.bind(null,l,g,e),[e]),l.flags|=2048,Do(9,zd.bind(null,l,g,i,n),void 0,null),i},useId:function(){var e=Pn(),n=ht.identifierPrefix;if(Ge){var i=Qn,l=Kn;i=(l&~(1<<32-Et(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=$o++,0")&&(O=O.replace("",e.displayName)),O}while(1<=S&&0<=T);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?z(e):""}function fe(e){switch(e.tag){case 5:return z(e.type);case 16:return z("Lazy");case 13:return z("Suspense");case 19:return z("SuspenseList");case 0:case 2:case 15:return e=oe(e.type,!1),e;case 11:return e=oe(e.type.render,!1),e;case 1:return e=oe(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case F:return"Fragment";case $:return"Portal";case q:return"Profiler";case G:return"StrictMode";case K:return"Suspense";case C:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ee:return(e.displayName||"Context")+".Consumer";case te:return(e._context.displayName||"Context")+".Provider";case ne:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case W:n=e._payload,e=e._init;try{return he(e(n))}catch{}}return null}function pe(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===G?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Z(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=se(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function ke(e){e._valueTracker||(e._valueTracker=me(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=se(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function re(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return H({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Z(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Te(e,n){n=n.checked,n!=null&&w(e,"checked",n,!1)}function $e(e,n){Te(e,n);var i=Z(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?lt(e,n.type,i):n.hasOwnProperty("defaultValue")&<(e,n.type,Z(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function st(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function lt(e,n,i){(n!=="number"||re(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var at=Array.isArray;function Ge(e,n,i,l){if(e=e.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=Je.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ot(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var xn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},oo=["Webkit","ms","Moz","O"];Object.keys(xn).forEach(function(e){oo.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),xn[n]=xn[e]})});function $n(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||xn.hasOwnProperty(e)&&xn[e]?(""+n).trim():n+"px"}function vi(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=$n(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,f):e[i]=f}}var or=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function $r(e,n){if(n){if(or[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function zn(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var zr=null;function sr(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var lr=null,Ft=null,ct=null;function Dn(e){if(e=Po(e)){if(typeof lr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=Rs(n),lr(e.stateNode,e.type,n))}}function On(e){Ft?ct?ct.push(e):ct=[e]:Ft=e}function wn(){if(Ft){var e=Ft,n=ct;if(ct=Ft=null,Dn(e),n)for(e=0;e>>=0,e===0?32:31-(uo(e)/Ur|0)|0}var Wn=64,Un=4194304;function bn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Bt(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,f=e.suspendedLanes,g=e.pingedLanes,S=i&268435455;if(S!==0){var T=S&~f;T!==0?l=bn(T):(g&=S,g!==0&&(l=bn(g)))}else S=i&~f,S!==0?l=bn(S):g!==0&&(l=bn(g));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,g=n&-n,f>=g||f===16&&(g&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function En(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Et(n),e[n]=i}function co(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=_o),Vc=" ",Wc=!1;function Uc(e,n){switch(e){case"keyup":return Zm.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Yc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var bi=!1;function ey(e,n){switch(e){case"compositionend":return Yc(n);case"keypress":return n.which!==32?null:(Wc=!0,Vc);case"textInput":return e=n.data,e===Vc&&Wc?null:e;default:return null}}function ty(e,n){if(bi)return e==="compositionend"||!pa&&Uc(e,n)?(e=zc(),_s=aa=gr=null,bi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Jc(i)}}function td(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?td(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function nd(){for(var e=window,n=re();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=re(e.document)}return n}function ya(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function cy(e){var n=nd(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&td(i.ownerDocument.documentElement,i)){if(l!==null&&ya(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var f=i.textContent.length,g=Math.min(l.start,f);l=l.end===void 0?g:Math.min(l.end,f),!e.extend&&g>l&&(f=l,l=g,g=f),f=ed(i,g);var S=ed(i,l);f&&S&&(e.rangeCount!==1||e.anchorNode!==f.node||e.anchorOffset!==f.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),e.removeAllRanges(),g>l?(e.addRange(n),e.extend(S.node,S.offset)):(n.setEnd(S.node,S.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,Ei=null,va=null,jo=null,xa=!1;function rd(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;xa||Ei==null||Ei!==re(l)||(l=Ei,"selectionStart"in l&&ya(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),jo&&No(jo,l)||(jo=l,l=Ms(va,"onSelect"),0Ri||(e.current=Ia[Ri],Ia[Ri]=null,Ri--)}function Be(e,n){Ri++,Ia[Ri]=e.current,e.current=n}var xr={},St=vr(xr),Rt=vr(!1),Qr=xr;function Ti(e,n){var i=e.type.contextTypes;if(!i)return xr;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in i)f[g]=n[g];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=f),f}function Tt(e){return e=e.childContextTypes,e!=null}function Ts(){Ue(Rt),Ue(St)}function vd(e,n,i){if(St.current!==xr)throw Error(o(168));Be(St,n),Be(Rt,i)}function xd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,pe(e)||"Unknown",f));return H({},i,l)}function Ls(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||xr,Qr=St.current,Be(St,e),Be(Rt,Rt.current),!0}function wd(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=xd(e,n,Qr),l.__reactInternalMemoizedMergedChildContext=e,Ue(Rt),Ue(St),Be(St,e)):Ue(Rt),Be(Rt,i)}var qn=null,As=!1,Ra=!1;function _d(e){qn===null?qn=[e]:qn.push(e)}function Sy(e){As=!0,_d(e)}function wr(){if(!Ra&&qn!==null){Ra=!0;var e=0,n=Fe;try{var i=qn;for(Fe=1;e>=S,f-=S,Kn=1<<32-Et(n)+f|i<Ce?(pt=Ee,Ee=null):pt=Ee.sibling;var Oe=le(X,Ee,Q[Ce],de);if(Oe===null){Ee===null&&(Ee=pt);break}e&&Ee&&Oe.alternate===null&&n(X,Ee),B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe,Ee=pt}if(Ce===Q.length)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;CeCe?(pt=Ee,Ee=null):pt=Ee.sibling;var Mr=le(X,Ee,Oe.value,de);if(Mr===null){Ee===null&&(Ee=pt);break}e&&Ee&&Mr.alternate===null&&n(X,Ee),B=g(Mr,B,Ce),be===null?_e=Mr:be.sibling=Mr,be=Mr,Ee=pt}if(Oe.done)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;!Oe.done;Ce++,Oe=Q.next())Oe=ue(X,Oe.value,de),Oe!==null&&(B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return Xe&&Jr(X,Ce),_e}for(Ee=l(X,Ee);!Oe.done;Ce++,Oe=Q.next())Oe=ge(Ee,X,Ce,Oe.value,de),Oe!==null&&(e&&Oe.alternate!==null&&Ee.delete(Oe.key===null?Ce:Oe.key),B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return e&&Ee.forEach(function(n0){return n(X,n0)}),Xe&&Jr(X,Ce),_e}function et(X,B,Q,de){if(typeof Q=="object"&&Q!==null&&Q.type===F&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case A:e:{for(var _e=Q.key,be=B;be!==null;){if(be.key===_e){if(_e=Q.type,_e===F){if(be.tag===7){i(X,be.sibling),B=f(be,Q.props.children),B.return=X,X=B;break e}}else if(be.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===W&&Ed(_e)===be.type){i(X,be.sibling),B=f(be,Q.props),B.ref=Io(X,be,Q),B.return=X,X=B;break e}i(X,be);break}else n(X,be);be=be.sibling}Q.type===F?(B=li(Q.props.children,X.mode,de,Q.key),B.return=X,X=B):(de=ul(Q.type,Q.key,Q.props,null,X.mode,de),de.ref=Io(X,B,Q),de.return=X,X=de)}return S(X);case $:e:{for(be=Q.key;B!==null;){if(B.key===be)if(B.tag===4&&B.stateNode.containerInfo===Q.containerInfo&&B.stateNode.implementation===Q.implementation){i(X,B.sibling),B=f(B,Q.children||[]),B.return=X,X=B;break e}else{i(X,B);break}else n(X,B);B=B.sibling}B=Mu(Q,X.mode,de),B.return=X,X=B}return S(X);case W:return be=Q._init,et(X,B,be(Q._payload),de)}if(at(Q))return xe(X,B,Q,de);if(D(Q))return we(X,B,Q,de);Os(X,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"?(Q=""+Q,B!==null&&B.tag===6?(i(X,B.sibling),B=f(B,Q),B.return=X,X=B):(i(X,B),B=Cu(Q,X.mode,de),B.return=X,X=B),S(X)):i(X,B)}return et}var zi=Cd(!0),Md=Cd(!1),Fs=vr(null),Hs=null,Di=null,Da=null;function Oa(){Da=Di=Hs=null}function Fa(e){var n=Fs.current;Ue(Fs),e._currentValue=n}function Ha(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function Oi(e,n){Hs=e,Da=Di=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Lt=!0),e.firstContext=null)}function Zt(e){var n=e._currentValue;if(Da!==e)if(e={context:e,memoizedValue:n,next:null},Di===null){if(Hs===null)throw Error(o(308));Di=e,Hs.dependencies={lanes:0,firstContext:e}}else Di=Di.next=e;return n}var ei=null;function Ba(e){ei===null?ei=[e]:ei.push(e)}function Pd(e,n,i,l){var f=n.interleaved;return f===null?(i.next=i,Ba(n)):(i.next=f.next,f.next=i),n.interleaved=i,Zn(e,l)}function Zn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var _r=!1;function Va(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Id(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Jn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Sr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(ze&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,Zn(e,i)}return f=l.interleaved,f===null?(n.next=n,Ba(l)):(n.next=f.next,f.next=n),l.interleaved=n,Zn(e,i)}function Bs(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}function Rd(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var S={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?f=g=S:g=g.next=S,i=i.next}while(i!==null);g===null?f=g=n:g=g.next=n}else f=g=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function Vs(e,n,i,l){var f=e.updateQueue;_r=!1;var g=f.firstBaseUpdate,S=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,J=O.next;O.next=null,S===null?g=J:S.next=J,S=O;var ae=e.alternate;ae!==null&&(ae=ae.updateQueue,T=ae.lastBaseUpdate,T!==S&&(T===null?ae.firstBaseUpdate=J:T.next=J,ae.lastBaseUpdate=O))}if(g!==null){var ue=f.baseState;S=0,ae=J=O=null,T=g;do{var le=T.lane,ge=T.eventTime;if((l&le)===le){ae!==null&&(ae=ae.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var xe=e,we=T;switch(le=n,ge=i,we.tag){case 1:if(xe=we.payload,typeof xe=="function"){ue=xe.call(ge,ue,le);break e}ue=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=we.payload,le=typeof xe=="function"?xe.call(ge,ue,le):xe,le==null)break e;ue=H({},ue,le);break e;case 2:_r=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,le=f.effects,le===null?f.effects=[T]:le.push(T))}else ge={eventTime:ge,lane:le,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ae===null?(J=ae=ge,O=ue):ae=ae.next=ge,S|=le;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;le=T,T=le.next,le.next=null,f.lastBaseUpdate=le,f.shared.pending=null}}while(!0);if(ae===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=J,f.lastBaseUpdate=ae,n=f.shared.interleaved,n!==null){f=n;do S|=f.lane,f=f.next;while(f!==n)}else g===null&&(f.shared.lanes=0);ri|=S,e.lanes=S,e.memoizedState=ue}}function Td(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=Xa.transition;Xa.transition={};try{e(!1),n()}finally{Fe=i,Xa.transition=l}}function Zd(){return Jt().memoizedState}function by(e,n,i){var l=br(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},Jd(e))ef(n,i);else if(i=Pd(e,n,i,l),i!==null){var f=Mt();dn(i,e,l,f),tf(i,n,l)}}function Ey(e,n,i){var l=br(e),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(Jd(e))ef(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,T=g(S,i);if(f.hasEagerState=!0,f.eagerState=T,sn(T,S)){var O=n.interleaved;O===null?(f.next=f,Ba(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=Pd(e,n,f,l),i!==null&&(f=Mt(),dn(i,e,l,f),tf(i,n,l))}}function Jd(e){var n=e.alternate;return e===Ke||n!==null&&n===Ke}function ef(e,n){Ao=Ys=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function tf(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}var qs={readContext:Zt,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},Cy={readContext:Zt,useCallback:function(e,n){return Pn().memoizedState=[e,n===void 0?null:n],e},useContext:Zt,useEffect:Wd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Gs(4194308,4,Gd.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Gs(4194308,4,e,n)},useInsertionEffect:function(e,n){return Gs(4,2,e,n)},useMemo:function(e,n){var i=Pn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=Pn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=by.bind(null,Ke,e),[l.memoizedState,e]},useRef:function(e){var n=Pn();return e={current:e},n.memoizedState=e},useState:Bd,useDebugValue:tu,useDeferredValue:function(e){return Pn().memoizedState=e},useTransition:function(){var e=Bd(!1),n=e[0];return e=jy.bind(null,e[1]),Pn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=Ke,f=Pn();if(Xe){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ht===null)throw Error(o(349));(ni&30)!==0||zd(l,n,i)}f.memoizedState=i;var g={value:i,getSnapshot:n};return f.queue=g,Wd(Od.bind(null,l,g,e),[e]),l.flags|=2048,Do(9,Dd.bind(null,l,g,i,n),void 0,null),i},useId:function(){var e=Pn(),n=ht.identifierPrefix;if(Xe){var i=Qn,l=Kn;i=(l&~(1<<32-Et(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=$o++,0<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=S.createElement(i,{is:l.is}):(e=S.createElement(i),i==="select"&&(S=e,l.multiple?S.multiple=!0:l.size&&(S.size=l.size))):e=S.createElementNS(e,i),e[Cn]=n,e[Mo]=l,_f(e,n,!1,!1),n.stateNode=e;e:{switch(S=zn(i,l),i){case"dialog":We("cancel",e),We("close",e),f=l;break;case"iframe":case"object":case"embed":We("load",e),f=l;break;case"video":case"audio":for(f=0;fWi&&(n.flags|=128,l=!0,Oo(g,!1),n.lanes=4194304)}else{if(!l)if(e=Ws(S),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Oo(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Ge)return Nt(n),null}else 2*Ve()-g.renderingStartTime>Wi&&i!==1073741824&&(n.flags|=128,l=!0,Oo(g,!1),n.lanes=4194304);g.isBackwards?(S.sibling=n.child,n.child=S):(i=g.last,i!==null?i.sibling=S:n.child=S,g.last=S)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(Nt(n),null);case 22:case 23:return Nu(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Yt&1073741824)!==0&&(Nt(n),n.subtreeFlags&6&&(n.flags|=8192)):Nt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function Ay(e,n){switch(Ta(n),n.tag){case 1:return Tt(n.type)&&Ts(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Fi(),Ue(Rt),Ue(St),Ya(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Wa(n),null;case 13:if(Ue(qe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));$i()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Fi(),null;case 10:return Oa(n.type._context),null;case 22:case 23:return Nu(),null;case 24:return null;default:return null}}var Js=!1,jt=!1,$y=typeof WeakSet=="function"?WeakSet:Set,ye=null;function Bi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Ze(e,n,l)}else i.current=null}function fu(e,n,i){try{i()}catch(l){Ze(e,n,l)}}var Nf=!1;function zy(e,n){if(Na=xs,e=td(),ma(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,g=l.focusNode;l=l.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var S=0,T=-1,O=-1,J=0,ae=0,ue=e,le=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=S+f),ue!==g||l!==0&&ue.nodeType!==3||(O=S+l),ue.nodeType===3&&(S+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)le=ue,ue=ge;for(;;){if(ue===e)break t;if(le===i&&++J===f&&(T=S),le===g&&++ae===l&&(O=S),(ge=ue.nextSibling)!==null)break;ue=le,le=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(ja={focusedElem:e,selectionRange:i},xs=!1,ye=n;ye!==null;)if(n=ye,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ye=e;else for(;ye!==null;){n=ye;try{var xe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var we=xe.memoizedProps,et=xe.memoizedState,G=n.stateNode,B=G.getSnapshotBeforeUpdate(n.elementType===n.type?we:an(n.type,we),et);G.__reactInternalSnapshotBeforeUpdate=B}break;case 3:var Q=n.stateNode.containerInfo;Q.nodeType===1?Q.textContent="":Q.nodeType===9&&Q.documentElement&&Q.removeChild(Q.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(de){Ze(n,n.return,de)}if(e=n.sibling,e!==null){e.return=n.return,ye=e;break}ye=n.return}return xe=Nf,Nf=!1,xe}function Fo(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&e)===e){var g=f.destroy;f.destroy=void 0,g!==void 0&&fu(n,i,g)}f=f.next}while(f!==l)}}function el(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function hu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function jf(e){var n=e.alternate;n!==null&&(e.alternate=null,jf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[Cn],delete n[Mo],delete n[Ma],delete n[xy],delete n[wy])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function bf(e){return e.tag===5||e.tag===3||e.tag===4}function Ef(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||bf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function pu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=Is));else if(l!==4&&(e=e.child,e!==null))for(pu(e,n,i),e=e.sibling;e!==null;)pu(e,n,i),e=e.sibling}function gu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(gu(e,n,i),e=e.sibling;e!==null;)gu(e,n,i),e=e.sibling}var vt=null,un=!1;function kr(e,n,i){for(i=i.child;i!==null;)Cf(e,n,i),i=i.sibling}function Cf(e,n,i){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(Vn,i)}catch{}switch(i.tag){case 5:jt||Bi(i,n);case 6:var l=vt,f=un;vt=null,kr(e,n,i),vt=l,un=f,vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):vt.removeChild(i.stateNode));break;case 18:vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?Ca(e.parentNode,i):e.nodeType===1&&Ca(e,i),vo(e)):Ca(vt,i.stateNode));break;case 4:l=vt,f=un,vt=i.stateNode.containerInfo,un=!0,kr(e,n,i),vt=l,un=f;break;case 0:case 11:case 14:case 15:if(!jt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var g=f,S=g.destroy;g=g.tag,S!==void 0&&((g&2)!==0||(g&4)!==0)&&fu(i,n,S),f=f.next}while(f!==l)}kr(e,n,i);break;case 1:if(!jt&&(Bi(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Ze(i,n,T)}kr(e,n,i);break;case 21:kr(e,n,i);break;case 22:i.mode&1?(jt=(l=jt)||i.memoizedState!==null,kr(e,n,i),jt=l):kr(e,n,i);break;default:kr(e,n,i)}}function Mf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new $y),n.forEach(function(l){var f=Yy.bind(null,e,l);i.has(l)||(i.add(l),l.then(f,f))})}}function cn(e,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=S),l&=~g}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Oy(l/1960))-l,10e?16:e,jr===null)var l=!1;else{if(e=jr,jr=null,ol=0,(ze&6)!==0)throw Error(o(331));var f=ze;for(ze|=4,ye=e.current;ye!==null;){var g=ye,S=g.child;if((ye.flags&16)!==0){var T=g.deletions;if(T!==null){for(var O=0;OVe()-vu?oi(e,0):yu|=i),$t(e,n)}function Bf(e,n){n===0&&((e.mode&1)===0?n=1:(n=Un,Un<<=1,(Un&130023424)===0&&(Un=4194304)));var i=Mt();e=Zn(e,n),e!==null&&(En(e,n,i),$t(e,i))}function Uy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Bf(e,i)}function Yy(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Bf(e,i)}var Vf;Vf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Rt.current)Lt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Lt=!1,Ty(e,n,i);Lt=(e.flags&131072)!==0}else Lt=!1,Ge&&(n.flags&1048576)!==0&&_d(n,zs,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Zs(e,n),e=n.pendingProps;var f=Ti(n,St.current);Oi(n,i),f=qa(null,n,l,e,f,i);var g=Ka();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Tt(l)?(g=!0,Ls(n)):g=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Ba(n),f.updater=Ks,n.stateNode=f,f._reactInternals=n,nu(n,l,e,i),n=su(null,n,l,!0,g,i)):(n.tag=0,Ge&&g&&Ra(n),Ct(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Zs(e,n),e=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=Gy(l),e=an(l,e),f){case 0:n=ou(null,n,l,e,i);break e;case 1:n=gf(null,n,l,e,i);break e;case 11:n=cf(null,n,l,e,i);break e;case 14:n=df(null,n,l,an(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),ou(e,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),gf(e,n,l,f,i);case 3:e:{if(mf(n),e===null)throw Error(o(387));l=n.pendingProps,g=n.memoizedState,f=g.element,Pd(e,n),Vs(n,l,null,i);var S=n.memoizedState;if(l=S.element,g.isDehydrated)if(g={element:l,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){f=Hi(Error(o(423)),n),n=yf(e,n,l,i,f);break e}else if(l!==f){f=Hi(Error(o(424)),n),n=yf(e,n,l,i,f);break e}else for(Ut=yr(n.stateNode.containerInfo.firstChild),Wt=n,Ge=!0,ln=null,i=Cd(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if($i(),l===f){n=er(e,n,i);break e}Ct(e,n,l,i)}n=n.child}return n;case 5:return Td(n),e===null&&Aa(n),l=n.type,f=n.pendingProps,g=e!==null?e.memoizedProps:null,S=f.children,ba(l,f)?S=null:g!==null&&ba(l,g)&&(n.flags|=32),pf(e,n),Ct(e,n,S,i),n.child;case 6:return e===null&&Aa(n),null;case 13:return vf(e,n,i);case 4:return Va(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=zi(n,null,l,i):Ct(e,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),cf(e,n,l,f,i);case 7:return Ct(e,n,n.pendingProps,i),n.child;case 8:return Ct(e,n,n.pendingProps.children,i),n.child;case 12:return Ct(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,g=n.memoizedProps,S=f.value,Be(Fs,l._currentValue),l._currentValue=S,g!==null)if(sn(g.value,S)){if(g.children===f.children&&!Rt.current){n=er(e,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var T=g.dependencies;if(T!==null){S=g.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(g.tag===1){O=Jn(-1,i&-i),O.tag=2;var J=g.updateQueue;if(J!==null){J=J.shared;var ae=J.pending;ae===null?O.next=O:(O.next=ae.next,ae.next=O),J.pending=O}}g.lanes|=i,O=g.alternate,O!==null&&(O.lanes|=i),Fa(g.return,i,n),T.lanes|=i;break}O=O.next}}else if(g.tag===10)S=g.type===n.type?null:g.child;else if(g.tag===18){if(S=g.return,S===null)throw Error(o(341));S.lanes|=i,T=S.alternate,T!==null&&(T.lanes|=i),Fa(S,i,n),S=g.sibling}else S=g.child;if(S!==null)S.return=g;else for(S=g;S!==null;){if(S===n){S=null;break}if(g=S.sibling,g!==null){g.return=S.return,S=g;break}S=S.return}g=S}Ct(e,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,Oi(n,i),f=Zt(f),l=l(f),n.flags|=1,Ct(e,n,l,i),n.child;case 14:return l=n.type,f=an(l,n.pendingProps),f=an(l.type,f),df(e,n,l,f,i);case 15:return ff(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),Zs(e,n),n.tag=1,Tt(l)?(e=!0,Ls(n)):e=!1,Oi(n,i),nf(n,l,f),nu(n,l,f,i),su(null,n,l,!0,e,i);case 19:return wf(e,n,i);case 22:return hf(e,n,i)}throw Error(o(156,n.tag))};function Wf(e,n){return Hr(e,n)}function Xy(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tn(e,n,i,l){return new Xy(e,n,i,l)}function bu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Gy(e){if(typeof e=="function")return bu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ne)return 11;if(e===V)return 14}return 2}function Cr(e,n){var i=e.alternate;return i===null?(i=tn(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function ul(e,n,i,l,f,g){var S=2;if(l=e,typeof e=="function")bu(e)&&(S=1);else if(typeof e=="string")S=5;else e:switch(e){case F:return li(i.children,f,g,n);case X:S=8,f|=8;break;case q:return e=tn(12,i,n,f|2),e.elementType=q,e.lanes=g,e;case K:return e=tn(13,i,n,f),e.elementType=K,e.lanes=g,e;case C:return e=tn(19,i,n,f),e.elementType=C,e.lanes=g,e;case U:return cl(i,f,g,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case te:S=10;break e;case ee:S=9;break e;case ne:S=11;break e;case V:S=14;break e;case W:S=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=tn(S,i,n,f),n.elementType=e,n.type=l,n.lanes=g,n}function li(e,n,i,l){return e=tn(7,e,l,n),e.lanes=i,e}function cl(e,n,i,l){return e=tn(22,e,l,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function Eu(e,n,i){return e=tn(6,e,null,n),e.lanes=i,e}function Cu(e,n,i){return n=tn(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function qy(e,n,i,l,f){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Yn(0),this.expirationTimes=Yn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Yn(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Mu(e,n,i,l,f,g,S,T,O){return e=new qy(e,n,i,T,O),n===1?(n=1,g===!0&&(n|=8)):n=0,g=tn(3,null,null,n),e.current=g,g.stateNode=e,g.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ba(g),e}function Ky(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),Au.exports=a0(),Au.exports}var ih;function u0(){if(ih)return yl;ih=1;var t=bp();return yl.createRoot=t.createRoot,yl.hydrateRoot=t.hydrateRoot,yl}var c0=u0();function Ep(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Ae(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(Ep(s,o.statusText||"Request failed"))}return o.json()}const d0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Pe={health:()=>Ae("/api/health"),settings:()=>Ae("/api/settings"),saveSettings:t=>{const r={...t};for(const o of d0)r[o]===""&&delete r[o];return Ae("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ae("/api/repos"),browse:t=>Ae(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ae(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ae("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ae(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Ae(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:(t,r=!0)=>Ae(`/api/architecture?repo_path=${encodeURIComponent(t)}&graph=${r?"1":"0"}`),architectureGraph:t=>Ae(`/api/architecture/graph?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Ae("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Ae("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Ae("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Ae("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Ae("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Ae(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open",s)=>Ae("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o,repo_path:s||null})}),scmRepos:t=>Ae(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ae("/api/oauth/status"),githubOAuthStart:()=>Ae("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ae("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ae("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Ae("/api/oauth/gitlab/start"),oauthDisconnect:t=>Ae("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ae("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})}),reviews:t=>Ae(`/api/reviews?repo_path=${encodeURIComponent(t)}`),getReview:(t,r)=>Ae(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(t)}`),reviewDiff:(t,r,o)=>Ae(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(t)}&other=${encodeURIComponent(o)}`),config:t=>Ae(`/api/config?repo_path=${encodeURIComponent(t)}`),saveConfig:(t,r)=>Ae("/api/config",{method:"PUT",body:JSON.stringify({repo_path:t,...r})}),addWaiver:(t,r,o,s)=>Ae("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:t,rule:r,node:o||null,reason:s||""})}),marks:(t,r)=>Ae(`/api/marks?repo_path=${encodeURIComponent(t)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:t=>Ae(`/api/architecture/health?repo_path=${encodeURIComponent(t)}`),workspaceStatus:t=>Ae(`/api/workspace/status?repo_path=${encodeURIComponent(t)}`),openEditor:(t,r,o,s)=>Ae("/api/open",{method:"POST",body:JSON.stringify({repo_path:t,path:r,line:o||null,editor:s||null})}),exportHtml:t=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:t})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(Ep(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(t,r,o,s)=>Ae("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:t,edges:r,source_id:o,target_id:s||null})})};function f0(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):t}function h0({open:t,actions:r,onClose:o}){const[s,a]=L.useState(""),[u,c]=L.useState(0),h=L.useRef(null),p=L.useMemo(()=>f0(r,s),[r,s]);if(L.useEffect(()=>{if(!t)return;a(""),c(0);const v=window.setTimeout(()=>{var m;return(m=h.current)==null?void 0:m.focus()},0);return()=>window.clearTimeout(v)},[t]),L.useEffect(()=>{c(0)},[s]),!t)return null;const y=p[u],x=v=>{v&&(o(),v.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:v=>{v.target===v.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:v=>a(v.target.value),onKeyDown:v=>{v.key==="Escape"?(v.preventDefault(),o()):v.key==="ArrowDown"?(v.preventDefault(),c(m=>Math.min(p.length-1,m+1))):v.key==="ArrowUp"?(v.preventDefault(),c(m=>Math.max(0,m-1))):v.key==="Enter"&&(v.preventDefault(),x(y))}}),d.jsxs("ul",{children:[p.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,p.slice(0,40).map((v,m)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:m===u?"active":"",onMouseEnter:()=>c(m),onClick:()=>x(v),children:[d.jsx("span",{children:v.label}),v.hint?d.jsx("span",{className:"muted",children:v.hint}):null]})},v.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function p0({config:t,busy:r,onSave:o,onWaiver:s}){const[a,u]=L.useState(t),[c,h]=L.useState(t.available_rules[0]||""),[p,y]=L.useState(""),[x,v]=L.useState("");L.useEffect(()=>{u(t)},[t]);const m=Object.entries(a.contexts||{}),_=(R,w,N)=>{const A=a.contexts[R];if(!A)return;const $=F=>F.split(",").map(X=>X.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[R]:{...A,[w]:w==="name"?N:$(N)}}})},k=(R,w)=>{const N=w.trim();if(!N||N===R)return;const{[R]:A,...$}=a.contexts;A&&u({...a,contexts:{...$,[N]:{...A,name:N}}})},j=()=>{let R=1;for(;a.contexts[`context-${R}`];)R+=1;const w=`context-${R}`;u({...a,contexts:{...a.contexts,[w]:{name:w,django_apps:[],react:[],public_api:[],owners:[]}}})},b=R=>{const{[R]:w,...N}=a.contexts;u({...a,contexts:N})},E=R=>{const w=a.rules.includes(R);u({...a,rules:w?a.rules.filter(N=>N!==R):[...a.rules,R]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),m.map(([R,w])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:R})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:R,"data-testid":`config-context-name-${R}`,onBlur:N=>k(R,N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(w.django_apps||[]).join(", "),onChange:N=>_(R,"django_apps",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(w.react||[]).join(", "),onChange:N=>_(R,"react",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(w.public_api||[]).join(", "),onChange:N=>_(R,"public_api",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(w.owners||[]).join(", "),onChange:N=>_(R,"owners",N.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>b(R),children:"Remove context"})]},R)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:j,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(R),onChange:()=>E(R)}),R]},R))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((R,w)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:R.rule}),R.node?` · ${R.node}`:"",R.reason?` — ${R.reason}`:""]},`${R.rule}:${R.node}:${w}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:R=>h(R.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsx("option",{value:R,children:R},R))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:R=>y(R.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:x,onChange:R=>v(R.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,x),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function Zo(t){return t.replaceAll("_"," ")}function g0(t){return t.replaceAll("_"," ")}function io(t){return t.split(".").pop()||t}function ec(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function m0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Tr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function yi({className:t,children:r}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function y0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function v0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function x0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function w0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function _0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function Cp({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function S0({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const k0="modulepreload",N0=function(t,r){return new URL(t,r).href},oh={},j0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(x){return Promise.all(x.map(v=>Promise.resolve(v).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),y=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(x=>{if(x=N0(x,s),x in oh)return;oh[x]=!0;const v=x.endsWith(".css"),m=v?'[rel="stylesheet"]':"";if(!!s)for(let j=h.length-1;j>=0;j--){const b=h[j];if(b.href===x&&(!v||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${x}"]${m}`))return;const k=document.createElement("link");if(k.rel=v?"stylesheet":k0,v||(k.as="script"),k.crossOrigin="",k.href=x,y&&k.setAttribute("nonce",y),document.head.appendChild(k),v)return new Promise((j,b)=>{k.addEventListener("load",j),k.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${x}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function nt(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Yl(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}Ml.prototype=Yl.prototype={constructor:Ml,on:function(t,r){var o=this._,s=E0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),lh.hasOwnProperty(r)?{space:lh[r],local:t}:t}function M0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===tc&&r.documentElement.namespaceURI===tc?r.createElement(t):r.createElementNS(o,t)}}function P0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Mp(t){var r=Xl(t);return(r.local?P0:M0)(r)}function I0(){}function gc(t){return t==null?I0:function(){return this.querySelector(t)}}function R0(t){typeof t!="function"&&(t=gc(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=w&&(w=R+1);!(A=b[w])&&++w=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function rv(t){t||(t=iv);function r(v,m){return v&&m?t(v.__data__,m.__data__):!v-!m}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function ov(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function sv(){return Array.from(this)}function lv(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?vv:typeof r=="function"?wv:xv)(t,r,o??"")):Ki(this.node(),t)}function Ki(t,r){return t.style.getPropertyValue(r)||Lp(t).getComputedStyle(t,null).getPropertyValue(r)}function Sv(t){return function(){delete this[t]}}function kv(t,r){return function(){this[t]=r}}function Nv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function jv(t,r){return arguments.length>1?this.each((r==null?Sv:typeof r=="function"?Nv:kv)(t,r)):this.node()[t]}function Ap(t){return t.trim().split(/^|\s+/)}function mc(t){return t.classList||new $p(t)}function $p(t){this._node=t,this._names=Ap(t.getAttribute("class")||"")}$p.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function zp(t,r){for(var o=mc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function Jv(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function nc(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:y,dispatch:x}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:y,enumerable:!0,configurable:!0},_:{value:x}})}nc.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function ux(t){return!t.ctrlKey&&!t.button}function cx(){return this.parentNode}function dx(t,r){return r??{x:t.x,y:t.y}}function fx(){return navigator.maxTouchPoints||"ontouchstart"in this}function Vp(){var t=ux,r=cx,o=dx,s=fx,a={},u=Yl("start","drag","end"),c=0,h,p,y,x,v=0;function m(N){N.on("mousedown.drag",_).filter(s).on("touchstart.drag",b).on("touchmove.drag",E,ax).on("touchend.drag touchcancel.drag",R).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(N,A){if(!(x||!t.call(this,N,A))){var $=w(this,r.call(this,N,A),N,A,"mouse");$&&(Xt(N.view).on("mousemove.drag",k,Jo).on("mouseup.drag",j,Jo),Hp(N.view),Du(N),y=!1,h=N.clientX,p=N.clientY,$("start",N))}}function k(N){if(Gi(N),!y){var A=N.clientX-h,$=N.clientY-p;y=A*A+$*$>v}a.mouse("drag",N)}function j(N){Xt(N.view).on("mousemove.drag mouseup.drag",null),Bp(N.view,y),Gi(N),a.mouse("end",N)}function b(N,A){if(t.call(this,N,A)){var $=N.changedTouches,F=r.call(this,N,A),X=$.length,q,te;for(q=0;q>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?xl(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?xl(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=px.exec(t))?new Dt(r[1],r[2],r[3],1):(r=gx.exec(t))?new Dt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=mx.exec(t))?xl(r[1],r[2],r[3],r[4]):(r=yx.exec(t))?xl(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=vx.exec(t))?ph(r[1],r[2]/100,r[3]/100,1):(r=xx.exec(t))?ph(r[1],r[2]/100,r[3]/100,r[4]):ah.hasOwnProperty(t)?dh(ah[t]):t==="transparent"?new Dt(NaN,NaN,NaN,0):null}function dh(t){return new Dt(t>>16&255,t>>8&255,t&255,1)}function xl(t,r,o,s){return s<=0&&(t=r=o=NaN),new Dt(t,r,o,s)}function Sx(t){return t instanceof fs||(t=fi(t)),t?(t=t.rgb(),new Dt(t.r,t.g,t.b,t.opacity)):new Dt}function rc(t,r,o,s){return arguments.length===1?Sx(t):new Dt(t,r,o,s??1)}function Dt(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}yc(Dt,rc,Wp(fs,{brighter(t){return t=t==null?Al:Math.pow(Al,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?es:Math.pow(es,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Dt(ci(this.r),ci(this.g),ci(this.b),$l(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:fh,formatHex:fh,formatHex8:kx,formatRgb:hh,toString:hh}));function fh(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}`}function kx(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}${ui((isNaN(this.opacity)?1:this.opacity)*255)}`}function hh(){const t=$l(this.opacity);return`${t===1?"rgb(":"rgba("}${ci(this.r)}, ${ci(this.g)}, ${ci(this.b)}${t===1?")":`, ${t})`}`}function $l(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ci(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ui(t){return t=ci(t),(t<16?"0":"")+t.toString(16)}function ph(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new hn(t,r,o,s)}function Up(t){if(t instanceof hn)return new hn(t.h,t.s,t.l,t.opacity);if(t instanceof fs||(t=fi(t)),!t)return new hn;if(t instanceof hn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new hn(c,h,p,t.opacity)}function Nx(t,r,o,s){return arguments.length===1?Up(t):new hn(t,r,o,s??1)}function hn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}yc(hn,Nx,Wp(fs,{brighter(t){return t=t==null?Al:Math.pow(Al,t),new hn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?es:Math.pow(es,t),new hn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Dt(Ou(t>=240?t-240:t+120,a,s),Ou(t,a,s),Ou(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new hn(gh(this.h),wl(this.s),wl(this.l),$l(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 t=$l(this.opacity);return`${t===1?"hsl(":"hsla("}${gh(this.h)}, ${wl(this.s)*100}%, ${wl(this.l)*100}%${t===1?")":`, ${t})`}`}}));function gh(t){return t=(t||0)%360,t<0?t+360:t}function wl(t){return Math.max(0,Math.min(1,t||0))}function Ou(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const vc=t=>()=>t;function jx(t,r){return function(o){return t+o*r}}function bx(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function Ex(t){return(t=+t)==1?Yp:function(r,o){return o-r?bx(r,o,t):vc(isNaN(r)?o:r)}}function Yp(t,r){var o=r-t;return o?jx(t,o):vc(isNaN(t)?r:t)}const zl=(function t(r){var o=Ex(r);function s(a,u){var c=o((a=rc(a)).r,(u=rc(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),y=Yp(a.opacity,u.opacity);return function(x){return a.r=c(x),a.g=h(x),a.b=p(x),a.opacity=y(x),a+""}}return s.gamma=t,s})(1);function Cx(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:Rn(s,a)})),o=Fu.lastIndex;return o180?x+=360:x-y>180&&(y+=360),m.push({i:v.push(a(v)+"rotate(",null,s)-2,x:Rn(y,x)})):x&&v.push(a(v)+"rotate("+x+s)}function h(y,x,v,m){y!==x?m.push({i:v.push(a(v)+"skewX(",null,s)-2,x:Rn(y,x)}):x&&v.push(a(v)+"skewX("+x+s)}function p(y,x,v,m,_,k){if(y!==v||x!==m){var j=_.push(a(_)+"scale(",null,",",null,")");k.push({i:j-4,x:Rn(y,v)},{i:j-2,x:Rn(x,m)})}else(v!==1||m!==1)&&_.push(a(_)+"scale("+v+","+m+")")}return function(y,x){var v=[],m=[];return y=t(y),x=t(x),u(y.translateX,y.translateY,x.translateX,x.translateY,v,m),c(y.rotate,x.rotate,v,m),h(y.skewX,x.skewX,v,m),p(y.scaleX,y.scaleY,x.scaleX,x.scaleY,v,m),y=x=null,function(_){for(var k=-1,j=m.length,b;++k=0&&t._call.call(void 0,r),t=t._next;--Qi}function vh(){hi=(Ol=ns.now())+Gl,Qi=Go=0;try{Vx()}finally{Qi=0,Ux(),hi=0}}function Wx(){var t=ns.now(),r=t-Ol;r>Kp&&(Gl-=r,Ol=t)}function Ux(){for(var t,r=Dl,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:Dl=o);qo=t,sc(s)}function sc(t){if(!Qi){Go&&(Go=clearTimeout(Go));var r=t-hi;r>24?(t<1/0&&(Go=setTimeout(vh,t-ns.now()-Gl)),Yo&&(Yo=clearInterval(Yo))):(Yo||(Ol=ns.now(),Yo=setInterval(Wx,Kp)),Qi=1,Qp(vh))}}function xh(t,r,o){var s=new Fl;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Yx=Yl("start","end","cancel","interrupt"),Xx=[],Jp=0,wh=1,lc=2,Il=3,_h=4,ac=5,Rl=6;function ql(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;Gx(t,o,{name:r,index:s,group:a,on:Yx,tween:Xx,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:Jp})}function wc(t,r){var o=yn(t,r);if(o.state>Jp)throw new Error("too late; already scheduled");return o}function Ln(t,r){var o=yn(t,r);if(o.state>Il)throw new Error("too late; already running");return o}function yn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function Gx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=Zp(u,0,o.time);function u(y){o.state=wh,o.timer.restart(c,o.delay,o.time),o.delay<=y&&c(y-o.delay)}function c(y){var x,v,m,_;if(o.state!==wh)return p();for(x in s)if(_=s[x],_.name===o.name){if(_.state===Il)return xh(c);_.state===_h?(_.state=Rl,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete s[x]):+xlc&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function Nw(t,r,o){var s,a,u=kw(r)?wc:Ln;return function(){var c=u(this,t),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function jw(t,r){var o=this._id;return arguments.length<2?yn(this.node(),o).on.on(t):this.each(Nw(o,t,r))}function bw(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function Ew(){return this.on("end.remove",bw(this._id))}function Cw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=gc(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function Jw(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function rr(t,r,o){this.k=t,this.x=r,this.y=o}rr.prototype={constructor:rr,scale:function(t){return t===1?this:new rr(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new rr(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Kl=new rr(1,0,0);rg.prototype=rr.prototype;function rg(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Kl;return t.__zoom}function Hu(t){t.stopImmediatePropagation()}function Xo(t){t.preventDefault(),t.stopImmediatePropagation()}function e1(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function t1(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function Sh(){return this.__zoom||Kl}function n1(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function r1(){return navigator.maxTouchPoints||"ontouchstart"in this}function i1(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function ig(){var t=e1,r=t1,o=i1,s=n1,a=r1,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=Pl,y=Yl("start","zoom","end"),x,v,m,_=500,k=150,j=0,b=10;function E(C){C.property("__zoom",Sh).on("wheel.zoom",X,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",te).filter(a).on("touchstart.zoom",ee).on("touchmove.zoom",ne).on("touchend.zoom touchcancel.zoom",K).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(C,V,W,U){var M=C.selection?C.selection():C;M.property("__zoom",Sh),C!==M?A(C,V,W,U):M.interrupt().each(function(){$(this,arguments).event(U).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},E.scaleBy=function(C,V,W,U){E.scaleTo(C,function(){var M=this.__zoom.k,D=typeof V=="function"?V.apply(this,arguments):V;return M*D},W,U)},E.scaleTo=function(C,V,W,U){E.transform(C,function(){var M=r.apply(this,arguments),D=this.__zoom,H=W==null?N(M):typeof W=="function"?W.apply(this,arguments):W,I=D.invert(H),z=typeof V=="function"?V.apply(this,arguments):V;return o(w(R(D,z),H,I),M,c)},W,U)},E.translateBy=function(C,V,W,U){E.transform(C,function(){return o(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),r.apply(this,arguments),c)},null,U)},E.translateTo=function(C,V,W,U,M){E.transform(C,function(){var D=r.apply(this,arguments),H=this.__zoom,I=U==null?N(D):typeof U=="function"?U.apply(this,arguments):U;return o(Kl.translate(I[0],I[1]).scale(H.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),D,c)},U,M)};function R(C,V){return V=Math.max(u[0],Math.min(u[1],V)),V===C.k?C:new rr(V,C.x,C.y)}function w(C,V,W){var U=V[0]-W[0]*C.k,M=V[1]-W[1]*C.k;return U===C.x&&M===C.y?C:new rr(C.k,U,M)}function N(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function A(C,V,W,U){C.on("start.zoom",function(){$(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(U).end()}).tween("zoom",function(){var M=this,D=arguments,H=$(M,D).event(U),I=r.apply(M,D),z=W==null?N(I):typeof W=="function"?W.apply(M,D):W,ie=Math.max(I[1][0]-I[0][0],I[1][1]-I[0][1]),oe=M.__zoom,fe=typeof V=="function"?V.apply(M,D):V,he=p(oe.invert(z).concat(ie/oe.k),fe.invert(z).concat(ie/fe.k));return function(pe){if(pe===1)pe=fe;else{var Z=he(pe),se=ie/Z[2];pe=new rr(se,z[0]-Z[0]*se,z[1]-Z[1]*se)}H.zoom(null,pe)}})}function $(C,V,W){return!W&&C.__zooming||new F(C,V)}function F(C,V){this.that=C,this.args=V,this.active=0,this.sourceEvent=null,this.extent=r.apply(C,V),this.taps=0}F.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,V){return this.mouse&&C!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var V=Xt(this.that).datum();y.call(C,this.that,new Jw(C,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:y}),V)}};function X(C,...V){if(!t.apply(this,arguments))return;var W=$(this,V).event(C),U=this.__zoom,M=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,s.apply(this,arguments)))),D=fn(C);if(W.wheel)(W.mouse[0][0]!==D[0]||W.mouse[0][1]!==D[1])&&(W.mouse[1]=U.invert(W.mouse[0]=D)),clearTimeout(W.wheel);else{if(U.k===M)return;W.mouse=[D,U.invert(D)],Tl(this),W.start()}Xo(C),W.wheel=setTimeout(H,k),W.zoom("mouse",o(w(R(U,M),W.mouse[0],W.mouse[1]),W.extent,c));function H(){W.wheel=null,W.end()}}function q(C,...V){if(m||!t.apply(this,arguments))return;var W=C.currentTarget,U=$(this,V,!0).event(C),M=Xt(C.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",ie,!0),D=fn(C,W),H=C.clientX,I=C.clientY;Hp(C.view),Hu(C),U.mouse=[D,this.__zoom.invert(D)],Tl(this),U.start();function z(oe){if(Xo(oe),!U.moved){var fe=oe.clientX-H,he=oe.clientY-I;U.moved=fe*fe+he*he>j}U.event(oe).zoom("mouse",o(w(U.that.__zoom,U.mouse[0]=fn(oe,W),U.mouse[1]),U.extent,c))}function ie(oe){M.on("mousemove.zoom mouseup.zoom",null),Bp(oe.view,U.moved),Xo(oe),U.event(oe).end()}}function te(C,...V){if(t.apply(this,arguments)){var W=this.__zoom,U=fn(C.changedTouches?C.changedTouches[0]:C,this),M=W.invert(U),D=W.k*(C.shiftKey?.5:2),H=o(w(R(W,D),U,M),r.apply(this,V),c);Xo(C),h>0?Xt(this).transition().duration(h).call(A,H,U,C):Xt(this).call(E.transform,H,U,C)}}function ee(C,...V){if(t.apply(this,arguments)){var W=C.touches,U=W.length,M=$(this,V,C.changedTouches.length===U).event(C),D,H,I,z;for(Hu(C),H=0;H`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},rs=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],og=["Enter"," ","Escape"],sg={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Zi;(function(t){t.Strict="strict",t.Loose="loose"})(Zi||(Zi={}));var di;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(di||(di={}));var is;(function(t){t.Partial="partial",t.Full="full"})(is||(is={}));const lg={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Lr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Lr||(Lr={}));var os;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(os||(os={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const kh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function ag(t){return t===null?null:t?"valid":"invalid"}const ug=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,o1=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),Sc=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),hs=(t,r=[0,0])=>{const{width:o,height:s}=vn(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},s1=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):Sc(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,Ql(a,Hl(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?Zl(s):{x:0,y:0,width:0,height:0}},ps=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=Ql(o,Hl(a)),s=!0)}),s?Zl(o):{x:0,y:0,width:0,height:0}},kc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,y=r.width/a,x=r.height/a,v=[];for(const m of t.values()){const{measured:_,selectable:k=!0,hidden:j=!1}=m;if(c&&!k||j)continue;const b=_.width??m.width??m.initialWidth??0,E=_.height??m.height??m.initialHeight??0,{x:R,y:w}=m.internals.positionAbsolute,N=hg(h,p,y,x,R,w,b,E),A=b*E,$=u&&N>0;(!m.internals.handleBounds||$||N>=A||m.dragging)&&v.push(m)}return v},l1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function a1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=vn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function u1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const h=a1(t,c),p=ps(h),y=jc(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(y,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function cg({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),h=c.parentId?o.get(c.parentId):void 0,{x:p,y}=h?h.internals.positionAbsolute:{x:0,y:0},x=c.origin??s;let v=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",mn.error005());else{const{width:_,height:k}=vn(h);_&&k&&(v=[[p,y],[p+_,y+k]])}else h&&gi(c.extent)&&(v=[[c.extent[0][0]+p,c.extent[0][1]+y],[c.extent[1][0]+p,c.extent[1][1]+y]]);const m=gi(v)?pi(r,v,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",mn.error015())),{position:{x:m.x-p+(c.measured.width??0)*x[0],y:m.y-y+(c.measured.height??0)*x[1]},positionAbsolute:m}}async function c1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(m=>m.id)),c=[];for(const m of o){if(m.deletable===!1)continue;const _=u.has(m.id),k=!_&&m.parentId&&c.find(j=>j.id===m.parentId);(_||k)&&c.push(m)}const h=new Set(r.map(m=>m.id)),p=s.filter(m=>m.deletable!==!1),x=l1(c,p);for(const m of p)h.has(m.id)&&!x.find(k=>k.id===m.id)&&x.push(m);if(!a)return{edges:x,nodes:c};const v=await a({nodes:c,edges:x});return typeof v=="boolean"?v?{edges:x,nodes:c}:{edges:[],nodes:[]}:v}const Ji=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),pi=(t={x:0,y:0},r,o)=>({x:Ji(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:Ji(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function dg(t,r,o){const{width:s,height:a}=vn(o),{x:u,y:c}=o.internals.positionAbsolute;return pi(t,[[u,c],[u+s,c+a]],r)}const Nh=(t,r,o)=>to?-Ji(Math.abs(t-o),1,r)/r:0,Nc=(t,r,o=15,s=40)=>{const a=Nh(t.x,s,r.width-s)*o,u=Nh(t.y,s,r.height-s)*o;return[a,u]},Ql=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),uc=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),Zl=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),ss=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=Sc(t)?t.internals.positionAbsolute:hs(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},Hl=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=Sc(t)?t.internals.positionAbsolute:hs(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},fg=(t,r)=>Zl(Ql(uc(t),uc(r))),hg=(t,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),y=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*y)},Bl=(t,r)=>hg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),jh=t=>pn(t.width)&&pn(t.height)&&pn(t.x)&&pn(t.y),pn=t=>!isNaN(t)&&isFinite(t),pg=(t,r)=>(o,s)=>{},gs=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),ms=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(t-o)/a,y:(r-s)/a};return u?gs(h,c):h},eo=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Yi(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function d1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Yi(t,o),a=Yi(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Yi(t.top??t.y??0,o),a=Yi(t.bottom??t.y??0,o),u=Yi(t.left??t.x??0,r),c=Yi(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function f1(t,r,o,s,a,u){const{x:c,y:h}=eo(t,[r,o,s]),{x:p,y}=eo({x:t.x+t.width,y:t.y+t.height},[r,o,s]),x=a-p,v=u-y;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(x),bottom:Math.floor(v)}}const jc=(t,r,o,s,a,u)=>{const c=d1(u,r,o),h=(r-c.x)/t.width,p=(o-c.y)/t.height,y=Math.min(h,p),x=Ji(y,s,a),v=t.x+t.width/2,m=t.y+t.height/2,_=r/2-v*x,k=o/2-m*x,j=f1(t,_,k,x,r,o),b={left:Math.min(j.left-c.left,0),top:Math.min(j.top-c.top,0),right:Math.min(j.right-c.right,0),bottom:Math.min(j.bottom-c.bottom,0)};return{x:_-b.left+b.right,y:k-b.top+b.bottom,zoom:x}},ls=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function gi(t){return t!=null&&t!=="parent"}function vn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function gg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function mg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function bh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function h1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function p1(t){return{...sg,...t||{}}}function Qo(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=gn(t),h=ms({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y}=o?gs(h,r):h;return{xSnapped:p,ySnapped:y,...h}}const bc=t=>({width:t.offsetWidth,height:t.offsetHeight}),yg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},g1=["INPUT","SELECT","TEXTAREA"];function vg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:g1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const xg=t=>"clientX"in t,gn=(t,r)=>{var u,c;const o=xg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},Eh=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...bc(c)}})};function wg({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=t*.125+a*.375+c*.375+o*.125,y=r*.125+u*.375+h*.375+s*.125,x=Math.abs(p-t),v=Math.abs(y-r);return[p,y,x,v]}function kl(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function Ch({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case Se.Left:return[r-kl(r-s,u),o];case Se.Right:return[r+kl(s-r,u),o];case Se.Top:return[r,o-kl(o-a,u)];case Se.Bottom:return[r,o+kl(a-o,u)]}}function _g({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top,curvature:c=.25}){const[h,p]=Ch({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[y,x]=Ch({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[v,m,_,k]=wg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:y,targetControlY:x});return[`M${t},${r} C${h},${p} ${y},${x} ${s},${a}`,v,m,_,k]}function Sg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const v1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,x1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),w1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",mn.error006()),r;const s=o.getEdgeId||v1;let a;return ug(t)?a={...t}:a={...t,id:s(t)},x1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function kg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=Sg({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,h]}const Mh={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},_1=({source:t,sourcePosition:r=Se.Bottom,target:o})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function S1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:s=Se.Top,center:a,offset:u,stepPosition:c}){const h=Mh[r],p=Mh[s],y={x:t.x+h.x*u,y:t.y+h.y*u},x={x:o.x+p.x*u,y:o.y+p.y*u},v=_1({source:y,sourcePosition:r,target:x}),m=v.x!==0?"x":"y",_=v[m];let k=[],j,b;const E={x:0,y:0},R={x:0,y:0},[,,w,N]=Sg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[m]*p[m]===-1){m==="x"?(j=a.x??y.x+(x.x-y.x)*c,b=a.y??(y.y+x.y)/2):(j=a.x??(y.x+x.x)/2,b=a.y??y.y+(x.y-y.y)*c);const X=[{x:j,y:y.y},{x:j,y:x.y}],q=[{x:y.x,y:b},{x:x.x,y:b}];h[m]===_?k=m==="x"?X:q:k=m==="x"?q:X}else{const X=[{x:y.x,y:x.y}],q=[{x:x.x,y:y.y}];if(m==="x"?k=h.x===_?q:X:k=h.y===_?X:q,r===s){const C=Math.abs(t[m]-o[m]);if(C<=u){const V=Math.min(u-1,u-C);h[m]===_?E[m]=(y[m]>t[m]?-1:1)*V:R[m]=(x[m]>o[m]?-1:1)*V}}if(r!==s){const C=m==="x"?"y":"x",V=h[m]===p[C],W=y[C]>x[C],U=y[C]=K?(j=(te.x+ee.x)/2,b=k[0].y):(j=k[0].x,b=(te.y+ee.y)/2)}const A={x:y.x+E.x,y:y.y+E.y},$={x:x.x+R.x,y:x.y+R.y};return[[t,...A.x!==k[0].x||A.y!==k[0].y?[A]:[],...k,...$.x!==k[k.length-1].x||$.y!==k[k.length-1].y?[$]:[],o],j,b,w,N]}function k1(t,r,o,s){const a=Math.min(Ph(t,r)/2,Ph(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const y=t.xo.id===r):t[0])||null}function cc(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function j1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const y=cc(p,r);u.has(y)||(c.push({id:y,color:p.color||o,...p}),u.add(y))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const Ng=1e3,b1=10,Ec={nodeOrigin:[0,0],nodeExtent:rs,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},E1={...Ec,checkEquality:!0};function Cc(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function C1(t,r,o){const s=Cc(Ec,o);for(const a of t.values())if(a.parentId)Pc(a,t,r,s);else{const u=hs(a,s.nodeOrigin),c=gi(a.extent)?a.extent:s.nodeExtent,h=pi(u,c,vn(a));a.internals.positionAbsolute=h}}function M1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function Mc(t){return t==="manual"}function dc(t,r,o,s={}){var x,v;const a=Cc(E1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!Mc(a.zIndexMode)?Ng:0;let p=t.length>0,y=!1;r.clear(),o.clear();for(const m of t){let _=c.get(m.id);if(a.checkEquality&&m===(_==null?void 0:_.internals.userNode))r.set(m.id,_);else{const k=hs(m,a.nodeOrigin),j=gi(m.extent)?m.extent:a.nodeExtent,b=pi(k,j,vn(m));_={...a.defaults,...m,measured:{width:(x=m.measured)==null?void 0:x.width,height:(v=m.measured)==null?void 0:v.height},internals:{positionAbsolute:b,handleBounds:M1(m,_),z:jg(m,h,a.zIndexMode),userNode:m}},r.set(m.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),m.parentId&&Pc(_,r,o,s,u),y||(y=m.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:y}}function P1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function Pc(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=Cc(Ec,s),y=t.parentId,x=r.get(y);if(!x){console.warn(`Parent node ${y} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}P1(t,o),a&&!x.parentId&&x.internals.rootParentIndex===void 0&&p==="auto"&&(x.internals.rootParentIndex=++a.i,x.internals.z=x.internals.z+a.i*b1),a&&x.internals.rootParentIndex!==void 0&&(a.i=x.internals.rootParentIndex);const v=u&&!Mc(p)?Ng:0,{x:m,y:_,z:k}=I1(t,x,c,h,v,p),{positionAbsolute:j}=t.internals,b=m!==j.x||_!==j.y;(b||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:b?{x:m,y:_}:j,z:k}})}function jg(t,r,o){const s=pn(t.zIndex)?t.zIndex:0;return Mc(o)?s:s+(t.selected?r:0)}function I1(t,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=vn(t),y=hs(t,o),x=gi(t.extent)?pi(y,t.extent,p):y;let v=pi({x:c+x.x,y:h+x.y},s,p);t.extent==="parent"&&(v=dg(v,p,r));const m=jg(t,a,u),_=r.internals.z??0;return{x:v.x,y:v.y,z:_>=m?_+1:m}}function Ic(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const y=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??ss(p),x=fg(y,h.rect);u.set(h.parentId,{expandedRect:x,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},y)=>{var w;const x=p.internals.positionAbsolute,v=vn(p),m=p.origin??s,_=h.x0||k>0||E||R)&&(a.push({id:y,type:"position",position:{x:p.position.x-_+E,y:p.position.y-k+R}}),(w=o.get(y))==null||w.forEach(N=>{t.some(A=>A.id===N.id)||a.push({id:N.id,type:"position",position:{x:N.position.x+_,y:N.position.y+k}})})),(v.width0){const _=Ic(m,r,o,a);y.push(..._)}return{changes:y,updatedInternals:p}}async function T1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Lh(t,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${t}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${t}-${u}`;const y=s.get(c)||new Map;s.set(c,y.set(o,r))}}function bg(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},y=`${a}-${c}--${u}-${h}`,x=`${u}-${h}--${a}-${c}`;Lh("source",p,x,t,a,c),Lh("target",p,y,t,u,h),r.set(s.id,s)}}function Eg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:Eg(o,r):!1}function Ah(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function L1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!Eg(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function Bu({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[y,x]of r){const v=(c=o.get(y))==null?void 0:c.internals.userNode;v&&a.push({...v,position:x.position,dragging:s})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function A1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=gs(u,r);return{x:c.x-u.x,y:c.y-u.y}}function $1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,y={x:0,y:0},x=null,v=!1,m=null,_=!1,k=!1,j=null;function b({noDragClassName:R,handleSelector:w,domNode:N,isSelectable:A,nodeId:$,nodeClickDistance:F=0}){m=Xt(N);function X({x:ne,y:K}){const{nodeLookup:C,nodeExtent:V,snapGrid:W,snapToGrid:U,nodeOrigin:M,onNodeDrag:D,onSelectionDrag:H,onError:I,updateNodePositions:z}=r();u={x:ne,y:K};let ie=!1;const oe=h.size>1,fe=oe&&V?uc(ps(h)):null,he=oe&&U?A1({dragItems:h,snapGrid:W,x:ne,y:K}):null;for(const[pe,Z]of h){if(!C.has(pe))continue;let se={x:ne-Z.distance.x,y:K-Z.distance.y};U&&(se=he?{x:Math.round(se.x+he.x),y:Math.round(se.y+he.y)}:gs(se,W));let me=null;if(oe&&V&&!Z.extent&&fe){const{positionAbsolute:re}=Z.internals,Ne=re.x-fe.x+V[0][0],Me=re.x+Z.measured.width-fe.x2+V[1][0],Te=re.y-fe.y+V[0][1],$e=re.y+Z.measured.height-fe.y2+V[1][1];me=[[Ne,Te],[Me,$e]]}const{position:ke,positionAbsolute:ve}=cg({nodeId:pe,nextPosition:se,nodeLookup:C,nodeExtent:me||V,nodeOrigin:M,onError:I});ie=ie||Z.position.x!==ke.x||Z.position.y!==ke.y,Z.position=ke,Z.internals.positionAbsolute=ve}if(k=k||ie,!!ie&&(z(h,!0),j&&(s||D||!$&&H))){const[pe,Z]=Bu({nodeId:$,dragItems:h,nodeLookup:C});s==null||s(j,h,pe,Z),D==null||D(j,pe,Z),$||H==null||H(j,Z)}}async function q(){if(!x)return;const{transform:ne,panBy:K,autoPanSpeed:C,autoPanOnNodeDrag:V}=r();if(!V){p=!1,cancelAnimationFrame(c);return}const[W,U]=Nc(y,x,C);(W!==0||U!==0)&&(u.x=(u.x??0)-W/ne[2],u.y=(u.y??0)-U/ne[2],await K({x:W,y:U})&&X(u)),c=requestAnimationFrame(q)}function te(ne){var oe;const{nodeLookup:K,multiSelectionActive:C,nodesDraggable:V,transform:W,snapGrid:U,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:H,onSelectionDragStart:I,unselectNodesAndEdges:z}=r();v=!0,(!D||!A)&&!C&&$&&((oe=K.get($))!=null&&oe.selected||z()),A&&D&&$&&(t==null||t($));const ie=Qo(ne.sourceEvent,{transform:W,snapGrid:U,snapToGrid:M,containerBounds:x});if(u=ie,h=L1(K,V,ie,$),h.size>0&&(o||H||!$&&I)){const[fe,he]=Bu({nodeId:$,dragItems:h,nodeLookup:K});o==null||o(ne.sourceEvent,h,fe,he),H==null||H(ne.sourceEvent,fe,he),$||I==null||I(ne.sourceEvent,he)}}const ee=Vp().clickDistance(F).on("start",ne=>{const{domNode:K,nodeDragThreshold:C,transform:V,snapGrid:W,snapToGrid:U}=r();x=(K==null?void 0:K.getBoundingClientRect())||null,_=!1,k=!1,j=ne.sourceEvent,C===0&&te(ne),u=Qo(ne.sourceEvent,{transform:V,snapGrid:W,snapToGrid:U,containerBounds:x}),y=gn(ne.sourceEvent,x)}).on("drag",ne=>{const{autoPanOnNodeDrag:K,transform:C,snapGrid:V,snapToGrid:W,nodeDragThreshold:U,nodeLookup:M}=r(),D=Qo(ne.sourceEvent,{transform:C,snapGrid:V,snapToGrid:W,containerBounds:x});if(j=ne.sourceEvent,(ne.sourceEvent.type==="touchmove"&&ne.sourceEvent.touches.length>1||$&&!M.has($))&&(_=!0),!_){if(!p&&K&&v&&(p=!0,q()),!v){const H=gn(ne.sourceEvent,x),I=H.x-y.x,z=H.y-y.y;Math.sqrt(I*I+z*z)>U&&te(ne)}(u.x!==D.xSnapped||u.y!==D.ySnapped)&&h&&v&&(y=gn(ne.sourceEvent,x),X(D))}}).on("end",ne=>{if(!v||_){_&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,v=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:K,updateNodePositions:C,onNodeDragStop:V,onSelectionDragStop:W}=r();if(k&&(C(h,!1),k=!1),a||V||!$&&W){const[U,M]=Bu({nodeId:$,dragItems:h,nodeLookup:K,dragging:!1});a==null||a(ne.sourceEvent,h,U,M),V==null||V(ne.sourceEvent,U,M),$||W==null||W(ne.sourceEvent,M)}}}).filter(ne=>{const K=ne.target;return!ne.button&&(!R||!Ah(K,`.${R}`,N))&&(!w||Ah(K,w,N))});m.call(ee)}function E(){m==null||m.on(".drag",null)}return{update:b,destroy:E}}function z1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())Bl(a,ss(u))>0&&s.push(u);return s}const D1=250;function O1(t,r,o,s){var h,p;let a=[],u=1/0;const c=z1(t,o,r+D1);for(const y of c){const x=[...((h=y.internals.handleBounds)==null?void 0:h.source)??[],...((p=y.internals.handleBounds)==null?void 0:p.target)??[]];for(const v of x){if(s.nodeId===v.nodeId&&s.type===v.type&&s.id===v.id)continue;const{x:m,y:_}=mi(y,v,v.position,!0),k=Math.sqrt(Math.pow(m-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const y=s.type==="source"?"target":"source";return a.find(x=>x.type===y)??a[0]}return a[0]}function Cg(t,r,o,s,a,u=!1){var y,x,v;const c=s.get(t);if(!c)return null;const h=a==="strict"?(y=c.internals.handleBounds)==null?void 0:y[r]:[...((x=c.internals.handleBounds)==null?void 0:x.source)??[],...((v=c.internals.handleBounds)==null?void 0:v.target)??[]],p=(o?h==null?void 0:h.find(m=>m.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...mi(c,p,p.position,!0)}:p}function Mg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function F1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const Pg=()=>!0;function H1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:y,autoPanOnConnect:x,flowId:v,panBy:m,cancelConnection:_,onConnectStart:k,onConnect:j,onConnectEnd:b,isValidConnection:E=Pg,onReconnectEnd:R,updateConnection:w,getTransform:N,getFromHandle:A,autoPanSpeed:$,dragThreshold:F=1,handleDomNode:X}){const q=yg(t.target);let te=0,ee;const{x:ne,y:K}=gn(t),C=Mg(u,X),V=h==null?void 0:h.getBoundingClientRect();let W=!1;if(!V||!C)return;const U=Cg(a,C,s,p,r);if(!U)return;let M=gn(t,V),D=!1,H=null,I=!1,z=null;function ie(){if(!x||!V)return;const[ke,ve]=Nc(M,V,$);m({x:ke,y:ve}),te=requestAnimationFrame(ie)}const oe={...U,nodeId:a,type:C,position:U.position},fe=p.get(a);let pe={inProgress:!0,isValid:null,from:mi(fe,oe,Se.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:fe,to:M,toHandle:null,toPosition:kh[oe.position],toNode:null,pointer:M};function Z(){W=!0,w(pe),k==null||k(t,{nodeId:a,handleId:s,handleType:C})}F===0&&Z();function se(ke){if(!W){const{x:$e,y:st}=gn(ke),lt=$e-ne,at=st-K;if(!(lt*lt+at*at>F*F))return;Z()}if(!A()||!oe){me(ke);return}const ve=N();M=gn(ke,V),ee=O1(ms(M,ve,!1,[1,1]),o,p,oe),D||(ie(),D=!0);const re=Ig(ke,{handle:ee,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:E,doc:q,lib:y,flowId:v,nodeLookup:p});z=re.handleDomNode,H=re.connection,I=F1(!!ee,re.isValid);const Ne=p.get(a),Me=Ne?mi(Ne,oe,Se.Left,!0):pe.from,Te={...pe,from:Me,isValid:I,to:re.toHandle&&I?eo({x:re.toHandle.x,y:re.toHandle.y},ve):M,toHandle:re.toHandle,toPosition:I&&re.toHandle?re.toHandle.position:kh[oe.position],toNode:re.toHandle?p.get(re.toHandle.nodeId):null,pointer:M};w(Te),pe=Te}function me(ke){if(!("touches"in ke&&ke.touches.length>0)){if(W){(ee||z)&&H&&I&&(j==null||j(H));const{inProgress:ve,...re}=pe,Ne={...re,toPosition:pe.toHandle?pe.toPosition:null};b==null||b(ke,Ne),u&&(R==null||R(ke,Ne))}_(),cancelAnimationFrame(te),D=!1,I=!1,H=null,z=null,q.removeEventListener("mousemove",se),q.removeEventListener("mouseup",me),q.removeEventListener("touchmove",se),q.removeEventListener("touchend",me)}}q.addEventListener("mousemove",se),q.addEventListener("mouseup",me),q.addEventListener("touchmove",se),q.addEventListener("touchend",me)}function Ig(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:y=Pg,nodeLookup:x}){const v=u==="target",m=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=gn(t),j=c.elementFromPoint(_,k),b=j!=null&&j.classList.contains(`${h}-flow__handle`)?j:m,E={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const R=Mg(void 0,b),w=b.getAttribute("data-nodeid"),N=b.getAttribute("data-handleid"),A=b.classList.contains("connectable"),$=b.classList.contains("connectableend");if(!w||!R)return E;const F={source:v?w:s,sourceHandle:v?N:a,target:v?s:w,targetHandle:v?a:N};E.connection=F;const q=A&&$&&(o===Zi.Strict?v&&R==="source"||!v&&R==="target":w!==s||N!==a);E.isValid=q&&y(F),E.toHandle=Cg(w,R,N,x,o,!0)}return E}const fc={onPointerDown:H1,isValid:Ig};function B1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Xt(t);function u({translateExtent:h,width:p,height:y,zoomStep:x=1,pannable:v=!0,zoomable:m=!0,inversePan:_=!1}){const k=w=>{if(w.sourceEvent.type!=="wheel"||!r)return;const N=o(),A=w.sourceEvent.ctrlKey&&ls()?10:1,$=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*x,F=N[2]*Math.pow(2,$*A);r.scaleTo(F)};let j=[0,0];const b=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(j=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},E=w=>{const N=o();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!r)return;const A=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],$=[A[0]-j[0],A[1]-j[1]];j=A;const F=s()*Math.max(N[2],Math.log(N[2]))*(_?-1:1),X={x:N[0]-$[0]*F,y:N[1]-$[1]*F},q=[[0,0],[p,y]];r.setViewportConstrained({x:X.x,y:X.y,zoom:N[2]},q,h)},R=ig().on("start",b).on("zoom",v?E:null).on("zoom.wheel",m?k:null);a.call(R,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:fn}}const Jl=t=>({x:t.x,y:t.y,zoom:t.k}),Vu=({x:t,y:r,zoom:o})=>Kl.translate(t,r).scale(o),Rr=(t,r)=>t.target.closest(`.${r}`),Rg=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),V1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Wu=(t,r=0,o=V1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Tg=t=>{const r=t.ctrlKey&&ls()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function W1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:y}){return x=>{if(Rr(x,r))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const v=o.property("__zoom").k||1;if(x.ctrlKey&&c){const b=fn(x),E=Tg(x),R=v*Math.pow(2,E);s.scaleTo(o,R,b,x);return}const m=x.deltaMode===1?20:1;let _=a===di.Vertical?0:x.deltaX*m,k=a===di.Horizontal?0:x.deltaY*m;!ls()&&x.shiftKey&&a!==di.Vertical&&(_=x.deltaY*m,k=0),s.translateBy(o,-(_/v)*u,-(k/v)*u,{internal:!0});const j=Jl(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(x,j):(t.isPanScrolling=!0,h==null||h(x,j)),t.panScrollTimeout=setTimeout(()=>{y==null||y(x,j),t.isPanScrolling=!1},150)}}function U1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=Rr(s,t);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function Y1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=Jl(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function X1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;t.usedRightMouseButton=!!(o&&Rg(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,Jl(u.transform)))}}function G1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&Rg(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const p=Jl(c.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function q1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:y,lib:x,connectionInProgress:v}){return m=>{var E;const _=r||o,k=s&&m.ctrlKey,j=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(Rr(m,`${x}-flow__node`)||Rr(m,`${x}-flow__edge`)||Rr(m,`${x}-flow__selection`)||Rr(m,`${x}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!c&&!s||h||v&&!j||Rr(m,p)&&j||Rr(m,y)&&(!j||u&&j&&!r)||!s&&m.ctrlKey&&j)return!1;if(!s&&m.type==="touchstart"&&((E=m.touches)==null?void 0:E.length)>1)return m.preventDefault(),!1;if(!_&&!u&&!k&&j||!a&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(a)&&!a.includes(m.button)&&m.type==="mousedown")return!1;const b=Array.isArray(a)&&a.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||j||t)&&b}}function K1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const y={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=t.getBoundingClientRect();let v=[[0,0],[x.width,x.height]];const m=typeof ResizeObserver<"u"?new ResizeObserver(K=>{const C=K[0];C&&(v=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;m==null||m.observe(t);const _=ig().extent(()=>v).scaleExtent([r,o]).translateExtent(s),k=Xt(t).call(_);N({x:a.x,y:a.y,zoom:Ji(a.zoom,r,o)},[[0,0],[x.width,x.height]],s);const j=k.on("wheel.zoom"),b=k.on("dblclick.zoom");_.wheelDelta(Tg);async function E(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Pl).transform(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function R({noWheelClassName:K,noPanClassName:C,onPaneContextMenu:V,userSelectionActive:W,panOnScroll:U,panOnDrag:M,panOnScrollMode:D,panOnScrollSpeed:H,preventScrolling:I,zoomOnPinch:z,zoomOnScroll:ie,zoomOnDoubleClick:oe,panActivationKeyPressed:fe=!1,zoomActivationKeyPressed:he,lib:pe,onTransformChange:Z,connectionInProgress:se,paneClickDistance:me,selectionOnDrag:ke}){W&&!y.isZoomingOrPanning&&w();const ve=U&&!he&&!W;_.clickDistance(ke?1/0:!pn(me)||me<0?0:me);const re=ve?W1({zoomPanValues:y,noWheelClassName:K,d3Selection:k,d3Zoom:_,panOnScrollMode:D,panOnScrollSpeed:H,zoomOnPinch:z,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):U1({noWheelClassName:K,preventScrolling:I,d3ZoomHandler:j});k.on("wheel.zoom",re,{passive:!1});const Ne=Y1({zoomPanValues:y,onDraggingChange:p,onPanZoomStart:c});_.on("start",Ne);const Me=X1({zoomPanValues:y,panOnDrag:M,onPaneContextMenu:!!V,onPanZoom:u,onTransformChange:Z});_.on("zoom",Me);const Te=G1({zoomPanValues:y,panOnDrag:M,panOnScroll:U,onPaneContextMenu:V,onPanZoomEnd:h,onDraggingChange:p});_.on("end",Te);const $e=q1({panActivationKeyPressed:fe,zoomActivationKeyPressed:he,panOnDrag:M,zoomOnScroll:ie,panOnScroll:U,zoomOnDoubleClick:oe,zoomOnPinch:z,userSelectionActive:W,noPanClassName:C,noWheelClassName:K,lib:pe,connectionInProgress:se});_.filter($e),oe?k.on("dblclick.zoom",b):k.on("dblclick.zoom",null)}function w(){_.on("zoom",null)}async function N(K,C,V){const W=Vu(K),U=_==null?void 0:_.constrain()(W,C,V);return U&&await E(U),U}async function A(K,C){const V=Vu(K);return await E(V,C),V}function $(K){if(k){const C=Vu(K),V=k.property("__zoom");(V.k!==K.zoom||V.x!==K.x||V.y!==K.y)&&(_==null||_.transform(k,C,null,{sync:!0}))}}function F(){const K=k?rg(k.node()):{x:0,y:0,k:1};return{x:K.x,y:K.y,zoom:K.k}}async function X(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Pl).scaleTo(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}async function q(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Pl).scaleBy(Wu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function te(K){_==null||_.scaleExtent(K)}function ee(K){_==null||_.translateExtent(K)}function ne(K){const C=!pn(K)||K<0?0:K;_==null||_.clickDistance(C)}return{update:R,destroy:w,setViewport:A,setViewportConstrained:N,getViewport:F,scaleTo:X,scaleBy:q,setScaleExtent:te,setTranslateExtent:ee,syncViewport:$,setClickDistance:ne}}var to;(function(t){t.Line="line",t.Handle="handle"})(to||(to={}));function Q1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function $h(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function Pr(t,r){return Math.max(0,r-t)}function Ir(t,r){return Math.max(0,t-r)}function Nl(t,r,o){return Math.max(0,r-t,t-o)}function zh(t,r){return t?!r:r}function Z1(t,r,o,s,a,u,c,h){let{affectsX:p,affectsY:y}=r;const{isHorizontal:x,isVertical:v}=r,m=x&&v,{xSnapped:_,ySnapped:k}=o,{minWidth:j,maxWidth:b,minHeight:E,maxHeight:R}=s,{x:w,y:N,width:A,height:$,aspectRatio:F}=t;let X=Math.floor(x?_-t.pointerX:0),q=Math.floor(v?k-t.pointerY:0);const te=A+(p?-X:X),ee=$+(y?-q:q),ne=-u[0]*A,K=-u[1]*$;let C=Nl(te,j,b),V=Nl(ee,E,R);if(c){let M=0,D=0;p&&X<0?M=Pr(w+X+ne,c[0][0]):!p&&X>0&&(M=Ir(w+te+ne,c[1][0])),y&&q<0?D=Pr(N+q+K,c[0][1]):!y&&q>0&&(D=Ir(N+ee+K,c[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(h){let M=0,D=0;p&&X>0?M=Ir(w+X,h[0][0]):!p&&X<0&&(M=Pr(w+te,h[1][0])),y&&q>0?D=Ir(N+q,h[0][1]):!y&&q<0&&(D=Pr(N+ee,h[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(a){if(x){const M=Nl(te/F,E,R)*F;if(C=Math.max(C,M),c){let D=0;!p&&!y||p&&!y&&m?D=Ir(N+K+te/F,c[1][1])*F:D=Pr(N+K+(p?X:-X)/F,c[0][1])*F,C=Math.max(C,D)}if(h){let D=0;!p&&!y||p&&!y&&m?D=Pr(N+te/F,h[1][1])*F:D=Ir(N+(p?X:-X)/F,h[0][1])*F,C=Math.max(C,D)}}if(v){const M=Nl(ee*F,j,b)/F;if(V=Math.max(V,M),c){let D=0;!p&&!y||y&&!p&&m?D=Ir(w+ee*F+ne,c[1][0])/F:D=Pr(w+(y?q:-q)*F+ne,c[0][0])/F,V=Math.max(V,D)}if(h){let D=0;!p&&!y||y&&!p&&m?D=Pr(w+ee*F,h[1][0])/F:D=Ir(w+(y?q:-q)*F,h[0][0])/F,V=Math.max(V,D)}}}q=q+(q<0?V:-V),X=X+(X<0?C:-C),a&&(m?te>ee*F?q=(zh(p,y)?-X:X)/F:X=(zh(p,y)?-q:q)*F:x?(q=X/F,y=p):(X=q*F,p=y));const W=p?w+X:w,U=y?N+q:N;return{width:A+(p?-X:X),height:$+(y?-q:q),x:u[0]*X*(p?-1:1)+W,y:u[1]*q*(y?-1:1)+U}}const Lg={width:0,height:0,x:0,y:0},J1={...Lg,pointerX:0,pointerY:0,aspectRatio:1};function e_(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function t_({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Xt(t);let c={controlDirection:$h("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:y,boundaries:x,keepAspectRatio:v,resizeDirection:m,onResizeStart:_,onResize:k,onResizeEnd:j,shouldResize:b}){let E={...Lg},R={...J1};c={boundaries:x,resizeDirection:m,keepAspectRatio:v,controlDirection:$h(y)};let w,N=null,A=[],$,F,X,q=!1;const te=Vp().on("start",ee=>{const{nodeLookup:ne,transform:K,snapGrid:C,snapToGrid:V,nodeOrigin:W,paneDomNode:U}=o();if(w=ne.get(r),!w)return;N=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:D}=Qo(ee.sourceEvent,{transform:K,snapGrid:C,snapToGrid:V,containerBounds:N});E={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},R={...E,pointerX:M,pointerY:D,aspectRatio:E.width/E.height},$=void 0,F=gi(w.extent)?w.extent:void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&($=ne.get(w.parentId)),$&&w.extent==="parent"&&(F=[[0,0],[$.measured.width,$.measured.height]]),A=[],X=void 0;for(const[H,I]of ne)if(I.parentId===r&&(A.push({id:H,position:{...I.position},extent:I.extent}),I.extent==="parent"||I.expandParent)){const z=e_(I,w,I.origin??W);X?X=[[Math.min(z[0][0],X[0][0]),Math.min(z[0][1],X[0][1])],[Math.max(z[1][0],X[1][0]),Math.max(z[1][1],X[1][1])]]:X=z}_==null||_(ee,{...E})}).on("drag",ee=>{const{transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V}=o(),W=Qo(ee.sourceEvent,{transform:ne,snapGrid:K,snapToGrid:C,containerBounds:N}),U=[];if(!w)return;const{x:M,y:D,width:H,height:I}=E,z={},ie=w.origin??V,{width:oe,height:fe,x:he,y:pe}=Z1(R,c.controlDirection,W,c.boundaries,c.keepAspectRatio,ie,F,X),Z=oe!==H,se=fe!==I,me=he!==M&&Z,ke=pe!==D&&se;if(!me&&!ke&&!Z&&!se)return;if((me||ke||ie[0]===1||ie[1]===1)&&(z.x=me?he:E.x,z.y=ke?pe:E.y,E.x=z.x,E.y=z.y,A.length>0)){const Me=he-M,Te=pe-D;for(const $e of A)$e.position={x:$e.position.x-Me+ie[0]*(oe-H),y:$e.position.y-Te+ie[1]*(fe-I)},U.push($e)}if((Z||se)&&(z.width=Z&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:E.width,z.height=se&&(!c.resizeDirection||c.resizeDirection==="vertical")?fe:E.height,E.width=z.width,E.height=z.height),$&&w.expandParent){const Me=ie[0]*(z.width??0);z.x&&z.x{q&&(j==null||j(ee,{...E}),a==null||a({...E}),q=!1)});u.call(te)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Uu={exports:{}},Yu={},Xu={exports:{}},Gu={};/** +`+g.stack}return{value:e,source:n,stack:f,digest:null}}function iu(e,n,i){return{value:e,source:null,stack:i??null,digest:n??null}}function ou(e,n){try{console.error(n.value)}catch(i){setTimeout(function(){throw i})}}var Iy=typeof WeakMap=="function"?WeakMap:Map;function sf(e,n,i){i=Jn(-1,i),i.tag=3,i.payload={element:null};var l=n.value;return i.callback=function(){rl||(rl=!0,wu=l),ou(e,n)},i}function lf(e,n,i){i=Jn(-1,i),i.tag=3;var l=e.type.getDerivedStateFromError;if(typeof l=="function"){var f=n.value;i.payload=function(){return l(f)},i.callback=function(){ou(e,n)}}var g=e.stateNode;return g!==null&&typeof g.componentDidCatch=="function"&&(i.callback=function(){ou(e,n),typeof l!="function"&&(Nr===null?Nr=new Set([this]):Nr.add(this));var S=n.stack;this.componentDidCatch(n.value,{componentStack:S!==null?S:""})}),i}function af(e,n,i){var l=e.pingCache;if(l===null){l=e.pingCache=new Iy;var f=new Set;l.set(n,f)}else f=l.get(n),f===void 0&&(f=new Set,l.set(n,f));f.has(i)||(f.add(i),e=Uy.bind(null,e,n,i),n.then(e,e))}function uf(e){do{var n;if((n=e.tag===13)&&(n=e.memoizedState,n=n!==null?n.dehydrated!==null:!0),n)return e;e=e.return}while(e!==null);return null}function cf(e,n,i,l,f){return(e.mode&1)===0?(e===n?e.flags|=65536:(e.flags|=128,i.flags|=131072,i.flags&=-52805,i.tag===1&&(i.alternate===null?i.tag=17:(n=Jn(-1,1),n.tag=2,Sr(i,n,1))),i.lanes|=1),e):(e.flags|=65536,e.lanes=f,e)}var Ry=N.ReactCurrentOwner,Lt=!1;function Ct(e,n,i,l){n.child=e===null?Md(n,null,i,l):zi(n,e.child,i,l)}function df(e,n,i,l,f){i=i.render;var g=n.ref;return Oi(n,f),l=Ka(e,n,i,l,g,f),i=Qa(),e!==null&&!Lt?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~f,er(e,n,f)):(Xe&&i&&Ta(n),n.flags|=1,Ct(e,n,l,f),n.child)}function ff(e,n,i,l,f){if(e===null){var g=i.type;return typeof g=="function"&&!Eu(g)&&g.defaultProps===void 0&&i.compare===null&&i.defaultProps===void 0?(n.tag=15,n.type=g,hf(e,n,g,l,f)):(e=ul(i.type,null,l,n,n.mode,f),e.ref=n.ref,e.return=n,n.child=e)}if(g=e.child,(e.lanes&f)===0){var S=g.memoizedProps;if(i=i.compare,i=i!==null?i:No,i(S,l)&&e.ref===n.ref)return er(e,n,f)}return n.flags|=1,e=Cr(g,l),e.ref=n.ref,e.return=n,n.child=e}function hf(e,n,i,l,f){if(e!==null){var g=e.memoizedProps;if(No(g,l)&&e.ref===n.ref)if(Lt=!1,n.pendingProps=l=g,(e.lanes&f)!==0)(e.flags&131072)!==0&&(Lt=!0);else return n.lanes=e.lanes,er(e,n,f)}return su(e,n,i,l,f)}function pf(e,n,i){var l=n.pendingProps,f=l.children,g=e!==null?e.memoizedState:null;if(l.mode==="hidden")if((n.mode&1)===0)n.memoizedState={baseLanes:0,cachePool:null,transitions:null},Be(Vi,Yt),Yt|=i;else{if((i&1073741824)===0)return e=g!==null?g.baseLanes|i:i,n.lanes=n.childLanes=1073741824,n.memoizedState={baseLanes:e,cachePool:null,transitions:null},n.updateQueue=null,Be(Vi,Yt),Yt|=e,null;n.memoizedState={baseLanes:0,cachePool:null,transitions:null},l=g!==null?g.baseLanes:i,Be(Vi,Yt),Yt|=l}else g!==null?(l=g.baseLanes|i,n.memoizedState=null):l=i,Be(Vi,Yt),Yt|=l;return Ct(e,n,f,i),n.child}function gf(e,n){var i=n.ref;(e===null&&i!==null||e!==null&&e.ref!==i)&&(n.flags|=512,n.flags|=2097152)}function su(e,n,i,l,f){var g=Tt(i)?Qr:St.current;return g=Ti(n,g),Oi(n,f),i=Ka(e,n,i,l,g,f),l=Qa(),e!==null&&!Lt?(n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~f,er(e,n,f)):(Xe&&l&&Ta(n),n.flags|=1,Ct(e,n,i,f),n.child)}function mf(e,n,i,l,f){if(Tt(i)){var g=!0;Ls(n)}else g=!1;if(Oi(n,f),n.stateNode===null)Zs(e,n),rf(n,i,l),ru(n,i,l,f),l=!0;else if(e===null){var S=n.stateNode,T=n.memoizedProps;S.props=T;var O=S.context,J=i.contextType;typeof J=="object"&&J!==null?J=Zt(J):(J=Tt(i)?Qr:St.current,J=Ti(n,J));var ae=i.getDerivedStateFromProps,ue=typeof ae=="function"||typeof S.getSnapshotBeforeUpdate=="function";ue||typeof S.UNSAFE_componentWillReceiveProps!="function"&&typeof S.componentWillReceiveProps!="function"||(T!==l||O!==J)&&of(n,S,l,J),_r=!1;var le=n.memoizedState;S.state=le,Vs(n,l,S,f),O=n.memoizedState,T!==l||le!==O||Rt.current||_r?(typeof ae=="function"&&(nu(n,i,ae,l),O=n.memoizedState),(T=_r||nf(n,i,T,l,le,O,J))?(ue||typeof S.UNSAFE_componentWillMount!="function"&&typeof S.componentWillMount!="function"||(typeof S.componentWillMount=="function"&&S.componentWillMount(),typeof S.UNSAFE_componentWillMount=="function"&&S.UNSAFE_componentWillMount()),typeof S.componentDidMount=="function"&&(n.flags|=4194308)):(typeof S.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=l,n.memoizedState=O),S.props=l,S.state=O,S.context=J,l=T):(typeof S.componentDidMount=="function"&&(n.flags|=4194308),l=!1)}else{S=n.stateNode,Id(e,n),T=n.memoizedProps,J=n.type===n.elementType?T:an(n.type,T),S.props=J,ue=n.pendingProps,le=S.context,O=i.contextType,typeof O=="object"&&O!==null?O=Zt(O):(O=Tt(i)?Qr:St.current,O=Ti(n,O));var ge=i.getDerivedStateFromProps;(ae=typeof ge=="function"||typeof S.getSnapshotBeforeUpdate=="function")||typeof S.UNSAFE_componentWillReceiveProps!="function"&&typeof S.componentWillReceiveProps!="function"||(T!==ue||le!==O)&&of(n,S,l,O),_r=!1,le=n.memoizedState,S.state=le,Vs(n,l,S,f);var xe=n.memoizedState;T!==ue||le!==xe||Rt.current||_r?(typeof ge=="function"&&(nu(n,i,ge,l),xe=n.memoizedState),(J=_r||nf(n,i,J,l,le,xe,O)||!1)?(ae||typeof S.UNSAFE_componentWillUpdate!="function"&&typeof S.componentWillUpdate!="function"||(typeof S.componentWillUpdate=="function"&&S.componentWillUpdate(l,xe,O),typeof S.UNSAFE_componentWillUpdate=="function"&&S.UNSAFE_componentWillUpdate(l,xe,O)),typeof S.componentDidUpdate=="function"&&(n.flags|=4),typeof S.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof S.componentDidUpdate!="function"||T===e.memoizedProps&&le===e.memoizedState||(n.flags|=4),typeof S.getSnapshotBeforeUpdate!="function"||T===e.memoizedProps&&le===e.memoizedState||(n.flags|=1024),n.memoizedProps=l,n.memoizedState=xe),S.props=l,S.state=xe,S.context=O,l=J):(typeof S.componentDidUpdate!="function"||T===e.memoizedProps&&le===e.memoizedState||(n.flags|=4),typeof S.getSnapshotBeforeUpdate!="function"||T===e.memoizedProps&&le===e.memoizedState||(n.flags|=1024),l=!1)}return lu(e,n,i,l,g,f)}function lu(e,n,i,l,f,g){gf(e,n);var S=(n.flags&128)!==0;if(!l&&!S)return f&&wd(n,i,!1),er(e,n,g);l=n.stateNode,Ry.current=n;var T=S&&typeof i.getDerivedStateFromError!="function"?null:l.render();return n.flags|=1,e!==null&&S?(n.child=zi(n,e.child,null,g),n.child=zi(n,null,T,g)):Ct(e,n,T,g),n.memoizedState=l.state,f&&wd(n,i,!0),n.child}function yf(e){var n=e.stateNode;n.pendingContext?vd(e,n.pendingContext,n.pendingContext!==n.context):n.context&&vd(e,n.context,!1),Wa(e,n.containerInfo)}function vf(e,n,i,l,f){return $i(),za(f),n.flags|=256,Ct(e,n,i,l),n.child}var au={dehydrated:null,treeContext:null,retryLane:0};function uu(e){return{baseLanes:e,cachePool:null,transitions:null}}function xf(e,n,i){var l=n.pendingProps,f=qe.current,g=!1,S=(n.flags&128)!==0,T;if((T=S)||(T=e!==null&&e.memoizedState===null?!1:(f&2)!==0),T?(g=!0,n.flags&=-129):(e===null||e.memoizedState!==null)&&(f|=1),Be(qe,f&1),e===null)return $a(n),e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?((n.mode&1)===0?n.lanes=1:e.data==="$!"?n.lanes=8:n.lanes=1073741824,null):(S=l.children,e=l.fallback,g?(l=n.mode,g=n.child,S={mode:"hidden",children:S},(l&1)===0&&g!==null?(g.childLanes=0,g.pendingProps=S):g=cl(S,l,0,null),e=li(e,l,i,null),g.return=n,e.return=n,g.sibling=e,n.child=g,n.child.memoizedState=uu(i),n.memoizedState=au,e):cu(n,S));if(f=e.memoizedState,f!==null&&(T=f.dehydrated,T!==null))return Ty(e,n,S,l,T,f,i);if(g){g=l.fallback,S=n.mode,f=e.child,T=f.sibling;var O={mode:"hidden",children:l.children};return(S&1)===0&&n.child!==f?(l=n.child,l.childLanes=0,l.pendingProps=O,n.deletions=null):(l=Cr(f,O),l.subtreeFlags=f.subtreeFlags&14680064),T!==null?g=Cr(T,g):(g=li(g,S,i,null),g.flags|=2),g.return=n,l.return=n,l.sibling=g,n.child=l,l=g,g=n.child,S=e.child.memoizedState,S=S===null?uu(i):{baseLanes:S.baseLanes|i,cachePool:null,transitions:S.transitions},g.memoizedState=S,g.childLanes=e.childLanes&~i,n.memoizedState=au,l}return g=e.child,e=g.sibling,l=Cr(g,{mode:"visible",children:l.children}),(n.mode&1)===0&&(l.lanes=i),l.return=n,l.sibling=null,e!==null&&(i=n.deletions,i===null?(n.deletions=[e],n.flags|=16):i.push(e)),n.child=l,n.memoizedState=null,l}function cu(e,n){return n=cl({mode:"visible",children:n},e.mode,0,null),n.return=e,e.child=n}function Qs(e,n,i,l){return l!==null&&za(l),zi(n,e.child,null,i),e=cu(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Ty(e,n,i,l,f,g,S){if(i)return n.flags&256?(n.flags&=-257,l=iu(Error(o(422))),Qs(e,n,S,l)):n.memoizedState!==null?(n.child=e.child,n.flags|=128,null):(g=l.fallback,f=n.mode,l=cl({mode:"visible",children:l.children},f,0,null),g=li(g,f,S,null),g.flags|=2,l.return=n,g.return=n,l.sibling=g,n.child=l,(n.mode&1)!==0&&zi(n,e.child,null,S),n.child.memoizedState=uu(S),n.memoizedState=au,g);if((n.mode&1)===0)return Qs(e,n,S,null);if(f.data==="$!"){if(l=f.nextSibling&&f.nextSibling.dataset,l)var T=l.dgst;return l=T,g=Error(o(419)),l=iu(g,l,void 0),Qs(e,n,S,l)}if(T=(S&e.childLanes)!==0,Lt||T){if(l=ht,l!==null){switch(S&-S){case 4:f=2;break;case 16:f=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:f=32;break;case 536870912:f=268435456;break;default:f=0}f=(f&(l.suspendedLanes|S))!==0?0:f,f!==0&&f!==g.retryLane&&(g.retryLane=f,Zn(e,f),dn(l,e,f,-1))}return bu(),l=iu(Error(o(421))),Qs(e,n,S,l)}return f.data==="$?"?(n.flags|=128,n.child=e.child,n=Yy.bind(null,e),f._reactRetry=n,null):(e=g.treeContext,Ut=yr(f.nextSibling),Wt=n,Xe=!0,ln=null,e!==null&&(Kt[Qt++]=Kn,Kt[Qt++]=Qn,Kt[Qt++]=Zr,Kn=e.id,Qn=e.overflow,Zr=n),n=cu(n,l.children),n.flags|=4096,n)}function wf(e,n,i){e.lanes|=n;var l=e.alternate;l!==null&&(l.lanes|=n),Ha(e.return,n,i)}function du(e,n,i,l,f){var g=e.memoizedState;g===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:l,tail:i,tailMode:f}:(g.isBackwards=n,g.rendering=null,g.renderingStartTime=0,g.last=l,g.tail=i,g.tailMode=f)}function _f(e,n,i){var l=n.pendingProps,f=l.revealOrder,g=l.tail;if(Ct(e,n,l.children,i),l=qe.current,(l&2)!==0)l=l&1|2,n.flags|=128;else{if(e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&wf(e,i,n);else if(e.tag===19)wf(e,i,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}l&=1}if(Be(qe,l),(n.mode&1)===0)n.memoizedState=null;else switch(f){case"forwards":for(i=n.child,f=null;i!==null;)e=i.alternate,e!==null&&Ws(e)===null&&(f=i),i=i.sibling;i=f,i===null?(f=n.child,n.child=null):(f=i.sibling,i.sibling=null),du(n,!1,f,i,g);break;case"backwards":for(i=null,f=n.child,n.child=null;f!==null;){if(e=f.alternate,e!==null&&Ws(e)===null){n.child=f;break}e=f.sibling,f.sibling=i,i=f,f=e}du(n,!0,i,null,g);break;case"together":du(n,!1,null,null,void 0);break;default:n.memoizedState=null}return n.child}function Zs(e,n){(n.mode&1)===0&&e!==null&&(e.alternate=null,n.alternate=null,n.flags|=2)}function er(e,n,i){if(e!==null&&(n.dependencies=e.dependencies),ri|=n.lanes,(i&n.childLanes)===0)return null;if(e!==null&&n.child!==e.child)throw Error(o(153));if(n.child!==null){for(e=n.child,i=Cr(e,e.pendingProps),n.child=i,i.return=n;e.sibling!==null;)e=e.sibling,i=i.sibling=Cr(e,e.pendingProps),i.return=n;i.sibling=null}return n.child}function Ly(e,n,i){switch(n.tag){case 3:yf(n),$i();break;case 5:Ld(n);break;case 1:Tt(n.type)&&Ls(n);break;case 4:Wa(n,n.stateNode.containerInfo);break;case 10:var l=n.type._context,f=n.memoizedProps.value;Be(Fs,l._currentValue),l._currentValue=f;break;case 13:if(l=n.memoizedState,l!==null)return l.dehydrated!==null?(Be(qe,qe.current&1),n.flags|=128,null):(i&n.child.childLanes)!==0?xf(e,n,i):(Be(qe,qe.current&1),e=er(e,n,i),e!==null?e.sibling:null);Be(qe,qe.current&1);break;case 19:if(l=(i&n.childLanes)!==0,(e.flags&128)!==0){if(l)return _f(e,n,i);n.flags|=128}if(f=n.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),Be(qe,qe.current),l)break;return null;case 22:case 23:return n.lanes=0,pf(e,n,i)}return er(e,n,i)}var Sf,fu,kf,Nf;Sf=function(e,n){for(var i=n.child;i!==null;){if(i.tag===5||i.tag===6)e.appendChild(i.stateNode);else if(i.tag!==4&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===n)break;for(;i.sibling===null;){if(i.return===null||i.return===n)return;i=i.return}i.sibling.return=i.return,i=i.sibling}},fu=function(){},kf=function(e,n,i,l){var f=e.memoizedProps;if(f!==l){e=n.stateNode,ti(Mn.current);var g=null;switch(i){case"input":f=Ne(e,f),l=Ne(e,l),g=[];break;case"select":f=H({},f,{value:void 0}),l=H({},l,{value:void 0}),g=[];break;case"textarea":f=wt(e,f),l=wt(e,l),g=[];break;default:typeof f.onClick!="function"&&typeof l.onClick=="function"&&(e.onclick=Is)}$r(i,l);var S;i=null;for(J in f)if(!l.hasOwnProperty(J)&&f.hasOwnProperty(J)&&f[J]!=null)if(J==="style"){var T=f[J];for(S in T)T.hasOwnProperty(S)&&(i||(i={}),i[S]="")}else J!=="dangerouslySetInnerHTML"&&J!=="children"&&J!=="suppressContentEditableWarning"&&J!=="suppressHydrationWarning"&&J!=="autoFocus"&&(a.hasOwnProperty(J)?g||(g=[]):(g=g||[]).push(J,null));for(J in l){var O=l[J];if(T=f!=null?f[J]:void 0,l.hasOwnProperty(J)&&O!==T&&(O!=null||T!=null))if(J==="style")if(T){for(S in T)!T.hasOwnProperty(S)||O&&O.hasOwnProperty(S)||(i||(i={}),i[S]="");for(S in O)O.hasOwnProperty(S)&&T[S]!==O[S]&&(i||(i={}),i[S]=O[S])}else i||(g||(g=[]),g.push(J,i)),i=O;else J==="dangerouslySetInnerHTML"?(O=O?O.__html:void 0,T=T?T.__html:void 0,O!=null&&T!==O&&(g=g||[]).push(J,O)):J==="children"?typeof O!="string"&&typeof O!="number"||(g=g||[]).push(J,""+O):J!=="suppressContentEditableWarning"&&J!=="suppressHydrationWarning"&&(a.hasOwnProperty(J)?(O!=null&&J==="onScroll"&&We("scroll",e),g||T===O||(g=[])):(g=g||[]).push(J,O))}i&&(g=g||[]).push("style",i);var J=g;(n.updateQueue=J)&&(n.flags|=4)}},Nf=function(e,n,i,l){i!==l&&(n.flags|=4)};function Oo(e,n){if(!Xe)switch(e.tailMode){case"hidden":n=e.tail;for(var i=null;n!==null;)n.alternate!==null&&(i=n),n=n.sibling;i===null?e.tail=null:i.sibling=null;break;case"collapsed":i=e.tail;for(var l=null;i!==null;)i.alternate!==null&&(l=i),i=i.sibling;l===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:l.sibling=null}}function Nt(e){var n=e.alternate!==null&&e.alternate.child===e.child,i=0,l=0;if(n)for(var f=e.child;f!==null;)i|=f.lanes|f.childLanes,l|=f.subtreeFlags&14680064,l|=f.flags&14680064,f.return=e,f=f.sibling;else for(f=e.child;f!==null;)i|=f.lanes|f.childLanes,l|=f.subtreeFlags,l|=f.flags,f.return=e,f=f.sibling;return e.subtreeFlags|=l,e.childLanes=i,n}function Ay(e,n,i){var l=n.pendingProps;switch(La(n),n.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Nt(n),null;case 1:return Tt(n.type)&&Ts(),Nt(n),null;case 3:return l=n.stateNode,Fi(),Ue(Rt),Ue(St),Ga(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(Ds(n)?n.flags|=4:e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,ln!==null&&(ku(ln),ln=null))),fu(e,n),Nt(n),null;case 5:Ua(n);var f=ti(Lo.current);if(i=n.type,e!==null&&n.stateNode!=null)kf(e,n,i,l,f),e.ref!==n.ref&&(n.flags|=512,n.flags|=2097152);else{if(!l){if(n.stateNode===null)throw Error(o(166));return Nt(n),null}if(e=ti(Mn.current),Ds(n)){l=n.stateNode,i=n.type;var g=n.memoizedProps;switch(l[Cn]=n,l[Mo]=g,e=(n.mode&1)!==0,i){case"dialog":We("cancel",l),We("close",l);break;case"iframe":case"object":case"embed":We("load",l);break;case"video":case"audio":for(f=0;f<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=S.createElement(i,{is:l.is}):(e=S.createElement(i),i==="select"&&(S=e,l.multiple?S.multiple=!0:l.size&&(S.size=l.size))):e=S.createElementNS(e,i),e[Cn]=n,e[Mo]=l,Sf(e,n,!1,!1),n.stateNode=e;e:{switch(S=zn(i,l),i){case"dialog":We("cancel",e),We("close",e),f=l;break;case"iframe":case"object":case"embed":We("load",e),f=l;break;case"video":case"audio":for(f=0;fWi&&(n.flags|=128,l=!0,Oo(g,!1),n.lanes=4194304)}else{if(!l)if(e=Ws(S),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Oo(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Xe)return Nt(n),null}else 2*Ve()-g.renderingStartTime>Wi&&i!==1073741824&&(n.flags|=128,l=!0,Oo(g,!1),n.lanes=4194304);g.isBackwards?(S.sibling=n.child,n.child=S):(i=g.last,i!==null?i.sibling=S:n.child=S,g.last=S)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(Nt(n),null);case 22:case 23:return ju(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Yt&1073741824)!==0&&(Nt(n),n.subtreeFlags&6&&(n.flags|=8192)):Nt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function $y(e,n){switch(La(n),n.tag){case 1:return Tt(n.type)&&Ts(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Fi(),Ue(Rt),Ue(St),Ga(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Ua(n),null;case 13:if(Ue(qe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));$i()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Fi(),null;case 10:return Fa(n.type._context),null;case 22:case 23:return ju(),null;case 24:return null;default:return null}}var Js=!1,jt=!1,zy=typeof WeakSet=="function"?WeakSet:Set,ye=null;function Bi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Ze(e,n,l)}else i.current=null}function hu(e,n,i){try{i()}catch(l){Ze(e,n,l)}}var jf=!1;function Dy(e,n){if(ja=xs,e=nd(),ya(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,g=l.focusNode;l=l.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var S=0,T=-1,O=-1,J=0,ae=0,ue=e,le=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=S+f),ue!==g||l!==0&&ue.nodeType!==3||(O=S+l),ue.nodeType===3&&(S+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)le=ue,ue=ge;for(;;){if(ue===e)break t;if(le===i&&++J===f&&(T=S),le===g&&++ae===l&&(O=S),(ge=ue.nextSibling)!==null)break;ue=le,le=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(ba={focusedElem:e,selectionRange:i},xs=!1,ye=n;ye!==null;)if(n=ye,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ye=e;else for(;ye!==null;){n=ye;try{var xe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var we=xe.memoizedProps,et=xe.memoizedState,X=n.stateNode,B=X.getSnapshotBeforeUpdate(n.elementType===n.type?we:an(n.type,we),et);X.__reactInternalSnapshotBeforeUpdate=B}break;case 3:var Q=n.stateNode.containerInfo;Q.nodeType===1?Q.textContent="":Q.nodeType===9&&Q.documentElement&&Q.removeChild(Q.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(de){Ze(n,n.return,de)}if(e=n.sibling,e!==null){e.return=n.return,ye=e;break}ye=n.return}return xe=jf,jf=!1,xe}function Fo(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&e)===e){var g=f.destroy;f.destroy=void 0,g!==void 0&&hu(n,i,g)}f=f.next}while(f!==l)}}function el(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function pu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function bf(e){var n=e.alternate;n!==null&&(e.alternate=null,bf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[Cn],delete n[Mo],delete n[Pa],delete n[wy],delete n[_y])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Ef(e){return e.tag===5||e.tag===3||e.tag===4}function Cf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Ef(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function gu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=Is));else if(l!==4&&(e=e.child,e!==null))for(gu(e,n,i),e=e.sibling;e!==null;)gu(e,n,i),e=e.sibling}function mu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(mu(e,n,i),e=e.sibling;e!==null;)mu(e,n,i),e=e.sibling}var vt=null,un=!1;function kr(e,n,i){for(i=i.child;i!==null;)Mf(e,n,i),i=i.sibling}function Mf(e,n,i){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(Vn,i)}catch{}switch(i.tag){case 5:jt||Bi(i,n);case 6:var l=vt,f=un;vt=null,kr(e,n,i),vt=l,un=f,vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):vt.removeChild(i.stateNode));break;case 18:vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?Ma(e.parentNode,i):e.nodeType===1&&Ma(e,i),vo(e)):Ma(vt,i.stateNode));break;case 4:l=vt,f=un,vt=i.stateNode.containerInfo,un=!0,kr(e,n,i),vt=l,un=f;break;case 0:case 11:case 14:case 15:if(!jt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var g=f,S=g.destroy;g=g.tag,S!==void 0&&((g&2)!==0||(g&4)!==0)&&hu(i,n,S),f=f.next}while(f!==l)}kr(e,n,i);break;case 1:if(!jt&&(Bi(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Ze(i,n,T)}kr(e,n,i);break;case 21:kr(e,n,i);break;case 22:i.mode&1?(jt=(l=jt)||i.memoizedState!==null,kr(e,n,i),jt=l):kr(e,n,i);break;default:kr(e,n,i)}}function Pf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new zy),n.forEach(function(l){var f=Gy.bind(null,e,l);i.has(l)||(i.add(l),l.then(f,f))})}}function cn(e,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=S),l&=~g}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Fy(l/1960))-l,10e?16:e,jr===null)var l=!1;else{if(e=jr,jr=null,ol=0,(ze&6)!==0)throw Error(o(331));var f=ze;for(ze|=4,ye=e.current;ye!==null;){var g=ye,S=g.child;if((ye.flags&16)!==0){var T=g.deletions;if(T!==null){for(var O=0;OVe()-xu?oi(e,0):vu|=i),$t(e,n)}function Vf(e,n){n===0&&((e.mode&1)===0?n=1:(n=Un,Un<<=1,(Un&130023424)===0&&(Un=4194304)));var i=Mt();e=Zn(e,n),e!==null&&(En(e,n,i),$t(e,i))}function Yy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Vf(e,i)}function Gy(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Vf(e,i)}var Wf;Wf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Rt.current)Lt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Lt=!1,Ly(e,n,i);Lt=(e.flags&131072)!==0}else Lt=!1,Xe&&(n.flags&1048576)!==0&&Sd(n,zs,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Zs(e,n),e=n.pendingProps;var f=Ti(n,St.current);Oi(n,i),f=Ka(null,n,l,e,f,i);var g=Qa();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Tt(l)?(g=!0,Ls(n)):g=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Va(n),f.updater=Ks,n.stateNode=f,f._reactInternals=n,ru(n,l,e,i),n=lu(null,n,l,!0,g,i)):(n.tag=0,Xe&&g&&Ta(n),Ct(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Zs(e,n),e=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=qy(l),e=an(l,e),f){case 0:n=su(null,n,l,e,i);break e;case 1:n=mf(null,n,l,e,i);break e;case 11:n=df(null,n,l,e,i);break e;case 14:n=ff(null,n,l,an(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),su(e,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),mf(e,n,l,f,i);case 3:e:{if(yf(n),e===null)throw Error(o(387));l=n.pendingProps,g=n.memoizedState,f=g.element,Id(e,n),Vs(n,l,null,i);var S=n.memoizedState;if(l=S.element,g.isDehydrated)if(g={element:l,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){f=Hi(Error(o(423)),n),n=vf(e,n,l,i,f);break e}else if(l!==f){f=Hi(Error(o(424)),n),n=vf(e,n,l,i,f);break e}else for(Ut=yr(n.stateNode.containerInfo.firstChild),Wt=n,Xe=!0,ln=null,i=Md(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if($i(),l===f){n=er(e,n,i);break e}Ct(e,n,l,i)}n=n.child}return n;case 5:return Ld(n),e===null&&$a(n),l=n.type,f=n.pendingProps,g=e!==null?e.memoizedProps:null,S=f.children,Ea(l,f)?S=null:g!==null&&Ea(l,g)&&(n.flags|=32),gf(e,n),Ct(e,n,S,i),n.child;case 6:return e===null&&$a(n),null;case 13:return xf(e,n,i);case 4:return Wa(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=zi(n,null,l,i):Ct(e,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),df(e,n,l,f,i);case 7:return Ct(e,n,n.pendingProps,i),n.child;case 8:return Ct(e,n,n.pendingProps.children,i),n.child;case 12:return Ct(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,g=n.memoizedProps,S=f.value,Be(Fs,l._currentValue),l._currentValue=S,g!==null)if(sn(g.value,S)){if(g.children===f.children&&!Rt.current){n=er(e,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var T=g.dependencies;if(T!==null){S=g.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(g.tag===1){O=Jn(-1,i&-i),O.tag=2;var J=g.updateQueue;if(J!==null){J=J.shared;var ae=J.pending;ae===null?O.next=O:(O.next=ae.next,ae.next=O),J.pending=O}}g.lanes|=i,O=g.alternate,O!==null&&(O.lanes|=i),Ha(g.return,i,n),T.lanes|=i;break}O=O.next}}else if(g.tag===10)S=g.type===n.type?null:g.child;else if(g.tag===18){if(S=g.return,S===null)throw Error(o(341));S.lanes|=i,T=S.alternate,T!==null&&(T.lanes|=i),Ha(S,i,n),S=g.sibling}else S=g.child;if(S!==null)S.return=g;else for(S=g;S!==null;){if(S===n){S=null;break}if(g=S.sibling,g!==null){g.return=S.return,S=g;break}S=S.return}g=S}Ct(e,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,Oi(n,i),f=Zt(f),l=l(f),n.flags|=1,Ct(e,n,l,i),n.child;case 14:return l=n.type,f=an(l,n.pendingProps),f=an(l.type,f),ff(e,n,l,f,i);case 15:return hf(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),Zs(e,n),n.tag=1,Tt(l)?(e=!0,Ls(n)):e=!1,Oi(n,i),rf(n,l,f),ru(n,l,f,i),lu(null,n,l,!0,e,i);case 19:return _f(e,n,i);case 22:return pf(e,n,i)}throw Error(o(156,n.tag))};function Uf(e,n){return Hr(e,n)}function Xy(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tn(e,n,i,l){return new Xy(e,n,i,l)}function Eu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function qy(e){if(typeof e=="function")return Eu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ne)return 11;if(e===V)return 14}return 2}function Cr(e,n){var i=e.alternate;return i===null?(i=tn(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function ul(e,n,i,l,f,g){var S=2;if(l=e,typeof e=="function")Eu(e)&&(S=1);else if(typeof e=="string")S=5;else e:switch(e){case F:return li(i.children,f,g,n);case G:S=8,f|=8;break;case q:return e=tn(12,i,n,f|2),e.elementType=q,e.lanes=g,e;case K:return e=tn(13,i,n,f),e.elementType=K,e.lanes=g,e;case C:return e=tn(19,i,n,f),e.elementType=C,e.lanes=g,e;case U:return cl(i,f,g,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case te:S=10;break e;case ee:S=9;break e;case ne:S=11;break e;case V:S=14;break e;case W:S=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=tn(S,i,n,f),n.elementType=e,n.type=l,n.lanes=g,n}function li(e,n,i,l){return e=tn(7,e,l,n),e.lanes=i,e}function cl(e,n,i,l){return e=tn(22,e,l,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function Cu(e,n,i){return e=tn(6,e,null,n),e.lanes=i,e}function Mu(e,n,i){return n=tn(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Ky(e,n,i,l,f){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Yn(0),this.expirationTimes=Yn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Yn(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Pu(e,n,i,l,f,g,S,T,O){return e=new Ky(e,n,i,T,O),n===1?(n=1,g===!0&&(n|=8)):n=0,g=tn(3,null,null,n),e.current=g,g.stateNode=e,g.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Va(g),e}function Qy(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),$u.exports=u0(),$u.exports}var oh;function c0(){if(oh)return yl;oh=1;var t=Ep();return yl.createRoot=t.createRoot,yl.hydrateRoot=t.hydrateRoot,yl}var d0=c0();function Cp(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Ae(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(Cp(s,o.statusText||"Request failed"))}return o.json()}const f0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Pe={health:()=>Ae("/api/health"),settings:()=>Ae("/api/settings"),saveSettings:t=>{const r={...t};for(const o of f0)r[o]===""&&delete r[o];return Ae("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ae("/api/repos"),browse:t=>Ae(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ae(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ae("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ae(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Ae(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:(t,r=!0)=>Ae(`/api/architecture?repo_path=${encodeURIComponent(t)}&graph=${r?"1":"0"}`),architectureGraph:t=>Ae(`/api/architecture/graph?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Ae("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Ae("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Ae("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Ae("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Ae("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Ae(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open",s)=>Ae("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o,repo_path:s||null})}),scmRepos:t=>Ae(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ae("/api/oauth/status"),githubOAuthStart:()=>Ae("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ae("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ae("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Ae("/api/oauth/gitlab/start"),oauthDisconnect:t=>Ae("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ae("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})}),reviews:t=>Ae(`/api/reviews?repo_path=${encodeURIComponent(t)}`),getReview:(t,r)=>Ae(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(t)}`),reviewDiff:(t,r,o)=>Ae(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(t)}&other=${encodeURIComponent(o)}`),config:t=>Ae(`/api/config?repo_path=${encodeURIComponent(t)}`),saveConfig:(t,r)=>Ae("/api/config",{method:"PUT",body:JSON.stringify({repo_path:t,...r})}),addWaiver:(t,r,o,s)=>Ae("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:t,rule:r,node:o||null,reason:s||""})}),marks:(t,r)=>Ae(`/api/marks?repo_path=${encodeURIComponent(t)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:t=>Ae(`/api/architecture/health?repo_path=${encodeURIComponent(t)}`),workspaceStatus:t=>Ae(`/api/workspace/status?repo_path=${encodeURIComponent(t)}`),openEditor:(t,r,o,s)=>Ae("/api/open",{method:"POST",body:JSON.stringify({repo_path:t,path:r,line:o||null,editor:s||null})}),exportHtml:t=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:t})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(Cp(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(t,r,o,s)=>Ae("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:t,edges:r,source_id:o,target_id:s||null})})};function h0(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):t}function p0({open:t,actions:r,onClose:o}){const[s,a]=L.useState(""),[u,c]=L.useState(0),h=L.useRef(null),p=L.useMemo(()=>h0(r,s),[r,s]);if(L.useEffect(()=>{if(!t)return;a(""),c(0);const v=window.setTimeout(()=>{var m;return(m=h.current)==null?void 0:m.focus()},0);return()=>window.clearTimeout(v)},[t]),L.useEffect(()=>{c(0)},[s]),!t)return null;const y=p[u],x=v=>{v&&(o(),v.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:v=>{v.target===v.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:v=>a(v.target.value),onKeyDown:v=>{v.key==="Escape"?(v.preventDefault(),o()):v.key==="ArrowDown"?(v.preventDefault(),c(m=>Math.min(p.length-1,m+1))):v.key==="ArrowUp"?(v.preventDefault(),c(m=>Math.max(0,m-1))):v.key==="Enter"&&(v.preventDefault(),x(y))}}),d.jsxs("ul",{children:[p.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,p.slice(0,40).map((v,m)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:m===u?"active":"",onMouseEnter:()=>c(m),onClick:()=>x(v),children:[d.jsx("span",{children:v.label}),v.hint?d.jsx("span",{className:"muted",children:v.hint}):null]})},v.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function g0({config:t,busy:r,onSave:o,onWaiver:s}){const[a,u]=L.useState(t),[c,h]=L.useState(t.available_rules[0]||""),[p,y]=L.useState(""),[x,v]=L.useState("");L.useEffect(()=>{u(t)},[t]);const m=Object.entries(a.contexts||{}),_=(R,w,N)=>{const A=a.contexts[R];if(!A)return;const $=F=>F.split(",").map(G=>G.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[R]:{...A,[w]:w==="name"?N:$(N)}}})},k=(R,w)=>{const N=w.trim();if(!N||N===R)return;const{[R]:A,...$}=a.contexts;A&&u({...a,contexts:{...$,[N]:{...A,name:N}}})},j=()=>{let R=1;for(;a.contexts[`context-${R}`];)R+=1;const w=`context-${R}`;u({...a,contexts:{...a.contexts,[w]:{name:w,django_apps:[],react:[],public_api:[],owners:[]}}})},b=R=>{const{[R]:w,...N}=a.contexts;u({...a,contexts:N})},E=R=>{const w=a.rules.includes(R);u({...a,rules:w?a.rules.filter(N=>N!==R):[...a.rules,R]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),m.map(([R,w])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:R})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:R,"data-testid":`config-context-name-${R}`,onBlur:N=>k(R,N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(w.django_apps||[]).join(", "),onChange:N=>_(R,"django_apps",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(w.react||[]).join(", "),onChange:N=>_(R,"react",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(w.public_api||[]).join(", "),onChange:N=>_(R,"public_api",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(w.owners||[]).join(", "),onChange:N=>_(R,"owners",N.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>b(R),children:"Remove context"})]},R)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:j,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(R),onChange:()=>E(R)}),R]},R))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((R,w)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:R.rule}),R.node?` · ${R.node}`:"",R.reason?` — ${R.reason}`:""]},`${R.rule}:${R.node}:${w}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:R=>h(R.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsx("option",{value:R,children:R},R))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:R=>y(R.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:x,onChange:R=>v(R.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,x),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function Zo(t){return t.replaceAll("_"," ")}function m0(t){return t.replaceAll("_"," ")}function io(t){return t.split(".").pop()||t}function tc(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function y0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Tr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function yi({className:t,children:r}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function v0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function x0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function w0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function _0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function S0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function Mp({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function k0({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const N0="modulepreload",j0=function(t,r){return new URL(t,r).href},sh={},b0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(x){return Promise.all(x.map(v=>Promise.resolve(v).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),y=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(x=>{if(x=j0(x,s),x in sh)return;sh[x]=!0;const v=x.endsWith(".css"),m=v?'[rel="stylesheet"]':"";if(!!s)for(let j=h.length-1;j>=0;j--){const b=h[j];if(b.href===x&&(!v||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${x}"]${m}`))return;const k=document.createElement("link");if(k.rel=v?"stylesheet":N0,v||(k.as="script"),k.crossOrigin="",k.href=x,y&&k.setAttribute("nonce",y),document.head.appendChild(k),v)return new Promise((j,b)=>{k.addEventListener("load",j),k.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${x}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function nt(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Gl(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}Ml.prototype=Gl.prototype={constructor:Ml,on:function(t,r){var o=this._,s=C0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),ah.hasOwnProperty(r)?{space:ah[r],local:t}:t}function P0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===nc&&r.documentElement.namespaceURI===nc?r.createElement(t):r.createElementNS(o,t)}}function I0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Pp(t){var r=Xl(t);return(r.local?I0:P0)(r)}function R0(){}function mc(t){return t==null?R0:function(){return this.querySelector(t)}}function T0(t){typeof t!="function"&&(t=mc(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=w&&(w=R+1);!(A=b[w])&&++w=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function iv(t){t||(t=ov);function r(v,m){return v&&m?t(v.__data__,m.__data__):!v-!m}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function sv(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function lv(){return Array.from(this)}function av(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?xv:typeof r=="function"?_v:wv)(t,r,o??"")):Ki(this.node(),t)}function Ki(t,r){return t.style.getPropertyValue(r)||Ap(t).getComputedStyle(t,null).getPropertyValue(r)}function kv(t){return function(){delete this[t]}}function Nv(t,r){return function(){this[t]=r}}function jv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function bv(t,r){return arguments.length>1?this.each((r==null?kv:typeof r=="function"?jv:Nv)(t,r)):this.node()[t]}function $p(t){return t.trim().split(/^|\s+/)}function yc(t){return t.classList||new zp(t)}function zp(t){this._node=t,this._names=$p(t.getAttribute("class")||"")}zp.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Dp(t,r){for(var o=yc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function ex(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function rc(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:y,dispatch:x}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:y,enumerable:!0,configurable:!0},_:{value:x}})}rc.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function cx(t){return!t.ctrlKey&&!t.button}function dx(){return this.parentNode}function fx(t,r){return r??{x:t.x,y:t.y}}function hx(){return navigator.maxTouchPoints||"ontouchstart"in this}function Wp(){var t=cx,r=dx,o=fx,s=hx,a={},u=Gl("start","drag","end"),c=0,h,p,y,x,v=0;function m(N){N.on("mousedown.drag",_).filter(s).on("touchstart.drag",b).on("touchmove.drag",E,ux).on("touchend.drag touchcancel.drag",R).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(N,A){if(!(x||!t.call(this,N,A))){var $=w(this,r.call(this,N,A),N,A,"mouse");$&&(Gt(N.view).on("mousemove.drag",k,Jo).on("mouseup.drag",j,Jo),Bp(N.view),Ou(N),y=!1,h=N.clientX,p=N.clientY,$("start",N))}}function k(N){if(Xi(N),!y){var A=N.clientX-h,$=N.clientY-p;y=A*A+$*$>v}a.mouse("drag",N)}function j(N){Gt(N.view).on("mousemove.drag mouseup.drag",null),Vp(N.view,y),Xi(N),a.mouse("end",N)}function b(N,A){if(t.call(this,N,A)){var $=N.changedTouches,F=r.call(this,N,A),G=$.length,q,te;for(q=0;q>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?xl(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?xl(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=gx.exec(t))?new Dt(r[1],r[2],r[3],1):(r=mx.exec(t))?new Dt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=yx.exec(t))?xl(r[1],r[2],r[3],r[4]):(r=vx.exec(t))?xl(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=xx.exec(t))?gh(r[1],r[2]/100,r[3]/100,1):(r=wx.exec(t))?gh(r[1],r[2]/100,r[3]/100,r[4]):uh.hasOwnProperty(t)?fh(uh[t]):t==="transparent"?new Dt(NaN,NaN,NaN,0):null}function fh(t){return new Dt(t>>16&255,t>>8&255,t&255,1)}function xl(t,r,o,s){return s<=0&&(t=r=o=NaN),new Dt(t,r,o,s)}function kx(t){return t instanceof fs||(t=fi(t)),t?(t=t.rgb(),new Dt(t.r,t.g,t.b,t.opacity)):new Dt}function ic(t,r,o,s){return arguments.length===1?kx(t):new Dt(t,r,o,s??1)}function Dt(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}vc(Dt,ic,Up(fs,{brighter(t){return t=t==null?Al:Math.pow(Al,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?es:Math.pow(es,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Dt(ci(this.r),ci(this.g),ci(this.b),$l(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:hh,formatHex:hh,formatHex8:Nx,formatRgb:ph,toString:ph}));function hh(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}`}function Nx(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}${ui((isNaN(this.opacity)?1:this.opacity)*255)}`}function ph(){const t=$l(this.opacity);return`${t===1?"rgb(":"rgba("}${ci(this.r)}, ${ci(this.g)}, ${ci(this.b)}${t===1?")":`, ${t})`}`}function $l(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ci(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ui(t){return t=ci(t),(t<16?"0":"")+t.toString(16)}function gh(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new hn(t,r,o,s)}function Yp(t){if(t instanceof hn)return new hn(t.h,t.s,t.l,t.opacity);if(t instanceof fs||(t=fi(t)),!t)return new hn;if(t instanceof hn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new hn(c,h,p,t.opacity)}function jx(t,r,o,s){return arguments.length===1?Yp(t):new hn(t,r,o,s??1)}function hn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}vc(hn,jx,Up(fs,{brighter(t){return t=t==null?Al:Math.pow(Al,t),new hn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?es:Math.pow(es,t),new hn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Dt(Fu(t>=240?t-240:t+120,a,s),Fu(t,a,s),Fu(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new hn(mh(this.h),wl(this.s),wl(this.l),$l(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 t=$l(this.opacity);return`${t===1?"hsl(":"hsla("}${mh(this.h)}, ${wl(this.s)*100}%, ${wl(this.l)*100}%${t===1?")":`, ${t})`}`}}));function mh(t){return t=(t||0)%360,t<0?t+360:t}function wl(t){return Math.max(0,Math.min(1,t||0))}function Fu(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const xc=t=>()=>t;function bx(t,r){return function(o){return t+o*r}}function Ex(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function Cx(t){return(t=+t)==1?Gp:function(r,o){return o-r?Ex(r,o,t):xc(isNaN(r)?o:r)}}function Gp(t,r){var o=r-t;return o?bx(t,o):xc(isNaN(t)?r:t)}const zl=(function t(r){var o=Cx(r);function s(a,u){var c=o((a=ic(a)).r,(u=ic(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),y=Gp(a.opacity,u.opacity);return function(x){return a.r=c(x),a.g=h(x),a.b=p(x),a.opacity=y(x),a+""}}return s.gamma=t,s})(1);function Mx(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:Rn(s,a)})),o=Hu.lastIndex;return o180?x+=360:x-y>180&&(y+=360),m.push({i:v.push(a(v)+"rotate(",null,s)-2,x:Rn(y,x)})):x&&v.push(a(v)+"rotate("+x+s)}function h(y,x,v,m){y!==x?m.push({i:v.push(a(v)+"skewX(",null,s)-2,x:Rn(y,x)}):x&&v.push(a(v)+"skewX("+x+s)}function p(y,x,v,m,_,k){if(y!==v||x!==m){var j=_.push(a(_)+"scale(",null,",",null,")");k.push({i:j-4,x:Rn(y,v)},{i:j-2,x:Rn(x,m)})}else(v!==1||m!==1)&&_.push(a(_)+"scale("+v+","+m+")")}return function(y,x){var v=[],m=[];return y=t(y),x=t(x),u(y.translateX,y.translateY,x.translateX,x.translateY,v,m),c(y.rotate,x.rotate,v,m),h(y.skewX,x.skewX,v,m),p(y.scaleX,y.scaleY,x.scaleX,x.scaleY,v,m),y=x=null,function(_){for(var k=-1,j=m.length,b;++k=0&&t._call.call(void 0,r),t=t._next;--Qi}function xh(){hi=(Ol=ns.now())+ql,Qi=Xo=0;try{Wx()}finally{Qi=0,Yx(),hi=0}}function Ux(){var t=ns.now(),r=t-Ol;r>Qp&&(ql-=r,Ol=t)}function Yx(){for(var t,r=Dl,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:Dl=o);qo=t,lc(s)}function lc(t){if(!Qi){Xo&&(Xo=clearTimeout(Xo));var r=t-hi;r>24?(t<1/0&&(Xo=setTimeout(xh,t-ns.now()-ql)),Yo&&(Yo=clearInterval(Yo))):(Yo||(Ol=ns.now(),Yo=setInterval(Ux,Qp)),Qi=1,Zp(xh))}}function wh(t,r,o){var s=new Fl;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Gx=Gl("start","end","cancel","interrupt"),Xx=[],eg=0,_h=1,ac=2,Il=3,Sh=4,uc=5,Rl=6;function Kl(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;qx(t,o,{name:r,index:s,group:a,on:Gx,tween:Xx,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:eg})}function _c(t,r){var o=yn(t,r);if(o.state>eg)throw new Error("too late; already scheduled");return o}function Ln(t,r){var o=yn(t,r);if(o.state>Il)throw new Error("too late; already running");return o}function yn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function qx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=Jp(u,0,o.time);function u(y){o.state=_h,o.timer.restart(c,o.delay,o.time),o.delay<=y&&c(y-o.delay)}function c(y){var x,v,m,_;if(o.state!==_h)return p();for(x in s)if(_=s[x],_.name===o.name){if(_.state===Il)return wh(c);_.state===Sh?(_.state=Rl,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete s[x]):+xac&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function jw(t,r,o){var s,a,u=Nw(r)?_c:Ln;return function(){var c=u(this,t),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function bw(t,r){var o=this._id;return arguments.length<2?yn(this.node(),o).on.on(t):this.each(jw(o,t,r))}function Ew(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function Cw(){return this.on("end.remove",Ew(this._id))}function Mw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=mc(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function e1(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function rr(t,r,o){this.k=t,this.x=r,this.y=o}rr.prototype={constructor:rr,scale:function(t){return t===1?this:new rr(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new rr(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Ql=new rr(1,0,0);ig.prototype=rr.prototype;function ig(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Ql;return t.__zoom}function Bu(t){t.stopImmediatePropagation()}function Go(t){t.preventDefault(),t.stopImmediatePropagation()}function t1(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function n1(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function kh(){return this.__zoom||Ql}function r1(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function i1(){return navigator.maxTouchPoints||"ontouchstart"in this}function o1(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function og(){var t=t1,r=n1,o=o1,s=r1,a=i1,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=Pl,y=Gl("start","zoom","end"),x,v,m,_=500,k=150,j=0,b=10;function E(C){C.property("__zoom",kh).on("wheel.zoom",G,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",te).filter(a).on("touchstart.zoom",ee).on("touchmove.zoom",ne).on("touchend.zoom touchcancel.zoom",K).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(C,V,W,U){var M=C.selection?C.selection():C;M.property("__zoom",kh),C!==M?A(C,V,W,U):M.interrupt().each(function(){$(this,arguments).event(U).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},E.scaleBy=function(C,V,W,U){E.scaleTo(C,function(){var M=this.__zoom.k,D=typeof V=="function"?V.apply(this,arguments):V;return M*D},W,U)},E.scaleTo=function(C,V,W,U){E.transform(C,function(){var M=r.apply(this,arguments),D=this.__zoom,H=W==null?N(M):typeof W=="function"?W.apply(this,arguments):W,I=D.invert(H),z=typeof V=="function"?V.apply(this,arguments):V;return o(w(R(D,z),H,I),M,c)},W,U)},E.translateBy=function(C,V,W,U){E.transform(C,function(){return o(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),r.apply(this,arguments),c)},null,U)},E.translateTo=function(C,V,W,U,M){E.transform(C,function(){var D=r.apply(this,arguments),H=this.__zoom,I=U==null?N(D):typeof U=="function"?U.apply(this,arguments):U;return o(Ql.translate(I[0],I[1]).scale(H.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),D,c)},U,M)};function R(C,V){return V=Math.max(u[0],Math.min(u[1],V)),V===C.k?C:new rr(V,C.x,C.y)}function w(C,V,W){var U=V[0]-W[0]*C.k,M=V[1]-W[1]*C.k;return U===C.x&&M===C.y?C:new rr(C.k,U,M)}function N(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function A(C,V,W,U){C.on("start.zoom",function(){$(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(U).end()}).tween("zoom",function(){var M=this,D=arguments,H=$(M,D).event(U),I=r.apply(M,D),z=W==null?N(I):typeof W=="function"?W.apply(M,D):W,ie=Math.max(I[1][0]-I[0][0],I[1][1]-I[0][1]),oe=M.__zoom,fe=typeof V=="function"?V.apply(M,D):V,he=p(oe.invert(z).concat(ie/oe.k),fe.invert(z).concat(ie/fe.k));return function(pe){if(pe===1)pe=fe;else{var Z=he(pe),se=ie/Z[2];pe=new rr(se,z[0]-Z[0]*se,z[1]-Z[1]*se)}H.zoom(null,pe)}})}function $(C,V,W){return!W&&C.__zooming||new F(C,V)}function F(C,V){this.that=C,this.args=V,this.active=0,this.sourceEvent=null,this.extent=r.apply(C,V),this.taps=0}F.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,V){return this.mouse&&C!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var V=Gt(this.that).datum();y.call(C,this.that,new e1(C,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:y}),V)}};function G(C,...V){if(!t.apply(this,arguments))return;var W=$(this,V).event(C),U=this.__zoom,M=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,s.apply(this,arguments)))),D=fn(C);if(W.wheel)(W.mouse[0][0]!==D[0]||W.mouse[0][1]!==D[1])&&(W.mouse[1]=U.invert(W.mouse[0]=D)),clearTimeout(W.wheel);else{if(U.k===M)return;W.mouse=[D,U.invert(D)],Tl(this),W.start()}Go(C),W.wheel=setTimeout(H,k),W.zoom("mouse",o(w(R(U,M),W.mouse[0],W.mouse[1]),W.extent,c));function H(){W.wheel=null,W.end()}}function q(C,...V){if(m||!t.apply(this,arguments))return;var W=C.currentTarget,U=$(this,V,!0).event(C),M=Gt(C.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",ie,!0),D=fn(C,W),H=C.clientX,I=C.clientY;Bp(C.view),Bu(C),U.mouse=[D,this.__zoom.invert(D)],Tl(this),U.start();function z(oe){if(Go(oe),!U.moved){var fe=oe.clientX-H,he=oe.clientY-I;U.moved=fe*fe+he*he>j}U.event(oe).zoom("mouse",o(w(U.that.__zoom,U.mouse[0]=fn(oe,W),U.mouse[1]),U.extent,c))}function ie(oe){M.on("mousemove.zoom mouseup.zoom",null),Vp(oe.view,U.moved),Go(oe),U.event(oe).end()}}function te(C,...V){if(t.apply(this,arguments)){var W=this.__zoom,U=fn(C.changedTouches?C.changedTouches[0]:C,this),M=W.invert(U),D=W.k*(C.shiftKey?.5:2),H=o(w(R(W,D),U,M),r.apply(this,V),c);Go(C),h>0?Gt(this).transition().duration(h).call(A,H,U,C):Gt(this).call(E.transform,H,U,C)}}function ee(C,...V){if(t.apply(this,arguments)){var W=C.touches,U=W.length,M=$(this,V,C.changedTouches.length===U).event(C),D,H,I,z;for(Bu(C),H=0;H`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},rs=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],sg=["Enter"," ","Escape"],lg={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Zi;(function(t){t.Strict="strict",t.Loose="loose"})(Zi||(Zi={}));var di;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(di||(di={}));var is;(function(t){t.Partial="partial",t.Full="full"})(is||(is={}));const ag={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Lr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Lr||(Lr={}));var os;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(os||(os={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const Nh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function ug(t){return t===null?null:t?"valid":"invalid"}const cg=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,s1=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),kc=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),hs=(t,r=[0,0])=>{const{width:o,height:s}=vn(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},l1=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):kc(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,Zl(a,Hl(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?Jl(s):{x:0,y:0,width:0,height:0}},ps=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=Zl(o,Hl(a)),s=!0)}),s?Jl(o):{x:0,y:0,width:0,height:0}},Nc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,y=r.width/a,x=r.height/a,v=[];for(const m of t.values()){const{measured:_,selectable:k=!0,hidden:j=!1}=m;if(c&&!k||j)continue;const b=_.width??m.width??m.initialWidth??0,E=_.height??m.height??m.initialHeight??0,{x:R,y:w}=m.internals.positionAbsolute,N=pg(h,p,y,x,R,w,b,E),A=b*E,$=u&&N>0;(!m.internals.handleBounds||$||N>=A||m.dragging)&&v.push(m)}return v},a1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function u1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=vn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function c1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const h=u1(t,c),p=ps(h),y=bc(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(y,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function dg({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),h=c.parentId?o.get(c.parentId):void 0,{x:p,y}=h?h.internals.positionAbsolute:{x:0,y:0},x=c.origin??s;let v=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",mn.error005());else{const{width:_,height:k}=vn(h);_&&k&&(v=[[p,y],[p+_,y+k]])}else h&&gi(c.extent)&&(v=[[c.extent[0][0]+p,c.extent[0][1]+y],[c.extent[1][0]+p,c.extent[1][1]+y]]);const m=gi(v)?pi(r,v,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",mn.error015())),{position:{x:m.x-p+(c.measured.width??0)*x[0],y:m.y-y+(c.measured.height??0)*x[1]},positionAbsolute:m}}async function d1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(m=>m.id)),c=[];for(const m of o){if(m.deletable===!1)continue;const _=u.has(m.id),k=!_&&m.parentId&&c.find(j=>j.id===m.parentId);(_||k)&&c.push(m)}const h=new Set(r.map(m=>m.id)),p=s.filter(m=>m.deletable!==!1),x=a1(c,p);for(const m of p)h.has(m.id)&&!x.find(k=>k.id===m.id)&&x.push(m);if(!a)return{edges:x,nodes:c};const v=await a({nodes:c,edges:x});return typeof v=="boolean"?v?{edges:x,nodes:c}:{edges:[],nodes:[]}:v}const Ji=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),pi=(t={x:0,y:0},r,o)=>({x:Ji(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:Ji(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function fg(t,r,o){const{width:s,height:a}=vn(o),{x:u,y:c}=o.internals.positionAbsolute;return pi(t,[[u,c],[u+s,c+a]],r)}const jh=(t,r,o)=>to?-Ji(Math.abs(t-o),1,r)/r:0,jc=(t,r,o=15,s=40)=>{const a=jh(t.x,s,r.width-s)*o,u=jh(t.y,s,r.height-s)*o;return[a,u]},Zl=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),cc=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),Jl=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),ss=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=kc(t)?t.internals.positionAbsolute:hs(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},Hl=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=kc(t)?t.internals.positionAbsolute:hs(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},hg=(t,r)=>Jl(Zl(cc(t),cc(r))),pg=(t,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),y=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*y)},Bl=(t,r)=>pg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),bh=t=>pn(t.width)&&pn(t.height)&&pn(t.x)&&pn(t.y),pn=t=>!isNaN(t)&&isFinite(t),gg=(t,r)=>(o,s)=>{},gs=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),ms=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(t-o)/a,y:(r-s)/a};return u?gs(h,c):h},eo=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Yi(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function f1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Yi(t,o),a=Yi(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Yi(t.top??t.y??0,o),a=Yi(t.bottom??t.y??0,o),u=Yi(t.left??t.x??0,r),c=Yi(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function h1(t,r,o,s,a,u){const{x:c,y:h}=eo(t,[r,o,s]),{x:p,y}=eo({x:t.x+t.width,y:t.y+t.height},[r,o,s]),x=a-p,v=u-y;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(x),bottom:Math.floor(v)}}const bc=(t,r,o,s,a,u)=>{const c=f1(u,r,o),h=(r-c.x)/t.width,p=(o-c.y)/t.height,y=Math.min(h,p),x=Ji(y,s,a),v=t.x+t.width/2,m=t.y+t.height/2,_=r/2-v*x,k=o/2-m*x,j=h1(t,_,k,x,r,o),b={left:Math.min(j.left-c.left,0),top:Math.min(j.top-c.top,0),right:Math.min(j.right-c.right,0),bottom:Math.min(j.bottom-c.bottom,0)};return{x:_-b.left+b.right,y:k-b.top+b.bottom,zoom:x}},ls=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function gi(t){return t!=null&&t!=="parent"}function vn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function mg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function yg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function Eh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function p1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function g1(t){return{...lg,...t||{}}}function Qo(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=gn(t),h=ms({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y}=o?gs(h,r):h;return{xSnapped:p,ySnapped:y,...h}}const Ec=t=>({width:t.offsetWidth,height:t.offsetHeight}),vg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},m1=["INPUT","SELECT","TEXTAREA"];function xg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:m1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const wg=t=>"clientX"in t,gn=(t,r)=>{var u,c;const o=wg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},Ch=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...Ec(c)}})};function _g({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=t*.125+a*.375+c*.375+o*.125,y=r*.125+u*.375+h*.375+s*.125,x=Math.abs(p-t),v=Math.abs(y-r);return[p,y,x,v]}function kl(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function Mh({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case Se.Left:return[r-kl(r-s,u),o];case Se.Right:return[r+kl(s-r,u),o];case Se.Top:return[r,o-kl(o-a,u)];case Se.Bottom:return[r,o+kl(a-o,u)]}}function Sg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top,curvature:c=.25}){const[h,p]=Mh({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[y,x]=Mh({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[v,m,_,k]=_g({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:y,targetControlY:x});return[`M${t},${r} C${h},${p} ${y},${x} ${s},${a}`,v,m,_,k]}function kg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const x1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,w1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),_1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",mn.error006()),r;const s=o.getEdgeId||x1;let a;return cg(t)?a={...t}:a={...t,id:s(t)},w1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function Ng({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=kg({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,h]}const Ph={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},S1=({source:t,sourcePosition:r=Se.Bottom,target:o})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function k1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:s=Se.Top,center:a,offset:u,stepPosition:c}){const h=Ph[r],p=Ph[s],y={x:t.x+h.x*u,y:t.y+h.y*u},x={x:o.x+p.x*u,y:o.y+p.y*u},v=S1({source:y,sourcePosition:r,target:x}),m=v.x!==0?"x":"y",_=v[m];let k=[],j,b;const E={x:0,y:0},R={x:0,y:0},[,,w,N]=kg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[m]*p[m]===-1){m==="x"?(j=a.x??y.x+(x.x-y.x)*c,b=a.y??(y.y+x.y)/2):(j=a.x??(y.x+x.x)/2,b=a.y??y.y+(x.y-y.y)*c);const G=[{x:j,y:y.y},{x:j,y:x.y}],q=[{x:y.x,y:b},{x:x.x,y:b}];h[m]===_?k=m==="x"?G:q:k=m==="x"?q:G}else{const G=[{x:y.x,y:x.y}],q=[{x:x.x,y:y.y}];if(m==="x"?k=h.x===_?q:G:k=h.y===_?G:q,r===s){const C=Math.abs(t[m]-o[m]);if(C<=u){const V=Math.min(u-1,u-C);h[m]===_?E[m]=(y[m]>t[m]?-1:1)*V:R[m]=(x[m]>o[m]?-1:1)*V}}if(r!==s){const C=m==="x"?"y":"x",V=h[m]===p[C],W=y[C]>x[C],U=y[C]=K?(j=(te.x+ee.x)/2,b=k[0].y):(j=k[0].x,b=(te.y+ee.y)/2)}const A={x:y.x+E.x,y:y.y+E.y},$={x:x.x+R.x,y:x.y+R.y};return[[t,...A.x!==k[0].x||A.y!==k[0].y?[A]:[],...k,...$.x!==k[k.length-1].x||$.y!==k[k.length-1].y?[$]:[],o],j,b,w,N]}function N1(t,r,o,s){const a=Math.min(Ih(t,r)/2,Ih(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const y=t.xo.id===r):t[0])||null}function dc(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function b1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const y=dc(p,r);u.has(y)||(c.push({id:y,color:p.color||o,...p}),u.add(y))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const jg=1e3,E1=10,Cc={nodeOrigin:[0,0],nodeExtent:rs,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},C1={...Cc,checkEquality:!0};function Mc(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function M1(t,r,o){const s=Mc(Cc,o);for(const a of t.values())if(a.parentId)Ic(a,t,r,s);else{const u=hs(a,s.nodeOrigin),c=gi(a.extent)?a.extent:s.nodeExtent,h=pi(u,c,vn(a));a.internals.positionAbsolute=h}}function P1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function Pc(t){return t==="manual"}function fc(t,r,o,s={}){var x,v;const a=Mc(C1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!Pc(a.zIndexMode)?jg:0;let p=t.length>0,y=!1;r.clear(),o.clear();for(const m of t){let _=c.get(m.id);if(a.checkEquality&&m===(_==null?void 0:_.internals.userNode))r.set(m.id,_);else{const k=hs(m,a.nodeOrigin),j=gi(m.extent)?m.extent:a.nodeExtent,b=pi(k,j,vn(m));_={...a.defaults,...m,measured:{width:(x=m.measured)==null?void 0:x.width,height:(v=m.measured)==null?void 0:v.height},internals:{positionAbsolute:b,handleBounds:P1(m,_),z:bg(m,h,a.zIndexMode),userNode:m}},r.set(m.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),m.parentId&&Ic(_,r,o,s,u),y||(y=m.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:y}}function I1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function Ic(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=Mc(Cc,s),y=t.parentId,x=r.get(y);if(!x){console.warn(`Parent node ${y} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}I1(t,o),a&&!x.parentId&&x.internals.rootParentIndex===void 0&&p==="auto"&&(x.internals.rootParentIndex=++a.i,x.internals.z=x.internals.z+a.i*E1),a&&x.internals.rootParentIndex!==void 0&&(a.i=x.internals.rootParentIndex);const v=u&&!Pc(p)?jg:0,{x:m,y:_,z:k}=R1(t,x,c,h,v,p),{positionAbsolute:j}=t.internals,b=m!==j.x||_!==j.y;(b||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:b?{x:m,y:_}:j,z:k}})}function bg(t,r,o){const s=pn(t.zIndex)?t.zIndex:0;return Pc(o)?s:s+(t.selected?r:0)}function R1(t,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=vn(t),y=hs(t,o),x=gi(t.extent)?pi(y,t.extent,p):y;let v=pi({x:c+x.x,y:h+x.y},s,p);t.extent==="parent"&&(v=fg(v,p,r));const m=bg(t,a,u),_=r.internals.z??0;return{x:v.x,y:v.y,z:_>=m?_+1:m}}function Rc(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const y=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??ss(p),x=hg(y,h.rect);u.set(h.parentId,{expandedRect:x,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},y)=>{var w;const x=p.internals.positionAbsolute,v=vn(p),m=p.origin??s,_=h.x0||k>0||E||R)&&(a.push({id:y,type:"position",position:{x:p.position.x-_+E,y:p.position.y-k+R}}),(w=o.get(y))==null||w.forEach(N=>{t.some(A=>A.id===N.id)||a.push({id:N.id,type:"position",position:{x:N.position.x+_,y:N.position.y+k}})})),(v.width0){const _=Rc(m,r,o,a);y.push(..._)}return{changes:y,updatedInternals:p}}async function L1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Ah(t,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${t}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${t}-${u}`;const y=s.get(c)||new Map;s.set(c,y.set(o,r))}}function Eg(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},y=`${a}-${c}--${u}-${h}`,x=`${u}-${h}--${a}-${c}`;Ah("source",p,x,t,a,c),Ah("target",p,y,t,u,h),r.set(s.id,s)}}function Cg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:Cg(o,r):!1}function $h(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function A1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!Cg(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function Vu({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[y,x]of r){const v=(c=o.get(y))==null?void 0:c.internals.userNode;v&&a.push({...v,position:x.position,dragging:s})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function $1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=gs(u,r);return{x:c.x-u.x,y:c.y-u.y}}function z1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,y={x:0,y:0},x=null,v=!1,m=null,_=!1,k=!1,j=null;function b({noDragClassName:R,handleSelector:w,domNode:N,isSelectable:A,nodeId:$,nodeClickDistance:F=0}){m=Gt(N);function G({x:ne,y:K}){const{nodeLookup:C,nodeExtent:V,snapGrid:W,snapToGrid:U,nodeOrigin:M,onNodeDrag:D,onSelectionDrag:H,onError:I,updateNodePositions:z}=r();u={x:ne,y:K};let ie=!1;const oe=h.size>1,fe=oe&&V?cc(ps(h)):null,he=oe&&U?$1({dragItems:h,snapGrid:W,x:ne,y:K}):null;for(const[pe,Z]of h){if(!C.has(pe))continue;let se={x:ne-Z.distance.x,y:K-Z.distance.y};U&&(se=he?{x:Math.round(se.x+he.x),y:Math.round(se.y+he.y)}:gs(se,W));let me=null;if(oe&&V&&!Z.extent&&fe){const{positionAbsolute:re}=Z.internals,Ne=re.x-fe.x+V[0][0],Me=re.x+Z.measured.width-fe.x2+V[1][0],Te=re.y-fe.y+V[0][1],$e=re.y+Z.measured.height-fe.y2+V[1][1];me=[[Ne,Te],[Me,$e]]}const{position:ke,positionAbsolute:ve}=dg({nodeId:pe,nextPosition:se,nodeLookup:C,nodeExtent:me||V,nodeOrigin:M,onError:I});ie=ie||Z.position.x!==ke.x||Z.position.y!==ke.y,Z.position=ke,Z.internals.positionAbsolute=ve}if(k=k||ie,!!ie&&(z(h,!0),j&&(s||D||!$&&H))){const[pe,Z]=Vu({nodeId:$,dragItems:h,nodeLookup:C});s==null||s(j,h,pe,Z),D==null||D(j,pe,Z),$||H==null||H(j,Z)}}async function q(){if(!x)return;const{transform:ne,panBy:K,autoPanSpeed:C,autoPanOnNodeDrag:V}=r();if(!V){p=!1,cancelAnimationFrame(c);return}const[W,U]=jc(y,x,C);(W!==0||U!==0)&&(u.x=(u.x??0)-W/ne[2],u.y=(u.y??0)-U/ne[2],await K({x:W,y:U})&&G(u)),c=requestAnimationFrame(q)}function te(ne){var oe;const{nodeLookup:K,multiSelectionActive:C,nodesDraggable:V,transform:W,snapGrid:U,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:H,onSelectionDragStart:I,unselectNodesAndEdges:z}=r();v=!0,(!D||!A)&&!C&&$&&((oe=K.get($))!=null&&oe.selected||z()),A&&D&&$&&(t==null||t($));const ie=Qo(ne.sourceEvent,{transform:W,snapGrid:U,snapToGrid:M,containerBounds:x});if(u=ie,h=A1(K,V,ie,$),h.size>0&&(o||H||!$&&I)){const[fe,he]=Vu({nodeId:$,dragItems:h,nodeLookup:K});o==null||o(ne.sourceEvent,h,fe,he),H==null||H(ne.sourceEvent,fe,he),$||I==null||I(ne.sourceEvent,he)}}const ee=Wp().clickDistance(F).on("start",ne=>{const{domNode:K,nodeDragThreshold:C,transform:V,snapGrid:W,snapToGrid:U}=r();x=(K==null?void 0:K.getBoundingClientRect())||null,_=!1,k=!1,j=ne.sourceEvent,C===0&&te(ne),u=Qo(ne.sourceEvent,{transform:V,snapGrid:W,snapToGrid:U,containerBounds:x}),y=gn(ne.sourceEvent,x)}).on("drag",ne=>{const{autoPanOnNodeDrag:K,transform:C,snapGrid:V,snapToGrid:W,nodeDragThreshold:U,nodeLookup:M}=r(),D=Qo(ne.sourceEvent,{transform:C,snapGrid:V,snapToGrid:W,containerBounds:x});if(j=ne.sourceEvent,(ne.sourceEvent.type==="touchmove"&&ne.sourceEvent.touches.length>1||$&&!M.has($))&&(_=!0),!_){if(!p&&K&&v&&(p=!0,q()),!v){const H=gn(ne.sourceEvent,x),I=H.x-y.x,z=H.y-y.y;Math.sqrt(I*I+z*z)>U&&te(ne)}(u.x!==D.xSnapped||u.y!==D.ySnapped)&&h&&v&&(y=gn(ne.sourceEvent,x),G(D))}}).on("end",ne=>{if(!v||_){_&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,v=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:K,updateNodePositions:C,onNodeDragStop:V,onSelectionDragStop:W}=r();if(k&&(C(h,!1),k=!1),a||V||!$&&W){const[U,M]=Vu({nodeId:$,dragItems:h,nodeLookup:K,dragging:!1});a==null||a(ne.sourceEvent,h,U,M),V==null||V(ne.sourceEvent,U,M),$||W==null||W(ne.sourceEvent,M)}}}).filter(ne=>{const K=ne.target;return!ne.button&&(!R||!$h(K,`.${R}`,N))&&(!w||$h(K,w,N))});m.call(ee)}function E(){m==null||m.on(".drag",null)}return{update:b,destroy:E}}function D1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())Bl(a,ss(u))>0&&s.push(u);return s}const O1=250;function F1(t,r,o,s){var h,p;let a=[],u=1/0;const c=D1(t,o,r+O1);for(const y of c){const x=[...((h=y.internals.handleBounds)==null?void 0:h.source)??[],...((p=y.internals.handleBounds)==null?void 0:p.target)??[]];for(const v of x){if(s.nodeId===v.nodeId&&s.type===v.type&&s.id===v.id)continue;const{x:m,y:_}=mi(y,v,v.position,!0),k=Math.sqrt(Math.pow(m-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const y=s.type==="source"?"target":"source";return a.find(x=>x.type===y)??a[0]}return a[0]}function Mg(t,r,o,s,a,u=!1){var y,x,v;const c=s.get(t);if(!c)return null;const h=a==="strict"?(y=c.internals.handleBounds)==null?void 0:y[r]:[...((x=c.internals.handleBounds)==null?void 0:x.source)??[],...((v=c.internals.handleBounds)==null?void 0:v.target)??[]],p=(o?h==null?void 0:h.find(m=>m.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...mi(c,p,p.position,!0)}:p}function Pg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function H1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const Ig=()=>!0;function B1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:y,autoPanOnConnect:x,flowId:v,panBy:m,cancelConnection:_,onConnectStart:k,onConnect:j,onConnectEnd:b,isValidConnection:E=Ig,onReconnectEnd:R,updateConnection:w,getTransform:N,getFromHandle:A,autoPanSpeed:$,dragThreshold:F=1,handleDomNode:G}){const q=vg(t.target);let te=0,ee;const{x:ne,y:K}=gn(t),C=Pg(u,G),V=h==null?void 0:h.getBoundingClientRect();let W=!1;if(!V||!C)return;const U=Mg(a,C,s,p,r);if(!U)return;let M=gn(t,V),D=!1,H=null,I=!1,z=null;function ie(){if(!x||!V)return;const[ke,ve]=jc(M,V,$);m({x:ke,y:ve}),te=requestAnimationFrame(ie)}const oe={...U,nodeId:a,type:C,position:U.position},fe=p.get(a);let pe={inProgress:!0,isValid:null,from:mi(fe,oe,Se.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:fe,to:M,toHandle:null,toPosition:Nh[oe.position],toNode:null,pointer:M};function Z(){W=!0,w(pe),k==null||k(t,{nodeId:a,handleId:s,handleType:C})}F===0&&Z();function se(ke){if(!W){const{x:$e,y:st}=gn(ke),lt=$e-ne,at=st-K;if(!(lt*lt+at*at>F*F))return;Z()}if(!A()||!oe){me(ke);return}const ve=N();M=gn(ke,V),ee=F1(ms(M,ve,!1,[1,1]),o,p,oe),D||(ie(),D=!0);const re=Rg(ke,{handle:ee,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:E,doc:q,lib:y,flowId:v,nodeLookup:p});z=re.handleDomNode,H=re.connection,I=H1(!!ee,re.isValid);const Ne=p.get(a),Me=Ne?mi(Ne,oe,Se.Left,!0):pe.from,Te={...pe,from:Me,isValid:I,to:re.toHandle&&I?eo({x:re.toHandle.x,y:re.toHandle.y},ve):M,toHandle:re.toHandle,toPosition:I&&re.toHandle?re.toHandle.position:Nh[oe.position],toNode:re.toHandle?p.get(re.toHandle.nodeId):null,pointer:M};w(Te),pe=Te}function me(ke){if(!("touches"in ke&&ke.touches.length>0)){if(W){(ee||z)&&H&&I&&(j==null||j(H));const{inProgress:ve,...re}=pe,Ne={...re,toPosition:pe.toHandle?pe.toPosition:null};b==null||b(ke,Ne),u&&(R==null||R(ke,Ne))}_(),cancelAnimationFrame(te),D=!1,I=!1,H=null,z=null,q.removeEventListener("mousemove",se),q.removeEventListener("mouseup",me),q.removeEventListener("touchmove",se),q.removeEventListener("touchend",me)}}q.addEventListener("mousemove",se),q.addEventListener("mouseup",me),q.addEventListener("touchmove",se),q.addEventListener("touchend",me)}function Rg(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:y=Ig,nodeLookup:x}){const v=u==="target",m=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=gn(t),j=c.elementFromPoint(_,k),b=j!=null&&j.classList.contains(`${h}-flow__handle`)?j:m,E={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const R=Pg(void 0,b),w=b.getAttribute("data-nodeid"),N=b.getAttribute("data-handleid"),A=b.classList.contains("connectable"),$=b.classList.contains("connectableend");if(!w||!R)return E;const F={source:v?w:s,sourceHandle:v?N:a,target:v?s:w,targetHandle:v?a:N};E.connection=F;const q=A&&$&&(o===Zi.Strict?v&&R==="source"||!v&&R==="target":w!==s||N!==a);E.isValid=q&&y(F),E.toHandle=Mg(w,R,N,x,o,!0)}return E}const hc={onPointerDown:B1,isValid:Rg};function V1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Gt(t);function u({translateExtent:h,width:p,height:y,zoomStep:x=1,pannable:v=!0,zoomable:m=!0,inversePan:_=!1}){const k=w=>{if(w.sourceEvent.type!=="wheel"||!r)return;const N=o(),A=w.sourceEvent.ctrlKey&&ls()?10:1,$=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*x,F=N[2]*Math.pow(2,$*A);r.scaleTo(F)};let j=[0,0];const b=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(j=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},E=w=>{const N=o();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!r)return;const A=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],$=[A[0]-j[0],A[1]-j[1]];j=A;const F=s()*Math.max(N[2],Math.log(N[2]))*(_?-1:1),G={x:N[0]-$[0]*F,y:N[1]-$[1]*F},q=[[0,0],[p,y]];r.setViewportConstrained({x:G.x,y:G.y,zoom:N[2]},q,h)},R=og().on("start",b).on("zoom",v?E:null).on("zoom.wheel",m?k:null);a.call(R,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:fn}}const ea=t=>({x:t.x,y:t.y,zoom:t.k}),Wu=({x:t,y:r,zoom:o})=>Ql.translate(t,r).scale(o),Rr=(t,r)=>t.target.closest(`.${r}`),Tg=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),W1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Uu=(t,r=0,o=W1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Lg=t=>{const r=t.ctrlKey&&ls()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function U1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:y}){return x=>{if(Rr(x,r))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const v=o.property("__zoom").k||1;if(x.ctrlKey&&c){const b=fn(x),E=Lg(x),R=v*Math.pow(2,E);s.scaleTo(o,R,b,x);return}const m=x.deltaMode===1?20:1;let _=a===di.Vertical?0:x.deltaX*m,k=a===di.Horizontal?0:x.deltaY*m;!ls()&&x.shiftKey&&a!==di.Vertical&&(_=x.deltaY*m,k=0),s.translateBy(o,-(_/v)*u,-(k/v)*u,{internal:!0});const j=ea(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(x,j):(t.isPanScrolling=!0,h==null||h(x,j)),t.panScrollTimeout=setTimeout(()=>{y==null||y(x,j),t.isPanScrolling=!1},150)}}function Y1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=Rr(s,t);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function G1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=ea(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function X1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;t.usedRightMouseButton=!!(o&&Tg(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,ea(u.transform)))}}function q1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&Tg(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const p=ea(c.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function K1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:y,lib:x,connectionInProgress:v}){return m=>{var E;const _=r||o,k=s&&m.ctrlKey,j=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(Rr(m,`${x}-flow__node`)||Rr(m,`${x}-flow__edge`)||Rr(m,`${x}-flow__selection`)||Rr(m,`${x}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!c&&!s||h||v&&!j||Rr(m,p)&&j||Rr(m,y)&&(!j||u&&j&&!r)||!s&&m.ctrlKey&&j)return!1;if(!s&&m.type==="touchstart"&&((E=m.touches)==null?void 0:E.length)>1)return m.preventDefault(),!1;if(!_&&!u&&!k&&j||!a&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(a)&&!a.includes(m.button)&&m.type==="mousedown")return!1;const b=Array.isArray(a)&&a.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||j||t)&&b}}function Q1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const y={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=t.getBoundingClientRect();let v=[[0,0],[x.width,x.height]];const m=typeof ResizeObserver<"u"?new ResizeObserver(K=>{const C=K[0];C&&(v=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;m==null||m.observe(t);const _=og().extent(()=>v).scaleExtent([r,o]).translateExtent(s),k=Gt(t).call(_);N({x:a.x,y:a.y,zoom:Ji(a.zoom,r,o)},[[0,0],[x.width,x.height]],s);const j=k.on("wheel.zoom"),b=k.on("dblclick.zoom");_.wheelDelta(Lg);async function E(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Pl).transform(Uu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function R({noWheelClassName:K,noPanClassName:C,onPaneContextMenu:V,userSelectionActive:W,panOnScroll:U,panOnDrag:M,panOnScrollMode:D,panOnScrollSpeed:H,preventScrolling:I,zoomOnPinch:z,zoomOnScroll:ie,zoomOnDoubleClick:oe,panActivationKeyPressed:fe=!1,zoomActivationKeyPressed:he,lib:pe,onTransformChange:Z,connectionInProgress:se,paneClickDistance:me,selectionOnDrag:ke}){W&&!y.isZoomingOrPanning&&w();const ve=U&&!he&&!W;_.clickDistance(ke?1/0:!pn(me)||me<0?0:me);const re=ve?U1({zoomPanValues:y,noWheelClassName:K,d3Selection:k,d3Zoom:_,panOnScrollMode:D,panOnScrollSpeed:H,zoomOnPinch:z,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):Y1({noWheelClassName:K,preventScrolling:I,d3ZoomHandler:j});k.on("wheel.zoom",re,{passive:!1});const Ne=G1({zoomPanValues:y,onDraggingChange:p,onPanZoomStart:c});_.on("start",Ne);const Me=X1({zoomPanValues:y,panOnDrag:M,onPaneContextMenu:!!V,onPanZoom:u,onTransformChange:Z});_.on("zoom",Me);const Te=q1({zoomPanValues:y,panOnDrag:M,panOnScroll:U,onPaneContextMenu:V,onPanZoomEnd:h,onDraggingChange:p});_.on("end",Te);const $e=K1({panActivationKeyPressed:fe,zoomActivationKeyPressed:he,panOnDrag:M,zoomOnScroll:ie,panOnScroll:U,zoomOnDoubleClick:oe,zoomOnPinch:z,userSelectionActive:W,noPanClassName:C,noWheelClassName:K,lib:pe,connectionInProgress:se});_.filter($e),oe?k.on("dblclick.zoom",b):k.on("dblclick.zoom",null)}function w(){_.on("zoom",null)}async function N(K,C,V){const W=Wu(K),U=_==null?void 0:_.constrain()(W,C,V);return U&&await E(U),U}async function A(K,C){const V=Wu(K);return await E(V,C),V}function $(K){if(k){const C=Wu(K),V=k.property("__zoom");(V.k!==K.zoom||V.x!==K.x||V.y!==K.y)&&(_==null||_.transform(k,C,null,{sync:!0}))}}function F(){const K=k?ig(k.node()):{x:0,y:0,k:1};return{x:K.x,y:K.y,zoom:K.k}}async function G(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Pl).scaleTo(Uu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}async function q(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Pl).scaleBy(Uu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function te(K){_==null||_.scaleExtent(K)}function ee(K){_==null||_.translateExtent(K)}function ne(K){const C=!pn(K)||K<0?0:K;_==null||_.clickDistance(C)}return{update:R,destroy:w,setViewport:A,setViewportConstrained:N,getViewport:F,scaleTo:G,scaleBy:q,setScaleExtent:te,setTranslateExtent:ee,syncViewport:$,setClickDistance:ne}}var to;(function(t){t.Line="line",t.Handle="handle"})(to||(to={}));function Z1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function zh(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function Pr(t,r){return Math.max(0,r-t)}function Ir(t,r){return Math.max(0,t-r)}function Nl(t,r,o){return Math.max(0,r-t,t-o)}function Dh(t,r){return t?!r:r}function J1(t,r,o,s,a,u,c,h){let{affectsX:p,affectsY:y}=r;const{isHorizontal:x,isVertical:v}=r,m=x&&v,{xSnapped:_,ySnapped:k}=o,{minWidth:j,maxWidth:b,minHeight:E,maxHeight:R}=s,{x:w,y:N,width:A,height:$,aspectRatio:F}=t;let G=Math.floor(x?_-t.pointerX:0),q=Math.floor(v?k-t.pointerY:0);const te=A+(p?-G:G),ee=$+(y?-q:q),ne=-u[0]*A,K=-u[1]*$;let C=Nl(te,j,b),V=Nl(ee,E,R);if(c){let M=0,D=0;p&&G<0?M=Pr(w+G+ne,c[0][0]):!p&&G>0&&(M=Ir(w+te+ne,c[1][0])),y&&q<0?D=Pr(N+q+K,c[0][1]):!y&&q>0&&(D=Ir(N+ee+K,c[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(h){let M=0,D=0;p&&G>0?M=Ir(w+G,h[0][0]):!p&&G<0&&(M=Pr(w+te,h[1][0])),y&&q>0?D=Ir(N+q,h[0][1]):!y&&q<0&&(D=Pr(N+ee,h[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(a){if(x){const M=Nl(te/F,E,R)*F;if(C=Math.max(C,M),c){let D=0;!p&&!y||p&&!y&&m?D=Ir(N+K+te/F,c[1][1])*F:D=Pr(N+K+(p?G:-G)/F,c[0][1])*F,C=Math.max(C,D)}if(h){let D=0;!p&&!y||p&&!y&&m?D=Pr(N+te/F,h[1][1])*F:D=Ir(N+(p?G:-G)/F,h[0][1])*F,C=Math.max(C,D)}}if(v){const M=Nl(ee*F,j,b)/F;if(V=Math.max(V,M),c){let D=0;!p&&!y||y&&!p&&m?D=Ir(w+ee*F+ne,c[1][0])/F:D=Pr(w+(y?q:-q)*F+ne,c[0][0])/F,V=Math.max(V,D)}if(h){let D=0;!p&&!y||y&&!p&&m?D=Pr(w+ee*F,h[1][0])/F:D=Ir(w+(y?q:-q)*F,h[0][0])/F,V=Math.max(V,D)}}}q=q+(q<0?V:-V),G=G+(G<0?C:-C),a&&(m?te>ee*F?q=(Dh(p,y)?-G:G)/F:G=(Dh(p,y)?-q:q)*F:x?(q=G/F,y=p):(G=q*F,p=y));const W=p?w+G:w,U=y?N+q:N;return{width:A+(p?-G:G),height:$+(y?-q:q),x:u[0]*G*(p?-1:1)+W,y:u[1]*q*(y?-1:1)+U}}const Ag={width:0,height:0,x:0,y:0},e_={...Ag,pointerX:0,pointerY:0,aspectRatio:1};function t_(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function n_({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Gt(t);let c={controlDirection:zh("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:y,boundaries:x,keepAspectRatio:v,resizeDirection:m,onResizeStart:_,onResize:k,onResizeEnd:j,shouldResize:b}){let E={...Ag},R={...e_};c={boundaries:x,resizeDirection:m,keepAspectRatio:v,controlDirection:zh(y)};let w,N=null,A=[],$,F,G,q=!1;const te=Wp().on("start",ee=>{const{nodeLookup:ne,transform:K,snapGrid:C,snapToGrid:V,nodeOrigin:W,paneDomNode:U}=o();if(w=ne.get(r),!w)return;N=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:D}=Qo(ee.sourceEvent,{transform:K,snapGrid:C,snapToGrid:V,containerBounds:N});E={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},R={...E,pointerX:M,pointerY:D,aspectRatio:E.width/E.height},$=void 0,F=gi(w.extent)?w.extent:void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&($=ne.get(w.parentId)),$&&w.extent==="parent"&&(F=[[0,0],[$.measured.width,$.measured.height]]),A=[],G=void 0;for(const[H,I]of ne)if(I.parentId===r&&(A.push({id:H,position:{...I.position},extent:I.extent}),I.extent==="parent"||I.expandParent)){const z=t_(I,w,I.origin??W);G?G=[[Math.min(z[0][0],G[0][0]),Math.min(z[0][1],G[0][1])],[Math.max(z[1][0],G[1][0]),Math.max(z[1][1],G[1][1])]]:G=z}_==null||_(ee,{...E})}).on("drag",ee=>{const{transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V}=o(),W=Qo(ee.sourceEvent,{transform:ne,snapGrid:K,snapToGrid:C,containerBounds:N}),U=[];if(!w)return;const{x:M,y:D,width:H,height:I}=E,z={},ie=w.origin??V,{width:oe,height:fe,x:he,y:pe}=J1(R,c.controlDirection,W,c.boundaries,c.keepAspectRatio,ie,F,G),Z=oe!==H,se=fe!==I,me=he!==M&&Z,ke=pe!==D&&se;if(!me&&!ke&&!Z&&!se)return;if((me||ke||ie[0]===1||ie[1]===1)&&(z.x=me?he:E.x,z.y=ke?pe:E.y,E.x=z.x,E.y=z.y,A.length>0)){const Me=he-M,Te=pe-D;for(const $e of A)$e.position={x:$e.position.x-Me+ie[0]*(oe-H),y:$e.position.y-Te+ie[1]*(fe-I)},U.push($e)}if((Z||se)&&(z.width=Z&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:E.width,z.height=se&&(!c.resizeDirection||c.resizeDirection==="vertical")?fe:E.height,E.width=z.width,E.height=z.height),$&&w.expandParent){const Me=ie[0]*(z.width??0);z.x&&z.x{q&&(j==null||j(ee,{...E}),a==null||a({...E}),q=!1)});u.call(te)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Yu={exports:{}},Gu={},Xu={exports:{}},qu={};/** * @license React * use-sync-external-store-shim.production.js * @@ -45,7 +45,7 @@ Error generating stack: `+g.message+` * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Dh;function n_(){if(Dh)return Gu;Dh=1;var t=cs();function r(v,m){return v===m&&(v!==0||1/v===1/m)||v!==v&&m!==m}var o=typeof Object.is=="function"?Object.is:r,s=t.useState,a=t.useEffect,u=t.useLayoutEffect,c=t.useDebugValue;function h(v,m){var _=m(),k=s({inst:{value:_,getSnapshot:m}}),j=k[0].inst,b=k[1];return u(function(){j.value=_,j.getSnapshot=m,p(j)&&b({inst:j})},[v,_,m]),a(function(){return p(j)&&b({inst:j}),v(function(){p(j)&&b({inst:j})})},[v]),c(_),_}function p(v){var m=v.getSnapshot;v=v.value;try{var _=m();return!o(v,_)}catch{return!0}}function y(v,m){return m()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:h;return Gu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:x,Gu}var Oh;function r_(){return Oh||(Oh=1,Xu.exports=n_()),Xu.exports}/** + */var Oh;function r_(){if(Oh)return qu;Oh=1;var t=cs();function r(v,m){return v===m&&(v!==0||1/v===1/m)||v!==v&&m!==m}var o=typeof Object.is=="function"?Object.is:r,s=t.useState,a=t.useEffect,u=t.useLayoutEffect,c=t.useDebugValue;function h(v,m){var _=m(),k=s({inst:{value:_,getSnapshot:m}}),j=k[0].inst,b=k[1];return u(function(){j.value=_,j.getSnapshot=m,p(j)&&b({inst:j})},[v,_,m]),a(function(){return p(j)&&b({inst:j}),v(function(){p(j)&&b({inst:j})})},[v]),c(_),_}function p(v){var m=v.getSnapshot;v=v.value;try{var _=m();return!o(v,_)}catch{return!0}}function y(v,m){return m()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:h;return qu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:x,qu}var Fh;function i_(){return Fh||(Fh=1,Xu.exports=r_()),Xu.exports}/** * @license React * use-sync-external-store-shim/with-selector.production.js * @@ -53,10 +53,10 @@ Error generating stack: `+g.message+` * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Fh;function i_(){if(Fh)return Yu;Fh=1;var t=cs(),r=r_();function o(y,x){return y===x&&(y!==0||1/y===1/x)||y!==y&&x!==x}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Yu.useSyncExternalStoreWithSelector=function(y,x,v,m,_){var k=u(null);if(k.current===null){var j={hasValue:!1,value:null};k.current=j}else j=k.current;k=h(function(){function E($){if(!R){if(R=!0,w=$,$=m($),_!==void 0&&j.hasValue){var F=j.value;if(_(F,$))return N=F}return N=$}if(F=N,s(w,$))return F;var X=m($);return _!==void 0&&_(F,X)?(w=$,F):(w=$,N=X)}var R=!1,w,N,A=v===void 0?null:v;return[function(){return E(x())},A===null?void 0:function(){return E(A())}]},[x,v,m,_]);var b=a(y,k[0],k[1]);return c(function(){j.hasValue=!0,j.value=b},[b]),p(b),b},Yu}var Hh;function o_(){return Hh||(Hh=1,Uu.exports=i_()),Uu.exports}var s_=o_();const l_=jp(s_),a_={},Bh=t=>{let r;const o=new Set,s=(x,v)=>{const m=typeof x=="function"?x(r):x;if(!Object.is(m,r)){const _=r;r=v??(typeof m!="object"||m===null)?m:Object.assign({},r,m),o.forEach(k=>k(r,_))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>y,subscribe:x=>(o.add(x),()=>o.delete(x)),destroy:()=>{(a_?"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."),o.clear()}},y=r=t(s,a,p);return p},u_=t=>t?Bh(t):Bh,{useDebugValue:c_}=o0,{useSyncExternalStoreWithSelector:d_}=l_,f_=t=>t;function Ag(t,r=f_,o){const s=d_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return c_(s),s}const Vh=(t,r)=>{const o=u_(t),s=(a,u=r)=>Ag(o,a,u);return Object.assign(s,o),s},h_=(t,r)=>t?Vh(t,r):Vh;function Qe(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}bp();const ea=L.createContext(null),p_=ea.Provider,$g=mn.error001("react");function De(t,r){const o=L.useContext(ea);if(o===null)throw new Error($g);return Ag(o,t,r)}function Ye(){const t=L.useContext(ea);if(t===null)throw new Error($g);return L.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Wh={display:"none"},g_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},zg="react-flow__node-desc",Dg="react-flow__edge-desc",m_="react-flow__aria-live",y_=t=>t.ariaLiveMessage,v_=t=>t.ariaLabelConfig;function x_({rfId:t}){const r=De(y_);return d.jsx("div",{id:`${m_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:g_,children:r})}function w_({rfId:t,disableKeyboardA11y:r}){const o=De(v_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${zg}-${t}`,style:Wh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${Dg}-${t}`,style:Wh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(x_,{rfId:t})]})}const ta=L.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return d.jsx("div",{className:nt(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});ta.displayName="Panel";const Uh="https://reactflow.dev?utm_source=attribution";function __({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:d.jsx(ta,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Uh}`,children:d.jsx("a",{href:Uh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const S_=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},jl=t=>t.id;function k_(t,r){return Qe(t.selectedNodes.map(jl),r.selectedNodes.map(jl))&&Qe(t.selectedEdges.map(jl),r.selectedEdges.map(jl))}function N_({onSelectionChange:t}){const r=Ye(),{selectedNodes:o,selectedEdges:s}=De(S_,k_);return L.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const j_=t=>!!t.onSelectionChangeHandlers;function b_({onSelectionChange:t}){const r=De(j_);return t||r?d.jsx(N_,{onSelectionChange:t}):null}const Og=[0,0],E_={x:0,y:0,zoom:1},C_=["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"],Yh=[...C_,"rfId"],M_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Xh={translateExtent:rs,nodeOrigin:Og,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function P_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=De(M_,Qe),y=Ye();L.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{x.current=Xh,h()}),[]);const x=L.useRef(Xh);return L.useEffect(()=>{for(const v of Yh){const m=t[v],_=x.current[v];m!==_&&(typeof t[v]>"u"||(v==="nodes"?r(m):v==="edges"?o(m):v==="minZoom"?s(m):v==="maxZoom"?a(m):v==="translateExtent"?u(m):v==="nodeExtent"?c(m):v==="ariaLabelConfig"?y.setState({ariaLabelConfig:p1(m)}):v==="fitView"?y.setState({fitViewQueued:m}):v==="fitViewOptions"?y.setState({fitViewOptions:m}):y.setState({[v]:m})))}x.current=t},Yh.map(v=>t[v])),null}function Gh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function I_(t){var s;const[r,o]=L.useState(t==="system"?null:t);return L.useEffect(()=>{if(t!=="system"){o(t);return}const a=Gh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=Gh())!=null&&s.matches?"dark":"light"}const qh=typeof document<"u"?document:null;function as(t=null,r={target:qh,actInsideInputWithModifier:!0}){const[o,s]=L.useState(!1),a=L.useRef(!1),u=L.useRef(new Set([])),[c,h]=L.useMemo(()=>{if(t!==null){const y=(Array.isArray(t)?t:[t]).filter(v=>typeof v=="string").map(v=>v.replace(/\+/g,` + */var Hh;function o_(){if(Hh)return Gu;Hh=1;var t=cs(),r=i_();function o(y,x){return y===x&&(y!==0||1/y===1/x)||y!==y&&x!==x}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Gu.useSyncExternalStoreWithSelector=function(y,x,v,m,_){var k=u(null);if(k.current===null){var j={hasValue:!1,value:null};k.current=j}else j=k.current;k=h(function(){function E($){if(!R){if(R=!0,w=$,$=m($),_!==void 0&&j.hasValue){var F=j.value;if(_(F,$))return N=F}return N=$}if(F=N,s(w,$))return F;var G=m($);return _!==void 0&&_(F,G)?(w=$,F):(w=$,N=G)}var R=!1,w,N,A=v===void 0?null:v;return[function(){return E(x())},A===null?void 0:function(){return E(A())}]},[x,v,m,_]);var b=a(y,k[0],k[1]);return c(function(){j.hasValue=!0,j.value=b},[b]),p(b),b},Gu}var Bh;function s_(){return Bh||(Bh=1,Yu.exports=o_()),Yu.exports}var l_=s_();const a_=bp(l_),u_={},Vh=t=>{let r;const o=new Set,s=(x,v)=>{const m=typeof x=="function"?x(r):x;if(!Object.is(m,r)){const _=r;r=v??(typeof m!="object"||m===null)?m:Object.assign({},r,m),o.forEach(k=>k(r,_))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>y,subscribe:x=>(o.add(x),()=>o.delete(x)),destroy:()=>{(u_?"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."),o.clear()}},y=r=t(s,a,p);return p},c_=t=>t?Vh(t):Vh,{useDebugValue:d_}=s0,{useSyncExternalStoreWithSelector:f_}=a_,h_=t=>t;function $g(t,r=h_,o){const s=f_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return d_(s),s}const Wh=(t,r)=>{const o=c_(t),s=(a,u=r)=>$g(o,a,u);return Object.assign(s,o),s},p_=(t,r)=>t?Wh(t,r):Wh;function Qe(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}Ep();const ta=L.createContext(null),g_=ta.Provider,zg=mn.error001("react");function De(t,r){const o=L.useContext(ta);if(o===null)throw new Error(zg);return $g(o,t,r)}function Ye(){const t=L.useContext(ta);if(t===null)throw new Error(zg);return L.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Uh={display:"none"},m_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Dg="react-flow__node-desc",Og="react-flow__edge-desc",y_="react-flow__aria-live",v_=t=>t.ariaLiveMessage,x_=t=>t.ariaLabelConfig;function w_({rfId:t}){const r=De(v_);return d.jsx("div",{id:`${y_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:m_,children:r})}function __({rfId:t,disableKeyboardA11y:r}){const o=De(x_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${Dg}-${t}`,style:Uh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${Og}-${t}`,style:Uh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(w_,{rfId:t})]})}const na=L.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return d.jsx("div",{className:nt(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});na.displayName="Panel";const Yh="https://reactflow.dev?utm_source=attribution";function S_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:d.jsx(na,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Yh}`,children:d.jsx("a",{href:Yh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const k_=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},jl=t=>t.id;function N_(t,r){return Qe(t.selectedNodes.map(jl),r.selectedNodes.map(jl))&&Qe(t.selectedEdges.map(jl),r.selectedEdges.map(jl))}function j_({onSelectionChange:t}){const r=Ye(),{selectedNodes:o,selectedEdges:s}=De(k_,N_);return L.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const b_=t=>!!t.onSelectionChangeHandlers;function E_({onSelectionChange:t}){const r=De(b_);return t||r?d.jsx(j_,{onSelectionChange:t}):null}const Fg=[0,0],C_={x:0,y:0,zoom:1},M_=["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"],Gh=[...M_,"rfId"],P_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Xh={translateExtent:rs,nodeOrigin:Fg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function I_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=De(P_,Qe),y=Ye();L.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{x.current=Xh,h()}),[]);const x=L.useRef(Xh);return L.useEffect(()=>{for(const v of Gh){const m=t[v],_=x.current[v];m!==_&&(typeof t[v]>"u"||(v==="nodes"?r(m):v==="edges"?o(m):v==="minZoom"?s(m):v==="maxZoom"?a(m):v==="translateExtent"?u(m):v==="nodeExtent"?c(m):v==="ariaLabelConfig"?y.setState({ariaLabelConfig:g1(m)}):v==="fitView"?y.setState({fitViewQueued:m}):v==="fitViewOptions"?y.setState({fitViewOptions:m}):y.setState({[v]:m})))}x.current=t},Gh.map(v=>t[v])),null}function qh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function R_(t){var s;const[r,o]=L.useState(t==="system"?null:t);return L.useEffect(()=>{if(t!=="system"){o(t);return}const a=qh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=qh())!=null&&s.matches?"dark":"light"}const Kh=typeof document<"u"?document:null;function as(t=null,r={target:Kh,actInsideInputWithModifier:!0}){const[o,s]=L.useState(!1),a=L.useRef(!1),u=L.useRef(new Set([])),[c,h]=L.useMemo(()=>{if(t!==null){const y=(Array.isArray(t)?t:[t]).filter(v=>typeof v=="string").map(v=>v.replace(/\+/g,` `).replace(` `,` +`).split(` -`)),x=y.reduce((v,m)=>v.concat(...m),[]);return[y,x]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??qh,y=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const x=_=>{var b,E;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!y)&&vg(_))return!1;const j=Qh(_.code,h);if(u.current.add(_[j]),Kh(c,u.current,!1)){const R=((E=(b=_.composedPath)==null?void 0:b.call(_))==null?void 0:E[0])||_.target,w=(R==null?void 0:R.nodeName)==="BUTTON"||(R==null?void 0:R.nodeName)==="A";r.preventDefault!==!1&&(a.current||!w)&&_.preventDefault(),s(!0)}},v=_=>{const k=Qh(_.code,h);Kh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},m=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",x),p==null||p.addEventListener("keyup",v),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{p==null||p.removeEventListener("keydown",x),p==null||p.removeEventListener("keyup",v),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,s]),o}function Kh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Qh(t,r){return r.includes(t)?"code":"key"}const R_=()=>{const t=Ye();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=jc(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),y={x:r.x-h,y:r.y-p},x=o.snapGrid??a,v=o.snapToGrid??u;return ms(y,s,v,x)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=eo(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function Fg(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)T_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function T_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function L_(t,r){return Fg(t,r)}function A_(t,r){return Fg(t,r)}function ai(t,r){return{id:t,type:"select",selected:r}}function Xi(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(ai(u.id,c)))}return s}function Zh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function Jh(t){return{id:t.id,type:"remove"}}const $_=pg();function z_(t,r,o={}){return w1(t,r,{...o,onError:o.onError??$_})}const ep=t=>o1(t),D_=t=>ug(t);function Hg(t){return L.forwardRef(t)}const Bg=typeof window<"u"?L.useLayoutEffect:L.useEffect;function tp(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>O_(()=>o(a=>a+BigInt(1))));return Bg(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function O_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Vg=L.createContext(null);function F_({children:t}){const r=Ye(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:y,hasDefaultNodes:x,onNodesChange:v,nodeLookup:m,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let j=p;for(const E of h)j=typeof E=="function"?E(j):E;let b=Zh({items:j,lookup:m});for(const E of k.values())b=E(b);x&&y(j),b.length>0?v==null||v(b):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:R,setNodes:w}=r.getState();E&&w(R)})},[]),s=tp(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:y,hasDefaultEdges:x,onEdgesChange:v,edgeLookup:m}=r.getState();let _=p;for(const k of h)_=typeof k=="function"?k(_):k;x?y(_):v&&v(Zh({items:_,lookup:m}))},[]),u=tp(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Vg.Provider,{value:c,children:t})}function H_(){const t=L.useContext(Vg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const B_=t=>!!t.panZoom;function na(){const t=R_(),r=Ye(),o=H_(),s=De(B_),a=L.useMemo(()=>{const u=v=>r.getState().nodeLookup.get(v),c=v=>{o.nodeQueue.push(v)},h=v=>{o.edgeQueue.push(v)},p=v=>{var E,R;const{nodeLookup:m,nodeOrigin:_}=r.getState(),k=ep(v)?v:m.get(v.id),j=k.parentId?mg(k.position,k.measured,k.parentId,m,_):k.position,b={...k,position:j,width:((E=k.measured)==null?void 0:E.width)??k.width,height:((R=k.measured)==null?void 0:R.height)??k.height};return ss(b)},y=(v,m,_={replace:!1})=>{c(k=>k.map(j=>{if(j.id===v){const b=typeof m=="function"?m(j):m;return _.replace&&ep(b)?b:{...j,...b}}return j}))},x=(v,m,_={replace:!1})=>{h(k=>k.map(j=>{if(j.id===v){const b=typeof m=="function"?m(j):m;return _.replace&&D_(b)?b:{...j,...b}}return j}))};return{getNodes:()=>r.getState().nodes.map(v=>({...v})),getNode:v=>{var m;return(m=u(v))==null?void 0:m.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:v=[]}=r.getState();return v.map(m=>({...m}))},getEdge:v=>r.getState().edgeLookup.get(v),setNodes:c,setEdges:h,addNodes:v=>{const m=Array.isArray(v)?v:[v];o.nodeQueue.push(_=>[..._,...m])},addEdges:v=>{const m=Array.isArray(v)?v:[v];o.edgeQueue.push(_=>[..._,...m])},toObject:()=>{const{nodes:v=[],edges:m=[],transform:_}=r.getState(),[k,j,b]=_;return{nodes:v.map(E=>({...E})),edges:m.map(E=>({...E})),viewport:{x:k,y:j,zoom:b}}},deleteElements:async({nodes:v=[],edges:m=[]})=>{const{nodes:_,edges:k,onNodesDelete:j,onEdgesDelete:b,triggerNodeChanges:E,triggerEdgeChanges:R,onDelete:w,onBeforeDelete:N}=r.getState(),{nodes:A,edges:$}=await c1({nodesToRemove:v,edgesToRemove:m,nodes:_,edges:k,onBeforeDelete:N}),F=$.length>0,X=A.length>0;if(F){const q=$.map(Jh);b==null||b($),R(q)}if(X){const q=A.map(Jh);j==null||j(A),E(q)}return(X||F)&&(w==null||w({nodes:A,edges:$})),{deletedNodes:A,deletedEdges:$}},getIntersectingNodes:(v,m=!0,_)=>{const k=jh(v),j=k?v:p(v),b=_!==void 0;return j?(_||r.getState().nodes).filter(E=>{const R=r.getState().nodeLookup.get(E.id);if(R&&!k&&(E.id===v.id||!R.internals.positionAbsolute))return!1;const w=ss(b?E:R),N=Bl(w,j);return m&&N>0||N>=w.width*w.height||N>=j.width*j.height}):[]},isNodeIntersecting:(v,m,_=!0)=>{const j=jh(v)?v:p(v);if(!j)return!1;const b=Bl(j,m);return _&&b>0||b>=m.width*m.height||b>=j.width*j.height},updateNode:y,updateNodeData:(v,m,_={replace:!1})=>{y(v,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},updateEdge:x,updateEdgeData:(v,m,_={replace:!1})=>{x(v,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},getNodesBounds:v=>{const{nodeLookup:m,nodeOrigin:_}=r.getState();return s1(v,{nodeLookup:m,nodeOrigin:_})},getHandleConnections:({type:v,id:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${v}${m?`-${m}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:v,handleId:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${v?m?`-${v}-${m}`:`-${v}`:""}`))==null?void 0:k.values())??[])},fitView:async v=>{const m=r.getState().fitViewResolver??h1();return r.setState({fitViewQueued:!0,fitViewOptions:v,fitViewResolver:m}),o.nodeQueue.push(_=>[..._]),m.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const np=t=>t.selected,V_=typeof window<"u"?window:void 0;function W_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ye(),{deleteElements:s}=na(),a=as(t,{actInsideInputWithModifier:!1}),u=as(r,{target:V_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(np),edges:c.filter(np)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function U_(t){const r=Ye();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=bc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",mn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const ra={position:"absolute",width:"100%",height:"100%",top:0,left:0},Y_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function X_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=di.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:y,translateExtent:x,minZoom:v,maxZoom:m,zoomActivationKeyCode:_,preventScrolling:k=!0,children:j,noWheelClassName:b,noPanClassName:E,onViewportChange:R,isControlledViewport:w,paneClickDistance:N,selectionOnDrag:A}){const $=Ye(),F=L.useRef(null),{userSelectionActive:X,lib:q,connectionInProgress:te}=De(Y_,Qe),ee=as(_),ne=L.useRef();U_(F);const K=L.useCallback(C=>{R==null||R({x:C[0],y:C[1],zoom:C[2]}),w||$.setState({transform:C})},[R,w]);return L.useEffect(()=>{if(F.current){ne.current=K1({domNode:F.current,minZoom:v,maxZoom:m,translateExtent:x,viewport:y,onDraggingChange:U=>$.setState(M=>M.paneDragging===U?M:{paneDragging:U}),onPanZoomStart:(U,M)=>{const{onViewportChangeStart:D,onMoveStart:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoom:(U,M)=>{const{onViewportChange:D,onMove:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoomEnd:(U,M)=>{const{onViewportChangeEnd:D,onMoveEnd:H}=$.getState();H==null||H(U,M),D==null||D(M)}});const{x:C,y:V,zoom:W}=ne.current.getViewport();return $.setState({panZoom:ne.current,transform:[C,V,W],domNode:F.current.closest(".react-flow")}),()=>{var U;(U=ne.current)==null||U.destroy()}}},[]),L.useEffect(()=>{var C;(C=ne.current)==null||C.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:ee,preventScrolling:k,noPanClassName:E,userSelectionActive:X,noWheelClassName:b,lib:q,onTransformChange:K,connectionInProgress:te,selectionOnDrag:A,paneClickDistance:N})},[t,r,o,s,a,u,c,h,p,ee,k,E,X,b,q,K,te,A,N]),d.jsx("div",{className:"react-flow__renderer",ref:F,style:ra,children:j})}const G_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function q_(){const{userSelectionActive:t,userSelectionRect:r}=De(G_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const qu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},K_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function Q_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=is.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:y,onPaneContextMenu:x,onPaneScroll:v,onPaneMouseEnter:m,onPaneMouseMove:_,onPaneMouseLeave:k,children:j}){const b=L.useRef(0),E=Ye(),{userSelectionActive:R,elementsSelectable:w,dragging:N,panBy:A,autoPanSpeed:$}=De(K_,Qe),F=w&&(t||R),X=L.useRef(null),q=L.useRef(),te=L.useRef(new Set),ee=L.useRef(new Set),ne=L.useRef(!1),K=L.useRef(!1),C=L.useRef({x:0,y:0}),V=L.useRef(!1),W=Z=>{if(K.current||ne.current||E.getState().connection.inProgress){K.current=!1,ne.current=!1;return}y==null||y(Z),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},U=Z=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Z.preventDefault();return}x==null||x(Z)},M=v?Z=>v(Z):void 0,D=Z=>{K.current&&(Z.stopPropagation(),K.current=!1)},H=Z=>{var $e,st;if(Z.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:se,transform:me}=E.getState();if(q.current=se==null?void 0:se.getBoundingClientRect(),!q.current)return;const ke=Z.target===X.current;if(!ke&&!!Z.target.closest(".nokey")||!t||!(c&&ke||r)||Z.button!==0||!Z.isPrimary)return;(st=($e=Z.target)==null?void 0:$e.setPointerCapture)==null||st.call($e,Z.pointerId),K.current=!1;const{x:Ne,y:Me}=gn(Z.nativeEvent,q.current),Te=ms({x:Ne,y:Me},me);E.setState({userSelectionRect:{width:0,height:0,startX:Te.x,startY:Te.y,x:Ne,y:Me}}),ke||(Z.stopPropagation(),Z.preventDefault())};function I(Z,se){const{userSelectionRect:me}=E.getState();if(!me)return;const{transform:ke,nodeLookup:ve,edgeLookup:re,connectionLookup:Ne,triggerNodeChanges:Me,triggerEdgeChanges:Te,defaultEdgeOptions:$e}=E.getState(),st={x:me.startX,y:me.startY},{x:lt,y:at}=eo(st,ke),Xe={startX:st.x,startY:st.y,x:Zmt.id)),ee.current=new Set;const gt=($e==null?void 0:$e.selectable)??!0;for(const mt of te.current){const Pt=Ne.get(mt);if(Pt)for(const{edgeId:ut}of Pt.values()){const Je=re.get(ut);Je&&(Je.selectable??gt)&&ee.current.add(ut)}}if(!bh(wt,te.current)){const mt=Xi(ve,te.current,!0);Me(mt)}if(!bh(qt,ee.current)){const mt=Xi(re,ee.current);Te(mt)}E.setState({userSelectionRect:Xe,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!a||!q.current)return;const[Z,se]=Nc(C.current,q.current,$);A({x:Z,y:se}).then(me=>{if(!K.current||!me){b.current=requestAnimationFrame(z);return}const{x:ke,y:ve}=C.current;I(ke,ve),b.current=requestAnimationFrame(z)})}const ie=()=>{cancelAnimationFrame(b.current),b.current=0,V.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=Z=>{const{userSelectionRect:se,transform:me,resetSelectedElements:ke}=E.getState();if(!q.current||!se)return;const{x:ve,y:re}=gn(Z.nativeEvent,q.current);C.current={x:ve,y:re};const Ne=eo({x:se.startX,y:se.startY},me);if(!K.current){const Me=r?0:u;if(Math.hypot(ve-Ne.x,re-Ne.y)<=Me)return;ke(),h==null||h(Z)}K.current=!0,V.current||(z(),V.current=!0),I(ve,re)},fe=Z=>{var se,me;if(!F){Z.target===X.current&&E.getState().connection.inProgress&&(ne.current=!0);return}Z.button===0&&((me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),!R&&Z.target===X.current&&E.getState().userSelectionRect&&(W==null||W(Z)),E.setState({userSelectionActive:!1,userSelectionRect:null}),K.current&&(p==null||p(Z),E.setState({nodesSelectionActive:te.current.size>0})),ie())},he=Z=>{var se,me;(me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),ie()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:nt(["react-flow__pane",{draggable:pe,dragging:N,selection:t}]),onClick:F?void 0:qu(W,X),onContextMenu:qu(U,X),onWheel:qu(M,X),onPointerEnter:F?void 0:m,onPointerMove:F?oe:_,onPointerUp:fe,onPointerCancel:F?he:void 0,onPointerDownCapture:F?H:void 0,onClickCapture:F?D:void 0,onPointerLeave:k,ref:X,style:ra,children:[j,d.jsx(q_,{})]})}function hc({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),y=h.get(t);if(!y){p==null||p("012",mn.error012(t));return}r.setState({nodesSelectionActive:!1}),y.selected?(o||y.selected&&c)&&(u({nodes:[y],edges:[]}),requestAnimationFrame(()=>{var x;return(x=s==null?void 0:s.current)==null?void 0:x.blur()})):a([t])}function Wg({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ye(),[p,y]=L.useState(!1),x=L.useRef();return L.useEffect(()=>{if(!r)return x.current=$1({getStoreItems:()=>h.getState(),onNodeMouseDown:v=>{hc({id:v,store:h,nodeRef:t})},onDragStart:()=>{y(!0)},onDragStop:()=>{y(!1)}}),()=>{var v;(v=x.current)==null||v.destroy(),x.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!x.current||x.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const Z_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Ug(){const t=Ye();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:y,nodeOrigin:x}=t.getState(),v=new Map,m=Z_(c),_=a?u[0]:5,k=a?u[1]:5,j=o.direction.x*_*o.factor,b=o.direction.y*k*o.factor;for(const[,E]of y){if(!m(E))continue;let R={x:E.internals.positionAbsolute.x+j,y:E.internals.positionAbsolute.y+b};a&&(R=gs(R,u));const{position:w,positionAbsolute:N}=cg({nodeId:E.id,nextPosition:R,nodeLookup:y,nodeExtent:s,nodeOrigin:x,onError:h});E.position=w,E.internals.positionAbsolute=N,v.set(E.id,E)}p(v)},[])}const Rc=L.createContext(null),J_=Rc.Provider;Rc.Consumer;const Yg=()=>L.useContext(Rc),eS=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Xg=L.createContext(null);function tS({children:t}){const r=De(eS,Qe);return d.jsx(Xg.Provider,{value:r,children:t})}function nS(){const t=L.useContext(Xg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const rS={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},iS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:y}=c;if(!h&&!a)return rS;const x=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:x,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Zi.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:x&&y}};function oS({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:y,onMouseDown:x,onTouchStart:v,...m},_){var V,W;const k=c||null,j=t==="target",b=Ye(),E=Yg(),{connectOnClick:R,noPanClassName:w,rfId:N}=nS(),{connectingFrom:A,connectingTo:$,clickConnecting:F,isPossibleEndHandle:X,connectionInProcess:q,clickConnectionInProcess:te,valid:ee}=De(iS(E,k,t),Qe);E||(W=(V=b.getState()).onError)==null||W.call(V,"010",mn.error010());const ne=U=>{const{defaultEdgeOptions:M,onConnect:D,hasDefaultEdges:H}=b.getState(),I={...M,...U};if(H){const{edges:z,setEdges:ie,onError:oe}=b.getState();ie(z_(I,z,{onError:oe}))}D==null||D(I),h==null||h(I)},K=U=>{if(!E)return;const M=xg(U.nativeEvent);if(a&&(M&&U.button===0||!M)){const D=b.getState();fc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:j,handleId:k,nodeId:E,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...H)=>{var I,z;return(z=(I=b.getState()).onConnectEnd)==null?void 0:z.call(I,...H)},updateConnection:D.updateConnection,onConnect:ne,isValidConnection:o||((...H)=>{var I,z;return((z=(I=b.getState()).isValidConnection)==null?void 0:z.call(I,...H))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}M?x==null||x(U):v==null||v(U)},C=U=>{const{onClickConnectStart:M,onClickConnectEnd:D,connectionClickStartHandle:H,connectionMode:I,isValidConnection:z,lib:ie,rfId:oe,nodeLookup:fe,connection:he}=b.getState();if(!E||!H&&!a)return;if(!H){M==null||M(U.nativeEvent,{nodeId:E,handleId:k,handleType:t}),b.setState({connectionClickStartHandle:{nodeId:E,type:t,id:k}});return}const pe=yg(U.target),Z=o||z,{connection:se,isValid:me}=fc.isValid(U.nativeEvent,{handle:{nodeId:E,id:k,type:t},connectionMode:I,fromNodeId:H.nodeId,fromHandleId:H.id||null,fromType:H.type,isValidConnection:Z,flowId:oe,doc:pe,lib:ie,nodeLookup:fe});me&&se&&ne(se);const ke=structuredClone(he);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,D==null||D(U,ke),b.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":k,"data-nodeid":E,"data-handlepos":r,"data-id":`${N}-${E}-${k}-${t}`,className:nt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",w,y,{source:!j,target:j,connectable:s,connectablestart:a,connectableend:u,clickconnecting:F,connectingfrom:A,connectingto:$,valid:ee,connectionindicator:s&&(!q||X)&&(q||te?u:a)}]),onMouseDown:K,onTouchStart:K,onClick:R?C:void 0,ref:_,...m,children:p})}const no=L.memo(Hg(oS));function sS({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(no,{type:"source",position:o,isConnectable:r})]})}function lS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:s=Se.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(no,{type:"source",position:s,isConnectable:r})]})}function aS(){return null}function uS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const Wl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},rp={input:sS,default:lS,output:uS,group:aS};function cS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const dS=t=>{const{width:r,height:o,x:s,y:a}=ps(t.nodeLookup,{filter:u=>!!u.selected});return{width:pn(r)?r:null,height:pn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function fS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ye(),{width:a,height:u,transformString:c,userSelectionActive:h}=De(dS,Qe),p=Ug(),y=L.useRef(null);L.useEffect(()=>{var _;o||(_=y.current)==null||_.focus({preventScroll:!0})},[o]);const x=!h&&a!==null&&u!==null;if(Wg({nodeRef:y,disabled:!x}),!x)return null;const v=t?_=>{const k=s.getState().nodes.filter(j=>j.selected);t(_,k)}:void 0,m=_=>{Object.prototype.hasOwnProperty.call(Wl,_.key)&&(_.preventDefault(),p({direction:Wl[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:nt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:y,className:"react-flow__nodesselection-rect",onContextMenu:v,tabIndex:o?void 0:-1,onKeyDown:o?void 0:m,style:{width:a,height:u}})})}const ip=typeof window<"u"?window:void 0,hS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Gg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:y,selectionOnDrag:x,selectionMode:v,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:j,zoomActivationKeyCode:b,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:N,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:X,autoPanOnSelection:q,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,preventScrolling:C,onSelectionContextMenu:V,noWheelClassName:W,noPanClassName:U,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:H}){const{nodesSelectionActive:I,userSelectionActive:z}=De(hS,Qe),ie=as(y,{target:ip}),oe=as(j,{target:ip}),fe=oe||X,he=oe||N,pe=x&&fe!==!0,Z=ie||z||pe;return W_({deleteKeyCode:p,multiSelectionKeyCode:k}),d.jsx(X_,{onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:!ie&&fe,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,zoomActivationKeyCode:b,preventScrolling:C,noWheelClassName:W,noPanClassName:U,onViewportChange:D,isControlledViewport:H,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(Q_,{onSelectionStart:m,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:q,isSelecting:!!Z,selectionMode:v,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:pe,children:[t,I&&d.jsx(fS,{onSelectionContextMenu:V,noPanClassName:U,disableKeyboardA11y:M})]})})}Gg.displayName="FlowRenderer";const pS=L.memo(Gg),gS=t=>r=>t?kc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function mS(t){return De(L.useCallback(gS(t),[t]),Qe)}const yS=t=>t.updateNodeInternals;function vS(){const t=De(yS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function xS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ye(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),y=L.useRef(r),x=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!x||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[x,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const v=y.current!==r,m=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(v||m||_)&&(y.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function wS({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:y,nodesFocusable:x,resizeObserver:v,noDragClassName:m,noPanClassName:_,disableKeyboardA11y:k,rfId:j,nodeTypes:b,nodeClickDistance:E,onError:R}){const{node:w,internals:N,isParent:A}=De(Z=>{const se=Z.nodeLookup.get(t),me=Z.parentLookup.has(t);return{node:se,internals:se.internals,isParent:me}},Qe);let $=w.type||"default",F=(b==null?void 0:b[$])||rp[$];F===void 0&&(R==null||R("003",mn.error003($)),$="default",F=(b==null?void 0:b.default)||rp.default);const X=!!(w.draggable||h&&typeof w.draggable>"u"),q=!!(w.selectable||p&&typeof w.selectable>"u"),te=!!(w.connectable||y&&typeof w.connectable>"u"),ee=!!(w.focusable||x&&typeof w.focusable>"u"),ne=Ye(),K=gg(w),C=xS({node:w,nodeType:$,hasDimensions:K,resizeObserver:v}),V=Wg({nodeRef:C,disabled:w.hidden||!X,noDragClassName:m,handleSelector:w.dragHandle,nodeId:t,isSelectable:q,nodeClickDistance:E}),W=Ug();if(w.hidden)return null;const U=vn(w),M=cS(w),D=q||X||r||o||s||a,H=o?Z=>o(Z,{...N.userNode}):void 0,I=s?Z=>s(Z,{...N.userNode}):void 0,z=a?Z=>a(Z,{...N.userNode}):void 0,ie=u?Z=>u(Z,{...N.userNode}):void 0,oe=c?Z=>c(Z,{...N.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:se,nodeDragThreshold:me}=ne.getState();q&&(!se||!X||me>0)&&hc({id:t,store:ne,nodeRef:C}),r&&r(Z,{...N.userNode})},he=Z=>{if(!(vg(Z.nativeEvent)||k)){if(og.includes(Z.key)&&q){const se=Z.key==="Escape";hc({id:t,store:ne,unselect:se,nodeRef:C})}else if(X&&w.selected&&Object.prototype.hasOwnProperty.call(Wl,Z.key)){Z.preventDefault();const{ariaLabelConfig:se}=ne.getState();ne.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),W({direction:Wl[Z.key],factor:Z.shiftKey?4:1})}}},pe=()=>{var Ne;if(k||!((Ne=C.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:Z,width:se,height:me,autoPanOnNodeFocus:ke,setCenter:ve}=ne.getState();if(!ke)return;kc(new Map([[t,w]]),{x:0,y:0,width:se,height:me},Z,!0).length>0||ve(w.position.x+U.width/2,w.position.y+U.height/2,{zoom:Z[2]})};return d.jsx("div",{className:nt(["react-flow__node",`react-flow__node-${$}`,{[_]:X},w.className,{selected:w.selected,selectable:q,parent:A,draggable:X,dragging:V}]),ref:C,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:K?"visible":"hidden",...w.style,...M},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:H,onMouseMove:I,onMouseLeave:z,onContextMenu:ie,onClick:fe,onDoubleClick:oe,onKeyDown:ee?he:void 0,tabIndex:ee?0:void 0,onFocus:ee?pe:void 0,role:w.ariaRole??(ee?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${zg}-${j}`,"aria-label":w.ariaLabel,...w.domAttributes,children:d.jsx(J_,{value:t,children:d.jsx(F,{id:t,data:w.data,type:$,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:w.selected??!1,selectable:q,draggable:X,deletable:w.deletable??!0,isConnectable:te,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:V,dragHandle:w.dragHandle,zIndex:N.z,parentId:w.parentId,...U})})})}var _S=L.memo(wS);const SS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function qg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=De(SS,Qe),u=mS(t.onlyRenderVisibleElements),c=vS();return d.jsx("div",{className:"react-flow__nodes",style:ra,children:u.map(h=>d.jsx(_S,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}qg.displayName="NodeRenderer";const kS=L.memo(qg);function NS(t){return De(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&y1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const jS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},bS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},op={[os.Arrow]:jS,[os.ArrowClosed]:bS};function ES(t){const r=Ye();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(op,t)?op[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",mn.error009(t)),null)},[t])}const CS=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=ES(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},Kg=({defaultColor:t,rfId:r})=>{const o=De(u=>u.edges),s=De(u=>u.defaultEdgeOptions),a=L.useMemo(()=>j1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(CS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Kg.displayName="MarkerDefinitions";var MS=L.memo(Kg);function Qg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:y,...x}){const[v,m]=L.useState({x:1,y:0,width:0,height:0}),_=nt(["react-flow__edge-textwrapper",y]),k=L.useRef(null);return L.useEffect(()=>{if(k.current){const j=k.current.getBBox();m({x:j.x,y:j.y,width:j.width,height:j.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-v.width/2} ${r-v.height/2})`,className:_,visibility:v.width?"visible":"hidden",...x,children:[a&&d.jsx("rect",{width:v.width+2*c[0],x:-c[0],y:-c[1],height:v.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:v.height/2,dy:"0.3em",ref:k,style:s,children:o}),p]}):null}Qg.displayName="EdgeText";const PS=L.memo(Qg);function ys({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:y=20,...x}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...x,d:t,fill:"none",className:nt(["react-flow__edge-path",x.className])}),y?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:y,className:"react-flow__edge-interaction"}):null,s&&pn(r)&&pn(o)?d.jsx(PS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function sp({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function Zg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top}){const[c,h]=sp({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,y]=sp({pos:u,x1:s,y1:a,x2:t,y2:r}),[x,v,m,_]=wg({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:y});return[`M${t},${r} C${c},${h} ${p},${y} ${s},${a}`,x,v,m,_]}function Jg(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})=>{const[R,w,N]=Zg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),A=t.isInternal?void 0:r;return d.jsx(ys,{id:A,path:R,labelX:w,labelY:N,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})})}const IS=Jg({isInternal:!1}),em=Jg({isInternal:!0});IS.displayName="SimpleBezierEdge";em.displayName="SimpleBezierEdgeInternal";function tm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,sourcePosition:_=Se.Bottom,targetPosition:k=Se.Top,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=Vl({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),$=t.isInternal?void 0:r;return d.jsx(ys,{id:$,path:w,labelX:N,labelY:A,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,markerEnd:j,markerStart:b,interactionWidth:R})})}const nm=tm({isInternal:!1}),rm=tm({isInternal:!0});nm.displayName="SmoothStepEdge";rm.displayName="SmoothStepEdgeInternal";function im(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(nm,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const RS=im({isInternal:!1}),om=im({isInternal:!0});RS.displayName="StepEdge";om.displayName="StepEdgeInternal";function sm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,markerEnd:_,markerStart:k,interactionWidth:j})=>{const[b,E,R]=kg({sourceX:o,sourceY:s,targetX:a,targetY:u}),w=t.isInternal?void 0:r;return d.jsx(ys,{id:w,path:b,labelX:E,labelY:R,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,markerEnd:_,markerStart:k,interactionWidth:j})})}const TS=sm({isInternal:!1}),lm=sm({isInternal:!0});TS.displayName="StraightEdge";lm.displayName="StraightEdgeInternal";function am(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=_g({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:E==null?void 0:E.curvature}),$=t.isInternal?void 0:r;return d.jsx(ys,{id:$,path:w,labelX:N,labelY:A,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:R})})}const LS=am({isInternal:!1}),um=am({isInternal:!0});LS.displayName="BezierEdge";um.displayName="BezierEdgeInternal";const lp={default:um,straight:lm,step:om,smoothstep:rm,simplebezier:em},ap={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},AS=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,$S=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,up="react-flow__edgeupdater";function cp({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:nt([up,`${up}-${h}`]),cx:AS(r,s,t),cy:$S(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function zS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:y,onReconnectStart:x,onReconnectEnd:v,setReconnecting:m,setUpdateHover:_}){const k=Ye(),j=(N,A)=>{if(N.button!==0)return;const{autoPanOnConnect:$,domNode:F,connectionMode:X,connectionRadius:q,lib:te,onConnectStart:ee,cancelConnection:ne,nodeLookup:K,rfId:C,panBy:V,updateConnection:W}=k.getState(),U=A.type==="target",M=(I,z)=>{m(!1),v==null||v(I,o,A.type,z)},D=I=>y==null?void 0:y(o,I),H=(I,z)=>{m(!0),x==null||x(N,o,A.type),ee==null||ee(I,z)};fc.onPointerDown(N.nativeEvent,{autoPanOnConnect:$,connectionMode:X,connectionRadius:q,domNode:F,handleId:A.id,nodeId:A.nodeId,nodeLookup:K,isTarget:U,edgeUpdaterType:A.type,lib:te,flowId:C,cancelConnection:ne,panBy:V,isValidConnection:(...I)=>{var z,ie;return((ie=(z=k.getState()).isValidConnection)==null?void 0:ie.call(z,...I))??!0},onConnect:D,onConnectStart:H,onConnectEnd:(...I)=>{var z,ie;return(ie=(z=k.getState()).onConnectEnd)==null?void 0:ie.call(z,...I)},onReconnectEnd:M,updateConnection:W,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:N.currentTarget})},b=N=>j(N,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),E=N=>j(N,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),R=()=>_(!0),w=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(cp,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:b,onMouseEnter:R,onMouseOut:w,type:"source"}),(t===!0||t==="target")&&d.jsx(cp,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:E,onMouseEnter:R,onMouseOut:w,type:"target"})]})}function DS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,reconnectRadius:x,onReconnect:v,onReconnectStart:m,onReconnectEnd:_,rfId:k,edgeTypes:j,noPanClassName:b,onError:E,disableKeyboardA11y:R}){let w=De(ve=>ve.edgeLookup.get(t));const N=De(ve=>ve.defaultEdgeOptions);w=N?{...N,...w}:w;let A=w.type||"default",$=(j==null?void 0:j[A])||lp[A];$===void 0&&(E==null||E("011",mn.error011(A)),A="default",$=(j==null?void 0:j.default)||lp.default);const F=!!(w.focusable||r&&typeof w.focusable>"u"),X=typeof v<"u"&&(w.reconnectable||o&&typeof w.reconnectable>"u"),q=!!(w.selectable||s&&typeof w.selectable>"u"),te=L.useRef(null),[ee,ne]=L.useState(!1),[K,C]=L.useState(!1),V=Ye(),{zIndex:W=w.zIndex,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z}=De(L.useCallback(ve=>{const re=ve.nodeLookup.get(w.source),Ne=ve.nodeLookup.get(w.target);if(!re||!Ne)return ap;const Me=N1({id:t,sourceNode:re,targetNode:Ne,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:ve.connectionMode,onError:E}),Te=m1({selected:w.selected,zIndex:w.zIndex,sourceNode:re,targetNode:Ne,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||ap,zIndex:Te}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex,E]),Qe),ie=L.useMemo(()=>w.markerStart?`url('#${cc(w.markerStart,k)}')`:void 0,[w.markerStart,k]),oe=L.useMemo(()=>w.markerEnd?`url('#${cc(w.markerEnd,k)}')`:void 0,[w.markerEnd,k]);if(w.hidden||U===null||M===null||D===null||H===null)return null;const fe=ve=>{var Te;const{addSelectedEdges:re,unselectNodesAndEdges:Ne,multiSelectionActive:Me}=V.getState();q&&(V.setState({nodesSelectionActive:!1}),w.selected&&Me?(Ne({nodes:[],edges:[w]}),(Te=te.current)==null||Te.blur()):re([t])),a&&a(ve,w)},he=u?ve=>{u(ve,{...w})}:void 0,pe=c?ve=>{c(ve,{...w})}:void 0,Z=h?ve=>{h(ve,{...w})}:void 0,se=p?ve=>{p(ve,{...w})}:void 0,me=y?ve=>{y(ve,{...w})}:void 0,ke=ve=>{var re;if(!R&&og.includes(ve.key)&&q){const{unselectNodesAndEdges:Ne,addSelectedEdges:Me}=V.getState();ve.key==="Escape"?((re=te.current)==null||re.blur(),Ne({edges:[w]})):Me([t])}};return d.jsx("svg",{style:{zIndex:W},children:d.jsxs("g",{className:nt(["react-flow__edge",`react-flow__edge-${A}`,w.className,b,{selected:w.selected,animated:w.animated,inactive:!q&&!a,updating:ee,selectable:q}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:Z,onMouseMove:se,onMouseLeave:me,onKeyDown:F?ke:void 0,tabIndex:F?0:void 0,role:w.ariaRole??(F?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":F?`${Dg}-${k}`:void 0,ref:te,...w.domAttributes,children:[!K&&d.jsx($,{id:t,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:q,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),X&&d.jsx(zS,{edge:w,isReconnectable:X,reconnectRadius:x,onReconnect:v,onReconnectStart:m,onReconnectEnd:_,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,setUpdateHover:ne,setReconnecting:C})]})})}var OS=L.memo(DS);const FS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function cm({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:y,onEdgeClick:x,reconnectRadius:v,onEdgeDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:j}){const{edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,onError:w}=De(FS,Qe),N=NS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(MS,{defaultColor:t,rfId:o}),N.map(A=>d.jsx(OS,{id:A,edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,onClick:x,reconnectRadius:v,onDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:w,edgeTypes:s,disableKeyboardA11y:j},A))]})}cm.displayName="EdgeRenderer";const HS=L.memo(cm),dp=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function BS({children:t}){const r=Ye(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return Bg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=dp(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:dp(s)},children:t})}function VS(t){const r=na(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const WS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function US(t){const r=De(WS),o=Ye();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function YS(t){return t.connection.inProgress?{...t.connection,to:ms(t.connection.to,t.transform)}:{...t.connection}}function XS(t){return YS}function GS(t){const r=XS();return De(r,Qe)}const qS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function KS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=De(qS,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:nt(["react-flow__connection",ag(h)]),children:d.jsx(dm,{style:r,type:o,CustomComponent:s,isValid:h})})})}const dm=({style:t,type:r=Lr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:y,toNode:x,toHandle:v,toPosition:m,pointer:_}=GS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:y.x,toY:y.y,fromPosition:p,toPosition:m,connectionStatus:ag(s),toNode:x,toHandle:v,pointer:_});let k="";const j={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:y.x,targetY:y.y,targetPosition:m};switch(r){case Lr.Bezier:[k]=_g(j);break;case Lr.SimpleBezier:[k]=Zg(j);break;case Lr.Step:[k]=Vl({...j,borderRadius:0});break;case Lr.SmoothStep:[k]=Vl(j);break;default:[k]=kg(j)}return d.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};dm.displayName="ConnectionLine";const QS={};function fp(t=QS){L.useRef(t),Ye(),L.useEffect(()=>{},[t])}function ZS(){Ye(),L.useRef(!1),L.useEffect(()=>{},[])}function fm({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:x,onSelectionContextMenu:v,onSelectionStart:m,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:j,connectionLineComponent:b,connectionLineContainerStyle:E,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,deleteKeyCode:X,onlyRenderVisibleElements:q,elementsSelectable:te,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,preventScrolling:V,defaultMarkerColor:W,zoomOnScroll:U,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,zoomOnDoubleClick:z,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneScroll:se,onPaneContextMenu:me,paneClickDistance:ke,nodeClickDistance:ve,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,noDragClassName:Xe,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,viewport:ut,onViewportChange:Je,nodesDraggable:An}){return fp(t),fp(r),ZS(),VS(o),US(ut),d.jsx(pS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneContextMenu:me,onPaneScroll:se,paneClickDistance:ke,deleteKeyCode:X,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,elementsSelectable:te,zoomOnScroll:U,zoomOnPinch:M,zoomOnDoubleClick:z,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,onSelectionContextMenu:v,preventScrolling:V,noDragClassName:Xe,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,onViewportChange:Je,isControlledViewport:!!ut,children:d.jsxs(BS,{children:[d.jsx(HS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,onlyRenderVisibleElements:q,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,defaultMarkerColor:W,noPanClassName:qt,disableKeyboardA11y:gt,rfId:Pt}),d.jsx(KS,{style:j,type:k,component:b,containerStyle:E}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(kS,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:x,nodeClickDistance:ve,onlyRenderVisibleElements:q,noPanClassName:qt,noDragClassName:Xe,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,nodesDraggable:An}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}fm.displayName="GraphView";const JS=L.memo(fm),ek=pg(),hp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:y=2,nodeOrigin:x,nodeExtent:v,zIndexMode:m="basic"}={})=>{const _=new Map,k=new Map,j=new Map,b=new Map,E=s??r??[],R=o??t??[],w=x??[0,0],N=v??rs;bg(j,b,E);const{nodesInitialized:A}=dc(R,_,k,{nodeOrigin:w,nodeExtent:N,zIndexMode:m});let $=[0,0,1];if(c&&a&&u){const F=ps(_,{filter:ee=>!!((ee.width||ee.initialWidth)&&(ee.height||ee.initialHeight))}),{x:X,y:q,zoom:te}=jc(F,a,u,p,y,(h==null?void 0:h.padding)??.1);$=[X,q,te]}return{rfId:"1",width:a??0,height:u??0,transform:$,nodes:R,nodesInitialized:A,nodeLookup:_,parentLookup:k,edges:E,edgeLookup:b,connectionLookup:j,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:y,translateExtent:rs,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Zi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...lg},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:ek,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:sg,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},tk=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:x,nodeExtent:v,zIndexMode:m})=>h_((_,k)=>{async function j(){const{nodeLookup:b,panZoom:E,fitViewOptions:R,fitViewResolver:w,width:N,height:A,minZoom:$,maxZoom:F}=k();E&&(await u1({nodes:b,width:N,height:A,panZoom:E,minZoom:$,maxZoom:F},R),w==null||w.resolve(!0),_({fitViewResolver:null}))}return{...hp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:x,nodeExtent:v,defaultNodes:o,defaultEdges:s,zIndexMode:m}),setNodes:b=>{const{nodeLookup:E,parentLookup:R,nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,fitViewQueued:$,zIndexMode:F,nodesSelectionActive:X}=k(),{nodesInitialized:q,hasSelectedNodes:te}=dc(b,E,R,{nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:F}),ee=X&&te;$&&q?(j(),_({nodes:b,nodesInitialized:q,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:ee})):_({nodes:b,nodesInitialized:q,nodesSelectionActive:ee})},setEdges:b=>{const{connectionLookup:E,edgeLookup:R}=k();bg(E,R,b),_({edges:b})},setDefaultNodesAndEdges:(b,E)=>{if(b){const{setNodes:R}=k();R(b),_({hasDefaultNodes:!0})}if(E){const{setEdges:R}=k();R(E),_({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:E,nodeLookup:R,parentLookup:w,domNode:N,nodeOrigin:A,nodeExtent:$,debug:F,fitViewQueued:X,zIndexMode:q}=k(),{changes:te,updatedInternals:ee}=R1(b,R,w,N,A,$,q);ee&&(C1(R,w,{nodeOrigin:A,nodeExtent:$,zIndexMode:q}),X?(j(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(te==null?void 0:te.length)>0&&(F&&console.log("React Flow: trigger node changes",te),E==null||E(te)))},updateNodePositions:(b,E=!1)=>{const R=[];let w=[];const{nodeLookup:N,triggerNodeChanges:A,connection:$,updateConnection:F,onNodesChangeMiddlewareMap:X}=k();for(const[q,te]of b){const ee=N.get(q),ne=!!(ee!=null&&ee.expandParent&&(ee!=null&&ee.parentId)&&(te!=null&&te.position)),K={id:q,type:"position",position:ne?{x:Math.max(0,te.position.x),y:Math.max(0,te.position.y)}:te.position,dragging:E};if(ee&&$.inProgress&&$.fromNode.id===ee.id){const C=mi(ee,$.fromHandle,Se.Left,!0);F({...$,from:C})}ne&&ee.parentId&&R.push({id:q,parentId:ee.parentId,rect:{...te.internals.positionAbsolute,width:te.measured.width??0,height:te.measured.height??0}}),w.push(K)}if(R.length>0){const{parentLookup:q,nodeOrigin:te}=k(),ee=Ic(R,N,q,te);w.push(...ee)}for(const q of X.values())w=q(w);A(w)},triggerNodeChanges:b=>{const{onNodesChange:E,setNodes:R,nodes:w,hasDefaultNodes:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=L_(b,w);R($)}A&&console.log("React Flow: trigger node changes",b),E==null||E(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:E,setEdges:R,edges:w,hasDefaultEdges:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=A_(b,w);R($)}A&&console.log("React Flow: trigger edge changes",b),E==null||E(b)}},addSelectedNodes:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));N($);return}N(Xi(w,new Set([...b]),!0)),A(Xi(R))},addSelectedEdges:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));A($);return}A(Xi(R,new Set([...b]))),N(Xi(w,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:E}={})=>{const{edges:R,nodes:w,nodeLookup:N,triggerNodeChanges:A,triggerEdgeChanges:$}=k(),F=b||w,X=E||R,q=[];for(const ee of F){if(!ee.selected)continue;const ne=N.get(ee.id);ne&&(ne.selected=!1),q.push(ai(ee.id,!1))}const te=[];for(const ee of X)ee.selected&&te.push(ai(ee.id,!1));A(q),$(te)},setMinZoom:b=>{const{panZoom:E,maxZoom:R}=k();E==null||E.setScaleExtent([b,R]),_({minZoom:b})},setMaxZoom:b=>{const{panZoom:E,minZoom:R}=k();E==null||E.setScaleExtent([R,b]),_({maxZoom:b})},setTranslateExtent:b=>{var E;(E=k().panZoom)==null||E.setTranslateExtent(b),_({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:E,triggerNodeChanges:R,triggerEdgeChanges:w,elementsSelectable:N}=k();if(!N)return;const A=E.reduce((F,X)=>X.selected?[...F,ai(X.id,!1)]:F,[]),$=b.reduce((F,X)=>X.selected?[...F,ai(X.id,!1)]:F,[]);R(A),w($)},setNodeExtent:b=>{const{nodes:E,nodeLookup:R,parentLookup:w,nodeOrigin:N,elevateNodesOnSelect:A,nodeExtent:$,zIndexMode:F}=k();b[0][0]===$[0][0]&&b[0][1]===$[0][1]&&b[1][0]===$[1][0]&&b[1][1]===$[1][1]||(dc(E,R,w,{nodeOrigin:N,nodeExtent:b,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:F}),_({nodeExtent:b}))},panBy:b=>{const{transform:E,width:R,height:w,panZoom:N,translateExtent:A}=k();return T1({delta:b,panZoom:N,transform:E,translateExtent:A,width:R,height:w})},setCenter:async(b,E,R)=>{const{width:w,height:N,maxZoom:A,panZoom:$}=k();if(!$)return!1;const F=typeof(R==null?void 0:R.zoom)<"u"?R.zoom:A;return await $.setViewport({x:w/2-b*F,y:N/2-E*F,zoom:F},{duration:R==null?void 0:R.duration,ease:R==null?void 0:R.ease,interpolate:R==null?void 0:R.interpolate}),!0},cancelConnection:()=>{_({connection:{...lg}})},updateConnection:b=>{_({connection:b})},reset:()=>_({...hp()})}},Object.is);function hm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:y,nodeOrigin:x,nodeExtent:v,zIndexMode:m,children:_}){const[k]=L.useState(()=>tk({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:y,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:x,nodeExtent:v,zIndexMode:m}));return d.jsx(p_,{value:k,children:d.jsx(F_,{children:d.jsx(tS,{children:_})})})}function nk({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:y,maxZoom:x,nodeOrigin:v,nodeExtent:m,zIndexMode:_}){return L.useContext(ea)?d.jsx(d.Fragment,{children:t}):d.jsx(hm,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:y,initialMaxZoom:x,nodeOrigin:v,nodeExtent:m,zIndexMode:_,children:t})}const rk={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function ik({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:y,onMove:x,onMoveStart:v,onMoveEnd:m,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,onNodeDragStart:F,onNodeDrag:X,onNodeDragStop:q,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onSelectionChange:K,onSelectionDragStart:C,onSelectionDrag:V,onSelectionDragStop:W,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:H,connectionMode:I,connectionLineType:z=Lr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:Z=!1,selectionMode:se=is.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:ke=ls()?"Meta":"Control",zoomActivationKeyCode:ve=ls()?"Meta":"Control",snapToGrid:re,snapGrid:Ne,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Te,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,nodeOrigin:Xe=Og,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt=!0,defaultViewport:mt=E_,minZoom:Pt=.5,maxZoom:ut=2,translateExtent:Je=rs,preventScrolling:An=!0,nodeExtent:Ot,defaultMarkerColor:xn="#b1b1b7",zoomOnScroll:oo=!0,zoomOnPinch:$n=!0,panOnScroll:vi=!1,panOnScrollSpeed:or=.5,panOnScrollMode:$r=di.Free,zoomOnDoubleClick:zn=!0,panOnDrag:zr=!0,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn=1,nodeClickDistance:Fn=0,children:_n,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn=10,onNodesChange:Ht,onEdgesChange:Or,noDragClassName:nn="nodrag",noWheelClassName:Fr="nowheel",noPanClassName:yt="nopan",fitView:Hn,fitViewOptions:ur,connectOnClick:so,attributionPosition:It,proOptions:Bn,defaultEdgeOptions:Hr,elevateNodesOnSelect:jn=!0,elevateEdgesOnSelect:Br=!1,disableKeyboardA11y:xi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:lo,autoPanOnSelection:Vr=!0,autoPanSpeed:wi,connectionRadius:cr,isValidConnection:ao,onError:dr,style:Vn,id:bt,nodeDragThreshold:Wr,connectionDragThreshold:Et,viewport:uo,onViewportChange:Ur,width:Yr,height:Wn,colorMode:Un="light",debug:bn,onScroll:Bt,ariaLabelConfig:_i,zIndexMode:Xr="basic",...fr},hr){const Yn=bt||"1",En=I_(Un),co=L.useCallback(pr=>{pr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Bt==null||Bt(pr)},[Bt]);return d.jsx("div",{"data-testid":"rf__wrapper",...fr,onScroll:co,style:{...Vn,...rk},ref:hr,className:nt(["react-flow",a,En]),id:bt,role:"application",children:d.jsxs(nk,{nodes:t,edges:r,width:Yr,height:Wn,fitView:Hn,fitViewOptions:ur,minZoom:Pt,maxZoom:ut,nodeOrigin:Xe,nodeExtent:Ot,zIndexMode:Xr,children:[d.jsx(P_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt,elevateNodesOnSelect:jn,elevateEdgesOnSelect:Br,minZoom:Pt,maxZoom:ut,nodeExtent:Ot,onNodesChange:Ht,onEdgesChange:Or,snapToGrid:re,snapGrid:Ne,connectionMode:I,translateExtent:Je,connectOnClick:so,defaultEdgeOptions:Hr,fitView:Hn,fitViewOptions:ur,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onNodeDragStart:F,onNodeDrag:X,onNodeDragStop:q,onSelectionDrag:V,onSelectionDragStart:C,onSelectionDragStop:W,onMove:x,onMoveStart:v,onMoveEnd:m,noPanClassName:yt,nodeOrigin:Xe,rfId:Yn,autoPanOnConnect:Ve,autoPanOnNodeDrag:lo,autoPanSpeed:wi,onError:dr,connectionRadius:cr,isValidConnection:ao,selectNodesOnDrag:Te,nodeDragThreshold:Wr,connectionDragThreshold:Et,onBeforeDelete:H,debug:bn,ariaLabelConfig:_i,zIndexMode:Xr}),d.jsx(JS,{onInit:y,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,nodeTypes:u,edgeTypes:c,connectionLineType:z,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:Z,selectionMode:se,deleteKeyCode:he,multiSelectionKeyCode:ke,panActivationKeyCode:me,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:mt,translateExtent:Je,minZoom:Pt,maxZoom:ut,preventScrolling:An,zoomOnScroll:oo,zoomOnPinch:$n,zoomOnDoubleClick:zn,panOnScroll:vi,panOnScrollSpeed:or,panOnScrollMode:$r,panOnDrag:zr,autoPanOnSelection:Vr,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn,nodeClickDistance:Fn,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn,defaultMarkerColor:xn,noDragClassName:nn,noWheelClassName:Fr,noPanClassName:yt,rfId:Yn,disableKeyboardA11y:xi,nodeExtent:Ot,viewport:uo,onViewportChange:Ur,nodesDraggable:$e}),d.jsx(b_,{onSelectionChange:K}),_n,d.jsx(__,{proOptions:Bn,position:It}),d.jsx(w_,{rfId:Yn,disableKeyboardA11y:xi})]})})}var ok=Hg(ik);function sk({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:nt(["react-flow__background-pattern",o,s])})}function lk({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:nt(["react-flow__background-pattern","dots",r])})}var Ar;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Ar||(Ar={}));const ak={[Ar.Dots]:1,[Ar.Lines]:1,[Ar.Cross]:6},uk=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function pm({id:t,variant:r=Ar.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:y,patternClassName:x}){const v=L.useRef(null),{transform:m,patternId:_}=De(uk,Qe),k=s||ak[r],j=r===Ar.Dots,b=r===Ar.Cross,E=Array.isArray(o)?o:[o,o],R=[E[0]*m[2]||1,E[1]*m[2]||1],w=k*m[2],N=Array.isArray(u)?u:[u,u],A=b?[w,w]:R,$=[N[0]*m[2]+A[0]/2,N[1]*m[2]+A[1]/2],F=`${_}${t||""}`;return d.jsxs("svg",{className:nt(["react-flow__background",y]),style:{...p,...ra,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:v,"data-testid":"rf__background",children:[d.jsx("pattern",{id:F,x:m[0]%R[0],y:m[1]%R[1],width:R[0],height:R[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:j?d.jsx(lk,{radius:w/2,className:x}):d.jsx(sk,{dimensions:A,lineWidth:a,variant:r,className:x})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${F})`})]})}pm.displayName="Background";const ck=L.memo(pm);function dk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function fk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function hk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 pk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 gk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 bl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:nt(["react-flow__controls-button",r]),...o,children:t})}const mk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function gm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:y,children:x,position:v="bottom-left",orientation:m="vertical","aria-label":_}){const k=Ye(),{isInteractive:j,minZoomReached:b,maxZoomReached:E,ariaLabelConfig:R}=De(mk,Qe),{zoomIn:w,zoomOut:N,fitView:A}=na(),$=()=>{w(),u==null||u()},F=()=>{N(),c==null||c()},X=()=>{A(a),h==null||h()},q=()=>{k.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),p==null||p(!j)},te=m==="horizontal"?"horizontal":"vertical";return d.jsxs(ta,{className:nt(["react-flow__controls",te,y]),position:v,style:t,"data-testid":"rf__controls","aria-label":_??R["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(bl,{onClick:$,className:"react-flow__controls-zoomin",title:R["controls.zoomIn.ariaLabel"],"aria-label":R["controls.zoomIn.ariaLabel"],disabled:E,children:d.jsx(dk,{})}),d.jsx(bl,{onClick:F,className:"react-flow__controls-zoomout",title:R["controls.zoomOut.ariaLabel"],"aria-label":R["controls.zoomOut.ariaLabel"],disabled:b,children:d.jsx(fk,{})})]}),o&&d.jsx(bl,{className:"react-flow__controls-fitview",onClick:X,title:R["controls.fitView.ariaLabel"],"aria-label":R["controls.fitView.ariaLabel"],children:d.jsx(hk,{})}),s&&d.jsx(bl,{className:"react-flow__controls-interactive",onClick:q,title:R["controls.interactive.ariaLabel"],"aria-label":R["controls.interactive.ariaLabel"],children:j?d.jsx(gk,{}):d.jsx(pk,{})}),x]})}gm.displayName="Controls";const yk=L.memo(gm);function vk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:y,borderRadius:x,shapeRendering:v,selected:m,onClick:_}){const{background:k,backgroundColor:j}=u||{},b=c||k||j;return d.jsx("rect",{className:nt(["react-flow__minimap-node",{selected:m},y]),x:r,y:o,rx:x,ry:x,width:s,height:a,style:{fill:b,stroke:h,strokeWidth:p},shapeRendering:v,onClick:_?E=>_(E,t):void 0})}const xk=L.memo(vk),wk=t=>t.nodes.map(r=>r.id),Ku=t=>t instanceof Function?t:()=>t;function _k({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=xk,onClick:c}){const h=De(wk,Qe),p=Ku(r),y=Ku(t),x=Ku(o),v=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(m=>d.jsx(kk,{id:m,nodeColorFunc:p,nodeStrokeColorFunc:y,nodeClassNameFunc:x,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:v},m))})}function Sk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:y,x,y:v,width:m,height:_}=De(k=>{const j=k.nodeLookup.get(t);if(!j)return{node:void 0,x:0,y:0,width:0,height:0};const b=j.internals.userNode,{x:E,y:R}=j.internals.positionAbsolute,{width:w,height:N}=vn(b);return{node:b,x:E,y:R,width:w,height:N}},Qe);return!y||y.hidden||!gg(y)?null:d.jsx(h,{x,y:v,width:m,height:_,style:y.style,selected:!!y.selected,className:s(y),color:r(y),borderRadius:a,strokeColor:o(y),strokeWidth:u,shapeRendering:c,onClick:p,id:y.id})}const kk=L.memo(Sk);var Nk=L.memo(_k);const jk=200,bk=150,Ek=t=>!t.hidden,Ck=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?fg(ps(t.nodeLookup,{filter:Ek}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},pp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,Mk=(t,r)=>pp(t.viewBB,r.viewBB)&&pp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,Pk="react-flow__minimap-desc";function mm({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:y,maskStrokeColor:x,maskStrokeWidth:v,position:m="bottom-right",onClick:_,onNodeClick:k,pannable:j=!1,zoomable:b=!1,ariaLabel:E,inversePan:R,zoomStep:w=1,offsetScale:N=5}){const A=Ye(),$=L.useRef(null),{boundingRect:F,viewBB:X,rfId:q,panZoom:te,translateExtent:ee,flowWidth:ne,flowHeight:K,ariaLabelConfig:C}=De(Ck,Mk),V=(t==null?void 0:t.width)??jk,W=(t==null?void 0:t.height)??bk,U=F.width/V,M=F.height/W,D=Math.max(U,M),H=D*V,I=D*W,z=N*D,ie=F.x-(H-F.width)/2-z,oe=F.y-(I-F.height)/2-z,fe=H+z*2,he=I+z*2,pe=`${Pk}-${q}`,Z=L.useRef(0),se=L.useRef();Z.current=D,L.useEffect(()=>{if($.current&&te)return se.current=B1({domNode:$.current,panZoom:te,getTransform:()=>A.getState().transform,getViewScale:()=>Z.current}),()=>{var re;(re=se.current)==null||re.destroy()}},[te]),L.useEffect(()=>{var re;(re=se.current)==null||re.update({translateExtent:ee,width:ne,height:K,inversePan:R,pannable:j,zoomStep:w,zoomable:b})},[j,b,R,w,ee,ne,K]);const me=_?re=>{var Te;const[Ne,Me]=((Te=se.current)==null?void 0:Te.pointer(re))||[0,0];_(re,{x:Ne,y:Me})}:void 0,ke=k?L.useCallback((re,Ne)=>{const Me=A.getState().nodeLookup.get(Ne).internals.userNode;k(re,Me)},[]):void 0,ve=E??C["minimap.ariaLabel"];return d.jsx(ta,{position:m,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof y=="string"?y:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof v=="number"?v*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:nt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:V,height:W,viewBox:`${ie} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:$,onClick:me,children:[ve&&d.jsx("title",{id:pe,children:ve}),d.jsx(Nk,{onClick:ke,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-z},${oe-z}h${fe+z*2}v${he+z*2}h${-fe-z*2}z - M${X.x},${X.y}h${X.width}v${X.height}h${-X.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}mm.displayName="MiniMap";const Ik=L.memo(mm),Rk=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Tk={[to.Line]:"right",[to.Handle]:"bottom-right"};function Lk({nodeId:t,position:r,variant:o=to.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:y=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:v=!1,resizeDirection:m,autoScale:_=!0,shouldResize:k,onResizeStart:j,onResize:b,onResizeEnd:E}){const R=Yg(),w=typeof t=="string"?t:R,N=Ye(),A=L.useRef(null),$=o===to.Handle,F=De(L.useCallback(Rk($&&_),[$,_]),Qe),X=L.useRef(null),q=r??Tk[o];L.useEffect(()=>{if(!(!A.current||!w))return X.current||(X.current=t_({domNode:A.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,domNode:W}=N.getState();return{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,paneDomNode:W}},onChange:(ee,ne)=>{const{triggerNodeChanges:K,nodeLookup:C,parentLookup:V,nodeOrigin:W}=N.getState(),U=[],M={x:ee.x,y:ee.y},D=C.get(w);if(D&&D.expandParent&&D.parentId){const H=D.origin??W,I=ee.width??D.measured.width??0,z=ee.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:I,height:z,...mg({x:ee.x??D.position.x,y:ee.y??D.position.y},{width:I,height:z},D.parentId,C,H)}},oe=Ic([ie],C,V,W);U.push(...oe),M.x=ee.x?Math.max(H[0]*I,ee.x):void 0,M.y=ee.y?Math.max(H[1]*z,ee.y):void 0}if(M.x!==void 0&&M.y!==void 0){const H={id:w,type:"position",position:{...M}};U.push(H)}if(ee.width!==void 0&&ee.height!==void 0){const I={id:w,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:ee.width,height:ee.height}};U.push(I)}for(const H of ne){const I={...H,type:"position"};U.push(I)}K(U)},onEnd:({width:ee,height:ne})=>{const K={id:w,type:"dimensions",resizing:!1,dimensions:{width:ee,height:ne}};N.getState().triggerNodeChanges([K])}})),X.current.update({controlPosition:q,boundaries:{minWidth:h,minHeight:p,maxWidth:y,maxHeight:x},keepAspectRatio:v,resizeDirection:m,onResizeStart:j,onResize:b,onResizeEnd:E,shouldResize:k}),()=>{var ee;(ee=X.current)==null||ee.destroy()}},[q,h,p,y,x,v,j,b,E,k]);const te=q.split("-");return d.jsx("div",{className:nt(["react-flow__resize-control","nodrag",...te,o,s]),ref:A,style:{...a,scale:F,...c&&{[$?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Lk);const Ak={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function ia(t){return Ak[t]??8}const us=208,ro=64,pc=88,$k=28,zk=8;function Dk(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function ym(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const w of t){const N=ia(w.type),A=s.get(N)??[];A.push(w),s.set(N,A)}const u=[...s.keys()].sort((w,N)=>w-N).map(w=>[...s.get(w)??[]].sort((N,A)=>N.name.localeCompare(A.name)||N.id.localeCompare(A.id))),c=new Set(t.map(w=>w.id)),h=new Map,p=new Map;for(const w of t)h.set(w.id,[]),p.set(w.id,[]);for(const w of r)!c.has(w.src)||!c.has(w.dst)||w.src===w.dst||(p.get(w.src).push(w.dst),h.get(w.dst).push(w.src));const y=new Map;u.forEach((w,N)=>{for(const A of w)y.set(A.id,N)});const x=new Map,v=()=>{for(const w of u)w.forEach((N,A)=>x.set(N.id,A))};v();const m=(w,N)=>{const A=w.map(($,F)=>{const X=N($.id).map(te=>x.get(te)).filter(te=>te!==void 0),q=Dk(X);return{n:$,bary:Number.isNaN(q)?F:q,name:$.name,id:$.id}});return A.sort(($,F)=>$.bary-F.bary||$.name.localeCompare(F.name)||$.id.localeCompare(F.id)),A.map($=>$.n)},_=w=>N=>y.get(N)===w;for(let w=0;w(h.get(A)??[]).filter(_(N-1))),v();for(let N=u.length-2;N>=0;N--)u[N]=m(u[N],A=>(p.get(A)??[]).filter(_(N+1))),v()}const k=us+pc,j=ro+$k,b=Math.max(...u.map(w=>w.length),1),E=[];let R=0;for(let w=0;wX.id)),A=new Set((u[w+1]??[]).map(X=>X.id));let $=0;if(A.size)for(const X of r)N.has(X.src)&&A.has(X.dst)&&($+=1);const F=Math.min(48,Math.max(0,($-2)*10));R+=k+F}return u.forEach((w,N)=>{const A=(b-w.length)*j/2;w.forEach(($,F)=>{o.set($.id,{x:E[N]??0,y:A+F*j})})}),o}const Ok=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),vm=90,Fk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),gp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Hk=Math.PI*(3-Math.sqrt(5)),xm=220,Bk=26,Vk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function wm(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function VN(t){return gp[t]?gp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Wk(t){return t>=vm?"3d":"2d"}function Uk(t){return t>=vm?"overview":"full"}function Yk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(wm(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Fk.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Yk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function Gk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function qk(t,r,o,s){const a=new Set(t.map(j=>j.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const j of r){if(!a.has(j.src)||!a.has(j.dst))continue;const b=u.get(j.src)??[];b.push({dst:j.dst,id:j.id}),u.set(j.src,b);const E=c.get(j.dst)??[];E.push({src:j.src,id:j.id}),c.set(j.dst,E)}const h=new Set(t.filter(j=>Ok.has(j.type)).map(j=>j.id)),p=h.size?h:a,y=new Set,x=[o];for(;x.length;){const j=x.pop();if(!y.has(j)){y.add(j);for(const b of u.get(j)??[])y.has(b.dst)||x.push(b.dst)}}const v=new Set([o]),m=[...p].filter(j=>y.has(j)),_=new Set(m);for(;m.length;){const j=m.pop();v.add(j);for(const b of c.get(j)??[])y.has(b.src)&&!_.has(b.src)&&(_.add(b.src),m.push(b.src))}const k=new Set;for(const j of r)v.has(j.src)&&v.has(j.dst)&&k.add(j.id);return{nodeIds:v,edgeIds:k}}function WN(t){const r=new Map;for(const s of t){const a=ia(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*xm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Bk*Math.sqrt(h+1),y=h*Hk;o.set(c.id,{x:u,y:p*Math.cos(y),z:p*Math.sin(y)})})}return o}function UN(t){const r=new Map;for(const o of t){const s=ia(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*xm,count:s}))}const El=16,Kk=12,Qk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Zk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),mp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},Jk={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},yp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],vp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),eN=new Set(["looks_idempotent_on_pk","null","blank"]),tN=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function nN(t){return mp[t]?mp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function rN(t,r,o){const s=new Map(r.map(m=>[m.id,m])),a=[];Qk.has(t.type)&&a.push("sink"),Zk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(m=>m.dst===t.id),h=o.filter(m=>m.src===t.id),p=c.slice(0,El).map(m=>Cl(m,s,m.src)),y=h.slice(0,El).map(m=>Cl(m,s,m.dst)),x=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,v={type:t.type,typeLabel:Zo(io(t.type)),layer:Vk[ia(t.type)]??"other",purpose:nN(t.type),name:t.name,qualifiedName:t.qualified_name,file:x,context:t.context,roles:a,facts:oN(u).filter(m=>!(m.key==="app"&&m.value===t.context)),inputs:p,outputs:y,extraInputs:Math.max(0,c.length-El),extraOutputs:Math.max(0,h.length-El),degreeIn:c.length,degreeOut:h.length,inputKinds:xp(c.map(m=>Cl(m,s,m.src))),outputKinds:xp(h.map(m=>Cl(m,s,m.dst))),pathSummary:""};return v.pathSummary=iN(v),v}function xp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function iN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function Cl(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Zo(io(s.type)):"",edgeType:t.type,edgeLabel:Zo(t.type),inferred:t.confidence<.8}}function oN(t){const r=[...yp.filter(a=>a in t),...Object.keys(t).filter(a=>!yp.includes(a)&&!vp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||vp.has(a)||tN.has(a))continue;s.add(a);const u=sN(a,t[a]);u!=null&&o.push({key:a,label:Jk[a]??Zo(a),value:u})}return o}function sN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!eN.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return lN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Kk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function lN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const wp=12,_p=.2,aN=.8,uN=ro;function cN(t,r,o){const s=o??ym(t,r),a=[...new Set([...s.values()].map(p=>p.x))].sort((p,y)=>p-y),u=[];for(const p of r){const y=s.get(p.src),x=s.get(p.dst);if(!y||!x)continue;const v=y.y+ro/2,m=x.y+ro/2;if(Math.abs(v-m)k.y0-j.y0||k.y1-j.y1||k.id.localeCompare(j.id)),x=fN(y),v=Math.max(0,...x.values())+1,m=y[0].sourceX,_=dN(a,m);for(const k of y){const j=hN(x.get(k.id)??0,v),b=k.targetX-k.sourceX;if(Math.abs(b-_)<.5){h.set(k.id,j);continue}const E=k.sourceX+_*j;h.set(k.id,Math.min(.92,Math.max(.08,(E-k.sourceX)/b)))}}return h}function dN(t,r){const o=r-us,s=t.find(a=>a>o+1);return s===void 0?pc:Math.max(pc,s-r)}function fN(t){const r=[],o=new Map;for(const s of t){let a=-1;for(let u=0;ur[u]+uN){a=u;break}a<0?(a=r.length,r.push(s.y1)):r[a]=Math.max(r[a],s.y1),o.set(s.id,a)}return o}function hN(t,r){return r<=1?.5:_p+(aN-_p)*t/(r-1)}const pN=new Set,gN=L.lazy(()=>j0(()=>import("./LayeredGraph3D-XtGMK0TN.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),mN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function yN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(no,{type:"target",position:Se.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:io(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Tr(t.name)}),d.jsx(no,{type:"source",position:Se.Right,isConnectable:!1})]})}const vN={load:yN},xN=new Set(["django","react","stitch","arch"]);function wN({id:t,sourceX:r,sourceY:o,targetX:s,targetY:a,sourcePosition:u,targetPosition:c,style:h,markerEnd:p,markerStart:y,label:x,labelStyle:v,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,data:b,interactionWidth:E}){const[R,w,N]=Vl({sourceX:r,sourceY:o,sourcePosition:u,targetX:s,targetY:a,targetPosition:c,borderRadius:8,stepPosition:(b==null?void 0:b.stepPosition)??.5});return d.jsx(ys,{id:t,path:R,labelX:w,labelY:N,label:x,labelStyle:v,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,style:h,markerEnd:p,markerStart:y,interactionWidth:E})}const _N={loadstep:wN};function SN({topologyKey:t}){const{fitView:r}=na();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function kN(t,r,o=null,s={}){const a=new Map(t.map(y=>[y.id,y])),u=ym(t,r),c=cN(t,r,u),h=t.map(y=>{var m;const x=((m=s.roles)==null?void 0:m[y.id])||[],v=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:y.id,type:"load",position:u.get(y.id)??{x:0,y:0},data:{name:y.name,type:y.type,file:y.file_path,roles:x,dim:v},selected:o===y.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:us,height:ro,style:{width:us,height:ro}}}),p=r.filter(y=>a.has(y.src)&&a.has(y.dst)).map(y=>{const x=mN[y.weight]||"var(--edge-cheap)",v=!!(o&&(y.src===o||y.dst===o));return{id:y.id,source:y.src,target:y.dst,type:"loadstep",animated:y.weight==="critical",data:{stepPosition:c.get(y.id)??.5},style:{stroke:x,strokeWidth:y.weight==="critical"?2.4:1.2,strokeDasharray:y.confidence<.8?"6 4":void 0},markerEnd:{type:os.ArrowClosed,width:14,height:14,color:x},label:v?y.type.replaceAll("_"," "):void 0,labelStyle:v?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:v?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:v?[3,5]:void 0,labelBgBorderRadius:v?4:void 0}});return{rfNodes:h,rfEdges:p}}function NN({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:y}){const x=rN(t,r,o);return L.useEffect(()=>{const v=m=>{m.key==="Escape"&&s()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:x.typeLabel}),d.jsx("div",{className:"inspector-roles",children:x.roles.map(v=>d.jsx("span",{className:"inspector-chip",children:v},v))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Tr(x.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:x.purpose}),x.context?d.jsx("div",{className:"muted",children:Tr(x.context)}):null,x.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Tr(x.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Tr(x.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",x.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[x.degreeIn," in · ",x.degreeOut," out"]}),x.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:x.pathSummary}):null,x.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:x.facts.map(v=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:v.label}),d.jsx("dd",{children:Tr(v.value)})]},v.key))}):null,d.jsx(Sp,{title:"Inputs",testId:"graph-inspector-inputs",links:x.inputs,extra:x.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(Sp,{title:"Outputs",testId:"graph-inspector-outputs",links:x.outputs,extra:x.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),a?d.jsx("p",{className:"whatif-hint","data-testid":"whatif-hint",children:y?"Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map.":"Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."}):null,d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",title:"Start a hypothetical walk from this node. Does not use Base/Head.",onClick:()=>a(t.id),children:"What if this changes"}):null,y?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",title:"Hide nodes that are not on a path from here to a sink. Does not start a new walk.",onClick:()=>y(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function Sp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Qu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:y,repoPath:x,onOpenFile:v,pinnedId:m,onPin:_}){const[k,j]=L.useState(null),b=a!==void 0?a:k,E=re=>{a===void 0&&j(re),u==null||u(re)},[R,w]=L.useState(null),[N,A]=L.useState(null),[$,F]=L.useState(new Set(xN)),[X,q]=L.useState(!1),[te,ee]=L.useState(""),[ne,K]=L.useState(!1),C=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,V=R??Wk(t.length),W=N??Uk(t.length),U=X?b:null,M=L.useMemo(()=>p?qk(t,r,p):null,[t,r,p]),D=M?t.filter(re=>M.nodeIds.has(re.id)):t,H=M?r.filter(re=>M.edgeIds.has(re.id)):r,I=L.useMemo(()=>Xk(D,H,{detail:W,families:$,focusId:U,neighborhoodOnly:!!U}),[D,H,W,$,U]),z=L.useMemo(()=>`${I.nodes.map(re=>re.id).join("\0")}|${I.edges.map(re=>re.id).join("\0")}`,[I.nodes,I.edges]),ie=b?t.find(re=>re.id===b)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const re=kN(I.nodes,I.edges,b,{roles:c,testOverlay:h});return C&&(re.rfEdges=re.rfEdges.map(Ne=>({...Ne,animated:!1}))),re},[I.nodes,I.edges,b,C,c,h]);L.useEffect(()=>{if(!s)return;const re=t.find(Ne=>Ne.file_path===s);re&&E(re.id)},[s,t]);const he=L.useMemo(()=>Gk(t,te),[t,te]),pe=(re,Ne)=>{E(Ne.id)},Z=()=>{E(null),q(!1)},se=ie?d.jsx(NN,{node:ie,nodes:t,edges:r,onClose:Z,onWhatIf:o,onSelect:E,onOpenFile:v,pinned:m===ie.id,onPin:_,onIsolate:y?re=>{y(p===re?null:re)}:void 0}):null,me=re=>{F(Ne=>{const Me=new Set(Ne);if(Me.has(re)){if(Me.size===1)return Ne;Me.delete(re)}else Me.add(re);return Me})},ke=L.useMemo(()=>{const re=new Set;for(const Ne of t)re.add(wm(Ne.type));return re},[t]),ve=t.length-I.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:V==="2d"?"active":"","aria-pressed":V==="2d",onClick:()=>w("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:V==="3d"?"active":"","aria-pressed":V==="3d",onClick:()=>w("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:W==="overview"?"active":"","aria-pressed":W==="overview",onClick:()=>A("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:W==="full"?"active":"","aria-pressed":W==="full",onClick:()=>A("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(re=>ke.has(re)).map(re=>d.jsx("button",{type:"button","data-testid":`graph-family-${re}`,className:$.has(re)?"active":"","aria-pressed":$.has(re),onClick:()=>me(re),children:re},re))}),d.jsx("button",{type:"button",className:X?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!b,onClick:()=>q(re=>!re),children:X?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>y==null?void 0:y(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:te,onChange:re=>{ee(re.target.value),K(!0)},onFocus:()=>K(!0),onBlur:()=>window.setTimeout(()=>K(!1),150)}),ne&&te.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(re=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:Ne=>Ne.preventDefault(),onClick:()=>{E(re.id),ee(""),K(!1)},children:[re.name,d.jsx("span",{className:"muted",children:io(re.type)})]})},re.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[I.nodes.length," nodes · ",I.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:V==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(gN,{nodes:I.nodes,edges:I.edges,selectedId:b,neighborIds:U?I.neighborIds:pN,onSelect:re=>{E(re),re||q(!1)}})}),se]}):d.jsxs(hm,{children:[d.jsxs(ok,{nodes:oe,edges:fe,nodeTypes:vN,edgeTypes:_N,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:Z,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(SN,{topologyKey:z}),d.jsx(ck,{}),d.jsx(Ik,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(yk,{})]}),se]})})]})}function _m(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function jN(t){localStorage.setItem("loadpath.editor",t)}async function bN(t,r,o,s=_m()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const kp=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],EN=["preset","branch","tag","commit"];function CN(t){var a;if(!(t!=null&&t.git))return[...kp];const r=((a=t.presets)!=null&&a.length?t.presets:kp.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function MN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function PN(t){return EN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function IN(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function Np({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[y,x]=L.useState(!1),[v,m]=L.useState(null),[_,k]=L.useState(0),j=L.useMemo(()=>{const N=CN(u);return v===null?N:MN(N,v)},[u,v]),b=L.useMemo(()=>PN(j),[j]);L.useEffect(()=>{y&&c()},[y,c]),L.useEffect(()=>{k(0)},[v,y]);const E=()=>{x(!1),m(null)},R=N=>{r(N.value),E()},w=N=>{if(N.key==="ArrowDown"){if(N.preventDefault(),!y){x(!0);return}k(A=>Math.min(A+1,Math.max(j.length-1,0)))}else if(N.key==="ArrowUp"){if(N.preventDefault(),!y)return;k(A=>Math.max(A-1,0))}else if(N.key==="Enter"&&y){N.preventDefault();const A=j[_];A&&R(A)}else N.key==="Escape"&&y&&(N.preventDefault(),E())};return d.jsxs("div",{className:"combo",ref:p,onBlur:N=>{N.currentTarget.contains(N.relatedTarget)||E()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":y,"aria-controls":h,"aria-autocomplete":"list",onChange:N=>{r(N.target.value),y&&m(N.target.value)},onKeyDown:w}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":y,onMouseDown:N=>N.preventDefault(),onClick:()=>y?E():x(!0),children:d.jsx(S0,{})})]}),y?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:b.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):b.map(N=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:IN(N.group)}),N.items.map(A=>{const $=j.indexOf(A);return d.jsxs("button",{type:"button",role:"option","aria-selected":$===_,className:$===_?"combo-option active":"combo-option","data-testid":`ref-option-${A.group}`,onMouseDown:F=>F.preventDefault(),onMouseEnter:()=>k($),onClick:()=>R(A),children:[d.jsx("span",{className:"combo-label",children:A.label}),A.detail?d.jsx("span",{className:"combo-detail",children:A.detail}):null]},`${A.group}:${A.value}`)})]},N.group))}):null]})}function RN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[y,x]=L.useState(""),[v,m]=L.useState(!1),_=L.useRef(null),k=L.useRef(0),j=async w=>{const N=k.current+1;k.current=N,m(!0);try{const A=await Pe.browse(w);if(k.current!==N)return;a(A),c(A.path),p(A.is_git?A.path:null),x("")}catch(A){if(k.current!==N)return;x(A instanceof Error?A.message:String(A))}finally{k.current===N&&m(!1)}};L.useEffect(()=>{var w,N;j(t),(w=_.current)==null||w.focus(),(N=_.current)==null||N.select()},[t]);const b=h||(s==null?void 0:s.path)||u,E=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",R=w=>{w.key==="Escape"&&(w.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:R,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:w=>w.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:w=>{w.preventDefault(),j(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:w=>c(w.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),y?d.jsx("div",{className:"error",role:"alert",children:y}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":v,children:s!=null&&s.entries.length?s.entries.map(w=>{const N=h===w.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":N,className:N?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":w.path,onClick:()=>p(w.path),onDoubleClick:()=>void j(w.path),children:[d.jsx(Cp,{}),d.jsx("span",{className:"explorer-name",children:w.name}),w.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},w.path)}):d.jsx("div",{className:"muted explorer-empty",children:v?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:b,children:b}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!b,onClick:()=>b&&r(b),children:["Use ",E]})]})]})})}const TN={scan:{start:0,end:20},extract:{start:20,end:88},boot:{start:88,end:94},stitch:{start:94,end:99},skipped:{start:100,end:100},done:{start:100,end:100}},LN=new Set(["scan","extract","boot","stitch"]);function AN(t){const r=t.phase||"";if(!r||r==="idle")return null;const o=TN[r];if(!o)return null;if(o.start===o.end)return o.end;const s=t.total||0;if(s<=0)return o.start;const a=Math.min(1,Math.max(0,(t.done||0)/s));return Math.round(o.start+(o.end-o.start)*a)}function $N(t){return!t.phase||t.phase==="idle"?null:typeof t.percent=="number"&&Number.isFinite(t.percent)?Math.max(0,Math.min(100,Math.round(t.percent))):AN(t)}const Ul=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],zN="obsidian",Sm="loadpath.theme";function DN(t){return Ul.some(r=>r.id===t)}function km(){try{const t=localStorage.getItem(Sm)||"";if(DN(t))return t}catch{}return zN}function ON(t){var r;return((r=Ul.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function Nm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=ON(t);try{localStorage.setItem(Sm,t)}catch{}}const Zu=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:y0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:v0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:x0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:w0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:_0}];function Ju(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function FN(){var fo,ho,Si,po,go,mo,ki,Gr,rn,on;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,y]=L.useState(null),[x,v]=L.useState(null),[m,_]=L.useState(null),[k,j]=L.useState([]),[b,E]=L.useState("review"),[R,w]=L.useState(""),[N,A]=L.useState(""),[$,F]=L.useState(null),[X,q]=L.useState(!1),[te,ee]=L.useState(!1),[ne,K]=L.useState(""),[C,V]=L.useState({}),[W,U]=L.useState([]),[M,D]=L.useState([]),[H,I]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[z,ie]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[oe,fe]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[he,pe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[Z,se]=L.useState(0),[me,ke]=L.useState(""),[ve,re]=L.useState(km),[Ne,Me]=L.useState(!1),[Te,$e]=L.useState(!1),[st,lt]=L.useState(!1),[at,Xe]=L.useState(null),[wt,qt]=L.useState(null),[gt,mt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[Pt,ut]=L.useState(null),[Je,An]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[Ot,xn]=L.useState([]),[oo,$n]=L.useState(null),[vi,or]=L.useState(null),[$r,zn]=L.useState(null),[zr,sr]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[lr,Ft]=L.useState(null),[ct,Dn]=L.useState(null),[On,wn]=L.useState(!1),[Fn,_n]=L.useState(!1),rt=L.useRef(o);rt.current=o;const Dr=L.useRef(!1);Dr.current=Te;const _t=L.useRef(""),ar=L.useRef(""),Sn=P=>{re(P),Nm(P)},dt=L.useRef(""),He=P=>{dt.current=P,A(P)},kn=P=>{let Y=0,ce=!1;F(0);const je=()=>{Pe.indexProgress(P).then(Ie=>{if(!dt.current)return;if(Ie.phase&&Ie.phase!=="idle"&&Ie.message&&He(Ie.message),LN.has(Ie.phase))ce=!0;else if(!ce)return;const qr=$N(Ie);qr!=null&&(Ie.phase==="scan"&&!Ie.done?Y=qr:Y=Math.max(Y,qr),F(Y))}).catch(()=>{})};je();const Le=window.setInterval(je,250);return()=>{window.clearInterval(Le),F(null)}};L.useEffect(()=>{Pe.settings().then(V).catch(()=>{}).finally(()=>Me(!0)),Pe.repos().then(P=>j(P.repos)).catch(()=>{})},[]);const Nn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const P=o;let Y=!1;return ar.current!==P&&Bn(P),Pe.config(P).then(ce=>{!Y&&rt.current===P&&or(ce)}).catch(()=>{}),Pe.architectureHealth(P).then(ce=>{!Y&&rt.current===P&&zn(ce)}).catch(()=>{}),()=>{Y=!0}},[t,o]);const Ht=P=>{rt.current=P,s(P),localStorage.setItem("loadpath.repo",P),P.trim()!==_t.current&&(_t.current="",Ft(null))},Or=L.useCallback(P=>{const Y=(P??rt.current).trim();return!Y||_t.current===Y?Promise.resolve():(_t.current=Y,Pe.gitRefs(Y).then(ce=>{rt.current.trim()===Y&&Ft(ce)}).catch(()=>{_t.current===Y&&(_t.current="",Ft(null))}))},[]),nn=(P,Y)=>{u(P),h(Y),localStorage.setItem("loadpath.base",P),localStorage.setItem("loadpath.head",Y)},Fr=(P,Y,ce)=>{ie(P),I(Y),localStorage.setItem("loadpath.provider",P),localStorage.setItem("loadpath.scmRepo",Y),ce!==void 0&&(fe(ce),localStorage.setItem("loadpath.prNumber",ce))},yt=P=>{y(P),se(0),Xe(wt&&P.nodes.some(Y=>Y.id===wt)?wt:null),ut(null),$n(null),P.what_if||(v(P),P.id&&localStorage.setItem("loadpath.lastReviewId",P.id))},Hn=async P=>{try{const Y=await Pe.reviews(P);xn(Y.reviews)}catch{xn([])}},ur=async P=>{try{zn(await Pe.architectureHealth(P))}catch{zn(null)}},so=P=>P==="github"?!!C.github_token_set:P==="gitlab"?!!C.gitlab_token_set:!!C.bitbucket_token_set,It=L.useCallback(async(P=z)=>{var Y;try{const ce=await Pe.scmRepos(P);D(ce.repos),(Y=ce.user)!=null&&Y.login&&V(je=>({...je,...P==="github"?{github_user:ce.user.login}:P==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{D([])}},[z]);L.useEffect(()=>{if(t!=="prs")return;let P=!1;return It(z).catch(()=>{P||D([])}),()=>{P=!0}},[t,z,It]),L.useEffect(()=>{if(!ct)return;let P=!1,Y=0;const ce=async()=>{try{const je=await Pe.githubOAuthPoll(ct.flow_id);if(P)return;if(je.status==="complete"){Dn(null);const Le=await Pe.settings();V(Le),K(je.user?`Signed in to GitHub as ${je.user}`:"Signed in to GitHub"),It("github");return}if(je.status==="pending"||je.status==="slow_down"){Y=window.setTimeout(ce,Math.max(je.interval||ct.interval,5)*1e3);return}Dn(null),w(je.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(je){if(P)return;Dn(null),w(je instanceof Error?je.message:String(je))}};return Y=window.setTimeout(ce,Math.max(ct.interval,5)*1e3),()=>{P=!0,window.clearTimeout(Y)}},[ct,It]),L.useEffect(()=>{if(!On)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.bitbucket.connected){wn(!1);const Ie=await Pe.settings();V(Ie),K(Le.bitbucket.user?`Signed in to Bitbucket as ${Le.bitbucket.user}`:"Signed in to Bitbucket"),It("bitbucket");return}if(Date.now()-ce>18e4){wn(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;wn(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[On,It]),L.useEffect(()=>{if(!Fn)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.gitlab.connected){_n(!1);const Ie=await Pe.settings();V(Ie),K(Le.gitlab.user?`Signed in to GitLab as ${Le.gitlab.user}`:"Signed in to GitLab"),It("gitlab");return}if(Date.now()-ce>18e4){_n(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;_n(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[Fn,It]);const Bn=async(P=o,Y=!1)=>{if(!P.trim())return null;ar.current=P,ee(!0);try{const ce=await Pe.architecture(P,!1);rt.current===P&&_(ce);const je=Pe.architectureGraph(P).then(Le=>{rt.current===P&&_(Ie=>Ie&&{...Ie,nodes:Le.nodes,edges:Le.edges,graph_pending:!1})});return je.catch(()=>{}).finally(()=>{rt.current===P&&ee(!1)}),Y&&await je,ce}catch(ce){throw rt.current===P&&ee(!1),ce}},Hr=async P=>{const Y=P.trim();if(!(!Y||Y===rt.current)){if(dt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),K(""),y(null),v(null),_(null),E("architecture"),Ht(Y),q(!0),He(`Loading ${m0(Y)}…`);try{await Promise.all([Bn(Y),Or(Y)])}catch(ce){rt.current===Y&&w(ce instanceof Error?ce.message:String(ce))}finally{rt.current===Y&&(He(""),q(!1))}}},jn=async()=>{if(dt.current||!Nn())return;w(""),K(""),He("Tracing load path…"),Ht(o),nn(a,c);const P=kn(o);try{const Y=await Pe.review(o,a,c,!0,he);yt(Y),E("review"),r("review"),await Pe.repos().then(ce=>j(ce.repos)).catch(()=>{}),await Promise.all([Bn(o),Hn(o),ur(o)])}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{P(),He("")}},Br=async(P=!0)=>{if(dt.current||!Nn())return;w(""),K(""),He(P?"Indexing…":"Full reindex…"),Ht(o);const Y=kn(o);try{await Pe.index(o,P);const ce=await Bn(o);await Pe.repos().then(je=>j(je.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(E("architecture"),r("architecture"))}catch(ce){w(ce instanceof Error?ce.message:String(ce))}finally{Y(),He("")}},xi=async()=>{if(!dt.current&&Nn()){w(""),K(""),He("Detecting layout…"),Ht(o);try{const P=await Pe.init(o);K(P.message),await Pe.repos().then(Y=>j(Y.repos)).catch(()=>{})}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ve=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),K("Copied markdown brief")}catch(P){w(P instanceof Error?P.message:String(P))}},lo=async()=>{if(!dt.current){if(p!=null&&p.what_if){w("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first.");return}if(!(p!=null&&p.markdown)||!H||!oe){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const P=await Pe.postComment(z,H,Number(oe),p.markdown);K(P.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Vr=async()=>{if(!dt.current){w(""),He("Fetching pull requests…");try{const P=await Pe.prs(z,H,"open",o.trim()||void 0);U(P.pull_requests);const Y=M.find(ce=>ce.slug.toLowerCase()===H.trim().toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},wi=async()=>{w("");try{const P=await Pe.githubOAuthStart();Dn(P),Ju(P.verification_uri_complete,"github.com","/login/device")}catch(P){w(P instanceof Error?P.message:String(P))}},cr=async()=>{w("");try{const P=await Pe.bitbucketOAuthStart();wn(!0),Ju(P.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(P){wn(!1),w(P instanceof Error?P.message:String(P))}},ao=async()=>{w("");try{const P=await Pe.gitlabOAuthStart();_n(!0),Ju(P.authorize_url,new URL(P.authorize_url).hostname,"/oauth/authorize")}catch(P){_n(!1),w(P instanceof Error?P.message:String(P))}},dr=async P=>{if(!(dt.current||!o.trim())){w(""),He("Walking what-if path…");try{const Y=await Pe.whatIf(o,P);K(`${Y.title} — ${Y.confidence.level} · ${(Y.sinks||[]).length} sinks`),yt({...Y,markdown:Y.markdown||"",index:Y.index||(p==null?void 0:p.index),workspace:Y.workspace||(p==null?void 0:p.workspace)}),E("review"),r("review")}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},Vn=()=>{if(x){yt(x),E("review"),r("review"),K("Restored the last git-range walk");return}y(null),se(0),Xe(null),ut(null),$n(null),E("architecture"),r("architecture"),K("")},bt=async P=>{var Le;if(dt.current)return;Fr(P.provider,P.repo,String(P.number));const Y=M.find(Ie=>Ie.slug.toLowerCase()===P.repo.toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path),w(""),He(`Fetching ${P.provider} #${P.number}…`);const ce=(Y==null?void 0:Y.local_path)||o,je=ce?kn(ce):()=>{};try{const Ie=await Pe.reviewPr(P.provider,P.repo,P.number,(Y==null?void 0:Y.local_path)||o||void 0);yt(Ie),Ie.pull_request&&typeof Ie.pull_request.repo_path=="string"&&Ht(Ie.pull_request.repo_path),nn(String(Ie.base||P.target_branch),String(Ie.head||P.source_branch)),E("review"),r("review"),typeof((Le=Ie.pull_request)==null?void 0:Le.repo_path)=="string"&&Hn(Ie.pull_request.repo_path)}catch(Ie){nn(P.base_sha||P.target_branch,P.head_sha||P.source_branch),r("review"),w(Ie instanceof Error?Ie.message:String(Ie))}finally{je(),He("")}},Wr=async P=>{w("");try{V(await Pe.oauthDisconnect(P)),z===P&&D([]),K(`Disconnected ${P}`)}catch(Y){w(Y instanceof Error?Y.message:String(Y))}},Et=async P=>{P.preventDefault();const Y=new FormData(P.currentTarget),ce={github_token:String(Y.get("github_token")||""),github_oauth_client_id:String(Y.get("github_oauth_client_id")||""),github_host:String(Y.get("github_host")||""),gitlab_token:String(Y.get("gitlab_token")||""),gitlab_host:String(Y.get("gitlab_host")||""),gitlab_oauth_client_id:String(Y.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(Y.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(Y.get("bitbucket_token")||""),bitbucket_username:String(Y.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(Y.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(Y.get("bitbucket_oauth_client_secret")||""),ai_provider:String(Y.get("ai_provider")||"none"),ai_api_key:String(Y.get("ai_api_key")||""),ai_model:String(Y.get("ai_model")||""),ai_base_url:String(Y.get("ai_base_url")||"")},je=k.length?{...ce,workspaces:k.map(Le=>({path:Le.path,name:Le.name}))}:ce;try{V(await Pe.saveSettings(je)),K("Settings saved on this machine")}catch(Le){w(Le instanceof Error?Le.message:String(Le))}},uo=async()=>{if(!(!p||dt.current)){He("Residual analysis…");try{const P=await Pe.residual(p);ke(P.note)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ur=L.useRef(jn);Ur.current=jn;const Yr=L.useRef(t);Yr.current=t;const Wn=L.useRef(!1);Wn.current=st;const Un=L.useRef(p);Un.current=p;const bn=L.useRef(Z);bn.current=Z,L.useEffect(()=>{const P=localStorage.getItem("loadpath.lastReviewId"),Y=(localStorage.getItem("loadpath.repo")||"").trim();if(!P||!Y){sr(!1);return}let ce=!1;return Pe.getReview(Y,P).then(je=>{ce||(yt(je),nn(je.base||localStorage.getItem("loadpath.base")||"HEAD~1",je.head||localStorage.getItem("loadpath.head")||"HEAD"),Hn(Y),ur(Y))}).catch(()=>{}).finally(()=>{ce||sr(!1)}),()=>{ce=!0}},[]);const Bt=L.useRef("");L.useEffect(()=>{if(!Je||!o.trim())return;let P=!1;const Y=async()=>{try{const je=await Pe.workspaceStatus(o);if(P)return;Bt.current&&je.fingerprint!==Bt.current&&!dt.current&&(pe(!0),localStorage.setItem("loadpath.dirty","1"),Ur.current()),Bt.current=je.fingerprint}catch{}};Y();const ce=window.setInterval(Y,2e3);return()=>{P=!0,window.clearInterval(ce)}},[Je,o]),L.useEffect(()=>{const P=Y=>{var Le;if((Y.metaKey||Y.ctrlKey)&&Y.key.toLowerCase()==="k"){Y.preventDefault(),lt(Ie=>!Ie);return}if(Wn.current){Y.key==="Escape"&&(Y.preventDefault(),lt(!1));return}if(Dr.current){Y.key==="Escape"&&(Y.preventDefault(),$e(!1));return}const ce=Y.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){Y.key==="Escape"&&ce.blur();return}if(Y.key==="Escape"){w(""),K(""),Xe(wt),ut(null);return}if(Y.key==="j"||Y.key==="k"){const Ie=((Le=Un.current)==null?void 0:Le.read_order)||[];if(!Ie.length)return;Y.preventDefault();const Xn=bn.current,qr=Y.key==="j"?Math.min(Ie.length-1,Xn+1):Math.max(0,Xn-1);se(qr);return}const je=Zu.find(Ie=>Ie.shortcut===Y.key);if(je&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey&&r(je.id),(Y.metaKey||Y.ctrlKey)&&Y.key==="Enter"){if(Yr.current==="settings"||Yr.current==="prs"||dt.current)return;Y.preventDefault(),Ur.current()}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[wt]);const _i=async(P,Y)=>{if(!o.trim())return;const ce=await bN(o,P,Y);ce.ok?K(ce.message):w(ce.message)},Xr=async()=>{if(p)try{const P=await Pe.exportHtml(p),Y=URL.createObjectURL(P),ce=document.createElement("a");ce.href=Y,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(Y),K("Saved HTML brief")}catch(P){w(P instanceof Error?P.message:String(P))}},fr=async P=>{if(o.trim()){He("Loading stored review…");try{const Y=await Pe.getReview(o,P);yt(Y),nn(Y.base||a,Y.head||c),E("review"),r("review");const ce=Ot.find(je=>je.id!==P);if(ce)try{$n(await Pe.reviewDiff(o,P,ce.id))}catch{$n(null)}}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},hr={selectedId:at,onSelect:Xe,nodeRoles:p==null?void 0:p.node_roles,testOverlay:gt,isolateSource:Pt,onIsolate:ut,repoPath:o,onOpenFile:_i,pinnedId:wt,onPin:qt},Yn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},...p!=null&&p.what_if?[{id:"exit-whatif",group:"Review",label:x?"Back to git-range walk":"Exit what-if walk",run:Vn}]:[],{id:"index",group:"Run",label:"Index repository",run:()=>void Br(!0)},{id:"watch",group:"Run",label:Je?"Stop watching working tree":"Watch working tree",run:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")}},{id:"tests",group:"Graph",label:gt?"Hide test overlay":"Show test overlay",run:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Xr()},...Zu.map(P=>({id:`tab-${P.id}`,group:"Tabs",label:`Go to ${P.label}`,hint:P.shortcut,run:()=>r(P.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(P=>({id:`node-${P.id}`,group:"Nodes",label:P.name,hint:io(P.type),run:()=>{Xe(P.id),r("graph")}})),...Ot.slice(0,12).map(P=>({id:`hist-${P.id}`,group:"History",label:P.title||P.id,hint:`${P.level||""} ${P.created_at||""}`.trim(),run:()=>void fr(P.id)}))],En=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[b,m,p]),co=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[b,m,p]),pr=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Fe=((p==null?void 0:p.findings)||[]).filter(P=>!P.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Zu.map(P=>{const Y=P.icon,ce=t===P.id;return d.jsxs("button",{type:"button","data-testid":P.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":P.label,onClick:()=>r(P.id),children:[d.jsx(Y,{}),d.jsx("span",{children:P.label})]},P.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:ve,onChange:P=>Sn(P.target.value),children:["dark","light"].map(P=>d.jsx("optgroup",{label:P==="dark"?"Dark":"Light",children:Ul.filter(Y=>Y.group===P).map(Y=>d.jsx("option",{value:Y.id,children:Y.label},Y.id))},P))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:N||pr}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[N?d.jsxs("div",{className:$!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","aria-valuemin":$!=null?0:void 0,"aria-valuemax":$!=null?100:void 0,"aria-valuenow":$??void 0,"data-testid":"progress",children:[d.jsx("i",{style:$!=null?{width:`${$}%`}:void 0}),d.jsx("span",{className:"sr-only",children:N})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[k.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:k.some(P=>P.path===o)?o:"",disabled:!!N,"aria-busy":X,onChange:P=>{P.target.value&&Hr(P.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),k.map(P=>d.jsxs("option",{value:P.path,children:[P.name,P.indexed?` (${P.counts.nodes})`:""]},P.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:P=>{const Y=P.target.value;s(Y),Y.trim()!==_t.current&&(_t.current="",Ft(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>$e(!0),children:d.jsx(Cp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(Np,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:P=>nn(P,c),placeholder:"base",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(Np,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:P=>nn(a,P),placeholder:"head",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:he?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":he,onClick:()=>{const P=!he;pe(P),localStorage.setItem("loadpath.dirty",P?"1":"0")},children:he?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:Je?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":Je,onClick:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")},children:Je?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.what_if?"what-if · ":"",p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!N,onClick:xi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!N,onClick:()=>Br(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!N,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[R?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:R}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,ne?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:ne}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>K(""),"aria-label":"Dismiss",children:"×"})]}):null,((fo=p==null?void 0:p.index)!=null&&fo.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((ho=p==null?void 0:p.index)==null?void 0:ho.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Si=p==null?void 0:p.index)==null?void 0:Si.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(po=p==null?void 0:p.workspace)!=null&&po.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,p!=null&&p.what_if?d.jsxs("div",{className:"banner whatif","data-testid":"whatif-banner",children:[d.jsxs("span",{children:["Hypothetical walk from"," ",d.jsx("strong",{children:((go=p.node)==null?void 0:go.name)||"this node"}),". Loadpath ignored Base/Head and asked which sinks would feel this node change — not a filter of the current map."]}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-exit-whatif",onClick:Vn,children:x?"Back to git range":"Back to architecture"})]}):null,X?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:N||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":X||te,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(HN,{review:p,findings:Fe,aiNote:me,busy:!!N,tourIndex:Z,onTour:se,onAskAi:uo,onCopy:Ve,onPost:lo,onSelect:Xe,onOpenFile:_i,onExport:Xr,history:Ot,diff:oo,onReopen:fr,onWaiver:(P,Y)=>{o.trim()&&Pe.addWaiver(o,P,Y||void 0,"from review").then(ce=>{or(ce),K(`Waived ${P} in loadpath.yml`)})}}):zr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Qu,{nodes:p.nodes,edges:p.edges,onWhatIf:dr,focusPath:(mo=p.read_order[Z])==null?void 0:mo.path,...hr}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(BN,{architecture:m,busy:!!N,onReindex:()=>Br(!1),onReview:jn,onSelect:Xe,config:vi,health:$r,onSaveConfig:P=>{Pe.saveConfig(o,P).then(Y=>{or(Y),K("Wrote loadpath.yml")})},onWaiver:(P,Y,ce)=>{Pe.addWaiver(o,P,Y,ce).then(je=>{or(je),K(`Waived ${P}`)})}}):X?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(te||m!=null&&m.graph_pending)&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(ki=m==null?void 0:m.counts)!=null&&ki.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Qu,{nodes:m.nodes,edges:m.edges,onWhatIf:dr,...hr,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":b==="review","data-testid":"graph-mode-review",className:b==="review"?"active":"",onClick:()=>E("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":b==="architecture","data-testid":"graph-mode-architecture",className:b==="architecture"?"active":"",onClick:()=>E("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:gt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":gt,onClick:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")},children:"Tests"})]}),En.length?d.jsx(Qu,{nodes:En,edges:co,onWhatIf:dr,...hr}):te||m!=null&&m.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:z,onChange:P=>Fr(P.target.value,H,oe),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:M.length?"Search your repos":"owner/repo",value:H,onChange:P=>Fr(z,P.target.value,oe),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:M.map(P=>d.jsxs("option",{value:P.slug,children:[P.private?"private":"public",P.local_path?" · local":""]},P.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!N||!so(z),onClick:()=>{It(z)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!N,onClick:Vr,children:"List PRs"})]}),M.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[M.length," ",z," repositor",M.length===1?"y":"ies",z==="github"&&C.github_user?` · @${String(C.github_user)}`:"",z==="gitlab"&&C.gitlab_user?` · @${String(C.gitlab_user)}`:"",z==="bitbucket"&&C.bitbucket_user?` · ${String(C.bitbucket_user)}`:""]}):null,W.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):W.map(P=>{var Y;return d.jsxs("article",{className:"pr","data-testid":`pr-${P.number}`,children:[d.jsxs("h3",{children:["#",P.number," ",P.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${P.draft?"":"open"}`,children:P.draft?"draft":P.state}),d.jsx("span",{children:P.author}),d.jsxs("span",{children:[P.source_branch," → ",P.target_branch]}),P.loadpath?d.jsxs("span",{className:`chip ${P.loadpath.level||""}`,"data-testid":`pr-loadpath-${P.number}`,children:[((Y=P.loadpath.level)==null?void 0:Y.toUpperCase())||"REVIEWED",P.loadpath.contract_break&&P.loadpath.contract_break!=="none"?` · ${P.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:P.url,target:"_blank",rel:"noreferrer",children:["Open on ",P.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${P.number}`,onClick:()=>void bt(P),children:"Review this PR"})]})]},`${P.provider}-${P.number}`)})]}),t==="settings"&&Ne&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Et,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Ul.map(P=>d.jsxs("button",{type:"button","data-theme":P.id,className:ve===P.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${P.id}`,onClick:()=>Sn(P.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:P.label}),d.jsx("div",{className:"group",children:P.group})]},P.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:_m(),onChange:P=>jN(P.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:C.github_token_set?C.github_user?`Signed in as @${String(C.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void Wr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!ct||!C.github_oauth_ready,onClick:()=>void wi(),children:ct?"Waiting for GitHub…":"Sign in with GitHub"})})]}),ct?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:ct.user_code})," at GitHub if the browser did not fill it in."]}):null,C.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(C.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(C.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:C.gitlab_token_set?C.gitlab_user?`Signed in as @${String(C.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void Wr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Fn||!C.gitlab_oauth_ready,onClick:()=>void ao(),children:Fn?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(C.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(C.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:C.bitbucket_token_set?C.bitbucket_user?`Signed in as ${String(C.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void Wr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:On||!C.bitbucket_oauth_ready,onClick:()=>void cr(),children:On?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),C.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(C.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(C.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((Gr=C.ai)==null?void 0:Gr.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((rn=C.ai)==null?void 0:rn.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((on=C.ai)==null?void 0:on.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(h0,{open:st,actions:Yn,onClose:()=>lt(!1)}),Te?d.jsx(RN,{initialPath:o,onClose:()=>$e(!1),onSelect:P=>{if(dt.current){w("Wait for the current job to finish before switching workspace.");return}$e(!1),Hr(P)}}):null]})}function HN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:y,onOpenFile:x,onExport:v,history:m,diff:_,onReopen:k,onWaiver:j}){var E,R,w,N,A,$,F,X,q,te,ee,ne,K,C,V,W,U;const b=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),b.length?d.jsx("ul",{className:"reasons",children:b.map(M=>d.jsx("li",{children:M},M))}):null,t.what_if?d.jsx("span",{className:"chip whatif","data-testid":"whatif-chip",children:"what-if"}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Zo(M)},M)),(E=t.contract_break)!=null&&E.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&y(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>j(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(R=t.workspace)!=null&&R.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>x(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&y(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(jm,{cards:t.deepening}),(N=(w=t.contract_break)==null?void 0:w.reasons)!=null&&N.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),($=(A=t.contract_break.sides)==null?void 0:A.rows)!=null&&$.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(F=t.auth)!=null&&F.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(X=t.suggested_tests)==null?void 0:X.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(q=t.trend)!=null&&q.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",ec(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),m.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:m.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,m.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>k(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?ec(M.created_at):""})]},M.id))]}):null,(ee=(te=t.evolution)==null?void 0:te.notes)!=null&&ee.length||(K=(ne=t.evolution)==null?void 0:ne.hotspots)!=null&&K.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((C=t.evolution)==null?void 0:C.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((V=t.evolution)==null?void 0:V.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:v,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",disabled:s||!!t.what_if,title:t.what_if?"Hypothetical walks are not posted to a pull request":void 0,onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(W=t.codeowners_reviewers)!=null&&W.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function BN({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var x;const y=t.findings.filter(v=>!v.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${ec(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(v=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:v.name})," — ",(v.django_apps||[]).join(", ")||"no apps"," ·"," ",(v.owners||[]).join(", ")||"unowned"]},v.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(v=>d.jsx("div",{className:"muted",children:v},v))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:y.length})]}),y.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):y.map(v=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>v.node_id&&a(v.node_id),children:[d.jsx("span",{className:`chip ${v.severity}`,children:v.severity}),v.message]})},v.rule+v.message))]}),d.jsx(jm,{cards:t.deepening}),(x=c==null?void 0:c.points)!=null&&x.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(v=>d.jsx("i",{className:v.level||"",title:`${v.level} · ${v.findings} findings`,style:{height:`${8+Math.min(24,(v.findings||0)*4)}px`}},v.id||v.created_at))}),Object.entries(c.contexts).map(([v,m])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:v})," — last ",((_=m[m.length-1])==null?void 0:_.findings)??0," findings"]},v)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(p0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((v,m)=>m[1]-v[1]).slice(0,12).map(([v,m])=>d.jsxs("tr",{children:[d.jsx("td",{children:io(v)}),d.jsx("td",{children:m})]},v))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function jm({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:g0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}Nm(km());c0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(FN,{})}));export{Vk as L,UN as a,VN as c,d as j,WN as l,L as r,io as t}; +`)),x=y.reduce((v,m)=>v.concat(...m),[]);return[y,x]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Kh,y=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const x=_=>{var b,E;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!y)&&xg(_))return!1;const j=Zh(_.code,h);if(u.current.add(_[j]),Qh(c,u.current,!1)){const R=((E=(b=_.composedPath)==null?void 0:b.call(_))==null?void 0:E[0])||_.target,w=(R==null?void 0:R.nodeName)==="BUTTON"||(R==null?void 0:R.nodeName)==="A";r.preventDefault!==!1&&(a.current||!w)&&_.preventDefault(),s(!0)}},v=_=>{const k=Zh(_.code,h);Qh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},m=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",x),p==null||p.addEventListener("keyup",v),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{p==null||p.removeEventListener("keydown",x),p==null||p.removeEventListener("keyup",v),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,s]),o}function Qh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Zh(t,r){return r.includes(t)?"code":"key"}const T_=()=>{const t=Ye();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=bc(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),y={x:r.x-h,y:r.y-p},x=o.snapGrid??a,v=o.snapToGrid??u;return ms(y,s,v,x)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=eo(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function Hg(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)L_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function L_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function A_(t,r){return Hg(t,r)}function $_(t,r){return Hg(t,r)}function ai(t,r){return{id:t,type:"select",selected:r}}function Gi(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(ai(u.id,c)))}return s}function Jh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function ep(t){return{id:t.id,type:"remove"}}const z_=gg();function D_(t,r,o={}){return _1(t,r,{...o,onError:o.onError??z_})}const tp=t=>s1(t),O_=t=>cg(t);function Bg(t){return L.forwardRef(t)}const Vg=typeof window<"u"?L.useLayoutEffect:L.useEffect;function np(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>F_(()=>o(a=>a+BigInt(1))));return Vg(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function F_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Wg=L.createContext(null);function H_({children:t}){const r=Ye(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:y,hasDefaultNodes:x,onNodesChange:v,nodeLookup:m,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let j=p;for(const E of h)j=typeof E=="function"?E(j):E;let b=Jh({items:j,lookup:m});for(const E of k.values())b=E(b);x&&y(j),b.length>0?v==null||v(b):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:R,setNodes:w}=r.getState();E&&w(R)})},[]),s=np(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:y,hasDefaultEdges:x,onEdgesChange:v,edgeLookup:m}=r.getState();let _=p;for(const k of h)_=typeof k=="function"?k(_):k;x?y(_):v&&v(Jh({items:_,lookup:m}))},[]),u=np(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Wg.Provider,{value:c,children:t})}function B_(){const t=L.useContext(Wg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const V_=t=>!!t.panZoom;function ra(){const t=T_(),r=Ye(),o=B_(),s=De(V_),a=L.useMemo(()=>{const u=v=>r.getState().nodeLookup.get(v),c=v=>{o.nodeQueue.push(v)},h=v=>{o.edgeQueue.push(v)},p=v=>{var E,R;const{nodeLookup:m,nodeOrigin:_}=r.getState(),k=tp(v)?v:m.get(v.id),j=k.parentId?yg(k.position,k.measured,k.parentId,m,_):k.position,b={...k,position:j,width:((E=k.measured)==null?void 0:E.width)??k.width,height:((R=k.measured)==null?void 0:R.height)??k.height};return ss(b)},y=(v,m,_={replace:!1})=>{c(k=>k.map(j=>{if(j.id===v){const b=typeof m=="function"?m(j):m;return _.replace&&tp(b)?b:{...j,...b}}return j}))},x=(v,m,_={replace:!1})=>{h(k=>k.map(j=>{if(j.id===v){const b=typeof m=="function"?m(j):m;return _.replace&&O_(b)?b:{...j,...b}}return j}))};return{getNodes:()=>r.getState().nodes.map(v=>({...v})),getNode:v=>{var m;return(m=u(v))==null?void 0:m.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:v=[]}=r.getState();return v.map(m=>({...m}))},getEdge:v=>r.getState().edgeLookup.get(v),setNodes:c,setEdges:h,addNodes:v=>{const m=Array.isArray(v)?v:[v];o.nodeQueue.push(_=>[..._,...m])},addEdges:v=>{const m=Array.isArray(v)?v:[v];o.edgeQueue.push(_=>[..._,...m])},toObject:()=>{const{nodes:v=[],edges:m=[],transform:_}=r.getState(),[k,j,b]=_;return{nodes:v.map(E=>({...E})),edges:m.map(E=>({...E})),viewport:{x:k,y:j,zoom:b}}},deleteElements:async({nodes:v=[],edges:m=[]})=>{const{nodes:_,edges:k,onNodesDelete:j,onEdgesDelete:b,triggerNodeChanges:E,triggerEdgeChanges:R,onDelete:w,onBeforeDelete:N}=r.getState(),{nodes:A,edges:$}=await d1({nodesToRemove:v,edgesToRemove:m,nodes:_,edges:k,onBeforeDelete:N}),F=$.length>0,G=A.length>0;if(F){const q=$.map(ep);b==null||b($),R(q)}if(G){const q=A.map(ep);j==null||j(A),E(q)}return(G||F)&&(w==null||w({nodes:A,edges:$})),{deletedNodes:A,deletedEdges:$}},getIntersectingNodes:(v,m=!0,_)=>{const k=bh(v),j=k?v:p(v),b=_!==void 0;return j?(_||r.getState().nodes).filter(E=>{const R=r.getState().nodeLookup.get(E.id);if(R&&!k&&(E.id===v.id||!R.internals.positionAbsolute))return!1;const w=ss(b?E:R),N=Bl(w,j);return m&&N>0||N>=w.width*w.height||N>=j.width*j.height}):[]},isNodeIntersecting:(v,m,_=!0)=>{const j=bh(v)?v:p(v);if(!j)return!1;const b=Bl(j,m);return _&&b>0||b>=m.width*m.height||b>=j.width*j.height},updateNode:y,updateNodeData:(v,m,_={replace:!1})=>{y(v,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},updateEdge:x,updateEdgeData:(v,m,_={replace:!1})=>{x(v,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},getNodesBounds:v=>{const{nodeLookup:m,nodeOrigin:_}=r.getState();return l1(v,{nodeLookup:m,nodeOrigin:_})},getHandleConnections:({type:v,id:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${v}${m?`-${m}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:v,handleId:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${v?m?`-${v}-${m}`:`-${v}`:""}`))==null?void 0:k.values())??[])},fitView:async v=>{const m=r.getState().fitViewResolver??p1();return r.setState({fitViewQueued:!0,fitViewOptions:v,fitViewResolver:m}),o.nodeQueue.push(_=>[..._]),m.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const rp=t=>t.selected,W_=typeof window<"u"?window:void 0;function U_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ye(),{deleteElements:s}=ra(),a=as(t,{actInsideInputWithModifier:!1}),u=as(r,{target:W_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(rp),edges:c.filter(rp)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function Y_(t){const r=Ye();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=Ec(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",mn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const ia={position:"absolute",width:"100%",height:"100%",top:0,left:0},G_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function X_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=di.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:y,translateExtent:x,minZoom:v,maxZoom:m,zoomActivationKeyCode:_,preventScrolling:k=!0,children:j,noWheelClassName:b,noPanClassName:E,onViewportChange:R,isControlledViewport:w,paneClickDistance:N,selectionOnDrag:A}){const $=Ye(),F=L.useRef(null),{userSelectionActive:G,lib:q,connectionInProgress:te}=De(G_,Qe),ee=as(_),ne=L.useRef();Y_(F);const K=L.useCallback(C=>{R==null||R({x:C[0],y:C[1],zoom:C[2]}),w||$.setState({transform:C})},[R,w]);return L.useEffect(()=>{if(F.current){ne.current=Q1({domNode:F.current,minZoom:v,maxZoom:m,translateExtent:x,viewport:y,onDraggingChange:U=>$.setState(M=>M.paneDragging===U?M:{paneDragging:U}),onPanZoomStart:(U,M)=>{const{onViewportChangeStart:D,onMoveStart:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoom:(U,M)=>{const{onViewportChange:D,onMove:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoomEnd:(U,M)=>{const{onViewportChangeEnd:D,onMoveEnd:H}=$.getState();H==null||H(U,M),D==null||D(M)}});const{x:C,y:V,zoom:W}=ne.current.getViewport();return $.setState({panZoom:ne.current,transform:[C,V,W],domNode:F.current.closest(".react-flow")}),()=>{var U;(U=ne.current)==null||U.destroy()}}},[]),L.useEffect(()=>{var C;(C=ne.current)==null||C.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:ee,preventScrolling:k,noPanClassName:E,userSelectionActive:G,noWheelClassName:b,lib:q,onTransformChange:K,connectionInProgress:te,selectionOnDrag:A,paneClickDistance:N})},[t,r,o,s,a,u,c,h,p,ee,k,E,G,b,q,K,te,A,N]),d.jsx("div",{className:"react-flow__renderer",ref:F,style:ia,children:j})}const q_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function K_(){const{userSelectionActive:t,userSelectionRect:r}=De(q_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const Ku=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},Q_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function Z_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=is.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:y,onPaneContextMenu:x,onPaneScroll:v,onPaneMouseEnter:m,onPaneMouseMove:_,onPaneMouseLeave:k,children:j}){const b=L.useRef(0),E=Ye(),{userSelectionActive:R,elementsSelectable:w,dragging:N,panBy:A,autoPanSpeed:$}=De(Q_,Qe),F=w&&(t||R),G=L.useRef(null),q=L.useRef(),te=L.useRef(new Set),ee=L.useRef(new Set),ne=L.useRef(!1),K=L.useRef(!1),C=L.useRef({x:0,y:0}),V=L.useRef(!1),W=Z=>{if(K.current||ne.current||E.getState().connection.inProgress){K.current=!1,ne.current=!1;return}y==null||y(Z),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},U=Z=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Z.preventDefault();return}x==null||x(Z)},M=v?Z=>v(Z):void 0,D=Z=>{K.current&&(Z.stopPropagation(),K.current=!1)},H=Z=>{var $e,st;if(Z.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:se,transform:me}=E.getState();if(q.current=se==null?void 0:se.getBoundingClientRect(),!q.current)return;const ke=Z.target===G.current;if(!ke&&!!Z.target.closest(".nokey")||!t||!(c&&ke||r)||Z.button!==0||!Z.isPrimary)return;(st=($e=Z.target)==null?void 0:$e.setPointerCapture)==null||st.call($e,Z.pointerId),K.current=!1;const{x:Ne,y:Me}=gn(Z.nativeEvent,q.current),Te=ms({x:Ne,y:Me},me);E.setState({userSelectionRect:{width:0,height:0,startX:Te.x,startY:Te.y,x:Ne,y:Me}}),ke||(Z.stopPropagation(),Z.preventDefault())};function I(Z,se){const{userSelectionRect:me}=E.getState();if(!me)return;const{transform:ke,nodeLookup:ve,edgeLookup:re,connectionLookup:Ne,triggerNodeChanges:Me,triggerEdgeChanges:Te,defaultEdgeOptions:$e}=E.getState(),st={x:me.startX,y:me.startY},{x:lt,y:at}=eo(st,ke),Ge={startX:st.x,startY:st.y,x:Zmt.id)),ee.current=new Set;const gt=($e==null?void 0:$e.selectable)??!0;for(const mt of te.current){const Pt=Ne.get(mt);if(Pt)for(const{edgeId:ut}of Pt.values()){const Je=re.get(ut);Je&&(Je.selectable??gt)&&ee.current.add(ut)}}if(!Eh(wt,te.current)){const mt=Gi(ve,te.current,!0);Me(mt)}if(!Eh(qt,ee.current)){const mt=Gi(re,ee.current);Te(mt)}E.setState({userSelectionRect:Ge,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!a||!q.current)return;const[Z,se]=jc(C.current,q.current,$);A({x:Z,y:se}).then(me=>{if(!K.current||!me){b.current=requestAnimationFrame(z);return}const{x:ke,y:ve}=C.current;I(ke,ve),b.current=requestAnimationFrame(z)})}const ie=()=>{cancelAnimationFrame(b.current),b.current=0,V.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=Z=>{const{userSelectionRect:se,transform:me,resetSelectedElements:ke}=E.getState();if(!q.current||!se)return;const{x:ve,y:re}=gn(Z.nativeEvent,q.current);C.current={x:ve,y:re};const Ne=eo({x:se.startX,y:se.startY},me);if(!K.current){const Me=r?0:u;if(Math.hypot(ve-Ne.x,re-Ne.y)<=Me)return;ke(),h==null||h(Z)}K.current=!0,V.current||(z(),V.current=!0),I(ve,re)},fe=Z=>{var se,me;if(!F){Z.target===G.current&&E.getState().connection.inProgress&&(ne.current=!0);return}Z.button===0&&((me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),!R&&Z.target===G.current&&E.getState().userSelectionRect&&(W==null||W(Z)),E.setState({userSelectionActive:!1,userSelectionRect:null}),K.current&&(p==null||p(Z),E.setState({nodesSelectionActive:te.current.size>0})),ie())},he=Z=>{var se,me;(me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),ie()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:nt(["react-flow__pane",{draggable:pe,dragging:N,selection:t}]),onClick:F?void 0:Ku(W,G),onContextMenu:Ku(U,G),onWheel:Ku(M,G),onPointerEnter:F?void 0:m,onPointerMove:F?oe:_,onPointerUp:fe,onPointerCancel:F?he:void 0,onPointerDownCapture:F?H:void 0,onClickCapture:F?D:void 0,onPointerLeave:k,ref:G,style:ia,children:[j,d.jsx(K_,{})]})}function pc({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),y=h.get(t);if(!y){p==null||p("012",mn.error012(t));return}r.setState({nodesSelectionActive:!1}),y.selected?(o||y.selected&&c)&&(u({nodes:[y],edges:[]}),requestAnimationFrame(()=>{var x;return(x=s==null?void 0:s.current)==null?void 0:x.blur()})):a([t])}function Ug({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ye(),[p,y]=L.useState(!1),x=L.useRef();return L.useEffect(()=>{if(!r)return x.current=z1({getStoreItems:()=>h.getState(),onNodeMouseDown:v=>{pc({id:v,store:h,nodeRef:t})},onDragStart:()=>{y(!0)},onDragStop:()=>{y(!1)}}),()=>{var v;(v=x.current)==null||v.destroy(),x.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!x.current||x.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const J_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Yg(){const t=Ye();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:y,nodeOrigin:x}=t.getState(),v=new Map,m=J_(c),_=a?u[0]:5,k=a?u[1]:5,j=o.direction.x*_*o.factor,b=o.direction.y*k*o.factor;for(const[,E]of y){if(!m(E))continue;let R={x:E.internals.positionAbsolute.x+j,y:E.internals.positionAbsolute.y+b};a&&(R=gs(R,u));const{position:w,positionAbsolute:N}=dg({nodeId:E.id,nextPosition:R,nodeLookup:y,nodeExtent:s,nodeOrigin:x,onError:h});E.position=w,E.internals.positionAbsolute=N,v.set(E.id,E)}p(v)},[])}const Tc=L.createContext(null),eS=Tc.Provider;Tc.Consumer;const Gg=()=>L.useContext(Tc),tS=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Xg=L.createContext(null);function nS({children:t}){const r=De(tS,Qe);return d.jsx(Xg.Provider,{value:r,children:t})}function rS(){const t=L.useContext(Xg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const iS={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},oS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:y}=c;if(!h&&!a)return iS;const x=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:x,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Zi.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:x&&y}};function sS({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:y,onMouseDown:x,onTouchStart:v,...m},_){var V,W;const k=c||null,j=t==="target",b=Ye(),E=Gg(),{connectOnClick:R,noPanClassName:w,rfId:N}=rS(),{connectingFrom:A,connectingTo:$,clickConnecting:F,isPossibleEndHandle:G,connectionInProcess:q,clickConnectionInProcess:te,valid:ee}=De(oS(E,k,t),Qe);E||(W=(V=b.getState()).onError)==null||W.call(V,"010",mn.error010());const ne=U=>{const{defaultEdgeOptions:M,onConnect:D,hasDefaultEdges:H}=b.getState(),I={...M,...U};if(H){const{edges:z,setEdges:ie,onError:oe}=b.getState();ie(D_(I,z,{onError:oe}))}D==null||D(I),h==null||h(I)},K=U=>{if(!E)return;const M=wg(U.nativeEvent);if(a&&(M&&U.button===0||!M)){const D=b.getState();hc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:j,handleId:k,nodeId:E,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...H)=>{var I,z;return(z=(I=b.getState()).onConnectEnd)==null?void 0:z.call(I,...H)},updateConnection:D.updateConnection,onConnect:ne,isValidConnection:o||((...H)=>{var I,z;return((z=(I=b.getState()).isValidConnection)==null?void 0:z.call(I,...H))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}M?x==null||x(U):v==null||v(U)},C=U=>{const{onClickConnectStart:M,onClickConnectEnd:D,connectionClickStartHandle:H,connectionMode:I,isValidConnection:z,lib:ie,rfId:oe,nodeLookup:fe,connection:he}=b.getState();if(!E||!H&&!a)return;if(!H){M==null||M(U.nativeEvent,{nodeId:E,handleId:k,handleType:t}),b.setState({connectionClickStartHandle:{nodeId:E,type:t,id:k}});return}const pe=vg(U.target),Z=o||z,{connection:se,isValid:me}=hc.isValid(U.nativeEvent,{handle:{nodeId:E,id:k,type:t},connectionMode:I,fromNodeId:H.nodeId,fromHandleId:H.id||null,fromType:H.type,isValidConnection:Z,flowId:oe,doc:pe,lib:ie,nodeLookup:fe});me&&se&&ne(se);const ke=structuredClone(he);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,D==null||D(U,ke),b.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":k,"data-nodeid":E,"data-handlepos":r,"data-id":`${N}-${E}-${k}-${t}`,className:nt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",w,y,{source:!j,target:j,connectable:s,connectablestart:a,connectableend:u,clickconnecting:F,connectingfrom:A,connectingto:$,valid:ee,connectionindicator:s&&(!q||G)&&(q||te?u:a)}]),onMouseDown:K,onTouchStart:K,onClick:R?C:void 0,ref:_,...m,children:p})}const no=L.memo(Bg(sS));function lS({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(no,{type:"source",position:o,isConnectable:r})]})}function aS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:s=Se.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(no,{type:"source",position:s,isConnectable:r})]})}function uS(){return null}function cS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const Wl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},ip={input:lS,default:aS,output:cS,group:uS};function dS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const fS=t=>{const{width:r,height:o,x:s,y:a}=ps(t.nodeLookup,{filter:u=>!!u.selected});return{width:pn(r)?r:null,height:pn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function hS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ye(),{width:a,height:u,transformString:c,userSelectionActive:h}=De(fS,Qe),p=Yg(),y=L.useRef(null);L.useEffect(()=>{var _;o||(_=y.current)==null||_.focus({preventScroll:!0})},[o]);const x=!h&&a!==null&&u!==null;if(Ug({nodeRef:y,disabled:!x}),!x)return null;const v=t?_=>{const k=s.getState().nodes.filter(j=>j.selected);t(_,k)}:void 0,m=_=>{Object.prototype.hasOwnProperty.call(Wl,_.key)&&(_.preventDefault(),p({direction:Wl[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:nt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:y,className:"react-flow__nodesselection-rect",onContextMenu:v,tabIndex:o?void 0:-1,onKeyDown:o?void 0:m,style:{width:a,height:u}})})}const op=typeof window<"u"?window:void 0,pS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function qg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:y,selectionOnDrag:x,selectionMode:v,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:j,zoomActivationKeyCode:b,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:N,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:G,autoPanOnSelection:q,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,preventScrolling:C,onSelectionContextMenu:V,noWheelClassName:W,noPanClassName:U,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:H}){const{nodesSelectionActive:I,userSelectionActive:z}=De(pS,Qe),ie=as(y,{target:op}),oe=as(j,{target:op}),fe=oe||G,he=oe||N,pe=x&&fe!==!0,Z=ie||z||pe;return U_({deleteKeyCode:p,multiSelectionKeyCode:k}),d.jsx(X_,{onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:!ie&&fe,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,zoomActivationKeyCode:b,preventScrolling:C,noWheelClassName:W,noPanClassName:U,onViewportChange:D,isControlledViewport:H,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(Z_,{onSelectionStart:m,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:q,isSelecting:!!Z,selectionMode:v,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:pe,children:[t,I&&d.jsx(hS,{onSelectionContextMenu:V,noPanClassName:U,disableKeyboardA11y:M})]})})}qg.displayName="FlowRenderer";const gS=L.memo(qg),mS=t=>r=>t?Nc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function yS(t){return De(L.useCallback(mS(t),[t]),Qe)}const vS=t=>t.updateNodeInternals;function xS(){const t=De(vS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function wS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ye(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),y=L.useRef(r),x=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!x||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[x,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const v=y.current!==r,m=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(v||m||_)&&(y.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function _S({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:y,nodesFocusable:x,resizeObserver:v,noDragClassName:m,noPanClassName:_,disableKeyboardA11y:k,rfId:j,nodeTypes:b,nodeClickDistance:E,onError:R}){const{node:w,internals:N,isParent:A}=De(Z=>{const se=Z.nodeLookup.get(t),me=Z.parentLookup.has(t);return{node:se,internals:se.internals,isParent:me}},Qe);let $=w.type||"default",F=(b==null?void 0:b[$])||ip[$];F===void 0&&(R==null||R("003",mn.error003($)),$="default",F=(b==null?void 0:b.default)||ip.default);const G=!!(w.draggable||h&&typeof w.draggable>"u"),q=!!(w.selectable||p&&typeof w.selectable>"u"),te=!!(w.connectable||y&&typeof w.connectable>"u"),ee=!!(w.focusable||x&&typeof w.focusable>"u"),ne=Ye(),K=mg(w),C=wS({node:w,nodeType:$,hasDimensions:K,resizeObserver:v}),V=Ug({nodeRef:C,disabled:w.hidden||!G,noDragClassName:m,handleSelector:w.dragHandle,nodeId:t,isSelectable:q,nodeClickDistance:E}),W=Yg();if(w.hidden)return null;const U=vn(w),M=dS(w),D=q||G||r||o||s||a,H=o?Z=>o(Z,{...N.userNode}):void 0,I=s?Z=>s(Z,{...N.userNode}):void 0,z=a?Z=>a(Z,{...N.userNode}):void 0,ie=u?Z=>u(Z,{...N.userNode}):void 0,oe=c?Z=>c(Z,{...N.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:se,nodeDragThreshold:me}=ne.getState();q&&(!se||!G||me>0)&&pc({id:t,store:ne,nodeRef:C}),r&&r(Z,{...N.userNode})},he=Z=>{if(!(xg(Z.nativeEvent)||k)){if(sg.includes(Z.key)&&q){const se=Z.key==="Escape";pc({id:t,store:ne,unselect:se,nodeRef:C})}else if(G&&w.selected&&Object.prototype.hasOwnProperty.call(Wl,Z.key)){Z.preventDefault();const{ariaLabelConfig:se}=ne.getState();ne.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),W({direction:Wl[Z.key],factor:Z.shiftKey?4:1})}}},pe=()=>{var Ne;if(k||!((Ne=C.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:Z,width:se,height:me,autoPanOnNodeFocus:ke,setCenter:ve}=ne.getState();if(!ke)return;Nc(new Map([[t,w]]),{x:0,y:0,width:se,height:me},Z,!0).length>0||ve(w.position.x+U.width/2,w.position.y+U.height/2,{zoom:Z[2]})};return d.jsx("div",{className:nt(["react-flow__node",`react-flow__node-${$}`,{[_]:G},w.className,{selected:w.selected,selectable:q,parent:A,draggable:G,dragging:V}]),ref:C,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:K?"visible":"hidden",...w.style,...M},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:H,onMouseMove:I,onMouseLeave:z,onContextMenu:ie,onClick:fe,onDoubleClick:oe,onKeyDown:ee?he:void 0,tabIndex:ee?0:void 0,onFocus:ee?pe:void 0,role:w.ariaRole??(ee?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${Dg}-${j}`,"aria-label":w.ariaLabel,...w.domAttributes,children:d.jsx(eS,{value:t,children:d.jsx(F,{id:t,data:w.data,type:$,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:w.selected??!1,selectable:q,draggable:G,deletable:w.deletable??!0,isConnectable:te,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:V,dragHandle:w.dragHandle,zIndex:N.z,parentId:w.parentId,...U})})})}var SS=L.memo(_S);const kS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Kg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=De(kS,Qe),u=yS(t.onlyRenderVisibleElements),c=xS();return d.jsx("div",{className:"react-flow__nodes",style:ia,children:u.map(h=>d.jsx(SS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Kg.displayName="NodeRenderer";const NS=L.memo(Kg);function jS(t){return De(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&v1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const bS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},ES=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},sp={[os.Arrow]:bS,[os.ArrowClosed]:ES};function CS(t){const r=Ye();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(sp,t)?sp[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",mn.error009(t)),null)},[t])}const MS=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=CS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},Qg=({defaultColor:t,rfId:r})=>{const o=De(u=>u.edges),s=De(u=>u.defaultEdgeOptions),a=L.useMemo(()=>b1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(MS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Qg.displayName="MarkerDefinitions";var PS=L.memo(Qg);function Zg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:y,...x}){const[v,m]=L.useState({x:1,y:0,width:0,height:0}),_=nt(["react-flow__edge-textwrapper",y]),k=L.useRef(null);return L.useEffect(()=>{if(k.current){const j=k.current.getBBox();m({x:j.x,y:j.y,width:j.width,height:j.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-v.width/2} ${r-v.height/2})`,className:_,visibility:v.width?"visible":"hidden",...x,children:[a&&d.jsx("rect",{width:v.width+2*c[0],x:-c[0],y:-c[1],height:v.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:v.height/2,dy:"0.3em",ref:k,style:s,children:o}),p]}):null}Zg.displayName="EdgeText";const IS=L.memo(Zg);function ys({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:y=20,...x}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...x,d:t,fill:"none",className:nt(["react-flow__edge-path",x.className])}),y?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:y,className:"react-flow__edge-interaction"}):null,s&&pn(r)&&pn(o)?d.jsx(IS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function lp({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function Jg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top}){const[c,h]=lp({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,y]=lp({pos:u,x1:s,y1:a,x2:t,y2:r}),[x,v,m,_]=_g({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:y});return[`M${t},${r} C${c},${h} ${p},${y} ${s},${a}`,x,v,m,_]}function em(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})=>{const[R,w,N]=Jg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),A=t.isInternal?void 0:r;return d.jsx(ys,{id:A,path:R,labelX:w,labelY:N,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})})}const RS=em({isInternal:!1}),tm=em({isInternal:!0});RS.displayName="SimpleBezierEdge";tm.displayName="SimpleBezierEdgeInternal";function nm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,sourcePosition:_=Se.Bottom,targetPosition:k=Se.Top,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=Vl({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),$=t.isInternal?void 0:r;return d.jsx(ys,{id:$,path:w,labelX:N,labelY:A,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,markerEnd:j,markerStart:b,interactionWidth:R})})}const rm=nm({isInternal:!1}),im=nm({isInternal:!0});rm.displayName="SmoothStepEdge";im.displayName="SmoothStepEdgeInternal";function om(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(rm,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const TS=om({isInternal:!1}),sm=om({isInternal:!0});TS.displayName="StepEdge";sm.displayName="StepEdgeInternal";function lm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,markerEnd:_,markerStart:k,interactionWidth:j})=>{const[b,E,R]=Ng({sourceX:o,sourceY:s,targetX:a,targetY:u}),w=t.isInternal?void 0:r;return d.jsx(ys,{id:w,path:b,labelX:E,labelY:R,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,markerEnd:_,markerStart:k,interactionWidth:j})})}const LS=lm({isInternal:!1}),am=lm({isInternal:!0});LS.displayName="StraightEdge";am.displayName="StraightEdgeInternal";function um(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=Sg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:E==null?void 0:E.curvature}),$=t.isInternal?void 0:r;return d.jsx(ys,{id:$,path:w,labelX:N,labelY:A,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:R})})}const AS=um({isInternal:!1}),cm=um({isInternal:!0});AS.displayName="BezierEdge";cm.displayName="BezierEdgeInternal";const ap={default:cm,straight:am,step:sm,smoothstep:im,simplebezier:tm},up={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},$S=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,zS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,cp="react-flow__edgeupdater";function dp({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:nt([cp,`${cp}-${h}`]),cx:$S(r,s,t),cy:zS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function DS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:y,onReconnectStart:x,onReconnectEnd:v,setReconnecting:m,setUpdateHover:_}){const k=Ye(),j=(N,A)=>{if(N.button!==0)return;const{autoPanOnConnect:$,domNode:F,connectionMode:G,connectionRadius:q,lib:te,onConnectStart:ee,cancelConnection:ne,nodeLookup:K,rfId:C,panBy:V,updateConnection:W}=k.getState(),U=A.type==="target",M=(I,z)=>{m(!1),v==null||v(I,o,A.type,z)},D=I=>y==null?void 0:y(o,I),H=(I,z)=>{m(!0),x==null||x(N,o,A.type),ee==null||ee(I,z)};hc.onPointerDown(N.nativeEvent,{autoPanOnConnect:$,connectionMode:G,connectionRadius:q,domNode:F,handleId:A.id,nodeId:A.nodeId,nodeLookup:K,isTarget:U,edgeUpdaterType:A.type,lib:te,flowId:C,cancelConnection:ne,panBy:V,isValidConnection:(...I)=>{var z,ie;return((ie=(z=k.getState()).isValidConnection)==null?void 0:ie.call(z,...I))??!0},onConnect:D,onConnectStart:H,onConnectEnd:(...I)=>{var z,ie;return(ie=(z=k.getState()).onConnectEnd)==null?void 0:ie.call(z,...I)},onReconnectEnd:M,updateConnection:W,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:N.currentTarget})},b=N=>j(N,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),E=N=>j(N,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),R=()=>_(!0),w=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(dp,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:b,onMouseEnter:R,onMouseOut:w,type:"source"}),(t===!0||t==="target")&&d.jsx(dp,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:E,onMouseEnter:R,onMouseOut:w,type:"target"})]})}function OS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,reconnectRadius:x,onReconnect:v,onReconnectStart:m,onReconnectEnd:_,rfId:k,edgeTypes:j,noPanClassName:b,onError:E,disableKeyboardA11y:R}){let w=De(ve=>ve.edgeLookup.get(t));const N=De(ve=>ve.defaultEdgeOptions);w=N?{...N,...w}:w;let A=w.type||"default",$=(j==null?void 0:j[A])||ap[A];$===void 0&&(E==null||E("011",mn.error011(A)),A="default",$=(j==null?void 0:j.default)||ap.default);const F=!!(w.focusable||r&&typeof w.focusable>"u"),G=typeof v<"u"&&(w.reconnectable||o&&typeof w.reconnectable>"u"),q=!!(w.selectable||s&&typeof w.selectable>"u"),te=L.useRef(null),[ee,ne]=L.useState(!1),[K,C]=L.useState(!1),V=Ye(),{zIndex:W=w.zIndex,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z}=De(L.useCallback(ve=>{const re=ve.nodeLookup.get(w.source),Ne=ve.nodeLookup.get(w.target);if(!re||!Ne)return up;const Me=j1({id:t,sourceNode:re,targetNode:Ne,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:ve.connectionMode,onError:E}),Te=y1({selected:w.selected,zIndex:w.zIndex,sourceNode:re,targetNode:Ne,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||up,zIndex:Te}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex,E]),Qe),ie=L.useMemo(()=>w.markerStart?`url('#${dc(w.markerStart,k)}')`:void 0,[w.markerStart,k]),oe=L.useMemo(()=>w.markerEnd?`url('#${dc(w.markerEnd,k)}')`:void 0,[w.markerEnd,k]);if(w.hidden||U===null||M===null||D===null||H===null)return null;const fe=ve=>{var Te;const{addSelectedEdges:re,unselectNodesAndEdges:Ne,multiSelectionActive:Me}=V.getState();q&&(V.setState({nodesSelectionActive:!1}),w.selected&&Me?(Ne({nodes:[],edges:[w]}),(Te=te.current)==null||Te.blur()):re([t])),a&&a(ve,w)},he=u?ve=>{u(ve,{...w})}:void 0,pe=c?ve=>{c(ve,{...w})}:void 0,Z=h?ve=>{h(ve,{...w})}:void 0,se=p?ve=>{p(ve,{...w})}:void 0,me=y?ve=>{y(ve,{...w})}:void 0,ke=ve=>{var re;if(!R&&sg.includes(ve.key)&&q){const{unselectNodesAndEdges:Ne,addSelectedEdges:Me}=V.getState();ve.key==="Escape"?((re=te.current)==null||re.blur(),Ne({edges:[w]})):Me([t])}};return d.jsx("svg",{style:{zIndex:W},children:d.jsxs("g",{className:nt(["react-flow__edge",`react-flow__edge-${A}`,w.className,b,{selected:w.selected,animated:w.animated,inactive:!q&&!a,updating:ee,selectable:q}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:Z,onMouseMove:se,onMouseLeave:me,onKeyDown:F?ke:void 0,tabIndex:F?0:void 0,role:w.ariaRole??(F?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":F?`${Og}-${k}`:void 0,ref:te,...w.domAttributes,children:[!K&&d.jsx($,{id:t,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:q,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),G&&d.jsx(DS,{edge:w,isReconnectable:G,reconnectRadius:x,onReconnect:v,onReconnectStart:m,onReconnectEnd:_,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,setUpdateHover:ne,setReconnecting:C})]})})}var FS=L.memo(OS);const HS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function dm({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:y,onEdgeClick:x,reconnectRadius:v,onEdgeDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:j}){const{edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,onError:w}=De(HS,Qe),N=jS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(PS,{defaultColor:t,rfId:o}),N.map(A=>d.jsx(FS,{id:A,edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,onClick:x,reconnectRadius:v,onDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:w,edgeTypes:s,disableKeyboardA11y:j},A))]})}dm.displayName="EdgeRenderer";const BS=L.memo(dm),fp=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function VS({children:t}){const r=Ye(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return Vg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=fp(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:fp(s)},children:t})}function WS(t){const r=ra(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const US=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function YS(t){const r=De(US),o=Ye();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function GS(t){return t.connection.inProgress?{...t.connection,to:ms(t.connection.to,t.transform)}:{...t.connection}}function XS(t){return GS}function qS(t){const r=XS();return De(r,Qe)}const KS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function QS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=De(KS,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:nt(["react-flow__connection",ug(h)]),children:d.jsx(fm,{style:r,type:o,CustomComponent:s,isValid:h})})})}const fm=({style:t,type:r=Lr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:y,toNode:x,toHandle:v,toPosition:m,pointer:_}=qS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:y.x,toY:y.y,fromPosition:p,toPosition:m,connectionStatus:ug(s),toNode:x,toHandle:v,pointer:_});let k="";const j={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:y.x,targetY:y.y,targetPosition:m};switch(r){case Lr.Bezier:[k]=Sg(j);break;case Lr.SimpleBezier:[k]=Jg(j);break;case Lr.Step:[k]=Vl({...j,borderRadius:0});break;case Lr.SmoothStep:[k]=Vl(j);break;default:[k]=Ng(j)}return d.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};fm.displayName="ConnectionLine";const ZS={};function hp(t=ZS){L.useRef(t),Ye(),L.useEffect(()=>{},[t])}function JS(){Ye(),L.useRef(!1),L.useEffect(()=>{},[])}function hm({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:x,onSelectionContextMenu:v,onSelectionStart:m,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:j,connectionLineComponent:b,connectionLineContainerStyle:E,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,deleteKeyCode:G,onlyRenderVisibleElements:q,elementsSelectable:te,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,preventScrolling:V,defaultMarkerColor:W,zoomOnScroll:U,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,zoomOnDoubleClick:z,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneScroll:se,onPaneContextMenu:me,paneClickDistance:ke,nodeClickDistance:ve,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,viewport:ut,onViewportChange:Je,nodesDraggable:An}){return hp(t),hp(r),JS(),WS(o),YS(ut),d.jsx(gS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneContextMenu:me,onPaneScroll:se,paneClickDistance:ke,deleteKeyCode:G,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,elementsSelectable:te,zoomOnScroll:U,zoomOnPinch:M,zoomOnDoubleClick:z,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,onSelectionContextMenu:v,preventScrolling:V,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,onViewportChange:Je,isControlledViewport:!!ut,children:d.jsxs(VS,{children:[d.jsx(BS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,onlyRenderVisibleElements:q,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,defaultMarkerColor:W,noPanClassName:qt,disableKeyboardA11y:gt,rfId:Pt}),d.jsx(QS,{style:j,type:k,component:b,containerStyle:E}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(NS,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:x,nodeClickDistance:ve,onlyRenderVisibleElements:q,noPanClassName:qt,noDragClassName:Ge,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,nodesDraggable:An}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}hm.displayName="GraphView";const ek=L.memo(hm),tk=gg(),pp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:y=2,nodeOrigin:x,nodeExtent:v,zIndexMode:m="basic"}={})=>{const _=new Map,k=new Map,j=new Map,b=new Map,E=s??r??[],R=o??t??[],w=x??[0,0],N=v??rs;Eg(j,b,E);const{nodesInitialized:A}=fc(R,_,k,{nodeOrigin:w,nodeExtent:N,zIndexMode:m});let $=[0,0,1];if(c&&a&&u){const F=ps(_,{filter:ee=>!!((ee.width||ee.initialWidth)&&(ee.height||ee.initialHeight))}),{x:G,y:q,zoom:te}=bc(F,a,u,p,y,(h==null?void 0:h.padding)??.1);$=[G,q,te]}return{rfId:"1",width:a??0,height:u??0,transform:$,nodes:R,nodesInitialized:A,nodeLookup:_,parentLookup:k,edges:E,edgeLookup:b,connectionLookup:j,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:y,translateExtent:rs,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Zi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...ag},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:tk,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:lg,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},nk=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:x,nodeExtent:v,zIndexMode:m})=>p_((_,k)=>{async function j(){const{nodeLookup:b,panZoom:E,fitViewOptions:R,fitViewResolver:w,width:N,height:A,minZoom:$,maxZoom:F}=k();E&&(await c1({nodes:b,width:N,height:A,panZoom:E,minZoom:$,maxZoom:F},R),w==null||w.resolve(!0),_({fitViewResolver:null}))}return{...pp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:x,nodeExtent:v,defaultNodes:o,defaultEdges:s,zIndexMode:m}),setNodes:b=>{const{nodeLookup:E,parentLookup:R,nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,fitViewQueued:$,zIndexMode:F,nodesSelectionActive:G}=k(),{nodesInitialized:q,hasSelectedNodes:te}=fc(b,E,R,{nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:F}),ee=G&&te;$&&q?(j(),_({nodes:b,nodesInitialized:q,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:ee})):_({nodes:b,nodesInitialized:q,nodesSelectionActive:ee})},setEdges:b=>{const{connectionLookup:E,edgeLookup:R}=k();Eg(E,R,b),_({edges:b})},setDefaultNodesAndEdges:(b,E)=>{if(b){const{setNodes:R}=k();R(b),_({hasDefaultNodes:!0})}if(E){const{setEdges:R}=k();R(E),_({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:E,nodeLookup:R,parentLookup:w,domNode:N,nodeOrigin:A,nodeExtent:$,debug:F,fitViewQueued:G,zIndexMode:q}=k(),{changes:te,updatedInternals:ee}=T1(b,R,w,N,A,$,q);ee&&(M1(R,w,{nodeOrigin:A,nodeExtent:$,zIndexMode:q}),G?(j(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(te==null?void 0:te.length)>0&&(F&&console.log("React Flow: trigger node changes",te),E==null||E(te)))},updateNodePositions:(b,E=!1)=>{const R=[];let w=[];const{nodeLookup:N,triggerNodeChanges:A,connection:$,updateConnection:F,onNodesChangeMiddlewareMap:G}=k();for(const[q,te]of b){const ee=N.get(q),ne=!!(ee!=null&&ee.expandParent&&(ee!=null&&ee.parentId)&&(te!=null&&te.position)),K={id:q,type:"position",position:ne?{x:Math.max(0,te.position.x),y:Math.max(0,te.position.y)}:te.position,dragging:E};if(ee&&$.inProgress&&$.fromNode.id===ee.id){const C=mi(ee,$.fromHandle,Se.Left,!0);F({...$,from:C})}ne&&ee.parentId&&R.push({id:q,parentId:ee.parentId,rect:{...te.internals.positionAbsolute,width:te.measured.width??0,height:te.measured.height??0}}),w.push(K)}if(R.length>0){const{parentLookup:q,nodeOrigin:te}=k(),ee=Rc(R,N,q,te);w.push(...ee)}for(const q of G.values())w=q(w);A(w)},triggerNodeChanges:b=>{const{onNodesChange:E,setNodes:R,nodes:w,hasDefaultNodes:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=A_(b,w);R($)}A&&console.log("React Flow: trigger node changes",b),E==null||E(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:E,setEdges:R,edges:w,hasDefaultEdges:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=$_(b,w);R($)}A&&console.log("React Flow: trigger edge changes",b),E==null||E(b)}},addSelectedNodes:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));N($);return}N(Gi(w,new Set([...b]),!0)),A(Gi(R))},addSelectedEdges:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));A($);return}A(Gi(R,new Set([...b]))),N(Gi(w,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:E}={})=>{const{edges:R,nodes:w,nodeLookup:N,triggerNodeChanges:A,triggerEdgeChanges:$}=k(),F=b||w,G=E||R,q=[];for(const ee of F){if(!ee.selected)continue;const ne=N.get(ee.id);ne&&(ne.selected=!1),q.push(ai(ee.id,!1))}const te=[];for(const ee of G)ee.selected&&te.push(ai(ee.id,!1));A(q),$(te)},setMinZoom:b=>{const{panZoom:E,maxZoom:R}=k();E==null||E.setScaleExtent([b,R]),_({minZoom:b})},setMaxZoom:b=>{const{panZoom:E,minZoom:R}=k();E==null||E.setScaleExtent([R,b]),_({maxZoom:b})},setTranslateExtent:b=>{var E;(E=k().panZoom)==null||E.setTranslateExtent(b),_({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:E,triggerNodeChanges:R,triggerEdgeChanges:w,elementsSelectable:N}=k();if(!N)return;const A=E.reduce((F,G)=>G.selected?[...F,ai(G.id,!1)]:F,[]),$=b.reduce((F,G)=>G.selected?[...F,ai(G.id,!1)]:F,[]);R(A),w($)},setNodeExtent:b=>{const{nodes:E,nodeLookup:R,parentLookup:w,nodeOrigin:N,elevateNodesOnSelect:A,nodeExtent:$,zIndexMode:F}=k();b[0][0]===$[0][0]&&b[0][1]===$[0][1]&&b[1][0]===$[1][0]&&b[1][1]===$[1][1]||(fc(E,R,w,{nodeOrigin:N,nodeExtent:b,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:F}),_({nodeExtent:b}))},panBy:b=>{const{transform:E,width:R,height:w,panZoom:N,translateExtent:A}=k();return L1({delta:b,panZoom:N,transform:E,translateExtent:A,width:R,height:w})},setCenter:async(b,E,R)=>{const{width:w,height:N,maxZoom:A,panZoom:$}=k();if(!$)return!1;const F=typeof(R==null?void 0:R.zoom)<"u"?R.zoom:A;return await $.setViewport({x:w/2-b*F,y:N/2-E*F,zoom:F},{duration:R==null?void 0:R.duration,ease:R==null?void 0:R.ease,interpolate:R==null?void 0:R.interpolate}),!0},cancelConnection:()=>{_({connection:{...ag}})},updateConnection:b=>{_({connection:b})},reset:()=>_({...pp()})}},Object.is);function pm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:y,nodeOrigin:x,nodeExtent:v,zIndexMode:m,children:_}){const[k]=L.useState(()=>nk({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:y,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:x,nodeExtent:v,zIndexMode:m}));return d.jsx(g_,{value:k,children:d.jsx(H_,{children:d.jsx(nS,{children:_})})})}function rk({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:y,maxZoom:x,nodeOrigin:v,nodeExtent:m,zIndexMode:_}){return L.useContext(ta)?d.jsx(d.Fragment,{children:t}):d.jsx(pm,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:y,initialMaxZoom:x,nodeOrigin:v,nodeExtent:m,zIndexMode:_,children:t})}const ik={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function ok({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:y,onMove:x,onMoveStart:v,onMoveEnd:m,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,onNodeDragStart:F,onNodeDrag:G,onNodeDragStop:q,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onSelectionChange:K,onSelectionDragStart:C,onSelectionDrag:V,onSelectionDragStop:W,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:H,connectionMode:I,connectionLineType:z=Lr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:Z=!1,selectionMode:se=is.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:ke=ls()?"Meta":"Control",zoomActivationKeyCode:ve=ls()?"Meta":"Control",snapToGrid:re,snapGrid:Ne,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Te,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,nodeOrigin:Ge=Fg,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt=!0,defaultViewport:mt=C_,minZoom:Pt=.5,maxZoom:ut=2,translateExtent:Je=rs,preventScrolling:An=!0,nodeExtent:Ot,defaultMarkerColor:xn="#b1b1b7",zoomOnScroll:oo=!0,zoomOnPinch:$n=!0,panOnScroll:vi=!1,panOnScrollSpeed:or=.5,panOnScrollMode:$r=di.Free,zoomOnDoubleClick:zn=!0,panOnDrag:zr=!0,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn=1,nodeClickDistance:Fn=0,children:_n,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn=10,onNodesChange:Ht,onEdgesChange:Or,noDragClassName:nn="nodrag",noWheelClassName:Fr="nowheel",noPanClassName:yt="nopan",fitView:Hn,fitViewOptions:ur,connectOnClick:so,attributionPosition:It,proOptions:Bn,defaultEdgeOptions:Hr,elevateNodesOnSelect:jn=!0,elevateEdgesOnSelect:Br=!1,disableKeyboardA11y:xi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:lo,autoPanOnSelection:Vr=!0,autoPanSpeed:wi,connectionRadius:cr,isValidConnection:ao,onError:dr,style:Vn,id:bt,nodeDragThreshold:Wr,connectionDragThreshold:Et,viewport:uo,onViewportChange:Ur,width:Yr,height:Wn,colorMode:Un="light",debug:bn,onScroll:Bt,ariaLabelConfig:_i,zIndexMode:Gr="basic",...fr},hr){const Yn=bt||"1",En=R_(Un),co=L.useCallback(pr=>{pr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Bt==null||Bt(pr)},[Bt]);return d.jsx("div",{"data-testid":"rf__wrapper",...fr,onScroll:co,style:{...Vn,...ik},ref:hr,className:nt(["react-flow",a,En]),id:bt,role:"application",children:d.jsxs(rk,{nodes:t,edges:r,width:Yr,height:Wn,fitView:Hn,fitViewOptions:ur,minZoom:Pt,maxZoom:ut,nodeOrigin:Ge,nodeExtent:Ot,zIndexMode:Gr,children:[d.jsx(I_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt,elevateNodesOnSelect:jn,elevateEdgesOnSelect:Br,minZoom:Pt,maxZoom:ut,nodeExtent:Ot,onNodesChange:Ht,onEdgesChange:Or,snapToGrid:re,snapGrid:Ne,connectionMode:I,translateExtent:Je,connectOnClick:so,defaultEdgeOptions:Hr,fitView:Hn,fitViewOptions:ur,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onNodeDragStart:F,onNodeDrag:G,onNodeDragStop:q,onSelectionDrag:V,onSelectionDragStart:C,onSelectionDragStop:W,onMove:x,onMoveStart:v,onMoveEnd:m,noPanClassName:yt,nodeOrigin:Ge,rfId:Yn,autoPanOnConnect:Ve,autoPanOnNodeDrag:lo,autoPanSpeed:wi,onError:dr,connectionRadius:cr,isValidConnection:ao,selectNodesOnDrag:Te,nodeDragThreshold:Wr,connectionDragThreshold:Et,onBeforeDelete:H,debug:bn,ariaLabelConfig:_i,zIndexMode:Gr}),d.jsx(ek,{onInit:y,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,nodeTypes:u,edgeTypes:c,connectionLineType:z,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:Z,selectionMode:se,deleteKeyCode:he,multiSelectionKeyCode:ke,panActivationKeyCode:me,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:mt,translateExtent:Je,minZoom:Pt,maxZoom:ut,preventScrolling:An,zoomOnScroll:oo,zoomOnPinch:$n,zoomOnDoubleClick:zn,panOnScroll:vi,panOnScrollSpeed:or,panOnScrollMode:$r,panOnDrag:zr,autoPanOnSelection:Vr,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn,nodeClickDistance:Fn,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn,defaultMarkerColor:xn,noDragClassName:nn,noWheelClassName:Fr,noPanClassName:yt,rfId:Yn,disableKeyboardA11y:xi,nodeExtent:Ot,viewport:uo,onViewportChange:Ur,nodesDraggable:$e}),d.jsx(E_,{onSelectionChange:K}),_n,d.jsx(S_,{proOptions:Bn,position:It}),d.jsx(__,{rfId:Yn,disableKeyboardA11y:xi})]})})}var sk=Bg(ok);function lk({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:nt(["react-flow__background-pattern",o,s])})}function ak({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:nt(["react-flow__background-pattern","dots",r])})}var Ar;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Ar||(Ar={}));const uk={[Ar.Dots]:1,[Ar.Lines]:1,[Ar.Cross]:6},ck=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function gm({id:t,variant:r=Ar.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:y,patternClassName:x}){const v=L.useRef(null),{transform:m,patternId:_}=De(ck,Qe),k=s||uk[r],j=r===Ar.Dots,b=r===Ar.Cross,E=Array.isArray(o)?o:[o,o],R=[E[0]*m[2]||1,E[1]*m[2]||1],w=k*m[2],N=Array.isArray(u)?u:[u,u],A=b?[w,w]:R,$=[N[0]*m[2]+A[0]/2,N[1]*m[2]+A[1]/2],F=`${_}${t||""}`;return d.jsxs("svg",{className:nt(["react-flow__background",y]),style:{...p,...ia,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:v,"data-testid":"rf__background",children:[d.jsx("pattern",{id:F,x:m[0]%R[0],y:m[1]%R[1],width:R[0],height:R[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:j?d.jsx(ak,{radius:w/2,className:x}):d.jsx(lk,{dimensions:A,lineWidth:a,variant:r,className:x})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${F})`})]})}gm.displayName="Background";const dk=L.memo(gm);function fk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function hk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function pk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 gk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 mk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 bl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:nt(["react-flow__controls-button",r]),...o,children:t})}const yk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function mm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:y,children:x,position:v="bottom-left",orientation:m="vertical","aria-label":_}){const k=Ye(),{isInteractive:j,minZoomReached:b,maxZoomReached:E,ariaLabelConfig:R}=De(yk,Qe),{zoomIn:w,zoomOut:N,fitView:A}=ra(),$=()=>{w(),u==null||u()},F=()=>{N(),c==null||c()},G=()=>{A(a),h==null||h()},q=()=>{k.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),p==null||p(!j)},te=m==="horizontal"?"horizontal":"vertical";return d.jsxs(na,{className:nt(["react-flow__controls",te,y]),position:v,style:t,"data-testid":"rf__controls","aria-label":_??R["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(bl,{onClick:$,className:"react-flow__controls-zoomin",title:R["controls.zoomIn.ariaLabel"],"aria-label":R["controls.zoomIn.ariaLabel"],disabled:E,children:d.jsx(fk,{})}),d.jsx(bl,{onClick:F,className:"react-flow__controls-zoomout",title:R["controls.zoomOut.ariaLabel"],"aria-label":R["controls.zoomOut.ariaLabel"],disabled:b,children:d.jsx(hk,{})})]}),o&&d.jsx(bl,{className:"react-flow__controls-fitview",onClick:G,title:R["controls.fitView.ariaLabel"],"aria-label":R["controls.fitView.ariaLabel"],children:d.jsx(pk,{})}),s&&d.jsx(bl,{className:"react-flow__controls-interactive",onClick:q,title:R["controls.interactive.ariaLabel"],"aria-label":R["controls.interactive.ariaLabel"],children:j?d.jsx(mk,{}):d.jsx(gk,{})}),x]})}mm.displayName="Controls";const vk=L.memo(mm);function xk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:y,borderRadius:x,shapeRendering:v,selected:m,onClick:_}){const{background:k,backgroundColor:j}=u||{},b=c||k||j;return d.jsx("rect",{className:nt(["react-flow__minimap-node",{selected:m},y]),x:r,y:o,rx:x,ry:x,width:s,height:a,style:{fill:b,stroke:h,strokeWidth:p},shapeRendering:v,onClick:_?E=>_(E,t):void 0})}const wk=L.memo(xk),_k=t=>t.nodes.map(r=>r.id),Qu=t=>t instanceof Function?t:()=>t;function Sk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=wk,onClick:c}){const h=De(_k,Qe),p=Qu(r),y=Qu(t),x=Qu(o),v=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(m=>d.jsx(Nk,{id:m,nodeColorFunc:p,nodeStrokeColorFunc:y,nodeClassNameFunc:x,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:v},m))})}function kk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:y,x,y:v,width:m,height:_}=De(k=>{const j=k.nodeLookup.get(t);if(!j)return{node:void 0,x:0,y:0,width:0,height:0};const b=j.internals.userNode,{x:E,y:R}=j.internals.positionAbsolute,{width:w,height:N}=vn(b);return{node:b,x:E,y:R,width:w,height:N}},Qe);return!y||y.hidden||!mg(y)?null:d.jsx(h,{x,y:v,width:m,height:_,style:y.style,selected:!!y.selected,className:s(y),color:r(y),borderRadius:a,strokeColor:o(y),strokeWidth:u,shapeRendering:c,onClick:p,id:y.id})}const Nk=L.memo(kk);var jk=L.memo(Sk);const bk=200,Ek=150,Ck=t=>!t.hidden,Mk=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?hg(ps(t.nodeLookup,{filter:Ck}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},gp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,Pk=(t,r)=>gp(t.viewBB,r.viewBB)&&gp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,Ik="react-flow__minimap-desc";function ym({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:y,maskStrokeColor:x,maskStrokeWidth:v,position:m="bottom-right",onClick:_,onNodeClick:k,pannable:j=!1,zoomable:b=!1,ariaLabel:E,inversePan:R,zoomStep:w=1,offsetScale:N=5}){const A=Ye(),$=L.useRef(null),{boundingRect:F,viewBB:G,rfId:q,panZoom:te,translateExtent:ee,flowWidth:ne,flowHeight:K,ariaLabelConfig:C}=De(Mk,Pk),V=(t==null?void 0:t.width)??bk,W=(t==null?void 0:t.height)??Ek,U=F.width/V,M=F.height/W,D=Math.max(U,M),H=D*V,I=D*W,z=N*D,ie=F.x-(H-F.width)/2-z,oe=F.y-(I-F.height)/2-z,fe=H+z*2,he=I+z*2,pe=`${Ik}-${q}`,Z=L.useRef(0),se=L.useRef();Z.current=D,L.useEffect(()=>{if($.current&&te)return se.current=V1({domNode:$.current,panZoom:te,getTransform:()=>A.getState().transform,getViewScale:()=>Z.current}),()=>{var re;(re=se.current)==null||re.destroy()}},[te]),L.useEffect(()=>{var re;(re=se.current)==null||re.update({translateExtent:ee,width:ne,height:K,inversePan:R,pannable:j,zoomStep:w,zoomable:b})},[j,b,R,w,ee,ne,K]);const me=_?re=>{var Te;const[Ne,Me]=((Te=se.current)==null?void 0:Te.pointer(re))||[0,0];_(re,{x:Ne,y:Me})}:void 0,ke=k?L.useCallback((re,Ne)=>{const Me=A.getState().nodeLookup.get(Ne).internals.userNode;k(re,Me)},[]):void 0,ve=E??C["minimap.ariaLabel"];return d.jsx(na,{position:m,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof y=="string"?y:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof v=="number"?v*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:nt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:V,height:W,viewBox:`${ie} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:$,onClick:me,children:[ve&&d.jsx("title",{id:pe,children:ve}),d.jsx(jk,{onClick:ke,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-z},${oe-z}h${fe+z*2}v${he+z*2}h${-fe-z*2}z + M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}ym.displayName="MiniMap";const Rk=L.memo(ym),Tk=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Lk={[to.Line]:"right",[to.Handle]:"bottom-right"};function Ak({nodeId:t,position:r,variant:o=to.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:y=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:v=!1,resizeDirection:m,autoScale:_=!0,shouldResize:k,onResizeStart:j,onResize:b,onResizeEnd:E}){const R=Gg(),w=typeof t=="string"?t:R,N=Ye(),A=L.useRef(null),$=o===to.Handle,F=De(L.useCallback(Tk($&&_),[$,_]),Qe),G=L.useRef(null),q=r??Lk[o];L.useEffect(()=>{if(!(!A.current||!w))return G.current||(G.current=n_({domNode:A.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,domNode:W}=N.getState();return{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,paneDomNode:W}},onChange:(ee,ne)=>{const{triggerNodeChanges:K,nodeLookup:C,parentLookup:V,nodeOrigin:W}=N.getState(),U=[],M={x:ee.x,y:ee.y},D=C.get(w);if(D&&D.expandParent&&D.parentId){const H=D.origin??W,I=ee.width??D.measured.width??0,z=ee.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:I,height:z,...yg({x:ee.x??D.position.x,y:ee.y??D.position.y},{width:I,height:z},D.parentId,C,H)}},oe=Rc([ie],C,V,W);U.push(...oe),M.x=ee.x?Math.max(H[0]*I,ee.x):void 0,M.y=ee.y?Math.max(H[1]*z,ee.y):void 0}if(M.x!==void 0&&M.y!==void 0){const H={id:w,type:"position",position:{...M}};U.push(H)}if(ee.width!==void 0&&ee.height!==void 0){const I={id:w,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:ee.width,height:ee.height}};U.push(I)}for(const H of ne){const I={...H,type:"position"};U.push(I)}K(U)},onEnd:({width:ee,height:ne})=>{const K={id:w,type:"dimensions",resizing:!1,dimensions:{width:ee,height:ne}};N.getState().triggerNodeChanges([K])}})),G.current.update({controlPosition:q,boundaries:{minWidth:h,minHeight:p,maxWidth:y,maxHeight:x},keepAspectRatio:v,resizeDirection:m,onResizeStart:j,onResize:b,onResizeEnd:E,shouldResize:k}),()=>{var ee;(ee=G.current)==null||ee.destroy()}},[q,h,p,y,x,v,j,b,E,k]);const te=q.split("-");return d.jsx("div",{className:nt(["react-flow__resize-control","nodrag",...te,o,s]),ref:A,style:{...a,scale:F,...c&&{[$?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Ak);const $k={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function oa(t){return $k[t]??8}const us=208,ro=64,gc=88,zk=28,Dk=8;function Ok(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function vm(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const w of t){const N=oa(w.type),A=s.get(N)??[];A.push(w),s.set(N,A)}const u=[...s.keys()].sort((w,N)=>w-N).map(w=>[...s.get(w)??[]].sort((N,A)=>N.name.localeCompare(A.name)||N.id.localeCompare(A.id))),c=new Set(t.map(w=>w.id)),h=new Map,p=new Map;for(const w of t)h.set(w.id,[]),p.set(w.id,[]);for(const w of r)!c.has(w.src)||!c.has(w.dst)||w.src===w.dst||(p.get(w.src).push(w.dst),h.get(w.dst).push(w.src));const y=new Map;u.forEach((w,N)=>{for(const A of w)y.set(A.id,N)});const x=new Map,v=()=>{for(const w of u)w.forEach((N,A)=>x.set(N.id,A))};v();const m=(w,N)=>{const A=w.map(($,F)=>{const G=N($.id).map(te=>x.get(te)).filter(te=>te!==void 0),q=Ok(G);return{n:$,bary:Number.isNaN(q)?F:q,name:$.name,id:$.id}});return A.sort(($,F)=>$.bary-F.bary||$.name.localeCompare(F.name)||$.id.localeCompare(F.id)),A.map($=>$.n)},_=w=>N=>y.get(N)===w;for(let w=0;w(h.get(A)??[]).filter(_(N-1))),v();for(let N=u.length-2;N>=0;N--)u[N]=m(u[N],A=>(p.get(A)??[]).filter(_(N+1))),v()}const k=us+gc,j=ro+zk,b=Math.max(...u.map(w=>w.length),1),E=[];let R=0;for(let w=0;wG.id)),A=new Set((u[w+1]??[]).map(G=>G.id));let $=0;if(A.size)for(const G of r)N.has(G.src)&&A.has(G.dst)&&($+=1);const F=Math.min(48,Math.max(0,($-2)*10));R+=k+F}return u.forEach((w,N)=>{const A=(b-w.length)*j/2;w.forEach(($,F)=>{o.set($.id,{x:E[N]??0,y:A+F*j})})}),o}const Fk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),xm=90,Hk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),mp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Bk=Math.PI*(3-Math.sqrt(5)),wm=220,Vk=26,Wk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function _m(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function UN(t){return mp[t]?mp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Uk(t){return t>=xm?"3d":"2d"}function Yk(t){return t>=xm?"overview":"full"}function Gk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(_m(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Hk.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Gk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function qk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function Kk(t,r,o,s){const a=new Set(t.map(j=>j.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const j of r){if(!a.has(j.src)||!a.has(j.dst))continue;const b=u.get(j.src)??[];b.push({dst:j.dst,id:j.id}),u.set(j.src,b);const E=c.get(j.dst)??[];E.push({src:j.src,id:j.id}),c.set(j.dst,E)}const h=new Set(t.filter(j=>Fk.has(j.type)).map(j=>j.id)),p=h.size?h:a,y=new Set,x=[o];for(;x.length;){const j=x.pop();if(!y.has(j)){y.add(j);for(const b of u.get(j)??[])y.has(b.dst)||x.push(b.dst)}}const v=new Set([o]),m=[...p].filter(j=>y.has(j)),_=new Set(m);for(;m.length;){const j=m.pop();v.add(j);for(const b of c.get(j)??[])y.has(b.src)&&!_.has(b.src)&&(_.add(b.src),m.push(b.src))}const k=new Set;for(const j of r)v.has(j.src)&&v.has(j.dst)&&k.add(j.id);return{nodeIds:v,edgeIds:k}}function YN(t){const r=new Map;for(const s of t){const a=oa(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*wm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Vk*Math.sqrt(h+1),y=h*Bk;o.set(c.id,{x:u,y:p*Math.cos(y),z:p*Math.sin(y)})})}return o}function GN(t){const r=new Map;for(const o of t){const s=oa(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*wm,count:s}))}const El=16,Qk=12,Zk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Jk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),yp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},eN={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},vp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],xp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),tN=new Set(["looks_idempotent_on_pk","null","blank"]),nN=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function rN(t){return yp[t]?yp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function iN(t,r,o){const s=new Map(r.map(m=>[m.id,m])),a=[];Zk.has(t.type)&&a.push("sink"),Jk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(m=>m.dst===t.id),h=o.filter(m=>m.src===t.id),p=c.slice(0,El).map(m=>Cl(m,s,m.src)),y=h.slice(0,El).map(m=>Cl(m,s,m.dst)),x=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,v={type:t.type,typeLabel:Zo(io(t.type)),layer:Wk[oa(t.type)]??"other",purpose:rN(t.type),name:t.name,qualifiedName:t.qualified_name,file:x,context:t.context,roles:a,facts:sN(u).filter(m=>!(m.key==="app"&&m.value===t.context)),inputs:p,outputs:y,extraInputs:Math.max(0,c.length-El),extraOutputs:Math.max(0,h.length-El),degreeIn:c.length,degreeOut:h.length,inputKinds:wp(c.map(m=>Cl(m,s,m.src))),outputKinds:wp(h.map(m=>Cl(m,s,m.dst))),pathSummary:""};return v.pathSummary=oN(v),v}function wp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function oN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function Cl(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Zo(io(s.type)):"",edgeType:t.type,edgeLabel:Zo(t.type),inferred:t.confidence<.8}}function sN(t){const r=[...vp.filter(a=>a in t),...Object.keys(t).filter(a=>!vp.includes(a)&&!xp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||xp.has(a)||nN.has(a))continue;s.add(a);const u=lN(a,t[a]);u!=null&&o.push({key:a,label:eN[a]??Zo(a),value:u})}return o}function lN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!tN.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return aN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Qk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function aN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const _p=12,Sp=.2,uN=.8,Ul=20,cN=ro;function dN(t,r,o){const s=o??vm(t,r),a=[...new Set([...s.values()].map(p=>p.x))].sort((p,y)=>p-y),u=[];for(const p of r){const y=s.get(p.src),x=s.get(p.dst);if(!y||!x)continue;const v=y.y+ro/2,m=x.y+ro/2;if(Math.abs(v-m)<_p)continue;const _=y.x+us,k=x.x;if(k-_<_p)continue;const b=Math.min(v,m),E=Math.max(v,m);u.push({id:p.id,y0:b,y1:E,sourceX:_,targetX:k,corridor:`${Math.round(_/8)}`})}const c=new Map;for(const p of u){const y=c.get(p.corridor)??[];y.push(p),c.set(p.corridor,y)}const h=new Map;for(const p of c.values()){const y=[...p].sort((k,j)=>k.y0-j.y0||k.y1-j.y1||k.id.localeCompare(j.id)),x=pN(y),v=Math.max(0,...x.values())+1,m=y[0].sourceX,_=fN(a,m);for(const k of y){const j=gN(x.get(k.id)??0,v),b=m+Ul+Math.max(1,_-2*Ul)*j;h.set(k.id,hN(k.sourceX,k.targetX,b))}}return h}function fN(t,r){const o=r-us,s=t.find(a=>a>o+1);return s===void 0?gc:Math.max(gc,s-r)}function hN(t,r,o){const s=r-t-2*Ul;return s<1?.5:(o-t-Ul)/s}function pN(t){const r=[],o=new Map;for(const s of t){let a=-1;for(let u=0;ur[u]+cN){a=u;break}a<0?(a=r.length,r.push(s.y1)):r[a]=Math.max(r[a],s.y1),o.set(s.id,a)}return o}function gN(t,r){return r<=1?.5:Sp+(uN-Sp)*t/(r-1)}const mN=new Set,yN=L.lazy(()=>b0(()=>import("./LayeredGraph3D-CprfGADt.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),vN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function xN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(no,{type:"target",position:Se.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:io(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Tr(t.name)}),d.jsx(no,{type:"source",position:Se.Right,isConnectable:!1})]})}const wN={load:xN},_N=new Set(["django","react","stitch","arch"]);function SN({id:t,sourceX:r,sourceY:o,targetX:s,targetY:a,sourcePosition:u,targetPosition:c,style:h,markerEnd:p,markerStart:y,label:x,labelStyle:v,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,data:b,interactionWidth:E}){const[R,w,N]=Vl({sourceX:r,sourceY:o,sourcePosition:u,targetX:s,targetY:a,targetPosition:c,borderRadius:8,stepPosition:(b==null?void 0:b.stepPosition)??.5});return d.jsx(ys,{id:t,path:R,labelX:w,labelY:N,label:x,labelStyle:v,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,style:h,markerEnd:p,markerStart:y,interactionWidth:E})}const kN={loadstep:SN};function NN({topologyKey:t}){const{fitView:r}=ra();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function jN(t,r,o=null,s={}){const a=new Map(t.map(y=>[y.id,y])),u=vm(t,r),c=dN(t,r,u),h=t.map(y=>{var m;const x=((m=s.roles)==null?void 0:m[y.id])||[],v=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:y.id,type:"load",position:u.get(y.id)??{x:0,y:0},data:{name:y.name,type:y.type,file:y.file_path,roles:x,dim:v},selected:o===y.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:us,height:ro,style:{width:us,height:ro}}}),p=r.filter(y=>a.has(y.src)&&a.has(y.dst)).map(y=>{const x=vN[y.weight]||"var(--edge-cheap)",v=!!(o&&(y.src===o||y.dst===o));return{id:y.id,source:y.src,target:y.dst,type:"loadstep",animated:y.weight==="critical",data:{stepPosition:c.get(y.id)??.5},style:{stroke:x,strokeWidth:y.weight==="critical"?2.4:1.2,strokeDasharray:y.confidence<.8?"6 4":void 0},markerEnd:{type:os.ArrowClosed,width:14,height:14,color:x},label:v?y.type.replaceAll("_"," "):void 0,labelStyle:v?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:v?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:v?[3,5]:void 0,labelBgBorderRadius:v?4:void 0}});return{rfNodes:h,rfEdges:p}}function bN({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:y}){const x=iN(t,r,o);return L.useEffect(()=>{const v=m=>{m.key==="Escape"&&s()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:x.typeLabel}),d.jsx("div",{className:"inspector-roles",children:x.roles.map(v=>d.jsx("span",{className:"inspector-chip",children:v},v))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Tr(x.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:x.purpose}),x.context?d.jsx("div",{className:"muted",children:Tr(x.context)}):null,x.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Tr(x.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Tr(x.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",x.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[x.degreeIn," in · ",x.degreeOut," out"]}),x.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:x.pathSummary}):null,x.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:x.facts.map(v=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:v.label}),d.jsx("dd",{children:Tr(v.value)})]},v.key))}):null,d.jsx(kp,{title:"Inputs",testId:"graph-inspector-inputs",links:x.inputs,extra:x.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(kp,{title:"Outputs",testId:"graph-inspector-outputs",links:x.outputs,extra:x.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),a?d.jsx("p",{className:"whatif-hint","data-testid":"whatif-hint",children:y?"Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map.":"Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."}):null,d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",title:"Start a hypothetical walk from this node. Does not use Base/Head.",onClick:()=>a(t.id),children:"What if this changes"}):null,y?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",title:"Hide nodes that are not on a path from here to a sink. Does not start a new walk.",onClick:()=>y(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function kp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Zu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:y,repoPath:x,onOpenFile:v,pinnedId:m,onPin:_}){const[k,j]=L.useState(null),b=a!==void 0?a:k,E=re=>{a===void 0&&j(re),u==null||u(re)},[R,w]=L.useState(null),[N,A]=L.useState(null),[$,F]=L.useState(new Set(_N)),[G,q]=L.useState(!1),[te,ee]=L.useState(""),[ne,K]=L.useState(!1),C=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,V=R??Uk(t.length),W=N??Yk(t.length),U=G?b:null,M=L.useMemo(()=>p?Kk(t,r,p):null,[t,r,p]),D=M?t.filter(re=>M.nodeIds.has(re.id)):t,H=M?r.filter(re=>M.edgeIds.has(re.id)):r,I=L.useMemo(()=>Xk(D,H,{detail:W,families:$,focusId:U,neighborhoodOnly:!!U}),[D,H,W,$,U]),z=L.useMemo(()=>`${I.nodes.map(re=>re.id).join("\0")}|${I.edges.map(re=>re.id).join("\0")}`,[I.nodes,I.edges]),ie=b?t.find(re=>re.id===b)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const re=jN(I.nodes,I.edges,b,{roles:c,testOverlay:h});return C&&(re.rfEdges=re.rfEdges.map(Ne=>({...Ne,animated:!1}))),re},[I.nodes,I.edges,b,C,c,h]);L.useEffect(()=>{if(!s)return;const re=t.find(Ne=>Ne.file_path===s);re&&E(re.id)},[s,t]);const he=L.useMemo(()=>qk(t,te),[t,te]),pe=(re,Ne)=>{E(Ne.id)},Z=()=>{E(null),q(!1)},se=ie?d.jsx(bN,{node:ie,nodes:t,edges:r,onClose:Z,onWhatIf:o,onSelect:E,onOpenFile:v,pinned:m===ie.id,onPin:_,onIsolate:y?re=>{y(p===re?null:re)}:void 0}):null,me=re=>{F(Ne=>{const Me=new Set(Ne);if(Me.has(re)){if(Me.size===1)return Ne;Me.delete(re)}else Me.add(re);return Me})},ke=L.useMemo(()=>{const re=new Set;for(const Ne of t)re.add(_m(Ne.type));return re},[t]),ve=t.length-I.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:V==="2d"?"active":"","aria-pressed":V==="2d",onClick:()=>w("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:V==="3d"?"active":"","aria-pressed":V==="3d",onClick:()=>w("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:W==="overview"?"active":"","aria-pressed":W==="overview",onClick:()=>A("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:W==="full"?"active":"","aria-pressed":W==="full",onClick:()=>A("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(re=>ke.has(re)).map(re=>d.jsx("button",{type:"button","data-testid":`graph-family-${re}`,className:$.has(re)?"active":"","aria-pressed":$.has(re),onClick:()=>me(re),children:re},re))}),d.jsx("button",{type:"button",className:G?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!b,onClick:()=>q(re=>!re),children:G?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>y==null?void 0:y(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:te,onChange:re=>{ee(re.target.value),K(!0)},onFocus:()=>K(!0),onBlur:()=>window.setTimeout(()=>K(!1),150)}),ne&&te.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(re=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:Ne=>Ne.preventDefault(),onClick:()=>{E(re.id),ee(""),K(!1)},children:[re.name,d.jsx("span",{className:"muted",children:io(re.type)})]})},re.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[I.nodes.length," nodes · ",I.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:V==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(yN,{nodes:I.nodes,edges:I.edges,selectedId:b,neighborIds:U?I.neighborIds:mN,onSelect:re=>{E(re),re||q(!1)}})}),se]}):d.jsxs(pm,{children:[d.jsxs(sk,{nodes:oe,edges:fe,nodeTypes:wN,edgeTypes:kN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:Z,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(NN,{topologyKey:z}),d.jsx(dk,{}),d.jsx(Rk,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(vk,{})]}),se]})})]})}function Sm(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function EN(t){localStorage.setItem("loadpath.editor",t)}async function CN(t,r,o,s=Sm()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const Np=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],MN=["preset","branch","tag","commit"];function PN(t){var a;if(!(t!=null&&t.git))return[...Np];const r=((a=t.presets)!=null&&a.length?t.presets:Np.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function IN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function RN(t){return MN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function TN(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function jp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[y,x]=L.useState(!1),[v,m]=L.useState(null),[_,k]=L.useState(0),j=L.useMemo(()=>{const N=PN(u);return v===null?N:IN(N,v)},[u,v]),b=L.useMemo(()=>RN(j),[j]);L.useEffect(()=>{y&&c()},[y,c]),L.useEffect(()=>{k(0)},[v,y]);const E=()=>{x(!1),m(null)},R=N=>{r(N.value),E()},w=N=>{if(N.key==="ArrowDown"){if(N.preventDefault(),!y){x(!0);return}k(A=>Math.min(A+1,Math.max(j.length-1,0)))}else if(N.key==="ArrowUp"){if(N.preventDefault(),!y)return;k(A=>Math.max(A-1,0))}else if(N.key==="Enter"&&y){N.preventDefault();const A=j[_];A&&R(A)}else N.key==="Escape"&&y&&(N.preventDefault(),E())};return d.jsxs("div",{className:"combo",ref:p,onBlur:N=>{N.currentTarget.contains(N.relatedTarget)||E()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":y,"aria-controls":h,"aria-autocomplete":"list",onChange:N=>{r(N.target.value),y&&m(N.target.value)},onKeyDown:w}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":y,onMouseDown:N=>N.preventDefault(),onClick:()=>y?E():x(!0),children:d.jsx(k0,{})})]}),y?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:b.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):b.map(N=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:TN(N.group)}),N.items.map(A=>{const $=j.indexOf(A);return d.jsxs("button",{type:"button",role:"option","aria-selected":$===_,className:$===_?"combo-option active":"combo-option","data-testid":`ref-option-${A.group}`,onMouseDown:F=>F.preventDefault(),onMouseEnter:()=>k($),onClick:()=>R(A),children:[d.jsx("span",{className:"combo-label",children:A.label}),A.detail?d.jsx("span",{className:"combo-detail",children:A.detail}):null]},`${A.group}:${A.value}`)})]},N.group))}):null]})}function LN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[y,x]=L.useState(""),[v,m]=L.useState(!1),_=L.useRef(null),k=L.useRef(0),j=async w=>{const N=k.current+1;k.current=N,m(!0);try{const A=await Pe.browse(w);if(k.current!==N)return;a(A),c(A.path),p(A.is_git?A.path:null),x("")}catch(A){if(k.current!==N)return;x(A instanceof Error?A.message:String(A))}finally{k.current===N&&m(!1)}};L.useEffect(()=>{var w,N;j(t),(w=_.current)==null||w.focus(),(N=_.current)==null||N.select()},[t]);const b=h||(s==null?void 0:s.path)||u,E=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",R=w=>{w.key==="Escape"&&(w.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:R,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:w=>w.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:w=>{w.preventDefault(),j(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:w=>c(w.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),y?d.jsx("div",{className:"error",role:"alert",children:y}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":v,children:s!=null&&s.entries.length?s.entries.map(w=>{const N=h===w.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":N,className:N?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":w.path,onClick:()=>p(w.path),onDoubleClick:()=>void j(w.path),children:[d.jsx(Mp,{}),d.jsx("span",{className:"explorer-name",children:w.name}),w.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},w.path)}):d.jsx("div",{className:"muted explorer-empty",children:v?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:b,children:b}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!b,onClick:()=>b&&r(b),children:["Use ",E]})]})]})})}const AN={scan:{start:0,end:20},extract:{start:20,end:88},boot:{start:88,end:94},stitch:{start:94,end:99},skipped:{start:100,end:100},done:{start:100,end:100}},$N=new Set(["scan","extract","boot","stitch"]);function zN(t){const r=t.phase||"";if(!r||r==="idle")return null;const o=AN[r];if(!o)return null;if(o.start===o.end)return o.end;const s=t.total||0;if(s<=0)return o.start;const a=Math.min(1,Math.max(0,(t.done||0)/s));return Math.round(o.start+(o.end-o.start)*a)}function DN(t){return!t.phase||t.phase==="idle"?null:typeof t.percent=="number"&&Number.isFinite(t.percent)?Math.max(0,Math.min(100,Math.round(t.percent))):zN(t)}const Yl=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],ON="obsidian",km="loadpath.theme";function FN(t){return Yl.some(r=>r.id===t)}function Nm(){try{const t=localStorage.getItem(km)||"";if(FN(t))return t}catch{}return ON}function HN(t){var r;return((r=Yl.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function jm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=HN(t);try{localStorage.setItem(km,t)}catch{}}const Ju=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:v0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:x0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:w0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:_0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:S0}];function ec(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function BN(){var fo,ho,Si,po,go,mo,ki,Xr,rn,on;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,y]=L.useState(null),[x,v]=L.useState(null),[m,_]=L.useState(null),[k,j]=L.useState([]),[b,E]=L.useState("review"),[R,w]=L.useState(""),[N,A]=L.useState(""),[$,F]=L.useState(null),[G,q]=L.useState(!1),[te,ee]=L.useState(!1),[ne,K]=L.useState(""),[C,V]=L.useState({}),[W,U]=L.useState([]),[M,D]=L.useState([]),[H,I]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[z,ie]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[oe,fe]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[he,pe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[Z,se]=L.useState(0),[me,ke]=L.useState(""),[ve,re]=L.useState(Nm),[Ne,Me]=L.useState(!1),[Te,$e]=L.useState(!1),[st,lt]=L.useState(!1),[at,Ge]=L.useState(null),[wt,qt]=L.useState(null),[gt,mt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[Pt,ut]=L.useState(null),[Je,An]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[Ot,xn]=L.useState([]),[oo,$n]=L.useState(null),[vi,or]=L.useState(null),[$r,zn]=L.useState(null),[zr,sr]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[lr,Ft]=L.useState(null),[ct,Dn]=L.useState(null),[On,wn]=L.useState(!1),[Fn,_n]=L.useState(!1),rt=L.useRef(o);rt.current=o;const Dr=L.useRef(!1);Dr.current=Te;const _t=L.useRef(""),ar=L.useRef(""),Sn=P=>{re(P),jm(P)},dt=L.useRef(""),He=P=>{dt.current=P,A(P)},kn=P=>{let Y=0,ce=!1;F(0);const je=()=>{Pe.indexProgress(P).then(Ie=>{if(!dt.current)return;if(Ie.phase&&Ie.phase!=="idle"&&Ie.message&&He(Ie.message),$N.has(Ie.phase))ce=!0;else if(!ce)return;const qr=DN(Ie);qr!=null&&(Ie.phase==="scan"&&!Ie.done?Y=qr:Y=Math.max(Y,qr),F(Y))}).catch(()=>{})};je();const Le=window.setInterval(je,250);return()=>{window.clearInterval(Le),F(null)}};L.useEffect(()=>{Pe.settings().then(V).catch(()=>{}).finally(()=>Me(!0)),Pe.repos().then(P=>j(P.repos)).catch(()=>{})},[]);const Nn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const P=o;let Y=!1;return ar.current!==P&&Bn(P),Pe.config(P).then(ce=>{!Y&&rt.current===P&&or(ce)}).catch(()=>{}),Pe.architectureHealth(P).then(ce=>{!Y&&rt.current===P&&zn(ce)}).catch(()=>{}),()=>{Y=!0}},[t,o]);const Ht=P=>{rt.current=P,s(P),localStorage.setItem("loadpath.repo",P),P.trim()!==_t.current&&(_t.current="",Ft(null))},Or=L.useCallback(P=>{const Y=(P??rt.current).trim();return!Y||_t.current===Y?Promise.resolve():(_t.current=Y,Pe.gitRefs(Y).then(ce=>{rt.current.trim()===Y&&Ft(ce)}).catch(()=>{_t.current===Y&&(_t.current="",Ft(null))}))},[]),nn=(P,Y)=>{u(P),h(Y),localStorage.setItem("loadpath.base",P),localStorage.setItem("loadpath.head",Y)},Fr=(P,Y,ce)=>{ie(P),I(Y),localStorage.setItem("loadpath.provider",P),localStorage.setItem("loadpath.scmRepo",Y),ce!==void 0&&(fe(ce),localStorage.setItem("loadpath.prNumber",ce))},yt=P=>{y(P),se(0),Ge(wt&&P.nodes.some(Y=>Y.id===wt)?wt:null),ut(null),$n(null),P.what_if||(v(P),P.id&&localStorage.setItem("loadpath.lastReviewId",P.id))},Hn=async P=>{try{const Y=await Pe.reviews(P);xn(Y.reviews)}catch{xn([])}},ur=async P=>{try{zn(await Pe.architectureHealth(P))}catch{zn(null)}},so=P=>P==="github"?!!C.github_token_set:P==="gitlab"?!!C.gitlab_token_set:!!C.bitbucket_token_set,It=L.useCallback(async(P=z)=>{var Y;try{const ce=await Pe.scmRepos(P);D(ce.repos),(Y=ce.user)!=null&&Y.login&&V(je=>({...je,...P==="github"?{github_user:ce.user.login}:P==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{D([])}},[z]);L.useEffect(()=>{if(t!=="prs")return;let P=!1;return It(z).catch(()=>{P||D([])}),()=>{P=!0}},[t,z,It]),L.useEffect(()=>{if(!ct)return;let P=!1,Y=0;const ce=async()=>{try{const je=await Pe.githubOAuthPoll(ct.flow_id);if(P)return;if(je.status==="complete"){Dn(null);const Le=await Pe.settings();V(Le),K(je.user?`Signed in to GitHub as ${je.user}`:"Signed in to GitHub"),It("github");return}if(je.status==="pending"||je.status==="slow_down"){Y=window.setTimeout(ce,Math.max(je.interval||ct.interval,5)*1e3);return}Dn(null),w(je.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(je){if(P)return;Dn(null),w(je instanceof Error?je.message:String(je))}};return Y=window.setTimeout(ce,Math.max(ct.interval,5)*1e3),()=>{P=!0,window.clearTimeout(Y)}},[ct,It]),L.useEffect(()=>{if(!On)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.bitbucket.connected){wn(!1);const Ie=await Pe.settings();V(Ie),K(Le.bitbucket.user?`Signed in to Bitbucket as ${Le.bitbucket.user}`:"Signed in to Bitbucket"),It("bitbucket");return}if(Date.now()-ce>18e4){wn(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;wn(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[On,It]),L.useEffect(()=>{if(!Fn)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.gitlab.connected){_n(!1);const Ie=await Pe.settings();V(Ie),K(Le.gitlab.user?`Signed in to GitLab as ${Le.gitlab.user}`:"Signed in to GitLab"),It("gitlab");return}if(Date.now()-ce>18e4){_n(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;_n(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[Fn,It]);const Bn=async(P=o,Y=!1)=>{if(!P.trim())return null;ar.current=P,ee(!0);try{const ce=await Pe.architecture(P,!1);rt.current===P&&_(ce);const je=Pe.architectureGraph(P).then(Le=>{rt.current===P&&_(Ie=>Ie&&{...Ie,nodes:Le.nodes,edges:Le.edges,graph_pending:!1})});return je.catch(()=>{}).finally(()=>{rt.current===P&&ee(!1)}),Y&&await je,ce}catch(ce){throw rt.current===P&&ee(!1),ce}},Hr=async P=>{const Y=P.trim();if(!(!Y||Y===rt.current)){if(dt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),K(""),y(null),v(null),_(null),E("architecture"),Ht(Y),q(!0),He(`Loading ${y0(Y)}…`);try{await Promise.all([Bn(Y),Or(Y)])}catch(ce){rt.current===Y&&w(ce instanceof Error?ce.message:String(ce))}finally{rt.current===Y&&(He(""),q(!1))}}},jn=async()=>{if(dt.current||!Nn())return;w(""),K(""),He("Tracing load path…"),Ht(o),nn(a,c);const P=kn(o);try{const Y=await Pe.review(o,a,c,!0,he);yt(Y),E("review"),r("review"),await Pe.repos().then(ce=>j(ce.repos)).catch(()=>{}),await Promise.all([Bn(o),Hn(o),ur(o)])}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{P(),He("")}},Br=async(P=!0)=>{if(dt.current||!Nn())return;w(""),K(""),He(P?"Indexing…":"Full reindex…"),Ht(o);const Y=kn(o);try{await Pe.index(o,P);const ce=await Bn(o);await Pe.repos().then(je=>j(je.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(E("architecture"),r("architecture"))}catch(ce){w(ce instanceof Error?ce.message:String(ce))}finally{Y(),He("")}},xi=async()=>{if(!dt.current&&Nn()){w(""),K(""),He("Detecting layout…"),Ht(o);try{const P=await Pe.init(o);K(P.message),await Pe.repos().then(Y=>j(Y.repos)).catch(()=>{})}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ve=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),K("Copied markdown brief")}catch(P){w(P instanceof Error?P.message:String(P))}},lo=async()=>{if(!dt.current){if(p!=null&&p.what_if){w("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first.");return}if(!(p!=null&&p.markdown)||!H||!oe){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const P=await Pe.postComment(z,H,Number(oe),p.markdown);K(P.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Vr=async()=>{if(!dt.current){w(""),He("Fetching pull requests…");try{const P=await Pe.prs(z,H,"open",o.trim()||void 0);U(P.pull_requests);const Y=M.find(ce=>ce.slug.toLowerCase()===H.trim().toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},wi=async()=>{w("");try{const P=await Pe.githubOAuthStart();Dn(P),ec(P.verification_uri_complete,"github.com","/login/device")}catch(P){w(P instanceof Error?P.message:String(P))}},cr=async()=>{w("");try{const P=await Pe.bitbucketOAuthStart();wn(!0),ec(P.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(P){wn(!1),w(P instanceof Error?P.message:String(P))}},ao=async()=>{w("");try{const P=await Pe.gitlabOAuthStart();_n(!0),ec(P.authorize_url,new URL(P.authorize_url).hostname,"/oauth/authorize")}catch(P){_n(!1),w(P instanceof Error?P.message:String(P))}},dr=async P=>{if(!(dt.current||!o.trim())){w(""),He("Walking what-if path…");try{const Y=await Pe.whatIf(o,P);K(`${Y.title} — ${Y.confidence.level} · ${(Y.sinks||[]).length} sinks`),yt({...Y,markdown:Y.markdown||"",index:Y.index||(p==null?void 0:p.index),workspace:Y.workspace||(p==null?void 0:p.workspace)}),E("review"),r("review")}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},Vn=()=>{if(x){yt(x),E("review"),r("review"),K("Restored the last git-range walk");return}y(null),se(0),Ge(null),ut(null),$n(null),E("architecture"),r("architecture"),K("")},bt=async P=>{var Le;if(dt.current)return;Fr(P.provider,P.repo,String(P.number));const Y=M.find(Ie=>Ie.slug.toLowerCase()===P.repo.toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path),w(""),He(`Fetching ${P.provider} #${P.number}…`);const ce=(Y==null?void 0:Y.local_path)||o,je=ce?kn(ce):()=>{};try{const Ie=await Pe.reviewPr(P.provider,P.repo,P.number,(Y==null?void 0:Y.local_path)||o||void 0);yt(Ie),Ie.pull_request&&typeof Ie.pull_request.repo_path=="string"&&Ht(Ie.pull_request.repo_path),nn(String(Ie.base||P.target_branch),String(Ie.head||P.source_branch)),E("review"),r("review"),typeof((Le=Ie.pull_request)==null?void 0:Le.repo_path)=="string"&&Hn(Ie.pull_request.repo_path)}catch(Ie){nn(P.base_sha||P.target_branch,P.head_sha||P.source_branch),r("review"),w(Ie instanceof Error?Ie.message:String(Ie))}finally{je(),He("")}},Wr=async P=>{w("");try{V(await Pe.oauthDisconnect(P)),z===P&&D([]),K(`Disconnected ${P}`)}catch(Y){w(Y instanceof Error?Y.message:String(Y))}},Et=async P=>{P.preventDefault();const Y=new FormData(P.currentTarget),ce={github_token:String(Y.get("github_token")||""),github_oauth_client_id:String(Y.get("github_oauth_client_id")||""),github_host:String(Y.get("github_host")||""),gitlab_token:String(Y.get("gitlab_token")||""),gitlab_host:String(Y.get("gitlab_host")||""),gitlab_oauth_client_id:String(Y.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(Y.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(Y.get("bitbucket_token")||""),bitbucket_username:String(Y.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(Y.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(Y.get("bitbucket_oauth_client_secret")||""),ai_provider:String(Y.get("ai_provider")||"none"),ai_api_key:String(Y.get("ai_api_key")||""),ai_model:String(Y.get("ai_model")||""),ai_base_url:String(Y.get("ai_base_url")||"")},je=k.length?{...ce,workspaces:k.map(Le=>({path:Le.path,name:Le.name}))}:ce;try{V(await Pe.saveSettings(je)),K("Settings saved on this machine")}catch(Le){w(Le instanceof Error?Le.message:String(Le))}},uo=async()=>{if(!(!p||dt.current)){He("Residual analysis…");try{const P=await Pe.residual(p);ke(P.note)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ur=L.useRef(jn);Ur.current=jn;const Yr=L.useRef(t);Yr.current=t;const Wn=L.useRef(!1);Wn.current=st;const Un=L.useRef(p);Un.current=p;const bn=L.useRef(Z);bn.current=Z,L.useEffect(()=>{const P=localStorage.getItem("loadpath.lastReviewId"),Y=(localStorage.getItem("loadpath.repo")||"").trim();if(!P||!Y){sr(!1);return}let ce=!1;return Pe.getReview(Y,P).then(je=>{ce||(yt(je),nn(je.base||localStorage.getItem("loadpath.base")||"HEAD~1",je.head||localStorage.getItem("loadpath.head")||"HEAD"),Hn(Y),ur(Y))}).catch(()=>{}).finally(()=>{ce||sr(!1)}),()=>{ce=!0}},[]);const Bt=L.useRef("");L.useEffect(()=>{if(!Je||!o.trim())return;let P=!1;const Y=async()=>{try{const je=await Pe.workspaceStatus(o);if(P)return;Bt.current&&je.fingerprint!==Bt.current&&!dt.current&&(pe(!0),localStorage.setItem("loadpath.dirty","1"),Ur.current()),Bt.current=je.fingerprint}catch{}};Y();const ce=window.setInterval(Y,2e3);return()=>{P=!0,window.clearInterval(ce)}},[Je,o]),L.useEffect(()=>{const P=Y=>{var Le;if((Y.metaKey||Y.ctrlKey)&&Y.key.toLowerCase()==="k"){Y.preventDefault(),lt(Ie=>!Ie);return}if(Wn.current){Y.key==="Escape"&&(Y.preventDefault(),lt(!1));return}if(Dr.current){Y.key==="Escape"&&(Y.preventDefault(),$e(!1));return}const ce=Y.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){Y.key==="Escape"&&ce.blur();return}if(Y.key==="Escape"){w(""),K(""),Ge(wt),ut(null);return}if(Y.key==="j"||Y.key==="k"){const Ie=((Le=Un.current)==null?void 0:Le.read_order)||[];if(!Ie.length)return;Y.preventDefault();const Gn=bn.current,qr=Y.key==="j"?Math.min(Ie.length-1,Gn+1):Math.max(0,Gn-1);se(qr);return}const je=Ju.find(Ie=>Ie.shortcut===Y.key);if(je&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey&&r(je.id),(Y.metaKey||Y.ctrlKey)&&Y.key==="Enter"){if(Yr.current==="settings"||Yr.current==="prs"||dt.current)return;Y.preventDefault(),Ur.current()}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[wt]);const _i=async(P,Y)=>{if(!o.trim())return;const ce=await CN(o,P,Y);ce.ok?K(ce.message):w(ce.message)},Gr=async()=>{if(p)try{const P=await Pe.exportHtml(p),Y=URL.createObjectURL(P),ce=document.createElement("a");ce.href=Y,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(Y),K("Saved HTML brief")}catch(P){w(P instanceof Error?P.message:String(P))}},fr=async P=>{if(o.trim()){He("Loading stored review…");try{const Y=await Pe.getReview(o,P);yt(Y),nn(Y.base||a,Y.head||c),E("review"),r("review");const ce=Ot.find(je=>je.id!==P);if(ce)try{$n(await Pe.reviewDiff(o,P,ce.id))}catch{$n(null)}}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},hr={selectedId:at,onSelect:Ge,nodeRoles:p==null?void 0:p.node_roles,testOverlay:gt,isolateSource:Pt,onIsolate:ut,repoPath:o,onOpenFile:_i,pinnedId:wt,onPin:qt},Yn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},...p!=null&&p.what_if?[{id:"exit-whatif",group:"Review",label:x?"Back to git-range walk":"Exit what-if walk",run:Vn}]:[],{id:"index",group:"Run",label:"Index repository",run:()=>void Br(!0)},{id:"watch",group:"Run",label:Je?"Stop watching working tree":"Watch working tree",run:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")}},{id:"tests",group:"Graph",label:gt?"Hide test overlay":"Show test overlay",run:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Gr()},...Ju.map(P=>({id:`tab-${P.id}`,group:"Tabs",label:`Go to ${P.label}`,hint:P.shortcut,run:()=>r(P.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(P=>({id:`node-${P.id}`,group:"Nodes",label:P.name,hint:io(P.type),run:()=>{Ge(P.id),r("graph")}})),...Ot.slice(0,12).map(P=>({id:`hist-${P.id}`,group:"History",label:P.title||P.id,hint:`${P.level||""} ${P.created_at||""}`.trim(),run:()=>void fr(P.id)}))],En=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[b,m,p]),co=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[b,m,p]),pr=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Fe=((p==null?void 0:p.findings)||[]).filter(P=>!P.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Ju.map(P=>{const Y=P.icon,ce=t===P.id;return d.jsxs("button",{type:"button","data-testid":P.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":P.label,onClick:()=>r(P.id),children:[d.jsx(Y,{}),d.jsx("span",{children:P.label})]},P.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:ve,onChange:P=>Sn(P.target.value),children:["dark","light"].map(P=>d.jsx("optgroup",{label:P==="dark"?"Dark":"Light",children:Yl.filter(Y=>Y.group===P).map(Y=>d.jsx("option",{value:Y.id,children:Y.label},Y.id))},P))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:N||pr}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[N?d.jsxs("div",{className:$!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","aria-valuemin":$!=null?0:void 0,"aria-valuemax":$!=null?100:void 0,"aria-valuenow":$??void 0,"data-testid":"progress",children:[d.jsx("i",{style:$!=null?{width:`${$}%`}:void 0}),d.jsx("span",{className:"sr-only",children:N})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[k.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:k.some(P=>P.path===o)?o:"",disabled:!!N,"aria-busy":G,onChange:P=>{P.target.value&&Hr(P.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),k.map(P=>d.jsxs("option",{value:P.path,children:[P.name,P.indexed?` (${P.counts.nodes})`:""]},P.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:P=>{const Y=P.target.value;s(Y),Y.trim()!==_t.current&&(_t.current="",Ft(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>$e(!0),children:d.jsx(Mp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(jp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:P=>nn(P,c),placeholder:"base",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(jp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:P=>nn(a,P),placeholder:"head",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:he?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":he,onClick:()=>{const P=!he;pe(P),localStorage.setItem("loadpath.dirty",P?"1":"0")},children:he?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:Je?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":Je,onClick:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")},children:Je?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.what_if?"what-if · ":"",p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!N,onClick:xi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!N,onClick:()=>Br(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!N,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[R?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:R}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,ne?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:ne}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>K(""),"aria-label":"Dismiss",children:"×"})]}):null,((fo=p==null?void 0:p.index)!=null&&fo.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((ho=p==null?void 0:p.index)==null?void 0:ho.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Si=p==null?void 0:p.index)==null?void 0:Si.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(po=p==null?void 0:p.workspace)!=null&&po.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,p!=null&&p.what_if?d.jsxs("div",{className:"banner whatif","data-testid":"whatif-banner",children:[d.jsxs("span",{children:["Hypothetical walk from"," ",d.jsx("strong",{children:((go=p.node)==null?void 0:go.name)||"this node"}),". Loadpath ignored Base/Head and asked which sinks would feel this node change — not a filter of the current map."]}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-exit-whatif",onClick:Vn,children:x?"Back to git range":"Back to architecture"})]}):null,G?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:N||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":G||te,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(VN,{review:p,findings:Fe,aiNote:me,busy:!!N,tourIndex:Z,onTour:se,onAskAi:uo,onCopy:Ve,onPost:lo,onSelect:Ge,onOpenFile:_i,onExport:Gr,history:Ot,diff:oo,onReopen:fr,onWaiver:(P,Y)=>{o.trim()&&Pe.addWaiver(o,P,Y||void 0,"from review").then(ce=>{or(ce),K(`Waived ${P} in loadpath.yml`)})}}):zr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Zu,{nodes:p.nodes,edges:p.edges,onWhatIf:dr,focusPath:(mo=p.read_order[Z])==null?void 0:mo.path,...hr}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(WN,{architecture:m,busy:!!N,onReindex:()=>Br(!1),onReview:jn,onSelect:Ge,config:vi,health:$r,onSaveConfig:P=>{Pe.saveConfig(o,P).then(Y=>{or(Y),K("Wrote loadpath.yml")})},onWaiver:(P,Y,ce)=>{Pe.addWaiver(o,P,Y,ce).then(je=>{or(je),K(`Waived ${P}`)})}}):G?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(te||m!=null&&m.graph_pending)&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(ki=m==null?void 0:m.counts)!=null&&ki.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Zu,{nodes:m.nodes,edges:m.edges,onWhatIf:dr,...hr,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":b==="review","data-testid":"graph-mode-review",className:b==="review"?"active":"",onClick:()=>E("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":b==="architecture","data-testid":"graph-mode-architecture",className:b==="architecture"?"active":"",onClick:()=>E("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:gt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":gt,onClick:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")},children:"Tests"})]}),En.length?d.jsx(Zu,{nodes:En,edges:co,onWhatIf:dr,...hr}):te||m!=null&&m.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:z,onChange:P=>Fr(P.target.value,H,oe),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:M.length?"Search your repos":"owner/repo",value:H,onChange:P=>Fr(z,P.target.value,oe),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:M.map(P=>d.jsxs("option",{value:P.slug,children:[P.private?"private":"public",P.local_path?" · local":""]},P.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!N||!so(z),onClick:()=>{It(z)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!N,onClick:Vr,children:"List PRs"})]}),M.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[M.length," ",z," repositor",M.length===1?"y":"ies",z==="github"&&C.github_user?` · @${String(C.github_user)}`:"",z==="gitlab"&&C.gitlab_user?` · @${String(C.gitlab_user)}`:"",z==="bitbucket"&&C.bitbucket_user?` · ${String(C.bitbucket_user)}`:""]}):null,W.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):W.map(P=>{var Y;return d.jsxs("article",{className:"pr","data-testid":`pr-${P.number}`,children:[d.jsxs("h3",{children:["#",P.number," ",P.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${P.draft?"":"open"}`,children:P.draft?"draft":P.state}),d.jsx("span",{children:P.author}),d.jsxs("span",{children:[P.source_branch," → ",P.target_branch]}),P.loadpath?d.jsxs("span",{className:`chip ${P.loadpath.level||""}`,"data-testid":`pr-loadpath-${P.number}`,children:[((Y=P.loadpath.level)==null?void 0:Y.toUpperCase())||"REVIEWED",P.loadpath.contract_break&&P.loadpath.contract_break!=="none"?` · ${P.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:P.url,target:"_blank",rel:"noreferrer",children:["Open on ",P.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${P.number}`,onClick:()=>void bt(P),children:"Review this PR"})]})]},`${P.provider}-${P.number}`)})]}),t==="settings"&&Ne&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Et,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Yl.map(P=>d.jsxs("button",{type:"button","data-theme":P.id,className:ve===P.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${P.id}`,onClick:()=>Sn(P.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:P.label}),d.jsx("div",{className:"group",children:P.group})]},P.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:Sm(),onChange:P=>EN(P.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:C.github_token_set?C.github_user?`Signed in as @${String(C.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void Wr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!ct||!C.github_oauth_ready,onClick:()=>void wi(),children:ct?"Waiting for GitHub…":"Sign in with GitHub"})})]}),ct?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:ct.user_code})," at GitHub if the browser did not fill it in."]}):null,C.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(C.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(C.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:C.gitlab_token_set?C.gitlab_user?`Signed in as @${String(C.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void Wr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Fn||!C.gitlab_oauth_ready,onClick:()=>void ao(),children:Fn?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(C.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(C.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:C.bitbucket_token_set?C.bitbucket_user?`Signed in as ${String(C.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void Wr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:On||!C.bitbucket_oauth_ready,onClick:()=>void cr(),children:On?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),C.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(C.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(C.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((Xr=C.ai)==null?void 0:Xr.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((rn=C.ai)==null?void 0:rn.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((on=C.ai)==null?void 0:on.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(p0,{open:st,actions:Yn,onClose:()=>lt(!1)}),Te?d.jsx(LN,{initialPath:o,onClose:()=>$e(!1),onSelect:P=>{if(dt.current){w("Wait for the current job to finish before switching workspace.");return}$e(!1),Hr(P)}}):null]})}function VN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:y,onOpenFile:x,onExport:v,history:m,diff:_,onReopen:k,onWaiver:j}){var E,R,w,N,A,$,F,G,q,te,ee,ne,K,C,V,W,U;const b=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),b.length?d.jsx("ul",{className:"reasons",children:b.map(M=>d.jsx("li",{children:M},M))}):null,t.what_if?d.jsx("span",{className:"chip whatif","data-testid":"whatif-chip",children:"what-if"}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Zo(M)},M)),(E=t.contract_break)!=null&&E.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&y(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>j(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(R=t.workspace)!=null&&R.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>x(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&y(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(bm,{cards:t.deepening}),(N=(w=t.contract_break)==null?void 0:w.reasons)!=null&&N.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),($=(A=t.contract_break.sides)==null?void 0:A.rows)!=null&&$.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(F=t.auth)!=null&&F.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(G=t.suggested_tests)==null?void 0:G.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(q=t.trend)!=null&&q.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",tc(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),m.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:m.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,m.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>k(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?tc(M.created_at):""})]},M.id))]}):null,(ee=(te=t.evolution)==null?void 0:te.notes)!=null&&ee.length||(K=(ne=t.evolution)==null?void 0:ne.hotspots)!=null&&K.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((C=t.evolution)==null?void 0:C.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((V=t.evolution)==null?void 0:V.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:v,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",disabled:s||!!t.what_if,title:t.what_if?"Hypothetical walks are not posted to a pull request":void 0,onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(W=t.codeowners_reviewers)!=null&&W.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function WN({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var x;const y=t.findings.filter(v=>!v.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${tc(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(v=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:v.name})," — ",(v.django_apps||[]).join(", ")||"no apps"," ·"," ",(v.owners||[]).join(", ")||"unowned"]},v.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(v=>d.jsx("div",{className:"muted",children:v},v))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:y.length})]}),y.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):y.map(v=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>v.node_id&&a(v.node_id),children:[d.jsx("span",{className:`chip ${v.severity}`,children:v.severity}),v.message]})},v.rule+v.message))]}),d.jsx(bm,{cards:t.deepening}),(x=c==null?void 0:c.points)!=null&&x.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(v=>d.jsx("i",{className:v.level||"",title:`${v.level} · ${v.findings} findings`,style:{height:`${8+Math.min(24,(v.findings||0)*4)}px`}},v.id||v.created_at))}),Object.entries(c.contexts).map(([v,m])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:v})," — last ",((_=m[m.length-1])==null?void 0:_.findings)??0," findings"]},v)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(g0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((v,m)=>m[1]-v[1]).slice(0,12).map(([v,m])=>d.jsxs("tr",{children:[d.jsx("td",{children:io(v)}),d.jsx("td",{children:m})]},v))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function bm({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:m0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}jm(Nm());d0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(BN,{})}));export{Wk as L,GN as a,UN as c,d as j,YN as l,L as r,io as t}; diff --git a/src/loadpath/static/index.html b/src/loadpath/static/index.html index 0e95751..877b685 100644 --- a/src/loadpath/static/index.html +++ b/src/loadpath/static/index.html @@ -17,7 +17,7 @@ - + diff --git a/tests/e2e/test_ui_flows.py b/tests/e2e/test_ui_flows.py index 9027068..7f08295 100644 --- a/tests/e2e/test_ui_flows.py +++ b/tests/e2e/test_ui_flows.py @@ -576,9 +576,14 @@ def test_ui_architecture_edges_use_distinct_verticals(live_app, browser_page): const segs = []; for (const p of document.querySelectorAll('.react-flow__edge-path')) { const pts = pointsOf(p.getAttribute('d') || ''); + if (pts.length < 2) continue; + const sx = pts[0].x; + const tx = pts[pts.length - 1].x; + if (tx <= sx + 8) continue; for (let i = 0; i + 1 < pts.length; i++) { const a = pts[i]; const b = pts[i + 1]; + if (a.x <= sx + 8 || a.x >= tx - 8) continue; if (Math.abs(a.x - b.x) < 1 && Math.abs(a.y - b.y) > 16) { segs.push({ x: Math.round(a.x), y0: Math.min(a.y, b.y), y1: Math.max(a.y, b.y) }); } diff --git a/ui/src/graphEdges.test.ts b/ui/src/graphEdges.test.ts index 4f68e1f..7c3715a 100644 --- a/ui/src/graphEdges.test.ts +++ b/ui/src/graphEdges.test.ts @@ -92,11 +92,10 @@ describe("assignEdgeStepPositions", () => { const edges = [edge("r1", "v1"), edge("r2", "u")]; const steps = assignEdgeStepPositions(nodes, edges, pos); const srcX = 208; - const nextCol = 296; - const skipCol = 592; - const xNext = srcX + (nextCol - srcX) * (steps.get("r2->u") ?? 0); - const xSkip = srcX + (skipCol - srcX) * (steps.get("r1->v1") ?? 0); - expect(Math.abs(xNext - xSkip)).toBeGreaterThan(40); + const laneX = (dst: number, step: number) => srcX + 20 + (dst - srcX - 40) * step; + const xNext = laneX(296, steps.get("r2->u") ?? 0); + const xSkip = laneX(592, steps.get("r1->v1") ?? 0); + expect(Math.abs(xNext - xSkip)).toBeGreaterThan(20); }); it("bends skip-column edges in the first gap so they do not sit on the next column", () => { @@ -113,10 +112,31 @@ describe("assignEdgeStepPositions", () => { const steps = assignEdgeStepPositions(nodes, [edge("r", "v")], pos); const step = steps.get("r->v") ?? 0.5; const srcX = 208; - const laneX = srcX + (592 - srcX) * step; + const laneX = srcX + 20 + (592 - srcX - 40) * step; expect(laneX).toBeLessThan(296); }); + it("gives two skip-column edges from one node distinct first-gap verticals", () => { + const nodes = [ + node("v", "django.view"), + node("c", "django.cache_key"), + node("f", "django.feature_flag"), + node("s", "django.serializer"), + ]; + const pos = new Map([ + ["v", { x: 0, y: 184 }], + ["s", { x: 296, y: 184 }], + ["c", { x: 592, y: 0 }], + ["f", { x: 592, y: 92 }], + ]); + const steps = assignEdgeStepPositions(nodes, [edge("v", "c"), edge("v", "f")], pos); + const srcX = 208; + const laneX = (dst: number, step: number) => srcX + 20 + (dst - srcX - 40) * step; + const xc = laneX(592, steps.get("v->c") ?? 0.5); + const xf = laneX(592, steps.get("v->f") ?? 0.5); + expect(Math.abs(xc - xf)).toBeGreaterThan(20); + }); + it("spreads lanes between 0.2 and 0.8", () => { expect(stepForLane(0, 1)).toBe(0.5); expect(stepForLane(0, 2)).toBe(0.2); diff --git a/ui/src/graphEdges.ts b/ui/src/graphEdges.ts index f06d07a..283d8b3 100644 --- a/ui/src/graphEdges.ts +++ b/ui/src/graphEdges.ts @@ -10,6 +10,8 @@ import { const HORIZONTAL_EPS = 12; const STEP_LO = 0.2; const STEP_HI = 0.8; +/** Matches @xyflow/react getSmoothStepPath default handle offset. */ +const STEP_OFFSET = 20; /** Adjacent stacked steps sit ~one node apart; reuse a vertical only beyond that. */ const CLEARANCE = GRAPH_NODE_HEIGHT; @@ -70,13 +72,8 @@ export function assignEdgeStepPositions( const gutter = gapAfter(colXs, sourceX); for (const span of sorted) { const t = stepForLane(laneOf.get(span.id) ?? 0, laneCount); - const denom = span.targetX - span.sourceX; - if (Math.abs(denom - gutter) < 0.5) { - steps.set(span.id, t); - continue; - } - const laneX = span.sourceX + gutter * t; - steps.set(span.id, Math.min(0.92, Math.max(0.08, (laneX - span.sourceX) / denom))); + const laneX = sourceX + STEP_OFFSET + Math.max(1, gutter - 2 * STEP_OFFSET) * t; + steps.set(span.id, stepForLaneX(span.sourceX, span.targetX, laneX)); } } return steps; @@ -89,6 +86,13 @@ function gapAfter(colXs: number[], sourceX: number): number { return Math.max(GRAPH_COL_GAP, next - sourceX); } +/** Invert getSmoothStepPath: vertical sits at sourceX + offset + (dx - 2*offset) * step. */ +function stepForLaneX(sourceX: number, targetX: number, laneX: number): number { + const inner = targetX - sourceX - 2 * STEP_OFFSET; + if (inner < 1) return 0.5; + return (laneX - sourceX - STEP_OFFSET) / inner; +} + /** First-fit coloring: two verticals share an x only when their y ranges stay apart. */ function lanesFor(spans: Span[]): Map { const laneEnds: number[] = []; From 13c8dbdab7cd7de2e2f16197b1c58fd9b414c399 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 16 Aug 2026 01:19:06 +0000 Subject: [PATCH 15/16] Fix dual-review findings before merge. Keep CODEOWNERS paths under .github, ignore .loadpath in the watch fingerprint, sort architecture-health series newest-last, persist empty rules, write waivers without exploding loadpath.yml, and require loopback for config/open writes. Watch reviews now use the dirty ref, failed graph loads clear the placeholder, architecture mode drops review isolate, reopen diffs the previous walk, and the palette cannot run an off-screen action. Co-authored-by: zord.lack.net --- src/loadpath/config.py | 8 +-- src/loadpath/review/codeowners.py | 2 +- src/loadpath/review/experience.py | 6 +- src/loadpath/server/app.py | 11 ++-- ...CprfGADt.js => LayeredGraph3D-BkYe4qmj.js} | 2 +- src/loadpath/static/assets/index-C5rEgtEu.js | 62 ------------------- src/loadpath/static/assets/index-cvBsmXkd.js | 62 +++++++++++++++++++ src/loadpath/static/index.html | 2 +- src/loadpath/workspace.py | 7 ++- tests/unit/test_experience.py | 61 +++++++++++++++++- tests/unit/test_scm_oauth.py | 15 +++++ ui/src/App.tsx | 33 +++++++--- ui/src/CommandPalette.tsx | 9 +-- ui/src/graphEdges.test.ts | 12 ++++ ui/src/graphEdges.ts | 2 +- ui/src/types.ts | 2 +- 16 files changed, 206 insertions(+), 90 deletions(-) rename src/loadpath/static/assets/{LayeredGraph3D-CprfGADt.js => LayeredGraph3D-BkYe4qmj.js} (99%) delete mode 100644 src/loadpath/static/assets/index-C5rEgtEu.js create mode 100644 src/loadpath/static/assets/index-cvBsmXkd.js diff --git a/src/loadpath/config.py b/src/loadpath/config.py index f57ec0b..aa5e509 100644 --- a/src/loadpath/config.py +++ b/src/loadpath/config.py @@ -129,7 +129,7 @@ def load_config(repo_root: Path, config_path: Path | None = None) -> LoadpathCon contexts=contexts, django_layers=list(layers.get("django") or ["route", "view", "service", "model"]), react_layers=list(layers.get("react") or ["route", "page", "feature", "shared"]), - rules=list(raw.get("rules") or DEFAULT_RULES), + rules=list(DEFAULT_RULES if raw.get("rules") is None else raw.get("rules") or []), waivers=waivers, django_root=raw.get("django_root", "backend"), react_root=raw.get("react_root", "frontend/src"), @@ -245,10 +245,8 @@ def write_config(repo_root: Path, document: dict[str, Any]) -> dict[str, Any]: def add_waiver(repo_root: Path, rule: str, node: str | None = None, reason: str = "") -> dict[str, Any]: cfg = load_config(repo_root) - doc = config_document(cfg) - waivers = list(doc.get("waivers") or []) + waivers = [{"rule": w.rule, "node": w.node, "reason": w.reason} for w in cfg.waivers] entry = {"rule": rule, "node": node, "reason": reason} if not any(w.get("rule") == rule and w.get("node") == node for w in waivers): waivers.append(entry) - doc["waivers"] = waivers - return write_config(repo_root, doc) + return write_config(repo_root, {"waivers": waivers}) diff --git a/src/loadpath/review/codeowners.py b/src/loadpath/review/codeowners.py index 790a965..75d4030 100644 --- a/src/loadpath/review/codeowners.py +++ b/src/loadpath/review/codeowners.py @@ -71,7 +71,7 @@ def _glob_to_re(pattern: str) -> re.Pattern[str]: def owners_for_path(path: str, rules: list[tuple[str, list[str]]]) -> list[str]: - normalized = path.replace("\\", "/").lstrip("./") + normalized = path.replace("\\", "/").removeprefix("./").lstrip("/") matched: list[str] = [] for pattern, owners in rules: try: diff --git a/src/loadpath/review/experience.py b/src/loadpath/review/experience.py index 0deea8d..ab0d584 100644 --- a/src/loadpath/review/experience.py +++ b/src/loadpath/review/experience.py @@ -468,9 +468,13 @@ def architecture_health(reviews: list[dict[str, Any]]) -> dict[str, Any]: {"created_at": point["created_at"], "findings": count, "level": point["level"]} ) points.sort(key=lambda p: p.get("created_at") or "") + contexts = {} + for name, series in sorted(context_series.items()): + series.sort(key=lambda p: p.get("created_at") or "") + contexts[name] = series[-24:] return { "points": points[-24:], - "contexts": {k: v[-24:] for k, v in sorted(context_series.items())}, + "contexts": contexts, } diff --git a/src/loadpath/server/app.py b/src/loadpath/server/app.py index 36f660c..534ce50 100644 --- a/src/loadpath/server/app.py +++ b/src/loadpath/server/app.py @@ -236,7 +236,7 @@ def _call_scm(provider: str, fn): def require_loopback(request: Request) -> None: if not is_loopback_request(request.headers.get("host") or "", request.headers.get("origin") or ""): - raise HTTPException(403, "SCM sign-in and repo listing are only available from the local Loadpath UI") + raise HTTPException(403, "This action is only available from the local Loadpath UI") def _attach_loadpath(listed: list[dict[str, Any]], repo_path: str | None) -> list[dict[str, Any]]: @@ -552,14 +552,16 @@ def api_config(repo_path: str) -> dict[str, Any]: return config_document(load_config(root)) @app.put("/api/config") - def api_config_put(body: ConfigUpdate) -> dict[str, Any]: + def api_config_put(request: Request, body: ConfigUpdate) -> dict[str, Any]: + require_loopback(request) root = require_repo_path(body.repo_path) document = body.model_dump(exclude_unset=True) document.pop("repo_path", None) return write_config(root, document) @app.post("/api/config/waiver") - def api_config_waiver(body: WaiverRequest) -> dict[str, Any]: + def api_config_waiver(request: Request, body: WaiverRequest) -> dict[str, Any]: + require_loopback(request) root = require_repo_path(body.repo_path) if not body.rule.strip(): raise HTTPException(400, "rule is required") @@ -605,7 +607,8 @@ def api_workspace_status(repo_path: str) -> dict[str, Any]: return workspace_status(root) @app.post("/api/open") - def api_open(body: OpenEditorRequest) -> dict[str, Any]: + def api_open(request: Request, body: OpenEditorRequest) -> dict[str, Any]: + require_loopback(request) root = require_repo_path(body.repo_path) try: return open_in_editor(root, body.path, body.line, body.editor) diff --git a/src/loadpath/static/assets/LayeredGraph3D-CprfGADt.js b/src/loadpath/static/assets/LayeredGraph3D-BkYe4qmj.js similarity index 99% rename from src/loadpath/static/assets/LayeredGraph3D-CprfGADt.js rename to src/loadpath/static/assets/LayeredGraph3D-BkYe4qmj.js index 69bacbd..a77784c 100644 --- a/src/loadpath/static/assets/LayeredGraph3D-CprfGADt.js +++ b/src/loadpath/static/assets/LayeredGraph3D-BkYe4qmj.js @@ -1,4 +1,4 @@ -import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-C5rEgtEu.js";/** +import{r as un,l as tc,c as nc,a as ic,L as sc,j as ei,t as rc}from"./index-cvBsmXkd.js";/** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT diff --git a/src/loadpath/static/assets/index-C5rEgtEu.js b/src/loadpath/static/assets/index-C5rEgtEu.js deleted file mode 100644 index 705298e..0000000 --- a/src/loadpath/static/assets/index-C5rEgtEu.js +++ /dev/null @@ -1,62 +0,0 @@ -(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function bp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Lu={exports:{}},Uo={},Au={exports:{}},Re={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Qf;function r0(){if(Qf)return Re;Qf=1;var t=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),v=Symbol.iterator;function m(I){return I===null||typeof I!="object"?null:(I=v&&I[v]||I["@@iterator"],typeof I=="function"?I:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,j={};function b(I,z,ie){this.props=I,this.context=z,this.refs=j,this.updater=ie||_}b.prototype.isReactComponent={},b.prototype.setState=function(I,z){if(typeof I!="object"&&typeof I!="function"&&I!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,I,z,"setState")},b.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function E(){}E.prototype=b.prototype;function R(I,z,ie){this.props=I,this.context=z,this.refs=j,this.updater=ie||_}var w=R.prototype=new E;w.constructor=R,k(w,b.prototype),w.isPureReactComponent=!0;var N=Array.isArray,A=Object.prototype.hasOwnProperty,$={current:null},F={key:!0,ref:!0,__self:!0,__source:!0};function G(I,z,ie){var oe,fe={},he=null,pe=null;if(z!=null)for(oe in z.ref!==void 0&&(pe=z.ref),z.key!==void 0&&(he=""+z.key),z)A.call(z,oe)&&!F.hasOwnProperty(oe)&&(fe[oe]=z[oe]);var Z=arguments.length-2;if(Z===1)fe.children=ie;else if(1>>1,z=M[I];if(0>>1;Ia(fe,H))hea(pe,fe)?(M[I]=pe,M[he]=H,I=he):(M[I]=fe,M[oe]=H,I=oe);else if(hea(pe,H))M[I]=pe,M[he]=H,I=he;else break e}}return D}function a(M,D){var H=M.sortIndex-D.sortIndex;return H!==0?H:M.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,h=c.now();t.unstable_now=function(){return c.now()-h}}var p=[],y=[],x=1,v=null,m=3,_=!1,k=!1,j=!1,b=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(M){for(var D=o(y);D!==null;){if(D.callback===null)s(y);else if(D.startTime<=M)s(y),D.sortIndex=D.expirationTime,r(p,D);else break;D=o(y)}}function N(M){if(j=!1,w(M),!k)if(o(p)!==null)k=!0,W(A);else{var D=o(y);D!==null&&U(N,D.startTime-M)}}function A(M,D){k=!1,j&&(j=!1,E(G),G=-1),_=!0;var H=m;try{for(w(D),v=o(p);v!==null&&(!(v.expirationTime>D)||M&&!ee());){var I=v.callback;if(typeof I=="function"){v.callback=null,m=v.priorityLevel;var z=I(v.expirationTime<=D);D=t.unstable_now(),typeof z=="function"?v.callback=z:v===o(p)&&s(p),w(D)}else s(p);v=o(p)}if(v!==null)var ie=!0;else{var oe=o(y);oe!==null&&U(N,oe.startTime-D),ie=!1}return ie}finally{v=null,m=H,_=!1}}var $=!1,F=null,G=-1,q=5,te=-1;function ee(){return!(t.unstable_now()-teM||125I?(M.sortIndex=H,r(y,M),o(p)===null&&M===o(y)&&(j?(E(G),G=-1):j=!0,U(N,H-I))):(M.sortIndex=z,r(p,M),k||_||(k=!0,W(A))),M},t.unstable_shouldYield=ee,t.unstable_wrapCallback=function(M){var D=m;return function(){var H=m;m=D;try{return M.apply(this,arguments)}finally{m=H}}}})(Du)),Du}var nh;function a0(){return nh||(nh=1,zu.exports=l0()),zu.exports}/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var rh;function u0(){if(rh)return zt;rh=1;var t=cs(),r=a0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,y=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,x={},v={};function m(e){return p.call(v,e)?!0:p.call(x,e)?!1:y.test(e)?v[e]=!0:(x[e]=!0,!1)}function _(e,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function k(e,n,i,l){if(n===null||typeof n>"u"||_(e,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function j(e,n,i,l,f,g,S){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=f,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=g,this.removeEmptyString=S}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){b[e]=new j(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];b[n]=new j(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){b[e]=new j(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){b[e]=new j(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){b[e]=new j(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){b[e]=new j(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){b[e]=new j(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){b[e]=new j(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){b[e]=new j(e,5,!1,e.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function R(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){b[e]=new j(e,1,!1,e.toLowerCase(),null,!1,!1)}),b.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){b[e]=new j(e,1,!1,e.toLowerCase(),null,!0,!0)});function w(e,n,i,l){var f=b.hasOwnProperty(n)?b[n]:null;(f!==null?f.type!==0:l||!(2T||f[S]!==g[T]){var O=` -`+f[S].replace(" at new "," at ");return e.displayName&&O.includes("")&&(O=O.replace("",e.displayName)),O}while(1<=S&&0<=T);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?z(e):""}function fe(e){switch(e.tag){case 5:return z(e.type);case 16:return z("Lazy");case 13:return z("Suspense");case 19:return z("SuspenseList");case 0:case 2:case 15:return e=oe(e.type,!1),e;case 11:return e=oe(e.type.render,!1),e;case 1:return e=oe(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case F:return"Fragment";case $:return"Portal";case q:return"Profiler";case G:return"StrictMode";case K:return"Suspense";case C:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ee:return(e.displayName||"Context")+".Consumer";case te:return(e._context.displayName||"Context")+".Provider";case ne:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case W:n=e._payload,e=e._init;try{return he(e(n))}catch{}}return null}function pe(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===G?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Z(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=se(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function ke(e){e._valueTracker||(e._valueTracker=me(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=se(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function re(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return H({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Me(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Z(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Te(e,n){n=n.checked,n!=null&&w(e,"checked",n,!1)}function $e(e,n){Te(e,n);var i=Z(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?lt(e,n.type,i):n.hasOwnProperty("defaultValue")&<(e,n.type,Z(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function st(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function lt(e,n,i){(n!=="number"||re(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var at=Array.isArray;function Ge(e,n,i,l){if(e=e.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=Je.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ot(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var xn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},oo=["Webkit","ms","Moz","O"];Object.keys(xn).forEach(function(e){oo.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),xn[n]=xn[e]})});function $n(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||xn.hasOwnProperty(e)&&xn[e]?(""+n).trim():n+"px"}function vi(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=$n(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,f):e[i]=f}}var or=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function $r(e,n){if(n){if(or[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function zn(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var zr=null;function sr(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var lr=null,Ft=null,ct=null;function Dn(e){if(e=Po(e)){if(typeof lr!="function")throw Error(o(280));var n=e.stateNode;n&&(n=Rs(n),lr(e.stateNode,e.type,n))}}function On(e){Ft?ct?ct.push(e):ct=[e]:Ft=e}function wn(){if(Ft){var e=Ft,n=ct;if(ct=Ft=null,Dn(e),n)for(e=0;e>>=0,e===0?32:31-(uo(e)/Ur|0)|0}var Wn=64,Un=4194304;function bn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Bt(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,f=e.suspendedLanes,g=e.pingedLanes,S=i&268435455;if(S!==0){var T=S&~f;T!==0?l=bn(T):(g&=S,g!==0&&(l=bn(g)))}else S=i&~f,S!==0?l=bn(S):g!==0&&(l=bn(g));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,g=n&-n,f>=g||f===16&&(g&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function En(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Et(n),e[n]=i}function co(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=_o),Vc=" ",Wc=!1;function Uc(e,n){switch(e){case"keyup":return Zm.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Yc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var bi=!1;function ey(e,n){switch(e){case"compositionend":return Yc(n);case"keypress":return n.which!==32?null:(Wc=!0,Vc);case"textInput":return e=n.data,e===Vc&&Wc?null:e;default:return null}}function ty(e,n){if(bi)return e==="compositionend"||!pa&&Uc(e,n)?(e=zc(),_s=aa=gr=null,bi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Jc(i)}}function td(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?td(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function nd(){for(var e=window,n=re();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=re(e.document)}return n}function ya(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function cy(e){var n=nd(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&td(i.ownerDocument.documentElement,i)){if(l!==null&&ya(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var f=i.textContent.length,g=Math.min(l.start,f);l=l.end===void 0?g:Math.min(l.end,f),!e.extend&&g>l&&(f=l,l=g,g=f),f=ed(i,g);var S=ed(i,l);f&&S&&(e.rangeCount!==1||e.anchorNode!==f.node||e.anchorOffset!==f.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),e.removeAllRanges(),g>l?(e.addRange(n),e.extend(S.node,S.offset)):(n.setEnd(S.node,S.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,Ei=null,va=null,jo=null,xa=!1;function rd(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;xa||Ei==null||Ei!==re(l)||(l=Ei,"selectionStart"in l&&ya(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),jo&&No(jo,l)||(jo=l,l=Ms(va,"onSelect"),0Ri||(e.current=Ia[Ri],Ia[Ri]=null,Ri--)}function Be(e,n){Ri++,Ia[Ri]=e.current,e.current=n}var xr={},St=vr(xr),Rt=vr(!1),Qr=xr;function Ti(e,n){var i=e.type.contextTypes;if(!i)return xr;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in i)f[g]=n[g];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=f),f}function Tt(e){return e=e.childContextTypes,e!=null}function Ts(){Ue(Rt),Ue(St)}function vd(e,n,i){if(St.current!==xr)throw Error(o(168));Be(St,n),Be(Rt,i)}function xd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,pe(e)||"Unknown",f));return H({},i,l)}function Ls(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||xr,Qr=St.current,Be(St,e),Be(Rt,Rt.current),!0}function wd(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=xd(e,n,Qr),l.__reactInternalMemoizedMergedChildContext=e,Ue(Rt),Ue(St),Be(St,e)):Ue(Rt),Be(Rt,i)}var qn=null,As=!1,Ra=!1;function _d(e){qn===null?qn=[e]:qn.push(e)}function Sy(e){As=!0,_d(e)}function wr(){if(!Ra&&qn!==null){Ra=!0;var e=0,n=Fe;try{var i=qn;for(Fe=1;e>=S,f-=S,Kn=1<<32-Et(n)+f|i<Ce?(pt=Ee,Ee=null):pt=Ee.sibling;var Oe=le(X,Ee,Q[Ce],de);if(Oe===null){Ee===null&&(Ee=pt);break}e&&Ee&&Oe.alternate===null&&n(X,Ee),B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe,Ee=pt}if(Ce===Q.length)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;CeCe?(pt=Ee,Ee=null):pt=Ee.sibling;var Mr=le(X,Ee,Oe.value,de);if(Mr===null){Ee===null&&(Ee=pt);break}e&&Ee&&Mr.alternate===null&&n(X,Ee),B=g(Mr,B,Ce),be===null?_e=Mr:be.sibling=Mr,be=Mr,Ee=pt}if(Oe.done)return i(X,Ee),Xe&&Jr(X,Ce),_e;if(Ee===null){for(;!Oe.done;Ce++,Oe=Q.next())Oe=ue(X,Oe.value,de),Oe!==null&&(B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return Xe&&Jr(X,Ce),_e}for(Ee=l(X,Ee);!Oe.done;Ce++,Oe=Q.next())Oe=ge(Ee,X,Ce,Oe.value,de),Oe!==null&&(e&&Oe.alternate!==null&&Ee.delete(Oe.key===null?Ce:Oe.key),B=g(Oe,B,Ce),be===null?_e=Oe:be.sibling=Oe,be=Oe);return e&&Ee.forEach(function(n0){return n(X,n0)}),Xe&&Jr(X,Ce),_e}function et(X,B,Q,de){if(typeof Q=="object"&&Q!==null&&Q.type===F&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case A:e:{for(var _e=Q.key,be=B;be!==null;){if(be.key===_e){if(_e=Q.type,_e===F){if(be.tag===7){i(X,be.sibling),B=f(be,Q.props.children),B.return=X,X=B;break e}}else if(be.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===W&&Ed(_e)===be.type){i(X,be.sibling),B=f(be,Q.props),B.ref=Io(X,be,Q),B.return=X,X=B;break e}i(X,be);break}else n(X,be);be=be.sibling}Q.type===F?(B=li(Q.props.children,X.mode,de,Q.key),B.return=X,X=B):(de=ul(Q.type,Q.key,Q.props,null,X.mode,de),de.ref=Io(X,B,Q),de.return=X,X=de)}return S(X);case $:e:{for(be=Q.key;B!==null;){if(B.key===be)if(B.tag===4&&B.stateNode.containerInfo===Q.containerInfo&&B.stateNode.implementation===Q.implementation){i(X,B.sibling),B=f(B,Q.children||[]),B.return=X,X=B;break e}else{i(X,B);break}else n(X,B);B=B.sibling}B=Mu(Q,X.mode,de),B.return=X,X=B}return S(X);case W:return be=Q._init,et(X,B,be(Q._payload),de)}if(at(Q))return xe(X,B,Q,de);if(D(Q))return we(X,B,Q,de);Os(X,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"?(Q=""+Q,B!==null&&B.tag===6?(i(X,B.sibling),B=f(B,Q),B.return=X,X=B):(i(X,B),B=Cu(Q,X.mode,de),B.return=X,X=B),S(X)):i(X,B)}return et}var zi=Cd(!0),Md=Cd(!1),Fs=vr(null),Hs=null,Di=null,Da=null;function Oa(){Da=Di=Hs=null}function Fa(e){var n=Fs.current;Ue(Fs),e._currentValue=n}function Ha(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function Oi(e,n){Hs=e,Da=Di=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(Lt=!0),e.firstContext=null)}function Zt(e){var n=e._currentValue;if(Da!==e)if(e={context:e,memoizedValue:n,next:null},Di===null){if(Hs===null)throw Error(o(308));Di=e,Hs.dependencies={lanes:0,firstContext:e}}else Di=Di.next=e;return n}var ei=null;function Ba(e){ei===null?ei=[e]:ei.push(e)}function Pd(e,n,i,l){var f=n.interleaved;return f===null?(i.next=i,Ba(n)):(i.next=f.next,f.next=i),n.interleaved=i,Zn(e,l)}function Zn(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var _r=!1;function Va(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Id(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Jn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function Sr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(ze&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,Zn(e,i)}return f=l.interleaved,f===null?(n.next=n,Ba(l)):(n.next=f.next,f.next=n),l.interleaved=n,Zn(e,i)}function Bs(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}function Rd(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var S={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?f=g=S:g=g.next=S,i=i.next}while(i!==null);g===null?f=g=n:g=g.next=n}else f=g=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function Vs(e,n,i,l){var f=e.updateQueue;_r=!1;var g=f.firstBaseUpdate,S=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,J=O.next;O.next=null,S===null?g=J:S.next=J,S=O;var ae=e.alternate;ae!==null&&(ae=ae.updateQueue,T=ae.lastBaseUpdate,T!==S&&(T===null?ae.firstBaseUpdate=J:T.next=J,ae.lastBaseUpdate=O))}if(g!==null){var ue=f.baseState;S=0,ae=J=O=null,T=g;do{var le=T.lane,ge=T.eventTime;if((l&le)===le){ae!==null&&(ae=ae.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var xe=e,we=T;switch(le=n,ge=i,we.tag){case 1:if(xe=we.payload,typeof xe=="function"){ue=xe.call(ge,ue,le);break e}ue=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=we.payload,le=typeof xe=="function"?xe.call(ge,ue,le):xe,le==null)break e;ue=H({},ue,le);break e;case 2:_r=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,le=f.effects,le===null?f.effects=[T]:le.push(T))}else ge={eventTime:ge,lane:le,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ae===null?(J=ae=ge,O=ue):ae=ae.next=ge,S|=le;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;le=T,T=le.next,le.next=null,f.lastBaseUpdate=le,f.shared.pending=null}}while(!0);if(ae===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=J,f.lastBaseUpdate=ae,n=f.shared.interleaved,n!==null){f=n;do S|=f.lane,f=f.next;while(f!==n)}else g===null&&(f.shared.lanes=0);ri|=S,e.lanes=S,e.memoizedState=ue}}function Td(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=Xa.transition;Xa.transition={};try{e(!1),n()}finally{Fe=i,Xa.transition=l}}function Zd(){return Jt().memoizedState}function by(e,n,i){var l=br(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},Jd(e))ef(n,i);else if(i=Pd(e,n,i,l),i!==null){var f=Mt();dn(i,e,l,f),tf(i,n,l)}}function Ey(e,n,i){var l=br(e),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(Jd(e))ef(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,T=g(S,i);if(f.hasEagerState=!0,f.eagerState=T,sn(T,S)){var O=n.interleaved;O===null?(f.next=f,Ba(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=Pd(e,n,f,l),i!==null&&(f=Mt(),dn(i,e,l,f),tf(i,n,l))}}function Jd(e){var n=e.alternate;return e===Ke||n!==null&&n===Ke}function ef(e,n){Ao=Ys=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function tf(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}var qs={readContext:Zt,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},Cy={readContext:Zt,useCallback:function(e,n){return Pn().memoizedState=[e,n===void 0?null:n],e},useContext:Zt,useEffect:Wd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Gs(4194308,4,Gd.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Gs(4194308,4,e,n)},useInsertionEffect:function(e,n){return Gs(4,2,e,n)},useMemo:function(e,n){var i=Pn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=Pn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=by.bind(null,Ke,e),[l.memoizedState,e]},useRef:function(e){var n=Pn();return e={current:e},n.memoizedState=e},useState:Bd,useDebugValue:tu,useDeferredValue:function(e){return Pn().memoizedState=e},useTransition:function(){var e=Bd(!1),n=e[0];return e=jy.bind(null,e[1]),Pn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=Ke,f=Pn();if(Xe){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ht===null)throw Error(o(349));(ni&30)!==0||zd(l,n,i)}f.memoizedState=i;var g={value:i,getSnapshot:n};return f.queue=g,Wd(Od.bind(null,l,g,e),[e]),l.flags|=2048,Do(9,Dd.bind(null,l,g,i,n),void 0,null),i},useId:function(){var e=Pn(),n=ht.identifierPrefix;if(Xe){var i=Qn,l=Kn;i=(l&~(1<<32-Et(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=$o++,0<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=S.createElement(i,{is:l.is}):(e=S.createElement(i),i==="select"&&(S=e,l.multiple?S.multiple=!0:l.size&&(S.size=l.size))):e=S.createElementNS(e,i),e[Cn]=n,e[Mo]=l,Sf(e,n,!1,!1),n.stateNode=e;e:{switch(S=zn(i,l),i){case"dialog":We("cancel",e),We("close",e),f=l;break;case"iframe":case"object":case"embed":We("load",e),f=l;break;case"video":case"audio":for(f=0;fWi&&(n.flags|=128,l=!0,Oo(g,!1),n.lanes=4194304)}else{if(!l)if(e=Ws(S),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Oo(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Xe)return Nt(n),null}else 2*Ve()-g.renderingStartTime>Wi&&i!==1073741824&&(n.flags|=128,l=!0,Oo(g,!1),n.lanes=4194304);g.isBackwards?(S.sibling=n.child,n.child=S):(i=g.last,i!==null?i.sibling=S:n.child=S,g.last=S)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(Nt(n),null);case 22:case 23:return ju(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Yt&1073741824)!==0&&(Nt(n),n.subtreeFlags&6&&(n.flags|=8192)):Nt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function $y(e,n){switch(La(n),n.tag){case 1:return Tt(n.type)&&Ts(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Fi(),Ue(Rt),Ue(St),Ga(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Ua(n),null;case 13:if(Ue(qe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));$i()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Fi(),null;case 10:return Fa(n.type._context),null;case 22:case 23:return ju(),null;case 24:return null;default:return null}}var Js=!1,jt=!1,zy=typeof WeakSet=="function"?WeakSet:Set,ye=null;function Bi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Ze(e,n,l)}else i.current=null}function hu(e,n,i){try{i()}catch(l){Ze(e,n,l)}}var jf=!1;function Dy(e,n){if(ja=xs,e=nd(),ya(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,g=l.focusNode;l=l.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var S=0,T=-1,O=-1,J=0,ae=0,ue=e,le=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=S+f),ue!==g||l!==0&&ue.nodeType!==3||(O=S+l),ue.nodeType===3&&(S+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)le=ue,ue=ge;for(;;){if(ue===e)break t;if(le===i&&++J===f&&(T=S),le===g&&++ae===l&&(O=S),(ge=ue.nextSibling)!==null)break;ue=le,le=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(ba={focusedElem:e,selectionRange:i},xs=!1,ye=n;ye!==null;)if(n=ye,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ye=e;else for(;ye!==null;){n=ye;try{var xe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var we=xe.memoizedProps,et=xe.memoizedState,X=n.stateNode,B=X.getSnapshotBeforeUpdate(n.elementType===n.type?we:an(n.type,we),et);X.__reactInternalSnapshotBeforeUpdate=B}break;case 3:var Q=n.stateNode.containerInfo;Q.nodeType===1?Q.textContent="":Q.nodeType===9&&Q.documentElement&&Q.removeChild(Q.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(de){Ze(n,n.return,de)}if(e=n.sibling,e!==null){e.return=n.return,ye=e;break}ye=n.return}return xe=jf,jf=!1,xe}function Fo(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&e)===e){var g=f.destroy;f.destroy=void 0,g!==void 0&&hu(n,i,g)}f=f.next}while(f!==l)}}function el(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function pu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function bf(e){var n=e.alternate;n!==null&&(e.alternate=null,bf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[Cn],delete n[Mo],delete n[Pa],delete n[wy],delete n[_y])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Ef(e){return e.tag===5||e.tag===3||e.tag===4}function Cf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Ef(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function gu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=Is));else if(l!==4&&(e=e.child,e!==null))for(gu(e,n,i),e=e.sibling;e!==null;)gu(e,n,i),e=e.sibling}function mu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(mu(e,n,i),e=e.sibling;e!==null;)mu(e,n,i),e=e.sibling}var vt=null,un=!1;function kr(e,n,i){for(i=i.child;i!==null;)Mf(e,n,i),i=i.sibling}function Mf(e,n,i){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(Vn,i)}catch{}switch(i.tag){case 5:jt||Bi(i,n);case 6:var l=vt,f=un;vt=null,kr(e,n,i),vt=l,un=f,vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):vt.removeChild(i.stateNode));break;case 18:vt!==null&&(un?(e=vt,i=i.stateNode,e.nodeType===8?Ma(e.parentNode,i):e.nodeType===1&&Ma(e,i),vo(e)):Ma(vt,i.stateNode));break;case 4:l=vt,f=un,vt=i.stateNode.containerInfo,un=!0,kr(e,n,i),vt=l,un=f;break;case 0:case 11:case 14:case 15:if(!jt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var g=f,S=g.destroy;g=g.tag,S!==void 0&&((g&2)!==0||(g&4)!==0)&&hu(i,n,S),f=f.next}while(f!==l)}kr(e,n,i);break;case 1:if(!jt&&(Bi(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Ze(i,n,T)}kr(e,n,i);break;case 21:kr(e,n,i);break;case 22:i.mode&1?(jt=(l=jt)||i.memoizedState!==null,kr(e,n,i),jt=l):kr(e,n,i);break;default:kr(e,n,i)}}function Pf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new zy),n.forEach(function(l){var f=Gy.bind(null,e,l);i.has(l)||(i.add(l),l.then(f,f))})}}function cn(e,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=S),l&=~g}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Fy(l/1960))-l,10e?16:e,jr===null)var l=!1;else{if(e=jr,jr=null,ol=0,(ze&6)!==0)throw Error(o(331));var f=ze;for(ze|=4,ye=e.current;ye!==null;){var g=ye,S=g.child;if((ye.flags&16)!==0){var T=g.deletions;if(T!==null){for(var O=0;OVe()-xu?oi(e,0):vu|=i),$t(e,n)}function Vf(e,n){n===0&&((e.mode&1)===0?n=1:(n=Un,Un<<=1,(Un&130023424)===0&&(Un=4194304)));var i=Mt();e=Zn(e,n),e!==null&&(En(e,n,i),$t(e,i))}function Yy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Vf(e,i)}function Gy(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Vf(e,i)}var Wf;Wf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Rt.current)Lt=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return Lt=!1,Ly(e,n,i);Lt=(e.flags&131072)!==0}else Lt=!1,Xe&&(n.flags&1048576)!==0&&Sd(n,zs,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Zs(e,n),e=n.pendingProps;var f=Ti(n,St.current);Oi(n,i),f=Ka(null,n,l,e,f,i);var g=Qa();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Tt(l)?(g=!0,Ls(n)):g=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Va(n),f.updater=Ks,n.stateNode=f,f._reactInternals=n,ru(n,l,e,i),n=lu(null,n,l,!0,g,i)):(n.tag=0,Xe&&g&&Ta(n),Ct(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Zs(e,n),e=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=qy(l),e=an(l,e),f){case 0:n=su(null,n,l,e,i);break e;case 1:n=mf(null,n,l,e,i);break e;case 11:n=df(null,n,l,e,i);break e;case 14:n=ff(null,n,l,an(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),su(e,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),mf(e,n,l,f,i);case 3:e:{if(yf(n),e===null)throw Error(o(387));l=n.pendingProps,g=n.memoizedState,f=g.element,Id(e,n),Vs(n,l,null,i);var S=n.memoizedState;if(l=S.element,g.isDehydrated)if(g={element:l,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){f=Hi(Error(o(423)),n),n=vf(e,n,l,i,f);break e}else if(l!==f){f=Hi(Error(o(424)),n),n=vf(e,n,l,i,f);break e}else for(Ut=yr(n.stateNode.containerInfo.firstChild),Wt=n,Xe=!0,ln=null,i=Md(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if($i(),l===f){n=er(e,n,i);break e}Ct(e,n,l,i)}n=n.child}return n;case 5:return Ld(n),e===null&&$a(n),l=n.type,f=n.pendingProps,g=e!==null?e.memoizedProps:null,S=f.children,Ea(l,f)?S=null:g!==null&&Ea(l,g)&&(n.flags|=32),gf(e,n),Ct(e,n,S,i),n.child;case 6:return e===null&&$a(n),null;case 13:return xf(e,n,i);case 4:return Wa(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=zi(n,null,l,i):Ct(e,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),df(e,n,l,f,i);case 7:return Ct(e,n,n.pendingProps,i),n.child;case 8:return Ct(e,n,n.pendingProps.children,i),n.child;case 12:return Ct(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,g=n.memoizedProps,S=f.value,Be(Fs,l._currentValue),l._currentValue=S,g!==null)if(sn(g.value,S)){if(g.children===f.children&&!Rt.current){n=er(e,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var T=g.dependencies;if(T!==null){S=g.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(g.tag===1){O=Jn(-1,i&-i),O.tag=2;var J=g.updateQueue;if(J!==null){J=J.shared;var ae=J.pending;ae===null?O.next=O:(O.next=ae.next,ae.next=O),J.pending=O}}g.lanes|=i,O=g.alternate,O!==null&&(O.lanes|=i),Ha(g.return,i,n),T.lanes|=i;break}O=O.next}}else if(g.tag===10)S=g.type===n.type?null:g.child;else if(g.tag===18){if(S=g.return,S===null)throw Error(o(341));S.lanes|=i,T=S.alternate,T!==null&&(T.lanes|=i),Ha(S,i,n),S=g.sibling}else S=g.child;if(S!==null)S.return=g;else for(S=g;S!==null;){if(S===n){S=null;break}if(g=S.sibling,g!==null){g.return=S.return,S=g;break}S=S.return}g=S}Ct(e,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,Oi(n,i),f=Zt(f),l=l(f),n.flags|=1,Ct(e,n,l,i),n.child;case 14:return l=n.type,f=an(l,n.pendingProps),f=an(l.type,f),ff(e,n,l,f,i);case 15:return hf(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:an(l,f),Zs(e,n),n.tag=1,Tt(l)?(e=!0,Ls(n)):e=!1,Oi(n,i),rf(n,l,f),ru(n,l,f,i),lu(null,n,l,!0,e,i);case 19:return _f(e,n,i);case 22:return pf(e,n,i)}throw Error(o(156,n.tag))};function Uf(e,n){return Hr(e,n)}function Xy(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tn(e,n,i,l){return new Xy(e,n,i,l)}function Eu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function qy(e){if(typeof e=="function")return Eu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ne)return 11;if(e===V)return 14}return 2}function Cr(e,n){var i=e.alternate;return i===null?(i=tn(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function ul(e,n,i,l,f,g){var S=2;if(l=e,typeof e=="function")Eu(e)&&(S=1);else if(typeof e=="string")S=5;else e:switch(e){case F:return li(i.children,f,g,n);case G:S=8,f|=8;break;case q:return e=tn(12,i,n,f|2),e.elementType=q,e.lanes=g,e;case K:return e=tn(13,i,n,f),e.elementType=K,e.lanes=g,e;case C:return e=tn(19,i,n,f),e.elementType=C,e.lanes=g,e;case U:return cl(i,f,g,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case te:S=10;break e;case ee:S=9;break e;case ne:S=11;break e;case V:S=14;break e;case W:S=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=tn(S,i,n,f),n.elementType=e,n.type=l,n.lanes=g,n}function li(e,n,i,l){return e=tn(7,e,l,n),e.lanes=i,e}function cl(e,n,i,l){return e=tn(22,e,l,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function Cu(e,n,i){return e=tn(6,e,null,n),e.lanes=i,e}function Mu(e,n,i){return n=tn(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Ky(e,n,i,l,f){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Yn(0),this.expirationTimes=Yn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Yn(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Pu(e,n,i,l,f,g,S,T,O){return e=new Ky(e,n,i,T,O),n===1?(n=1,g===!0&&(n|=8)):n=0,g=tn(3,null,null,n),e.current=g,g.stateNode=e,g.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Va(g),e}function Qy(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),$u.exports=u0(),$u.exports}var oh;function c0(){if(oh)return yl;oh=1;var t=Ep();return yl.createRoot=t.createRoot,yl.hydrateRoot=t.hydrateRoot,yl}var d0=c0();function Cp(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Ae(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(Cp(s,o.statusText||"Request failed"))}return o.json()}const f0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Pe={health:()=>Ae("/api/health"),settings:()=>Ae("/api/settings"),saveSettings:t=>{const r={...t};for(const o of f0)r[o]===""&&delete r[o];return Ae("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ae("/api/repos"),browse:t=>Ae(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ae(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ae("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ae(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Ae(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:(t,r=!0)=>Ae(`/api/architecture?repo_path=${encodeURIComponent(t)}&graph=${r?"1":"0"}`),architectureGraph:t=>Ae(`/api/architecture/graph?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Ae("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Ae("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Ae("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Ae("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Ae("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Ae(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open",s)=>Ae("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o,repo_path:s||null})}),scmRepos:t=>Ae(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ae("/api/oauth/status"),githubOAuthStart:()=>Ae("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ae("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ae("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Ae("/api/oauth/gitlab/start"),oauthDisconnect:t=>Ae("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ae("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})}),reviews:t=>Ae(`/api/reviews?repo_path=${encodeURIComponent(t)}`),getReview:(t,r)=>Ae(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(t)}`),reviewDiff:(t,r,o)=>Ae(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(t)}&other=${encodeURIComponent(o)}`),config:t=>Ae(`/api/config?repo_path=${encodeURIComponent(t)}`),saveConfig:(t,r)=>Ae("/api/config",{method:"PUT",body:JSON.stringify({repo_path:t,...r})}),addWaiver:(t,r,o,s)=>Ae("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:t,rule:r,node:o||null,reason:s||""})}),marks:(t,r)=>Ae(`/api/marks?repo_path=${encodeURIComponent(t)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:t=>Ae(`/api/architecture/health?repo_path=${encodeURIComponent(t)}`),workspaceStatus:t=>Ae(`/api/workspace/status?repo_path=${encodeURIComponent(t)}`),openEditor:(t,r,o,s)=>Ae("/api/open",{method:"POST",body:JSON.stringify({repo_path:t,path:r,line:o||null,editor:s||null})}),exportHtml:t=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:t})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(Cp(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(t,r,o,s)=>Ae("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:t,edges:r,source_id:o,target_id:s||null})})};function h0(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):t}function p0({open:t,actions:r,onClose:o}){const[s,a]=L.useState(""),[u,c]=L.useState(0),h=L.useRef(null),p=L.useMemo(()=>h0(r,s),[r,s]);if(L.useEffect(()=>{if(!t)return;a(""),c(0);const v=window.setTimeout(()=>{var m;return(m=h.current)==null?void 0:m.focus()},0);return()=>window.clearTimeout(v)},[t]),L.useEffect(()=>{c(0)},[s]),!t)return null;const y=p[u],x=v=>{v&&(o(),v.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:v=>{v.target===v.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:v=>a(v.target.value),onKeyDown:v=>{v.key==="Escape"?(v.preventDefault(),o()):v.key==="ArrowDown"?(v.preventDefault(),c(m=>Math.min(p.length-1,m+1))):v.key==="ArrowUp"?(v.preventDefault(),c(m=>Math.max(0,m-1))):v.key==="Enter"&&(v.preventDefault(),x(y))}}),d.jsxs("ul",{children:[p.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,p.slice(0,40).map((v,m)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:m===u?"active":"",onMouseEnter:()=>c(m),onClick:()=>x(v),children:[d.jsx("span",{children:v.label}),v.hint?d.jsx("span",{className:"muted",children:v.hint}):null]})},v.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function g0({config:t,busy:r,onSave:o,onWaiver:s}){const[a,u]=L.useState(t),[c,h]=L.useState(t.available_rules[0]||""),[p,y]=L.useState(""),[x,v]=L.useState("");L.useEffect(()=>{u(t)},[t]);const m=Object.entries(a.contexts||{}),_=(R,w,N)=>{const A=a.contexts[R];if(!A)return;const $=F=>F.split(",").map(G=>G.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[R]:{...A,[w]:w==="name"?N:$(N)}}})},k=(R,w)=>{const N=w.trim();if(!N||N===R)return;const{[R]:A,...$}=a.contexts;A&&u({...a,contexts:{...$,[N]:{...A,name:N}}})},j=()=>{let R=1;for(;a.contexts[`context-${R}`];)R+=1;const w=`context-${R}`;u({...a,contexts:{...a.contexts,[w]:{name:w,django_apps:[],react:[],public_api:[],owners:[]}}})},b=R=>{const{[R]:w,...N}=a.contexts;u({...a,contexts:N})},E=R=>{const w=a.rules.includes(R);u({...a,rules:w?a.rules.filter(N=>N!==R):[...a.rules,R]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),m.map(([R,w])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:R})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:R,"data-testid":`config-context-name-${R}`,onBlur:N=>k(R,N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(w.django_apps||[]).join(", "),onChange:N=>_(R,"django_apps",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(w.react||[]).join(", "),onChange:N=>_(R,"react",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(w.public_api||[]).join(", "),onChange:N=>_(R,"public_api",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(w.owners||[]).join(", "),onChange:N=>_(R,"owners",N.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>b(R),children:"Remove context"})]},R)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:j,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(R),onChange:()=>E(R)}),R]},R))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((R,w)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:R.rule}),R.node?` · ${R.node}`:"",R.reason?` — ${R.reason}`:""]},`${R.rule}:${R.node}:${w}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:R=>h(R.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsx("option",{value:R,children:R},R))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:R=>y(R.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:x,onChange:R=>v(R.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,x),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function Zo(t){return t.replaceAll("_"," ")}function m0(t){return t.replaceAll("_"," ")}function io(t){return t.split(".").pop()||t}function tc(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function y0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Tr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function yi({className:t,children:r}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function v0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function x0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function w0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function _0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function S0({className:t}){return d.jsxs(yi,{className:t,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function Mp({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function k0({className:t}){return d.jsx(yi,{className:t,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const N0="modulepreload",j0=function(t,r){return new URL(t,r).href},sh={},b0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(x){return Promise.all(x.map(v=>Promise.resolve(v).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),y=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(x=>{if(x=j0(x,s),x in sh)return;sh[x]=!0;const v=x.endsWith(".css"),m=v?'[rel="stylesheet"]':"";if(!!s)for(let j=h.length-1;j>=0;j--){const b=h[j];if(b.href===x&&(!v||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${x}"]${m}`))return;const k=document.createElement("link");if(k.rel=v?"stylesheet":N0,v||(k.as="script"),k.crossOrigin="",k.href=x,y&&k.setAttribute("nonce",y),document.head.appendChild(k),v)return new Promise((j,b)=>{k.addEventListener("load",j),k.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${x}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function nt(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Gl(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}Ml.prototype=Gl.prototype={constructor:Ml,on:function(t,r){var o=this._,s=C0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),ah.hasOwnProperty(r)?{space:ah[r],local:t}:t}function P0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===nc&&r.documentElement.namespaceURI===nc?r.createElement(t):r.createElementNS(o,t)}}function I0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Pp(t){var r=Xl(t);return(r.local?I0:P0)(r)}function R0(){}function mc(t){return t==null?R0:function(){return this.querySelector(t)}}function T0(t){typeof t!="function"&&(t=mc(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=w&&(w=R+1);!(A=b[w])&&++w=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function iv(t){t||(t=ov);function r(v,m){return v&&m?t(v.__data__,m.__data__):!v-!m}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function sv(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function lv(){return Array.from(this)}function av(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?xv:typeof r=="function"?_v:wv)(t,r,o??"")):Ki(this.node(),t)}function Ki(t,r){return t.style.getPropertyValue(r)||Ap(t).getComputedStyle(t,null).getPropertyValue(r)}function kv(t){return function(){delete this[t]}}function Nv(t,r){return function(){this[t]=r}}function jv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function bv(t,r){return arguments.length>1?this.each((r==null?kv:typeof r=="function"?jv:Nv)(t,r)):this.node()[t]}function $p(t){return t.trim().split(/^|\s+/)}function yc(t){return t.classList||new zp(t)}function zp(t){this._node=t,this._names=$p(t.getAttribute("class")||"")}zp.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Dp(t,r){for(var o=yc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function ex(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function rc(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:y,dispatch:x}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:y,enumerable:!0,configurable:!0},_:{value:x}})}rc.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function cx(t){return!t.ctrlKey&&!t.button}function dx(){return this.parentNode}function fx(t,r){return r??{x:t.x,y:t.y}}function hx(){return navigator.maxTouchPoints||"ontouchstart"in this}function Wp(){var t=cx,r=dx,o=fx,s=hx,a={},u=Gl("start","drag","end"),c=0,h,p,y,x,v=0;function m(N){N.on("mousedown.drag",_).filter(s).on("touchstart.drag",b).on("touchmove.drag",E,ux).on("touchend.drag touchcancel.drag",R).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(N,A){if(!(x||!t.call(this,N,A))){var $=w(this,r.call(this,N,A),N,A,"mouse");$&&(Gt(N.view).on("mousemove.drag",k,Jo).on("mouseup.drag",j,Jo),Bp(N.view),Ou(N),y=!1,h=N.clientX,p=N.clientY,$("start",N))}}function k(N){if(Xi(N),!y){var A=N.clientX-h,$=N.clientY-p;y=A*A+$*$>v}a.mouse("drag",N)}function j(N){Gt(N.view).on("mousemove.drag mouseup.drag",null),Vp(N.view,y),Xi(N),a.mouse("end",N)}function b(N,A){if(t.call(this,N,A)){var $=N.changedTouches,F=r.call(this,N,A),G=$.length,q,te;for(q=0;q>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?xl(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?xl(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=gx.exec(t))?new Dt(r[1],r[2],r[3],1):(r=mx.exec(t))?new Dt(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=yx.exec(t))?xl(r[1],r[2],r[3],r[4]):(r=vx.exec(t))?xl(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=xx.exec(t))?gh(r[1],r[2]/100,r[3]/100,1):(r=wx.exec(t))?gh(r[1],r[2]/100,r[3]/100,r[4]):uh.hasOwnProperty(t)?fh(uh[t]):t==="transparent"?new Dt(NaN,NaN,NaN,0):null}function fh(t){return new Dt(t>>16&255,t>>8&255,t&255,1)}function xl(t,r,o,s){return s<=0&&(t=r=o=NaN),new Dt(t,r,o,s)}function kx(t){return t instanceof fs||(t=fi(t)),t?(t=t.rgb(),new Dt(t.r,t.g,t.b,t.opacity)):new Dt}function ic(t,r,o,s){return arguments.length===1?kx(t):new Dt(t,r,o,s??1)}function Dt(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}vc(Dt,ic,Up(fs,{brighter(t){return t=t==null?Al:Math.pow(Al,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?es:Math.pow(es,t),new Dt(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Dt(ci(this.r),ci(this.g),ci(this.b),$l(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:hh,formatHex:hh,formatHex8:Nx,formatRgb:ph,toString:ph}));function hh(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}`}function Nx(){return`#${ui(this.r)}${ui(this.g)}${ui(this.b)}${ui((isNaN(this.opacity)?1:this.opacity)*255)}`}function ph(){const t=$l(this.opacity);return`${t===1?"rgb(":"rgba("}${ci(this.r)}, ${ci(this.g)}, ${ci(this.b)}${t===1?")":`, ${t})`}`}function $l(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ci(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ui(t){return t=ci(t),(t<16?"0":"")+t.toString(16)}function gh(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new hn(t,r,o,s)}function Yp(t){if(t instanceof hn)return new hn(t.h,t.s,t.l,t.opacity);if(t instanceof fs||(t=fi(t)),!t)return new hn;if(t instanceof hn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new hn(c,h,p,t.opacity)}function jx(t,r,o,s){return arguments.length===1?Yp(t):new hn(t,r,o,s??1)}function hn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}vc(hn,jx,Up(fs,{brighter(t){return t=t==null?Al:Math.pow(Al,t),new hn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?es:Math.pow(es,t),new hn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Dt(Fu(t>=240?t-240:t+120,a,s),Fu(t,a,s),Fu(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new hn(mh(this.h),wl(this.s),wl(this.l),$l(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 t=$l(this.opacity);return`${t===1?"hsl(":"hsla("}${mh(this.h)}, ${wl(this.s)*100}%, ${wl(this.l)*100}%${t===1?")":`, ${t})`}`}}));function mh(t){return t=(t||0)%360,t<0?t+360:t}function wl(t){return Math.max(0,Math.min(1,t||0))}function Fu(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const xc=t=>()=>t;function bx(t,r){return function(o){return t+o*r}}function Ex(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function Cx(t){return(t=+t)==1?Gp:function(r,o){return o-r?Ex(r,o,t):xc(isNaN(r)?o:r)}}function Gp(t,r){var o=r-t;return o?bx(t,o):xc(isNaN(t)?r:t)}const zl=(function t(r){var o=Cx(r);function s(a,u){var c=o((a=ic(a)).r,(u=ic(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),y=Gp(a.opacity,u.opacity);return function(x){return a.r=c(x),a.g=h(x),a.b=p(x),a.opacity=y(x),a+""}}return s.gamma=t,s})(1);function Mx(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:Rn(s,a)})),o=Hu.lastIndex;return o180?x+=360:x-y>180&&(y+=360),m.push({i:v.push(a(v)+"rotate(",null,s)-2,x:Rn(y,x)})):x&&v.push(a(v)+"rotate("+x+s)}function h(y,x,v,m){y!==x?m.push({i:v.push(a(v)+"skewX(",null,s)-2,x:Rn(y,x)}):x&&v.push(a(v)+"skewX("+x+s)}function p(y,x,v,m,_,k){if(y!==v||x!==m){var j=_.push(a(_)+"scale(",null,",",null,")");k.push({i:j-4,x:Rn(y,v)},{i:j-2,x:Rn(x,m)})}else(v!==1||m!==1)&&_.push(a(_)+"scale("+v+","+m+")")}return function(y,x){var v=[],m=[];return y=t(y),x=t(x),u(y.translateX,y.translateY,x.translateX,x.translateY,v,m),c(y.rotate,x.rotate,v,m),h(y.skewX,x.skewX,v,m),p(y.scaleX,y.scaleY,x.scaleX,x.scaleY,v,m),y=x=null,function(_){for(var k=-1,j=m.length,b;++k=0&&t._call.call(void 0,r),t=t._next;--Qi}function xh(){hi=(Ol=ns.now())+ql,Qi=Xo=0;try{Wx()}finally{Qi=0,Yx(),hi=0}}function Ux(){var t=ns.now(),r=t-Ol;r>Qp&&(ql-=r,Ol=t)}function Yx(){for(var t,r=Dl,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:Dl=o);qo=t,lc(s)}function lc(t){if(!Qi){Xo&&(Xo=clearTimeout(Xo));var r=t-hi;r>24?(t<1/0&&(Xo=setTimeout(xh,t-ns.now()-ql)),Yo&&(Yo=clearInterval(Yo))):(Yo||(Ol=ns.now(),Yo=setInterval(Ux,Qp)),Qi=1,Zp(xh))}}function wh(t,r,o){var s=new Fl;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Gx=Gl("start","end","cancel","interrupt"),Xx=[],eg=0,_h=1,ac=2,Il=3,Sh=4,uc=5,Rl=6;function Kl(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;qx(t,o,{name:r,index:s,group:a,on:Gx,tween:Xx,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:eg})}function _c(t,r){var o=yn(t,r);if(o.state>eg)throw new Error("too late; already scheduled");return o}function Ln(t,r){var o=yn(t,r);if(o.state>Il)throw new Error("too late; already running");return o}function yn(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function qx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=Jp(u,0,o.time);function u(y){o.state=_h,o.timer.restart(c,o.delay,o.time),o.delay<=y&&c(y-o.delay)}function c(y){var x,v,m,_;if(o.state!==_h)return p();for(x in s)if(_=s[x],_.name===o.name){if(_.state===Il)return wh(c);_.state===Sh?(_.state=Rl,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete s[x]):+xac&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function jw(t,r,o){var s,a,u=Nw(r)?_c:Ln;return function(){var c=u(this,t),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function bw(t,r){var o=this._id;return arguments.length<2?yn(this.node(),o).on.on(t):this.each(jw(o,t,r))}function Ew(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function Cw(){return this.on("end.remove",Ew(this._id))}function Mw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=mc(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function e1(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function rr(t,r,o){this.k=t,this.x=r,this.y=o}rr.prototype={constructor:rr,scale:function(t){return t===1?this:new rr(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new rr(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Ql=new rr(1,0,0);ig.prototype=rr.prototype;function ig(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Ql;return t.__zoom}function Bu(t){t.stopImmediatePropagation()}function Go(t){t.preventDefault(),t.stopImmediatePropagation()}function t1(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function n1(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function kh(){return this.__zoom||Ql}function r1(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function i1(){return navigator.maxTouchPoints||"ontouchstart"in this}function o1(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function og(){var t=t1,r=n1,o=o1,s=r1,a=i1,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=Pl,y=Gl("start","zoom","end"),x,v,m,_=500,k=150,j=0,b=10;function E(C){C.property("__zoom",kh).on("wheel.zoom",G,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",te).filter(a).on("touchstart.zoom",ee).on("touchmove.zoom",ne).on("touchend.zoom touchcancel.zoom",K).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(C,V,W,U){var M=C.selection?C.selection():C;M.property("__zoom",kh),C!==M?A(C,V,W,U):M.interrupt().each(function(){$(this,arguments).event(U).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},E.scaleBy=function(C,V,W,U){E.scaleTo(C,function(){var M=this.__zoom.k,D=typeof V=="function"?V.apply(this,arguments):V;return M*D},W,U)},E.scaleTo=function(C,V,W,U){E.transform(C,function(){var M=r.apply(this,arguments),D=this.__zoom,H=W==null?N(M):typeof W=="function"?W.apply(this,arguments):W,I=D.invert(H),z=typeof V=="function"?V.apply(this,arguments):V;return o(w(R(D,z),H,I),M,c)},W,U)},E.translateBy=function(C,V,W,U){E.transform(C,function(){return o(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),r.apply(this,arguments),c)},null,U)},E.translateTo=function(C,V,W,U,M){E.transform(C,function(){var D=r.apply(this,arguments),H=this.__zoom,I=U==null?N(D):typeof U=="function"?U.apply(this,arguments):U;return o(Ql.translate(I[0],I[1]).scale(H.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),D,c)},U,M)};function R(C,V){return V=Math.max(u[0],Math.min(u[1],V)),V===C.k?C:new rr(V,C.x,C.y)}function w(C,V,W){var U=V[0]-W[0]*C.k,M=V[1]-W[1]*C.k;return U===C.x&&M===C.y?C:new rr(C.k,U,M)}function N(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function A(C,V,W,U){C.on("start.zoom",function(){$(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(U).end()}).tween("zoom",function(){var M=this,D=arguments,H=$(M,D).event(U),I=r.apply(M,D),z=W==null?N(I):typeof W=="function"?W.apply(M,D):W,ie=Math.max(I[1][0]-I[0][0],I[1][1]-I[0][1]),oe=M.__zoom,fe=typeof V=="function"?V.apply(M,D):V,he=p(oe.invert(z).concat(ie/oe.k),fe.invert(z).concat(ie/fe.k));return function(pe){if(pe===1)pe=fe;else{var Z=he(pe),se=ie/Z[2];pe=new rr(se,z[0]-Z[0]*se,z[1]-Z[1]*se)}H.zoom(null,pe)}})}function $(C,V,W){return!W&&C.__zooming||new F(C,V)}function F(C,V){this.that=C,this.args=V,this.active=0,this.sourceEvent=null,this.extent=r.apply(C,V),this.taps=0}F.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,V){return this.mouse&&C!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var V=Gt(this.that).datum();y.call(C,this.that,new e1(C,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:y}),V)}};function G(C,...V){if(!t.apply(this,arguments))return;var W=$(this,V).event(C),U=this.__zoom,M=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,s.apply(this,arguments)))),D=fn(C);if(W.wheel)(W.mouse[0][0]!==D[0]||W.mouse[0][1]!==D[1])&&(W.mouse[1]=U.invert(W.mouse[0]=D)),clearTimeout(W.wheel);else{if(U.k===M)return;W.mouse=[D,U.invert(D)],Tl(this),W.start()}Go(C),W.wheel=setTimeout(H,k),W.zoom("mouse",o(w(R(U,M),W.mouse[0],W.mouse[1]),W.extent,c));function H(){W.wheel=null,W.end()}}function q(C,...V){if(m||!t.apply(this,arguments))return;var W=C.currentTarget,U=$(this,V,!0).event(C),M=Gt(C.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",ie,!0),D=fn(C,W),H=C.clientX,I=C.clientY;Bp(C.view),Bu(C),U.mouse=[D,this.__zoom.invert(D)],Tl(this),U.start();function z(oe){if(Go(oe),!U.moved){var fe=oe.clientX-H,he=oe.clientY-I;U.moved=fe*fe+he*he>j}U.event(oe).zoom("mouse",o(w(U.that.__zoom,U.mouse[0]=fn(oe,W),U.mouse[1]),U.extent,c))}function ie(oe){M.on("mousemove.zoom mouseup.zoom",null),Vp(oe.view,U.moved),Go(oe),U.event(oe).end()}}function te(C,...V){if(t.apply(this,arguments)){var W=this.__zoom,U=fn(C.changedTouches?C.changedTouches[0]:C,this),M=W.invert(U),D=W.k*(C.shiftKey?.5:2),H=o(w(R(W,D),U,M),r.apply(this,V),c);Go(C),h>0?Gt(this).transition().duration(h).call(A,H,U,C):Gt(this).call(E.transform,H,U,C)}}function ee(C,...V){if(t.apply(this,arguments)){var W=C.touches,U=W.length,M=$(this,V,C.changedTouches.length===U).event(C),D,H,I,z;for(Bu(C),H=0;H`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},rs=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],sg=["Enter"," ","Escape"],lg={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Zi;(function(t){t.Strict="strict",t.Loose="loose"})(Zi||(Zi={}));var di;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(di||(di={}));var is;(function(t){t.Partial="partial",t.Full="full"})(is||(is={}));const ag={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Lr;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Lr||(Lr={}));var os;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(os||(os={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const Nh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function ug(t){return t===null?null:t?"valid":"invalid"}const cg=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,s1=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),kc=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),hs=(t,r=[0,0])=>{const{width:o,height:s}=vn(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},l1=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):kc(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,Zl(a,Hl(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?Jl(s):{x:0,y:0,width:0,height:0}},ps=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=Zl(o,Hl(a)),s=!0)}),s?Jl(o):{x:0,y:0,width:0,height:0}},Nc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,y=r.width/a,x=r.height/a,v=[];for(const m of t.values()){const{measured:_,selectable:k=!0,hidden:j=!1}=m;if(c&&!k||j)continue;const b=_.width??m.width??m.initialWidth??0,E=_.height??m.height??m.initialHeight??0,{x:R,y:w}=m.internals.positionAbsolute,N=pg(h,p,y,x,R,w,b,E),A=b*E,$=u&&N>0;(!m.internals.handleBounds||$||N>=A||m.dragging)&&v.push(m)}return v},a1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function u1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=vn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function c1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const h=u1(t,c),p=ps(h),y=bc(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(y,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function dg({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),h=c.parentId?o.get(c.parentId):void 0,{x:p,y}=h?h.internals.positionAbsolute:{x:0,y:0},x=c.origin??s;let v=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",mn.error005());else{const{width:_,height:k}=vn(h);_&&k&&(v=[[p,y],[p+_,y+k]])}else h&&gi(c.extent)&&(v=[[c.extent[0][0]+p,c.extent[0][1]+y],[c.extent[1][0]+p,c.extent[1][1]+y]]);const m=gi(v)?pi(r,v,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",mn.error015())),{position:{x:m.x-p+(c.measured.width??0)*x[0],y:m.y-y+(c.measured.height??0)*x[1]},positionAbsolute:m}}async function d1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(m=>m.id)),c=[];for(const m of o){if(m.deletable===!1)continue;const _=u.has(m.id),k=!_&&m.parentId&&c.find(j=>j.id===m.parentId);(_||k)&&c.push(m)}const h=new Set(r.map(m=>m.id)),p=s.filter(m=>m.deletable!==!1),x=a1(c,p);for(const m of p)h.has(m.id)&&!x.find(k=>k.id===m.id)&&x.push(m);if(!a)return{edges:x,nodes:c};const v=await a({nodes:c,edges:x});return typeof v=="boolean"?v?{edges:x,nodes:c}:{edges:[],nodes:[]}:v}const Ji=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),pi=(t={x:0,y:0},r,o)=>({x:Ji(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:Ji(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function fg(t,r,o){const{width:s,height:a}=vn(o),{x:u,y:c}=o.internals.positionAbsolute;return pi(t,[[u,c],[u+s,c+a]],r)}const jh=(t,r,o)=>to?-Ji(Math.abs(t-o),1,r)/r:0,jc=(t,r,o=15,s=40)=>{const a=jh(t.x,s,r.width-s)*o,u=jh(t.y,s,r.height-s)*o;return[a,u]},Zl=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),cc=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),Jl=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),ss=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=kc(t)?t.internals.positionAbsolute:hs(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},Hl=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=kc(t)?t.internals.positionAbsolute:hs(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},hg=(t,r)=>Jl(Zl(cc(t),cc(r))),pg=(t,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),y=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*y)},Bl=(t,r)=>pg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),bh=t=>pn(t.width)&&pn(t.height)&&pn(t.x)&&pn(t.y),pn=t=>!isNaN(t)&&isFinite(t),gg=(t,r)=>(o,s)=>{},gs=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),ms=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(t-o)/a,y:(r-s)/a};return u?gs(h,c):h},eo=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Yi(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function f1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Yi(t,o),a=Yi(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Yi(t.top??t.y??0,o),a=Yi(t.bottom??t.y??0,o),u=Yi(t.left??t.x??0,r),c=Yi(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function h1(t,r,o,s,a,u){const{x:c,y:h}=eo(t,[r,o,s]),{x:p,y}=eo({x:t.x+t.width,y:t.y+t.height},[r,o,s]),x=a-p,v=u-y;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(x),bottom:Math.floor(v)}}const bc=(t,r,o,s,a,u)=>{const c=f1(u,r,o),h=(r-c.x)/t.width,p=(o-c.y)/t.height,y=Math.min(h,p),x=Ji(y,s,a),v=t.x+t.width/2,m=t.y+t.height/2,_=r/2-v*x,k=o/2-m*x,j=h1(t,_,k,x,r,o),b={left:Math.min(j.left-c.left,0),top:Math.min(j.top-c.top,0),right:Math.min(j.right-c.right,0),bottom:Math.min(j.bottom-c.bottom,0)};return{x:_-b.left+b.right,y:k-b.top+b.bottom,zoom:x}},ls=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function gi(t){return t!=null&&t!=="parent"}function vn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function mg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function yg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function Eh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function p1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function g1(t){return{...lg,...t||{}}}function Qo(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=gn(t),h=ms({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y}=o?gs(h,r):h;return{xSnapped:p,ySnapped:y,...h}}const Ec=t=>({width:t.offsetWidth,height:t.offsetHeight}),vg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},m1=["INPUT","SELECT","TEXTAREA"];function xg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:m1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const wg=t=>"clientX"in t,gn=(t,r)=>{var u,c;const o=wg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},Ch=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...Ec(c)}})};function _g({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=t*.125+a*.375+c*.375+o*.125,y=r*.125+u*.375+h*.375+s*.125,x=Math.abs(p-t),v=Math.abs(y-r);return[p,y,x,v]}function kl(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function Mh({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case Se.Left:return[r-kl(r-s,u),o];case Se.Right:return[r+kl(s-r,u),o];case Se.Top:return[r,o-kl(o-a,u)];case Se.Bottom:return[r,o+kl(a-o,u)]}}function Sg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top,curvature:c=.25}){const[h,p]=Mh({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[y,x]=Mh({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[v,m,_,k]=_g({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:y,targetControlY:x});return[`M${t},${r} C${h},${p} ${y},${x} ${s},${a}`,v,m,_,k]}function kg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const x1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,w1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),_1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",mn.error006()),r;const s=o.getEdgeId||x1;let a;return cg(t)?a={...t}:a={...t,id:s(t)},w1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function Ng({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=kg({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,h]}const Ph={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},S1=({source:t,sourcePosition:r=Se.Bottom,target:o})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function k1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:s=Se.Top,center:a,offset:u,stepPosition:c}){const h=Ph[r],p=Ph[s],y={x:t.x+h.x*u,y:t.y+h.y*u},x={x:o.x+p.x*u,y:o.y+p.y*u},v=S1({source:y,sourcePosition:r,target:x}),m=v.x!==0?"x":"y",_=v[m];let k=[],j,b;const E={x:0,y:0},R={x:0,y:0},[,,w,N]=kg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[m]*p[m]===-1){m==="x"?(j=a.x??y.x+(x.x-y.x)*c,b=a.y??(y.y+x.y)/2):(j=a.x??(y.x+x.x)/2,b=a.y??y.y+(x.y-y.y)*c);const G=[{x:j,y:y.y},{x:j,y:x.y}],q=[{x:y.x,y:b},{x:x.x,y:b}];h[m]===_?k=m==="x"?G:q:k=m==="x"?q:G}else{const G=[{x:y.x,y:x.y}],q=[{x:x.x,y:y.y}];if(m==="x"?k=h.x===_?q:G:k=h.y===_?G:q,r===s){const C=Math.abs(t[m]-o[m]);if(C<=u){const V=Math.min(u-1,u-C);h[m]===_?E[m]=(y[m]>t[m]?-1:1)*V:R[m]=(x[m]>o[m]?-1:1)*V}}if(r!==s){const C=m==="x"?"y":"x",V=h[m]===p[C],W=y[C]>x[C],U=y[C]=K?(j=(te.x+ee.x)/2,b=k[0].y):(j=k[0].x,b=(te.y+ee.y)/2)}const A={x:y.x+E.x,y:y.y+E.y},$={x:x.x+R.x,y:x.y+R.y};return[[t,...A.x!==k[0].x||A.y!==k[0].y?[A]:[],...k,...$.x!==k[k.length-1].x||$.y!==k[k.length-1].y?[$]:[],o],j,b,w,N]}function N1(t,r,o,s){const a=Math.min(Ih(t,r)/2,Ih(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const y=t.xo.id===r):t[0])||null}function dc(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function b1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const y=dc(p,r);u.has(y)||(c.push({id:y,color:p.color||o,...p}),u.add(y))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const jg=1e3,E1=10,Cc={nodeOrigin:[0,0],nodeExtent:rs,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},C1={...Cc,checkEquality:!0};function Mc(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function M1(t,r,o){const s=Mc(Cc,o);for(const a of t.values())if(a.parentId)Ic(a,t,r,s);else{const u=hs(a,s.nodeOrigin),c=gi(a.extent)?a.extent:s.nodeExtent,h=pi(u,c,vn(a));a.internals.positionAbsolute=h}}function P1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function Pc(t){return t==="manual"}function fc(t,r,o,s={}){var x,v;const a=Mc(C1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!Pc(a.zIndexMode)?jg:0;let p=t.length>0,y=!1;r.clear(),o.clear();for(const m of t){let _=c.get(m.id);if(a.checkEquality&&m===(_==null?void 0:_.internals.userNode))r.set(m.id,_);else{const k=hs(m,a.nodeOrigin),j=gi(m.extent)?m.extent:a.nodeExtent,b=pi(k,j,vn(m));_={...a.defaults,...m,measured:{width:(x=m.measured)==null?void 0:x.width,height:(v=m.measured)==null?void 0:v.height},internals:{positionAbsolute:b,handleBounds:P1(m,_),z:bg(m,h,a.zIndexMode),userNode:m}},r.set(m.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),m.parentId&&Ic(_,r,o,s,u),y||(y=m.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:y}}function I1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function Ic(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=Mc(Cc,s),y=t.parentId,x=r.get(y);if(!x){console.warn(`Parent node ${y} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}I1(t,o),a&&!x.parentId&&x.internals.rootParentIndex===void 0&&p==="auto"&&(x.internals.rootParentIndex=++a.i,x.internals.z=x.internals.z+a.i*E1),a&&x.internals.rootParentIndex!==void 0&&(a.i=x.internals.rootParentIndex);const v=u&&!Pc(p)?jg:0,{x:m,y:_,z:k}=R1(t,x,c,h,v,p),{positionAbsolute:j}=t.internals,b=m!==j.x||_!==j.y;(b||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:b?{x:m,y:_}:j,z:k}})}function bg(t,r,o){const s=pn(t.zIndex)?t.zIndex:0;return Pc(o)?s:s+(t.selected?r:0)}function R1(t,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=vn(t),y=hs(t,o),x=gi(t.extent)?pi(y,t.extent,p):y;let v=pi({x:c+x.x,y:h+x.y},s,p);t.extent==="parent"&&(v=fg(v,p,r));const m=bg(t,a,u),_=r.internals.z??0;return{x:v.x,y:v.y,z:_>=m?_+1:m}}function Rc(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const y=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??ss(p),x=hg(y,h.rect);u.set(h.parentId,{expandedRect:x,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},y)=>{var w;const x=p.internals.positionAbsolute,v=vn(p),m=p.origin??s,_=h.x0||k>0||E||R)&&(a.push({id:y,type:"position",position:{x:p.position.x-_+E,y:p.position.y-k+R}}),(w=o.get(y))==null||w.forEach(N=>{t.some(A=>A.id===N.id)||a.push({id:N.id,type:"position",position:{x:N.position.x+_,y:N.position.y+k}})})),(v.width0){const _=Rc(m,r,o,a);y.push(..._)}return{changes:y,updatedInternals:p}}async function L1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Ah(t,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${t}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${t}-${u}`;const y=s.get(c)||new Map;s.set(c,y.set(o,r))}}function Eg(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},y=`${a}-${c}--${u}-${h}`,x=`${u}-${h}--${a}-${c}`;Ah("source",p,x,t,a,c),Ah("target",p,y,t,u,h),r.set(s.id,s)}}function Cg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:Cg(o,r):!1}function $h(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function A1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!Cg(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function Vu({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[y,x]of r){const v=(c=o.get(y))==null?void 0:c.internals.userNode;v&&a.push({...v,position:x.position,dragging:s})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function $1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=gs(u,r);return{x:c.x-u.x,y:c.y-u.y}}function z1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,y={x:0,y:0},x=null,v=!1,m=null,_=!1,k=!1,j=null;function b({noDragClassName:R,handleSelector:w,domNode:N,isSelectable:A,nodeId:$,nodeClickDistance:F=0}){m=Gt(N);function G({x:ne,y:K}){const{nodeLookup:C,nodeExtent:V,snapGrid:W,snapToGrid:U,nodeOrigin:M,onNodeDrag:D,onSelectionDrag:H,onError:I,updateNodePositions:z}=r();u={x:ne,y:K};let ie=!1;const oe=h.size>1,fe=oe&&V?cc(ps(h)):null,he=oe&&U?$1({dragItems:h,snapGrid:W,x:ne,y:K}):null;for(const[pe,Z]of h){if(!C.has(pe))continue;let se={x:ne-Z.distance.x,y:K-Z.distance.y};U&&(se=he?{x:Math.round(se.x+he.x),y:Math.round(se.y+he.y)}:gs(se,W));let me=null;if(oe&&V&&!Z.extent&&fe){const{positionAbsolute:re}=Z.internals,Ne=re.x-fe.x+V[0][0],Me=re.x+Z.measured.width-fe.x2+V[1][0],Te=re.y-fe.y+V[0][1],$e=re.y+Z.measured.height-fe.y2+V[1][1];me=[[Ne,Te],[Me,$e]]}const{position:ke,positionAbsolute:ve}=dg({nodeId:pe,nextPosition:se,nodeLookup:C,nodeExtent:me||V,nodeOrigin:M,onError:I});ie=ie||Z.position.x!==ke.x||Z.position.y!==ke.y,Z.position=ke,Z.internals.positionAbsolute=ve}if(k=k||ie,!!ie&&(z(h,!0),j&&(s||D||!$&&H))){const[pe,Z]=Vu({nodeId:$,dragItems:h,nodeLookup:C});s==null||s(j,h,pe,Z),D==null||D(j,pe,Z),$||H==null||H(j,Z)}}async function q(){if(!x)return;const{transform:ne,panBy:K,autoPanSpeed:C,autoPanOnNodeDrag:V}=r();if(!V){p=!1,cancelAnimationFrame(c);return}const[W,U]=jc(y,x,C);(W!==0||U!==0)&&(u.x=(u.x??0)-W/ne[2],u.y=(u.y??0)-U/ne[2],await K({x:W,y:U})&&G(u)),c=requestAnimationFrame(q)}function te(ne){var oe;const{nodeLookup:K,multiSelectionActive:C,nodesDraggable:V,transform:W,snapGrid:U,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:H,onSelectionDragStart:I,unselectNodesAndEdges:z}=r();v=!0,(!D||!A)&&!C&&$&&((oe=K.get($))!=null&&oe.selected||z()),A&&D&&$&&(t==null||t($));const ie=Qo(ne.sourceEvent,{transform:W,snapGrid:U,snapToGrid:M,containerBounds:x});if(u=ie,h=A1(K,V,ie,$),h.size>0&&(o||H||!$&&I)){const[fe,he]=Vu({nodeId:$,dragItems:h,nodeLookup:K});o==null||o(ne.sourceEvent,h,fe,he),H==null||H(ne.sourceEvent,fe,he),$||I==null||I(ne.sourceEvent,he)}}const ee=Wp().clickDistance(F).on("start",ne=>{const{domNode:K,nodeDragThreshold:C,transform:V,snapGrid:W,snapToGrid:U}=r();x=(K==null?void 0:K.getBoundingClientRect())||null,_=!1,k=!1,j=ne.sourceEvent,C===0&&te(ne),u=Qo(ne.sourceEvent,{transform:V,snapGrid:W,snapToGrid:U,containerBounds:x}),y=gn(ne.sourceEvent,x)}).on("drag",ne=>{const{autoPanOnNodeDrag:K,transform:C,snapGrid:V,snapToGrid:W,nodeDragThreshold:U,nodeLookup:M}=r(),D=Qo(ne.sourceEvent,{transform:C,snapGrid:V,snapToGrid:W,containerBounds:x});if(j=ne.sourceEvent,(ne.sourceEvent.type==="touchmove"&&ne.sourceEvent.touches.length>1||$&&!M.has($))&&(_=!0),!_){if(!p&&K&&v&&(p=!0,q()),!v){const H=gn(ne.sourceEvent,x),I=H.x-y.x,z=H.y-y.y;Math.sqrt(I*I+z*z)>U&&te(ne)}(u.x!==D.xSnapped||u.y!==D.ySnapped)&&h&&v&&(y=gn(ne.sourceEvent,x),G(D))}}).on("end",ne=>{if(!v||_){_&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,v=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:K,updateNodePositions:C,onNodeDragStop:V,onSelectionDragStop:W}=r();if(k&&(C(h,!1),k=!1),a||V||!$&&W){const[U,M]=Vu({nodeId:$,dragItems:h,nodeLookup:K,dragging:!1});a==null||a(ne.sourceEvent,h,U,M),V==null||V(ne.sourceEvent,U,M),$||W==null||W(ne.sourceEvent,M)}}}).filter(ne=>{const K=ne.target;return!ne.button&&(!R||!$h(K,`.${R}`,N))&&(!w||$h(K,w,N))});m.call(ee)}function E(){m==null||m.on(".drag",null)}return{update:b,destroy:E}}function D1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())Bl(a,ss(u))>0&&s.push(u);return s}const O1=250;function F1(t,r,o,s){var h,p;let a=[],u=1/0;const c=D1(t,o,r+O1);for(const y of c){const x=[...((h=y.internals.handleBounds)==null?void 0:h.source)??[],...((p=y.internals.handleBounds)==null?void 0:p.target)??[]];for(const v of x){if(s.nodeId===v.nodeId&&s.type===v.type&&s.id===v.id)continue;const{x:m,y:_}=mi(y,v,v.position,!0),k=Math.sqrt(Math.pow(m-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const y=s.type==="source"?"target":"source";return a.find(x=>x.type===y)??a[0]}return a[0]}function Mg(t,r,o,s,a,u=!1){var y,x,v;const c=s.get(t);if(!c)return null;const h=a==="strict"?(y=c.internals.handleBounds)==null?void 0:y[r]:[...((x=c.internals.handleBounds)==null?void 0:x.source)??[],...((v=c.internals.handleBounds)==null?void 0:v.target)??[]],p=(o?h==null?void 0:h.find(m=>m.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...mi(c,p,p.position,!0)}:p}function Pg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function H1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const Ig=()=>!0;function B1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:y,autoPanOnConnect:x,flowId:v,panBy:m,cancelConnection:_,onConnectStart:k,onConnect:j,onConnectEnd:b,isValidConnection:E=Ig,onReconnectEnd:R,updateConnection:w,getTransform:N,getFromHandle:A,autoPanSpeed:$,dragThreshold:F=1,handleDomNode:G}){const q=vg(t.target);let te=0,ee;const{x:ne,y:K}=gn(t),C=Pg(u,G),V=h==null?void 0:h.getBoundingClientRect();let W=!1;if(!V||!C)return;const U=Mg(a,C,s,p,r);if(!U)return;let M=gn(t,V),D=!1,H=null,I=!1,z=null;function ie(){if(!x||!V)return;const[ke,ve]=jc(M,V,$);m({x:ke,y:ve}),te=requestAnimationFrame(ie)}const oe={...U,nodeId:a,type:C,position:U.position},fe=p.get(a);let pe={inProgress:!0,isValid:null,from:mi(fe,oe,Se.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:fe,to:M,toHandle:null,toPosition:Nh[oe.position],toNode:null,pointer:M};function Z(){W=!0,w(pe),k==null||k(t,{nodeId:a,handleId:s,handleType:C})}F===0&&Z();function se(ke){if(!W){const{x:$e,y:st}=gn(ke),lt=$e-ne,at=st-K;if(!(lt*lt+at*at>F*F))return;Z()}if(!A()||!oe){me(ke);return}const ve=N();M=gn(ke,V),ee=F1(ms(M,ve,!1,[1,1]),o,p,oe),D||(ie(),D=!0);const re=Rg(ke,{handle:ee,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:E,doc:q,lib:y,flowId:v,nodeLookup:p});z=re.handleDomNode,H=re.connection,I=H1(!!ee,re.isValid);const Ne=p.get(a),Me=Ne?mi(Ne,oe,Se.Left,!0):pe.from,Te={...pe,from:Me,isValid:I,to:re.toHandle&&I?eo({x:re.toHandle.x,y:re.toHandle.y},ve):M,toHandle:re.toHandle,toPosition:I&&re.toHandle?re.toHandle.position:Nh[oe.position],toNode:re.toHandle?p.get(re.toHandle.nodeId):null,pointer:M};w(Te),pe=Te}function me(ke){if(!("touches"in ke&&ke.touches.length>0)){if(W){(ee||z)&&H&&I&&(j==null||j(H));const{inProgress:ve,...re}=pe,Ne={...re,toPosition:pe.toHandle?pe.toPosition:null};b==null||b(ke,Ne),u&&(R==null||R(ke,Ne))}_(),cancelAnimationFrame(te),D=!1,I=!1,H=null,z=null,q.removeEventListener("mousemove",se),q.removeEventListener("mouseup",me),q.removeEventListener("touchmove",se),q.removeEventListener("touchend",me)}}q.addEventListener("mousemove",se),q.addEventListener("mouseup",me),q.addEventListener("touchmove",se),q.addEventListener("touchend",me)}function Rg(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:y=Ig,nodeLookup:x}){const v=u==="target",m=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=gn(t),j=c.elementFromPoint(_,k),b=j!=null&&j.classList.contains(`${h}-flow__handle`)?j:m,E={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const R=Pg(void 0,b),w=b.getAttribute("data-nodeid"),N=b.getAttribute("data-handleid"),A=b.classList.contains("connectable"),$=b.classList.contains("connectableend");if(!w||!R)return E;const F={source:v?w:s,sourceHandle:v?N:a,target:v?s:w,targetHandle:v?a:N};E.connection=F;const q=A&&$&&(o===Zi.Strict?v&&R==="source"||!v&&R==="target":w!==s||N!==a);E.isValid=q&&y(F),E.toHandle=Mg(w,R,N,x,o,!0)}return E}const hc={onPointerDown:B1,isValid:Rg};function V1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Gt(t);function u({translateExtent:h,width:p,height:y,zoomStep:x=1,pannable:v=!0,zoomable:m=!0,inversePan:_=!1}){const k=w=>{if(w.sourceEvent.type!=="wheel"||!r)return;const N=o(),A=w.sourceEvent.ctrlKey&&ls()?10:1,$=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*x,F=N[2]*Math.pow(2,$*A);r.scaleTo(F)};let j=[0,0];const b=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(j=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},E=w=>{const N=o();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!r)return;const A=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],$=[A[0]-j[0],A[1]-j[1]];j=A;const F=s()*Math.max(N[2],Math.log(N[2]))*(_?-1:1),G={x:N[0]-$[0]*F,y:N[1]-$[1]*F},q=[[0,0],[p,y]];r.setViewportConstrained({x:G.x,y:G.y,zoom:N[2]},q,h)},R=og().on("start",b).on("zoom",v?E:null).on("zoom.wheel",m?k:null);a.call(R,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:fn}}const ea=t=>({x:t.x,y:t.y,zoom:t.k}),Wu=({x:t,y:r,zoom:o})=>Ql.translate(t,r).scale(o),Rr=(t,r)=>t.target.closest(`.${r}`),Tg=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),W1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Uu=(t,r=0,o=W1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Lg=t=>{const r=t.ctrlKey&&ls()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function U1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:y}){return x=>{if(Rr(x,r))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const v=o.property("__zoom").k||1;if(x.ctrlKey&&c){const b=fn(x),E=Lg(x),R=v*Math.pow(2,E);s.scaleTo(o,R,b,x);return}const m=x.deltaMode===1?20:1;let _=a===di.Vertical?0:x.deltaX*m,k=a===di.Horizontal?0:x.deltaY*m;!ls()&&x.shiftKey&&a!==di.Vertical&&(_=x.deltaY*m,k=0),s.translateBy(o,-(_/v)*u,-(k/v)*u,{internal:!0});const j=ea(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(x,j):(t.isPanScrolling=!0,h==null||h(x,j)),t.panScrollTimeout=setTimeout(()=>{y==null||y(x,j),t.isPanScrolling=!1},150)}}function Y1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=Rr(s,t);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function G1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=ea(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function X1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;t.usedRightMouseButton=!!(o&&Tg(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,ea(u.transform)))}}function q1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&Tg(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const p=ea(c.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function K1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:y,lib:x,connectionInProgress:v}){return m=>{var E;const _=r||o,k=s&&m.ctrlKey,j=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(Rr(m,`${x}-flow__node`)||Rr(m,`${x}-flow__edge`)||Rr(m,`${x}-flow__selection`)||Rr(m,`${x}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!c&&!s||h||v&&!j||Rr(m,p)&&j||Rr(m,y)&&(!j||u&&j&&!r)||!s&&m.ctrlKey&&j)return!1;if(!s&&m.type==="touchstart"&&((E=m.touches)==null?void 0:E.length)>1)return m.preventDefault(),!1;if(!_&&!u&&!k&&j||!a&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(a)&&!a.includes(m.button)&&m.type==="mousedown")return!1;const b=Array.isArray(a)&&a.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||j||t)&&b}}function Q1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const y={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=t.getBoundingClientRect();let v=[[0,0],[x.width,x.height]];const m=typeof ResizeObserver<"u"?new ResizeObserver(K=>{const C=K[0];C&&(v=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;m==null||m.observe(t);const _=og().extent(()=>v).scaleExtent([r,o]).translateExtent(s),k=Gt(t).call(_);N({x:a.x,y:a.y,zoom:Ji(a.zoom,r,o)},[[0,0],[x.width,x.height]],s);const j=k.on("wheel.zoom"),b=k.on("dblclick.zoom");_.wheelDelta(Lg);async function E(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Pl).transform(Uu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function R({noWheelClassName:K,noPanClassName:C,onPaneContextMenu:V,userSelectionActive:W,panOnScroll:U,panOnDrag:M,panOnScrollMode:D,panOnScrollSpeed:H,preventScrolling:I,zoomOnPinch:z,zoomOnScroll:ie,zoomOnDoubleClick:oe,panActivationKeyPressed:fe=!1,zoomActivationKeyPressed:he,lib:pe,onTransformChange:Z,connectionInProgress:se,paneClickDistance:me,selectionOnDrag:ke}){W&&!y.isZoomingOrPanning&&w();const ve=U&&!he&&!W;_.clickDistance(ke?1/0:!pn(me)||me<0?0:me);const re=ve?U1({zoomPanValues:y,noWheelClassName:K,d3Selection:k,d3Zoom:_,panOnScrollMode:D,panOnScrollSpeed:H,zoomOnPinch:z,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):Y1({noWheelClassName:K,preventScrolling:I,d3ZoomHandler:j});k.on("wheel.zoom",re,{passive:!1});const Ne=G1({zoomPanValues:y,onDraggingChange:p,onPanZoomStart:c});_.on("start",Ne);const Me=X1({zoomPanValues:y,panOnDrag:M,onPaneContextMenu:!!V,onPanZoom:u,onTransformChange:Z});_.on("zoom",Me);const Te=q1({zoomPanValues:y,panOnDrag:M,panOnScroll:U,onPaneContextMenu:V,onPanZoomEnd:h,onDraggingChange:p});_.on("end",Te);const $e=K1({panActivationKeyPressed:fe,zoomActivationKeyPressed:he,panOnDrag:M,zoomOnScroll:ie,panOnScroll:U,zoomOnDoubleClick:oe,zoomOnPinch:z,userSelectionActive:W,noPanClassName:C,noWheelClassName:K,lib:pe,connectionInProgress:se});_.filter($e),oe?k.on("dblclick.zoom",b):k.on("dblclick.zoom",null)}function w(){_.on("zoom",null)}async function N(K,C,V){const W=Wu(K),U=_==null?void 0:_.constrain()(W,C,V);return U&&await E(U),U}async function A(K,C){const V=Wu(K);return await E(V,C),V}function $(K){if(k){const C=Wu(K),V=k.property("__zoom");(V.k!==K.zoom||V.x!==K.x||V.y!==K.y)&&(_==null||_.transform(k,C,null,{sync:!0}))}}function F(){const K=k?ig(k.node()):{x:0,y:0,k:1};return{x:K.x,y:K.y,zoom:K.k}}async function G(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Pl).scaleTo(Uu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}async function q(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Pl).scaleBy(Uu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function te(K){_==null||_.scaleExtent(K)}function ee(K){_==null||_.translateExtent(K)}function ne(K){const C=!pn(K)||K<0?0:K;_==null||_.clickDistance(C)}return{update:R,destroy:w,setViewport:A,setViewportConstrained:N,getViewport:F,scaleTo:G,scaleBy:q,setScaleExtent:te,setTranslateExtent:ee,syncViewport:$,setClickDistance:ne}}var to;(function(t){t.Line="line",t.Handle="handle"})(to||(to={}));function Z1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function zh(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function Pr(t,r){return Math.max(0,r-t)}function Ir(t,r){return Math.max(0,t-r)}function Nl(t,r,o){return Math.max(0,r-t,t-o)}function Dh(t,r){return t?!r:r}function J1(t,r,o,s,a,u,c,h){let{affectsX:p,affectsY:y}=r;const{isHorizontal:x,isVertical:v}=r,m=x&&v,{xSnapped:_,ySnapped:k}=o,{minWidth:j,maxWidth:b,minHeight:E,maxHeight:R}=s,{x:w,y:N,width:A,height:$,aspectRatio:F}=t;let G=Math.floor(x?_-t.pointerX:0),q=Math.floor(v?k-t.pointerY:0);const te=A+(p?-G:G),ee=$+(y?-q:q),ne=-u[0]*A,K=-u[1]*$;let C=Nl(te,j,b),V=Nl(ee,E,R);if(c){let M=0,D=0;p&&G<0?M=Pr(w+G+ne,c[0][0]):!p&&G>0&&(M=Ir(w+te+ne,c[1][0])),y&&q<0?D=Pr(N+q+K,c[0][1]):!y&&q>0&&(D=Ir(N+ee+K,c[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(h){let M=0,D=0;p&&G>0?M=Ir(w+G,h[0][0]):!p&&G<0&&(M=Pr(w+te,h[1][0])),y&&q>0?D=Ir(N+q,h[0][1]):!y&&q<0&&(D=Pr(N+ee,h[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(a){if(x){const M=Nl(te/F,E,R)*F;if(C=Math.max(C,M),c){let D=0;!p&&!y||p&&!y&&m?D=Ir(N+K+te/F,c[1][1])*F:D=Pr(N+K+(p?G:-G)/F,c[0][1])*F,C=Math.max(C,D)}if(h){let D=0;!p&&!y||p&&!y&&m?D=Pr(N+te/F,h[1][1])*F:D=Ir(N+(p?G:-G)/F,h[0][1])*F,C=Math.max(C,D)}}if(v){const M=Nl(ee*F,j,b)/F;if(V=Math.max(V,M),c){let D=0;!p&&!y||y&&!p&&m?D=Ir(w+ee*F+ne,c[1][0])/F:D=Pr(w+(y?q:-q)*F+ne,c[0][0])/F,V=Math.max(V,D)}if(h){let D=0;!p&&!y||y&&!p&&m?D=Pr(w+ee*F,h[1][0])/F:D=Ir(w+(y?q:-q)*F,h[0][0])/F,V=Math.max(V,D)}}}q=q+(q<0?V:-V),G=G+(G<0?C:-C),a&&(m?te>ee*F?q=(Dh(p,y)?-G:G)/F:G=(Dh(p,y)?-q:q)*F:x?(q=G/F,y=p):(G=q*F,p=y));const W=p?w+G:w,U=y?N+q:N;return{width:A+(p?-G:G),height:$+(y?-q:q),x:u[0]*G*(p?-1:1)+W,y:u[1]*q*(y?-1:1)+U}}const Ag={width:0,height:0,x:0,y:0},e_={...Ag,pointerX:0,pointerY:0,aspectRatio:1};function t_(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function n_({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Gt(t);let c={controlDirection:zh("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:y,boundaries:x,keepAspectRatio:v,resizeDirection:m,onResizeStart:_,onResize:k,onResizeEnd:j,shouldResize:b}){let E={...Ag},R={...e_};c={boundaries:x,resizeDirection:m,keepAspectRatio:v,controlDirection:zh(y)};let w,N=null,A=[],$,F,G,q=!1;const te=Wp().on("start",ee=>{const{nodeLookup:ne,transform:K,snapGrid:C,snapToGrid:V,nodeOrigin:W,paneDomNode:U}=o();if(w=ne.get(r),!w)return;N=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:D}=Qo(ee.sourceEvent,{transform:K,snapGrid:C,snapToGrid:V,containerBounds:N});E={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},R={...E,pointerX:M,pointerY:D,aspectRatio:E.width/E.height},$=void 0,F=gi(w.extent)?w.extent:void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&($=ne.get(w.parentId)),$&&w.extent==="parent"&&(F=[[0,0],[$.measured.width,$.measured.height]]),A=[],G=void 0;for(const[H,I]of ne)if(I.parentId===r&&(A.push({id:H,position:{...I.position},extent:I.extent}),I.extent==="parent"||I.expandParent)){const z=t_(I,w,I.origin??W);G?G=[[Math.min(z[0][0],G[0][0]),Math.min(z[0][1],G[0][1])],[Math.max(z[1][0],G[1][0]),Math.max(z[1][1],G[1][1])]]:G=z}_==null||_(ee,{...E})}).on("drag",ee=>{const{transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V}=o(),W=Qo(ee.sourceEvent,{transform:ne,snapGrid:K,snapToGrid:C,containerBounds:N}),U=[];if(!w)return;const{x:M,y:D,width:H,height:I}=E,z={},ie=w.origin??V,{width:oe,height:fe,x:he,y:pe}=J1(R,c.controlDirection,W,c.boundaries,c.keepAspectRatio,ie,F,G),Z=oe!==H,se=fe!==I,me=he!==M&&Z,ke=pe!==D&&se;if(!me&&!ke&&!Z&&!se)return;if((me||ke||ie[0]===1||ie[1]===1)&&(z.x=me?he:E.x,z.y=ke?pe:E.y,E.x=z.x,E.y=z.y,A.length>0)){const Me=he-M,Te=pe-D;for(const $e of A)$e.position={x:$e.position.x-Me+ie[0]*(oe-H),y:$e.position.y-Te+ie[1]*(fe-I)},U.push($e)}if((Z||se)&&(z.width=Z&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:E.width,z.height=se&&(!c.resizeDirection||c.resizeDirection==="vertical")?fe:E.height,E.width=z.width,E.height=z.height),$&&w.expandParent){const Me=ie[0]*(z.width??0);z.x&&z.x{q&&(j==null||j(ee,{...E}),a==null||a({...E}),q=!1)});u.call(te)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Yu={exports:{}},Gu={},Xu={exports:{}},qu={};/** - * @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 Oh;function r_(){if(Oh)return qu;Oh=1;var t=cs();function r(v,m){return v===m&&(v!==0||1/v===1/m)||v!==v&&m!==m}var o=typeof Object.is=="function"?Object.is:r,s=t.useState,a=t.useEffect,u=t.useLayoutEffect,c=t.useDebugValue;function h(v,m){var _=m(),k=s({inst:{value:_,getSnapshot:m}}),j=k[0].inst,b=k[1];return u(function(){j.value=_,j.getSnapshot=m,p(j)&&b({inst:j})},[v,_,m]),a(function(){return p(j)&&b({inst:j}),v(function(){p(j)&&b({inst:j})})},[v]),c(_),_}function p(v){var m=v.getSnapshot;v=v.value;try{var _=m();return!o(v,_)}catch{return!0}}function y(v,m){return m()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:h;return qu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:x,qu}var Fh;function i_(){return Fh||(Fh=1,Xu.exports=r_()),Xu.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 Hh;function o_(){if(Hh)return Gu;Hh=1;var t=cs(),r=i_();function o(y,x){return y===x&&(y!==0||1/y===1/x)||y!==y&&x!==x}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Gu.useSyncExternalStoreWithSelector=function(y,x,v,m,_){var k=u(null);if(k.current===null){var j={hasValue:!1,value:null};k.current=j}else j=k.current;k=h(function(){function E($){if(!R){if(R=!0,w=$,$=m($),_!==void 0&&j.hasValue){var F=j.value;if(_(F,$))return N=F}return N=$}if(F=N,s(w,$))return F;var G=m($);return _!==void 0&&_(F,G)?(w=$,F):(w=$,N=G)}var R=!1,w,N,A=v===void 0?null:v;return[function(){return E(x())},A===null?void 0:function(){return E(A())}]},[x,v,m,_]);var b=a(y,k[0],k[1]);return c(function(){j.hasValue=!0,j.value=b},[b]),p(b),b},Gu}var Bh;function s_(){return Bh||(Bh=1,Yu.exports=o_()),Yu.exports}var l_=s_();const a_=bp(l_),u_={},Vh=t=>{let r;const o=new Set,s=(x,v)=>{const m=typeof x=="function"?x(r):x;if(!Object.is(m,r)){const _=r;r=v??(typeof m!="object"||m===null)?m:Object.assign({},r,m),o.forEach(k=>k(r,_))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>y,subscribe:x=>(o.add(x),()=>o.delete(x)),destroy:()=>{(u_?"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."),o.clear()}},y=r=t(s,a,p);return p},c_=t=>t?Vh(t):Vh,{useDebugValue:d_}=s0,{useSyncExternalStoreWithSelector:f_}=a_,h_=t=>t;function $g(t,r=h_,o){const s=f_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return d_(s),s}const Wh=(t,r)=>{const o=c_(t),s=(a,u=r)=>$g(o,a,u);return Object.assign(s,o),s},p_=(t,r)=>t?Wh(t,r):Wh;function Qe(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}Ep();const ta=L.createContext(null),g_=ta.Provider,zg=mn.error001("react");function De(t,r){const o=L.useContext(ta);if(o===null)throw new Error(zg);return $g(o,t,r)}function Ye(){const t=L.useContext(ta);if(t===null)throw new Error(zg);return L.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Uh={display:"none"},m_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Dg="react-flow__node-desc",Og="react-flow__edge-desc",y_="react-flow__aria-live",v_=t=>t.ariaLiveMessage,x_=t=>t.ariaLabelConfig;function w_({rfId:t}){const r=De(v_);return d.jsx("div",{id:`${y_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:m_,children:r})}function __({rfId:t,disableKeyboardA11y:r}){const o=De(x_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${Dg}-${t}`,style:Uh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${Og}-${t}`,style:Uh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(w_,{rfId:t})]})}const na=L.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return d.jsx("div",{className:nt(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});na.displayName="Panel";const Yh="https://reactflow.dev?utm_source=attribution";function S_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:d.jsx(na,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Yh}`,children:d.jsx("a",{href:Yh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const k_=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},jl=t=>t.id;function N_(t,r){return Qe(t.selectedNodes.map(jl),r.selectedNodes.map(jl))&&Qe(t.selectedEdges.map(jl),r.selectedEdges.map(jl))}function j_({onSelectionChange:t}){const r=Ye(),{selectedNodes:o,selectedEdges:s}=De(k_,N_);return L.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const b_=t=>!!t.onSelectionChangeHandlers;function E_({onSelectionChange:t}){const r=De(b_);return t||r?d.jsx(j_,{onSelectionChange:t}):null}const Fg=[0,0],C_={x:0,y:0,zoom:1},M_=["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"],Gh=[...M_,"rfId"],P_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Xh={translateExtent:rs,nodeOrigin:Fg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function I_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=De(P_,Qe),y=Ye();L.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{x.current=Xh,h()}),[]);const x=L.useRef(Xh);return L.useEffect(()=>{for(const v of Gh){const m=t[v],_=x.current[v];m!==_&&(typeof t[v]>"u"||(v==="nodes"?r(m):v==="edges"?o(m):v==="minZoom"?s(m):v==="maxZoom"?a(m):v==="translateExtent"?u(m):v==="nodeExtent"?c(m):v==="ariaLabelConfig"?y.setState({ariaLabelConfig:g1(m)}):v==="fitView"?y.setState({fitViewQueued:m}):v==="fitViewOptions"?y.setState({fitViewOptions:m}):y.setState({[v]:m})))}x.current=t},Gh.map(v=>t[v])),null}function qh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function R_(t){var s;const[r,o]=L.useState(t==="system"?null:t);return L.useEffect(()=>{if(t!=="system"){o(t);return}const a=qh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=qh())!=null&&s.matches?"dark":"light"}const Kh=typeof document<"u"?document:null;function as(t=null,r={target:Kh,actInsideInputWithModifier:!0}){const[o,s]=L.useState(!1),a=L.useRef(!1),u=L.useRef(new Set([])),[c,h]=L.useMemo(()=>{if(t!==null){const y=(Array.isArray(t)?t:[t]).filter(v=>typeof v=="string").map(v=>v.replace(/\+/g,` -`).replace(` - -`,` -+`).split(` -`)),x=y.reduce((v,m)=>v.concat(...m),[]);return[y,x]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Kh,y=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const x=_=>{var b,E;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!y)&&xg(_))return!1;const j=Zh(_.code,h);if(u.current.add(_[j]),Qh(c,u.current,!1)){const R=((E=(b=_.composedPath)==null?void 0:b.call(_))==null?void 0:E[0])||_.target,w=(R==null?void 0:R.nodeName)==="BUTTON"||(R==null?void 0:R.nodeName)==="A";r.preventDefault!==!1&&(a.current||!w)&&_.preventDefault(),s(!0)}},v=_=>{const k=Zh(_.code,h);Qh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},m=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",x),p==null||p.addEventListener("keyup",v),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{p==null||p.removeEventListener("keydown",x),p==null||p.removeEventListener("keyup",v),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,s]),o}function Qh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Zh(t,r){return r.includes(t)?"code":"key"}const T_=()=>{const t=Ye();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=bc(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),y={x:r.x-h,y:r.y-p},x=o.snapGrid??a,v=o.snapToGrid??u;return ms(y,s,v,x)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=eo(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function Hg(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)L_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function L_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function A_(t,r){return Hg(t,r)}function $_(t,r){return Hg(t,r)}function ai(t,r){return{id:t,type:"select",selected:r}}function Gi(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(ai(u.id,c)))}return s}function Jh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function ep(t){return{id:t.id,type:"remove"}}const z_=gg();function D_(t,r,o={}){return _1(t,r,{...o,onError:o.onError??z_})}const tp=t=>s1(t),O_=t=>cg(t);function Bg(t){return L.forwardRef(t)}const Vg=typeof window<"u"?L.useLayoutEffect:L.useEffect;function np(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>F_(()=>o(a=>a+BigInt(1))));return Vg(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function F_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Wg=L.createContext(null);function H_({children:t}){const r=Ye(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:y,hasDefaultNodes:x,onNodesChange:v,nodeLookup:m,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let j=p;for(const E of h)j=typeof E=="function"?E(j):E;let b=Jh({items:j,lookup:m});for(const E of k.values())b=E(b);x&&y(j),b.length>0?v==null||v(b):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:R,setNodes:w}=r.getState();E&&w(R)})},[]),s=np(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:y,hasDefaultEdges:x,onEdgesChange:v,edgeLookup:m}=r.getState();let _=p;for(const k of h)_=typeof k=="function"?k(_):k;x?y(_):v&&v(Jh({items:_,lookup:m}))},[]),u=np(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Wg.Provider,{value:c,children:t})}function B_(){const t=L.useContext(Wg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const V_=t=>!!t.panZoom;function ra(){const t=T_(),r=Ye(),o=B_(),s=De(V_),a=L.useMemo(()=>{const u=v=>r.getState().nodeLookup.get(v),c=v=>{o.nodeQueue.push(v)},h=v=>{o.edgeQueue.push(v)},p=v=>{var E,R;const{nodeLookup:m,nodeOrigin:_}=r.getState(),k=tp(v)?v:m.get(v.id),j=k.parentId?yg(k.position,k.measured,k.parentId,m,_):k.position,b={...k,position:j,width:((E=k.measured)==null?void 0:E.width)??k.width,height:((R=k.measured)==null?void 0:R.height)??k.height};return ss(b)},y=(v,m,_={replace:!1})=>{c(k=>k.map(j=>{if(j.id===v){const b=typeof m=="function"?m(j):m;return _.replace&&tp(b)?b:{...j,...b}}return j}))},x=(v,m,_={replace:!1})=>{h(k=>k.map(j=>{if(j.id===v){const b=typeof m=="function"?m(j):m;return _.replace&&O_(b)?b:{...j,...b}}return j}))};return{getNodes:()=>r.getState().nodes.map(v=>({...v})),getNode:v=>{var m;return(m=u(v))==null?void 0:m.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:v=[]}=r.getState();return v.map(m=>({...m}))},getEdge:v=>r.getState().edgeLookup.get(v),setNodes:c,setEdges:h,addNodes:v=>{const m=Array.isArray(v)?v:[v];o.nodeQueue.push(_=>[..._,...m])},addEdges:v=>{const m=Array.isArray(v)?v:[v];o.edgeQueue.push(_=>[..._,...m])},toObject:()=>{const{nodes:v=[],edges:m=[],transform:_}=r.getState(),[k,j,b]=_;return{nodes:v.map(E=>({...E})),edges:m.map(E=>({...E})),viewport:{x:k,y:j,zoom:b}}},deleteElements:async({nodes:v=[],edges:m=[]})=>{const{nodes:_,edges:k,onNodesDelete:j,onEdgesDelete:b,triggerNodeChanges:E,triggerEdgeChanges:R,onDelete:w,onBeforeDelete:N}=r.getState(),{nodes:A,edges:$}=await d1({nodesToRemove:v,edgesToRemove:m,nodes:_,edges:k,onBeforeDelete:N}),F=$.length>0,G=A.length>0;if(F){const q=$.map(ep);b==null||b($),R(q)}if(G){const q=A.map(ep);j==null||j(A),E(q)}return(G||F)&&(w==null||w({nodes:A,edges:$})),{deletedNodes:A,deletedEdges:$}},getIntersectingNodes:(v,m=!0,_)=>{const k=bh(v),j=k?v:p(v),b=_!==void 0;return j?(_||r.getState().nodes).filter(E=>{const R=r.getState().nodeLookup.get(E.id);if(R&&!k&&(E.id===v.id||!R.internals.positionAbsolute))return!1;const w=ss(b?E:R),N=Bl(w,j);return m&&N>0||N>=w.width*w.height||N>=j.width*j.height}):[]},isNodeIntersecting:(v,m,_=!0)=>{const j=bh(v)?v:p(v);if(!j)return!1;const b=Bl(j,m);return _&&b>0||b>=m.width*m.height||b>=j.width*j.height},updateNode:y,updateNodeData:(v,m,_={replace:!1})=>{y(v,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},updateEdge:x,updateEdgeData:(v,m,_={replace:!1})=>{x(v,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},getNodesBounds:v=>{const{nodeLookup:m,nodeOrigin:_}=r.getState();return l1(v,{nodeLookup:m,nodeOrigin:_})},getHandleConnections:({type:v,id:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${v}${m?`-${m}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:v,handleId:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${v?m?`-${v}-${m}`:`-${v}`:""}`))==null?void 0:k.values())??[])},fitView:async v=>{const m=r.getState().fitViewResolver??p1();return r.setState({fitViewQueued:!0,fitViewOptions:v,fitViewResolver:m}),o.nodeQueue.push(_=>[..._]),m.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const rp=t=>t.selected,W_=typeof window<"u"?window:void 0;function U_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ye(),{deleteElements:s}=ra(),a=as(t,{actInsideInputWithModifier:!1}),u=as(r,{target:W_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(rp),edges:c.filter(rp)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function Y_(t){const r=Ye();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=Ec(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",mn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const ia={position:"absolute",width:"100%",height:"100%",top:0,left:0},G_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function X_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=di.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:y,translateExtent:x,minZoom:v,maxZoom:m,zoomActivationKeyCode:_,preventScrolling:k=!0,children:j,noWheelClassName:b,noPanClassName:E,onViewportChange:R,isControlledViewport:w,paneClickDistance:N,selectionOnDrag:A}){const $=Ye(),F=L.useRef(null),{userSelectionActive:G,lib:q,connectionInProgress:te}=De(G_,Qe),ee=as(_),ne=L.useRef();Y_(F);const K=L.useCallback(C=>{R==null||R({x:C[0],y:C[1],zoom:C[2]}),w||$.setState({transform:C})},[R,w]);return L.useEffect(()=>{if(F.current){ne.current=Q1({domNode:F.current,minZoom:v,maxZoom:m,translateExtent:x,viewport:y,onDraggingChange:U=>$.setState(M=>M.paneDragging===U?M:{paneDragging:U}),onPanZoomStart:(U,M)=>{const{onViewportChangeStart:D,onMoveStart:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoom:(U,M)=>{const{onViewportChange:D,onMove:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoomEnd:(U,M)=>{const{onViewportChangeEnd:D,onMoveEnd:H}=$.getState();H==null||H(U,M),D==null||D(M)}});const{x:C,y:V,zoom:W}=ne.current.getViewport();return $.setState({panZoom:ne.current,transform:[C,V,W],domNode:F.current.closest(".react-flow")}),()=>{var U;(U=ne.current)==null||U.destroy()}}},[]),L.useEffect(()=>{var C;(C=ne.current)==null||C.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:ee,preventScrolling:k,noPanClassName:E,userSelectionActive:G,noWheelClassName:b,lib:q,onTransformChange:K,connectionInProgress:te,selectionOnDrag:A,paneClickDistance:N})},[t,r,o,s,a,u,c,h,p,ee,k,E,G,b,q,K,te,A,N]),d.jsx("div",{className:"react-flow__renderer",ref:F,style:ia,children:j})}const q_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function K_(){const{userSelectionActive:t,userSelectionRect:r}=De(q_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const Ku=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},Q_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function Z_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=is.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:y,onPaneContextMenu:x,onPaneScroll:v,onPaneMouseEnter:m,onPaneMouseMove:_,onPaneMouseLeave:k,children:j}){const b=L.useRef(0),E=Ye(),{userSelectionActive:R,elementsSelectable:w,dragging:N,panBy:A,autoPanSpeed:$}=De(Q_,Qe),F=w&&(t||R),G=L.useRef(null),q=L.useRef(),te=L.useRef(new Set),ee=L.useRef(new Set),ne=L.useRef(!1),K=L.useRef(!1),C=L.useRef({x:0,y:0}),V=L.useRef(!1),W=Z=>{if(K.current||ne.current||E.getState().connection.inProgress){K.current=!1,ne.current=!1;return}y==null||y(Z),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},U=Z=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Z.preventDefault();return}x==null||x(Z)},M=v?Z=>v(Z):void 0,D=Z=>{K.current&&(Z.stopPropagation(),K.current=!1)},H=Z=>{var $e,st;if(Z.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:se,transform:me}=E.getState();if(q.current=se==null?void 0:se.getBoundingClientRect(),!q.current)return;const ke=Z.target===G.current;if(!ke&&!!Z.target.closest(".nokey")||!t||!(c&&ke||r)||Z.button!==0||!Z.isPrimary)return;(st=($e=Z.target)==null?void 0:$e.setPointerCapture)==null||st.call($e,Z.pointerId),K.current=!1;const{x:Ne,y:Me}=gn(Z.nativeEvent,q.current),Te=ms({x:Ne,y:Me},me);E.setState({userSelectionRect:{width:0,height:0,startX:Te.x,startY:Te.y,x:Ne,y:Me}}),ke||(Z.stopPropagation(),Z.preventDefault())};function I(Z,se){const{userSelectionRect:me}=E.getState();if(!me)return;const{transform:ke,nodeLookup:ve,edgeLookup:re,connectionLookup:Ne,triggerNodeChanges:Me,triggerEdgeChanges:Te,defaultEdgeOptions:$e}=E.getState(),st={x:me.startX,y:me.startY},{x:lt,y:at}=eo(st,ke),Ge={startX:st.x,startY:st.y,x:Zmt.id)),ee.current=new Set;const gt=($e==null?void 0:$e.selectable)??!0;for(const mt of te.current){const Pt=Ne.get(mt);if(Pt)for(const{edgeId:ut}of Pt.values()){const Je=re.get(ut);Je&&(Je.selectable??gt)&&ee.current.add(ut)}}if(!Eh(wt,te.current)){const mt=Gi(ve,te.current,!0);Me(mt)}if(!Eh(qt,ee.current)){const mt=Gi(re,ee.current);Te(mt)}E.setState({userSelectionRect:Ge,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!a||!q.current)return;const[Z,se]=jc(C.current,q.current,$);A({x:Z,y:se}).then(me=>{if(!K.current||!me){b.current=requestAnimationFrame(z);return}const{x:ke,y:ve}=C.current;I(ke,ve),b.current=requestAnimationFrame(z)})}const ie=()=>{cancelAnimationFrame(b.current),b.current=0,V.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=Z=>{const{userSelectionRect:se,transform:me,resetSelectedElements:ke}=E.getState();if(!q.current||!se)return;const{x:ve,y:re}=gn(Z.nativeEvent,q.current);C.current={x:ve,y:re};const Ne=eo({x:se.startX,y:se.startY},me);if(!K.current){const Me=r?0:u;if(Math.hypot(ve-Ne.x,re-Ne.y)<=Me)return;ke(),h==null||h(Z)}K.current=!0,V.current||(z(),V.current=!0),I(ve,re)},fe=Z=>{var se,me;if(!F){Z.target===G.current&&E.getState().connection.inProgress&&(ne.current=!0);return}Z.button===0&&((me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),!R&&Z.target===G.current&&E.getState().userSelectionRect&&(W==null||W(Z)),E.setState({userSelectionActive:!1,userSelectionRect:null}),K.current&&(p==null||p(Z),E.setState({nodesSelectionActive:te.current.size>0})),ie())},he=Z=>{var se,me;(me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),ie()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:nt(["react-flow__pane",{draggable:pe,dragging:N,selection:t}]),onClick:F?void 0:Ku(W,G),onContextMenu:Ku(U,G),onWheel:Ku(M,G),onPointerEnter:F?void 0:m,onPointerMove:F?oe:_,onPointerUp:fe,onPointerCancel:F?he:void 0,onPointerDownCapture:F?H:void 0,onClickCapture:F?D:void 0,onPointerLeave:k,ref:G,style:ia,children:[j,d.jsx(K_,{})]})}function pc({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),y=h.get(t);if(!y){p==null||p("012",mn.error012(t));return}r.setState({nodesSelectionActive:!1}),y.selected?(o||y.selected&&c)&&(u({nodes:[y],edges:[]}),requestAnimationFrame(()=>{var x;return(x=s==null?void 0:s.current)==null?void 0:x.blur()})):a([t])}function Ug({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ye(),[p,y]=L.useState(!1),x=L.useRef();return L.useEffect(()=>{if(!r)return x.current=z1({getStoreItems:()=>h.getState(),onNodeMouseDown:v=>{pc({id:v,store:h,nodeRef:t})},onDragStart:()=>{y(!0)},onDragStop:()=>{y(!1)}}),()=>{var v;(v=x.current)==null||v.destroy(),x.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!x.current||x.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const J_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Yg(){const t=Ye();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:y,nodeOrigin:x}=t.getState(),v=new Map,m=J_(c),_=a?u[0]:5,k=a?u[1]:5,j=o.direction.x*_*o.factor,b=o.direction.y*k*o.factor;for(const[,E]of y){if(!m(E))continue;let R={x:E.internals.positionAbsolute.x+j,y:E.internals.positionAbsolute.y+b};a&&(R=gs(R,u));const{position:w,positionAbsolute:N}=dg({nodeId:E.id,nextPosition:R,nodeLookup:y,nodeExtent:s,nodeOrigin:x,onError:h});E.position=w,E.internals.positionAbsolute=N,v.set(E.id,E)}p(v)},[])}const Tc=L.createContext(null),eS=Tc.Provider;Tc.Consumer;const Gg=()=>L.useContext(Tc),tS=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Xg=L.createContext(null);function nS({children:t}){const r=De(tS,Qe);return d.jsx(Xg.Provider,{value:r,children:t})}function rS(){const t=L.useContext(Xg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const iS={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},oS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:y}=c;if(!h&&!a)return iS;const x=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:x,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Zi.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:x&&y}};function sS({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:y,onMouseDown:x,onTouchStart:v,...m},_){var V,W;const k=c||null,j=t==="target",b=Ye(),E=Gg(),{connectOnClick:R,noPanClassName:w,rfId:N}=rS(),{connectingFrom:A,connectingTo:$,clickConnecting:F,isPossibleEndHandle:G,connectionInProcess:q,clickConnectionInProcess:te,valid:ee}=De(oS(E,k,t),Qe);E||(W=(V=b.getState()).onError)==null||W.call(V,"010",mn.error010());const ne=U=>{const{defaultEdgeOptions:M,onConnect:D,hasDefaultEdges:H}=b.getState(),I={...M,...U};if(H){const{edges:z,setEdges:ie,onError:oe}=b.getState();ie(D_(I,z,{onError:oe}))}D==null||D(I),h==null||h(I)},K=U=>{if(!E)return;const M=wg(U.nativeEvent);if(a&&(M&&U.button===0||!M)){const D=b.getState();hc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:j,handleId:k,nodeId:E,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...H)=>{var I,z;return(z=(I=b.getState()).onConnectEnd)==null?void 0:z.call(I,...H)},updateConnection:D.updateConnection,onConnect:ne,isValidConnection:o||((...H)=>{var I,z;return((z=(I=b.getState()).isValidConnection)==null?void 0:z.call(I,...H))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}M?x==null||x(U):v==null||v(U)},C=U=>{const{onClickConnectStart:M,onClickConnectEnd:D,connectionClickStartHandle:H,connectionMode:I,isValidConnection:z,lib:ie,rfId:oe,nodeLookup:fe,connection:he}=b.getState();if(!E||!H&&!a)return;if(!H){M==null||M(U.nativeEvent,{nodeId:E,handleId:k,handleType:t}),b.setState({connectionClickStartHandle:{nodeId:E,type:t,id:k}});return}const pe=vg(U.target),Z=o||z,{connection:se,isValid:me}=hc.isValid(U.nativeEvent,{handle:{nodeId:E,id:k,type:t},connectionMode:I,fromNodeId:H.nodeId,fromHandleId:H.id||null,fromType:H.type,isValidConnection:Z,flowId:oe,doc:pe,lib:ie,nodeLookup:fe});me&&se&&ne(se);const ke=structuredClone(he);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,D==null||D(U,ke),b.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":k,"data-nodeid":E,"data-handlepos":r,"data-id":`${N}-${E}-${k}-${t}`,className:nt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",w,y,{source:!j,target:j,connectable:s,connectablestart:a,connectableend:u,clickconnecting:F,connectingfrom:A,connectingto:$,valid:ee,connectionindicator:s&&(!q||G)&&(q||te?u:a)}]),onMouseDown:K,onTouchStart:K,onClick:R?C:void 0,ref:_,...m,children:p})}const no=L.memo(Bg(sS));function lS({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(no,{type:"source",position:o,isConnectable:r})]})}function aS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:s=Se.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(no,{type:"source",position:s,isConnectable:r})]})}function uS(){return null}function cS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const Wl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},ip={input:lS,default:aS,output:cS,group:uS};function dS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const fS=t=>{const{width:r,height:o,x:s,y:a}=ps(t.nodeLookup,{filter:u=>!!u.selected});return{width:pn(r)?r:null,height:pn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function hS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ye(),{width:a,height:u,transformString:c,userSelectionActive:h}=De(fS,Qe),p=Yg(),y=L.useRef(null);L.useEffect(()=>{var _;o||(_=y.current)==null||_.focus({preventScroll:!0})},[o]);const x=!h&&a!==null&&u!==null;if(Ug({nodeRef:y,disabled:!x}),!x)return null;const v=t?_=>{const k=s.getState().nodes.filter(j=>j.selected);t(_,k)}:void 0,m=_=>{Object.prototype.hasOwnProperty.call(Wl,_.key)&&(_.preventDefault(),p({direction:Wl[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:nt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:y,className:"react-flow__nodesselection-rect",onContextMenu:v,tabIndex:o?void 0:-1,onKeyDown:o?void 0:m,style:{width:a,height:u}})})}const op=typeof window<"u"?window:void 0,pS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function qg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:y,selectionOnDrag:x,selectionMode:v,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:j,zoomActivationKeyCode:b,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:N,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:G,autoPanOnSelection:q,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,preventScrolling:C,onSelectionContextMenu:V,noWheelClassName:W,noPanClassName:U,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:H}){const{nodesSelectionActive:I,userSelectionActive:z}=De(pS,Qe),ie=as(y,{target:op}),oe=as(j,{target:op}),fe=oe||G,he=oe||N,pe=x&&fe!==!0,Z=ie||z||pe;return U_({deleteKeyCode:p,multiSelectionKeyCode:k}),d.jsx(X_,{onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:!ie&&fe,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,zoomActivationKeyCode:b,preventScrolling:C,noWheelClassName:W,noPanClassName:U,onViewportChange:D,isControlledViewport:H,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(Z_,{onSelectionStart:m,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:q,isSelecting:!!Z,selectionMode:v,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:pe,children:[t,I&&d.jsx(hS,{onSelectionContextMenu:V,noPanClassName:U,disableKeyboardA11y:M})]})})}qg.displayName="FlowRenderer";const gS=L.memo(qg),mS=t=>r=>t?Nc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function yS(t){return De(L.useCallback(mS(t),[t]),Qe)}const vS=t=>t.updateNodeInternals;function xS(){const t=De(vS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function wS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ye(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),y=L.useRef(r),x=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!x||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[x,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const v=y.current!==r,m=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(v||m||_)&&(y.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function _S({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:y,nodesFocusable:x,resizeObserver:v,noDragClassName:m,noPanClassName:_,disableKeyboardA11y:k,rfId:j,nodeTypes:b,nodeClickDistance:E,onError:R}){const{node:w,internals:N,isParent:A}=De(Z=>{const se=Z.nodeLookup.get(t),me=Z.parentLookup.has(t);return{node:se,internals:se.internals,isParent:me}},Qe);let $=w.type||"default",F=(b==null?void 0:b[$])||ip[$];F===void 0&&(R==null||R("003",mn.error003($)),$="default",F=(b==null?void 0:b.default)||ip.default);const G=!!(w.draggable||h&&typeof w.draggable>"u"),q=!!(w.selectable||p&&typeof w.selectable>"u"),te=!!(w.connectable||y&&typeof w.connectable>"u"),ee=!!(w.focusable||x&&typeof w.focusable>"u"),ne=Ye(),K=mg(w),C=wS({node:w,nodeType:$,hasDimensions:K,resizeObserver:v}),V=Ug({nodeRef:C,disabled:w.hidden||!G,noDragClassName:m,handleSelector:w.dragHandle,nodeId:t,isSelectable:q,nodeClickDistance:E}),W=Yg();if(w.hidden)return null;const U=vn(w),M=dS(w),D=q||G||r||o||s||a,H=o?Z=>o(Z,{...N.userNode}):void 0,I=s?Z=>s(Z,{...N.userNode}):void 0,z=a?Z=>a(Z,{...N.userNode}):void 0,ie=u?Z=>u(Z,{...N.userNode}):void 0,oe=c?Z=>c(Z,{...N.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:se,nodeDragThreshold:me}=ne.getState();q&&(!se||!G||me>0)&&pc({id:t,store:ne,nodeRef:C}),r&&r(Z,{...N.userNode})},he=Z=>{if(!(xg(Z.nativeEvent)||k)){if(sg.includes(Z.key)&&q){const se=Z.key==="Escape";pc({id:t,store:ne,unselect:se,nodeRef:C})}else if(G&&w.selected&&Object.prototype.hasOwnProperty.call(Wl,Z.key)){Z.preventDefault();const{ariaLabelConfig:se}=ne.getState();ne.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),W({direction:Wl[Z.key],factor:Z.shiftKey?4:1})}}},pe=()=>{var Ne;if(k||!((Ne=C.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:Z,width:se,height:me,autoPanOnNodeFocus:ke,setCenter:ve}=ne.getState();if(!ke)return;Nc(new Map([[t,w]]),{x:0,y:0,width:se,height:me},Z,!0).length>0||ve(w.position.x+U.width/2,w.position.y+U.height/2,{zoom:Z[2]})};return d.jsx("div",{className:nt(["react-flow__node",`react-flow__node-${$}`,{[_]:G},w.className,{selected:w.selected,selectable:q,parent:A,draggable:G,dragging:V}]),ref:C,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:K?"visible":"hidden",...w.style,...M},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:H,onMouseMove:I,onMouseLeave:z,onContextMenu:ie,onClick:fe,onDoubleClick:oe,onKeyDown:ee?he:void 0,tabIndex:ee?0:void 0,onFocus:ee?pe:void 0,role:w.ariaRole??(ee?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${Dg}-${j}`,"aria-label":w.ariaLabel,...w.domAttributes,children:d.jsx(eS,{value:t,children:d.jsx(F,{id:t,data:w.data,type:$,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:w.selected??!1,selectable:q,draggable:G,deletable:w.deletable??!0,isConnectable:te,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:V,dragHandle:w.dragHandle,zIndex:N.z,parentId:w.parentId,...U})})})}var SS=L.memo(_S);const kS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Kg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=De(kS,Qe),u=yS(t.onlyRenderVisibleElements),c=xS();return d.jsx("div",{className:"react-flow__nodes",style:ia,children:u.map(h=>d.jsx(SS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Kg.displayName="NodeRenderer";const NS=L.memo(Kg);function jS(t){return De(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&v1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const bS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},ES=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},sp={[os.Arrow]:bS,[os.ArrowClosed]:ES};function CS(t){const r=Ye();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(sp,t)?sp[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",mn.error009(t)),null)},[t])}const MS=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=CS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},Qg=({defaultColor:t,rfId:r})=>{const o=De(u=>u.edges),s=De(u=>u.defaultEdgeOptions),a=L.useMemo(()=>b1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(MS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Qg.displayName="MarkerDefinitions";var PS=L.memo(Qg);function Zg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:y,...x}){const[v,m]=L.useState({x:1,y:0,width:0,height:0}),_=nt(["react-flow__edge-textwrapper",y]),k=L.useRef(null);return L.useEffect(()=>{if(k.current){const j=k.current.getBBox();m({x:j.x,y:j.y,width:j.width,height:j.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-v.width/2} ${r-v.height/2})`,className:_,visibility:v.width?"visible":"hidden",...x,children:[a&&d.jsx("rect",{width:v.width+2*c[0],x:-c[0],y:-c[1],height:v.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:v.height/2,dy:"0.3em",ref:k,style:s,children:o}),p]}):null}Zg.displayName="EdgeText";const IS=L.memo(Zg);function ys({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:y=20,...x}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...x,d:t,fill:"none",className:nt(["react-flow__edge-path",x.className])}),y?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:y,className:"react-flow__edge-interaction"}):null,s&&pn(r)&&pn(o)?d.jsx(IS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function lp({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function Jg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top}){const[c,h]=lp({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,y]=lp({pos:u,x1:s,y1:a,x2:t,y2:r}),[x,v,m,_]=_g({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:y});return[`M${t},${r} C${c},${h} ${p},${y} ${s},${a}`,x,v,m,_]}function em(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})=>{const[R,w,N]=Jg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),A=t.isInternal?void 0:r;return d.jsx(ys,{id:A,path:R,labelX:w,labelY:N,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})})}const RS=em({isInternal:!1}),tm=em({isInternal:!0});RS.displayName="SimpleBezierEdge";tm.displayName="SimpleBezierEdgeInternal";function nm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,sourcePosition:_=Se.Bottom,targetPosition:k=Se.Top,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=Vl({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),$=t.isInternal?void 0:r;return d.jsx(ys,{id:$,path:w,labelX:N,labelY:A,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,markerEnd:j,markerStart:b,interactionWidth:R})})}const rm=nm({isInternal:!1}),im=nm({isInternal:!0});rm.displayName="SmoothStepEdge";im.displayName="SmoothStepEdgeInternal";function om(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(rm,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const TS=om({isInternal:!1}),sm=om({isInternal:!0});TS.displayName="StepEdge";sm.displayName="StepEdgeInternal";function lm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,markerEnd:_,markerStart:k,interactionWidth:j})=>{const[b,E,R]=Ng({sourceX:o,sourceY:s,targetX:a,targetY:u}),w=t.isInternal?void 0:r;return d.jsx(ys,{id:w,path:b,labelX:E,labelY:R,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,markerEnd:_,markerStart:k,interactionWidth:j})})}const LS=lm({isInternal:!1}),am=lm({isInternal:!0});LS.displayName="StraightEdge";am.displayName="StraightEdgeInternal";function um(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=Sg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:E==null?void 0:E.curvature}),$=t.isInternal?void 0:r;return d.jsx(ys,{id:$,path:w,labelX:N,labelY:A,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:R})})}const AS=um({isInternal:!1}),cm=um({isInternal:!0});AS.displayName="BezierEdge";cm.displayName="BezierEdgeInternal";const ap={default:cm,straight:am,step:sm,smoothstep:im,simplebezier:tm},up={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},$S=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,zS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,cp="react-flow__edgeupdater";function dp({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:nt([cp,`${cp}-${h}`]),cx:$S(r,s,t),cy:zS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function DS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:y,onReconnectStart:x,onReconnectEnd:v,setReconnecting:m,setUpdateHover:_}){const k=Ye(),j=(N,A)=>{if(N.button!==0)return;const{autoPanOnConnect:$,domNode:F,connectionMode:G,connectionRadius:q,lib:te,onConnectStart:ee,cancelConnection:ne,nodeLookup:K,rfId:C,panBy:V,updateConnection:W}=k.getState(),U=A.type==="target",M=(I,z)=>{m(!1),v==null||v(I,o,A.type,z)},D=I=>y==null?void 0:y(o,I),H=(I,z)=>{m(!0),x==null||x(N,o,A.type),ee==null||ee(I,z)};hc.onPointerDown(N.nativeEvent,{autoPanOnConnect:$,connectionMode:G,connectionRadius:q,domNode:F,handleId:A.id,nodeId:A.nodeId,nodeLookup:K,isTarget:U,edgeUpdaterType:A.type,lib:te,flowId:C,cancelConnection:ne,panBy:V,isValidConnection:(...I)=>{var z,ie;return((ie=(z=k.getState()).isValidConnection)==null?void 0:ie.call(z,...I))??!0},onConnect:D,onConnectStart:H,onConnectEnd:(...I)=>{var z,ie;return(ie=(z=k.getState()).onConnectEnd)==null?void 0:ie.call(z,...I)},onReconnectEnd:M,updateConnection:W,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:N.currentTarget})},b=N=>j(N,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),E=N=>j(N,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),R=()=>_(!0),w=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(dp,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:b,onMouseEnter:R,onMouseOut:w,type:"source"}),(t===!0||t==="target")&&d.jsx(dp,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:E,onMouseEnter:R,onMouseOut:w,type:"target"})]})}function OS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,reconnectRadius:x,onReconnect:v,onReconnectStart:m,onReconnectEnd:_,rfId:k,edgeTypes:j,noPanClassName:b,onError:E,disableKeyboardA11y:R}){let w=De(ve=>ve.edgeLookup.get(t));const N=De(ve=>ve.defaultEdgeOptions);w=N?{...N,...w}:w;let A=w.type||"default",$=(j==null?void 0:j[A])||ap[A];$===void 0&&(E==null||E("011",mn.error011(A)),A="default",$=(j==null?void 0:j.default)||ap.default);const F=!!(w.focusable||r&&typeof w.focusable>"u"),G=typeof v<"u"&&(w.reconnectable||o&&typeof w.reconnectable>"u"),q=!!(w.selectable||s&&typeof w.selectable>"u"),te=L.useRef(null),[ee,ne]=L.useState(!1),[K,C]=L.useState(!1),V=Ye(),{zIndex:W=w.zIndex,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z}=De(L.useCallback(ve=>{const re=ve.nodeLookup.get(w.source),Ne=ve.nodeLookup.get(w.target);if(!re||!Ne)return up;const Me=j1({id:t,sourceNode:re,targetNode:Ne,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:ve.connectionMode,onError:E}),Te=y1({selected:w.selected,zIndex:w.zIndex,sourceNode:re,targetNode:Ne,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Me||up,zIndex:Te}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex,E]),Qe),ie=L.useMemo(()=>w.markerStart?`url('#${dc(w.markerStart,k)}')`:void 0,[w.markerStart,k]),oe=L.useMemo(()=>w.markerEnd?`url('#${dc(w.markerEnd,k)}')`:void 0,[w.markerEnd,k]);if(w.hidden||U===null||M===null||D===null||H===null)return null;const fe=ve=>{var Te;const{addSelectedEdges:re,unselectNodesAndEdges:Ne,multiSelectionActive:Me}=V.getState();q&&(V.setState({nodesSelectionActive:!1}),w.selected&&Me?(Ne({nodes:[],edges:[w]}),(Te=te.current)==null||Te.blur()):re([t])),a&&a(ve,w)},he=u?ve=>{u(ve,{...w})}:void 0,pe=c?ve=>{c(ve,{...w})}:void 0,Z=h?ve=>{h(ve,{...w})}:void 0,se=p?ve=>{p(ve,{...w})}:void 0,me=y?ve=>{y(ve,{...w})}:void 0,ke=ve=>{var re;if(!R&&sg.includes(ve.key)&&q){const{unselectNodesAndEdges:Ne,addSelectedEdges:Me}=V.getState();ve.key==="Escape"?((re=te.current)==null||re.blur(),Ne({edges:[w]})):Me([t])}};return d.jsx("svg",{style:{zIndex:W},children:d.jsxs("g",{className:nt(["react-flow__edge",`react-flow__edge-${A}`,w.className,b,{selected:w.selected,animated:w.animated,inactive:!q&&!a,updating:ee,selectable:q}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:Z,onMouseMove:se,onMouseLeave:me,onKeyDown:F?ke:void 0,tabIndex:F?0:void 0,role:w.ariaRole??(F?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":F?`${Og}-${k}`:void 0,ref:te,...w.domAttributes,children:[!K&&d.jsx($,{id:t,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:q,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),G&&d.jsx(DS,{edge:w,isReconnectable:G,reconnectRadius:x,onReconnect:v,onReconnectStart:m,onReconnectEnd:_,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,setUpdateHover:ne,setReconnecting:C})]})})}var FS=L.memo(OS);const HS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function dm({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:y,onEdgeClick:x,reconnectRadius:v,onEdgeDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:j}){const{edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,onError:w}=De(HS,Qe),N=jS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(PS,{defaultColor:t,rfId:o}),N.map(A=>d.jsx(FS,{id:A,edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,onClick:x,reconnectRadius:v,onDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:w,edgeTypes:s,disableKeyboardA11y:j},A))]})}dm.displayName="EdgeRenderer";const BS=L.memo(dm),fp=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function VS({children:t}){const r=Ye(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return Vg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=fp(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:fp(s)},children:t})}function WS(t){const r=ra(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const US=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function YS(t){const r=De(US),o=Ye();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function GS(t){return t.connection.inProgress?{...t.connection,to:ms(t.connection.to,t.transform)}:{...t.connection}}function XS(t){return GS}function qS(t){const r=XS();return De(r,Qe)}const KS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function QS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=De(KS,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:nt(["react-flow__connection",ug(h)]),children:d.jsx(fm,{style:r,type:o,CustomComponent:s,isValid:h})})})}const fm=({style:t,type:r=Lr.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:y,toNode:x,toHandle:v,toPosition:m,pointer:_}=qS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:y.x,toY:y.y,fromPosition:p,toPosition:m,connectionStatus:ug(s),toNode:x,toHandle:v,pointer:_});let k="";const j={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:y.x,targetY:y.y,targetPosition:m};switch(r){case Lr.Bezier:[k]=Sg(j);break;case Lr.SimpleBezier:[k]=Jg(j);break;case Lr.Step:[k]=Vl({...j,borderRadius:0});break;case Lr.SmoothStep:[k]=Vl(j);break;default:[k]=Ng(j)}return d.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};fm.displayName="ConnectionLine";const ZS={};function hp(t=ZS){L.useRef(t),Ye(),L.useEffect(()=>{},[t])}function JS(){Ye(),L.useRef(!1),L.useEffect(()=>{},[])}function hm({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:x,onSelectionContextMenu:v,onSelectionStart:m,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:j,connectionLineComponent:b,connectionLineContainerStyle:E,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,deleteKeyCode:G,onlyRenderVisibleElements:q,elementsSelectable:te,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,preventScrolling:V,defaultMarkerColor:W,zoomOnScroll:U,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,zoomOnDoubleClick:z,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneScroll:se,onPaneContextMenu:me,paneClickDistance:ke,nodeClickDistance:ve,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,viewport:ut,onViewportChange:Je,nodesDraggable:An}){return hp(t),hp(r),JS(),WS(o),YS(ut),d.jsx(gS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneContextMenu:me,onPaneScroll:se,paneClickDistance:ke,deleteKeyCode:G,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,elementsSelectable:te,zoomOnScroll:U,zoomOnPinch:M,zoomOnDoubleClick:z,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,onSelectionContextMenu:v,preventScrolling:V,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:qt,disableKeyboardA11y:gt,onViewportChange:Je,isControlledViewport:!!ut,children:d.jsxs(VS,{children:[d.jsx(BS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:st,onReconnectStart:lt,onReconnectEnd:at,onlyRenderVisibleElements:q,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Me,onEdgeMouseLeave:Te,reconnectRadius:$e,defaultMarkerColor:W,noPanClassName:qt,disableKeyboardA11y:gt,rfId:Pt}),d.jsx(QS,{style:j,type:k,component:b,containerStyle:E}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(NS,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:x,nodeClickDistance:ve,onlyRenderVisibleElements:q,noPanClassName:qt,noDragClassName:Ge,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Pt,nodesDraggable:An}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}hm.displayName="GraphView";const ek=L.memo(hm),tk=gg(),pp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:y=2,nodeOrigin:x,nodeExtent:v,zIndexMode:m="basic"}={})=>{const _=new Map,k=new Map,j=new Map,b=new Map,E=s??r??[],R=o??t??[],w=x??[0,0],N=v??rs;Eg(j,b,E);const{nodesInitialized:A}=fc(R,_,k,{nodeOrigin:w,nodeExtent:N,zIndexMode:m});let $=[0,0,1];if(c&&a&&u){const F=ps(_,{filter:ee=>!!((ee.width||ee.initialWidth)&&(ee.height||ee.initialHeight))}),{x:G,y:q,zoom:te}=bc(F,a,u,p,y,(h==null?void 0:h.padding)??.1);$=[G,q,te]}return{rfId:"1",width:a??0,height:u??0,transform:$,nodes:R,nodesInitialized:A,nodeLookup:_,parentLookup:k,edges:E,edgeLookup:b,connectionLookup:j,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:y,translateExtent:rs,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Zi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...ag},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:tk,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:lg,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},nk=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:x,nodeExtent:v,zIndexMode:m})=>p_((_,k)=>{async function j(){const{nodeLookup:b,panZoom:E,fitViewOptions:R,fitViewResolver:w,width:N,height:A,minZoom:$,maxZoom:F}=k();E&&(await c1({nodes:b,width:N,height:A,panZoom:E,minZoom:$,maxZoom:F},R),w==null||w.resolve(!0),_({fitViewResolver:null}))}return{...pp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:x,nodeExtent:v,defaultNodes:o,defaultEdges:s,zIndexMode:m}),setNodes:b=>{const{nodeLookup:E,parentLookup:R,nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,fitViewQueued:$,zIndexMode:F,nodesSelectionActive:G}=k(),{nodesInitialized:q,hasSelectedNodes:te}=fc(b,E,R,{nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:F}),ee=G&&te;$&&q?(j(),_({nodes:b,nodesInitialized:q,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:ee})):_({nodes:b,nodesInitialized:q,nodesSelectionActive:ee})},setEdges:b=>{const{connectionLookup:E,edgeLookup:R}=k();Eg(E,R,b),_({edges:b})},setDefaultNodesAndEdges:(b,E)=>{if(b){const{setNodes:R}=k();R(b),_({hasDefaultNodes:!0})}if(E){const{setEdges:R}=k();R(E),_({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:E,nodeLookup:R,parentLookup:w,domNode:N,nodeOrigin:A,nodeExtent:$,debug:F,fitViewQueued:G,zIndexMode:q}=k(),{changes:te,updatedInternals:ee}=T1(b,R,w,N,A,$,q);ee&&(M1(R,w,{nodeOrigin:A,nodeExtent:$,zIndexMode:q}),G?(j(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(te==null?void 0:te.length)>0&&(F&&console.log("React Flow: trigger node changes",te),E==null||E(te)))},updateNodePositions:(b,E=!1)=>{const R=[];let w=[];const{nodeLookup:N,triggerNodeChanges:A,connection:$,updateConnection:F,onNodesChangeMiddlewareMap:G}=k();for(const[q,te]of b){const ee=N.get(q),ne=!!(ee!=null&&ee.expandParent&&(ee!=null&&ee.parentId)&&(te!=null&&te.position)),K={id:q,type:"position",position:ne?{x:Math.max(0,te.position.x),y:Math.max(0,te.position.y)}:te.position,dragging:E};if(ee&&$.inProgress&&$.fromNode.id===ee.id){const C=mi(ee,$.fromHandle,Se.Left,!0);F({...$,from:C})}ne&&ee.parentId&&R.push({id:q,parentId:ee.parentId,rect:{...te.internals.positionAbsolute,width:te.measured.width??0,height:te.measured.height??0}}),w.push(K)}if(R.length>0){const{parentLookup:q,nodeOrigin:te}=k(),ee=Rc(R,N,q,te);w.push(...ee)}for(const q of G.values())w=q(w);A(w)},triggerNodeChanges:b=>{const{onNodesChange:E,setNodes:R,nodes:w,hasDefaultNodes:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=A_(b,w);R($)}A&&console.log("React Flow: trigger node changes",b),E==null||E(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:E,setEdges:R,edges:w,hasDefaultEdges:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=$_(b,w);R($)}A&&console.log("React Flow: trigger edge changes",b),E==null||E(b)}},addSelectedNodes:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));N($);return}N(Gi(w,new Set([...b]),!0)),A(Gi(R))},addSelectedEdges:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>ai(F,!0));A($);return}A(Gi(R,new Set([...b]))),N(Gi(w,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:E}={})=>{const{edges:R,nodes:w,nodeLookup:N,triggerNodeChanges:A,triggerEdgeChanges:$}=k(),F=b||w,G=E||R,q=[];for(const ee of F){if(!ee.selected)continue;const ne=N.get(ee.id);ne&&(ne.selected=!1),q.push(ai(ee.id,!1))}const te=[];for(const ee of G)ee.selected&&te.push(ai(ee.id,!1));A(q),$(te)},setMinZoom:b=>{const{panZoom:E,maxZoom:R}=k();E==null||E.setScaleExtent([b,R]),_({minZoom:b})},setMaxZoom:b=>{const{panZoom:E,minZoom:R}=k();E==null||E.setScaleExtent([R,b]),_({maxZoom:b})},setTranslateExtent:b=>{var E;(E=k().panZoom)==null||E.setTranslateExtent(b),_({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:E,triggerNodeChanges:R,triggerEdgeChanges:w,elementsSelectable:N}=k();if(!N)return;const A=E.reduce((F,G)=>G.selected?[...F,ai(G.id,!1)]:F,[]),$=b.reduce((F,G)=>G.selected?[...F,ai(G.id,!1)]:F,[]);R(A),w($)},setNodeExtent:b=>{const{nodes:E,nodeLookup:R,parentLookup:w,nodeOrigin:N,elevateNodesOnSelect:A,nodeExtent:$,zIndexMode:F}=k();b[0][0]===$[0][0]&&b[0][1]===$[0][1]&&b[1][0]===$[1][0]&&b[1][1]===$[1][1]||(fc(E,R,w,{nodeOrigin:N,nodeExtent:b,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:F}),_({nodeExtent:b}))},panBy:b=>{const{transform:E,width:R,height:w,panZoom:N,translateExtent:A}=k();return L1({delta:b,panZoom:N,transform:E,translateExtent:A,width:R,height:w})},setCenter:async(b,E,R)=>{const{width:w,height:N,maxZoom:A,panZoom:$}=k();if(!$)return!1;const F=typeof(R==null?void 0:R.zoom)<"u"?R.zoom:A;return await $.setViewport({x:w/2-b*F,y:N/2-E*F,zoom:F},{duration:R==null?void 0:R.duration,ease:R==null?void 0:R.ease,interpolate:R==null?void 0:R.interpolate}),!0},cancelConnection:()=>{_({connection:{...ag}})},updateConnection:b=>{_({connection:b})},reset:()=>_({...pp()})}},Object.is);function pm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:y,nodeOrigin:x,nodeExtent:v,zIndexMode:m,children:_}){const[k]=L.useState(()=>nk({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:y,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:x,nodeExtent:v,zIndexMode:m}));return d.jsx(g_,{value:k,children:d.jsx(H_,{children:d.jsx(nS,{children:_})})})}function rk({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:y,maxZoom:x,nodeOrigin:v,nodeExtent:m,zIndexMode:_}){return L.useContext(ta)?d.jsx(d.Fragment,{children:t}):d.jsx(pm,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:y,initialMaxZoom:x,nodeOrigin:v,nodeExtent:m,zIndexMode:_,children:t})}const ik={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function ok({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:y,onMove:x,onMoveStart:v,onMoveEnd:m,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,onNodeDragStart:F,onNodeDrag:G,onNodeDragStop:q,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onSelectionChange:K,onSelectionDragStart:C,onSelectionDrag:V,onSelectionDragStop:W,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:H,connectionMode:I,connectionLineType:z=Lr.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:Z=!1,selectionMode:se=is.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:ke=ls()?"Meta":"Control",zoomActivationKeyCode:ve=ls()?"Meta":"Control",snapToGrid:re,snapGrid:Ne,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Te,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,nodeOrigin:Ge=Fg,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt=!0,defaultViewport:mt=C_,minZoom:Pt=.5,maxZoom:ut=2,translateExtent:Je=rs,preventScrolling:An=!0,nodeExtent:Ot,defaultMarkerColor:xn="#b1b1b7",zoomOnScroll:oo=!0,zoomOnPinch:$n=!0,panOnScroll:vi=!1,panOnScrollSpeed:or=.5,panOnScrollMode:$r=di.Free,zoomOnDoubleClick:zn=!0,panOnDrag:zr=!0,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn=1,nodeClickDistance:Fn=0,children:_n,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn=10,onNodesChange:Ht,onEdgesChange:Or,noDragClassName:nn="nodrag",noWheelClassName:Fr="nowheel",noPanClassName:yt="nopan",fitView:Hn,fitViewOptions:ur,connectOnClick:so,attributionPosition:It,proOptions:Bn,defaultEdgeOptions:Hr,elevateNodesOnSelect:jn=!0,elevateEdgesOnSelect:Br=!1,disableKeyboardA11y:xi=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:lo,autoPanOnSelection:Vr=!0,autoPanSpeed:wi,connectionRadius:cr,isValidConnection:ao,onError:dr,style:Vn,id:bt,nodeDragThreshold:Wr,connectionDragThreshold:Et,viewport:uo,onViewportChange:Ur,width:Yr,height:Wn,colorMode:Un="light",debug:bn,onScroll:Bt,ariaLabelConfig:_i,zIndexMode:Gr="basic",...fr},hr){const Yn=bt||"1",En=R_(Un),co=L.useCallback(pr=>{pr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Bt==null||Bt(pr)},[Bt]);return d.jsx("div",{"data-testid":"rf__wrapper",...fr,onScroll:co,style:{...Vn,...ik},ref:hr,className:nt(["react-flow",a,En]),id:bt,role:"application",children:d.jsxs(rk,{nodes:t,edges:r,width:Yr,height:Wn,fitView:Hn,fitViewOptions:ur,minZoom:Pt,maxZoom:ut,nodeOrigin:Ge,nodeExtent:Ot,zIndexMode:Gr,children:[d.jsx(I_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,nodesDraggable:$e,autoPanOnNodeFocus:st,nodesConnectable:lt,nodesFocusable:at,edgesFocusable:wt,edgesReconnectable:qt,elementsSelectable:gt,elevateNodesOnSelect:jn,elevateEdgesOnSelect:Br,minZoom:Pt,maxZoom:ut,nodeExtent:Ot,onNodesChange:Ht,onEdgesChange:Or,snapToGrid:re,snapGrid:Ne,connectionMode:I,translateExtent:Je,connectOnClick:so,defaultEdgeOptions:Hr,fitView:Hn,fitViewOptions:ur,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onNodeDragStart:F,onNodeDrag:G,onNodeDragStop:q,onSelectionDrag:V,onSelectionDragStart:C,onSelectionDragStop:W,onMove:x,onMoveStart:v,onMoveEnd:m,noPanClassName:yt,nodeOrigin:Ge,rfId:Yn,autoPanOnConnect:Ve,autoPanOnNodeDrag:lo,autoPanSpeed:wi,onError:dr,connectionRadius:cr,isValidConnection:ao,selectNodesOnDrag:Te,nodeDragThreshold:Wr,connectionDragThreshold:Et,onBeforeDelete:H,debug:bn,ariaLabelConfig:_i,zIndexMode:Gr}),d.jsx(ek,{onInit:y,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,nodeTypes:u,edgeTypes:c,connectionLineType:z,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:Z,selectionMode:se,deleteKeyCode:he,multiSelectionKeyCode:ke,panActivationKeyCode:me,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Me,defaultViewport:mt,translateExtent:Je,minZoom:Pt,maxZoom:ut,preventScrolling:An,zoomOnScroll:oo,zoomOnPinch:$n,zoomOnDoubleClick:zn,panOnScroll:vi,panOnScrollSpeed:or,panOnScrollMode:$r,panOnDrag:zr,autoPanOnSelection:Vr,onPaneClick:sr,onPaneMouseEnter:lr,onPaneMouseMove:Ft,onPaneMouseLeave:ct,onPaneScroll:Dn,onPaneContextMenu:On,paneClickDistance:wn,nodeClickDistance:Fn,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onReconnect:rt,onReconnectStart:Dr,onReconnectEnd:_t,onEdgeContextMenu:ar,onEdgeDoubleClick:Sn,onEdgeMouseEnter:dt,onEdgeMouseMove:He,onEdgeMouseLeave:kn,reconnectRadius:Nn,defaultMarkerColor:xn,noDragClassName:nn,noWheelClassName:Fr,noPanClassName:yt,rfId:Yn,disableKeyboardA11y:xi,nodeExtent:Ot,viewport:uo,onViewportChange:Ur,nodesDraggable:$e}),d.jsx(E_,{onSelectionChange:K}),_n,d.jsx(S_,{proOptions:Bn,position:It}),d.jsx(__,{rfId:Yn,disableKeyboardA11y:xi})]})})}var sk=Bg(ok);function lk({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:nt(["react-flow__background-pattern",o,s])})}function ak({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:nt(["react-flow__background-pattern","dots",r])})}var Ar;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Ar||(Ar={}));const uk={[Ar.Dots]:1,[Ar.Lines]:1,[Ar.Cross]:6},ck=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function gm({id:t,variant:r=Ar.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:y,patternClassName:x}){const v=L.useRef(null),{transform:m,patternId:_}=De(ck,Qe),k=s||uk[r],j=r===Ar.Dots,b=r===Ar.Cross,E=Array.isArray(o)?o:[o,o],R=[E[0]*m[2]||1,E[1]*m[2]||1],w=k*m[2],N=Array.isArray(u)?u:[u,u],A=b?[w,w]:R,$=[N[0]*m[2]+A[0]/2,N[1]*m[2]+A[1]/2],F=`${_}${t||""}`;return d.jsxs("svg",{className:nt(["react-flow__background",y]),style:{...p,...ia,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:v,"data-testid":"rf__background",children:[d.jsx("pattern",{id:F,x:m[0]%R[0],y:m[1]%R[1],width:R[0],height:R[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:j?d.jsx(ak,{radius:w/2,className:x}):d.jsx(lk,{dimensions:A,lineWidth:a,variant:r,className:x})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${F})`})]})}gm.displayName="Background";const dk=L.memo(gm);function fk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function hk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function pk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 gk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 mk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 bl({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:nt(["react-flow__controls-button",r]),...o,children:t})}const yk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function mm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:y,children:x,position:v="bottom-left",orientation:m="vertical","aria-label":_}){const k=Ye(),{isInteractive:j,minZoomReached:b,maxZoomReached:E,ariaLabelConfig:R}=De(yk,Qe),{zoomIn:w,zoomOut:N,fitView:A}=ra(),$=()=>{w(),u==null||u()},F=()=>{N(),c==null||c()},G=()=>{A(a),h==null||h()},q=()=>{k.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),p==null||p(!j)},te=m==="horizontal"?"horizontal":"vertical";return d.jsxs(na,{className:nt(["react-flow__controls",te,y]),position:v,style:t,"data-testid":"rf__controls","aria-label":_??R["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(bl,{onClick:$,className:"react-flow__controls-zoomin",title:R["controls.zoomIn.ariaLabel"],"aria-label":R["controls.zoomIn.ariaLabel"],disabled:E,children:d.jsx(fk,{})}),d.jsx(bl,{onClick:F,className:"react-flow__controls-zoomout",title:R["controls.zoomOut.ariaLabel"],"aria-label":R["controls.zoomOut.ariaLabel"],disabled:b,children:d.jsx(hk,{})})]}),o&&d.jsx(bl,{className:"react-flow__controls-fitview",onClick:G,title:R["controls.fitView.ariaLabel"],"aria-label":R["controls.fitView.ariaLabel"],children:d.jsx(pk,{})}),s&&d.jsx(bl,{className:"react-flow__controls-interactive",onClick:q,title:R["controls.interactive.ariaLabel"],"aria-label":R["controls.interactive.ariaLabel"],children:j?d.jsx(mk,{}):d.jsx(gk,{})}),x]})}mm.displayName="Controls";const vk=L.memo(mm);function xk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:y,borderRadius:x,shapeRendering:v,selected:m,onClick:_}){const{background:k,backgroundColor:j}=u||{},b=c||k||j;return d.jsx("rect",{className:nt(["react-flow__minimap-node",{selected:m},y]),x:r,y:o,rx:x,ry:x,width:s,height:a,style:{fill:b,stroke:h,strokeWidth:p},shapeRendering:v,onClick:_?E=>_(E,t):void 0})}const wk=L.memo(xk),_k=t=>t.nodes.map(r=>r.id),Qu=t=>t instanceof Function?t:()=>t;function Sk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=wk,onClick:c}){const h=De(_k,Qe),p=Qu(r),y=Qu(t),x=Qu(o),v=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(m=>d.jsx(Nk,{id:m,nodeColorFunc:p,nodeStrokeColorFunc:y,nodeClassNameFunc:x,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:v},m))})}function kk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:y,x,y:v,width:m,height:_}=De(k=>{const j=k.nodeLookup.get(t);if(!j)return{node:void 0,x:0,y:0,width:0,height:0};const b=j.internals.userNode,{x:E,y:R}=j.internals.positionAbsolute,{width:w,height:N}=vn(b);return{node:b,x:E,y:R,width:w,height:N}},Qe);return!y||y.hidden||!mg(y)?null:d.jsx(h,{x,y:v,width:m,height:_,style:y.style,selected:!!y.selected,className:s(y),color:r(y),borderRadius:a,strokeColor:o(y),strokeWidth:u,shapeRendering:c,onClick:p,id:y.id})}const Nk=L.memo(kk);var jk=L.memo(Sk);const bk=200,Ek=150,Ck=t=>!t.hidden,Mk=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?hg(ps(t.nodeLookup,{filter:Ck}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},gp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,Pk=(t,r)=>gp(t.viewBB,r.viewBB)&&gp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,Ik="react-flow__minimap-desc";function ym({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:y,maskStrokeColor:x,maskStrokeWidth:v,position:m="bottom-right",onClick:_,onNodeClick:k,pannable:j=!1,zoomable:b=!1,ariaLabel:E,inversePan:R,zoomStep:w=1,offsetScale:N=5}){const A=Ye(),$=L.useRef(null),{boundingRect:F,viewBB:G,rfId:q,panZoom:te,translateExtent:ee,flowWidth:ne,flowHeight:K,ariaLabelConfig:C}=De(Mk,Pk),V=(t==null?void 0:t.width)??bk,W=(t==null?void 0:t.height)??Ek,U=F.width/V,M=F.height/W,D=Math.max(U,M),H=D*V,I=D*W,z=N*D,ie=F.x-(H-F.width)/2-z,oe=F.y-(I-F.height)/2-z,fe=H+z*2,he=I+z*2,pe=`${Ik}-${q}`,Z=L.useRef(0),se=L.useRef();Z.current=D,L.useEffect(()=>{if($.current&&te)return se.current=V1({domNode:$.current,panZoom:te,getTransform:()=>A.getState().transform,getViewScale:()=>Z.current}),()=>{var re;(re=se.current)==null||re.destroy()}},[te]),L.useEffect(()=>{var re;(re=se.current)==null||re.update({translateExtent:ee,width:ne,height:K,inversePan:R,pannable:j,zoomStep:w,zoomable:b})},[j,b,R,w,ee,ne,K]);const me=_?re=>{var Te;const[Ne,Me]=((Te=se.current)==null?void 0:Te.pointer(re))||[0,0];_(re,{x:Ne,y:Me})}:void 0,ke=k?L.useCallback((re,Ne)=>{const Me=A.getState().nodeLookup.get(Ne).internals.userNode;k(re,Me)},[]):void 0,ve=E??C["minimap.ariaLabel"];return d.jsx(na,{position:m,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof y=="string"?y:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof v=="number"?v*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:nt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:V,height:W,viewBox:`${ie} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:$,onClick:me,children:[ve&&d.jsx("title",{id:pe,children:ve}),d.jsx(jk,{onClick:ke,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-z},${oe-z}h${fe+z*2}v${he+z*2}h${-fe-z*2}z - M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}ym.displayName="MiniMap";const Rk=L.memo(ym),Tk=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Lk={[to.Line]:"right",[to.Handle]:"bottom-right"};function Ak({nodeId:t,position:r,variant:o=to.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:y=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:v=!1,resizeDirection:m,autoScale:_=!0,shouldResize:k,onResizeStart:j,onResize:b,onResizeEnd:E}){const R=Gg(),w=typeof t=="string"?t:R,N=Ye(),A=L.useRef(null),$=o===to.Handle,F=De(L.useCallback(Tk($&&_),[$,_]),Qe),G=L.useRef(null),q=r??Lk[o];L.useEffect(()=>{if(!(!A.current||!w))return G.current||(G.current=n_({domNode:A.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,domNode:W}=N.getState();return{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,paneDomNode:W}},onChange:(ee,ne)=>{const{triggerNodeChanges:K,nodeLookup:C,parentLookup:V,nodeOrigin:W}=N.getState(),U=[],M={x:ee.x,y:ee.y},D=C.get(w);if(D&&D.expandParent&&D.parentId){const H=D.origin??W,I=ee.width??D.measured.width??0,z=ee.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:I,height:z,...yg({x:ee.x??D.position.x,y:ee.y??D.position.y},{width:I,height:z},D.parentId,C,H)}},oe=Rc([ie],C,V,W);U.push(...oe),M.x=ee.x?Math.max(H[0]*I,ee.x):void 0,M.y=ee.y?Math.max(H[1]*z,ee.y):void 0}if(M.x!==void 0&&M.y!==void 0){const H={id:w,type:"position",position:{...M}};U.push(H)}if(ee.width!==void 0&&ee.height!==void 0){const I={id:w,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:ee.width,height:ee.height}};U.push(I)}for(const H of ne){const I={...H,type:"position"};U.push(I)}K(U)},onEnd:({width:ee,height:ne})=>{const K={id:w,type:"dimensions",resizing:!1,dimensions:{width:ee,height:ne}};N.getState().triggerNodeChanges([K])}})),G.current.update({controlPosition:q,boundaries:{minWidth:h,minHeight:p,maxWidth:y,maxHeight:x},keepAspectRatio:v,resizeDirection:m,onResizeStart:j,onResize:b,onResizeEnd:E,shouldResize:k}),()=>{var ee;(ee=G.current)==null||ee.destroy()}},[q,h,p,y,x,v,j,b,E,k]);const te=q.split("-");return d.jsx("div",{className:nt(["react-flow__resize-control","nodrag",...te,o,s]),ref:A,style:{...a,scale:F,...c&&{[$?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Ak);const $k={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function oa(t){return $k[t]??8}const us=208,ro=64,gc=88,zk=28,Dk=8;function Ok(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function vm(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const w of t){const N=oa(w.type),A=s.get(N)??[];A.push(w),s.set(N,A)}const u=[...s.keys()].sort((w,N)=>w-N).map(w=>[...s.get(w)??[]].sort((N,A)=>N.name.localeCompare(A.name)||N.id.localeCompare(A.id))),c=new Set(t.map(w=>w.id)),h=new Map,p=new Map;for(const w of t)h.set(w.id,[]),p.set(w.id,[]);for(const w of r)!c.has(w.src)||!c.has(w.dst)||w.src===w.dst||(p.get(w.src).push(w.dst),h.get(w.dst).push(w.src));const y=new Map;u.forEach((w,N)=>{for(const A of w)y.set(A.id,N)});const x=new Map,v=()=>{for(const w of u)w.forEach((N,A)=>x.set(N.id,A))};v();const m=(w,N)=>{const A=w.map(($,F)=>{const G=N($.id).map(te=>x.get(te)).filter(te=>te!==void 0),q=Ok(G);return{n:$,bary:Number.isNaN(q)?F:q,name:$.name,id:$.id}});return A.sort(($,F)=>$.bary-F.bary||$.name.localeCompare(F.name)||$.id.localeCompare(F.id)),A.map($=>$.n)},_=w=>N=>y.get(N)===w;for(let w=0;w(h.get(A)??[]).filter(_(N-1))),v();for(let N=u.length-2;N>=0;N--)u[N]=m(u[N],A=>(p.get(A)??[]).filter(_(N+1))),v()}const k=us+gc,j=ro+zk,b=Math.max(...u.map(w=>w.length),1),E=[];let R=0;for(let w=0;wG.id)),A=new Set((u[w+1]??[]).map(G=>G.id));let $=0;if(A.size)for(const G of r)N.has(G.src)&&A.has(G.dst)&&($+=1);const F=Math.min(48,Math.max(0,($-2)*10));R+=k+F}return u.forEach((w,N)=>{const A=(b-w.length)*j/2;w.forEach(($,F)=>{o.set($.id,{x:E[N]??0,y:A+F*j})})}),o}const Fk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),xm=90,Hk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),mp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Bk=Math.PI*(3-Math.sqrt(5)),wm=220,Vk=26,Wk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function _m(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function UN(t){return mp[t]?mp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Uk(t){return t>=xm?"3d":"2d"}function Yk(t){return t>=xm?"overview":"full"}function Gk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(_m(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Hk.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Gk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function qk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function Kk(t,r,o,s){const a=new Set(t.map(j=>j.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const j of r){if(!a.has(j.src)||!a.has(j.dst))continue;const b=u.get(j.src)??[];b.push({dst:j.dst,id:j.id}),u.set(j.src,b);const E=c.get(j.dst)??[];E.push({src:j.src,id:j.id}),c.set(j.dst,E)}const h=new Set(t.filter(j=>Fk.has(j.type)).map(j=>j.id)),p=h.size?h:a,y=new Set,x=[o];for(;x.length;){const j=x.pop();if(!y.has(j)){y.add(j);for(const b of u.get(j)??[])y.has(b.dst)||x.push(b.dst)}}const v=new Set([o]),m=[...p].filter(j=>y.has(j)),_=new Set(m);for(;m.length;){const j=m.pop();v.add(j);for(const b of c.get(j)??[])y.has(b.src)&&!_.has(b.src)&&(_.add(b.src),m.push(b.src))}const k=new Set;for(const j of r)v.has(j.src)&&v.has(j.dst)&&k.add(j.id);return{nodeIds:v,edgeIds:k}}function YN(t){const r=new Map;for(const s of t){const a=oa(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*wm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Vk*Math.sqrt(h+1),y=h*Bk;o.set(c.id,{x:u,y:p*Math.cos(y),z:p*Math.sin(y)})})}return o}function GN(t){const r=new Map;for(const o of t){const s=oa(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*wm,count:s}))}const El=16,Qk=12,Zk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Jk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),yp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},eN={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},vp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],xp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),tN=new Set(["looks_idempotent_on_pk","null","blank"]),nN=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function rN(t){return yp[t]?yp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function iN(t,r,o){const s=new Map(r.map(m=>[m.id,m])),a=[];Zk.has(t.type)&&a.push("sink"),Jk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(m=>m.dst===t.id),h=o.filter(m=>m.src===t.id),p=c.slice(0,El).map(m=>Cl(m,s,m.src)),y=h.slice(0,El).map(m=>Cl(m,s,m.dst)),x=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,v={type:t.type,typeLabel:Zo(io(t.type)),layer:Wk[oa(t.type)]??"other",purpose:rN(t.type),name:t.name,qualifiedName:t.qualified_name,file:x,context:t.context,roles:a,facts:sN(u).filter(m=>!(m.key==="app"&&m.value===t.context)),inputs:p,outputs:y,extraInputs:Math.max(0,c.length-El),extraOutputs:Math.max(0,h.length-El),degreeIn:c.length,degreeOut:h.length,inputKinds:wp(c.map(m=>Cl(m,s,m.src))),outputKinds:wp(h.map(m=>Cl(m,s,m.dst))),pathSummary:""};return v.pathSummary=oN(v),v}function wp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function oN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function Cl(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Zo(io(s.type)):"",edgeType:t.type,edgeLabel:Zo(t.type),inferred:t.confidence<.8}}function sN(t){const r=[...vp.filter(a=>a in t),...Object.keys(t).filter(a=>!vp.includes(a)&&!xp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||xp.has(a)||nN.has(a))continue;s.add(a);const u=lN(a,t[a]);u!=null&&o.push({key:a,label:eN[a]??Zo(a),value:u})}return o}function lN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!tN.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return aN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Qk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function aN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const _p=12,Sp=.2,uN=.8,Ul=20,cN=ro;function dN(t,r,o){const s=o??vm(t,r),a=[...new Set([...s.values()].map(p=>p.x))].sort((p,y)=>p-y),u=[];for(const p of r){const y=s.get(p.src),x=s.get(p.dst);if(!y||!x)continue;const v=y.y+ro/2,m=x.y+ro/2;if(Math.abs(v-m)<_p)continue;const _=y.x+us,k=x.x;if(k-_<_p)continue;const b=Math.min(v,m),E=Math.max(v,m);u.push({id:p.id,y0:b,y1:E,sourceX:_,targetX:k,corridor:`${Math.round(_/8)}`})}const c=new Map;for(const p of u){const y=c.get(p.corridor)??[];y.push(p),c.set(p.corridor,y)}const h=new Map;for(const p of c.values()){const y=[...p].sort((k,j)=>k.y0-j.y0||k.y1-j.y1||k.id.localeCompare(j.id)),x=pN(y),v=Math.max(0,...x.values())+1,m=y[0].sourceX,_=fN(a,m);for(const k of y){const j=gN(x.get(k.id)??0,v),b=m+Ul+Math.max(1,_-2*Ul)*j;h.set(k.id,hN(k.sourceX,k.targetX,b))}}return h}function fN(t,r){const o=r-us,s=t.find(a=>a>o+1);return s===void 0?gc:Math.max(gc,s-r)}function hN(t,r,o){const s=r-t-2*Ul;return s<1?.5:(o-t-Ul)/s}function pN(t){const r=[],o=new Map;for(const s of t){let a=-1;for(let u=0;ur[u]+cN){a=u;break}a<0?(a=r.length,r.push(s.y1)):r[a]=Math.max(r[a],s.y1),o.set(s.id,a)}return o}function gN(t,r){return r<=1?.5:Sp+(uN-Sp)*t/(r-1)}const mN=new Set,yN=L.lazy(()=>b0(()=>import("./LayeredGraph3D-CprfGADt.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),vN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function xN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(no,{type:"target",position:Se.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:io(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Tr(t.name)}),d.jsx(no,{type:"source",position:Se.Right,isConnectable:!1})]})}const wN={load:xN},_N=new Set(["django","react","stitch","arch"]);function SN({id:t,sourceX:r,sourceY:o,targetX:s,targetY:a,sourcePosition:u,targetPosition:c,style:h,markerEnd:p,markerStart:y,label:x,labelStyle:v,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,data:b,interactionWidth:E}){const[R,w,N]=Vl({sourceX:r,sourceY:o,sourcePosition:u,targetX:s,targetY:a,targetPosition:c,borderRadius:8,stepPosition:(b==null?void 0:b.stepPosition)??.5});return d.jsx(ys,{id:t,path:R,labelX:w,labelY:N,label:x,labelStyle:v,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,style:h,markerEnd:p,markerStart:y,interactionWidth:E})}const kN={loadstep:SN};function NN({topologyKey:t}){const{fitView:r}=ra();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function jN(t,r,o=null,s={}){const a=new Map(t.map(y=>[y.id,y])),u=vm(t,r),c=dN(t,r,u),h=t.map(y=>{var m;const x=((m=s.roles)==null?void 0:m[y.id])||[],v=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:y.id,type:"load",position:u.get(y.id)??{x:0,y:0},data:{name:y.name,type:y.type,file:y.file_path,roles:x,dim:v},selected:o===y.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:us,height:ro,style:{width:us,height:ro}}}),p=r.filter(y=>a.has(y.src)&&a.has(y.dst)).map(y=>{const x=vN[y.weight]||"var(--edge-cheap)",v=!!(o&&(y.src===o||y.dst===o));return{id:y.id,source:y.src,target:y.dst,type:"loadstep",animated:y.weight==="critical",data:{stepPosition:c.get(y.id)??.5},style:{stroke:x,strokeWidth:y.weight==="critical"?2.4:1.2,strokeDasharray:y.confidence<.8?"6 4":void 0},markerEnd:{type:os.ArrowClosed,width:14,height:14,color:x},label:v?y.type.replaceAll("_"," "):void 0,labelStyle:v?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:v?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:v?[3,5]:void 0,labelBgBorderRadius:v?4:void 0}});return{rfNodes:h,rfEdges:p}}function bN({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:y}){const x=iN(t,r,o);return L.useEffect(()=>{const v=m=>{m.key==="Escape"&&s()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:x.typeLabel}),d.jsx("div",{className:"inspector-roles",children:x.roles.map(v=>d.jsx("span",{className:"inspector-chip",children:v},v))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Tr(x.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:x.purpose}),x.context?d.jsx("div",{className:"muted",children:Tr(x.context)}):null,x.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Tr(x.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Tr(x.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",x.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[x.degreeIn," in · ",x.degreeOut," out"]}),x.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:x.pathSummary}):null,x.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:x.facts.map(v=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:v.label}),d.jsx("dd",{children:Tr(v.value)})]},v.key))}):null,d.jsx(kp,{title:"Inputs",testId:"graph-inspector-inputs",links:x.inputs,extra:x.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(kp,{title:"Outputs",testId:"graph-inspector-outputs",links:x.outputs,extra:x.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),a?d.jsx("p",{className:"whatif-hint","data-testid":"whatif-hint",children:y?"Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map.":"Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."}):null,d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",title:"Start a hypothetical walk from this node. Does not use Base/Head.",onClick:()=>a(t.id),children:"What if this changes"}):null,y?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",title:"Hide nodes that are not on a path from here to a sink. Does not start a new walk.",onClick:()=>y(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function kp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Tr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Zu({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:y,repoPath:x,onOpenFile:v,pinnedId:m,onPin:_}){const[k,j]=L.useState(null),b=a!==void 0?a:k,E=re=>{a===void 0&&j(re),u==null||u(re)},[R,w]=L.useState(null),[N,A]=L.useState(null),[$,F]=L.useState(new Set(_N)),[G,q]=L.useState(!1),[te,ee]=L.useState(""),[ne,K]=L.useState(!1),C=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,V=R??Uk(t.length),W=N??Yk(t.length),U=G?b:null,M=L.useMemo(()=>p?Kk(t,r,p):null,[t,r,p]),D=M?t.filter(re=>M.nodeIds.has(re.id)):t,H=M?r.filter(re=>M.edgeIds.has(re.id)):r,I=L.useMemo(()=>Xk(D,H,{detail:W,families:$,focusId:U,neighborhoodOnly:!!U}),[D,H,W,$,U]),z=L.useMemo(()=>`${I.nodes.map(re=>re.id).join("\0")}|${I.edges.map(re=>re.id).join("\0")}`,[I.nodes,I.edges]),ie=b?t.find(re=>re.id===b)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const re=jN(I.nodes,I.edges,b,{roles:c,testOverlay:h});return C&&(re.rfEdges=re.rfEdges.map(Ne=>({...Ne,animated:!1}))),re},[I.nodes,I.edges,b,C,c,h]);L.useEffect(()=>{if(!s)return;const re=t.find(Ne=>Ne.file_path===s);re&&E(re.id)},[s,t]);const he=L.useMemo(()=>qk(t,te),[t,te]),pe=(re,Ne)=>{E(Ne.id)},Z=()=>{E(null),q(!1)},se=ie?d.jsx(bN,{node:ie,nodes:t,edges:r,onClose:Z,onWhatIf:o,onSelect:E,onOpenFile:v,pinned:m===ie.id,onPin:_,onIsolate:y?re=>{y(p===re?null:re)}:void 0}):null,me=re=>{F(Ne=>{const Me=new Set(Ne);if(Me.has(re)){if(Me.size===1)return Ne;Me.delete(re)}else Me.add(re);return Me})},ke=L.useMemo(()=>{const re=new Set;for(const Ne of t)re.add(_m(Ne.type));return re},[t]),ve=t.length-I.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:V==="2d"?"active":"","aria-pressed":V==="2d",onClick:()=>w("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:V==="3d"?"active":"","aria-pressed":V==="3d",onClick:()=>w("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:W==="overview"?"active":"","aria-pressed":W==="overview",onClick:()=>A("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:W==="full"?"active":"","aria-pressed":W==="full",onClick:()=>A("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(re=>ke.has(re)).map(re=>d.jsx("button",{type:"button","data-testid":`graph-family-${re}`,className:$.has(re)?"active":"","aria-pressed":$.has(re),onClick:()=>me(re),children:re},re))}),d.jsx("button",{type:"button",className:G?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!b,onClick:()=>q(re=>!re),children:G?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>y==null?void 0:y(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:te,onChange:re=>{ee(re.target.value),K(!0)},onFocus:()=>K(!0),onBlur:()=>window.setTimeout(()=>K(!1),150)}),ne&&te.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(re=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:Ne=>Ne.preventDefault(),onClick:()=>{E(re.id),ee(""),K(!1)},children:[re.name,d.jsx("span",{className:"muted",children:io(re.type)})]})},re.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[I.nodes.length," nodes · ",I.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:V==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(yN,{nodes:I.nodes,edges:I.edges,selectedId:b,neighborIds:U?I.neighborIds:mN,onSelect:re=>{E(re),re||q(!1)}})}),se]}):d.jsxs(pm,{children:[d.jsxs(sk,{nodes:oe,edges:fe,nodeTypes:wN,edgeTypes:kN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:Z,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(NN,{topologyKey:z}),d.jsx(dk,{}),d.jsx(Rk,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(vk,{})]}),se]})})]})}function Sm(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function EN(t){localStorage.setItem("loadpath.editor",t)}async function CN(t,r,o,s=Sm()){try{const a=await Pe.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const Np=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],MN=["preset","branch","tag","commit"];function PN(t){var a;if(!(t!=null&&t.git))return[...Np];const r=((a=t.presets)!=null&&a.length?t.presets:Np.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function IN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function RN(t){return MN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function TN(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function jp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[y,x]=L.useState(!1),[v,m]=L.useState(null),[_,k]=L.useState(0),j=L.useMemo(()=>{const N=PN(u);return v===null?N:IN(N,v)},[u,v]),b=L.useMemo(()=>RN(j),[j]);L.useEffect(()=>{y&&c()},[y,c]),L.useEffect(()=>{k(0)},[v,y]);const E=()=>{x(!1),m(null)},R=N=>{r(N.value),E()},w=N=>{if(N.key==="ArrowDown"){if(N.preventDefault(),!y){x(!0);return}k(A=>Math.min(A+1,Math.max(j.length-1,0)))}else if(N.key==="ArrowUp"){if(N.preventDefault(),!y)return;k(A=>Math.max(A-1,0))}else if(N.key==="Enter"&&y){N.preventDefault();const A=j[_];A&&R(A)}else N.key==="Escape"&&y&&(N.preventDefault(),E())};return d.jsxs("div",{className:"combo",ref:p,onBlur:N=>{N.currentTarget.contains(N.relatedTarget)||E()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":y,"aria-controls":h,"aria-autocomplete":"list",onChange:N=>{r(N.target.value),y&&m(N.target.value)},onKeyDown:w}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":y,onMouseDown:N=>N.preventDefault(),onClick:()=>y?E():x(!0),children:d.jsx(k0,{})})]}),y?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:b.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):b.map(N=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:TN(N.group)}),N.items.map(A=>{const $=j.indexOf(A);return d.jsxs("button",{type:"button",role:"option","aria-selected":$===_,className:$===_?"combo-option active":"combo-option","data-testid":`ref-option-${A.group}`,onMouseDown:F=>F.preventDefault(),onMouseEnter:()=>k($),onClick:()=>R(A),children:[d.jsx("span",{className:"combo-label",children:A.label}),A.detail?d.jsx("span",{className:"combo-detail",children:A.detail}):null]},`${A.group}:${A.value}`)})]},N.group))}):null]})}function LN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[y,x]=L.useState(""),[v,m]=L.useState(!1),_=L.useRef(null),k=L.useRef(0),j=async w=>{const N=k.current+1;k.current=N,m(!0);try{const A=await Pe.browse(w);if(k.current!==N)return;a(A),c(A.path),p(A.is_git?A.path:null),x("")}catch(A){if(k.current!==N)return;x(A instanceof Error?A.message:String(A))}finally{k.current===N&&m(!1)}};L.useEffect(()=>{var w,N;j(t),(w=_.current)==null||w.focus(),(N=_.current)==null||N.select()},[t]);const b=h||(s==null?void 0:s.path)||u,E=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",R=w=>{w.key==="Escape"&&(w.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:R,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:w=>w.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:w=>{w.preventDefault(),j(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:w=>c(w.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),y?d.jsx("div",{className:"error",role:"alert",children:y}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":v,children:s!=null&&s.entries.length?s.entries.map(w=>{const N=h===w.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":N,className:N?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":w.path,onClick:()=>p(w.path),onDoubleClick:()=>void j(w.path),children:[d.jsx(Mp,{}),d.jsx("span",{className:"explorer-name",children:w.name}),w.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},w.path)}):d.jsx("div",{className:"muted explorer-empty",children:v?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:b,children:b}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!b,onClick:()=>b&&r(b),children:["Use ",E]})]})]})})}const AN={scan:{start:0,end:20},extract:{start:20,end:88},boot:{start:88,end:94},stitch:{start:94,end:99},skipped:{start:100,end:100},done:{start:100,end:100}},$N=new Set(["scan","extract","boot","stitch"]);function zN(t){const r=t.phase||"";if(!r||r==="idle")return null;const o=AN[r];if(!o)return null;if(o.start===o.end)return o.end;const s=t.total||0;if(s<=0)return o.start;const a=Math.min(1,Math.max(0,(t.done||0)/s));return Math.round(o.start+(o.end-o.start)*a)}function DN(t){return!t.phase||t.phase==="idle"?null:typeof t.percent=="number"&&Number.isFinite(t.percent)?Math.max(0,Math.min(100,Math.round(t.percent))):zN(t)}const Yl=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],ON="obsidian",km="loadpath.theme";function FN(t){return Yl.some(r=>r.id===t)}function Nm(){try{const t=localStorage.getItem(km)||"";if(FN(t))return t}catch{}return ON}function HN(t){var r;return((r=Yl.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function jm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=HN(t);try{localStorage.setItem(km,t)}catch{}}const Ju=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:v0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:x0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:w0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:_0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:S0}];function ec(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function BN(){var fo,ho,Si,po,go,mo,ki,Xr,rn,on;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,y]=L.useState(null),[x,v]=L.useState(null),[m,_]=L.useState(null),[k,j]=L.useState([]),[b,E]=L.useState("review"),[R,w]=L.useState(""),[N,A]=L.useState(""),[$,F]=L.useState(null),[G,q]=L.useState(!1),[te,ee]=L.useState(!1),[ne,K]=L.useState(""),[C,V]=L.useState({}),[W,U]=L.useState([]),[M,D]=L.useState([]),[H,I]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[z,ie]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[oe,fe]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[he,pe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[Z,se]=L.useState(0),[me,ke]=L.useState(""),[ve,re]=L.useState(Nm),[Ne,Me]=L.useState(!1),[Te,$e]=L.useState(!1),[st,lt]=L.useState(!1),[at,Ge]=L.useState(null),[wt,qt]=L.useState(null),[gt,mt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[Pt,ut]=L.useState(null),[Je,An]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[Ot,xn]=L.useState([]),[oo,$n]=L.useState(null),[vi,or]=L.useState(null),[$r,zn]=L.useState(null),[zr,sr]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[lr,Ft]=L.useState(null),[ct,Dn]=L.useState(null),[On,wn]=L.useState(!1),[Fn,_n]=L.useState(!1),rt=L.useRef(o);rt.current=o;const Dr=L.useRef(!1);Dr.current=Te;const _t=L.useRef(""),ar=L.useRef(""),Sn=P=>{re(P),jm(P)},dt=L.useRef(""),He=P=>{dt.current=P,A(P)},kn=P=>{let Y=0,ce=!1;F(0);const je=()=>{Pe.indexProgress(P).then(Ie=>{if(!dt.current)return;if(Ie.phase&&Ie.phase!=="idle"&&Ie.message&&He(Ie.message),$N.has(Ie.phase))ce=!0;else if(!ce)return;const qr=DN(Ie);qr!=null&&(Ie.phase==="scan"&&!Ie.done?Y=qr:Y=Math.max(Y,qr),F(Y))}).catch(()=>{})};je();const Le=window.setInterval(je,250);return()=>{window.clearInterval(Le),F(null)}};L.useEffect(()=>{Pe.settings().then(V).catch(()=>{}).finally(()=>Me(!0)),Pe.repos().then(P=>j(P.repos)).catch(()=>{})},[]);const Nn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const P=o;let Y=!1;return ar.current!==P&&Bn(P),Pe.config(P).then(ce=>{!Y&&rt.current===P&&or(ce)}).catch(()=>{}),Pe.architectureHealth(P).then(ce=>{!Y&&rt.current===P&&zn(ce)}).catch(()=>{}),()=>{Y=!0}},[t,o]);const Ht=P=>{rt.current=P,s(P),localStorage.setItem("loadpath.repo",P),P.trim()!==_t.current&&(_t.current="",Ft(null))},Or=L.useCallback(P=>{const Y=(P??rt.current).trim();return!Y||_t.current===Y?Promise.resolve():(_t.current=Y,Pe.gitRefs(Y).then(ce=>{rt.current.trim()===Y&&Ft(ce)}).catch(()=>{_t.current===Y&&(_t.current="",Ft(null))}))},[]),nn=(P,Y)=>{u(P),h(Y),localStorage.setItem("loadpath.base",P),localStorage.setItem("loadpath.head",Y)},Fr=(P,Y,ce)=>{ie(P),I(Y),localStorage.setItem("loadpath.provider",P),localStorage.setItem("loadpath.scmRepo",Y),ce!==void 0&&(fe(ce),localStorage.setItem("loadpath.prNumber",ce))},yt=P=>{y(P),se(0),Ge(wt&&P.nodes.some(Y=>Y.id===wt)?wt:null),ut(null),$n(null),P.what_if||(v(P),P.id&&localStorage.setItem("loadpath.lastReviewId",P.id))},Hn=async P=>{try{const Y=await Pe.reviews(P);xn(Y.reviews)}catch{xn([])}},ur=async P=>{try{zn(await Pe.architectureHealth(P))}catch{zn(null)}},so=P=>P==="github"?!!C.github_token_set:P==="gitlab"?!!C.gitlab_token_set:!!C.bitbucket_token_set,It=L.useCallback(async(P=z)=>{var Y;try{const ce=await Pe.scmRepos(P);D(ce.repos),(Y=ce.user)!=null&&Y.login&&V(je=>({...je,...P==="github"?{github_user:ce.user.login}:P==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{D([])}},[z]);L.useEffect(()=>{if(t!=="prs")return;let P=!1;return It(z).catch(()=>{P||D([])}),()=>{P=!0}},[t,z,It]),L.useEffect(()=>{if(!ct)return;let P=!1,Y=0;const ce=async()=>{try{const je=await Pe.githubOAuthPoll(ct.flow_id);if(P)return;if(je.status==="complete"){Dn(null);const Le=await Pe.settings();V(Le),K(je.user?`Signed in to GitHub as ${je.user}`:"Signed in to GitHub"),It("github");return}if(je.status==="pending"||je.status==="slow_down"){Y=window.setTimeout(ce,Math.max(je.interval||ct.interval,5)*1e3);return}Dn(null),w(je.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(je){if(P)return;Dn(null),w(je instanceof Error?je.message:String(je))}};return Y=window.setTimeout(ce,Math.max(ct.interval,5)*1e3),()=>{P=!0,window.clearTimeout(Y)}},[ct,It]),L.useEffect(()=>{if(!On)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.bitbucket.connected){wn(!1);const Ie=await Pe.settings();V(Ie),K(Le.bitbucket.user?`Signed in to Bitbucket as ${Le.bitbucket.user}`:"Signed in to Bitbucket"),It("bitbucket");return}if(Date.now()-ce>18e4){wn(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;wn(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[On,It]),L.useEffect(()=>{if(!Fn)return;let P=!1,Y=0;const ce=Date.now(),je=async()=>{try{const Le=await Pe.oauthStatus();if(P)return;if(Le.gitlab.connected){_n(!1);const Ie=await Pe.settings();V(Ie),K(Le.gitlab.user?`Signed in to GitLab as ${Le.gitlab.user}`:"Signed in to GitLab"),It("gitlab");return}if(Date.now()-ce>18e4){_n(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(je,1500)}catch(Le){if(P)return;_n(!1),w(Le instanceof Error?Le.message:String(Le))}};return Y=window.setTimeout(je,1500),()=>{P=!0,window.clearTimeout(Y)}},[Fn,It]);const Bn=async(P=o,Y=!1)=>{if(!P.trim())return null;ar.current=P,ee(!0);try{const ce=await Pe.architecture(P,!1);rt.current===P&&_(ce);const je=Pe.architectureGraph(P).then(Le=>{rt.current===P&&_(Ie=>Ie&&{...Ie,nodes:Le.nodes,edges:Le.edges,graph_pending:!1})});return je.catch(()=>{}).finally(()=>{rt.current===P&&ee(!1)}),Y&&await je,ce}catch(ce){throw rt.current===P&&ee(!1),ce}},Hr=async P=>{const Y=P.trim();if(!(!Y||Y===rt.current)){if(dt.current){w("Wait for the current job to finish before switching workspace.");return}w(""),K(""),y(null),v(null),_(null),E("architecture"),Ht(Y),q(!0),He(`Loading ${y0(Y)}…`);try{await Promise.all([Bn(Y),Or(Y)])}catch(ce){rt.current===Y&&w(ce instanceof Error?ce.message:String(ce))}finally{rt.current===Y&&(He(""),q(!1))}}},jn=async()=>{if(dt.current||!Nn())return;w(""),K(""),He("Tracing load path…"),Ht(o),nn(a,c);const P=kn(o);try{const Y=await Pe.review(o,a,c,!0,he);yt(Y),E("review"),r("review"),await Pe.repos().then(ce=>j(ce.repos)).catch(()=>{}),await Promise.all([Bn(o),Hn(o),ur(o)])}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{P(),He("")}},Br=async(P=!0)=>{if(dt.current||!Nn())return;w(""),K(""),He(P?"Indexing…":"Full reindex…"),Ht(o);const Y=kn(o);try{await Pe.index(o,P);const ce=await Bn(o);await Pe.repos().then(je=>j(je.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(E("architecture"),r("architecture"))}catch(ce){w(ce instanceof Error?ce.message:String(ce))}finally{Y(),He("")}},xi=async()=>{if(!dt.current&&Nn()){w(""),K(""),He("Detecting layout…"),Ht(o);try{const P=await Pe.init(o);K(P.message),await Pe.repos().then(Y=>j(Y.repos)).catch(()=>{})}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ve=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),K("Copied markdown brief")}catch(P){w(P instanceof Error?P.message:String(P))}},lo=async()=>{if(!dt.current){if(p!=null&&p.what_if){w("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first.");return}if(!(p!=null&&p.markdown)||!H||!oe){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const P=await Pe.postComment(z,H,Number(oe),p.markdown);K(P.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Vr=async()=>{if(!dt.current){w(""),He("Fetching pull requests…");try{const P=await Pe.prs(z,H,"open",o.trim()||void 0);U(P.pull_requests);const Y=M.find(ce=>ce.slug.toLowerCase()===H.trim().toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},wi=async()=>{w("");try{const P=await Pe.githubOAuthStart();Dn(P),ec(P.verification_uri_complete,"github.com","/login/device")}catch(P){w(P instanceof Error?P.message:String(P))}},cr=async()=>{w("");try{const P=await Pe.bitbucketOAuthStart();wn(!0),ec(P.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(P){wn(!1),w(P instanceof Error?P.message:String(P))}},ao=async()=>{w("");try{const P=await Pe.gitlabOAuthStart();_n(!0),ec(P.authorize_url,new URL(P.authorize_url).hostname,"/oauth/authorize")}catch(P){_n(!1),w(P instanceof Error?P.message:String(P))}},dr=async P=>{if(!(dt.current||!o.trim())){w(""),He("Walking what-if path…");try{const Y=await Pe.whatIf(o,P);K(`${Y.title} — ${Y.confidence.level} · ${(Y.sinks||[]).length} sinks`),yt({...Y,markdown:Y.markdown||"",index:Y.index||(p==null?void 0:p.index),workspace:Y.workspace||(p==null?void 0:p.workspace)}),E("review"),r("review")}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},Vn=()=>{if(x){yt(x),E("review"),r("review"),K("Restored the last git-range walk");return}y(null),se(0),Ge(null),ut(null),$n(null),E("architecture"),r("architecture"),K("")},bt=async P=>{var Le;if(dt.current)return;Fr(P.provider,P.repo,String(P.number));const Y=M.find(Ie=>Ie.slug.toLowerCase()===P.repo.toLowerCase());Y!=null&&Y.local_path&&Ht(Y.local_path),w(""),He(`Fetching ${P.provider} #${P.number}…`);const ce=(Y==null?void 0:Y.local_path)||o,je=ce?kn(ce):()=>{};try{const Ie=await Pe.reviewPr(P.provider,P.repo,P.number,(Y==null?void 0:Y.local_path)||o||void 0);yt(Ie),Ie.pull_request&&typeof Ie.pull_request.repo_path=="string"&&Ht(Ie.pull_request.repo_path),nn(String(Ie.base||P.target_branch),String(Ie.head||P.source_branch)),E("review"),r("review"),typeof((Le=Ie.pull_request)==null?void 0:Le.repo_path)=="string"&&Hn(Ie.pull_request.repo_path)}catch(Ie){nn(P.base_sha||P.target_branch,P.head_sha||P.source_branch),r("review"),w(Ie instanceof Error?Ie.message:String(Ie))}finally{je(),He("")}},Wr=async P=>{w("");try{V(await Pe.oauthDisconnect(P)),z===P&&D([]),K(`Disconnected ${P}`)}catch(Y){w(Y instanceof Error?Y.message:String(Y))}},Et=async P=>{P.preventDefault();const Y=new FormData(P.currentTarget),ce={github_token:String(Y.get("github_token")||""),github_oauth_client_id:String(Y.get("github_oauth_client_id")||""),github_host:String(Y.get("github_host")||""),gitlab_token:String(Y.get("gitlab_token")||""),gitlab_host:String(Y.get("gitlab_host")||""),gitlab_oauth_client_id:String(Y.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(Y.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(Y.get("bitbucket_token")||""),bitbucket_username:String(Y.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(Y.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(Y.get("bitbucket_oauth_client_secret")||""),ai_provider:String(Y.get("ai_provider")||"none"),ai_api_key:String(Y.get("ai_api_key")||""),ai_model:String(Y.get("ai_model")||""),ai_base_url:String(Y.get("ai_base_url")||"")},je=k.length?{...ce,workspaces:k.map(Le=>({path:Le.path,name:Le.name}))}:ce;try{V(await Pe.saveSettings(je)),K("Settings saved on this machine")}catch(Le){w(Le instanceof Error?Le.message:String(Le))}},uo=async()=>{if(!(!p||dt.current)){He("Residual analysis…");try{const P=await Pe.residual(p);ke(P.note)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Ur=L.useRef(jn);Ur.current=jn;const Yr=L.useRef(t);Yr.current=t;const Wn=L.useRef(!1);Wn.current=st;const Un=L.useRef(p);Un.current=p;const bn=L.useRef(Z);bn.current=Z,L.useEffect(()=>{const P=localStorage.getItem("loadpath.lastReviewId"),Y=(localStorage.getItem("loadpath.repo")||"").trim();if(!P||!Y){sr(!1);return}let ce=!1;return Pe.getReview(Y,P).then(je=>{ce||(yt(je),nn(je.base||localStorage.getItem("loadpath.base")||"HEAD~1",je.head||localStorage.getItem("loadpath.head")||"HEAD"),Hn(Y),ur(Y))}).catch(()=>{}).finally(()=>{ce||sr(!1)}),()=>{ce=!0}},[]);const Bt=L.useRef("");L.useEffect(()=>{if(!Je||!o.trim())return;let P=!1;const Y=async()=>{try{const je=await Pe.workspaceStatus(o);if(P)return;Bt.current&&je.fingerprint!==Bt.current&&!dt.current&&(pe(!0),localStorage.setItem("loadpath.dirty","1"),Ur.current()),Bt.current=je.fingerprint}catch{}};Y();const ce=window.setInterval(Y,2e3);return()=>{P=!0,window.clearInterval(ce)}},[Je,o]),L.useEffect(()=>{const P=Y=>{var Le;if((Y.metaKey||Y.ctrlKey)&&Y.key.toLowerCase()==="k"){Y.preventDefault(),lt(Ie=>!Ie);return}if(Wn.current){Y.key==="Escape"&&(Y.preventDefault(),lt(!1));return}if(Dr.current){Y.key==="Escape"&&(Y.preventDefault(),$e(!1));return}const ce=Y.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){Y.key==="Escape"&&ce.blur();return}if(Y.key==="Escape"){w(""),K(""),Ge(wt),ut(null);return}if(Y.key==="j"||Y.key==="k"){const Ie=((Le=Un.current)==null?void 0:Le.read_order)||[];if(!Ie.length)return;Y.preventDefault();const Gn=bn.current,qr=Y.key==="j"?Math.min(Ie.length-1,Gn+1):Math.max(0,Gn-1);se(qr);return}const je=Ju.find(Ie=>Ie.shortcut===Y.key);if(je&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey&&r(je.id),(Y.metaKey||Y.ctrlKey)&&Y.key==="Enter"){if(Yr.current==="settings"||Yr.current==="prs"||dt.current)return;Y.preventDefault(),Ur.current()}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[wt]);const _i=async(P,Y)=>{if(!o.trim())return;const ce=await CN(o,P,Y);ce.ok?K(ce.message):w(ce.message)},Gr=async()=>{if(p)try{const P=await Pe.exportHtml(p),Y=URL.createObjectURL(P),ce=document.createElement("a");ce.href=Y,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(Y),K("Saved HTML brief")}catch(P){w(P instanceof Error?P.message:String(P))}},fr=async P=>{if(o.trim()){He("Loading stored review…");try{const Y=await Pe.getReview(o,P);yt(Y),nn(Y.base||a,Y.head||c),E("review"),r("review");const ce=Ot.find(je=>je.id!==P);if(ce)try{$n(await Pe.reviewDiff(o,P,ce.id))}catch{$n(null)}}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},hr={selectedId:at,onSelect:Ge,nodeRoles:p==null?void 0:p.node_roles,testOverlay:gt,isolateSource:Pt,onIsolate:ut,repoPath:o,onOpenFile:_i,pinnedId:wt,onPin:qt},Yn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void jn()},...p!=null&&p.what_if?[{id:"exit-whatif",group:"Review",label:x?"Back to git-range walk":"Exit what-if walk",run:Vn}]:[],{id:"index",group:"Run",label:"Index repository",run:()=>void Br(!0)},{id:"watch",group:"Run",label:Je?"Stop watching working tree":"Watch working tree",run:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")}},{id:"tests",group:"Graph",label:gt?"Hide test overlay":"Show test overlay",run:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void Gr()},...Ju.map(P=>({id:`tab-${P.id}`,group:"Tabs",label:`Go to ${P.label}`,hint:P.shortcut,run:()=>r(P.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(P=>({id:`node-${P.id}`,group:"Nodes",label:P.name,hint:io(P.type),run:()=>{Ge(P.id),r("graph")}})),...Ot.slice(0,12).map(P=>({id:`hist-${P.id}`,group:"History",label:P.title||P.id,hint:`${P.level||""} ${P.created_at||""}`.trim(),run:()=>void fr(P.id)}))],En=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[b,m,p]),co=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[b,m,p]),pr=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",Fe=((p==null?void 0:p.findings)||[]).filter(P=>!P.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),Ju.map(P=>{const Y=P.icon,ce=t===P.id;return d.jsxs("button",{type:"button","data-testid":P.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":P.label,onClick:()=>r(P.id),children:[d.jsx(Y,{}),d.jsx("span",{children:P.label})]},P.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:ve,onChange:P=>Sn(P.target.value),children:["dark","light"].map(P=>d.jsx("optgroup",{label:P==="dark"?"Dark":"Light",children:Yl.filter(Y=>Y.group===P).map(Y=>d.jsx("option",{value:Y.id,children:Y.label},Y.id))},P))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:N||pr}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[N?d.jsxs("div",{className:$!=null?"progress determinate":"progress",role:"status","aria-live":"polite","aria-busy":"true","aria-valuemin":$!=null?0:void 0,"aria-valuemax":$!=null?100:void 0,"aria-valuenow":$??void 0,"data-testid":"progress",children:[d.jsx("i",{style:$!=null?{width:`${$}%`}:void 0}),d.jsx("span",{className:"sr-only",children:N})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[k.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:k.some(P=>P.path===o)?o:"",disabled:!!N,"aria-busy":G,onChange:P=>{P.target.value&&Hr(P.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),k.map(P=>d.jsxs("option",{value:P.path,children:[P.name,P.indexed?` (${P.counts.nodes})`:""]},P.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:P=>{const Y=P.target.value;s(Y),Y.trim()!==_t.current&&(_t.current="",Ft(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>$e(!0),children:d.jsx(Mp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(jp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:P=>nn(P,c),placeholder:"base",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(jp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:P=>nn(a,P),placeholder:"head",refs:lr,onNeedRefs:Or})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:he?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":he,onClick:()=>{const P=!he;pe(P),localStorage.setItem("loadpath.dirty",P?"1":"0")},children:he?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:Je?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":Je,onClick:()=>{const P=!Je;An(P),localStorage.setItem("loadpath.watch",P?"1":"0")},children:Je?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.what_if?"what-if · ":"",p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!N,onClick:xi,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!N,onClick:()=>Br(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!N,onClick:jn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[R?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:R}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,ne?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:ne}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>K(""),"aria-label":"Dismiss",children:"×"})]}):null,((fo=p==null?void 0:p.index)!=null&&fo.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((ho=p==null?void 0:p.index)==null?void 0:ho.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((Si=p==null?void 0:p.index)==null?void 0:Si.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(po=p==null?void 0:p.workspace)!=null&&po.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,p!=null&&p.what_if?d.jsxs("div",{className:"banner whatif","data-testid":"whatif-banner",children:[d.jsxs("span",{children:["Hypothetical walk from"," ",d.jsx("strong",{children:((go=p.node)==null?void 0:go.name)||"this node"}),". Loadpath ignored Base/Head and asked which sinks would feel this node change — not a filter of the current map."]}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-exit-whatif",onClick:Vn,children:x?"Back to git range":"Back to architecture"})]}):null,G?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:N||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":G||te,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(VN,{review:p,findings:Fe,aiNote:me,busy:!!N,tourIndex:Z,onTour:se,onAskAi:uo,onCopy:Ve,onPost:lo,onSelect:Ge,onOpenFile:_i,onExport:Gr,history:Ot,diff:oo,onReopen:fr,onWaiver:(P,Y)=>{o.trim()&&Pe.addWaiver(o,P,Y||void 0,"from review").then(ce=>{or(ce),K(`Waived ${P} in loadpath.yml`)})}}):zr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Zu,{nodes:p.nodes,edges:p.edges,onWhatIf:dr,focusPath:(mo=p.read_order[Z])==null?void 0:mo.path,...hr}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(WN,{architecture:m,busy:!!N,onReindex:()=>Br(!1),onReview:jn,onSelect:Ge,config:vi,health:$r,onSaveConfig:P=>{Pe.saveConfig(o,P).then(Y=>{or(Y),K("Wrote loadpath.yml")})},onWaiver:(P,Y,ce)=>{Pe.addWaiver(o,P,Y,ce).then(je=>{or(je),K(`Waived ${P}`)})}}):G?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(te||m!=null&&m.graph_pending)&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(ki=m==null?void 0:m.counts)!=null&&ki.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Zu,{nodes:m.nodes,edges:m.edges,onWhatIf:dr,...hr,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":b==="review","data-testid":"graph-mode-review",className:b==="review"?"active":"",onClick:()=>E("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":b==="architecture","data-testid":"graph-mode-architecture",className:b==="architecture"?"active":"",onClick:()=>E("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:gt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":gt,onClick:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")},children:"Tests"})]}),En.length?d.jsx(Zu,{nodes:En,edges:co,onWhatIf:dr,...hr}):te||m!=null&&m.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:z,onChange:P=>Fr(P.target.value,H,oe),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:M.length?"Search your repos":"owner/repo",value:H,onChange:P=>Fr(z,P.target.value,oe),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:M.map(P=>d.jsxs("option",{value:P.slug,children:[P.private?"private":"public",P.local_path?" · local":""]},P.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!N||!so(z),onClick:()=>{It(z)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!N,onClick:Vr,children:"List PRs"})]}),M.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[M.length," ",z," repositor",M.length===1?"y":"ies",z==="github"&&C.github_user?` · @${String(C.github_user)}`:"",z==="gitlab"&&C.gitlab_user?` · @${String(C.gitlab_user)}`:"",z==="bitbucket"&&C.bitbucket_user?` · ${String(C.bitbucket_user)}`:""]}):null,W.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):W.map(P=>{var Y;return d.jsxs("article",{className:"pr","data-testid":`pr-${P.number}`,children:[d.jsxs("h3",{children:["#",P.number," ",P.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${P.draft?"":"open"}`,children:P.draft?"draft":P.state}),d.jsx("span",{children:P.author}),d.jsxs("span",{children:[P.source_branch," → ",P.target_branch]}),P.loadpath?d.jsxs("span",{className:`chip ${P.loadpath.level||""}`,"data-testid":`pr-loadpath-${P.number}`,children:[((Y=P.loadpath.level)==null?void 0:Y.toUpperCase())||"REVIEWED",P.loadpath.contract_break&&P.loadpath.contract_break!=="none"?` · ${P.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:P.url,target:"_blank",rel:"noreferrer",children:["Open on ",P.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${P.number}`,onClick:()=>void bt(P),children:"Review this PR"})]})]},`${P.provider}-${P.number}`)})]}),t==="settings"&&Ne&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:Et,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Yl.map(P=>d.jsxs("button",{type:"button","data-theme":P.id,className:ve===P.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${P.id}`,onClick:()=>Sn(P.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:P.label}),d.jsx("div",{className:"group",children:P.group})]},P.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:Sm(),onChange:P=>EN(P.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:C.github_token_set?C.github_user?`Signed in as @${String(C.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void Wr("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!ct||!C.github_oauth_ready,onClick:()=>void wi(),children:ct?"Waiting for GitHub…":"Sign in with GitHub"})})]}),ct?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:ct.user_code})," at GitHub if the browser did not fill it in."]}):null,C.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(C.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(C.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:C.gitlab_token_set?C.gitlab_user?`Signed in as @${String(C.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void Wr("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Fn||!C.gitlab_oauth_ready,onClick:()=>void ao(),children:Fn?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(C.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(C.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:C.bitbucket_token_set?C.bitbucket_user?`Signed in as ${String(C.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void Wr("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:On||!C.bitbucket_oauth_ready,onClick:()=>void cr(),children:On?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),C.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(C.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(C.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((Xr=C.ai)==null?void 0:Xr.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((rn=C.ai)==null?void 0:rn.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((on=C.ai)==null?void 0:on.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(p0,{open:st,actions:Yn,onClose:()=>lt(!1)}),Te?d.jsx(LN,{initialPath:o,onClose:()=>$e(!1),onSelect:P=>{if(dt.current){w("Wait for the current job to finish before switching workspace.");return}$e(!1),Hr(P)}}):null]})}function VN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:y,onOpenFile:x,onExport:v,history:m,diff:_,onReopen:k,onWaiver:j}){var E,R,w,N,A,$,F,G,q,te,ee,ne,K,C,V,W,U;const b=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),b.length?d.jsx("ul",{className:"reasons",children:b.map(M=>d.jsx("li",{children:M},M))}):null,t.what_if?d.jsx("span",{className:"chip whatif","data-testid":"whatif-chip",children:"what-if"}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Zo(M)},M)),(E=t.contract_break)!=null&&E.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&y(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>j(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(R=t.workspace)!=null&&R.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>x(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&y(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(bm,{cards:t.deepening}),(N=(w=t.contract_break)==null?void 0:w.reasons)!=null&&N.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),($=(A=t.contract_break.sides)==null?void 0:A.rows)!=null&&$.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(F=t.auth)!=null&&F.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(G=t.suggested_tests)==null?void 0:G.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(q=t.trend)!=null&&q.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",tc(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),m.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:m.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,m.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>k(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?tc(M.created_at):""})]},M.id))]}):null,(ee=(te=t.evolution)==null?void 0:te.notes)!=null&&ee.length||(K=(ne=t.evolution)==null?void 0:ne.hotspots)!=null&&K.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((C=t.evolution)==null?void 0:C.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((V=t.evolution)==null?void 0:V.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:v,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",disabled:s||!!t.what_if,title:t.what_if?"Hypothetical walks are not posted to a pull request":void 0,onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(W=t.codeowners_reviewers)!=null&&W.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function WN({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var x;const y=t.findings.filter(v=>!v.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${tc(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(v=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:v.name})," — ",(v.django_apps||[]).join(", ")||"no apps"," ·"," ",(v.owners||[]).join(", ")||"unowned"]},v.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(v=>d.jsx("div",{className:"muted",children:v},v))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:y.length})]}),y.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):y.map(v=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>v.node_id&&a(v.node_id),children:[d.jsx("span",{className:`chip ${v.severity}`,children:v.severity}),v.message]})},v.rule+v.message))]}),d.jsx(bm,{cards:t.deepening}),(x=c==null?void 0:c.points)!=null&&x.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(v=>d.jsx("i",{className:v.level||"",title:`${v.level} · ${v.findings} findings`,style:{height:`${8+Math.min(24,(v.findings||0)*4)}px`}},v.id||v.created_at))}),Object.entries(c.contexts).map(([v,m])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:v})," — last ",((_=m[m.length-1])==null?void 0:_.findings)??0," findings"]},v)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(g0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((v,m)=>m[1]-v[1]).slice(0,12).map(([v,m])=>d.jsxs("tr",{children:[d.jsx("td",{children:io(v)}),d.jsx("td",{children:m})]},v))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function bm({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:m0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}jm(Nm());d0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(BN,{})}));export{Wk as L,GN as a,UN as c,d as j,YN as l,L as r,io as t}; diff --git a/src/loadpath/static/assets/index-cvBsmXkd.js b/src/loadpath/static/assets/index-cvBsmXkd.js new file mode 100644 index 0000000..fa22bbf --- /dev/null +++ b/src/loadpath/static/assets/index-cvBsmXkd.js @@ -0,0 +1,62 @@ +(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const u of a)if(u.type==="childList")for(const c of u.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function o(a){const u={};return a.integrity&&(u.integrity=a.integrity),a.referrerPolicy&&(u.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?u.credentials="include":a.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(a){if(a.ep)return;a.ep=!0;const u=o(a);fetch(a.href,u)}})();function bp(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Au={exports:{}},Uo={},$u={exports:{}},Te={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Qf;function r0(){if(Qf)return Te;Qf=1;var t=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),v=Symbol.iterator;function m(I){return I===null||typeof I!="object"?null:(I=v&&I[v]||I["@@iterator"],typeof I=="function"?I:null)}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,j={};function b(I,z,ie){this.props=I,this.context=z,this.refs=j,this.updater=ie||_}b.prototype.isReactComponent={},b.prototype.setState=function(I,z){if(typeof I!="object"&&typeof I!="function"&&I!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,I,z,"setState")},b.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function E(){}E.prototype=b.prototype;function R(I,z,ie){this.props=I,this.context=z,this.refs=j,this.updater=ie||_}var w=R.prototype=new E;w.constructor=R,k(w,b.prototype),w.isPureReactComponent=!0;var N=Array.isArray,A=Object.prototype.hasOwnProperty,$={current:null},F={key:!0,ref:!0,__self:!0,__source:!0};function G(I,z,ie){var oe,fe={},he=null,pe=null;if(z!=null)for(oe in z.ref!==void 0&&(pe=z.ref),z.key!==void 0&&(he=""+z.key),z)A.call(z,oe)&&!F.hasOwnProperty(oe)&&(fe[oe]=z[oe]);var Z=arguments.length-2;if(Z===1)fe.children=ie;else if(1>>1,z=M[I];if(0>>1;Ia(fe,H))hea(pe,fe)?(M[I]=pe,M[he]=H,I=he):(M[I]=fe,M[oe]=H,I=oe);else if(hea(pe,H))M[I]=pe,M[he]=H,I=he;else break e}}return D}function a(M,D){var H=M.sortIndex-D.sortIndex;return H!==0?H:M.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var c=Date,h=c.now();t.unstable_now=function(){return c.now()-h}}var p=[],y=[],x=1,v=null,m=3,_=!1,k=!1,j=!1,b=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(M){for(var D=o(y);D!==null;){if(D.callback===null)s(y);else if(D.startTime<=M)s(y),D.sortIndex=D.expirationTime,r(p,D);else break;D=o(y)}}function N(M){if(j=!1,w(M),!k)if(o(p)!==null)k=!0,W(A);else{var D=o(y);D!==null&&U(N,D.startTime-M)}}function A(M,D){k=!1,j&&(j=!1,E(G),G=-1),_=!0;var H=m;try{for(w(D),v=o(p);v!==null&&(!(v.expirationTime>D)||M&&!ee());){var I=v.callback;if(typeof I=="function"){v.callback=null,m=v.priorityLevel;var z=I(v.expirationTime<=D);D=t.unstable_now(),typeof z=="function"?v.callback=z:v===o(p)&&s(p),w(D)}else s(p);v=o(p)}if(v!==null)var ie=!0;else{var oe=o(y);oe!==null&&U(N,oe.startTime-D),ie=!1}return ie}finally{v=null,m=H,_=!1}}var $=!1,F=null,G=-1,q=5,te=-1;function ee(){return!(t.unstable_now()-teM||125I?(M.sortIndex=H,r(y,M),o(p)===null&&M===o(y)&&(j?(E(G),G=-1):j=!0,U(N,H-I))):(M.sortIndex=z,r(p,M),k||_||(k=!0,W(A))),M},t.unstable_shouldYield=ee,t.unstable_wrapCallback=function(M){var D=m;return function(){var H=m;m=D;try{return M.apply(this,arguments)}finally{m=H}}}})(Ou)),Ou}var nh;function a0(){return nh||(nh=1,Du.exports=l0()),Du.exports}/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var rh;function u0(){if(rh)return Dt;rh=1;var t=cs(),r=a0();function o(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,i=1;i"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),p=Object.prototype.hasOwnProperty,y=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,x={},v={};function m(e){return p.call(v,e)?!0:p.call(x,e)?!1:y.test(e)?v[e]=!0:(x[e]=!0,!1)}function _(e,n,i,l){if(i!==null&&i.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return l?!1:i!==null?!i.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function k(e,n,i,l){if(n===null||typeof n>"u"||_(e,n,i,l))return!0;if(l)return!1;if(i!==null)switch(i.type){case 3:return!n;case 4:return n===!1;case 5:return isNaN(n);case 6:return isNaN(n)||1>n}return!1}function j(e,n,i,l,f,g,S){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=l,this.attributeNamespace=f,this.mustUseProperty=i,this.propertyName=e,this.type=n,this.sanitizeURL=g,this.removeEmptyString=S}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){b[e]=new j(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];b[n]=new j(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){b[e]=new j(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){b[e]=new j(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){b[e]=new j(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){b[e]=new j(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){b[e]=new j(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){b[e]=new j(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){b[e]=new j(e,5,!1,e.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function R(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var n=e.replace(E,R);b[n]=new j(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){b[e]=new j(e,1,!1,e.toLowerCase(),null,!1,!1)}),b.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){b[e]=new j(e,1,!1,e.toLowerCase(),null,!0,!0)});function w(e,n,i,l){var f=b.hasOwnProperty(n)?b[n]:null;(f!==null?f.type!==0:l||!(2T||f[S]!==g[T]){var O=` +`+f[S].replace(" at new "," at ");return e.displayName&&O.includes("")&&(O=O.replace("",e.displayName)),O}while(1<=S&&0<=T);break}}}finally{ie=!1,Error.prepareStackTrace=i}return(e=e?e.displayName||e.name:"")?z(e):""}function fe(e){switch(e.tag){case 5:return z(e.type);case 16:return z("Lazy");case 13:return z("Suspense");case 19:return z("SuspenseList");case 0:case 2:case 15:return e=oe(e.type,!1),e;case 11:return e=oe(e.type.render,!1),e;case 1:return e=oe(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case F:return"Fragment";case $:return"Portal";case q:return"Profiler";case G:return"StrictMode";case K:return"Suspense";case C:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case ee:return(e.displayName||"Context")+".Consumer";case te:return(e._context.displayName||"Context")+".Provider";case ne:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case V:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case W:n=e._payload,e=e._init;try{return he(e(n))}catch{}}return null}function pe(e){var n=e.type;switch(e.tag){case 24:return"Cache";case 9:return(n.displayName||"Context")+".Consumer";case 10:return(n._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===G?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n}return null}function Z(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function me(e){var n=se(e)?"checked":"value",i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),l=""+e[n];if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,g=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function ke(e){e._valueTracker||(e._valueTracker=me(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var i=n.getValue(),l="";return e&&(l=se(e)?e.checked?"true":"false":e.value),e=l,e!==i?(n.setValue(e),!0):!1}function re(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ne(e,n){var i=n.checked;return H({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:i??e._wrapperState.initialChecked})}function Ie(e,n){var i=n.defaultValue==null?"":n.defaultValue,l=n.checked!=null?n.checked:n.defaultChecked;i=Z(n.value!=null?n.value:i),e._wrapperState={initialChecked:l,initialValue:i,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Le(e,n){n=n.checked,n!=null&&w(e,"checked",n,!1)}function $e(e,n){Le(e,n);var i=Z(n.value),l=n.type;if(i!=null)l==="number"?(i===0&&e.value===""||e.value!=i)&&(e.value=""+i):e.value!==""+i&&(e.value=""+i);else if(l==="submit"||l==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?at(e,n.type,i):n.hasOwnProperty("defaultValue")&&at(e,n.type,Z(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function lt(e,n,i){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var l=n.type;if(!(l!=="submit"&&l!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,i||n===e.value||(e.value=n),e.defaultValue=n}i=e.name,i!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,i!==""&&(e.name=i)}function at(e,n,i){(n!=="number"||re(e.ownerDocument)!==e)&&(i==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+i&&(e.defaultValue=""+i))}var ut=Array.isArray;function Ge(e,n,i,l){if(e=e.options,n){n={};for(var f=0;f"+n.valueOf().toString()+"",n=et.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Mt(e,n){if(n){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=n;return}}e.textContent=n}var kn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},oo=["Webkit","ms","Moz","O"];Object.keys(kn).forEach(function(e){oo.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),kn[n]=kn[e]})});function On(e,n,i){return n==null||typeof n=="boolean"||n===""?"":i||typeof n!="number"||n===0||kn.hasOwnProperty(e)&&kn[e]?(""+n).trim():n+"px"}function gi(e,n){e=e.style;for(var i in n)if(n.hasOwnProperty(i)){var l=i.indexOf("--")===0,f=On(i,n[i],l);i==="float"&&(i="cssFloat"),l?e.setProperty(i,f):e[i]=f}}var lr=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function zr(e,n){if(n){if(lr[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(o(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(o(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(o(61))}if(n.style!=null&&typeof n.style!="object")throw Error(o(62))}}function Fn(e,n){if(e.indexOf("-")===-1)return typeof n.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Dr=null;function ar(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ur=null,Ft=null,dt=null;function Hn(e){if(e=Po(e)){if(typeof ur!="function")throw Error(o(280));var n=e.stateNode;n&&(n=Ts(n),ur(e.stateNode,e.type,n))}}function Bn(e){Ft?dt?dt.push(e):dt=[e]:Ft=e}function Nn(){if(Ft){var e=Ft,n=dt;if(dt=Ft=null,Hn(e),n)for(e=0;e>>=0,e===0?32:31-(uo(e)/co|0)|0}var Mn=64,Xn=4194304;function Pn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function qt(e,n){var i=e.pendingLanes;if(i===0)return 0;var l=0,f=e.suspendedLanes,g=e.pingedLanes,S=i&268435455;if(S!==0){var T=S&~f;T!==0?l=Pn(T):(g&=S,g!==0&&(l=Pn(g)))}else S=i&~f,S!==0?l=Pn(S):g!==0&&(l=Pn(g));if(l===0)return 0;if(n!==0&&n!==l&&(n&f)===0&&(f=l&-l,g=n&-n,f>=g||f===16&&(g&4194240)!==0))return n;if((l&4)!==0&&(l|=i&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=l;0i;i++)n.push(e);return n}function qn(e,n,i){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-yt(n),e[n]=i}function _i(e,n){var i=e.pendingLanes&~n;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=n,e.mutableReadLanes&=n,e.entangledLanes&=n,n=e.entanglements;var l=e.eventTimes;for(e=e.expirationTimes;0=_o),Vc=" ",Wc=!1;function Uc(e,n){switch(e){case"keyup":return Zm.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Yc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var bi=!1;function ey(e,n){switch(e){case"compositionend":return Yc(n);case"keypress":return n.which!==32?null:(Wc=!0,Vc);case"textInput":return e=n.data,e===Vc&&Wc?null:e;default:return null}}function ty(e,n){if(bi)return e==="compositionend"||!ga&&Uc(e,n)?(e=zc(),Ss=ua=mr=null,bi=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-e};e=l}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Jc(i)}}function td(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?td(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function nd(){for(var e=window,n=re();n instanceof e.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)e=n.contentWindow;else break;n=re(e.document)}return n}function va(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}function cy(e){var n=nd(),i=e.focusedElem,l=e.selectionRange;if(n!==i&&i&&i.ownerDocument&&td(i.ownerDocument.documentElement,i)){if(l!==null&&va(i)){if(n=l.start,e=l.end,e===void 0&&(e=n),"selectionStart"in i)i.selectionStart=n,i.selectionEnd=Math.min(e,i.value.length);else if(e=(n=i.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var f=i.textContent.length,g=Math.min(l.start,f);l=l.end===void 0?g:Math.min(l.end,f),!e.extend&&g>l&&(f=l,l=g,g=f),f=ed(i,g);var S=ed(i,l);f&&S&&(e.rangeCount!==1||e.anchorNode!==f.node||e.anchorOffset!==f.offset||e.focusNode!==S.node||e.focusOffset!==S.offset)&&(n=n.createRange(),n.setStart(f.node,f.offset),e.removeAllRanges(),g>l?(e.addRange(n),e.extend(S.node,S.offset)):(n.setEnd(S.node,S.offset),e.addRange(n)))}}for(n=[],e=i;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i=document.documentMode,Ei=null,xa=null,jo=null,wa=!1;function rd(e,n,i){var l=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;wa||Ei==null||Ei!==re(l)||(l=Ei,"selectionStart"in l&&va(l)?l={start:l.selectionStart,end:l.selectionEnd}:(l=(l.ownerDocument&&l.ownerDocument.defaultView||window).getSelection(),l={anchorNode:l.anchorNode,anchorOffset:l.anchorOffset,focusNode:l.focusNode,focusOffset:l.focusOffset}),jo&&No(jo,l)||(jo=l,l=Ps(xa,"onSelect"),0Ri||(e.current=Ra[Ri],Ra[Ri]=null,Ri--)}function Be(e,n){Ri++,Ra[Ri]=e.current,e.current=n}var wr={},St=xr(wr),Tt=xr(!1),Xr=wr;function Ti(e,n){var i=e.type.contextTypes;if(!i)return wr;var l=e.stateNode;if(l&&l.__reactInternalMemoizedUnmaskedChildContext===n)return l.__reactInternalMemoizedMaskedChildContext;var f={},g;for(g in i)f[g]=n[g];return l&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=f),f}function Lt(e){return e=e.childContextTypes,e!=null}function Ls(){Ue(Tt),Ue(St)}function vd(e,n,i){if(St.current!==wr)throw Error(o(168));Be(St,n),Be(Tt,i)}function xd(e,n,i){var l=e.stateNode;if(n=n.childContextTypes,typeof l.getChildContext!="function")return i;l=l.getChildContext();for(var f in l)if(!(f in n))throw Error(o(108,pe(e)||"Unknown",f));return H({},i,l)}function As(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||wr,Xr=St.current,Be(St,e),Be(Tt,Tt.current),!0}function wd(e,n,i){var l=e.stateNode;if(!l)throw Error(o(169));i?(e=xd(e,n,Xr),l.__reactInternalMemoizedMergedChildContext=e,Ue(Tt),Ue(St),Be(St,e)):Ue(Tt),Be(Tt,i)}var Qn=null,$s=!1,Ta=!1;function _d(e){Qn===null?Qn=[e]:Qn.push(e)}function Sy(e){$s=!0,_d(e)}function _r(){if(!Ta&&Qn!==null){Ta=!0;var e=0,n=Fe;try{var i=Qn;for(Fe=1;e>=S,f-=S,Zn=1<<32-yt(n)+f|i<Ce?(pt=be,be=null):pt=be.sibling;var Oe=le(X,be,Q[Ce],de);if(Oe===null){be===null&&(be=pt);break}e&&be&&Oe.alternate===null&&n(X,be),B=g(Oe,B,Ce),je===null?_e=Oe:je.sibling=Oe,je=Oe,be=pt}if(Ce===Q.length)return i(X,be),Xe&&Kr(X,Ce),_e;if(be===null){for(;CeCe?(pt=be,be=null):pt=be.sibling;var Pr=le(X,be,Oe.value,de);if(Pr===null){be===null&&(be=pt);break}e&&be&&Pr.alternate===null&&n(X,be),B=g(Pr,B,Ce),je===null?_e=Pr:je.sibling=Pr,je=Pr,be=pt}if(Oe.done)return i(X,be),Xe&&Kr(X,Ce),_e;if(be===null){for(;!Oe.done;Ce++,Oe=Q.next())Oe=ue(X,Oe.value,de),Oe!==null&&(B=g(Oe,B,Ce),je===null?_e=Oe:je.sibling=Oe,je=Oe);return Xe&&Kr(X,Ce),_e}for(be=l(X,be);!Oe.done;Ce++,Oe=Q.next())Oe=ge(be,X,Ce,Oe.value,de),Oe!==null&&(e&&Oe.alternate!==null&&be.delete(Oe.key===null?Ce:Oe.key),B=g(Oe,B,Ce),je===null?_e=Oe:je.sibling=Oe,je=Oe);return e&&be.forEach(function(n0){return n(X,n0)}),Xe&&Kr(X,Ce),_e}function tt(X,B,Q,de){if(typeof Q=="object"&&Q!==null&&Q.type===F&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case A:e:{for(var _e=Q.key,je=B;je!==null;){if(je.key===_e){if(_e=Q.type,_e===F){if(je.tag===7){i(X,je.sibling),B=f(je,Q.props.children),B.return=X,X=B;break e}}else if(je.elementType===_e||typeof _e=="object"&&_e!==null&&_e.$$typeof===W&&Ed(_e)===je.type){i(X,je.sibling),B=f(je,Q.props),B.ref=Io(X,je,Q),B.return=X,X=B;break e}i(X,je);break}else n(X,je);je=je.sibling}Q.type===F?(B=ii(Q.props.children,X.mode,de,Q.key),B.return=X,X=B):(de=cl(Q.type,Q.key,Q.props,null,X.mode,de),de.ref=Io(X,B,Q),de.return=X,X=de)}return S(X);case $:e:{for(je=Q.key;B!==null;){if(B.key===je)if(B.tag===4&&B.stateNode.containerInfo===Q.containerInfo&&B.stateNode.implementation===Q.implementation){i(X,B.sibling),B=f(B,Q.children||[]),B.return=X,X=B;break e}else{i(X,B);break}else n(X,B);B=B.sibling}B=Pu(Q,X.mode,de),B.return=X,X=B}return S(X);case W:return je=Q._init,tt(X,B,je(Q._payload),de)}if(ut(Q))return xe(X,B,Q,de);if(D(Q))return we(X,B,Q,de);Fs(X,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"?(Q=""+Q,B!==null&&B.tag===6?(i(X,B.sibling),B=f(B,Q),B.return=X,X=B):(i(X,B),B=Mu(Q,X.mode,de),B.return=X,X=B),S(X)):i(X,B)}return tt}var zi=Cd(!0),Md=Cd(!1),Hs=xr(null),Bs=null,Di=null,Oa=null;function Fa(){Oa=Di=Bs=null}function Ha(e){var n=Hs.current;Ue(Hs),e._currentValue=n}function Ba(e,n,i){for(;e!==null;){var l=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,l!==null&&(l.childLanes|=n)):l!==null&&(l.childLanes&n)!==n&&(l.childLanes|=n),e===i)break;e=e.return}}function Oi(e,n){Bs=e,Oa=Di=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(At=!0),e.firstContext=null)}function Zt(e){var n=e._currentValue;if(Oa!==e)if(e={context:e,memoizedValue:n,next:null},Di===null){if(Bs===null)throw Error(o(308));Di=e,Bs.dependencies={lanes:0,firstContext:e}}else Di=Di.next=e;return n}var Qr=null;function Va(e){Qr===null?Qr=[e]:Qr.push(e)}function Pd(e,n,i,l){var f=n.interleaved;return f===null?(i.next=i,Va(n)):(i.next=f.next,f.next=i),n.interleaved=i,er(e,l)}function er(e,n){e.lanes|=n;var i=e.alternate;for(i!==null&&(i.lanes|=n),i=e,e=e.return;e!==null;)e.childLanes|=n,i=e.alternate,i!==null&&(i.childLanes|=n),i=e,e=e.return;return i.tag===3?i.stateNode:null}var Sr=!1;function Wa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Id(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function tr(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function kr(e,n,i){var l=e.updateQueue;if(l===null)return null;if(l=l.shared,(ze&2)!==0){var f=l.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),l.pending=n,er(e,i)}return f=l.interleaved,f===null?(n.next=n,Va(l)):(n.next=f.next,f.next=n),l.interleaved=n,er(e,i)}function Vs(e,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194240)!==0)){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}function Rd(e,n){var i=e.updateQueue,l=e.alternate;if(l!==null&&(l=l.updateQueue,i===l)){var f=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var S={eventTime:i.eventTime,lane:i.lane,tag:i.tag,payload:i.payload,callback:i.callback,next:null};g===null?f=g=S:g=g.next=S,i=i.next}while(i!==null);g===null?f=g=n:g=g.next=n}else f=g=n;i={baseState:l.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:l.shared,effects:l.effects},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=n:e.next=n,i.lastBaseUpdate=n}function Ws(e,n,i,l){var f=e.updateQueue;Sr=!1;var g=f.firstBaseUpdate,S=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var O=T,J=O.next;O.next=null,S===null?g=J:S.next=J,S=O;var ae=e.alternate;ae!==null&&(ae=ae.updateQueue,T=ae.lastBaseUpdate,T!==S&&(T===null?ae.firstBaseUpdate=J:T.next=J,ae.lastBaseUpdate=O))}if(g!==null){var ue=f.baseState;S=0,ae=J=O=null,T=g;do{var le=T.lane,ge=T.eventTime;if((l&le)===le){ae!==null&&(ae=ae.next={eventTime:ge,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var xe=e,we=T;switch(le=n,ge=i,we.tag){case 1:if(xe=we.payload,typeof xe=="function"){ue=xe.call(ge,ue,le);break e}ue=xe;break e;case 3:xe.flags=xe.flags&-65537|128;case 0:if(xe=we.payload,le=typeof xe=="function"?xe.call(ge,ue,le):xe,le==null)break e;ue=H({},ue,le);break e;case 2:Sr=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,le=f.effects,le===null?f.effects=[T]:le.push(T))}else ge={eventTime:ge,lane:le,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ae===null?(J=ae=ge,O=ue):ae=ae.next=ge,S|=le;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;le=T,T=le.next,le.next=null,f.lastBaseUpdate=le,f.shared.pending=null}}while(!0);if(ae===null&&(O=ue),f.baseState=O,f.firstBaseUpdate=J,f.lastBaseUpdate=ae,n=f.shared.interleaved,n!==null){f=n;do S|=f.lane,f=f.next;while(f!==n)}else g===null&&(f.shared.lanes=0);ei|=S,e.lanes=S,e.memoizedState=ue}}function Td(e,n,i){if(e=n.effects,n.effects=null,e!==null)for(n=0;ni?i:4,e(!0);var l=qa.transition;qa.transition={};try{e(!1),n()}finally{Fe=i,qa.transition=l}}function Zd(){return Jt().memoizedState}function by(e,n,i){var l=Er(e);if(i={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null},Jd(e))ef(n,i);else if(i=Pd(e,n,i,l),i!==null){var f=Et();gn(i,e,l,f),tf(i,n,l)}}function Ey(e,n,i){var l=Er(e),f={lane:l,action:i,hasEagerState:!1,eagerState:null,next:null};if(Jd(e))ef(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,T=g(S,i);if(f.hasEagerState=!0,f.eagerState=T,cn(T,S)){var O=n.interleaved;O===null?(f.next=f,Va(n)):(f.next=O.next,O.next=f),n.interleaved=f;return}}catch{}finally{}i=Pd(e,n,f,l),i!==null&&(f=Et(),gn(i,e,l,f),tf(i,n,l))}}function Jd(e){var n=e.alternate;return e===Ke||n!==null&&n===Ke}function ef(e,n){Ao=Gs=!0;var i=e.pending;i===null?n.next=n:(n.next=i.next,i.next=n),e.pending=n}function tf(e,n,i){if((i&4194240)!==0){var l=n.lanes;l&=e.pendingLanes,i|=l,n.lanes=i,pr(e,i)}}var Ks={readContext:Zt,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},Cy={readContext:Zt,useCallback:function(e,n){return Tn().memoizedState=[e,n===void 0?null:n],e},useContext:Zt,useEffect:Wd,useImperativeHandle:function(e,n,i){return i=i!=null?i.concat([e]):null,Xs(4194308,4,Gd.bind(null,n,e),i)},useLayoutEffect:function(e,n){return Xs(4194308,4,e,n)},useInsertionEffect:function(e,n){return Xs(4,2,e,n)},useMemo:function(e,n){var i=Tn();return n=n===void 0?null:n,e=e(),i.memoizedState=[e,n],e},useReducer:function(e,n,i){var l=Tn();return n=i!==void 0?i(n):n,l.memoizedState=l.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},l.queue=e,e=e.dispatch=by.bind(null,Ke,e),[l.memoizedState,e]},useRef:function(e){var n=Tn();return e={current:e},n.memoizedState=e},useState:Bd,useDebugValue:nu,useDeferredValue:function(e){return Tn().memoizedState=e},useTransition:function(){var e=Bd(!1),n=e[0];return e=jy.bind(null,e[1]),Tn().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,i){var l=Ke,f=Tn();if(Xe){if(i===void 0)throw Error(o(407));i=i()}else{if(i=n(),ht===null)throw Error(o(349));(Jr&30)!==0||zd(l,n,i)}f.memoizedState=i;var g={value:i,getSnapshot:n};return f.queue=g,Wd(Od.bind(null,l,g,e),[e]),l.flags|=2048,Do(9,Dd.bind(null,l,g,i,n),void 0,null),i},useId:function(){var e=Tn(),n=ht.identifierPrefix;if(Xe){var i=Jn,l=Zn;i=(l&~(1<<32-yt(l)-1)).toString(32)+i,n=":"+n+"R"+i,i=$o++,0<\/script>",e=e.removeChild(e.firstChild)):typeof l.is=="string"?e=S.createElement(i,{is:l.is}):(e=S.createElement(i),i==="select"&&(S=e,l.multiple?S.multiple=!0:l.size&&(S.size=l.size))):e=S.createElementNS(e,i),e[In]=n,e[Mo]=l,Sf(e,n,!1,!1),n.stateNode=e;e:{switch(S=Fn(i,l),i){case"dialog":We("cancel",e),We("close",e),f=l;break;case"iframe":case"object":case"embed":We("load",e),f=l;break;case"video":case"audio":for(f=0;fWi&&(n.flags|=128,l=!0,Oo(g,!1),n.lanes=4194304)}else{if(!l)if(e=Us(S),e!==null){if(n.flags|=128,l=!0,i=e.updateQueue,i!==null&&(n.updateQueue=i,n.flags|=4),Oo(g,!0),g.tail===null&&g.tailMode==="hidden"&&!S.alternate&&!Xe)return Nt(n),null}else 2*Ve()-g.renderingStartTime>Wi&&i!==1073741824&&(n.flags|=128,l=!0,Oo(g,!1),n.lanes=4194304);g.isBackwards?(S.sibling=n.child,n.child=S):(i=g.last,i!==null?i.sibling=S:n.child=S,g.last=S)}return g.tail!==null?(n=g.tail,g.rendering=n,g.tail=n.sibling,g.renderingStartTime=Ve(),n.sibling=null,i=qe.current,Be(qe,l?i&1|2:i&1),n):(Nt(n),null);case 22:case 23:return bu(),l=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==l&&(n.flags|=8192),l&&(n.mode&1)!==0?(Wt&1073741824)!==0&&(Nt(n),n.subtreeFlags&6&&(n.flags|=8192)):Nt(n),null;case 24:return null;case 25:return null}throw Error(o(156,n.tag))}function $y(e,n){switch(Aa(n),n.tag){case 1:return Lt(n.type)&&Ls(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Fi(),Ue(Tt),Ue(St),Xa(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Ya(n),null;case 13:if(Ue(qe),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));$i()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Ue(qe),null;case 4:return Fi(),null;case 10:return Ha(n.type._context),null;case 22:case 23:return bu(),null;case 24:return null;default:return null}}var el=!1,jt=!1,zy=typeof WeakSet=="function"?WeakSet:Set,ye=null;function Bi(e,n){var i=e.ref;if(i!==null)if(typeof i=="function")try{i(null)}catch(l){Je(e,n,l)}else i.current=null}function pu(e,n,i){try{i()}catch(l){Je(e,n,l)}}var jf=!1;function Dy(e,n){if(ba=ws,e=nd(),va(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var l=i.getSelection&&i.getSelection();if(l&&l.rangeCount!==0){i=l.anchorNode;var f=l.anchorOffset,g=l.focusNode;l=l.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var S=0,T=-1,O=-1,J=0,ae=0,ue=e,le=null;t:for(;;){for(var ge;ue!==i||f!==0&&ue.nodeType!==3||(T=S+f),ue!==g||l!==0&&ue.nodeType!==3||(O=S+l),ue.nodeType===3&&(S+=ue.nodeValue.length),(ge=ue.firstChild)!==null;)le=ue,ue=ge;for(;;){if(ue===e)break t;if(le===i&&++J===f&&(T=S),le===g&&++ae===l&&(O=S),(ge=ue.nextSibling)!==null)break;ue=le,le=ue.parentNode}ue=ge}i=T===-1||O===-1?null:{start:T,end:O}}else i=null}i=i||{start:0,end:0}}else i=null;for(Ea={focusedElem:e,selectionRange:i},ws=!1,ye=n;ye!==null;)if(n=ye,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,ye=e;else for(;ye!==null;){n=ye;try{var xe=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(xe!==null){var we=xe.memoizedProps,tt=xe.memoizedState,X=n.stateNode,B=X.getSnapshotBeforeUpdate(n.elementType===n.type?we:fn(n.type,we),tt);X.__reactInternalSnapshotBeforeUpdate=B}break;case 3:var Q=n.stateNode.containerInfo;Q.nodeType===1?Q.textContent="":Q.nodeType===9&&Q.documentElement&&Q.removeChild(Q.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(o(163))}}catch(de){Je(n,n.return,de)}if(e=n.sibling,e!==null){e.return=n.return,ye=e;break}ye=n.return}return xe=jf,jf=!1,xe}function Fo(e,n,i){var l=n.updateQueue;if(l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&e)===e){var g=f.destroy;f.destroy=void 0,g!==void 0&&pu(n,i,g)}f=f.next}while(f!==l)}}function tl(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&e)===e){var l=i.create;i.destroy=l()}i=i.next}while(i!==n)}}function gu(e){var n=e.ref;if(n!==null){var i=e.stateNode;switch(e.tag){case 5:e=i;break;default:e=i}typeof n=="function"?n(e):n.current=e}}function bf(e){var n=e.alternate;n!==null&&(e.alternate=null,bf(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[In],delete n[Mo],delete n[Ia],delete n[wy],delete n[_y])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Ef(e){return e.tag===5||e.tag===3||e.tag===4}function Cf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Ef(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function mu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.nodeType===8?i.parentNode.insertBefore(e,n):i.insertBefore(e,n):(i.nodeType===8?(n=i.parentNode,n.insertBefore(e,i)):(n=i,n.appendChild(e)),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=Rs));else if(l!==4&&(e=e.child,e!==null))for(mu(e,n,i),e=e.sibling;e!==null;)mu(e,n,i),e=e.sibling}function yu(e,n,i){var l=e.tag;if(l===5||l===6)e=e.stateNode,n?i.insertBefore(e,n):i.appendChild(e);else if(l!==4&&(e=e.child,e!==null))for(yu(e,n,i),e=e.sibling;e!==null;)yu(e,n,i),e=e.sibling}var vt=null,hn=!1;function Nr(e,n,i){for(i=i.child;i!==null;)Mf(e,n,i),i=i.sibling}function Mf(e,n,i){if(_t&&typeof _t.onCommitFiberUnmount=="function")try{_t.onCommitFiberUnmount(Cn,i)}catch{}switch(i.tag){case 5:jt||Bi(i,n);case 6:var l=vt,f=hn;vt=null,Nr(e,n,i),vt=l,hn=f,vt!==null&&(hn?(e=vt,i=i.stateNode,e.nodeType===8?e.parentNode.removeChild(i):e.removeChild(i)):vt.removeChild(i.stateNode));break;case 18:vt!==null&&(hn?(e=vt,i=i.stateNode,e.nodeType===8?Pa(e.parentNode,i):e.nodeType===1&&Pa(e,i),vo(e)):Pa(vt,i.stateNode));break;case 4:l=vt,f=hn,vt=i.stateNode.containerInfo,hn=!0,Nr(e,n,i),vt=l,hn=f;break;case 0:case 11:case 14:case 15:if(!jt&&(l=i.updateQueue,l!==null&&(l=l.lastEffect,l!==null))){f=l=l.next;do{var g=f,S=g.destroy;g=g.tag,S!==void 0&&((g&2)!==0||(g&4)!==0)&&pu(i,n,S),f=f.next}while(f!==l)}Nr(e,n,i);break;case 1:if(!jt&&(Bi(i,n),l=i.stateNode,typeof l.componentWillUnmount=="function"))try{l.props=i.memoizedProps,l.state=i.memoizedState,l.componentWillUnmount()}catch(T){Je(i,n,T)}Nr(e,n,i);break;case 21:Nr(e,n,i);break;case 22:i.mode&1?(jt=(l=jt)||i.memoizedState!==null,Nr(e,n,i),jt=l):Nr(e,n,i);break;default:Nr(e,n,i)}}function Pf(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var i=e.stateNode;i===null&&(i=e.stateNode=new zy),n.forEach(function(l){var f=Gy.bind(null,e,l);i.has(l)||(i.add(l),l.then(f,f))})}}function pn(e,n){var i=n.deletions;if(i!==null)for(var l=0;lf&&(f=S),l&=~g}if(l=f,l=Ve()-l,l=(120>l?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Fy(l/1960))-l,10e?16:e,br===null)var l=!1;else{if(e=br,br=null,sl=0,(ze&6)!==0)throw Error(o(331));var f=ze;for(ze|=4,ye=e.current;ye!==null;){var g=ye,S=g.child;if((ye.flags&16)!==0){var T=g.deletions;if(T!==null){for(var O=0;OVe()-wu?ni(e,0):xu|=i),zt(e,n)}function Vf(e,n){n===0&&((e.mode&1)===0?n=1:(n=Xn,Xn<<=1,(Xn&130023424)===0&&(Xn=4194304)));var i=Et();e=er(e,n),e!==null&&(qn(e,n,i),zt(e,i))}function Yy(e){var n=e.memoizedState,i=0;n!==null&&(i=n.retryLane),Vf(e,i)}function Gy(e,n){var i=0;switch(e.tag){case 13:var l=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(o(314))}l!==null&&l.delete(n),Vf(e,i)}var Wf;Wf=function(e,n,i){if(e!==null)if(e.memoizedProps!==n.pendingProps||Tt.current)At=!0;else{if((e.lanes&i)===0&&(n.flags&128)===0)return At=!1,Ly(e,n,i);At=(e.flags&131072)!==0}else At=!1,Xe&&(n.flags&1048576)!==0&&Sd(n,Ds,n.index);switch(n.lanes=0,n.tag){case 2:var l=n.type;Js(e,n),e=n.pendingProps;var f=Ti(n,St.current);Oi(n,i),f=Qa(null,n,l,e,f,i);var g=Za();return n.flags|=1,typeof f=="object"&&f!==null&&typeof f.render=="function"&&f.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,Lt(l)?(g=!0,As(n)):g=!1,n.memoizedState=f.state!==null&&f.state!==void 0?f.state:null,Wa(n),f.updater=Qs,n.stateNode=f,f._reactInternals=n,iu(n,l,e,i),n=au(null,n,l,!0,g,i)):(n.tag=0,Xe&&g&&La(n),bt(null,n,f,i),n=n.child),n;case 16:l=n.elementType;e:{switch(Js(e,n),e=n.pendingProps,f=l._init,l=f(l._payload),n.type=l,f=n.tag=qy(l),e=fn(l,e),f){case 0:n=lu(null,n,l,e,i);break e;case 1:n=mf(null,n,l,e,i);break e;case 11:n=df(null,n,l,e,i);break e;case 14:n=ff(null,n,l,fn(l.type,e),i);break e}throw Error(o(306,l,""))}return n;case 0:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:fn(l,f),lu(e,n,l,f,i);case 1:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:fn(l,f),mf(e,n,l,f,i);case 3:e:{if(yf(n),e===null)throw Error(o(387));l=n.pendingProps,g=n.memoizedState,f=g.element,Id(e,n),Ws(n,l,null,i);var S=n.memoizedState;if(l=S.element,g.isDehydrated)if(g={element:l,isDehydrated:!1,cache:S.cache,pendingSuspenseBoundaries:S.pendingSuspenseBoundaries,transitions:S.transitions},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){f=Hi(Error(o(423)),n),n=vf(e,n,l,i,f);break e}else if(l!==f){f=Hi(Error(o(424)),n),n=vf(e,n,l,i,f);break e}else for(Vt=vr(n.stateNode.containerInfo.firstChild),Bt=n,Xe=!0,dn=null,i=Md(n,null,l,i),n.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if($i(),l===f){n=nr(e,n,i);break e}bt(e,n,l,i)}n=n.child}return n;case 5:return Ld(n),e===null&&za(n),l=n.type,f=n.pendingProps,g=e!==null?e.memoizedProps:null,S=f.children,Ca(l,f)?S=null:g!==null&&Ca(l,g)&&(n.flags|=32),gf(e,n),bt(e,n,S,i),n.child;case 6:return e===null&&za(n),null;case 13:return xf(e,n,i);case 4:return Ua(n,n.stateNode.containerInfo),l=n.pendingProps,e===null?n.child=zi(n,null,l,i):bt(e,n,l,i),n.child;case 11:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:fn(l,f),df(e,n,l,f,i);case 7:return bt(e,n,n.pendingProps,i),n.child;case 8:return bt(e,n,n.pendingProps.children,i),n.child;case 12:return bt(e,n,n.pendingProps.children,i),n.child;case 10:e:{if(l=n.type._context,f=n.pendingProps,g=n.memoizedProps,S=f.value,Be(Hs,l._currentValue),l._currentValue=S,g!==null)if(cn(g.value,S)){if(g.children===f.children&&!Tt.current){n=nr(e,n,i);break e}}else for(g=n.child,g!==null&&(g.return=n);g!==null;){var T=g.dependencies;if(T!==null){S=g.child;for(var O=T.firstContext;O!==null;){if(O.context===l){if(g.tag===1){O=tr(-1,i&-i),O.tag=2;var J=g.updateQueue;if(J!==null){J=J.shared;var ae=J.pending;ae===null?O.next=O:(O.next=ae.next,ae.next=O),J.pending=O}}g.lanes|=i,O=g.alternate,O!==null&&(O.lanes|=i),Ba(g.return,i,n),T.lanes|=i;break}O=O.next}}else if(g.tag===10)S=g.type===n.type?null:g.child;else if(g.tag===18){if(S=g.return,S===null)throw Error(o(341));S.lanes|=i,T=S.alternate,T!==null&&(T.lanes|=i),Ba(S,i,n),S=g.sibling}else S=g.child;if(S!==null)S.return=g;else for(S=g;S!==null;){if(S===n){S=null;break}if(g=S.sibling,g!==null){g.return=S.return,S=g;break}S=S.return}g=S}bt(e,n,f.children,i),n=n.child}return n;case 9:return f=n.type,l=n.pendingProps.children,Oi(n,i),f=Zt(f),l=l(f),n.flags|=1,bt(e,n,l,i),n.child;case 14:return l=n.type,f=fn(l,n.pendingProps),f=fn(l.type,f),ff(e,n,l,f,i);case 15:return hf(e,n,n.type,n.pendingProps,i);case 17:return l=n.type,f=n.pendingProps,f=n.elementType===l?f:fn(l,f),Js(e,n),n.tag=1,Lt(l)?(e=!0,As(n)):e=!1,Oi(n,i),rf(n,l,f),iu(n,l,f,i),au(null,n,l,!0,e,i);case 19:return _f(e,n,i);case 22:return pf(e,n,i)}throw Error(o(156,n.tag))};function Uf(e,n){return Yn(e,n)}function Xy(e,n,i,l){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=l,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tn(e,n,i,l){return new Xy(e,n,i,l)}function Cu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function qy(e){if(typeof e=="function")return Cu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ne)return 11;if(e===V)return 14}return 2}function Mr(e,n){var i=e.alternate;return i===null?(i=tn(e.tag,n,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&14680064,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i}function cl(e,n,i,l,f,g){var S=2;if(l=e,typeof e=="function")Cu(e)&&(S=1);else if(typeof e=="string")S=5;else e:switch(e){case F:return ii(i.children,f,g,n);case G:S=8,f|=8;break;case q:return e=tn(12,i,n,f|2),e.elementType=q,e.lanes=g,e;case K:return e=tn(13,i,n,f),e.elementType=K,e.lanes=g,e;case C:return e=tn(19,i,n,f),e.elementType=C,e.lanes=g,e;case U:return dl(i,f,g,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case te:S=10;break e;case ee:S=9;break e;case ne:S=11;break e;case V:S=14;break e;case W:S=16,l=null;break e}throw Error(o(130,e==null?e:typeof e,""))}return n=tn(S,i,n,f),n.elementType=e,n.type=l,n.lanes=g,n}function ii(e,n,i,l){return e=tn(7,e,l,n),e.lanes=i,e}function dl(e,n,i,l){return e=tn(22,e,l,n),e.elementType=U,e.lanes=i,e.stateNode={isHidden:!1},e}function Mu(e,n,i){return e=tn(6,e,null,n),e.lanes=i,e}function Pu(e,n,i){return n=tn(4,e.children!==null?e.children:[],e.key,n),n.lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Ky(e,n,i,l,f){this.tag=n,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=sn(0),this.expirationTimes=sn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=sn(0),this.identifierPrefix=l,this.onRecoverableError=f,this.mutableSourceEagerHydrationData=null}function Iu(e,n,i,l,f,g,S,T,O){return e=new Ky(e,n,i,T,O),n===1?(n=1,g===!0&&(n|=8)):n=0,g=tn(3,null,null,n),e.current=g,g.stateNode=e,g.memoizedState={element:l,isDehydrated:i,cache:null,transitions:null,pendingSuspenseBoundaries:null},Wa(g),e}function Qy(e,n,i){var l=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),zu.exports=u0(),zu.exports}var oh;function c0(){if(oh)return vl;oh=1;var t=Ep();return vl.createRoot=t.createRoot,vl.hydrateRoot=t.hydrateRoot,vl}var d0=c0();function Cp(t,r="Request failed"){const o=(t||"").trim();if(!o)return r;try{const a=JSON.parse(o).detail;if(typeof a=="string"&&a.trim())return a;if(Array.isArray(a)){const u=a.map(c=>typeof c=="string"?c:c&&typeof c=="object"&&"msg"in c?String(c.msg):"").filter(Boolean);if(u.length)return u.join("; ")}}catch{}return o}async function Ae(t,r){const o=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!o.ok){const s=await o.text();throw new Error(Cp(s,o.statusText||"Request failed"))}return o.json()}const f0=["github_token","gitlab_token","gitlab_oauth_client_secret","bitbucket_token","bitbucket_oauth_client_secret","ai_api_key","ai_model","ai_base_url"],Re={health:()=>Ae("/api/health"),settings:()=>Ae("/api/settings"),saveSettings:t=>{const r={...t};for(const o of f0)r[o]===""&&delete r[o];return Ae("/api/settings",{method:"PUT",body:JSON.stringify(r)})},repos:()=>Ae("/api/repos"),browse:t=>Ae(`/api/fs${t?`?path=${encodeURIComponent(t)}`:""}`),gitRefs:(t,r=50)=>Ae(`/api/git/refs?repo_path=${encodeURIComponent(t)}&limit=${r}`),index:(t,r=!0)=>Ae("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>Ae(`/api/index?repo_path=${encodeURIComponent(t)}`),indexProgress:t=>Ae(`/api/index/progress?repo_path=${encodeURIComponent(t)}`),architecture:(t,r=!0)=>Ae(`/api/architecture?repo_path=${encodeURIComponent(t)}&graph=${r?"1":"0"}`),architectureGraph:t=>Ae(`/api/architecture/graph?repo_path=${encodeURIComponent(t)}`),review:(t,r,o,s=!0,a=!1)=>Ae("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:o||null,reindex:s,incremental:!0,three_dot:!0,dirty:a})}),whatIf:(t,r)=>Ae("/api/whatif",{method:"POST",body:JSON.stringify({repo_path:t,node_id:r})}),reviewPr:(t,r,o,s)=>Ae("/api/prs/review",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,repo_path:s||null})}),init:(t,r=!1)=>Ae("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,o,s)=>Ae("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:o,markdown:s})}),graph:(t,r="full")=>Ae(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,o="open",s)=>Ae("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:o,repo_path:s||null})}),scmRepos:t=>Ae(`/api/scm/repos?provider=${encodeURIComponent(t)}`),oauthStatus:()=>Ae("/api/oauth/status"),githubOAuthStart:()=>Ae("/api/oauth/github/start",{method:"POST",body:"{}"}),githubOAuthPoll:t=>Ae("/api/oauth/github/poll",{method:"POST",body:JSON.stringify({flow_id:t})}),bitbucketOAuthStart:()=>Ae("/api/oauth/bitbucket/start"),gitlabOAuthStart:()=>Ae("/api/oauth/gitlab/start"),oauthDisconnect:t=>Ae("/api/oauth/disconnect",{method:"POST",body:JSON.stringify({provider:t})}),residual:t=>Ae("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})}),reviews:t=>Ae(`/api/reviews?repo_path=${encodeURIComponent(t)}`),getReview:(t,r)=>Ae(`/api/reviews/${encodeURIComponent(r)}?repo_path=${encodeURIComponent(t)}`),reviewDiff:(t,r,o)=>Ae(`/api/reviews/${encodeURIComponent(r)}/diff?repo_path=${encodeURIComponent(t)}&other=${encodeURIComponent(o)}`),config:t=>Ae(`/api/config?repo_path=${encodeURIComponent(t)}`),saveConfig:(t,r)=>Ae("/api/config",{method:"PUT",body:JSON.stringify({repo_path:t,...r})}),addWaiver:(t,r,o,s)=>Ae("/api/config/waiver",{method:"POST",body:JSON.stringify({repo_path:t,rule:r,node:o||null,reason:s||""})}),marks:(t,r)=>Ae(`/api/marks?repo_path=${encodeURIComponent(t)}${r?`&review_id=${encodeURIComponent(r)}`:""}`),architectureHealth:t=>Ae(`/api/architecture/health?repo_path=${encodeURIComponent(t)}`),workspaceStatus:t=>Ae(`/api/workspace/status?repo_path=${encodeURIComponent(t)}`),openEditor:(t,r,o,s)=>Ae("/api/open",{method:"POST",body:JSON.stringify({repo_path:t,path:r,line:o||null,editor:s||null})}),exportHtml:t=>fetch("/api/export/html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({review:t})}).then(async r=>{if(!r.ok){const o=await r.text();throw new Error(Cp(o,r.statusText||"Request failed"))}return r.blob()}),isolate:(t,r,o,s)=>Ae("/api/graph/isolate",{method:"POST",body:JSON.stringify({nodes:t,edges:r,source_id:o,target_id:s||null})})};function h0(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.label.toLowerCase().includes(o)||(s.hint||"").toLowerCase().includes(o)||(s.group||"").toLowerCase().includes(o)):t}function p0({open:t,actions:r,onClose:o}){const[s,a]=L.useState(""),[u,c]=L.useState(0),h=L.useRef(null),p=L.useMemo(()=>h0(r,s),[r,s]);if(L.useEffect(()=>{if(!t)return;a(""),c(0);const m=window.setTimeout(()=>{var _;return(_=h.current)==null?void 0:_.focus()},0);return()=>window.clearTimeout(m)},[t]),L.useEffect(()=>{c(0)},[s]),!t)return null;const y=p.slice(0,40),x=y[Math.min(u,Math.max(y.length-1,0))],v=m=>{m&&(o(),m.run())};return d.jsx("div",{className:"palette-scrim","data-testid":"command-palette",onClick:m=>{m.target===m.currentTarget&&o()},children:d.jsxs("div",{className:"palette",role:"dialog","aria-label":"Command palette",children:[d.jsx("input",{ref:h,"data-testid":"command-palette-input",placeholder:"Jump to a node, run a review, toggle overlays…",value:s,onChange:m=>a(m.target.value),onKeyDown:m=>{m.key==="Escape"?(m.preventDefault(),o()):m.key==="ArrowDown"?(m.preventDefault(),c(_=>Math.min(Math.max(y.length-1,0),_+1))):m.key==="ArrowUp"?(m.preventDefault(),c(_=>Math.max(0,_-1))):m.key==="Enter"&&(m.preventDefault(),v(x))}}),d.jsxs("ul",{children:[y.length===0?d.jsx("li",{className:"muted",children:"No matches"}):null,y.map((m,_)=>d.jsx("li",{children:d.jsxs("button",{type:"button",className:_===u?"active":"",onMouseEnter:()=>c(_),onClick:()=>v(m),children:[d.jsx("span",{children:m.label}),m.hint?d.jsx("span",{className:"muted",children:m.hint}):null]})},m.id))]}),d.jsxs("div",{className:"palette-foot muted",children:[d.jsx("kbd",{children:"↑"}),d.jsx("kbd",{children:"↓"})," move · ",d.jsx("kbd",{children:"Enter"})," run · ",d.jsx("kbd",{children:"Esc"})," close"]})]})})}function g0({config:t,busy:r,onSave:o,onWaiver:s}){const[a,u]=L.useState(t),[c,h]=L.useState(t.available_rules[0]||""),[p,y]=L.useState(""),[x,v]=L.useState("");L.useEffect(()=>{u(t)},[t]);const m=Object.entries(a.contexts||{}),_=(R,w,N)=>{const A=a.contexts[R];if(!A)return;const $=F=>F.split(",").map(G=>G.trim()).filter(Boolean);u({...a,contexts:{...a.contexts,[R]:{...A,[w]:w==="name"?N:$(N)}}})},k=(R,w)=>{const N=w.trim();if(!N||N===R)return;const{[R]:A,...$}=a.contexts;A&&u({...a,contexts:{...$,[N]:{...A,name:N}}})},j=()=>{let R=1;for(;a.contexts[`context-${R}`];)R+=1;const w=`context-${R}`;u({...a,contexts:{...a.contexts,[w]:{name:w,django_apps:[],react:[],public_api:[],owners:[]}}})},b=R=>{const{[R]:w,...N}=a.contexts;u({...a,contexts:N})},E=R=>{const w=a.rules.includes(R);u({...a,rules:w?a.rules.filter(N=>N!==R):[...a.rules,R]})};return d.jsxs("div",{className:"config-editor","data-testid":"config-editor",children:[d.jsx("p",{className:"muted",children:a.exists?a.path:"No loadpath.yml yet — saving writes one at the repo root."}),m.map(([R,w])=>d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Context ",d.jsx("span",{className:"count",children:R})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{defaultValue:R,"data-testid":`config-context-name-${R}`,onBlur:N=>k(R,N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Django apps"}),d.jsx("input",{value:(w.django_apps||[]).join(", "),onChange:N=>_(R,"django_apps",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"React folders"}),d.jsx("input",{value:(w.react||[]).join(", "),onChange:N=>_(R,"react",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Public API"}),d.jsx("input",{value:(w.public_api||[]).join(", "),onChange:N=>_(R,"public_api",N.target.value)})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Owners"}),d.jsx("input",{value:(w.owners||[]).join(", "),onChange:N=>_(R,"owners",N.target.value)})]}),d.jsx("button",{type:"button",className:"btn",onClick:()=>b(R),children:"Remove context"})]},R)),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-context",onClick:j,children:"Add context"})}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:a.rules.length})]}),(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsxs("label",{className:"check-row",children:[d.jsx("input",{type:"checkbox",checked:a.rules.includes(R),onChange:()=>E(R)}),R]},R))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Waivers ",d.jsx("span",{className:"count",children:(a.waivers||[]).length})]}),(a.waivers||[]).map((R,w)=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:R.rule}),R.node?` · ${R.node}`:"",R.reason?` — ${R.reason}`:""]},`${R.rule}:${R.node}:${w}`)),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Rule"}),d.jsx("select",{value:c,onChange:R=>h(R.target.value),children:(a.available_rules.length?a.available_rules:a.rules).map(R=>d.jsx("option",{value:R,children:R},R))})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Node id (optional)"}),d.jsx("input",{value:p,onChange:R=>y(R.target.value),placeholder:"django.view:…"})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Reason"}),d.jsx("input",{value:x,onChange:R=>v(R.target.value)})]}),d.jsx("button",{type:"button",className:"btn","data-testid":"config-add-waiver",disabled:r||!c,onClick:()=>s==null?void 0:s(c,p,x),children:"Add waiver"})]}),d.jsx("div",{className:"btn-row",children:d.jsx("button",{type:"button",className:"btn primary","data-testid":"config-save",disabled:r,onClick:()=>o(a),children:"Save loadpath.yml"})})]})}function Zo(t){return t.replaceAll("_"," ")}function m0(t){return t.replaceAll("_"," ")}function io(t){return t.split(".").pop()||t}function nc(t){if(!t)return"";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function y0(t){return t.split(/[\\/]/).filter(Boolean).pop()||t}function Lr(t){return t.replace(/([/\\._:@-])/g,"$1​")}function pi({className:t,children:r}){return d.jsx("svg",{className:t,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})}function v0({className:t}){return d.jsxs(pi,{className:t,children:[d.jsx("path",{d:"M3 3.5h6.5L13 7v5.5H3z"}),d.jsx("path",{d:"M9.5 3.5V7H13"}),d.jsx("path",{d:"M5.5 9.5h5M5.5 11.5h3.5"})]})}function x0({className:t}){return d.jsxs(pi,{className:t,children:[d.jsx("rect",{x:"2.5",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"2.5",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"2.5",y:"9",width:"4.5",height:"4.5",rx:"0.8"}),d.jsx("rect",{x:"9",y:"9",width:"4.5",height:"4.5",rx:"0.8"})]})}function w0({className:t}){return d.jsxs(pi,{className:t,children:[d.jsx("circle",{cx:"4",cy:"8",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"4",r:"1.6"}),d.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),d.jsx("path",{d:"M5.5 7.2 10.4 4.8M5.5 8.8 10.4 11.2"})]})}function _0({className:t}){return d.jsxs(pi,{className:t,children:[d.jsx("circle",{cx:"4.5",cy:"4",r:"1.4"}),d.jsx("circle",{cx:"4.5",cy:"12",r:"1.4"}),d.jsx("circle",{cx:"11.5",cy:"12",r:"1.4"}),d.jsx("path",{d:"M4.5 5.5v5M4.5 8h4.2a3 3 0 0 1 3 3"})]})}function S0({className:t}){return d.jsxs(pi,{className:t,children:[d.jsx("circle",{cx:"8",cy:"8",r:"2.1"}),d.jsx("path",{d:"M8 2.5v1.6M8 11.9v1.6M2.5 8h1.6M11.9 8h1.6M4.1 4.1l1.1 1.1M10.8 10.8l1.1 1.1M11.9 4.1l-1.1 1.1M5.2 10.8l-1.1 1.1"})]})}function Mp({className:t}){return d.jsx(pi,{className:t,children:d.jsx("path",{d:"M2.5 4.5h4L8 6h5.5v6.5h-11z"})})}function k0({className:t}){return d.jsx(pi,{className:t,children:d.jsx("path",{d:"M4 6.5 8 10.5 12 6.5"})})}const N0="modulepreload",j0=function(t,r){return new URL(t,r).href},sh={},b0=function(r,o,s){let a=Promise.resolve();if(o&&o.length>0){let c=function(x){return Promise.all(x.map(v=>Promise.resolve(v).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};const h=document.getElementsByTagName("link"),p=document.querySelector("meta[property=csp-nonce]"),y=(p==null?void 0:p.nonce)||(p==null?void 0:p.getAttribute("nonce"));a=c(o.map(x=>{if(x=j0(x,s),x in sh)return;sh[x]=!0;const v=x.endsWith(".css"),m=v?'[rel="stylesheet"]':"";if(!!s)for(let j=h.length-1;j>=0;j--){const b=h[j];if(b.href===x&&(!v||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${x}"]${m}`))return;const k=document.createElement("link");if(k.rel=v?"stylesheet":N0,v||(k.as="script"),k.crossOrigin="",k.href=x,y&&k.setAttribute("nonce",y),document.head.appendChild(k),v)return new Promise((j,b)=>{k.addEventListener("load",j),k.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${x}`)))})}))}function u(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&u(h.reason);return r().catch(u)})};function rt(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let o=0,s;o{}};function Xl(){for(var t=0,r=arguments.length,o={},s;t=0&&(s=o.slice(a+1),o=o.slice(0,a)),o&&!r.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:s}})}Pl.prototype=Xl.prototype={constructor:Pl,on:function(t,r){var o=this._,s=C0(t+"",o),a,u=-1,c=s.length;if(arguments.length<2){for(;++u0)for(var o=new Array(a),s=0,a,u;s=0&&(r=t.slice(0,o))!=="xmlns"&&(t=t.slice(o+1)),ah.hasOwnProperty(r)?{space:ah[r],local:t}:t}function P0(t){return function(){var r=this.ownerDocument,o=this.namespaceURI;return o===rc&&r.documentElement.namespaceURI===rc?r.createElement(t):r.createElementNS(o,t)}}function I0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Pp(t){var r=ql(t);return(r.local?I0:P0)(r)}function R0(){}function yc(t){return t==null?R0:function(){return this.querySelector(t)}}function T0(t){typeof t!="function"&&(t=yc(t));for(var r=this._groups,o=r.length,s=new Array(o),a=0;a=w&&(w=R+1);!(A=b[w])&&++w=0;)(c=s[a])&&(u&&c.compareDocumentPosition(u)^4&&u.parentNode.insertBefore(c,u),u=c);return this}function iv(t){t||(t=ov);function r(v,m){return v&&m?t(v.__data__,m.__data__):!v-!m}for(var o=this._groups,s=o.length,a=new Array(s),u=0;ur?1:t>=r?0:NaN}function sv(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function lv(){return Array.from(this)}function av(){for(var t=this._groups,r=0,o=t.length;r1?this.each((r==null?xv:typeof r=="function"?_v:wv)(t,r,o??"")):Ki(this.node(),t)}function Ki(t,r){return t.style.getPropertyValue(r)||Ap(t).getComputedStyle(t,null).getPropertyValue(r)}function kv(t){return function(){delete this[t]}}function Nv(t,r){return function(){this[t]=r}}function jv(t,r){return function(){var o=r.apply(this,arguments);o==null?delete this[t]:this[t]=o}}function bv(t,r){return arguments.length>1?this.each((r==null?kv:typeof r=="function"?jv:Nv)(t,r)):this.node()[t]}function $p(t){return t.trim().split(/^|\s+/)}function vc(t){return t.classList||new zp(t)}function zp(t){this._node=t,this._names=$p(t.getAttribute("class")||"")}zp.prototype={add:function(t){var r=this._names.indexOf(t);r<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var r=this._names.indexOf(t);r>=0&&(this._names.splice(r,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Dp(t,r){for(var o=vc(t),s=-1,a=r.length;++s=0&&(o=r.slice(s+1),r=r.slice(0,s)),{type:r,name:o}})}function ex(t){return function(){var r=this.__on;if(r){for(var o=0,s=-1,a=r.length,u;o()=>t;function ic(t,{sourceEvent:r,subject:o,target:s,identifier:a,active:u,x:c,y:h,dx:p,dy:y,dispatch:x}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:u,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:y,enumerable:!0,configurable:!0},_:{value:x}})}ic.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function cx(t){return!t.ctrlKey&&!t.button}function dx(){return this.parentNode}function fx(t,r){return r??{x:t.x,y:t.y}}function hx(){return navigator.maxTouchPoints||"ontouchstart"in this}function Wp(){var t=cx,r=dx,o=fx,s=hx,a={},u=Xl("start","drag","end"),c=0,h,p,y,x,v=0;function m(N){N.on("mousedown.drag",_).filter(s).on("touchstart.drag",b).on("touchmove.drag",E,ux).on("touchend.drag touchcancel.drag",R).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(N,A){if(!(x||!t.call(this,N,A))){var $=w(this,r.call(this,N,A),N,A,"mouse");$&&(Ut(N.view).on("mousemove.drag",k,Jo).on("mouseup.drag",j,Jo),Bp(N.view),Fu(N),y=!1,h=N.clientX,p=N.clientY,$("start",N))}}function k(N){if(Xi(N),!y){var A=N.clientX-h,$=N.clientY-p;y=A*A+$*$>v}a.mouse("drag",N)}function j(N){Ut(N.view).on("mousemove.drag mouseup.drag",null),Vp(N.view,y),Xi(N),a.mouse("end",N)}function b(N,A){if(t.call(this,N,A)){var $=N.changedTouches,F=r.call(this,N,A),G=$.length,q,te;for(q=0;q>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):o===8?wl(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):o===4?wl(r>>12&15|r>>8&240,r>>8&15|r>>4&240,r>>4&15|r&240,((r&15)<<4|r&15)/255):null):(r=gx.exec(t))?new Ot(r[1],r[2],r[3],1):(r=mx.exec(t))?new Ot(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=yx.exec(t))?wl(r[1],r[2],r[3],r[4]):(r=vx.exec(t))?wl(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=xx.exec(t))?gh(r[1],r[2]/100,r[3]/100,1):(r=wx.exec(t))?gh(r[1],r[2]/100,r[3]/100,r[4]):uh.hasOwnProperty(t)?fh(uh[t]):t==="transparent"?new Ot(NaN,NaN,NaN,0):null}function fh(t){return new Ot(t>>16&255,t>>8&255,t&255,1)}function wl(t,r,o,s){return s<=0&&(t=r=o=NaN),new Ot(t,r,o,s)}function kx(t){return t instanceof fs||(t=ui(t)),t?(t=t.rgb(),new Ot(t.r,t.g,t.b,t.opacity)):new Ot}function oc(t,r,o,s){return arguments.length===1?kx(t):new Ot(t,r,o,s??1)}function Ot(t,r,o,s){this.r=+t,this.g=+r,this.b=+o,this.opacity=+s}xc(Ot,oc,Up(fs,{brighter(t){return t=t==null?$l:Math.pow($l,t),new Ot(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?es:Math.pow(es,t),new Ot(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Ot(li(this.r),li(this.g),li(this.b),zl(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:hh,formatHex:hh,formatHex8:Nx,formatRgb:ph,toString:ph}));function hh(){return`#${si(this.r)}${si(this.g)}${si(this.b)}`}function Nx(){return`#${si(this.r)}${si(this.g)}${si(this.b)}${si((isNaN(this.opacity)?1:this.opacity)*255)}`}function ph(){const t=zl(this.opacity);return`${t===1?"rgb(":"rgba("}${li(this.r)}, ${li(this.g)}, ${li(this.b)}${t===1?")":`, ${t})`}`}function zl(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function li(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function si(t){return t=li(t),(t<16?"0":"")+t.toString(16)}function gh(t,r,o,s){return s<=0?t=r=o=NaN:o<=0||o>=1?t=r=NaN:r<=0&&(t=NaN),new yn(t,r,o,s)}function Yp(t){if(t instanceof yn)return new yn(t.h,t.s,t.l,t.opacity);if(t instanceof fs||(t=ui(t)),!t)return new yn;if(t instanceof yn)return t;t=t.rgb();var r=t.r/255,o=t.g/255,s=t.b/255,a=Math.min(r,o,s),u=Math.max(r,o,s),c=NaN,h=u-a,p=(u+a)/2;return h?(r===u?c=(o-s)/h+(o0&&p<1?0:c,new yn(c,h,p,t.opacity)}function jx(t,r,o,s){return arguments.length===1?Yp(t):new yn(t,r,o,s??1)}function yn(t,r,o,s){this.h=+t,this.s=+r,this.l=+o,this.opacity=+s}xc(yn,jx,Up(fs,{brighter(t){return t=t==null?$l:Math.pow($l,t),new yn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?es:Math.pow(es,t),new yn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,r=isNaN(t)||isNaN(this.s)?0:this.s,o=this.l,s=o+(o<.5?o:1-o)*r,a=2*o-s;return new Ot(Hu(t>=240?t-240:t+120,a,s),Hu(t,a,s),Hu(t<120?t+240:t-120,a,s),this.opacity)},clamp(){return new yn(mh(this.h),_l(this.s),_l(this.l),zl(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 t=zl(this.opacity);return`${t===1?"hsl(":"hsla("}${mh(this.h)}, ${_l(this.s)*100}%, ${_l(this.l)*100}%${t===1?")":`, ${t})`}`}}));function mh(t){return t=(t||0)%360,t<0?t+360:t}function _l(t){return Math.max(0,Math.min(1,t||0))}function Hu(t,r,o){return(t<60?r+(o-r)*t/60:t<180?o:t<240?r+(o-r)*(240-t)/60:r)*255}const wc=t=>()=>t;function bx(t,r){return function(o){return t+o*r}}function Ex(t,r,o){return t=Math.pow(t,o),r=Math.pow(r,o)-t,o=1/o,function(s){return Math.pow(t+s*r,o)}}function Cx(t){return(t=+t)==1?Gp:function(r,o){return o-r?Ex(r,o,t):wc(isNaN(r)?o:r)}}function Gp(t,r){var o=r-t;return o?bx(t,o):wc(isNaN(t)?r:t)}const Dl=(function t(r){var o=Cx(r);function s(a,u){var c=o((a=oc(a)).r,(u=oc(u)).r),h=o(a.g,u.g),p=o(a.b,u.b),y=Gp(a.opacity,u.opacity);return function(x){return a.r=c(x),a.g=h(x),a.b=p(x),a.opacity=y(x),a+""}}return s.gamma=t,s})(1);function Mx(t,r){r||(r=[]);var o=t?Math.min(r.length,t.length):0,s=r.slice(),a;return function(u){for(a=0;ao&&(u=r.slice(o,u),h[c]?h[c]+=u:h[++c]=u),(s=s[0])===(a=a[0])?h[c]?h[c]+=a:h[++c]=a:(h[++c]=null,p.push({i:c,x:An(s,a)})),o=Bu.lastIndex;return o180?x+=360:x-y>180&&(y+=360),m.push({i:v.push(a(v)+"rotate(",null,s)-2,x:An(y,x)})):x&&v.push(a(v)+"rotate("+x+s)}function h(y,x,v,m){y!==x?m.push({i:v.push(a(v)+"skewX(",null,s)-2,x:An(y,x)}):x&&v.push(a(v)+"skewX("+x+s)}function p(y,x,v,m,_,k){if(y!==v||x!==m){var j=_.push(a(_)+"scale(",null,",",null,")");k.push({i:j-4,x:An(y,v)},{i:j-2,x:An(x,m)})}else(v!==1||m!==1)&&_.push(a(_)+"scale("+v+","+m+")")}return function(y,x){var v=[],m=[];return y=t(y),x=t(x),u(y.translateX,y.translateY,x.translateX,x.translateY,v,m),c(y.rotate,x.rotate,v,m),h(y.skewX,x.skewX,v,m),p(y.scaleX,y.scaleY,x.scaleX,x.scaleY,v,m),y=x=null,function(_){for(var k=-1,j=m.length,b;++k=0&&t._call.call(void 0,r),t=t._next;--Qi}function xh(){ci=(Fl=ns.now())+Kl,Qi=Xo=0;try{Wx()}finally{Qi=0,Yx(),ci=0}}function Ux(){var t=ns.now(),r=t-Fl;r>Qp&&(Kl-=r,Fl=t)}function Yx(){for(var t,r=Ol,o,s=1/0;r;)r._call?(s>r._time&&(s=r._time),t=r,r=r._next):(o=r._next,r._next=null,r=t?t._next=o:Ol=o);qo=t,ac(s)}function ac(t){if(!Qi){Xo&&(Xo=clearTimeout(Xo));var r=t-ci;r>24?(t<1/0&&(Xo=setTimeout(xh,t-ns.now()-Kl)),Yo&&(Yo=clearInterval(Yo))):(Yo||(Fl=ns.now(),Yo=setInterval(Ux,Qp)),Qi=1,Zp(xh))}}function wh(t,r,o){var s=new Hl;return r=r==null?0:+r,s.restart(a=>{s.stop(),t(a+r)},r,o),s}var Gx=Xl("start","end","cancel","interrupt"),Xx=[],eg=0,_h=1,uc=2,Rl=3,Sh=4,cc=5,Tl=6;function Ql(t,r,o,s,a,u){var c=t.__transition;if(!c)t.__transition={};else if(o in c)return;qx(t,o,{name:r,index:s,group:a,on:Gx,tween:Xx,time:u.time,delay:u.delay,duration:u.duration,ease:u.ease,timer:null,state:eg})}function Sc(t,r){var o=_n(t,r);if(o.state>eg)throw new Error("too late; already scheduled");return o}function zn(t,r){var o=_n(t,r);if(o.state>Rl)throw new Error("too late; already running");return o}function _n(t,r){var o=t.__transition;if(!o||!(o=o[r]))throw new Error("transition not found");return o}function qx(t,r,o){var s=t.__transition,a;s[r]=o,o.timer=Jp(u,0,o.time);function u(y){o.state=_h,o.timer.restart(c,o.delay,o.time),o.delay<=y&&c(y-o.delay)}function c(y){var x,v,m,_;if(o.state!==_h)return p();for(x in s)if(_=s[x],_.name===o.name){if(_.state===Rl)return wh(c);_.state===Sh?(_.state=Tl,_.timer.stop(),_.on.call("interrupt",t,t.__data__,_.index,_.group),delete s[x]):+xuc&&s.state=0&&(r=r.slice(0,o)),!r||r==="start"})}function jw(t,r,o){var s,a,u=Nw(r)?Sc:zn;return function(){var c=u(this,t),h=c.on;h!==s&&(a=(s=h).copy()).on(r,o),c.on=a}}function bw(t,r){var o=this._id;return arguments.length<2?_n(this.node(),o).on.on(t):this.each(jw(o,t,r))}function Ew(t){return function(){var r=this.parentNode;for(var o in this.__transition)if(+o!==t)return;r&&r.removeChild(this)}}function Cw(){return this.on("end.remove",Ew(this._id))}function Mw(t){var r=this._name,o=this._id;typeof t!="function"&&(t=yc(t));for(var s=this._groups,a=s.length,u=new Array(a),c=0;c()=>t;function e1(t,{sourceEvent:r,target:o,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function or(t,r,o){this.k=t,this.x=r,this.y=o}or.prototype={constructor:or,scale:function(t){return t===1?this:new or(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new or(this.k,this.x+this.k*t,this.y+this.k*r)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Zl=new or(1,0,0);ig.prototype=or.prototype;function ig(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Zl;return t.__zoom}function Vu(t){t.stopImmediatePropagation()}function Go(t){t.preventDefault(),t.stopImmediatePropagation()}function t1(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function n1(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function kh(){return this.__zoom||Zl}function r1(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function i1(){return navigator.maxTouchPoints||"ontouchstart"in this}function o1(t,r,o){var s=t.invertX(r[0][0])-o[0][0],a=t.invertX(r[1][0])-o[1][0],u=t.invertY(r[0][1])-o[0][1],c=t.invertY(r[1][1])-o[1][1];return t.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),c>u?(u+c)/2:Math.min(0,u)||Math.max(0,c))}function og(){var t=t1,r=n1,o=o1,s=r1,a=i1,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],h=250,p=Il,y=Xl("start","zoom","end"),x,v,m,_=500,k=150,j=0,b=10;function E(C){C.property("__zoom",kh).on("wheel.zoom",G,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",te).filter(a).on("touchstart.zoom",ee).on("touchmove.zoom",ne).on("touchend.zoom touchcancel.zoom",K).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(C,V,W,U){var M=C.selection?C.selection():C;M.property("__zoom",kh),C!==M?A(C,V,W,U):M.interrupt().each(function(){$(this,arguments).event(U).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},E.scaleBy=function(C,V,W,U){E.scaleTo(C,function(){var M=this.__zoom.k,D=typeof V=="function"?V.apply(this,arguments):V;return M*D},W,U)},E.scaleTo=function(C,V,W,U){E.transform(C,function(){var M=r.apply(this,arguments),D=this.__zoom,H=W==null?N(M):typeof W=="function"?W.apply(this,arguments):W,I=D.invert(H),z=typeof V=="function"?V.apply(this,arguments):V;return o(w(R(D,z),H,I),M,c)},W,U)},E.translateBy=function(C,V,W,U){E.transform(C,function(){return o(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),r.apply(this,arguments),c)},null,U)},E.translateTo=function(C,V,W,U,M){E.transform(C,function(){var D=r.apply(this,arguments),H=this.__zoom,I=U==null?N(D):typeof U=="function"?U.apply(this,arguments):U;return o(Zl.translate(I[0],I[1]).scale(H.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),D,c)},U,M)};function R(C,V){return V=Math.max(u[0],Math.min(u[1],V)),V===C.k?C:new or(V,C.x,C.y)}function w(C,V,W){var U=V[0]-W[0]*C.k,M=V[1]-W[1]*C.k;return U===C.x&&M===C.y?C:new or(C.k,U,M)}function N(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function A(C,V,W,U){C.on("start.zoom",function(){$(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(U).end()}).tween("zoom",function(){var M=this,D=arguments,H=$(M,D).event(U),I=r.apply(M,D),z=W==null?N(I):typeof W=="function"?W.apply(M,D):W,ie=Math.max(I[1][0]-I[0][0],I[1][1]-I[0][1]),oe=M.__zoom,fe=typeof V=="function"?V.apply(M,D):V,he=p(oe.invert(z).concat(ie/oe.k),fe.invert(z).concat(ie/fe.k));return function(pe){if(pe===1)pe=fe;else{var Z=he(pe),se=ie/Z[2];pe=new or(se,z[0]-Z[0]*se,z[1]-Z[1]*se)}H.zoom(null,pe)}})}function $(C,V,W){return!W&&C.__zooming||new F(C,V)}function F(C,V){this.that=C,this.args=V,this.active=0,this.sourceEvent=null,this.extent=r.apply(C,V),this.taps=0}F.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,V){return this.mouse&&C!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var V=Ut(this.that).datum();y.call(C,this.that,new e1(C,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:y}),V)}};function G(C,...V){if(!t.apply(this,arguments))return;var W=$(this,V).event(C),U=this.__zoom,M=Math.max(u[0],Math.min(u[1],U.k*Math.pow(2,s.apply(this,arguments)))),D=mn(C);if(W.wheel)(W.mouse[0][0]!==D[0]||W.mouse[0][1]!==D[1])&&(W.mouse[1]=U.invert(W.mouse[0]=D)),clearTimeout(W.wheel);else{if(U.k===M)return;W.mouse=[D,U.invert(D)],Ll(this),W.start()}Go(C),W.wheel=setTimeout(H,k),W.zoom("mouse",o(w(R(U,M),W.mouse[0],W.mouse[1]),W.extent,c));function H(){W.wheel=null,W.end()}}function q(C,...V){if(m||!t.apply(this,arguments))return;var W=C.currentTarget,U=$(this,V,!0).event(C),M=Ut(C.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",ie,!0),D=mn(C,W),H=C.clientX,I=C.clientY;Bp(C.view),Vu(C),U.mouse=[D,this.__zoom.invert(D)],Ll(this),U.start();function z(oe){if(Go(oe),!U.moved){var fe=oe.clientX-H,he=oe.clientY-I;U.moved=fe*fe+he*he>j}U.event(oe).zoom("mouse",o(w(U.that.__zoom,U.mouse[0]=mn(oe,W),U.mouse[1]),U.extent,c))}function ie(oe){M.on("mousemove.zoom mouseup.zoom",null),Vp(oe.view,U.moved),Go(oe),U.event(oe).end()}}function te(C,...V){if(t.apply(this,arguments)){var W=this.__zoom,U=mn(C.changedTouches?C.changedTouches[0]:C,this),M=W.invert(U),D=W.k*(C.shiftKey?.5:2),H=o(w(R(W,D),U,M),r.apply(this,V),c);Go(C),h>0?Ut(this).transition().duration(h).call(A,H,U,C):Ut(this).call(E.transform,H,U,C)}}function ee(C,...V){if(t.apply(this,arguments)){var W=C.touches,U=W.length,M=$(this,V,C.changedTouches.length===U).event(C),D,H,I,z;for(Vu(C),H=0;H`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:r,sourceHandle:o,targetHandle:s})=>`Couldn't create edge for ${t} handle id: "${t==="source"?o:s}", edge id: ${r}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},rs=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],sg=["Enter"," ","Escape"],lg={"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:t,x:r,y:o})=>`Moved selected node ${t}. New position, x: ${r}, y: ${o}`,"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 Zi;(function(t){t.Strict="strict",t.Loose="loose"})(Zi||(Zi={}));var ai;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(ai||(ai={}));var is;(function(t){t.Partial="partial",t.Full="full"})(is||(is={}));const ag={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ar;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Ar||(Ar={}));var os;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(os||(os={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const Nh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function ug(t){return t===null?null:t?"valid":"invalid"}const cg=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,s1=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),Nc=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),hs=(t,r=[0,0])=>{const{width:o,height:s}=Sn(t),a=t.origin??r,u=o*a[0],c=s*a[1];return{x:t.position.x-u,y:t.position.y-c}},l1=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let o=!1;const s=t.reduce((a,u)=>{const c=typeof u=="string";let h=!r.nodeLookup&&!c?u:void 0;return r.nodeLookup&&(h=c?r.nodeLookup.get(u):Nc(u)?u:r.nodeLookup.get(u.id)),h?(o=!0,Jl(a,Bl(h,r.nodeOrigin))):a},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return o?ea(s):{x:0,y:0,width:0,height:0}},ps=(t,r={})=>{let o={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return t.forEach(a=>{(r.filter===void 0||r.filter(a))&&(o=Jl(o,Bl(a)),s=!0)}),s?ea(o):{x:0,y:0,width:0,height:0}},jc=(t,r,[o,s,a]=[0,0,1],u=!1,c=!1)=>{const h=(r.x-o)/a,p=(r.y-s)/a,y=r.width/a,x=r.height/a,v=[];for(const m of t.values()){const{measured:_,selectable:k=!0,hidden:j=!1}=m;if(c&&!k||j)continue;const b=_.width??m.width??m.initialWidth??0,E=_.height??m.height??m.initialHeight??0,{x:R,y:w}=m.internals.positionAbsolute,N=pg(h,p,y,x,R,w,b,E),A=b*E,$=u&&N>0;(!m.internals.handleBounds||$||N>=A||m.dragging)&&v.push(m)}return v},a1=(t,r)=>{const o=new Set;return t.forEach(s=>{o.add(s.id)}),r.filter(s=>o.has(s.source)||o.has(s.target))};function u1(t,r){const o=new Map,s=r!=null&&r.nodes?new Set(r.nodes.map(a=>a.id)):null;return t.forEach(a=>{let u;if(r!=null&&r.includeHiddenNodes){const{width:c,height:h}=Sn(a);u=c>0&&h>0}else u=!!(a.measured.width&&a.measured.height&&!a.hidden);u&&(!s||s.has(a.id))&&o.set(a.id,a)}),o}async function c1({nodes:t,width:r,height:o,panZoom:s,minZoom:a,maxZoom:u},c){if(t.size===0)return!0;const h=u1(t,c),p=ps(h),y=Ec(p,r,o,(c==null?void 0:c.minZoom)??a,(c==null?void 0:c.maxZoom)??u,(c==null?void 0:c.padding)??.1);return await s.setViewport(y,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function dg({nodeId:t,nextPosition:r,nodeLookup:o,nodeOrigin:s=[0,0],nodeExtent:a,onError:u}){const c=o.get(t),h=c.parentId?o.get(c.parentId):void 0,{x:p,y}=h?h.internals.positionAbsolute:{x:0,y:0},x=c.origin??s;let v=c.extent||a;if(c.extent==="parent"&&!c.expandParent)if(!h)u==null||u("005",wn.error005());else{const{width:_,height:k}=Sn(h);_&&k&&(v=[[p,y],[p+_,y+k]])}else h&&fi(c.extent)&&(v=[[c.extent[0][0]+p,c.extent[0][1]+y],[c.extent[1][0]+p,c.extent[1][1]+y]]);const m=fi(v)?di(r,v,c.measured):r;return(c.measured.width===void 0||c.measured.height===void 0)&&(u==null||u("015",wn.error015())),{position:{x:m.x-p+(c.measured.width??0)*x[0],y:m.y-y+(c.measured.height??0)*x[1]},positionAbsolute:m}}async function d1({nodesToRemove:t=[],edgesToRemove:r=[],nodes:o,edges:s,onBeforeDelete:a}){const u=new Set(t.map(m=>m.id)),c=[];for(const m of o){if(m.deletable===!1)continue;const _=u.has(m.id),k=!_&&m.parentId&&c.find(j=>j.id===m.parentId);(_||k)&&c.push(m)}const h=new Set(r.map(m=>m.id)),p=s.filter(m=>m.deletable!==!1),x=a1(c,p);for(const m of p)h.has(m.id)&&!x.find(k=>k.id===m.id)&&x.push(m);if(!a)return{edges:x,nodes:c};const v=await a({nodes:c,edges:x});return typeof v=="boolean"?v?{edges:x,nodes:c}:{edges:[],nodes:[]}:v}const Ji=(t,r=0,o=1)=>Math.min(Math.max(t,r),o),di=(t={x:0,y:0},r,o)=>({x:Ji(t.x,r[0][0],r[1][0]-((o==null?void 0:o.width)??0)),y:Ji(t.y,r[0][1],r[1][1]-((o==null?void 0:o.height)??0))});function fg(t,r,o){const{width:s,height:a}=Sn(o),{x:u,y:c}=o.internals.positionAbsolute;return di(t,[[u,c],[u+s,c+a]],r)}const jh=(t,r,o)=>to?-Ji(Math.abs(t-o),1,r)/r:0,bc=(t,r,o=15,s=40)=>{const a=jh(t.x,s,r.width-s)*o,u=jh(t.y,s,r.height-s)*o;return[a,u]},Jl=(t,r)=>({x:Math.min(t.x,r.x),y:Math.min(t.y,r.y),x2:Math.max(t.x2,r.x2),y2:Math.max(t.y2,r.y2)}),dc=({x:t,y:r,width:o,height:s})=>({x:t,y:r,x2:t+o,y2:r+s}),ea=({x:t,y:r,x2:o,y2:s})=>({x:t,y:r,width:o-t,height:s-r}),ss=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=Nc(t)?t.internals.positionAbsolute:hs(t,r);return{x:o,y:s,width:((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0,height:((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0}},Bl=(t,r=[0,0])=>{var a,u;const{x:o,y:s}=Nc(t)?t.internals.positionAbsolute:hs(t,r);return{x:o,y:s,x2:o+(((a=t.measured)==null?void 0:a.width)??t.width??t.initialWidth??0),y2:s+(((u=t.measured)==null?void 0:u.height)??t.height??t.initialHeight??0)}},hg=(t,r)=>ea(Jl(dc(t),dc(r))),pg=(t,r,o,s,a,u,c,h)=>{const p=Math.max(0,Math.min(t+o,a+c)-Math.max(t,a)),y=Math.max(0,Math.min(r+s,u+h)-Math.max(r,u));return Math.ceil(p*y)},Vl=(t,r)=>pg(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),bh=t=>vn(t.width)&&vn(t.height)&&vn(t.x)&&vn(t.y),vn=t=>!isNaN(t)&&isFinite(t),gg=(t,r)=>(o,s)=>{},gs=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),ms=({x:t,y:r},[o,s,a],u=!1,c=[1,1])=>{const h={x:(t-o)/a,y:(r-s)/a};return u?gs(h,c):h},eo=({x:t,y:r},[o,s,a])=>({x:t*a+o,y:r*a+s});function Yi(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(o)}if(typeof t=="string"&&t.endsWith("%")){const o=parseFloat(t);if(!Number.isNaN(o))return Math.floor(r*o*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function f1(t,r,o){if(typeof t=="string"||typeof t=="number"){const s=Yi(t,o),a=Yi(t,r);return{top:s,right:a,bottom:s,left:a,x:a*2,y:s*2}}if(typeof t=="object"){const s=Yi(t.top??t.y??0,o),a=Yi(t.bottom??t.y??0,o),u=Yi(t.left??t.x??0,r),c=Yi(t.right??t.x??0,r);return{top:s,right:c,bottom:a,left:u,x:u+c,y:s+a}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function h1(t,r,o,s,a,u){const{x:c,y:h}=eo(t,[r,o,s]),{x:p,y}=eo({x:t.x+t.width,y:t.y+t.height},[r,o,s]),x=a-p,v=u-y;return{left:Math.floor(c),top:Math.floor(h),right:Math.floor(x),bottom:Math.floor(v)}}const Ec=(t,r,o,s,a,u)=>{const c=f1(u,r,o),h=(r-c.x)/t.width,p=(o-c.y)/t.height,y=Math.min(h,p),x=Ji(y,s,a),v=t.x+t.width/2,m=t.y+t.height/2,_=r/2-v*x,k=o/2-m*x,j=h1(t,_,k,x,r,o),b={left:Math.min(j.left-c.left,0),top:Math.min(j.top-c.top,0),right:Math.min(j.right-c.right,0),bottom:Math.min(j.bottom-c.bottom,0)};return{x:_-b.left+b.right,y:k-b.top+b.bottom,zoom:x}},ls=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function fi(t){return t!=null&&t!=="parent"}function Sn(t){var r,o;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight??0}}function mg(t){var r,o;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((o=t.measured)==null?void 0:o.height)??t.height??t.initialHeight)!==void 0}function yg(t,r={width:0,height:0},o,s,a){const u={...t},c=s.get(o);if(c){const h=c.origin||a;u.x+=c.internals.positionAbsolute.x-(r.width??0)*h[0],u.y+=c.internals.positionAbsolute.y-(r.height??0)*h[1]}return u}function Eh(t,r){if(t.size!==r.size)return!1;for(const o of t)if(!r.has(o))return!1;return!0}function p1(){let t,r;return{promise:new Promise((s,a)=>{t=s,r=a}),resolve:t,reject:r}}function g1(t){return{...lg,...t||{}}}function Qo(t,{snapGrid:r=[0,0],snapToGrid:o=!1,transform:s,containerBounds:a}){const{x:u,y:c}=xn(t),h=ms({x:u-((a==null?void 0:a.left)??0),y:c-((a==null?void 0:a.top)??0)},s),{x:p,y}=o?gs(h,r):h;return{xSnapped:p,ySnapped:y,...h}}const Cc=t=>({width:t.offsetWidth,height:t.offsetHeight}),vg=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},m1=["INPUT","SELECT","TEXTAREA"];function xg(t){var s,a;const r=((a=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:a[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:m1.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const wg=t=>"clientX"in t,xn=(t,r)=>{var u,c;const o=wg(t),s=o?t.clientX:(u=t.touches)==null?void 0:u[0].clientX,a=o?t.clientY:(c=t.touches)==null?void 0:c[0].clientY;return{x:s-((r==null?void 0:r.left)??0),y:a-((r==null?void 0:r.top)??0)}},Ch=(t,r,o,s,a)=>{const u=r.querySelectorAll(`.${t}`);return!u||!u.length?null:Array.from(u).map(c=>{const h=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:t,nodeId:a,position:c.getAttribute("data-handlepos"),x:(h.left-o.left)/s,y:(h.top-o.top)/s,...Cc(c)}})};function _g({sourceX:t,sourceY:r,targetX:o,targetY:s,sourceControlX:a,sourceControlY:u,targetControlX:c,targetControlY:h}){const p=t*.125+a*.375+c*.375+o*.125,y=r*.125+u*.375+h*.375+s*.125,x=Math.abs(p-t),v=Math.abs(y-r);return[p,y,x,v]}function Nl(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function Mh({pos:t,x1:r,y1:o,x2:s,y2:a,c:u}){switch(t){case Se.Left:return[r-Nl(r-s,u),o];case Se.Right:return[r+Nl(s-r,u),o];case Se.Top:return[r,o-Nl(o-a,u)];case Se.Bottom:return[r,o+Nl(a-o,u)]}}function Sg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top,curvature:c=.25}){const[h,p]=Mh({pos:o,x1:t,y1:r,x2:s,y2:a,c}),[y,x]=Mh({pos:u,x1:s,y1:a,x2:t,y2:r,c}),[v,m,_,k]=_g({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:h,sourceControlY:p,targetControlX:y,targetControlY:x});return[`M${t},${r} C${h},${p} ${y},${x} ${s},${a}`,v,m,_,k]}function kg({sourceX:t,sourceY:r,targetX:o,targetY:s}){const a=Math.abs(o-t)/2,u=o0}const x1=({source:t,sourceHandle:r,target:o,targetHandle:s})=>`xy-edge__${t}${r||""}-${o}${s||""}`,w1=(t,r)=>r.some(o=>o.source===t.source&&o.target===t.target&&(o.sourceHandle===t.sourceHandle||!o.sourceHandle&&!t.sourceHandle)&&(o.targetHandle===t.targetHandle||!o.targetHandle&&!t.targetHandle)),_1=(t,r,o={})=>{var u;if(!t.source||!t.target)return(u=o.onError)==null||u.call(o,"006",wn.error006()),r;const s=o.getEdgeId||x1;let a;return cg(t)?a={...t}:a={...t,id:s(t)},w1(a,r)?r:(a.sourceHandle===null&&delete a.sourceHandle,a.targetHandle===null&&delete a.targetHandle,r.concat(a))};function Ng({sourceX:t,sourceY:r,targetX:o,targetY:s}){const[a,u,c,h]=kg({sourceX:t,sourceY:r,targetX:o,targetY:s});return[`M ${t},${r}L ${o},${s}`,a,u,c,h]}const Ph={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},S1=({source:t,sourcePosition:r=Se.Bottom,target:o})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function k1({source:t,sourcePosition:r=Se.Bottom,target:o,targetPosition:s=Se.Top,center:a,offset:u,stepPosition:c}){const h=Ph[r],p=Ph[s],y={x:t.x+h.x*u,y:t.y+h.y*u},x={x:o.x+p.x*u,y:o.y+p.y*u},v=S1({source:y,sourcePosition:r,target:x}),m=v.x!==0?"x":"y",_=v[m];let k=[],j,b;const E={x:0,y:0},R={x:0,y:0},[,,w,N]=kg({sourceX:t.x,sourceY:t.y,targetX:o.x,targetY:o.y});if(h[m]*p[m]===-1){m==="x"?(j=a.x??y.x+(x.x-y.x)*c,b=a.y??(y.y+x.y)/2):(j=a.x??(y.x+x.x)/2,b=a.y??y.y+(x.y-y.y)*c);const G=[{x:j,y:y.y},{x:j,y:x.y}],q=[{x:y.x,y:b},{x:x.x,y:b}];h[m]===_?k=m==="x"?G:q:k=m==="x"?q:G}else{const G=[{x:y.x,y:x.y}],q=[{x:x.x,y:y.y}];if(m==="x"?k=h.x===_?q:G:k=h.y===_?G:q,r===s){const C=Math.abs(t[m]-o[m]);if(C<=u){const V=Math.min(u-1,u-C);h[m]===_?E[m]=(y[m]>t[m]?-1:1)*V:R[m]=(x[m]>o[m]?-1:1)*V}}if(r!==s){const C=m==="x"?"y":"x",V=h[m]===p[C],W=y[C]>x[C],U=y[C]=K?(j=(te.x+ee.x)/2,b=k[0].y):(j=k[0].x,b=(te.y+ee.y)/2)}const A={x:y.x+E.x,y:y.y+E.y},$={x:x.x+R.x,y:x.y+R.y};return[[t,...A.x!==k[0].x||A.y!==k[0].y?[A]:[],...k,...$.x!==k[k.length-1].x||$.y!==k[k.length-1].y?[$]:[],o],j,b,w,N]}function N1(t,r,o,s){const a=Math.min(Ih(t,r)/2,Ih(r,o)/2,s),{x:u,y:c}=r;if(t.x===u&&u===o.x||t.y===c&&c===o.y)return`L${u} ${c}`;if(t.y===c){const y=t.xo.id===r):t[0])||null}function fc(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(s=>`${s}=${t[s]}`).join("&")}`:""}function b1(t,{id:r,defaultColor:o,defaultMarkerStart:s,defaultMarkerEnd:a}){const u=new Set;return t.reduce((c,h)=>([h.markerStart||s,h.markerEnd||a].forEach(p=>{if(p&&typeof p=="object"){const y=fc(p,r);u.has(y)||(c.push({id:y,color:p.color||o,...p}),u.add(y))}}),c),[]).sort((c,h)=>c.id.localeCompare(h.id))}const jg=1e3,E1=10,Mc={nodeOrigin:[0,0],nodeExtent:rs,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},C1={...Mc,checkEquality:!0};function Pc(t,r){const o={...t};for(const s in r)r[s]!==void 0&&(o[s]=r[s]);return o}function M1(t,r,o){const s=Pc(Mc,o);for(const a of t.values())if(a.parentId)Rc(a,t,r,s);else{const u=hs(a,s.nodeOrigin),c=fi(a.extent)?a.extent:s.nodeExtent,h=di(u,c,Sn(a));a.internals.positionAbsolute=h}}function P1(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const o=[],s=[];for(const a of t.handles){const u={id:a.id,width:a.width??1,height:a.height??1,nodeId:t.id,x:a.x,y:a.y,position:a.position,type:a.type};a.type==="source"?o.push(u):a.type==="target"&&s.push(u)}return{source:o,target:s}}function Ic(t){return t==="manual"}function hc(t,r,o,s={}){var x,v;const a=Pc(C1,s),u={i:0},c=new Map(r),h=a!=null&&a.elevateNodesOnSelect&&!Ic(a.zIndexMode)?jg:0;let p=t.length>0,y=!1;r.clear(),o.clear();for(const m of t){let _=c.get(m.id);if(a.checkEquality&&m===(_==null?void 0:_.internals.userNode))r.set(m.id,_);else{const k=hs(m,a.nodeOrigin),j=fi(m.extent)?m.extent:a.nodeExtent,b=di(k,j,Sn(m));_={...a.defaults,...m,measured:{width:(x=m.measured)==null?void 0:x.width,height:(v=m.measured)==null?void 0:v.height},internals:{positionAbsolute:b,handleBounds:P1(m,_),z:bg(m,h,a.zIndexMode),userNode:m}},r.set(m.id,_)}(_.measured===void 0||_.measured.width===void 0||_.measured.height===void 0)&&!_.hidden&&(p=!1),m.parentId&&Rc(_,r,o,s,u),y||(y=m.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:y}}function I1(t,r){if(!t.parentId)return;const o=r.get(t.parentId);o?o.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function Rc(t,r,o,s,a){const{elevateNodesOnSelect:u,nodeOrigin:c,nodeExtent:h,zIndexMode:p}=Pc(Mc,s),y=t.parentId,x=r.get(y);if(!x){console.warn(`Parent node ${y} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}I1(t,o),a&&!x.parentId&&x.internals.rootParentIndex===void 0&&p==="auto"&&(x.internals.rootParentIndex=++a.i,x.internals.z=x.internals.z+a.i*E1),a&&x.internals.rootParentIndex!==void 0&&(a.i=x.internals.rootParentIndex);const v=u&&!Ic(p)?jg:0,{x:m,y:_,z:k}=R1(t,x,c,h,v,p),{positionAbsolute:j}=t.internals,b=m!==j.x||_!==j.y;(b||k!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:b?{x:m,y:_}:j,z:k}})}function bg(t,r,o){const s=vn(t.zIndex)?t.zIndex:0;return Ic(o)?s:s+(t.selected?r:0)}function R1(t,r,o,s,a,u){const{x:c,y:h}=r.internals.positionAbsolute,p=Sn(t),y=hs(t,o),x=fi(t.extent)?di(y,t.extent,p):y;let v=di({x:c+x.x,y:h+x.y},s,p);t.extent==="parent"&&(v=fg(v,p,r));const m=bg(t,a,u),_=r.internals.z??0;return{x:v.x,y:v.y,z:_>=m?_+1:m}}function Tc(t,r,o,s=[0,0]){var c;const a=[],u=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const y=((c=u.get(h.parentId))==null?void 0:c.expandedRect)??ss(p),x=hg(y,h.rect);u.set(h.parentId,{expandedRect:x,parent:p})}return u.size>0&&u.forEach(({expandedRect:h,parent:p},y)=>{var w;const x=p.internals.positionAbsolute,v=Sn(p),m=p.origin??s,_=h.x0||k>0||E||R)&&(a.push({id:y,type:"position",position:{x:p.position.x-_+E,y:p.position.y-k+R}}),(w=o.get(y))==null||w.forEach(N=>{t.some(A=>A.id===N.id)||a.push({id:N.id,type:"position",position:{x:N.position.x+_,y:N.position.y+k}})})),(v.width0){const _=Tc(m,r,o,a);y.push(..._)}return{changes:y,updatedInternals:p}}async function L1({delta:t,panZoom:r,transform:o,translateExtent:s,width:a,height:u}){if(!r||!t.x&&!t.y)return!1;const c=await r.setViewportConstrained({x:o[0]+t.x,y:o[1]+t.y,zoom:o[2]},[[0,0],[a,u]],s);return!!c&&(c.x!==o[0]||c.y!==o[1]||c.k!==o[2])}function Ah(t,r,o,s,a,u){let c=a;const h=s.get(c)||new Map;s.set(c,h.set(o,r)),c=`${a}-${t}`;const p=s.get(c)||new Map;if(s.set(c,p.set(o,r)),u){c=`${a}-${t}-${u}`;const y=s.get(c)||new Map;s.set(c,y.set(o,r))}}function Eg(t,r,o){t.clear(),r.clear();for(const s of o){const{source:a,target:u,sourceHandle:c=null,targetHandle:h=null}=s,p={edgeId:s.id,source:a,target:u,sourceHandle:c,targetHandle:h},y=`${a}-${c}--${u}-${h}`,x=`${u}-${h}--${a}-${c}`;Ah("source",p,x,t,a,c),Ah("target",p,y,t,u,h),r.set(s.id,s)}}function Cg(t,r){if(!t.parentId)return!1;const o=r.get(t.parentId);return o?o.selected?!0:Cg(o,r):!1}function $h(t,r,o){var a;let s=t;do{if((a=s==null?void 0:s.matches)!=null&&a.call(s,r))return!0;if(s===o)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function A1(t,r,o,s){const a=new Map;for(const[u,c]of t)if((c.selected||c.id===s)&&(!c.parentId||!Cg(c,t))&&(c.draggable||r&&typeof c.draggable>"u")){const h=t.get(u);h&&a.set(u,{id:u,position:h.position||{x:0,y:0},distance:{x:o.x-h.internals.positionAbsolute.x,y:o.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return a}function Wu({nodeId:t,dragItems:r,nodeLookup:o,dragging:s=!0}){var c,h,p;const a=[];for(const[y,x]of r){const v=(c=o.get(y))==null?void 0:c.internals.userNode;v&&a.push({...v,position:x.position,dragging:s})}if(!t)return[a[0],a];const u=(h=o.get(t))==null?void 0:h.internals.userNode;return[u?{...u,position:((p=r.get(t))==null?void 0:p.position)||u.position,dragging:s}:a[0],a]}function $1({dragItems:t,snapGrid:r,x:o,y:s}){const a=t.values().next().value;if(!a)return null;const u={x:o-a.distance.x,y:s-a.distance.y},c=gs(u,r);return{x:c.x-u.x,y:c.y-u.y}}function z1({onNodeMouseDown:t,getStoreItems:r,onDragStart:o,onDrag:s,onDragStop:a}){let u={x:null,y:null},c=0,h=new Map,p=!1,y={x:0,y:0},x=null,v=!1,m=null,_=!1,k=!1,j=null;function b({noDragClassName:R,handleSelector:w,domNode:N,isSelectable:A,nodeId:$,nodeClickDistance:F=0}){m=Ut(N);function G({x:ne,y:K}){const{nodeLookup:C,nodeExtent:V,snapGrid:W,snapToGrid:U,nodeOrigin:M,onNodeDrag:D,onSelectionDrag:H,onError:I,updateNodePositions:z}=r();u={x:ne,y:K};let ie=!1;const oe=h.size>1,fe=oe&&V?dc(ps(h)):null,he=oe&&U?$1({dragItems:h,snapGrid:W,x:ne,y:K}):null;for(const[pe,Z]of h){if(!C.has(pe))continue;let se={x:ne-Z.distance.x,y:K-Z.distance.y};U&&(se=he?{x:Math.round(se.x+he.x),y:Math.round(se.y+he.y)}:gs(se,W));let me=null;if(oe&&V&&!Z.extent&&fe){const{positionAbsolute:re}=Z.internals,Ne=re.x-fe.x+V[0][0],Ie=re.x+Z.measured.width-fe.x2+V[1][0],Le=re.y-fe.y+V[0][1],$e=re.y+Z.measured.height-fe.y2+V[1][1];me=[[Ne,Le],[Ie,$e]]}const{position:ke,positionAbsolute:ve}=dg({nodeId:pe,nextPosition:se,nodeLookup:C,nodeExtent:me||V,nodeOrigin:M,onError:I});ie=ie||Z.position.x!==ke.x||Z.position.y!==ke.y,Z.position=ke,Z.internals.positionAbsolute=ve}if(k=k||ie,!!ie&&(z(h,!0),j&&(s||D||!$&&H))){const[pe,Z]=Wu({nodeId:$,dragItems:h,nodeLookup:C});s==null||s(j,h,pe,Z),D==null||D(j,pe,Z),$||H==null||H(j,Z)}}async function q(){if(!x)return;const{transform:ne,panBy:K,autoPanSpeed:C,autoPanOnNodeDrag:V}=r();if(!V){p=!1,cancelAnimationFrame(c);return}const[W,U]=bc(y,x,C);(W!==0||U!==0)&&(u.x=(u.x??0)-W/ne[2],u.y=(u.y??0)-U/ne[2],await K({x:W,y:U})&&G(u)),c=requestAnimationFrame(q)}function te(ne){var oe;const{nodeLookup:K,multiSelectionActive:C,nodesDraggable:V,transform:W,snapGrid:U,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:H,onSelectionDragStart:I,unselectNodesAndEdges:z}=r();v=!0,(!D||!A)&&!C&&$&&((oe=K.get($))!=null&&oe.selected||z()),A&&D&&$&&(t==null||t($));const ie=Qo(ne.sourceEvent,{transform:W,snapGrid:U,snapToGrid:M,containerBounds:x});if(u=ie,h=A1(K,V,ie,$),h.size>0&&(o||H||!$&&I)){const[fe,he]=Wu({nodeId:$,dragItems:h,nodeLookup:K});o==null||o(ne.sourceEvent,h,fe,he),H==null||H(ne.sourceEvent,fe,he),$||I==null||I(ne.sourceEvent,he)}}const ee=Wp().clickDistance(F).on("start",ne=>{const{domNode:K,nodeDragThreshold:C,transform:V,snapGrid:W,snapToGrid:U}=r();x=(K==null?void 0:K.getBoundingClientRect())||null,_=!1,k=!1,j=ne.sourceEvent,C===0&&te(ne),u=Qo(ne.sourceEvent,{transform:V,snapGrid:W,snapToGrid:U,containerBounds:x}),y=xn(ne.sourceEvent,x)}).on("drag",ne=>{const{autoPanOnNodeDrag:K,transform:C,snapGrid:V,snapToGrid:W,nodeDragThreshold:U,nodeLookup:M}=r(),D=Qo(ne.sourceEvent,{transform:C,snapGrid:V,snapToGrid:W,containerBounds:x});if(j=ne.sourceEvent,(ne.sourceEvent.type==="touchmove"&&ne.sourceEvent.touches.length>1||$&&!M.has($))&&(_=!0),!_){if(!p&&K&&v&&(p=!0,q()),!v){const H=xn(ne.sourceEvent,x),I=H.x-y.x,z=H.y-y.y;Math.sqrt(I*I+z*z)>U&&te(ne)}(u.x!==D.xSnapped||u.y!==D.ySnapped)&&h&&v&&(y=xn(ne.sourceEvent,x),G(D))}}).on("end",ne=>{if(!v||_){_&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,v=!1,cancelAnimationFrame(c),h.size>0){const{nodeLookup:K,updateNodePositions:C,onNodeDragStop:V,onSelectionDragStop:W}=r();if(k&&(C(h,!1),k=!1),a||V||!$&&W){const[U,M]=Wu({nodeId:$,dragItems:h,nodeLookup:K,dragging:!1});a==null||a(ne.sourceEvent,h,U,M),V==null||V(ne.sourceEvent,U,M),$||W==null||W(ne.sourceEvent,M)}}}).filter(ne=>{const K=ne.target;return!ne.button&&(!R||!$h(K,`.${R}`,N))&&(!w||$h(K,w,N))});m.call(ee)}function E(){m==null||m.on(".drag",null)}return{update:b,destroy:E}}function D1(t,r,o){const s=[],a={x:t.x-o,y:t.y-o,width:o*2,height:o*2};for(const u of r.values())Vl(a,ss(u))>0&&s.push(u);return s}const O1=250;function F1(t,r,o,s){var h,p;let a=[],u=1/0;const c=D1(t,o,r+O1);for(const y of c){const x=[...((h=y.internals.handleBounds)==null?void 0:h.source)??[],...((p=y.internals.handleBounds)==null?void 0:p.target)??[]];for(const v of x){if(s.nodeId===v.nodeId&&s.type===v.type&&s.id===v.id)continue;const{x:m,y:_}=hi(y,v,v.position,!0),k=Math.sqrt(Math.pow(m-t.x,2)+Math.pow(_-t.y,2));k>r||(k1){const y=s.type==="source"?"target":"source";return a.find(x=>x.type===y)??a[0]}return a[0]}function Mg(t,r,o,s,a,u=!1){var y,x,v;const c=s.get(t);if(!c)return null;const h=a==="strict"?(y=c.internals.handleBounds)==null?void 0:y[r]:[...((x=c.internals.handleBounds)==null?void 0:x.source)??[],...((v=c.internals.handleBounds)==null?void 0:v.target)??[]],p=(o?h==null?void 0:h.find(m=>m.id===o):h==null?void 0:h[0])??null;return p&&u?{...p,...hi(c,p,p.position,!0)}:p}function Pg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function H1(t,r){let o=null;return r?o=!0:t&&!r&&(o=!1),o}const Ig=()=>!0;function B1(t,{connectionMode:r,connectionRadius:o,handleId:s,nodeId:a,edgeUpdaterType:u,isTarget:c,domNode:h,nodeLookup:p,lib:y,autoPanOnConnect:x,flowId:v,panBy:m,cancelConnection:_,onConnectStart:k,onConnect:j,onConnectEnd:b,isValidConnection:E=Ig,onReconnectEnd:R,updateConnection:w,getTransform:N,getFromHandle:A,autoPanSpeed:$,dragThreshold:F=1,handleDomNode:G}){const q=vg(t.target);let te=0,ee;const{x:ne,y:K}=xn(t),C=Pg(u,G),V=h==null?void 0:h.getBoundingClientRect();let W=!1;if(!V||!C)return;const U=Mg(a,C,s,p,r);if(!U)return;let M=xn(t,V),D=!1,H=null,I=!1,z=null;function ie(){if(!x||!V)return;const[ke,ve]=bc(M,V,$);m({x:ke,y:ve}),te=requestAnimationFrame(ie)}const oe={...U,nodeId:a,type:C,position:U.position},fe=p.get(a);let pe={inProgress:!0,isValid:null,from:hi(fe,oe,Se.Left,!0),fromHandle:oe,fromPosition:oe.position,fromNode:fe,to:M,toHandle:null,toPosition:Nh[oe.position],toNode:null,pointer:M};function Z(){W=!0,w(pe),k==null||k(t,{nodeId:a,handleId:s,handleType:C})}F===0&&Z();function se(ke){if(!W){const{x:$e,y:lt}=xn(ke),at=$e-ne,ut=lt-K;if(!(at*at+ut*ut>F*F))return;Z()}if(!A()||!oe){me(ke);return}const ve=N();M=xn(ke,V),ee=F1(ms(M,ve,!1,[1,1]),o,p,oe),D||(ie(),D=!0);const re=Rg(ke,{handle:ee,connectionMode:r,fromNodeId:a,fromHandleId:s,fromType:c?"target":"source",isValidConnection:E,doc:q,lib:y,flowId:v,nodeLookup:p});z=re.handleDomNode,H=re.connection,I=H1(!!ee,re.isValid);const Ne=p.get(a),Ie=Ne?hi(Ne,oe,Se.Left,!0):pe.from,Le={...pe,from:Ie,isValid:I,to:re.toHandle&&I?eo({x:re.toHandle.x,y:re.toHandle.y},ve):M,toHandle:re.toHandle,toPosition:I&&re.toHandle?re.toHandle.position:Nh[oe.position],toNode:re.toHandle?p.get(re.toHandle.nodeId):null,pointer:M};w(Le),pe=Le}function me(ke){if(!("touches"in ke&&ke.touches.length>0)){if(W){(ee||z)&&H&&I&&(j==null||j(H));const{inProgress:ve,...re}=pe,Ne={...re,toPosition:pe.toHandle?pe.toPosition:null};b==null||b(ke,Ne),u&&(R==null||R(ke,Ne))}_(),cancelAnimationFrame(te),D=!1,I=!1,H=null,z=null,q.removeEventListener("mousemove",se),q.removeEventListener("mouseup",me),q.removeEventListener("touchmove",se),q.removeEventListener("touchend",me)}}q.addEventListener("mousemove",se),q.addEventListener("mouseup",me),q.addEventListener("touchmove",se),q.addEventListener("touchend",me)}function Rg(t,{handle:r,connectionMode:o,fromNodeId:s,fromHandleId:a,fromType:u,doc:c,lib:h,flowId:p,isValidConnection:y=Ig,nodeLookup:x}){const v=u==="target",m=r?c.querySelector(`.${h}-flow__handle[data-id="${p}-${r==null?void 0:r.nodeId}-${r==null?void 0:r.id}-${r==null?void 0:r.type}"]`):null,{x:_,y:k}=xn(t),j=c.elementFromPoint(_,k),b=j!=null&&j.classList.contains(`${h}-flow__handle`)?j:m,E={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const R=Pg(void 0,b),w=b.getAttribute("data-nodeid"),N=b.getAttribute("data-handleid"),A=b.classList.contains("connectable"),$=b.classList.contains("connectableend");if(!w||!R)return E;const F={source:v?w:s,sourceHandle:v?N:a,target:v?s:w,targetHandle:v?a:N};E.connection=F;const q=A&&$&&(o===Zi.Strict?v&&R==="source"||!v&&R==="target":w!==s||N!==a);E.isValid=q&&y(F),E.toHandle=Mg(w,R,N,x,o,!0)}return E}const pc={onPointerDown:B1,isValid:Rg};function V1({domNode:t,panZoom:r,getTransform:o,getViewScale:s}){const a=Ut(t);function u({translateExtent:h,width:p,height:y,zoomStep:x=1,pannable:v=!0,zoomable:m=!0,inversePan:_=!1}){const k=w=>{if(w.sourceEvent.type!=="wheel"||!r)return;const N=o(),A=w.sourceEvent.ctrlKey&&ls()?10:1,$=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*x,F=N[2]*Math.pow(2,$*A);r.scaleTo(F)};let j=[0,0];const b=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(j=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},E=w=>{const N=o();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!r)return;const A=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],$=[A[0]-j[0],A[1]-j[1]];j=A;const F=s()*Math.max(N[2],Math.log(N[2]))*(_?-1:1),G={x:N[0]-$[0]*F,y:N[1]-$[1]*F},q=[[0,0],[p,y]];r.setViewportConstrained({x:G.x,y:G.y,zoom:N[2]},q,h)},R=og().on("start",b).on("zoom",v?E:null).on("zoom.wheel",m?k:null);a.call(R,{})}function c(){a.on("zoom",null)}return{update:u,destroy:c,pointer:mn}}const ta=t=>({x:t.x,y:t.y,zoom:t.k}),Uu=({x:t,y:r,zoom:o})=>Zl.translate(t,r).scale(o),Tr=(t,r)=>t.target.closest(`.${r}`),Tg=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),W1=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Yu=(t,r=0,o=W1,s=()=>{})=>{const a=typeof r=="number"&&r>0;return a||s(),a?t.transition().duration(r).ease(o).on("end",s):t},Lg=t=>{const r=t.ctrlKey&&ls()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function U1({zoomPanValues:t,noWheelClassName:r,d3Selection:o,d3Zoom:s,panOnScrollMode:a,panOnScrollSpeed:u,zoomOnPinch:c,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:y}){return x=>{if(Tr(x,r))return x.ctrlKey&&x.preventDefault(),!1;x.preventDefault(),x.stopImmediatePropagation();const v=o.property("__zoom").k||1;if(x.ctrlKey&&c){const b=mn(x),E=Lg(x),R=v*Math.pow(2,E);s.scaleTo(o,R,b,x);return}const m=x.deltaMode===1?20:1;let _=a===ai.Vertical?0:x.deltaX*m,k=a===ai.Horizontal?0:x.deltaY*m;!ls()&&x.shiftKey&&a!==ai.Vertical&&(_=x.deltaY*m,k=0),s.translateBy(o,-(_/v)*u,-(k/v)*u,{internal:!0});const j=ta(o.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(x,j):(t.isPanScrolling=!0,h==null||h(x,j)),t.panScrollTimeout=setTimeout(()=>{y==null||y(x,j),t.isPanScrolling=!1},150)}}function Y1({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:o}){return function(s,a){const u=s.type==="wheel",c=!r&&u&&!s.ctrlKey,h=Tr(s,t);if(s.ctrlKey&&u&&h&&s.preventDefault(),c||h)return null;s.preventDefault(),o.call(this,s,a)}}function G1({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:o}){return s=>{var u,c,h;if((u=s.sourceEvent)!=null&&u.internal)return;const a=ta(s.transform);t.mouseButton=((c=s.sourceEvent)==null?void 0:c.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=a,((h=s.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),o&&(o==null||o(s.sourceEvent,a))}}function X1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:o,onTransformChange:s,onPanZoom:a}){return u=>{var c,h;t.usedRightMouseButton=!!(o&&Tg(r,t.mouseButton??0)),(c=u.sourceEvent)!=null&&c.sync||s([u.transform.x,u.transform.y,u.transform.k]),a&&!((h=u.sourceEvent)!=null&&h.internal)&&(a==null||a(u.sourceEvent,ta(u.transform)))}}function q1({zoomPanValues:t,panOnDrag:r,panOnScroll:o,onDraggingChange:s,onPanZoomEnd:a,onPaneContextMenu:u}){return c=>{var h;if(!((h=c.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,u&&Tg(r,t.mouseButton??0)&&!t.usedRightMouseButton&&c.sourceEvent&&u(c.sourceEvent),t.usedRightMouseButton=!1,s(!1),a)){const p=ta(c.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{a==null||a(c.sourceEvent,p)},o?150:0)}}}function K1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:o,zoomOnPinch:s,panOnDrag:a,panOnScroll:u,zoomOnDoubleClick:c,userSelectionActive:h,noWheelClassName:p,noPanClassName:y,lib:x,connectionInProgress:v}){return m=>{var E;const _=r||o,k=s&&m.ctrlKey,j=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(Tr(m,`${x}-flow__node`)||Tr(m,`${x}-flow__edge`)||Tr(m,`${x}-flow__selection`)||Tr(m,`${x}-flow__nodesselection`)))return!0;if(!a&&!_&&!u&&!c&&!s||h||v&&!j||Tr(m,p)&&j||Tr(m,y)&&(!j||u&&j&&!r)||!s&&m.ctrlKey&&j)return!1;if(!s&&m.type==="touchstart"&&((E=m.touches)==null?void 0:E.length)>1)return m.preventDefault(),!1;if(!_&&!u&&!k&&j||!a&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(a)&&!a.includes(m.button)&&m.type==="mousedown")return!1;const b=Array.isArray(a)&&a.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||j||t)&&b}}function Q1({domNode:t,minZoom:r,maxZoom:o,translateExtent:s,viewport:a,onPanZoom:u,onPanZoomStart:c,onPanZoomEnd:h,onDraggingChange:p}){const y={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},x=t.getBoundingClientRect();let v=[[0,0],[x.width,x.height]];const m=typeof ResizeObserver<"u"?new ResizeObserver(K=>{const C=K[0];C&&(v=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;m==null||m.observe(t);const _=og().extent(()=>v).scaleExtent([r,o]).translateExtent(s),k=Ut(t).call(_);N({x:a.x,y:a.y,zoom:Ji(a.zoom,r,o)},[[0,0],[x.width,x.height]],s);const j=k.on("wheel.zoom"),b=k.on("dblclick.zoom");_.wheelDelta(Lg);async function E(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Il).transform(Yu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function R({noWheelClassName:K,noPanClassName:C,onPaneContextMenu:V,userSelectionActive:W,panOnScroll:U,panOnDrag:M,panOnScrollMode:D,panOnScrollSpeed:H,preventScrolling:I,zoomOnPinch:z,zoomOnScroll:ie,zoomOnDoubleClick:oe,panActivationKeyPressed:fe=!1,zoomActivationKeyPressed:he,lib:pe,onTransformChange:Z,connectionInProgress:se,paneClickDistance:me,selectionOnDrag:ke}){W&&!y.isZoomingOrPanning&&w();const ve=U&&!he&&!W;_.clickDistance(ke?1/0:!vn(me)||me<0?0:me);const re=ve?U1({zoomPanValues:y,noWheelClassName:K,d3Selection:k,d3Zoom:_,panOnScrollMode:D,panOnScrollSpeed:H,zoomOnPinch:z,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:h}):Y1({noWheelClassName:K,preventScrolling:I,d3ZoomHandler:j});k.on("wheel.zoom",re,{passive:!1});const Ne=G1({zoomPanValues:y,onDraggingChange:p,onPanZoomStart:c});_.on("start",Ne);const Ie=X1({zoomPanValues:y,panOnDrag:M,onPaneContextMenu:!!V,onPanZoom:u,onTransformChange:Z});_.on("zoom",Ie);const Le=q1({zoomPanValues:y,panOnDrag:M,panOnScroll:U,onPaneContextMenu:V,onPanZoomEnd:h,onDraggingChange:p});_.on("end",Le);const $e=K1({panActivationKeyPressed:fe,zoomActivationKeyPressed:he,panOnDrag:M,zoomOnScroll:ie,panOnScroll:U,zoomOnDoubleClick:oe,zoomOnPinch:z,userSelectionActive:W,noPanClassName:C,noWheelClassName:K,lib:pe,connectionInProgress:se});_.filter($e),oe?k.on("dblclick.zoom",b):k.on("dblclick.zoom",null)}function w(){_.on("zoom",null)}async function N(K,C,V){const W=Uu(K),U=_==null?void 0:_.constrain()(W,C,V);return U&&await E(U),U}async function A(K,C){const V=Uu(K);return await E(V,C),V}function $(K){if(k){const C=Uu(K),V=k.property("__zoom");(V.k!==K.zoom||V.x!==K.x||V.y!==K.y)&&(_==null||_.transform(k,C,null,{sync:!0}))}}function F(){const K=k?ig(k.node()):{x:0,y:0,k:1};return{x:K.x,y:K.y,zoom:K.k}}async function G(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Il).scaleTo(Yu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}async function q(K,C){return k?new Promise(V=>{_==null||_.interpolate((C==null?void 0:C.interpolate)==="linear"?Ko:Il).scaleBy(Yu(k,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>V(!0)),K)}):!1}function te(K){_==null||_.scaleExtent(K)}function ee(K){_==null||_.translateExtent(K)}function ne(K){const C=!vn(K)||K<0?0:K;_==null||_.clickDistance(C)}return{update:R,destroy:w,setViewport:A,setViewportConstrained:N,getViewport:F,scaleTo:G,scaleBy:q,setScaleExtent:te,setTranslateExtent:ee,syncViewport:$,setClickDistance:ne}}var to;(function(t){t.Line="line",t.Handle="handle"})(to||(to={}));function Z1({width:t,prevWidth:r,height:o,prevHeight:s,affectsX:a,affectsY:u}){const c=t-r,h=o-s,p=[c>0?1:c<0?-1:0,h>0?1:h<0?-1:0];return c&&a&&(p[0]=p[0]*-1),h&&u&&(p[1]=p[1]*-1),p}function zh(t){const r=t.includes("right")||t.includes("left"),o=t.includes("bottom")||t.includes("top"),s=t.includes("left"),a=t.includes("top");return{isHorizontal:r,isVertical:o,affectsX:s,affectsY:a}}function Ir(t,r){return Math.max(0,r-t)}function Rr(t,r){return Math.max(0,t-r)}function jl(t,r,o){return Math.max(0,r-t,t-o)}function Dh(t,r){return t?!r:r}function J1(t,r,o,s,a,u,c,h){let{affectsX:p,affectsY:y}=r;const{isHorizontal:x,isVertical:v}=r,m=x&&v,{xSnapped:_,ySnapped:k}=o,{minWidth:j,maxWidth:b,minHeight:E,maxHeight:R}=s,{x:w,y:N,width:A,height:$,aspectRatio:F}=t;let G=Math.floor(x?_-t.pointerX:0),q=Math.floor(v?k-t.pointerY:0);const te=A+(p?-G:G),ee=$+(y?-q:q),ne=-u[0]*A,K=-u[1]*$;let C=jl(te,j,b),V=jl(ee,E,R);if(c){let M=0,D=0;p&&G<0?M=Ir(w+G+ne,c[0][0]):!p&&G>0&&(M=Rr(w+te+ne,c[1][0])),y&&q<0?D=Ir(N+q+K,c[0][1]):!y&&q>0&&(D=Rr(N+ee+K,c[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(h){let M=0,D=0;p&&G>0?M=Rr(w+G,h[0][0]):!p&&G<0&&(M=Ir(w+te,h[1][0])),y&&q>0?D=Rr(N+q,h[0][1]):!y&&q<0&&(D=Ir(N+ee,h[1][1])),C=Math.max(C,M),V=Math.max(V,D)}if(a){if(x){const M=jl(te/F,E,R)*F;if(C=Math.max(C,M),c){let D=0;!p&&!y||p&&!y&&m?D=Rr(N+K+te/F,c[1][1])*F:D=Ir(N+K+(p?G:-G)/F,c[0][1])*F,C=Math.max(C,D)}if(h){let D=0;!p&&!y||p&&!y&&m?D=Ir(N+te/F,h[1][1])*F:D=Rr(N+(p?G:-G)/F,h[0][1])*F,C=Math.max(C,D)}}if(v){const M=jl(ee*F,j,b)/F;if(V=Math.max(V,M),c){let D=0;!p&&!y||y&&!p&&m?D=Rr(w+ee*F+ne,c[1][0])/F:D=Ir(w+(y?q:-q)*F+ne,c[0][0])/F,V=Math.max(V,D)}if(h){let D=0;!p&&!y||y&&!p&&m?D=Ir(w+ee*F,h[1][0])/F:D=Rr(w+(y?q:-q)*F,h[0][0])/F,V=Math.max(V,D)}}}q=q+(q<0?V:-V),G=G+(G<0?C:-C),a&&(m?te>ee*F?q=(Dh(p,y)?-G:G)/F:G=(Dh(p,y)?-q:q)*F:x?(q=G/F,y=p):(G=q*F,p=y));const W=p?w+G:w,U=y?N+q:N;return{width:A+(p?-G:G),height:$+(y?-q:q),x:u[0]*G*(p?-1:1)+W,y:u[1]*q*(y?-1:1)+U}}const Ag={width:0,height:0,x:0,y:0},e_={...Ag,pointerX:0,pointerY:0,aspectRatio:1};function t_(t,r,o){const s=r.position.x+t.position.x,a=r.position.y+t.position.y,u=t.measured.width??0,c=t.measured.height??0,h=o[0]*u,p=o[1]*c;return[[s-h,a-p],[s+u-h,a+c-p]]}function n_({domNode:t,nodeId:r,getStoreItems:o,onChange:s,onEnd:a}){const u=Ut(t);let c={controlDirection:zh("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:y,boundaries:x,keepAspectRatio:v,resizeDirection:m,onResizeStart:_,onResize:k,onResizeEnd:j,shouldResize:b}){let E={...Ag},R={...e_};c={boundaries:x,resizeDirection:m,keepAspectRatio:v,controlDirection:zh(y)};let w,N=null,A=[],$,F,G,q=!1;const te=Wp().on("start",ee=>{const{nodeLookup:ne,transform:K,snapGrid:C,snapToGrid:V,nodeOrigin:W,paneDomNode:U}=o();if(w=ne.get(r),!w)return;N=(U==null?void 0:U.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:D}=Qo(ee.sourceEvent,{transform:K,snapGrid:C,snapToGrid:V,containerBounds:N});E={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},R={...E,pointerX:M,pointerY:D,aspectRatio:E.width/E.height},$=void 0,F=fi(w.extent)?w.extent:void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&($=ne.get(w.parentId)),$&&w.extent==="parent"&&(F=[[0,0],[$.measured.width,$.measured.height]]),A=[],G=void 0;for(const[H,I]of ne)if(I.parentId===r&&(A.push({id:H,position:{...I.position},extent:I.extent}),I.extent==="parent"||I.expandParent)){const z=t_(I,w,I.origin??W);G?G=[[Math.min(z[0][0],G[0][0]),Math.min(z[0][1],G[0][1])],[Math.max(z[1][0],G[1][0]),Math.max(z[1][1],G[1][1])]]:G=z}_==null||_(ee,{...E})}).on("drag",ee=>{const{transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V}=o(),W=Qo(ee.sourceEvent,{transform:ne,snapGrid:K,snapToGrid:C,containerBounds:N}),U=[];if(!w)return;const{x:M,y:D,width:H,height:I}=E,z={},ie=w.origin??V,{width:oe,height:fe,x:he,y:pe}=J1(R,c.controlDirection,W,c.boundaries,c.keepAspectRatio,ie,F,G),Z=oe!==H,se=fe!==I,me=he!==M&&Z,ke=pe!==D&&se;if(!me&&!ke&&!Z&&!se)return;if((me||ke||ie[0]===1||ie[1]===1)&&(z.x=me?he:E.x,z.y=ke?pe:E.y,E.x=z.x,E.y=z.y,A.length>0)){const Ie=he-M,Le=pe-D;for(const $e of A)$e.position={x:$e.position.x-Ie+ie[0]*(oe-H),y:$e.position.y-Le+ie[1]*(fe-I)},U.push($e)}if((Z||se)&&(z.width=Z&&(!c.resizeDirection||c.resizeDirection==="horizontal")?oe:E.width,z.height=se&&(!c.resizeDirection||c.resizeDirection==="vertical")?fe:E.height,E.width=z.width,E.height=z.height),$&&w.expandParent){const Ie=ie[0]*(z.width??0);z.x&&z.x{q&&(j==null||j(ee,{...E}),a==null||a({...E}),q=!1)});u.call(te)}function p(){u.on(".drag",null)}return{update:h,destroy:p}}var Gu={exports:{}},Xu={},qu={exports:{}},Ku={};/** + * @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 Oh;function r_(){if(Oh)return Ku;Oh=1;var t=cs();function r(v,m){return v===m&&(v!==0||1/v===1/m)||v!==v&&m!==m}var o=typeof Object.is=="function"?Object.is:r,s=t.useState,a=t.useEffect,u=t.useLayoutEffect,c=t.useDebugValue;function h(v,m){var _=m(),k=s({inst:{value:_,getSnapshot:m}}),j=k[0].inst,b=k[1];return u(function(){j.value=_,j.getSnapshot=m,p(j)&&b({inst:j})},[v,_,m]),a(function(){return p(j)&&b({inst:j}),v(function(){p(j)&&b({inst:j})})},[v]),c(_),_}function p(v){var m=v.getSnapshot;v=v.value;try{var _=m();return!o(v,_)}catch{return!0}}function y(v,m){return m()}var x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:h;return Ku.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:x,Ku}var Fh;function i_(){return Fh||(Fh=1,qu.exports=r_()),qu.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 Hh;function o_(){if(Hh)return Xu;Hh=1;var t=cs(),r=i_();function o(y,x){return y===x&&(y!==0||1/y===1/x)||y!==y&&x!==x}var s=typeof Object.is=="function"?Object.is:o,a=r.useSyncExternalStore,u=t.useRef,c=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Xu.useSyncExternalStoreWithSelector=function(y,x,v,m,_){var k=u(null);if(k.current===null){var j={hasValue:!1,value:null};k.current=j}else j=k.current;k=h(function(){function E($){if(!R){if(R=!0,w=$,$=m($),_!==void 0&&j.hasValue){var F=j.value;if(_(F,$))return N=F}return N=$}if(F=N,s(w,$))return F;var G=m($);return _!==void 0&&_(F,G)?(w=$,F):(w=$,N=G)}var R=!1,w,N,A=v===void 0?null:v;return[function(){return E(x())},A===null?void 0:function(){return E(A())}]},[x,v,m,_]);var b=a(y,k[0],k[1]);return c(function(){j.hasValue=!0,j.value=b},[b]),p(b),b},Xu}var Bh;function s_(){return Bh||(Bh=1,Gu.exports=o_()),Gu.exports}var l_=s_();const a_=bp(l_),u_={},Vh=t=>{let r;const o=new Set,s=(x,v)=>{const m=typeof x=="function"?x(r):x;if(!Object.is(m,r)){const _=r;r=v??(typeof m!="object"||m===null)?m:Object.assign({},r,m),o.forEach(k=>k(r,_))}},a=()=>r,p={setState:s,getState:a,getInitialState:()=>y,subscribe:x=>(o.add(x),()=>o.delete(x)),destroy:()=>{(u_?"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."),o.clear()}},y=r=t(s,a,p);return p},c_=t=>t?Vh(t):Vh,{useDebugValue:d_}=s0,{useSyncExternalStoreWithSelector:f_}=a_,h_=t=>t;function $g(t,r=h_,o){const s=f_(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,o);return d_(s),s}const Wh=(t,r)=>{const o=c_(t),s=(a,u=r)=>$g(o,a,u);return Object.assign(s,o),s},p_=(t,r)=>t?Wh(t,r):Wh;function Qe(t,r){if(Object.is(t,r))return!0;if(typeof t!="object"||t===null||typeof r!="object"||r===null)return!1;if(t instanceof Map&&r instanceof Map){if(t.size!==r.size)return!1;for(const[s,a]of t)if(!Object.is(a,r.get(s)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const s of t)if(!r.has(s))return!1;return!0}const o=Object.keys(t);if(o.length!==Object.keys(r).length)return!1;for(const s of o)if(!Object.prototype.hasOwnProperty.call(r,s)||!Object.is(t[s],r[s]))return!1;return!0}Ep();const na=L.createContext(null),g_=na.Provider,zg=wn.error001("react");function De(t,r){const o=L.useContext(na);if(o===null)throw new Error(zg);return $g(o,t,r)}function Ye(){const t=L.useContext(na);if(t===null)throw new Error(zg);return L.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Uh={display:"none"},m_={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Dg="react-flow__node-desc",Og="react-flow__edge-desc",y_="react-flow__aria-live",v_=t=>t.ariaLiveMessage,x_=t=>t.ariaLabelConfig;function w_({rfId:t}){const r=De(v_);return d.jsx("div",{id:`${y_}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:m_,children:r})}function __({rfId:t,disableKeyboardA11y:r}){const o=De(x_);return d.jsxs(d.Fragment,{children:[d.jsx("div",{id:`${Dg}-${t}`,style:Uh,children:r?o["node.a11yDescription.default"]:o["node.a11yDescription.keyboardDisabled"]}),d.jsx("div",{id:`${Og}-${t}`,style:Uh,children:o["edge.a11yDescription.default"]}),!r&&d.jsx(w_,{rfId:t})]})}const ra=L.forwardRef(({position:t="top-left",children:r,className:o,style:s,...a},u)=>{const c=`${t}`.split("-");return d.jsx("div",{className:rt(["react-flow__panel",o,...c]),style:s,ref:u,...a,children:r})});ra.displayName="Panel";const Yh="https://reactflow.dev?utm_source=attribution";function S_({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:d.jsx(ra,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Yh}`,children:d.jsx("a",{href:Yh,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const k_=t=>{const r=[],o=[];for(const[,s]of t.nodeLookup)s.selected&&r.push(s.internals.userNode);for(const[,s]of t.edgeLookup)s.selected&&o.push(s);return{selectedNodes:r,selectedEdges:o}},bl=t=>t.id;function N_(t,r){return Qe(t.selectedNodes.map(bl),r.selectedNodes.map(bl))&&Qe(t.selectedEdges.map(bl),r.selectedEdges.map(bl))}function j_({onSelectionChange:t}){const r=Ye(),{selectedNodes:o,selectedEdges:s}=De(k_,N_);return L.useEffect(()=>{const a={nodes:o,edges:s};t==null||t(a),r.getState().onSelectionChangeHandlers.forEach(u=>u(a))},[o,s,t]),null}const b_=t=>!!t.onSelectionChangeHandlers;function E_({onSelectionChange:t}){const r=De(b_);return t||r?d.jsx(j_,{onSelectionChange:t}):null}const Fg=[0,0],C_={x:0,y:0,zoom:1},M_=["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"],Gh=[...M_,"rfId"],P_=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),Xh={translateExtent:rs,nodeOrigin:Fg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function I_(t){const{setNodes:r,setEdges:o,setMinZoom:s,setMaxZoom:a,setTranslateExtent:u,setNodeExtent:c,reset:h,setDefaultNodesAndEdges:p}=De(P_,Qe),y=Ye();L.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{x.current=Xh,h()}),[]);const x=L.useRef(Xh);return L.useEffect(()=>{for(const v of Gh){const m=t[v],_=x.current[v];m!==_&&(typeof t[v]>"u"||(v==="nodes"?r(m):v==="edges"?o(m):v==="minZoom"?s(m):v==="maxZoom"?a(m):v==="translateExtent"?u(m):v==="nodeExtent"?c(m):v==="ariaLabelConfig"?y.setState({ariaLabelConfig:g1(m)}):v==="fitView"?y.setState({fitViewQueued:m}):v==="fitViewOptions"?y.setState({fitViewOptions:m}):y.setState({[v]:m})))}x.current=t},Gh.map(v=>t[v])),null}function qh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function R_(t){var s;const[r,o]=L.useState(t==="system"?null:t);return L.useEffect(()=>{if(t!=="system"){o(t);return}const a=qh(),u=()=>o(a!=null&&a.matches?"dark":"light");return u(),a==null||a.addEventListener("change",u),()=>{a==null||a.removeEventListener("change",u)}},[t]),r!==null?r:(s=qh())!=null&&s.matches?"dark":"light"}const Kh=typeof document<"u"?document:null;function as(t=null,r={target:Kh,actInsideInputWithModifier:!0}){const[o,s]=L.useState(!1),a=L.useRef(!1),u=L.useRef(new Set([])),[c,h]=L.useMemo(()=>{if(t!==null){const y=(Array.isArray(t)?t:[t]).filter(v=>typeof v=="string").map(v=>v.replace(/\+/g,` +`).replace(` + +`,` ++`).split(` +`)),x=y.reduce((v,m)=>v.concat(...m),[]);return[y,x]}return[[],[]]},[t]);return L.useEffect(()=>{const p=(r==null?void 0:r.target)??Kh,y=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const x=_=>{var b,E;if(a.current=_.ctrlKey||_.metaKey||_.shiftKey||_.altKey,(!a.current||a.current&&!y)&&xg(_))return!1;const j=Zh(_.code,h);if(u.current.add(_[j]),Qh(c,u.current,!1)){const R=((E=(b=_.composedPath)==null?void 0:b.call(_))==null?void 0:E[0])||_.target,w=(R==null?void 0:R.nodeName)==="BUTTON"||(R==null?void 0:R.nodeName)==="A";r.preventDefault!==!1&&(a.current||!w)&&_.preventDefault(),s(!0)}},v=_=>{const k=Zh(_.code,h);Qh(c,u.current,!0)?(s(!1),u.current.clear()):u.current.delete(_[k]),_.key==="Meta"&&u.current.clear(),a.current=!1},m=()=>{u.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",x),p==null||p.addEventListener("keyup",v),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{p==null||p.removeEventListener("keydown",x),p==null||p.removeEventListener("keyup",v),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,s]),o}function Qh(t,r,o){return t.filter(s=>o||s.length===r.size).some(s=>s.every(a=>r.has(a)))}function Zh(t,r){return r.includes(t)?"code":"key"}const T_=()=>{const t=Ye();return L.useMemo(()=>({zoomIn:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:o}=t.getState();return o?o.scaleBy(1/1.2,r):!1},zoomTo:async(r,o)=>{const{panZoom:s}=t.getState();return s?s.scaleTo(r,o):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,o)=>{const{transform:[s,a,u],panZoom:c}=t.getState();return c?(await c.setViewport({x:r.x??s,y:r.y??a,zoom:r.zoom??u},o),!0):!1},getViewport:()=>{const[r,o,s]=t.getState().transform;return{x:r,y:o,zoom:s}},setCenter:async(r,o,s)=>t.getState().setCenter(r,o,s),fitBounds:async(r,o)=>{const{width:s,height:a,minZoom:u,maxZoom:c,panZoom:h}=t.getState(),p=Ec(r,s,a,u,c,(o==null?void 0:o.padding)??.1);return h?(await h.setViewport(p,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0):!1},screenToFlowPosition:(r,o={})=>{const{transform:s,snapGrid:a,snapToGrid:u,domNode:c}=t.getState();if(!c)return r;const{x:h,y:p}=c.getBoundingClientRect(),y={x:r.x-h,y:r.y-p},x=o.snapGrid??a,v=o.snapToGrid??u;return ms(y,s,v,x)},flowToScreenPosition:r=>{const{transform:o,domNode:s}=t.getState();if(!s)return r;const{x:a,y:u}=s.getBoundingClientRect(),c=eo(r,o);return{x:c.x+a,y:c.y+u}}}),[])};function Hg(t,r){const o=[],s=new Map,a=[];for(const u of t)if(u.type==="add"){a.push(u);continue}else if(u.type==="remove"||u.type==="replace")s.set(u.id,[u]);else{const c=s.get(u.id);c?c.push(u):s.set(u.id,[u])}for(const u of r){const c=s.get(u.id);if(!c){o.push(u);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){o.push({...c[0].item});continue}const h={...u};for(const p of c)L_(p,h);o.push(h)}return a.length&&a.forEach(u=>{u.index!==void 0?o.splice(u.index,0,{...u.item}):o.push({...u.item})}),o}function L_(t,r){switch(t.type){case"select":{r.selected=t.selected;break}case"position":{typeof t.position<"u"&&(r.position=t.position),typeof t.dragging<"u"&&(r.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(r.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(r.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(r.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(r.resizing=t.resizing);break}}}function A_(t,r){return Hg(t,r)}function $_(t,r){return Hg(t,r)}function oi(t,r){return{id:t,type:"select",selected:r}}function Gi(t,r=new Set,o=!1){const s=[];for(const[a,u]of t){const c=r.has(a);!(u.selected===void 0&&!c)&&u.selected!==c&&(o&&(u.selected=c),s.push(oi(u.id,c)))}return s}function Jh({items:t=[],lookup:r}){var a;const o=[],s=new Map(t.map(u=>[u.id,u]));for(const[u,c]of t.entries()){const h=r.get(c.id),p=((a=h==null?void 0:h.internals)==null?void 0:a.userNode)??h;p!==void 0&&p!==c&&o.push({id:c.id,item:c,type:"replace"}),p===void 0&&o.push({item:c,type:"add",index:u})}for(const[u]of r)s.get(u)===void 0&&o.push({id:u,type:"remove"});return o}function ep(t){return{id:t.id,type:"remove"}}const z_=gg();function D_(t,r,o={}){return _1(t,r,{...o,onError:o.onError??z_})}const tp=t=>s1(t),O_=t=>cg(t);function Bg(t){return L.forwardRef(t)}const Vg=typeof window<"u"?L.useLayoutEffect:L.useEffect;function np(t){const[r,o]=L.useState(BigInt(0)),[s]=L.useState(()=>F_(()=>o(a=>a+BigInt(1))));return Vg(()=>{const a=s.get();a.length&&(t(a),s.reset())},[r]),s}function F_(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:o=>{r.push(o),t()}}}const Wg=L.createContext(null);function H_({children:t}){const r=Ye(),o=L.useCallback(h=>{const{nodes:p=[],setNodes:y,hasDefaultNodes:x,onNodesChange:v,nodeLookup:m,fitViewQueued:_,onNodesChangeMiddlewareMap:k}=r.getState();let j=p;for(const E of h)j=typeof E=="function"?E(j):E;let b=Jh({items:j,lookup:m});for(const E of k.values())b=E(b);x&&y(j),b.length>0?v==null||v(b):_&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:R,setNodes:w}=r.getState();E&&w(R)})},[]),s=np(o),a=L.useCallback(h=>{const{edges:p=[],setEdges:y,hasDefaultEdges:x,onEdgesChange:v,edgeLookup:m}=r.getState();let _=p;for(const k of h)_=typeof k=="function"?k(_):k;x?y(_):v&&v(Jh({items:_,lookup:m}))},[]),u=np(a),c=L.useMemo(()=>({nodeQueue:s,edgeQueue:u}),[]);return d.jsx(Wg.Provider,{value:c,children:t})}function B_(){const t=L.useContext(Wg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const V_=t=>!!t.panZoom;function ia(){const t=T_(),r=Ye(),o=B_(),s=De(V_),a=L.useMemo(()=>{const u=v=>r.getState().nodeLookup.get(v),c=v=>{o.nodeQueue.push(v)},h=v=>{o.edgeQueue.push(v)},p=v=>{var E,R;const{nodeLookup:m,nodeOrigin:_}=r.getState(),k=tp(v)?v:m.get(v.id),j=k.parentId?yg(k.position,k.measured,k.parentId,m,_):k.position,b={...k,position:j,width:((E=k.measured)==null?void 0:E.width)??k.width,height:((R=k.measured)==null?void 0:R.height)??k.height};return ss(b)},y=(v,m,_={replace:!1})=>{c(k=>k.map(j=>{if(j.id===v){const b=typeof m=="function"?m(j):m;return _.replace&&tp(b)?b:{...j,...b}}return j}))},x=(v,m,_={replace:!1})=>{h(k=>k.map(j=>{if(j.id===v){const b=typeof m=="function"?m(j):m;return _.replace&&O_(b)?b:{...j,...b}}return j}))};return{getNodes:()=>r.getState().nodes.map(v=>({...v})),getNode:v=>{var m;return(m=u(v))==null?void 0:m.internals.userNode},getInternalNode:u,getEdges:()=>{const{edges:v=[]}=r.getState();return v.map(m=>({...m}))},getEdge:v=>r.getState().edgeLookup.get(v),setNodes:c,setEdges:h,addNodes:v=>{const m=Array.isArray(v)?v:[v];o.nodeQueue.push(_=>[..._,...m])},addEdges:v=>{const m=Array.isArray(v)?v:[v];o.edgeQueue.push(_=>[..._,...m])},toObject:()=>{const{nodes:v=[],edges:m=[],transform:_}=r.getState(),[k,j,b]=_;return{nodes:v.map(E=>({...E})),edges:m.map(E=>({...E})),viewport:{x:k,y:j,zoom:b}}},deleteElements:async({nodes:v=[],edges:m=[]})=>{const{nodes:_,edges:k,onNodesDelete:j,onEdgesDelete:b,triggerNodeChanges:E,triggerEdgeChanges:R,onDelete:w,onBeforeDelete:N}=r.getState(),{nodes:A,edges:$}=await d1({nodesToRemove:v,edgesToRemove:m,nodes:_,edges:k,onBeforeDelete:N}),F=$.length>0,G=A.length>0;if(F){const q=$.map(ep);b==null||b($),R(q)}if(G){const q=A.map(ep);j==null||j(A),E(q)}return(G||F)&&(w==null||w({nodes:A,edges:$})),{deletedNodes:A,deletedEdges:$}},getIntersectingNodes:(v,m=!0,_)=>{const k=bh(v),j=k?v:p(v),b=_!==void 0;return j?(_||r.getState().nodes).filter(E=>{const R=r.getState().nodeLookup.get(E.id);if(R&&!k&&(E.id===v.id||!R.internals.positionAbsolute))return!1;const w=ss(b?E:R),N=Vl(w,j);return m&&N>0||N>=w.width*w.height||N>=j.width*j.height}):[]},isNodeIntersecting:(v,m,_=!0)=>{const j=bh(v)?v:p(v);if(!j)return!1;const b=Vl(j,m);return _&&b>0||b>=m.width*m.height||b>=j.width*j.height},updateNode:y,updateNodeData:(v,m,_={replace:!1})=>{y(v,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},updateEdge:x,updateEdgeData:(v,m,_={replace:!1})=>{x(v,k=>{const j=typeof m=="function"?m(k):m;return _.replace?{...k,data:j}:{...k,data:{...k.data,...j}}},_)},getNodesBounds:v=>{const{nodeLookup:m,nodeOrigin:_}=r.getState();return l1(v,{nodeLookup:m,nodeOrigin:_})},getHandleConnections:({type:v,id:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}-${v}${m?`-${m}`:""}`))==null?void 0:k.values())??[])},getNodeConnections:({type:v,handleId:m,nodeId:_})=>{var k;return Array.from(((k=r.getState().connectionLookup.get(`${_}${v?m?`-${v}-${m}`:`-${v}`:""}`))==null?void 0:k.values())??[])},fitView:async v=>{const m=r.getState().fitViewResolver??p1();return r.setState({fitViewQueued:!0,fitViewOptions:v,fitViewResolver:m}),o.nodeQueue.push(_=>[..._]),m.promise}}},[]);return L.useMemo(()=>({...a,...t,viewportInitialized:s}),[s])}const rp=t=>t.selected,W_=typeof window<"u"?window:void 0;function U_({deleteKeyCode:t,multiSelectionKeyCode:r}){const o=Ye(),{deleteElements:s}=ia(),a=as(t,{actInsideInputWithModifier:!1}),u=as(r,{target:W_});L.useEffect(()=>{if(a){const{edges:c,nodes:h}=o.getState();s({nodes:h.filter(rp),edges:c.filter(rp)}),o.setState({nodesSelectionActive:!1})}},[a]),L.useEffect(()=>{o.setState({multiSelectionActive:u})},[u])}function Y_(t){const r=Ye();L.useEffect(()=>{const o=()=>{var a,u,c,h;if(!t.current||!(((u=(a=t.current).checkVisibility)==null?void 0:u.call(a))??!0))return!1;const s=Cc(t.current);(s.height===0||s.width===0)&&((h=(c=r.getState()).onError)==null||h.call(c,"004",wn.error004())),r.setState({width:s.width||500,height:s.height||500})};if(t.current){o(),window.addEventListener("resize",o);const s=new ResizeObserver(()=>o());return s.observe(t.current),()=>{window.removeEventListener("resize",o),s&&t.current&&s.unobserve(t.current)}}},[])}const oa={position:"absolute",width:"100%",height:"100%",top:0,left:0},G_=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function X_({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panActivationKeyPressed:a,panOnScrollSpeed:u=.5,panOnScrollMode:c=ai.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:y,translateExtent:x,minZoom:v,maxZoom:m,zoomActivationKeyCode:_,preventScrolling:k=!0,children:j,noWheelClassName:b,noPanClassName:E,onViewportChange:R,isControlledViewport:w,paneClickDistance:N,selectionOnDrag:A}){const $=Ye(),F=L.useRef(null),{userSelectionActive:G,lib:q,connectionInProgress:te}=De(G_,Qe),ee=as(_),ne=L.useRef();Y_(F);const K=L.useCallback(C=>{R==null||R({x:C[0],y:C[1],zoom:C[2]}),w||$.setState({transform:C})},[R,w]);return L.useEffect(()=>{if(F.current){ne.current=Q1({domNode:F.current,minZoom:v,maxZoom:m,translateExtent:x,viewport:y,onDraggingChange:U=>$.setState(M=>M.paneDragging===U?M:{paneDragging:U}),onPanZoomStart:(U,M)=>{const{onViewportChangeStart:D,onMoveStart:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoom:(U,M)=>{const{onViewportChange:D,onMove:H}=$.getState();H==null||H(U,M),D==null||D(M)},onPanZoomEnd:(U,M)=>{const{onViewportChangeEnd:D,onMoveEnd:H}=$.getState();H==null||H(U,M),D==null||D(M)}});const{x:C,y:V,zoom:W}=ne.current.getViewport();return $.setState({panZoom:ne.current,transform:[C,V,W],domNode:F.current.closest(".react-flow")}),()=>{var U;(U=ne.current)==null||U.destroy()}}},[]),L.useEffect(()=>{var C;(C=ne.current)==null||C.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:o,panOnScroll:s,panActivationKeyPressed:a,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:ee,preventScrolling:k,noPanClassName:E,userSelectionActive:G,noWheelClassName:b,lib:q,onTransformChange:K,connectionInProgress:te,selectionOnDrag:A,paneClickDistance:N})},[t,r,o,s,a,u,c,h,p,ee,k,E,G,b,q,K,te,A,N]),d.jsx("div",{className:"react-flow__renderer",ref:F,style:oa,children:j})}const q_=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function K_(){const{userSelectionActive:t,userSelectionRect:r}=De(q_,Qe);return t&&r?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:r.width,height:r.height,transform:`translate(${r.x}px, ${r.y}px)`}}):null}const Qu=(t,r)=>o=>{o.target===r.current&&(t==null||t(o))},Q_=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function Z_({isSelecting:t,selectionKeyPressed:r,selectionMode:o=is.Full,panOnDrag:s,autoPanOnSelection:a,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:h,onSelectionEnd:p,onPaneClick:y,onPaneContextMenu:x,onPaneScroll:v,onPaneMouseEnter:m,onPaneMouseMove:_,onPaneMouseLeave:k,children:j}){const b=L.useRef(0),E=Ye(),{userSelectionActive:R,elementsSelectable:w,dragging:N,panBy:A,autoPanSpeed:$}=De(Q_,Qe),F=w&&(t||R),G=L.useRef(null),q=L.useRef(),te=L.useRef(new Set),ee=L.useRef(new Set),ne=L.useRef(!1),K=L.useRef(!1),C=L.useRef({x:0,y:0}),V=L.useRef(!1),W=Z=>{if(K.current||ne.current||E.getState().connection.inProgress){K.current=!1,ne.current=!1;return}y==null||y(Z),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},U=Z=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){Z.preventDefault();return}x==null||x(Z)},M=v?Z=>v(Z):void 0,D=Z=>{K.current&&(Z.stopPropagation(),K.current=!1)},H=Z=>{var $e,lt;if(Z.pointerType==="touch"&&s!==!1&&!r)return;const{domNode:se,transform:me}=E.getState();if(q.current=se==null?void 0:se.getBoundingClientRect(),!q.current)return;const ke=Z.target===G.current;if(!ke&&!!Z.target.closest(".nokey")||!t||!(c&&ke||r)||Z.button!==0||!Z.isPrimary)return;(lt=($e=Z.target)==null?void 0:$e.setPointerCapture)==null||lt.call($e,Z.pointerId),K.current=!1;const{x:Ne,y:Ie}=xn(Z.nativeEvent,q.current),Le=ms({x:Ne,y:Ie},me);E.setState({userSelectionRect:{width:0,height:0,startX:Le.x,startY:Le.y,x:Ne,y:Ie}}),ke||(Z.stopPropagation(),Z.preventDefault())};function I(Z,se){const{userSelectionRect:me}=E.getState();if(!me)return;const{transform:ke,nodeLookup:ve,edgeLookup:re,connectionLookup:Ne,triggerNodeChanges:Ie,triggerEdgeChanges:Le,defaultEdgeOptions:$e}=E.getState(),lt={x:me.startX,y:me.startY},{x:at,y:ut}=eo(lt,ke),Ge={startX:lt.x,startY:lt.y,x:Zmt.id)),ee.current=new Set;const gt=($e==null?void 0:$e.selectable)??!0;for(const mt of te.current){const Ct=Ne.get(mt);if(Ct)for(const{edgeId:ct}of Ct.values()){const et=re.get(ct);et&&(et.selectable??gt)&&ee.current.add(ct)}}if(!Eh(wt,te.current)){const mt=Gi(ve,te.current,!0);Ie(mt)}if(!Eh(Gt,ee.current)){const mt=Gi(re,ee.current);Le(mt)}E.setState({userSelectionRect:Ge,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!a||!q.current)return;const[Z,se]=bc(C.current,q.current,$);A({x:Z,y:se}).then(me=>{if(!K.current||!me){b.current=requestAnimationFrame(z);return}const{x:ke,y:ve}=C.current;I(ke,ve),b.current=requestAnimationFrame(z)})}const ie=()=>{cancelAnimationFrame(b.current),b.current=0,V.current=!1};L.useEffect(()=>()=>ie(),[]);const oe=Z=>{const{userSelectionRect:se,transform:me,resetSelectedElements:ke}=E.getState();if(!q.current||!se)return;const{x:ve,y:re}=xn(Z.nativeEvent,q.current);C.current={x:ve,y:re};const Ne=eo({x:se.startX,y:se.startY},me);if(!K.current){const Ie=r?0:u;if(Math.hypot(ve-Ne.x,re-Ne.y)<=Ie)return;ke(),h==null||h(Z)}K.current=!0,V.current||(z(),V.current=!0),I(ve,re)},fe=Z=>{var se,me;if(!F){Z.target===G.current&&E.getState().connection.inProgress&&(ne.current=!0);return}Z.button===0&&((me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),!R&&Z.target===G.current&&E.getState().userSelectionRect&&(W==null||W(Z)),E.setState({userSelectionActive:!1,userSelectionRect:null}),K.current&&(p==null||p(Z),E.setState({nodesSelectionActive:te.current.size>0})),ie())},he=Z=>{var se,me;(me=(se=Z.target)==null?void 0:se.releasePointerCapture)==null||me.call(se,Z.pointerId),ie()},pe=s===!0||Array.isArray(s)&&s.includes(0);return d.jsxs("div",{className:rt(["react-flow__pane",{draggable:pe,dragging:N,selection:t}]),onClick:F?void 0:Qu(W,G),onContextMenu:Qu(U,G),onWheel:Qu(M,G),onPointerEnter:F?void 0:m,onPointerMove:F?oe:_,onPointerUp:fe,onPointerCancel:F?he:void 0,onPointerDownCapture:F?H:void 0,onClickCapture:F?D:void 0,onPointerLeave:k,ref:G,style:oa,children:[j,d.jsx(K_,{})]})}function gc({id:t,store:r,unselect:o=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:u,multiSelectionActive:c,nodeLookup:h,onError:p}=r.getState(),y=h.get(t);if(!y){p==null||p("012",wn.error012(t));return}r.setState({nodesSelectionActive:!1}),y.selected?(o||y.selected&&c)&&(u({nodes:[y],edges:[]}),requestAnimationFrame(()=>{var x;return(x=s==null?void 0:s.current)==null?void 0:x.blur()})):a([t])}function Ug({nodeRef:t,disabled:r=!1,noDragClassName:o,handleSelector:s,nodeId:a,isSelectable:u,nodeClickDistance:c}){const h=Ye(),[p,y]=L.useState(!1),x=L.useRef();return L.useEffect(()=>{if(!r)return x.current=z1({getStoreItems:()=>h.getState(),onNodeMouseDown:v=>{gc({id:v,store:h,nodeRef:t})},onDragStart:()=>{y(!0)},onDragStop:()=>{y(!1)}}),()=>{var v;(v=x.current)==null||v.destroy(),x.current=void 0}},[r,h,t]),L.useEffect(()=>{r||!t.current||!x.current||x.current.update({noDragClassName:o,handleSelector:s,domNode:t.current,isSelectable:u,nodeId:a,nodeClickDistance:c})},[o,s,r,u,t,a,c]),p}const J_=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function Yg(){const t=Ye();return L.useCallback(o=>{const{nodeExtent:s,snapToGrid:a,snapGrid:u,nodesDraggable:c,onError:h,updateNodePositions:p,nodeLookup:y,nodeOrigin:x}=t.getState(),v=new Map,m=J_(c),_=a?u[0]:5,k=a?u[1]:5,j=o.direction.x*_*o.factor,b=o.direction.y*k*o.factor;for(const[,E]of y){if(!m(E))continue;let R={x:E.internals.positionAbsolute.x+j,y:E.internals.positionAbsolute.y+b};a&&(R=gs(R,u));const{position:w,positionAbsolute:N}=dg({nodeId:E.id,nextPosition:R,nodeLookup:y,nodeExtent:s,nodeOrigin:x,onError:h});E.position=w,E.internals.positionAbsolute=N,v.set(E.id,E)}p(v)},[])}const Lc=L.createContext(null),eS=Lc.Provider;Lc.Consumer;const Gg=()=>L.useContext(Lc),tS=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Xg=L.createContext(null);function nS({children:t}){const r=De(tS,Qe);return d.jsx(Xg.Provider,{value:r,children:t})}function rS(){const t=L.useContext(Xg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const iS={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},oS=(t,r,o)=>s=>{const{connectionClickStartHandle:a,connectionMode:u,connection:c}=s,{fromHandle:h,toHandle:p,isValid:y}=c;if(!h&&!a)return iS;const x=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===o;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===o,connectingTo:x,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===r&&(a==null?void 0:a.type)===o,isPossibleEndHandle:u===Zi.Strict?(h==null?void 0:h.type)!==o:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!a,valid:x&&y}};function sS({type:t="source",position:r=Se.Top,isValidConnection:o,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:u=!0,id:c,onConnect:h,children:p,className:y,onMouseDown:x,onTouchStart:v,...m},_){var V,W;const k=c||null,j=t==="target",b=Ye(),E=Gg(),{connectOnClick:R,noPanClassName:w,rfId:N}=rS(),{connectingFrom:A,connectingTo:$,clickConnecting:F,isPossibleEndHandle:G,connectionInProcess:q,clickConnectionInProcess:te,valid:ee}=De(oS(E,k,t),Qe);E||(W=(V=b.getState()).onError)==null||W.call(V,"010",wn.error010());const ne=U=>{const{defaultEdgeOptions:M,onConnect:D,hasDefaultEdges:H}=b.getState(),I={...M,...U};if(H){const{edges:z,setEdges:ie,onError:oe}=b.getState();ie(D_(I,z,{onError:oe}))}D==null||D(I),h==null||h(I)},K=U=>{if(!E)return;const M=wg(U.nativeEvent);if(a&&(M&&U.button===0||!M)){const D=b.getState();pc.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:D.autoPanOnConnect,connectionMode:D.connectionMode,connectionRadius:D.connectionRadius,domNode:D.domNode,nodeLookup:D.nodeLookup,lib:D.lib,isTarget:j,handleId:k,nodeId:E,flowId:D.rfId,panBy:D.panBy,cancelConnection:D.cancelConnection,onConnectStart:D.onConnectStart,onConnectEnd:(...H)=>{var I,z;return(z=(I=b.getState()).onConnectEnd)==null?void 0:z.call(I,...H)},updateConnection:D.updateConnection,onConnect:ne,isValidConnection:o||((...H)=>{var I,z;return((z=(I=b.getState()).isValidConnection)==null?void 0:z.call(I,...H))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:D.autoPanSpeed,dragThreshold:D.connectionDragThreshold})}M?x==null||x(U):v==null||v(U)},C=U=>{const{onClickConnectStart:M,onClickConnectEnd:D,connectionClickStartHandle:H,connectionMode:I,isValidConnection:z,lib:ie,rfId:oe,nodeLookup:fe,connection:he}=b.getState();if(!E||!H&&!a)return;if(!H){M==null||M(U.nativeEvent,{nodeId:E,handleId:k,handleType:t}),b.setState({connectionClickStartHandle:{nodeId:E,type:t,id:k}});return}const pe=vg(U.target),Z=o||z,{connection:se,isValid:me}=pc.isValid(U.nativeEvent,{handle:{nodeId:E,id:k,type:t},connectionMode:I,fromNodeId:H.nodeId,fromHandleId:H.id||null,fromType:H.type,isValidConnection:Z,flowId:oe,doc:pe,lib:ie,nodeLookup:fe});me&&se&&ne(se);const ke=structuredClone(he);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,D==null||D(U,ke),b.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":k,"data-nodeid":E,"data-handlepos":r,"data-id":`${N}-${E}-${k}-${t}`,className:rt(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",w,y,{source:!j,target:j,connectable:s,connectablestart:a,connectableend:u,clickconnecting:F,connectingfrom:A,connectingto:$,valid:ee,connectionindicator:s&&(!q||G)&&(q||te?u:a)}]),onMouseDown:K,onTouchStart:K,onClick:R?C:void 0,ref:_,...m,children:p})}const no=L.memo(Bg(sS));function lS({data:t,isConnectable:r,sourcePosition:o=Se.Bottom}){return d.jsxs(d.Fragment,{children:[t==null?void 0:t.label,d.jsx(no,{type:"source",position:o,isConnectable:r})]})}function aS({data:t,isConnectable:r,targetPosition:o=Se.Top,sourcePosition:s=Se.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label,d.jsx(no,{type:"source",position:s,isConnectable:r})]})}function uS(){return null}function cS({data:t,isConnectable:r,targetPosition:o=Se.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:o,isConnectable:r}),t==null?void 0:t.label]})}const Ul={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},ip={input:lS,default:aS,output:cS,group:uS};function dS(t){var r,o,s,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((o=t.style)==null?void 0:o.height)}:{width:t.width??((s=t.style)==null?void 0:s.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const fS=t=>{const{width:r,height:o,x:s,y:a}=ps(t.nodeLookup,{filter:u=>!!u.selected});return{width:vn(r)?r:null,height:vn(o)?o:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${s}px,${a}px)`}};function hS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:o}){const s=Ye(),{width:a,height:u,transformString:c,userSelectionActive:h}=De(fS,Qe),p=Yg(),y=L.useRef(null);L.useEffect(()=>{var _;o||(_=y.current)==null||_.focus({preventScroll:!0})},[o]);const x=!h&&a!==null&&u!==null;if(Ug({nodeRef:y,disabled:!x}),!x)return null;const v=t?_=>{const k=s.getState().nodes.filter(j=>j.selected);t(_,k)}:void 0,m=_=>{Object.prototype.hasOwnProperty.call(Ul,_.key)&&(_.preventDefault(),p({direction:Ul[_.key],factor:_.shiftKey?4:1}))};return d.jsx("div",{className:rt(["react-flow__nodesselection","react-flow__container",r]),style:{transform:c},children:d.jsx("div",{ref:y,className:"react-flow__nodesselection-rect",onContextMenu:v,tabIndex:o?void 0:-1,onKeyDown:o?void 0:m,style:{width:a,height:u}})})}const op=typeof window<"u"?window:void 0,pS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function qg({children:t,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:y,selectionOnDrag:x,selectionMode:v,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:k,panActivationKeyCode:j,zoomActivationKeyCode:b,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:N,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:G,autoPanOnSelection:q,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,preventScrolling:C,onSelectionContextMenu:V,noWheelClassName:W,noPanClassName:U,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:H}){const{nodesSelectionActive:I,userSelectionActive:z}=De(pS,Qe),ie=as(y,{target:op}),oe=as(j,{target:op}),fe=oe||G,he=oe||N,pe=x&&fe!==!0,Z=ie||z||pe;return U_({deleteKeyCode:p,multiSelectionKeyCode:k}),d.jsx(X_,{onPaneContextMenu:u,elementsSelectable:E,zoomOnScroll:R,zoomOnPinch:w,panOnScroll:he,panActivationKeyPressed:oe,panOnScrollSpeed:A,panOnScrollMode:$,zoomOnDoubleClick:F,panOnDrag:!ie&&fe,defaultViewport:te,translateExtent:ee,minZoom:ne,maxZoom:K,zoomActivationKeyCode:b,preventScrolling:C,noWheelClassName:W,noPanClassName:U,onViewportChange:D,isControlledViewport:H,paneClickDistance:h,selectionOnDrag:pe,children:d.jsxs(Z_,{onSelectionStart:m,onSelectionEnd:_,onPaneClick:r,onPaneMouseEnter:o,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:u,onPaneScroll:c,panOnDrag:fe,autoPanOnSelection:q,isSelecting:!!Z,selectionMode:v,selectionKeyPressed:ie,paneClickDistance:h,selectionOnDrag:pe,children:[t,I&&d.jsx(hS,{onSelectionContextMenu:V,noPanClassName:U,disableKeyboardA11y:M})]})})}qg.displayName="FlowRenderer";const gS=L.memo(qg),mS=t=>r=>t?jc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(o=>o.id):Array.from(r.nodeLookup.keys());function yS(t){return De(L.useCallback(mS(t),[t]),Qe)}const vS=t=>t.updateNodeInternals;function xS(){const t=De(vS),[r]=L.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(o=>{const s=new Map;o.forEach(a=>{const u=a.target.getAttribute("data-id");s.set(u,{id:u,nodeElement:a.target,force:!0})}),t(s)}));return L.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function wS({node:t,nodeType:r,hasDimensions:o,resizeObserver:s}){const a=Ye(),u=L.useRef(null),c=L.useRef(null),h=L.useRef(t.sourcePosition),p=L.useRef(t.targetPosition),y=L.useRef(r),x=o&&!!t.internals.handleBounds;return L.useEffect(()=>{u.current&&!t.hidden&&(!x||c.current!==u.current)&&(c.current&&(s==null||s.unobserve(c.current)),s==null||s.observe(u.current),c.current=u.current)},[x,t.hidden]),L.useEffect(()=>()=>{c.current&&(s==null||s.unobserve(c.current),c.current=null)},[]),L.useEffect(()=>{if(u.current){const v=y.current!==r,m=h.current!==t.sourcePosition,_=p.current!==t.targetPosition;(v||m||_)&&(y.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:u.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),u}function _S({id:t,onClick:r,onMouseEnter:o,onMouseMove:s,onMouseLeave:a,onContextMenu:u,onDoubleClick:c,nodesDraggable:h,elementsSelectable:p,nodesConnectable:y,nodesFocusable:x,resizeObserver:v,noDragClassName:m,noPanClassName:_,disableKeyboardA11y:k,rfId:j,nodeTypes:b,nodeClickDistance:E,onError:R}){const{node:w,internals:N,isParent:A}=De(Z=>{const se=Z.nodeLookup.get(t),me=Z.parentLookup.has(t);return{node:se,internals:se.internals,isParent:me}},Qe);let $=w.type||"default",F=(b==null?void 0:b[$])||ip[$];F===void 0&&(R==null||R("003",wn.error003($)),$="default",F=(b==null?void 0:b.default)||ip.default);const G=!!(w.draggable||h&&typeof w.draggable>"u"),q=!!(w.selectable||p&&typeof w.selectable>"u"),te=!!(w.connectable||y&&typeof w.connectable>"u"),ee=!!(w.focusable||x&&typeof w.focusable>"u"),ne=Ye(),K=mg(w),C=wS({node:w,nodeType:$,hasDimensions:K,resizeObserver:v}),V=Ug({nodeRef:C,disabled:w.hidden||!G,noDragClassName:m,handleSelector:w.dragHandle,nodeId:t,isSelectable:q,nodeClickDistance:E}),W=Yg();if(w.hidden)return null;const U=Sn(w),M=dS(w),D=q||G||r||o||s||a,H=o?Z=>o(Z,{...N.userNode}):void 0,I=s?Z=>s(Z,{...N.userNode}):void 0,z=a?Z=>a(Z,{...N.userNode}):void 0,ie=u?Z=>u(Z,{...N.userNode}):void 0,oe=c?Z=>c(Z,{...N.userNode}):void 0,fe=Z=>{const{selectNodesOnDrag:se,nodeDragThreshold:me}=ne.getState();q&&(!se||!G||me>0)&&gc({id:t,store:ne,nodeRef:C}),r&&r(Z,{...N.userNode})},he=Z=>{if(!(xg(Z.nativeEvent)||k)){if(sg.includes(Z.key)&&q){const se=Z.key==="Escape";gc({id:t,store:ne,unselect:se,nodeRef:C})}else if(G&&w.selected&&Object.prototype.hasOwnProperty.call(Ul,Z.key)){Z.preventDefault();const{ariaLabelConfig:se}=ne.getState();ne.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:Z.key.replace("Arrow","").toLowerCase(),x:~~N.positionAbsolute.x,y:~~N.positionAbsolute.y})}),W({direction:Ul[Z.key],factor:Z.shiftKey?4:1})}}},pe=()=>{var Ne;if(k||!((Ne=C.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:Z,width:se,height:me,autoPanOnNodeFocus:ke,setCenter:ve}=ne.getState();if(!ke)return;jc(new Map([[t,w]]),{x:0,y:0,width:se,height:me},Z,!0).length>0||ve(w.position.x+U.width/2,w.position.y+U.height/2,{zoom:Z[2]})};return d.jsx("div",{className:rt(["react-flow__node",`react-flow__node-${$}`,{[_]:G},w.className,{selected:w.selected,selectable:q,parent:A,draggable:G,dragging:V}]),ref:C,style:{zIndex:N.z,transform:`translate(${N.positionAbsolute.x}px,${N.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:K?"visible":"hidden",...w.style,...M},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:H,onMouseMove:I,onMouseLeave:z,onContextMenu:ie,onClick:fe,onDoubleClick:oe,onKeyDown:ee?he:void 0,tabIndex:ee?0:void 0,onFocus:ee?pe:void 0,role:w.ariaRole??(ee?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${Dg}-${j}`,"aria-label":w.ariaLabel,...w.domAttributes,children:d.jsx(eS,{value:t,children:d.jsx(F,{id:t,data:w.data,type:$,positionAbsoluteX:N.positionAbsolute.x,positionAbsoluteY:N.positionAbsolute.y,selected:w.selected??!1,selectable:q,draggable:G,deletable:w.deletable??!0,isConnectable:te,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:V,dragHandle:w.dragHandle,zIndex:N.z,parentId:w.parentId,...U})})})}var SS=L.memo(_S);const kS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Kg(t){const{nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,onError:a}=De(kS,Qe),u=yS(t.onlyRenderVisibleElements),c=xS();return d.jsx("div",{className:"react-flow__nodes",style:oa,children:u.map(h=>d.jsx(SS,{id:h,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:o,elementsSelectable:s,nodeClickDistance:t.nodeClickDistance,onError:a},h))})}Kg.displayName="NodeRenderer";const NS=L.memo(Kg);function jS(t){return De(L.useCallback(o=>{if(!t)return o.edges.map(a=>a.id);const s=[];if(o.width&&o.height)for(const a of o.edges){const u=o.nodeLookup.get(a.source),c=o.nodeLookup.get(a.target);u&&c&&v1({sourceNode:u,targetNode:c,width:o.width,height:o.height,transform:o.transform})&&s.push(a.id)}return s},[t]),Qe)}const bS=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t}};return d.jsx("polyline",{className:"arrow",style:o,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},ES=({color:t="none",strokeWidth:r=1})=>{const o={strokeWidth:r,...t&&{stroke:t,fill:t}};return d.jsx("polyline",{className:"arrowclosed",style:o,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},sp={[os.Arrow]:bS,[os.ArrowClosed]:ES};function CS(t){const r=Ye();return L.useMemo(()=>{var a,u;return Object.prototype.hasOwnProperty.call(sp,t)?sp[t]:((u=(a=r.getState()).onError)==null||u.call(a,"009",wn.error009(t)),null)},[t])}const MS=({id:t,type:r,color:o,width:s=12.5,height:a=12.5,markerUnits:u="strokeWidth",strokeWidth:c,orient:h="auto-start-reverse"})=>{const p=CS(r);return p?d.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:u,orient:h,refX:"0",refY:"0",children:d.jsx(p,{color:o,strokeWidth:c})}):null},Qg=({defaultColor:t,rfId:r})=>{const o=De(u=>u.edges),s=De(u=>u.defaultEdgeOptions),a=L.useMemo(()=>b1(o,{id:r,defaultColor:t,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[o,s,r,t]);return a.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:a.map(u=>d.jsx(MS,{id:u.id,type:u.type,color:u.color,width:u.width,height:u.height,markerUnits:u.markerUnits,strokeWidth:u.strokeWidth,orient:u.orient},u.id))})}):null};Qg.displayName="MarkerDefinitions";var PS=L.memo(Qg);function Zg({x:t,y:r,label:o,labelStyle:s,labelShowBg:a=!0,labelBgStyle:u,labelBgPadding:c=[2,4],labelBgBorderRadius:h=2,children:p,className:y,...x}){const[v,m]=L.useState({x:1,y:0,width:0,height:0}),_=rt(["react-flow__edge-textwrapper",y]),k=L.useRef(null);return L.useEffect(()=>{if(k.current){const j=k.current.getBBox();m({x:j.x,y:j.y,width:j.width,height:j.height})}},[o]),o?d.jsxs("g",{transform:`translate(${t-v.width/2} ${r-v.height/2})`,className:_,visibility:v.width?"visible":"hidden",...x,children:[a&&d.jsx("rect",{width:v.width+2*c[0],x:-c[0],y:-c[1],height:v.height+2*c[1],className:"react-flow__edge-textbg",style:u,rx:h,ry:h}),d.jsx("text",{className:"react-flow__edge-text",y:v.height/2,dy:"0.3em",ref:k,style:s,children:o}),p]}):null}Zg.displayName="EdgeText";const IS=L.memo(Zg);function ys({path:t,labelX:r,labelY:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:y=20,...x}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...x,d:t,fill:"none",className:rt(["react-flow__edge-path",x.className])}),y?d.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:y,className:"react-flow__edge-interaction"}):null,s&&vn(r)&&vn(o)?d.jsx(IS,{x:r,y:o,label:s,labelStyle:a,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function lp({pos:t,x1:r,y1:o,x2:s,y2:a}){return t===Se.Left||t===Se.Right?[.5*(r+s),o]:[r,.5*(o+a)]}function Jg({sourceX:t,sourceY:r,sourcePosition:o=Se.Bottom,targetX:s,targetY:a,targetPosition:u=Se.Top}){const[c,h]=lp({pos:o,x1:t,y1:r,x2:s,y2:a}),[p,y]=lp({pos:u,x1:s,y1:a,x2:t,y2:r}),[x,v,m,_]=_g({sourceX:t,sourceY:r,targetX:s,targetY:a,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:y});return[`M${t},${r} C${c},${h} ${p},${y} ${s},${a}`,x,v,m,_]}function em(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c,targetPosition:h,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})=>{const[R,w,N]=Jg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h}),A=t.isInternal?void 0:r;return d.jsx(ys,{id:A,path:R,labelX:w,labelY:N,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:E})})}const RS=em({isInternal:!1}),tm=em({isInternal:!0});RS.displayName="SimpleBezierEdge";tm.displayName="SimpleBezierEdgeInternal";function nm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,sourcePosition:_=Se.Bottom,targetPosition:k=Se.Top,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=Wl({sourceX:o,sourceY:s,sourcePosition:_,targetX:a,targetY:u,targetPosition:k,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),$=t.isInternal?void 0:r;return d.jsx(ys,{id:$,path:w,labelX:N,labelY:A,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,markerEnd:j,markerStart:b,interactionWidth:R})})}const rm=nm({isInternal:!1}),im=nm({isInternal:!0});rm.displayName="SmoothStepEdge";im.displayName="SmoothStepEdgeInternal";function om(t){return L.memo(({id:r,...o})=>{var a;const s=t.isInternal?void 0:r;return d.jsx(rm,{...o,id:s,pathOptions:L.useMemo(()=>{var u;return{borderRadius:0,offset:(u=o.pathOptions)==null?void 0:u.offset}},[(a=o.pathOptions)==null?void 0:a.offset])})})}const TS=om({isInternal:!1}),sm=om({isInternal:!0});TS.displayName="StepEdge";sm.displayName="StepEdgeInternal";function lm(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,markerEnd:_,markerStart:k,interactionWidth:j})=>{const[b,E,R]=Ng({sourceX:o,sourceY:s,targetX:a,targetY:u}),w=t.isInternal?void 0:r;return d.jsx(ys,{id:w,path:b,labelX:E,labelY:R,label:c,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:x,labelBgBorderRadius:v,style:m,markerEnd:_,markerStart:k,interactionWidth:j})})}const LS=lm({isInternal:!1}),am=lm({isInternal:!0});LS.displayName="StraightEdge";am.displayName="StraightEdgeInternal";function um(t){return L.memo(({id:r,sourceX:o,sourceY:s,targetX:a,targetY:u,sourcePosition:c=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,pathOptions:E,interactionWidth:R})=>{const[w,N,A]=Sg({sourceX:o,sourceY:s,sourcePosition:c,targetX:a,targetY:u,targetPosition:h,curvature:E==null?void 0:E.curvature}),$=t.isInternal?void 0:r;return d.jsx(ys,{id:$,path:w,labelX:N,labelY:A,label:p,labelStyle:y,labelShowBg:x,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:_,style:k,markerEnd:j,markerStart:b,interactionWidth:R})})}const AS=um({isInternal:!1}),cm=um({isInternal:!0});AS.displayName="BezierEdge";cm.displayName="BezierEdgeInternal";const ap={default:cm,straight:am,step:sm,smoothstep:im,simplebezier:tm},up={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},$S=(t,r,o)=>o===Se.Left?t-r:o===Se.Right?t+r:t,zS=(t,r,o)=>o===Se.Top?t-r:o===Se.Bottom?t+r:t,cp="react-flow__edgeupdater";function dp({position:t,centerX:r,centerY:o,radius:s=10,onMouseDown:a,onMouseEnter:u,onMouseOut:c,type:h}){return d.jsx("circle",{onMouseDown:a,onMouseEnter:u,onMouseOut:c,className:rt([cp,`${cp}-${h}`]),cx:$S(r,s,t),cy:zS(o,s,t),r:s,stroke:"transparent",fill:"transparent"})}function DS({isReconnectable:t,reconnectRadius:r,edge:o,sourceX:s,sourceY:a,targetX:u,targetY:c,sourcePosition:h,targetPosition:p,onReconnect:y,onReconnectStart:x,onReconnectEnd:v,setReconnecting:m,setUpdateHover:_}){const k=Ye(),j=(N,A)=>{if(N.button!==0)return;const{autoPanOnConnect:$,domNode:F,connectionMode:G,connectionRadius:q,lib:te,onConnectStart:ee,cancelConnection:ne,nodeLookup:K,rfId:C,panBy:V,updateConnection:W}=k.getState(),U=A.type==="target",M=(I,z)=>{m(!1),v==null||v(I,o,A.type,z)},D=I=>y==null?void 0:y(o,I),H=(I,z)=>{m(!0),x==null||x(N,o,A.type),ee==null||ee(I,z)};pc.onPointerDown(N.nativeEvent,{autoPanOnConnect:$,connectionMode:G,connectionRadius:q,domNode:F,handleId:A.id,nodeId:A.nodeId,nodeLookup:K,isTarget:U,edgeUpdaterType:A.type,lib:te,flowId:C,cancelConnection:ne,panBy:V,isValidConnection:(...I)=>{var z,ie;return((ie=(z=k.getState()).isValidConnection)==null?void 0:ie.call(z,...I))??!0},onConnect:D,onConnectStart:H,onConnectEnd:(...I)=>{var z,ie;return(ie=(z=k.getState()).onConnectEnd)==null?void 0:ie.call(z,...I)},onReconnectEnd:M,updateConnection:W,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:N.currentTarget})},b=N=>j(N,{nodeId:o.target,id:o.targetHandle??null,type:"target"}),E=N=>j(N,{nodeId:o.source,id:o.sourceHandle??null,type:"source"}),R=()=>_(!0),w=()=>_(!1);return d.jsxs(d.Fragment,{children:[(t===!0||t==="source")&&d.jsx(dp,{position:h,centerX:s,centerY:a,radius:r,onMouseDown:b,onMouseEnter:R,onMouseOut:w,type:"source"}),(t===!0||t==="target")&&d.jsx(dp,{position:p,centerX:u,centerY:c,radius:r,onMouseDown:E,onMouseEnter:R,onMouseOut:w,type:"target"})]})}function OS({id:t,edgesFocusable:r,edgesReconnectable:o,elementsSelectable:s,onClick:a,onDoubleClick:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,reconnectRadius:x,onReconnect:v,onReconnectStart:m,onReconnectEnd:_,rfId:k,edgeTypes:j,noPanClassName:b,onError:E,disableKeyboardA11y:R}){let w=De(ve=>ve.edgeLookup.get(t));const N=De(ve=>ve.defaultEdgeOptions);w=N?{...N,...w}:w;let A=w.type||"default",$=(j==null?void 0:j[A])||ap[A];$===void 0&&(E==null||E("011",wn.error011(A)),A="default",$=(j==null?void 0:j.default)||ap.default);const F=!!(w.focusable||r&&typeof w.focusable>"u"),G=typeof v<"u"&&(w.reconnectable||o&&typeof w.reconnectable>"u"),q=!!(w.selectable||s&&typeof w.selectable>"u"),te=L.useRef(null),[ee,ne]=L.useState(!1),[K,C]=L.useState(!1),V=Ye(),{zIndex:W=w.zIndex,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z}=De(L.useCallback(ve=>{const re=ve.nodeLookup.get(w.source),Ne=ve.nodeLookup.get(w.target);if(!re||!Ne)return up;const Ie=j1({id:t,sourceNode:re,targetNode:Ne,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:ve.connectionMode,onError:E}),Le=y1({selected:w.selected,zIndex:w.zIndex,sourceNode:re,targetNode:Ne,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Ie||up,zIndex:Le}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex,E]),Qe),ie=L.useMemo(()=>w.markerStart?`url('#${fc(w.markerStart,k)}')`:void 0,[w.markerStart,k]),oe=L.useMemo(()=>w.markerEnd?`url('#${fc(w.markerEnd,k)}')`:void 0,[w.markerEnd,k]);if(w.hidden||U===null||M===null||D===null||H===null)return null;const fe=ve=>{var Le;const{addSelectedEdges:re,unselectNodesAndEdges:Ne,multiSelectionActive:Ie}=V.getState();q&&(V.setState({nodesSelectionActive:!1}),w.selected&&Ie?(Ne({nodes:[],edges:[w]}),(Le=te.current)==null||Le.blur()):re([t])),a&&a(ve,w)},he=u?ve=>{u(ve,{...w})}:void 0,pe=c?ve=>{c(ve,{...w})}:void 0,Z=h?ve=>{h(ve,{...w})}:void 0,se=p?ve=>{p(ve,{...w})}:void 0,me=y?ve=>{y(ve,{...w})}:void 0,ke=ve=>{var re;if(!R&&sg.includes(ve.key)&&q){const{unselectNodesAndEdges:Ne,addSelectedEdges:Ie}=V.getState();ve.key==="Escape"?((re=te.current)==null||re.blur(),Ne({edges:[w]})):Ie([t])}};return d.jsx("svg",{style:{zIndex:W},children:d.jsxs("g",{className:rt(["react-flow__edge",`react-flow__edge-${A}`,w.className,b,{selected:w.selected,animated:w.animated,inactive:!q&&!a,updating:ee,selectable:q}]),onClick:fe,onDoubleClick:he,onContextMenu:pe,onMouseEnter:Z,onMouseMove:se,onMouseLeave:me,onKeyDown:F?ke:void 0,tabIndex:F?0:void 0,role:w.ariaRole??(F?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":F?`${Og}-${k}`:void 0,ref:te,...w.domAttributes,children:[!K&&d.jsx($,{id:t,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:q,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:ie,markerEnd:oe,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),G&&d.jsx(DS,{edge:w,isReconnectable:G,reconnectRadius:x,onReconnect:v,onReconnectStart:m,onReconnectEnd:_,sourceX:U,sourceY:M,targetX:D,targetY:H,sourcePosition:I,targetPosition:z,setUpdateHover:ne,setReconnecting:C})]})})}var FS=L.memo(OS);const HS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function dm({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:o,edgeTypes:s,noPanClassName:a,onReconnect:u,onEdgeContextMenu:c,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:y,onEdgeClick:x,reconnectRadius:v,onEdgeDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,disableKeyboardA11y:j}){const{edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,onError:w}=De(HS,Qe),N=jS(r);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(PS,{defaultColor:t,rfId:o}),N.map(A=>d.jsx(FS,{id:A,edgesFocusable:b,edgesReconnectable:E,elementsSelectable:R,noPanClassName:a,onReconnect:u,onContextMenu:c,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,onClick:x,reconnectRadius:v,onDoubleClick:m,onReconnectStart:_,onReconnectEnd:k,rfId:o,onError:w,edgeTypes:s,disableKeyboardA11y:j},A))]})}dm.displayName="EdgeRenderer";const BS=L.memo(dm),fp=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function VS({children:t}){const r=Ye(),o=L.useRef(null),[s]=L.useState(()=>r.getState().transform);return Vg(()=>{let a=null;const u=()=>{const c=r.getState().transform;a&&c[0]===a[0]&&c[1]===a[1]&&c[2]===a[2]||(a=c,o.current&&(o.current.style.transform=fp(c)))};return u(),r.subscribe(u)},[r]),d.jsx("div",{ref:o,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:fp(s)},children:t})}function WS(t){const r=ia(),o=L.useRef(!1);L.useEffect(()=>{!o.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),o.current=!0)},[t,r.viewportInitialized])}const US=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function YS(t){const r=De(US),o=Ye();return L.useEffect(()=>{t&&(r==null||r(t),o.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function GS(t){return t.connection.inProgress?{...t.connection,to:ms(t.connection.to,t.transform)}:{...t.connection}}function XS(t){return GS}function qS(t){const r=XS();return De(r,Qe)}const KS=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function QS({containerStyle:t,style:r,type:o,component:s}){const{nodesConnectable:a,width:u,height:c,isValid:h,inProgress:p}=De(KS,Qe);return!(u&&a&&p)?null:d.jsx("svg",{style:t,width:u,height:c,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:rt(["react-flow__connection",ug(h)]),children:d.jsx(fm,{style:r,type:o,CustomComponent:s,isValid:h})})})}const fm=({style:t,type:r=Ar.Bezier,CustomComponent:o,isValid:s})=>{const{inProgress:a,from:u,fromNode:c,fromHandle:h,fromPosition:p,to:y,toNode:x,toHandle:v,toPosition:m,pointer:_}=qS();if(!a)return;if(o)return d.jsx(o,{connectionLineType:r,connectionLineStyle:t,fromNode:c,fromHandle:h,fromX:u.x,fromY:u.y,toX:y.x,toY:y.y,fromPosition:p,toPosition:m,connectionStatus:ug(s),toNode:x,toHandle:v,pointer:_});let k="";const j={sourceX:u.x,sourceY:u.y,sourcePosition:p,targetX:y.x,targetY:y.y,targetPosition:m};switch(r){case Ar.Bezier:[k]=Sg(j);break;case Ar.SimpleBezier:[k]=Jg(j);break;case Ar.Step:[k]=Wl({...j,borderRadius:0});break;case Ar.SmoothStep:[k]=Wl(j);break;default:[k]=Ng(j)}return d.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};fm.displayName="ConnectionLine";const ZS={};function hp(t=ZS){L.useRef(t),Ye(),L.useEffect(()=>{},[t])}function JS(){Ye(),L.useRef(!1),L.useEffect(()=>{},[])}function hm({nodeTypes:t,edgeTypes:r,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:x,onSelectionContextMenu:v,onSelectionStart:m,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:j,connectionLineComponent:b,connectionLineContainerStyle:E,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,deleteKeyCode:G,onlyRenderVisibleElements:q,elementsSelectable:te,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,preventScrolling:V,defaultMarkerColor:W,zoomOnScroll:U,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,zoomOnDoubleClick:z,panOnDrag:ie,autoPanOnSelection:oe,onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneScroll:se,onPaneContextMenu:me,paneClickDistance:ke,nodeClickDistance:ve,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Ie,onEdgeMouseLeave:Le,reconnectRadius:$e,onReconnect:lt,onReconnectStart:at,onReconnectEnd:ut,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:Gt,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Ct,viewport:ct,onViewportChange:et,nodesDraggable:Dn}){return hp(t),hp(r),JS(),WS(o),YS(ct),d.jsx(gS,{onPaneClick:fe,onPaneMouseEnter:he,onPaneMouseMove:pe,onPaneMouseLeave:Z,onPaneContextMenu:me,onPaneScroll:se,paneClickDistance:ke,deleteKeyCode:G,selectionKeyCode:R,selectionOnDrag:w,selectionMode:N,onSelectionStart:m,onSelectionEnd:_,multiSelectionKeyCode:A,panActivationKeyCode:$,zoomActivationKeyCode:F,elementsSelectable:te,zoomOnScroll:U,zoomOnPinch:M,zoomOnDoubleClick:z,panOnScroll:D,panOnScrollSpeed:H,panOnScrollMode:I,panOnDrag:ie,autoPanOnSelection:oe,defaultViewport:ee,translateExtent:ne,minZoom:K,maxZoom:C,onSelectionContextMenu:v,preventScrolling:V,noDragClassName:Ge,noWheelClassName:wt,noPanClassName:Gt,disableKeyboardA11y:gt,onViewportChange:et,isControlledViewport:!!ct,children:d.jsxs(VS,{children:[d.jsx(BS,{edgeTypes:r,onEdgeClick:a,onEdgeDoubleClick:c,onReconnect:lt,onReconnectStart:at,onReconnectEnd:ut,onlyRenderVisibleElements:q,onEdgeContextMenu:re,onEdgeMouseEnter:Ne,onEdgeMouseMove:Ie,onEdgeMouseLeave:Le,reconnectRadius:$e,defaultMarkerColor:W,noPanClassName:Gt,disableKeyboardA11y:gt,rfId:Ct}),d.jsx(QS,{style:j,type:k,component:b,containerStyle:E}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(NS,{nodeTypes:t,onNodeClick:s,onNodeDoubleClick:u,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:x,nodeClickDistance:ve,onlyRenderVisibleElements:q,noPanClassName:Gt,noDragClassName:Ge,disableKeyboardA11y:gt,nodeExtent:mt,rfId:Ct,nodesDraggable:Dn}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}hm.displayName="GraphView";const ek=L.memo(hm),tk=gg(),pp=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p=.5,maxZoom:y=2,nodeOrigin:x,nodeExtent:v,zIndexMode:m="basic"}={})=>{const _=new Map,k=new Map,j=new Map,b=new Map,E=s??r??[],R=o??t??[],w=x??[0,0],N=v??rs;Eg(j,b,E);const{nodesInitialized:A}=hc(R,_,k,{nodeOrigin:w,nodeExtent:N,zIndexMode:m});let $=[0,0,1];if(c&&a&&u){const F=ps(_,{filter:ee=>!!((ee.width||ee.initialWidth)&&(ee.height||ee.initialHeight))}),{x:G,y:q,zoom:te}=Ec(F,a,u,p,y,(h==null?void 0:h.padding)??.1);$=[G,q,te]}return{rfId:"1",width:a??0,height:u??0,transform:$,nodes:R,nodesInitialized:A,nodeLookup:_,parentLookup:k,edges:E,edgeLookup:b,connectionLookup:j,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:o!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:y,translateExtent:rs,nodeExtent:N,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Zi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,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:c??!1,fitViewOptions:h,fitViewResolver:null,connection:{...ag},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:tk,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:lg,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},nk=({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:x,nodeExtent:v,zIndexMode:m})=>p_((_,k)=>{async function j(){const{nodeLookup:b,panZoom:E,fitViewOptions:R,fitViewResolver:w,width:N,height:A,minZoom:$,maxZoom:F}=k();E&&(await c1({nodes:b,width:N,height:A,panZoom:E,minZoom:$,maxZoom:F},R),w==null||w.resolve(!0),_({fitViewResolver:null}))}return{...pp({nodes:t,edges:r,width:a,height:u,fitView:c,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:x,nodeExtent:v,defaultNodes:o,defaultEdges:s,zIndexMode:m}),setNodes:b=>{const{nodeLookup:E,parentLookup:R,nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,fitViewQueued:$,zIndexMode:F,nodesSelectionActive:G}=k(),{nodesInitialized:q,hasSelectedNodes:te}=hc(b,E,R,{nodeOrigin:w,nodeExtent:N,elevateNodesOnSelect:A,checkEquality:!0,zIndexMode:F}),ee=G&&te;$&&q?(j(),_({nodes:b,nodesInitialized:q,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:ee})):_({nodes:b,nodesInitialized:q,nodesSelectionActive:ee})},setEdges:b=>{const{connectionLookup:E,edgeLookup:R}=k();Eg(E,R,b),_({edges:b})},setDefaultNodesAndEdges:(b,E)=>{if(b){const{setNodes:R}=k();R(b),_({hasDefaultNodes:!0})}if(E){const{setEdges:R}=k();R(E),_({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:E,nodeLookup:R,parentLookup:w,domNode:N,nodeOrigin:A,nodeExtent:$,debug:F,fitViewQueued:G,zIndexMode:q}=k(),{changes:te,updatedInternals:ee}=T1(b,R,w,N,A,$,q);ee&&(M1(R,w,{nodeOrigin:A,nodeExtent:$,zIndexMode:q}),G?(j(),_({fitViewQueued:!1,fitViewOptions:void 0})):_({}),(te==null?void 0:te.length)>0&&(F&&console.log("React Flow: trigger node changes",te),E==null||E(te)))},updateNodePositions:(b,E=!1)=>{const R=[];let w=[];const{nodeLookup:N,triggerNodeChanges:A,connection:$,updateConnection:F,onNodesChangeMiddlewareMap:G}=k();for(const[q,te]of b){const ee=N.get(q),ne=!!(ee!=null&&ee.expandParent&&(ee!=null&&ee.parentId)&&(te!=null&&te.position)),K={id:q,type:"position",position:ne?{x:Math.max(0,te.position.x),y:Math.max(0,te.position.y)}:te.position,dragging:E};if(ee&&$.inProgress&&$.fromNode.id===ee.id){const C=hi(ee,$.fromHandle,Se.Left,!0);F({...$,from:C})}ne&&ee.parentId&&R.push({id:q,parentId:ee.parentId,rect:{...te.internals.positionAbsolute,width:te.measured.width??0,height:te.measured.height??0}}),w.push(K)}if(R.length>0){const{parentLookup:q,nodeOrigin:te}=k(),ee=Tc(R,N,q,te);w.push(...ee)}for(const q of G.values())w=q(w);A(w)},triggerNodeChanges:b=>{const{onNodesChange:E,setNodes:R,nodes:w,hasDefaultNodes:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=A_(b,w);R($)}A&&console.log("React Flow: trigger node changes",b),E==null||E(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:E,setEdges:R,edges:w,hasDefaultEdges:N,debug:A}=k();if(b!=null&&b.length){if(N){const $=$_(b,w);R($)}A&&console.log("React Flow: trigger edge changes",b),E==null||E(b)}},addSelectedNodes:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>oi(F,!0));N($);return}N(Gi(w,new Set([...b]),!0)),A(Gi(R))},addSelectedEdges:b=>{const{multiSelectionActive:E,edgeLookup:R,nodeLookup:w,triggerNodeChanges:N,triggerEdgeChanges:A}=k();if(E){const $=b.map(F=>oi(F,!0));A($);return}A(Gi(R,new Set([...b]))),N(Gi(w,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:E}={})=>{const{edges:R,nodes:w,nodeLookup:N,triggerNodeChanges:A,triggerEdgeChanges:$}=k(),F=b||w,G=E||R,q=[];for(const ee of F){if(!ee.selected)continue;const ne=N.get(ee.id);ne&&(ne.selected=!1),q.push(oi(ee.id,!1))}const te=[];for(const ee of G)ee.selected&&te.push(oi(ee.id,!1));A(q),$(te)},setMinZoom:b=>{const{panZoom:E,maxZoom:R}=k();E==null||E.setScaleExtent([b,R]),_({minZoom:b})},setMaxZoom:b=>{const{panZoom:E,minZoom:R}=k();E==null||E.setScaleExtent([R,b]),_({maxZoom:b})},setTranslateExtent:b=>{var E;(E=k().panZoom)==null||E.setTranslateExtent(b),_({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:E,triggerNodeChanges:R,triggerEdgeChanges:w,elementsSelectable:N}=k();if(!N)return;const A=E.reduce((F,G)=>G.selected?[...F,oi(G.id,!1)]:F,[]),$=b.reduce((F,G)=>G.selected?[...F,oi(G.id,!1)]:F,[]);R(A),w($)},setNodeExtent:b=>{const{nodes:E,nodeLookup:R,parentLookup:w,nodeOrigin:N,elevateNodesOnSelect:A,nodeExtent:$,zIndexMode:F}=k();b[0][0]===$[0][0]&&b[0][1]===$[0][1]&&b[1][0]===$[1][0]&&b[1][1]===$[1][1]||(hc(E,R,w,{nodeOrigin:N,nodeExtent:b,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:F}),_({nodeExtent:b}))},panBy:b=>{const{transform:E,width:R,height:w,panZoom:N,translateExtent:A}=k();return L1({delta:b,panZoom:N,transform:E,translateExtent:A,width:R,height:w})},setCenter:async(b,E,R)=>{const{width:w,height:N,maxZoom:A,panZoom:$}=k();if(!$)return!1;const F=typeof(R==null?void 0:R.zoom)<"u"?R.zoom:A;return await $.setViewport({x:w/2-b*F,y:N/2-E*F,zoom:F},{duration:R==null?void 0:R.duration,ease:R==null?void 0:R.ease,interpolate:R==null?void 0:R.interpolate}),!0},cancelConnection:()=>{_({connection:{...ag}})},updateConnection:b=>{_({connection:b})},reset:()=>_({...pp()})}},Object.is);function pm({initialNodes:t,initialEdges:r,defaultNodes:o,defaultEdges:s,initialWidth:a,initialHeight:u,initialMinZoom:c,initialMaxZoom:h,initialFitViewOptions:p,fitView:y,nodeOrigin:x,nodeExtent:v,zIndexMode:m,children:_}){const[k]=L.useState(()=>nk({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,width:a,height:u,fitView:y,minZoom:c,maxZoom:h,fitViewOptions:p,nodeOrigin:x,nodeExtent:v,zIndexMode:m}));return d.jsx(g_,{value:k,children:d.jsx(H_,{children:d.jsx(nS,{children:_})})})}function rk({children:t,nodes:r,edges:o,defaultNodes:s,defaultEdges:a,width:u,height:c,fitView:h,fitViewOptions:p,minZoom:y,maxZoom:x,nodeOrigin:v,nodeExtent:m,zIndexMode:_}){return L.useContext(na)?d.jsx(d.Fragment,{children:t}):d.jsx(pm,{initialNodes:r,initialEdges:o,defaultNodes:s,defaultEdges:a,initialWidth:u,initialHeight:c,fitView:h,initialFitViewOptions:p,initialMinZoom:y,initialMaxZoom:x,nodeOrigin:v,nodeExtent:m,zIndexMode:_,children:t})}const ik={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function ok({nodes:t,edges:r,defaultNodes:o,defaultEdges:s,className:a,nodeTypes:u,edgeTypes:c,onNodeClick:h,onEdgeClick:p,onInit:y,onMove:x,onMoveStart:v,onMoveEnd:m,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,onNodeDragStart:F,onNodeDrag:G,onNodeDragStop:q,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onSelectionChange:K,onSelectionDragStart:C,onSelectionDrag:V,onSelectionDragStop:W,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:H,connectionMode:I,connectionLineType:z=Ar.Bezier,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,deleteKeyCode:he="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:Z=!1,selectionMode:se=is.Full,panActivationKeyCode:me="Space",multiSelectionKeyCode:ke=ls()?"Meta":"Control",zoomActivationKeyCode:ve=ls()?"Meta":"Control",snapToGrid:re,snapGrid:Ne,onlyRenderVisibleElements:Ie=!1,selectNodesOnDrag:Le,nodesDraggable:$e,autoPanOnNodeFocus:lt,nodesConnectable:at,nodesFocusable:ut,nodeOrigin:Ge=Fg,edgesFocusable:wt,edgesReconnectable:Gt,elementsSelectable:gt=!0,defaultViewport:mt=C_,minZoom:Ct=.5,maxZoom:ct=2,translateExtent:et=rs,preventScrolling:Dn=!0,nodeExtent:Mt,defaultMarkerColor:kn="#b1b1b7",zoomOnScroll:oo=!0,zoomOnPinch:On=!0,panOnScroll:gi=!1,panOnScrollSpeed:lr=.5,panOnScrollMode:zr=ai.Free,zoomOnDoubleClick:Fn=!0,panOnDrag:Dr=!0,onPaneClick:ar,onPaneMouseEnter:ur,onPaneMouseMove:Ft,onPaneMouseLeave:dt,onPaneScroll:Hn,onPaneContextMenu:Bn,paneClickDistance:Nn=1,nodeClickDistance:Vn=0,children:jn,onReconnect:it,onReconnectStart:cr,onReconnectEnd:bn,onEdgeContextMenu:Pt,onEdgeDoubleClick:nn,onEdgeMouseEnter:mi,onEdgeMouseMove:Ze,onEdgeMouseLeave:He,reconnectRadius:En=10,onNodesChange:Wn,onEdgesChange:rn,noDragClassName:Or="nodrag",noWheelClassName:on="nowheel",noPanClassName:It="nopan",fitView:Xt,fitViewOptions:Un,connectOnClick:yi,attributionPosition:vi,proOptions:Rt,defaultEdgeOptions:Yn,elevateNodesOnSelect:Fr=!0,elevateEdgesOnSelect:Gn=!1,disableKeyboardA11y:dr=!1,autoPanOnConnect:Ve,autoPanOnNodeDrag:so,autoPanOnSelection:Hr=!0,autoPanSpeed:xi,connectionRadius:fr,isValidConnection:lo,onError:wi,style:Cn,id:_t,nodeDragThreshold:ao,connectionDragThreshold:yt,viewport:uo,onViewportChange:co,width:Br,height:Mn,colorMode:Xn="light",debug:Pn,onScroll:qt,ariaLabelConfig:Vr,zIndexMode:Wr="basic",...hr},Ur){const sn=_t||"1",qn=R_(Xn),_i=L.useCallback(pr=>{pr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),qt==null||qt(pr)},[qt]);return d.jsx("div",{"data-testid":"rf__wrapper",...hr,onScroll:_i,style:{...Cn,...ik},ref:Ur,className:rt(["react-flow",a,qn]),id:_t,role:"application",children:d.jsxs(rk,{nodes:t,edges:r,width:Br,height:Mn,fitView:Xt,fitViewOptions:Un,minZoom:Ct,maxZoom:ct,nodeOrigin:Ge,nodeExtent:Mt,zIndexMode:Wr,children:[d.jsx(I_,{nodes:t,edges:r,defaultNodes:o,defaultEdges:s,onConnect:_,onConnectStart:k,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:E,nodesDraggable:$e,autoPanOnNodeFocus:lt,nodesConnectable:at,nodesFocusable:ut,edgesFocusable:wt,edgesReconnectable:Gt,elementsSelectable:gt,elevateNodesOnSelect:Fr,elevateEdgesOnSelect:Gn,minZoom:Ct,maxZoom:ct,nodeExtent:Mt,onNodesChange:Wn,onEdgesChange:rn,snapToGrid:re,snapGrid:Ne,connectionMode:I,translateExtent:et,connectOnClick:yi,defaultEdgeOptions:Yn,fitView:Xt,fitViewOptions:Un,onNodesDelete:te,onEdgesDelete:ee,onDelete:ne,onNodeDragStart:F,onNodeDrag:G,onNodeDragStop:q,onSelectionDrag:V,onSelectionDragStart:C,onSelectionDragStop:W,onMove:x,onMoveStart:v,onMoveEnd:m,noPanClassName:It,nodeOrigin:Ge,rfId:sn,autoPanOnConnect:Ve,autoPanOnNodeDrag:so,autoPanSpeed:xi,onError:wi,connectionRadius:fr,isValidConnection:lo,selectNodesOnDrag:Le,nodeDragThreshold:ao,connectionDragThreshold:yt,onBeforeDelete:H,debug:Pn,ariaLabelConfig:Vr,zIndexMode:Wr}),d.jsx(ek,{onInit:y,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:R,onNodeMouseMove:w,onNodeMouseLeave:N,onNodeContextMenu:A,onNodeDoubleClick:$,nodeTypes:u,edgeTypes:c,connectionLineType:z,connectionLineStyle:ie,connectionLineComponent:oe,connectionLineContainerStyle:fe,selectionKeyCode:pe,selectionOnDrag:Z,selectionMode:se,deleteKeyCode:he,multiSelectionKeyCode:ke,panActivationKeyCode:me,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Ie,defaultViewport:mt,translateExtent:et,minZoom:Ct,maxZoom:ct,preventScrolling:Dn,zoomOnScroll:oo,zoomOnPinch:On,zoomOnDoubleClick:Fn,panOnScroll:gi,panOnScrollSpeed:lr,panOnScrollMode:zr,panOnDrag:Dr,autoPanOnSelection:Hr,onPaneClick:ar,onPaneMouseEnter:ur,onPaneMouseMove:Ft,onPaneMouseLeave:dt,onPaneScroll:Hn,onPaneContextMenu:Bn,paneClickDistance:Nn,nodeClickDistance:Vn,onSelectionContextMenu:U,onSelectionStart:M,onSelectionEnd:D,onReconnect:it,onReconnectStart:cr,onReconnectEnd:bn,onEdgeContextMenu:Pt,onEdgeDoubleClick:nn,onEdgeMouseEnter:mi,onEdgeMouseMove:Ze,onEdgeMouseLeave:He,reconnectRadius:En,defaultMarkerColor:kn,noDragClassName:Or,noWheelClassName:on,noPanClassName:It,rfId:sn,disableKeyboardA11y:dr,nodeExtent:Mt,viewport:uo,onViewportChange:co,nodesDraggable:$e}),d.jsx(E_,{onSelectionChange:K}),jn,d.jsx(S_,{proOptions:Rt,position:vi}),d.jsx(__,{rfId:sn,disableKeyboardA11y:dr})]})})}var sk=Bg(ok);function lk({dimensions:t,lineWidth:r,variant:o,className:s}){return d.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:rt(["react-flow__background-pattern",o,s])})}function ak({radius:t,className:r}){return d.jsx("circle",{cx:t,cy:t,r:t,className:rt(["react-flow__background-pattern","dots",r])})}var $r;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})($r||($r={}));const uk={[$r.Dots]:1,[$r.Lines]:1,[$r.Cross]:6},ck=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function gm({id:t,variant:r=$r.Dots,gap:o=20,size:s,lineWidth:a=1,offset:u=0,color:c,bgColor:h,style:p,className:y,patternClassName:x}){const v=L.useRef(null),{transform:m,patternId:_}=De(ck,Qe),k=s||uk[r],j=r===$r.Dots,b=r===$r.Cross,E=Array.isArray(o)?o:[o,o],R=[E[0]*m[2]||1,E[1]*m[2]||1],w=k*m[2],N=Array.isArray(u)?u:[u,u],A=b?[w,w]:R,$=[N[0]*m[2]+A[0]/2,N[1]*m[2]+A[1]/2],F=`${_}${t||""}`;return d.jsxs("svg",{className:rt(["react-flow__background",y]),style:{...p,...oa,"--xy-background-color-props":h,"--xy-background-pattern-color-props":c},ref:v,"data-testid":"rf__background",children:[d.jsx("pattern",{id:F,x:m[0]%R[0],y:m[1]%R[1],width:R[0],height:R[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:j?d.jsx(ak,{radius:w/2,className:x}):d.jsx(lk,{dimensions:A,lineWidth:a,variant:r,className:x})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${F})`})]})}gm.displayName="Background";const dk=L.memo(gm);function fk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function hk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function pk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.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 gk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 mk(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.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 El({children:t,className:r,...o}){return d.jsx("button",{type:"button",className:rt(["react-flow__controls-button",r]),...o,children:t})}const yk=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function mm({style:t,showZoom:r=!0,showFitView:o=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:u,onZoomOut:c,onFitView:h,onInteractiveChange:p,className:y,children:x,position:v="bottom-left",orientation:m="vertical","aria-label":_}){const k=Ye(),{isInteractive:j,minZoomReached:b,maxZoomReached:E,ariaLabelConfig:R}=De(yk,Qe),{zoomIn:w,zoomOut:N,fitView:A}=ia(),$=()=>{w(),u==null||u()},F=()=>{N(),c==null||c()},G=()=>{A(a),h==null||h()},q=()=>{k.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),p==null||p(!j)},te=m==="horizontal"?"horizontal":"vertical";return d.jsxs(ra,{className:rt(["react-flow__controls",te,y]),position:v,style:t,"data-testid":"rf__controls","aria-label":_??R["controls.ariaLabel"],children:[r&&d.jsxs(d.Fragment,{children:[d.jsx(El,{onClick:$,className:"react-flow__controls-zoomin",title:R["controls.zoomIn.ariaLabel"],"aria-label":R["controls.zoomIn.ariaLabel"],disabled:E,children:d.jsx(fk,{})}),d.jsx(El,{onClick:F,className:"react-flow__controls-zoomout",title:R["controls.zoomOut.ariaLabel"],"aria-label":R["controls.zoomOut.ariaLabel"],disabled:b,children:d.jsx(hk,{})})]}),o&&d.jsx(El,{className:"react-flow__controls-fitview",onClick:G,title:R["controls.fitView.ariaLabel"],"aria-label":R["controls.fitView.ariaLabel"],children:d.jsx(pk,{})}),s&&d.jsx(El,{className:"react-flow__controls-interactive",onClick:q,title:R["controls.interactive.ariaLabel"],"aria-label":R["controls.interactive.ariaLabel"],children:j?d.jsx(mk,{}):d.jsx(gk,{})}),x]})}mm.displayName="Controls";const vk=L.memo(mm);function xk({id:t,x:r,y:o,width:s,height:a,style:u,color:c,strokeColor:h,strokeWidth:p,className:y,borderRadius:x,shapeRendering:v,selected:m,onClick:_}){const{background:k,backgroundColor:j}=u||{},b=c||k||j;return d.jsx("rect",{className:rt(["react-flow__minimap-node",{selected:m},y]),x:r,y:o,rx:x,ry:x,width:s,height:a,style:{fill:b,stroke:h,strokeWidth:p},shapeRendering:v,onClick:_?E=>_(E,t):void 0})}const wk=L.memo(xk),_k=t=>t.nodes.map(r=>r.id),Zu=t=>t instanceof Function?t:()=>t;function Sk({nodeStrokeColor:t,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:a,nodeComponent:u=wk,onClick:c}){const h=De(_k,Qe),p=Zu(r),y=Zu(t),x=Zu(o),v=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:h.map(m=>d.jsx(Nk,{id:m,nodeColorFunc:p,nodeStrokeColorFunc:y,nodeClassNameFunc:x,nodeBorderRadius:s,nodeStrokeWidth:a,NodeComponent:u,onClick:c,shapeRendering:v},m))})}function kk({id:t,nodeColorFunc:r,nodeStrokeColorFunc:o,nodeClassNameFunc:s,nodeBorderRadius:a,nodeStrokeWidth:u,shapeRendering:c,NodeComponent:h,onClick:p}){const{node:y,x,y:v,width:m,height:_}=De(k=>{const j=k.nodeLookup.get(t);if(!j)return{node:void 0,x:0,y:0,width:0,height:0};const b=j.internals.userNode,{x:E,y:R}=j.internals.positionAbsolute,{width:w,height:N}=Sn(b);return{node:b,x:E,y:R,width:w,height:N}},Qe);return!y||y.hidden||!mg(y)?null:d.jsx(h,{x,y:v,width:m,height:_,style:y.style,selected:!!y.selected,className:s(y),color:r(y),borderRadius:a,strokeColor:o(y),strokeWidth:u,shapeRendering:c,onClick:p,id:y.id})}const Nk=L.memo(kk);var jk=L.memo(Sk);const bk=200,Ek=150,Ck=t=>!t.hidden,Mk=t=>{const r={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:r,boundingRect:t.nodeLookup.size>0?hg(ps(t.nodeLookup,{filter:Ck}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},gp=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,Pk=(t,r)=>gp(t.viewBB,r.viewBB)&&gp(t.boundingRect,r.boundingRect)&&t.rfId===r.rfId&&t.panZoom===r.panZoom&&t.translateExtent===r.translateExtent&&t.flowWidth===r.flowWidth&&t.flowHeight===r.flowHeight&&t.ariaLabelConfig===r.ariaLabelConfig,Ik="react-flow__minimap-desc";function ym({style:t,className:r,nodeStrokeColor:o,nodeColor:s,nodeClassName:a="",nodeBorderRadius:u=5,nodeStrokeWidth:c,nodeComponent:h,bgColor:p,maskColor:y,maskStrokeColor:x,maskStrokeWidth:v,position:m="bottom-right",onClick:_,onNodeClick:k,pannable:j=!1,zoomable:b=!1,ariaLabel:E,inversePan:R,zoomStep:w=1,offsetScale:N=5}){const A=Ye(),$=L.useRef(null),{boundingRect:F,viewBB:G,rfId:q,panZoom:te,translateExtent:ee,flowWidth:ne,flowHeight:K,ariaLabelConfig:C}=De(Mk,Pk),V=(t==null?void 0:t.width)??bk,W=(t==null?void 0:t.height)??Ek,U=F.width/V,M=F.height/W,D=Math.max(U,M),H=D*V,I=D*W,z=N*D,ie=F.x-(H-F.width)/2-z,oe=F.y-(I-F.height)/2-z,fe=H+z*2,he=I+z*2,pe=`${Ik}-${q}`,Z=L.useRef(0),se=L.useRef();Z.current=D,L.useEffect(()=>{if($.current&&te)return se.current=V1({domNode:$.current,panZoom:te,getTransform:()=>A.getState().transform,getViewScale:()=>Z.current}),()=>{var re;(re=se.current)==null||re.destroy()}},[te]),L.useEffect(()=>{var re;(re=se.current)==null||re.update({translateExtent:ee,width:ne,height:K,inversePan:R,pannable:j,zoomStep:w,zoomable:b})},[j,b,R,w,ee,ne,K]);const me=_?re=>{var Le;const[Ne,Ie]=((Le=se.current)==null?void 0:Le.pointer(re))||[0,0];_(re,{x:Ne,y:Ie})}:void 0,ke=k?L.useCallback((re,Ne)=>{const Ie=A.getState().nodeLookup.get(Ne).internals.userNode;k(re,Ie)},[]):void 0,ve=E??C["minimap.ariaLabel"];return d.jsx(ra,{position:m,style:{...t,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof y=="string"?y:void 0,"--xy-minimap-mask-stroke-color-props":typeof x=="string"?x:void 0,"--xy-minimap-mask-stroke-width-props":typeof v=="number"?v*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:rt(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:V,height:W,viewBox:`${ie} ${oe} ${fe} ${he}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:$,onClick:me,children:[ve&&d.jsx("title",{id:pe,children:ve}),d.jsx(jk,{onClick:ke,nodeColor:s,nodeStrokeColor:o,nodeBorderRadius:u,nodeClassName:a,nodeStrokeWidth:c,nodeComponent:h}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${ie-z},${oe-z}h${fe+z*2}v${he+z*2}h${-fe-z*2}z + M${G.x},${G.y}h${G.width}v${G.height}h${-G.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}ym.displayName="MiniMap";const Rk=L.memo(ym),Tk=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,Lk={[to.Line]:"right",[to.Handle]:"bottom-right"};function Ak({nodeId:t,position:r,variant:o=to.Handle,className:s,style:a=void 0,children:u,color:c,minWidth:h=10,minHeight:p=10,maxWidth:y=Number.MAX_VALUE,maxHeight:x=Number.MAX_VALUE,keepAspectRatio:v=!1,resizeDirection:m,autoScale:_=!0,shouldResize:k,onResizeStart:j,onResize:b,onResizeEnd:E}){const R=Gg(),w=typeof t=="string"?t:R,N=Ye(),A=L.useRef(null),$=o===to.Handle,F=De(L.useCallback(Tk($&&_),[$,_]),Qe),G=L.useRef(null),q=r??Lk[o];L.useEffect(()=>{if(!(!A.current||!w))return G.current||(G.current=n_({domNode:A.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,domNode:W}=N.getState();return{nodeLookup:ee,transform:ne,snapGrid:K,snapToGrid:C,nodeOrigin:V,paneDomNode:W}},onChange:(ee,ne)=>{const{triggerNodeChanges:K,nodeLookup:C,parentLookup:V,nodeOrigin:W}=N.getState(),U=[],M={x:ee.x,y:ee.y},D=C.get(w);if(D&&D.expandParent&&D.parentId){const H=D.origin??W,I=ee.width??D.measured.width??0,z=ee.height??D.measured.height??0,ie={id:D.id,parentId:D.parentId,rect:{width:I,height:z,...yg({x:ee.x??D.position.x,y:ee.y??D.position.y},{width:I,height:z},D.parentId,C,H)}},oe=Tc([ie],C,V,W);U.push(...oe),M.x=ee.x?Math.max(H[0]*I,ee.x):void 0,M.y=ee.y?Math.max(H[1]*z,ee.y):void 0}if(M.x!==void 0&&M.y!==void 0){const H={id:w,type:"position",position:{...M}};U.push(H)}if(ee.width!==void 0&&ee.height!==void 0){const I={id:w,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:ee.width,height:ee.height}};U.push(I)}for(const H of ne){const I={...H,type:"position"};U.push(I)}K(U)},onEnd:({width:ee,height:ne})=>{const K={id:w,type:"dimensions",resizing:!1,dimensions:{width:ee,height:ne}};N.getState().triggerNodeChanges([K])}})),G.current.update({controlPosition:q,boundaries:{minWidth:h,minHeight:p,maxWidth:y,maxHeight:x},keepAspectRatio:v,resizeDirection:m,onResizeStart:j,onResize:b,onResizeEnd:E,shouldResize:k}),()=>{var ee;(ee=G.current)==null||ee.destroy()}},[q,h,p,y,x,v,j,b,E,k]);const te=q.split("-");return d.jsx("div",{className:rt(["react-flow__resize-control","nodrag",...te,o,s]),ref:A,style:{...a,scale:F,...c&&{[$?"backgroundColor":"borderColor"]:c}},children:u})}L.memo(Ak);const $k={"arch.context":0,"django.app":0,"django.route":1,"django.websocket_route":1,"fastapi.route":1,"django.url_name":2,"django.view":3,"django.viewset_action":3,"django.permission":3,"django.throttle":3,"django.serializer":4,"django.form":4,"graphql.type":4,"fastapi.model":4,"django.serializer_field":5,"django.service":5,"graphql.field":5,"django.model":6,"django.field":7,"django.relation":7,"django.task":8,"django.receiver":8,"django.signal":8,"django.test":8,"django.migration_op":8,"django.admin":8,"django.management_command":8,"django.consumer":8,"django.cache_key":8,"django.feature_flag":8,"django.side_effect":8,"openapi.path":9,"graphql.operation":9,"react.api_client":10,"django.htmx":10,"react.query_key":11,"react.hook":11,"react.feature":11,"react.route":12,"react.page":12,"django.template":12,"react.component":13,"react.context":13,"react.form_schema":14,"react.test":14};function sa(t){return $k[t]??8}const us=208,ro=64,mc=88,zk=28,Dk=8;function Ok(t){if(!t.length)return Number.NaN;const r=[...t].sort((s,a)=>s-a),o=Math.floor(r.length/2);return r.length%2?r[o]:(r[o-1]+r[o])/2}function vm(t,r=[]){const o=new Map;if(!t.length)return o;const s=new Map;for(const w of t){const N=sa(w.type),A=s.get(N)??[];A.push(w),s.set(N,A)}const u=[...s.keys()].sort((w,N)=>w-N).map(w=>[...s.get(w)??[]].sort((N,A)=>N.name.localeCompare(A.name)||N.id.localeCompare(A.id))),c=new Set(t.map(w=>w.id)),h=new Map,p=new Map;for(const w of t)h.set(w.id,[]),p.set(w.id,[]);for(const w of r)!c.has(w.src)||!c.has(w.dst)||w.src===w.dst||(p.get(w.src).push(w.dst),h.get(w.dst).push(w.src));const y=new Map;u.forEach((w,N)=>{for(const A of w)y.set(A.id,N)});const x=new Map,v=()=>{for(const w of u)w.forEach((N,A)=>x.set(N.id,A))};v();const m=(w,N)=>{const A=w.map(($,F)=>{const G=N($.id).map(te=>x.get(te)).filter(te=>te!==void 0),q=Ok(G);return{n:$,bary:Number.isNaN(q)?F:q,name:$.name,id:$.id}});return A.sort(($,F)=>$.bary-F.bary||$.name.localeCompare(F.name)||$.id.localeCompare(F.id)),A.map($=>$.n)},_=w=>N=>y.get(N)===w;for(let w=0;w(h.get(A)??[]).filter(_(N-1))),v();for(let N=u.length-2;N>=0;N--)u[N]=m(u[N],A=>(p.get(A)??[]).filter(_(N+1))),v()}const k=us+mc,j=ro+zk,b=Math.max(...u.map(w=>w.length),1),E=[];let R=0;for(let w=0;wG.id)),A=new Set((u[w+1]??[]).map(G=>G.id));let $=0;if(A.size)for(const G of r)N.has(G.src)&&A.has(G.dst)&&($+=1);const F=Math.min(120,Math.max(0,($-2)*12));R+=k+F}return u.forEach((w,N)=>{const A=(b-w.length)*j/2;w.forEach(($,F)=>{o.set($.id,{x:E[N]??0,y:A+F*j})})}),o}const Fk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","openapi.path","django.consumer","django.websocket_route","django.template","graphql.operation","fastapi.route"]),xm=90,Hk=new Set(["django.field","django.serializer_field","django.relation","django.test","react.test","graphql.field","django.url_name","django.throttle"]),mp={"arch.context":"#edf2f4","django.app":"#8d99ae","django.route":"#4cc9f0","django.url_name":"#4cc9f0","django.view":"#4895ef","django.viewset_action":"#4361ee","django.permission":"#7b8cde","django.serializer":"#f4a261","django.form":"#e9c46a","django.serializer_field":"#e9c46a","django.service":"#90be6d","django.model":"#2a9d8f","django.field":"#8ac926","django.task":"#e76f51","django.receiver":"#e85d04","django.signal":"#f4a261","django.test":"#6c757d","django.admin":"#adb5bd","django.migration_op":"#9d4edd","django.consumer":"#e76f51","django.websocket_route":"#4cc9f0","django.template":"#c77dff","django.htmx":"#ff6b6b","django.cache_key":"#6c757d","django.feature_flag":"#f4a261","django.side_effect":"#e85d04","graphql.type":"#00bbf9","graphql.operation":"#00bbf9","fastapi.route":"#4cc9f0","fastapi.model":"#f4a261","openapi.path":"#00bbf9","react.api_client":"#ff6b6b","react.query_key":"#adb5bd","react.hook":"#7b2cbf","react.feature":"#9d4edd","react.route":"#c77dff","react.page":"#c77dff","react.component":"#9d4edd","react.form_schema":"#ffd166","react.test":"#6c757d"},Bk=Math.PI*(3-Math.sqrt(5)),wm=220,Vk=26,Wk={0:"context",1:"routes",2:"url names",3:"views",4:"serializers",5:"services",6:"models",7:"fields",8:"jobs / signals",9:"openapi",10:"api client",11:"hooks",12:"pages",13:"components",14:"forms / tests"};function _m(t){return t.startsWith("react.")?"react":t.startsWith("openapi.")||t.startsWith("graphql.")||t.startsWith("fastapi.")?"stitch":t.startsWith("arch.")?"arch":"django"}function UN(t){return mp[t]?mp[t]:t.startsWith("react.")?"#9d4edd":t.startsWith("openapi.")?"#00bbf9":"#4a5568"}function Uk(t){return t>=xm?"3d":"2d"}function Yk(t){return t>=xm?"overview":"full"}function Gk(t,r,o=1){const s=new Set([t]);let a=new Set([t]);for(let u=0;uo.families.has(_m(h.type)));o.detail==="overview"&&(s=s.filter(h=>!Hk.has(h.type)));const a=new Set(s.map(h=>h.id)),u=r.filter(h=>a.has(h.src)&&a.has(h.dst)),c=o.focusId?Gk(o.focusId,u,1):new Set;if(o.neighborhoodOnly&&o.focusId&&c.size){s=s.filter(p=>c.has(p.id));const h=new Set(s.map(p=>p.id));return{nodes:s,edges:u.filter(p=>h.has(p.src)&&h.has(p.dst)),neighborIds:c}}return{nodes:s,edges:u,neighborIds:c}}function qk(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>`${s.name} ${s.qualified_name} ${s.type} ${s.file_path||""} ${s.context||""}`.toLowerCase().includes(o)).slice(0,24):[]}function Kk(t,r,o,s){const a=new Set(t.map(j=>j.id));if(!a.has(o))return{nodeIds:new Set,edgeIds:new Set};const u=new Map,c=new Map;for(const j of r){if(!a.has(j.src)||!a.has(j.dst))continue;const b=u.get(j.src)??[];b.push({dst:j.dst,id:j.id}),u.set(j.src,b);const E=c.get(j.dst)??[];E.push({src:j.src,id:j.id}),c.set(j.dst,E)}const h=new Set(t.filter(j=>Fk.has(j.type)).map(j=>j.id)),p=h.size?h:a,y=new Set,x=[o];for(;x.length;){const j=x.pop();if(!y.has(j)){y.add(j);for(const b of u.get(j)??[])y.has(b.dst)||x.push(b.dst)}}const v=new Set([o]),m=[...p].filter(j=>y.has(j)),_=new Set(m);for(;m.length;){const j=m.pop();v.add(j);for(const b of c.get(j)??[])y.has(b.src)&&!_.has(b.src)&&(_.add(b.src),m.push(b.src))}const k=new Set;for(const j of r)v.has(j.src)&&v.has(j.dst)&&k.add(j.id);return{nodeIds:v,edgeIds:k}}function YN(t){const r=new Map;for(const s of t){const a=sa(s.type),u=r.get(a)??[];u.push(s),r.set(a,u)}const o=new Map;for(const[s,a]of r){a.sort((c,h)=>c.name.localeCompare(h.name));const u=s*wm;a.forEach((c,h)=>{if(a.length===1){o.set(c.id,{x:u,y:0,z:0});return}const p=Vk*Math.sqrt(h+1),y=h*Bk;o.set(c.id,{x:u,y:p*Math.cos(y),z:p*Math.sin(y)})})}return o}function GN(t){const r=new Map;for(const o of t){const s=sa(o.type);r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>o[0]-s[0]).map(([o,s])=>({layer:o,x:o*wm,count:s}))}const Cl=16,Qk=12,Zk=new Set(["django.route","react.route","react.page","django.task","django.migration_op","django.permission","django.throttle","django.admin","django.management_command","openapi.path","django.consumer","django.websocket_route","django.template","django.cache_key","django.feature_flag","django.side_effect","graphql.operation","fastapi.route"]),Jk=new Set(["django.serializer","django.serializer_field","django.form","openapi.path","react.form_schema","django.route","graphql.type","graphql.field","graphql.operation","fastapi.model","fastapi.route"]),yp={"arch.context":"Ownership boundary from loadpath.yml — the context this code belongs to.","django.app":"Django app package that owns models, views, and jobs.","django.route":"HTTP URL that publishes a view. A sink: this is where a change becomes a public request.","django.url_name":"Named URL used by reverse() / {% url %} lookups.","django.view":"Request handler (class-based view, function view, or ViewSet).","django.viewset_action":"One ViewSet action (list, create, retrieve, update, destroy).","django.permission":"Auth gate on a view — who is allowed to hit this path.","django.throttle":"Rate-limit class attached to a view.","django.serializer":"Request/response contract: which fields go in and come out.","django.form":"Django form or django-filter FilterSet — the typed input contract.","django.serializer_field":"One field on a serializer or form — the typed slot on the contract.","django.service":"Internal service or use-case. Work that is not itself an HTTP sink.","django.model":"ORM model. Schema and relations live here.","django.field":"Model column. Type, indexes, and relations are the contract of the table.","django.relation":"Model-to-model relation (FK / M2M / O2O).","django.task":"Celery or Dramatiq job. Once enqueued, this is a sink.","django.receiver":"Signal handler that runs after a model event.","django.signal":"Django signal that receivers subscribe to.","django.test":"Backend test that mentions symbols on this path.","django.admin":"Django admin class for a model.","django.migration_op":"Schema migration operation (CreateModel, AlterField, …).","django.management_command":"manage.py command — an operational sink.","django.consumer":"Django Channels WebSocket/HTTP consumer. A sink once a client connects.","django.websocket_route":"ASGI WebSocket URL. A sink: this is where a change becomes a live connection.","django.template":"Django template. HTML (and HTMX) the server renders.","django.htmx":"HTMX call from a template to a URL — another published seam.","django.cache_key":"Cache get/set key. Invalidation is part of the load path.","django.feature_flag":"Feature flag checked on this path. The change may be dark-launched.","django.side_effect":"transaction.on_commit (or similar) side effect that runs after the request commits.","graphql.type":"GraphQL object/input type — a published contract.","graphql.field":"One field on a GraphQL type.","graphql.operation":"GraphQL query, mutation, or subscription. A published contract and a sink.","fastapi.route":"FastAPI path operation sitting next to Django in this repo.","fastapi.model":"Pydantic response/request model — the FastAPI contract.","openapi.path":"Generated OpenAPI operation. The typed HTTP contract between stacks.","react.api_client":"Frontend fetch or generated client call to an API path.","react.query_key":"React Query cache key. Invalidation and reads share this name.","react.hook":"Data hook wrapping query or mutation calls.","react.feature":"Frontend feature module (folder).","react.route":"Client-side route. A sink: this is a URL the user can open.","react.page":"Page or screen component rendered by a route.","react.component":"UI component.","react.form_schema":"Zod (or similar) schema — typed form inputs on the client.","react.test":"Frontend test covering a page, hook, or component.","react.context":"React context provider."},eN={field_type:"Type",fields:"Fields",form_fields:"Form fields",permissions:"Permissions",throttles:"Throttles",authentication:"Authentication",pagination:"Pagination",filterset:"Filterset",bases:"Extends",on_delete:"on_delete",related_name:"related_name",unique:"Unique",db_index:"Indexed",relation:"Relation field",looks_idempotent_on_pk:"Idempotent on pk",broker:"Broker",route:"Route",url_name:"URL name",view:"View",include:"Includes",mounted_at:"Mounted at",full_path:"Full path",method:"Method",path:"Path",operation_id:"Operation",raw:"URL",kind:"Schema",exclude:"Excludes",queryset_in_serializer:"Queryset in serializer",get_queryset:"Custom get_queryset",get_serializer_class:"Dynamic serializer",dynamic:"Dynamic",fbv:"Function view",ninja:"Django Ninja",django_form:"Django form",mutation:"Mutation",has_error_boundary:"Error boundary",invalidation:"Cache invalidation",inferred:"Inferred stitch",generated:"Generated",shared:"Shared module",element:"Renders",model_name:"Model",field_name:"Field",op:"Operation",app:"App",feature:"Feature",from_view:"From view",mentions:"Mentions",nodeid:"Test id",task:"Task",to:"Related to",doc:"Summary",template:"Template",signal:"Signal",sender:"Sender",decorators:"Decorators",nplusone:"N+1 risk",lookups:"Lookups",null:"NULL",blank:"Blank",default:"Default",max_length:"max_length",max_digits:"max_digits",decimal_places:"decimal_places",primary_key:"Primary key",help_text:"Help text",choices:"Choices",auto_now:"auto_now",auto_now_add:"auto_now_add",basename:"Router basename",args:"Args",beat:"Beat",schedule_name:"Schedule",websocket:"WebSocket",htmx:"HTMX",blocks:"Blocks",db_table:"db_table"},vp=["doc","field_type","method","path","operation_id","raw","route","mounted_at","full_path","url_name","view","element","fields","form_fields","exclude","kind","bases","permissions","authentication","throttles","pagination","filterset","on_delete","related_name","to","unique","db_index","null","blank","default","max_length","max_digits","decimal_places","primary_key","auto_now","auto_now_add","help_text","choices","relation","nplusone","lookups","template","signal","sender","decorators","basename","args","beat","schedule_name","websocket","htmx","blocks","db_table","looks_idempotent_on_pk","broker","task","model_name","field_name","op","app","feature","from_view","include","fbv","ninja","django_form","mutation","has_error_boundary","invalidation","inferred","generated","shared","queryset_in_serializer","get_queryset","get_serializer_class","dynamic","mentions","nodeid"],xp=new Set(["referenced","placeholder","booted","line","call","from","import","local","source","file","plain_handler","string_ref","pagination_sink","match","via","generated_client","django","react","superseded_by_generated","foreign_app","imported"]),tN=new Set(["looks_idempotent_on_pk","null","blank"]),nN=new Set(["inferred","generated","mutation","fbv","ninja","filterset"]);function rN(t){return yp[t]?yp[t]:t.startsWith("react.")?"A React node on the load path.":t.startsWith("django.")?"A Django node on the load path.":t.startsWith("openapi.")?"A stitch node between Django and React.":"A node on the architecture graph."}function iN(t,r,o){const s=new Map(r.map(m=>[m.id,m])),a=[];Zk.has(t.type)&&a.push("sink"),Jk.has(t.type)&&a.push("contract");const u=t.extra??{};u.inferred&&a.push("inferred"),u.generated&&a.push("generated"),u.mutation&&a.push("mutation"),u.fbv&&a.push("function view"),u.ninja&&a.push("ninja"),u.filterset===!0&&a.push("filterset");const c=o.filter(m=>m.dst===t.id),h=o.filter(m=>m.src===t.id),p=c.slice(0,Cl).map(m=>Ml(m,s,m.src)),y=h.slice(0,Cl).map(m=>Ml(m,s,m.dst)),x=t.file_path?`${t.file_path}${t.start_line?`:${t.start_line}`:""}`:void 0,v={type:t.type,typeLabel:Zo(io(t.type)),layer:Wk[sa(t.type)]??"other",purpose:rN(t.type),name:t.name,qualifiedName:t.qualified_name,file:x,context:t.context,roles:a,facts:sN(u).filter(m=>!(m.key==="app"&&m.value===t.context)),inputs:p,outputs:y,extraInputs:Math.max(0,c.length-Cl),extraOutputs:Math.max(0,h.length-Cl),degreeIn:c.length,degreeOut:h.length,inputKinds:wp(c.map(m=>Ml(m,s,m.src))),outputKinds:wp(h.map(m=>Ml(m,s,m.dst))),pathSummary:""};return v.pathSummary=oN(v),v}function wp(t){const r=new Map;for(const o of t){const s=o.edgeLabel||o.edgeType.replaceAll("_"," ");r.set(s,(r.get(s)||0)+1)}return[...r.entries()].sort((o,s)=>s[1]-o[1]||o[0].localeCompare(s[0])).map(([o,s])=>({label:o,count:s}))}function oN(t){const r=t.inputKinds.map(s=>`${s.label} ×${s.count}`).join(", "),o=t.outputKinds.map(s=>`${s.label} ×${s.count}`).join(", ");return r&&o?`${r} → this → ${o}`:o?`this → ${o}`:r?`${r} → this`:""}function Ml(t,r,o){const s=r.get(o),a=o.includes(":")?o.slice(o.indexOf(":")+1):o;return{id:o,name:(s==null?void 0:s.name)||a,type:(s==null?void 0:s.type)||"",typeLabel:s?Zo(io(s.type)):"",edgeType:t.type,edgeLabel:Zo(t.type),inferred:t.confidence<.8}}function sN(t){const r=[...vp.filter(a=>a in t),...Object.keys(t).filter(a=>!vp.includes(a)&&!xp.has(a))],o=[],s=new Set;for(const a of r){if(s.has(a)||xp.has(a)||nN.has(a))continue;s.add(a);const u=lN(a,t[a]);u!=null&&o.push({key:a,label:eN[a]??Zo(a),value:u})}return o}function lN(t,r){if(r==null)return null;if(typeof r=="boolean")return!r&&!tN.has(t)?null:r?"yes":"no";if(typeof r=="number")return String(r);if(typeof r=="string")return r.trim()||null;if(Array.isArray(r)){if(r.some(u=>u&&typeof u=="object"))return aN(t,r);const o=r.map(u=>typeof u=="string"||typeof u=="number"?String(u):"").filter(Boolean);if(!o.length)return null;const s=o.slice(0,Qk),a=o.length-s.length;return a>0?`${s.join(", ")} +${a} more`:s.join(", ")}return null}function aN(t,r){const o=r.slice(0,4).map(a=>{if(t==="nplusone"){const c=String(a.queryset||"queryset"),h=Array.isArray(a.accessed)?a.accessed.join("."):"",p=a.line?` L${a.line}`:"";return h?`${c} → ${h}${p}`:`${c}${p}`}if(t==="lookups"){const c=Array.isArray(a.fields)?a.fields.join(", "):"",h=String(a.kind||"filter");return c?`${h} ${c}`:h}return Object.entries(a).filter(([,c])=>c!=null&&(typeof c=="string"||typeof c=="number")).slice(0,3).map(([c,h])=>`${c}=${h}`).join(" ")});if(!o.some(Boolean))return null;const s=r.length-o.length;return s>0?`${o.join("; ")} +${s} more`:o.join("; ")}const _p=12,Sp=.2,uN=.8,Yl=20,cN=ro;function dN(t,r,o){const s=o??vm(t,r),a=[...new Set([...s.values()].map(p=>p.x))].sort((p,y)=>p-y),u=[];for(const p of r){const y=s.get(p.src),x=s.get(p.dst);if(!y||!x)continue;const v=y.y+ro/2,m=x.y+ro/2;if(Math.abs(v-m)<_p)continue;const _=y.x+us,k=x.x;if(k-_<_p)continue;const b=Math.min(v,m),E=Math.max(v,m);u.push({id:p.id,y0:b,y1:E,sourceX:_,targetX:k,corridor:`${Math.round(_/8)}`})}const c=new Map;for(const p of u){const y=c.get(p.corridor)??[];y.push(p),c.set(p.corridor,y)}const h=new Map;for(const p of c.values()){const y=[...p].sort((k,j)=>k.y0-j.y0||k.y1-j.y1||k.id.localeCompare(j.id)),x=pN(y),v=Math.max(0,...x.values())+1,m=y[0].sourceX,_=fN(a,m);for(const k of y){const j=gN(x.get(k.id)??0,v),b=m+Yl+Math.max(1,_-2*Yl)*j;h.set(k.id,hN(k.sourceX,k.targetX,b))}}return h}function fN(t,r){const o=r-us,s=t.find(a=>a>o+1);return s===void 0?mc:Math.max(mc,s-r)}function hN(t,r,o){const s=r-t-2*Yl;return s<1?.5:Math.min(1,Math.max(0,(o-t-Yl)/s))}function pN(t){const r=[],o=new Map;for(const s of t){let a=-1;for(let u=0;ur[u]+cN){a=u;break}a<0?(a=r.length,r.push(s.y1)):r[a]=Math.max(r[a],s.y1),o.set(s.id,a)}return o}function gN(t,r){return r<=1?.5:Sp+(uN-Sp)*t/(r-1)}const mN=new Set,yN=L.lazy(()=>b0(()=>import("./LayeredGraph3D-BkYe4qmj.js"),[],import.meta.url).then(t=>({default:t.LayeredGraph3D}))),vN={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function xN({data:t,selected:r}){const o=(t.roles||[]).map(s=>`role-${s}`).join(" ");return d.jsxs("div",{className:["lp-node",r?"selected":"",t.dim?"dim":"",o].filter(Boolean).join(" "),children:[d.jsx(no,{type:"target",position:Se.Left,isConnectable:!1}),d.jsx("div",{className:"t",children:io(t.type)}),d.jsx("div",{className:"n",title:t.name,children:Lr(t.name)}),d.jsx(no,{type:"source",position:Se.Right,isConnectable:!1})]})}const wN={load:xN},_N=new Set(["django","react","stitch","arch"]);function SN({id:t,sourceX:r,sourceY:o,targetX:s,targetY:a,sourcePosition:u,targetPosition:c,style:h,markerEnd:p,markerStart:y,label:x,labelStyle:v,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,data:b,interactionWidth:E}){const[R,w,N]=Wl({sourceX:r,sourceY:o,sourcePosition:u,targetX:s,targetY:a,targetPosition:c,borderRadius:8,stepPosition:(b==null?void 0:b.stepPosition)??.5});return d.jsx(ys,{id:t,path:R,labelX:w,labelY:N,label:x,labelStyle:v,labelShowBg:m,labelBgStyle:_,labelBgPadding:k,labelBgBorderRadius:j,style:h,markerEnd:p,markerStart:y,interactionWidth:E})}const kN={loadstep:SN};function NN({topologyKey:t}){const{fitView:r}=ia();return L.useEffect(()=>{let o=0;const s=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{r({padding:.2,maxZoom:1.15})})});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(o)}},[r,t]),null}function jN(t,r,o=null,s={}){const a=new Map(t.map(y=>[y.id,y])),u=vm(t,r),c=dN(t,r,u),h=t.map(y=>{var m;const x=((m=s.roles)==null?void 0:m[y.id])||[],v=!!s.testOverlay&&!x.includes("tested")&&!x.includes("untested")&&!x.includes("test")&&!x.includes("seed");return{id:y.id,type:"load",position:u.get(y.id)??{x:0,y:0},data:{name:y.name,type:y.type,file:y.file_path,roles:x,dim:v},selected:o===y.id,sourcePosition:Se.Right,targetPosition:Se.Left,width:us,height:ro,style:{width:us,height:ro}}}),p=r.filter(y=>a.has(y.src)&&a.has(y.dst)).map(y=>{const x=vN[y.weight]||"var(--edge-cheap)",v=!!(o&&(y.src===o||y.dst===o));return{id:y.id,source:y.src,target:y.dst,type:"loadstep",animated:y.weight==="critical",data:{stepPosition:c.get(y.id)??.5},style:{stroke:x,strokeWidth:y.weight==="critical"?2.4:1.2,strokeDasharray:y.confidence<.8?"6 4":void 0},markerEnd:{type:os.ArrowClosed,width:14,height:14,color:x},label:v?y.type.replaceAll("_"," "):void 0,labelStyle:v?{fill:"var(--ink)",fontSize:10,fontWeight:600}:void 0,labelBgStyle:v?{fill:"var(--graph-bg)",fillOpacity:.92}:void 0,labelBgPadding:v?[3,5]:void 0,labelBgBorderRadius:v?4:void 0}});return{rfNodes:h,rfEdges:p}}function bN({node:t,nodes:r,edges:o,onClose:s,onWhatIf:a,onSelect:u,onOpenFile:c,pinned:h,onPin:p,onIsolate:y}){const x=iN(t,r,o);return L.useEffect(()=>{const v=m=>{m.key==="Escape"&&s()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[s]),d.jsxs("aside",{className:"inspector","data-testid":"graph-inspector",children:[d.jsxs("div",{className:"inspector-head",children:[d.jsx("div",{className:"t",children:x.typeLabel}),d.jsx("div",{className:"inspector-roles",children:x.roles.map(v=>d.jsx("span",{className:"inspector-chip",children:v},v))}),d.jsx("button",{type:"button",className:"inspector-close","data-testid":"graph-inspector-close","aria-label":"Close inspector",onClick:s,children:"×"})]}),d.jsx("div",{className:"n",children:Lr(x.name)}),d.jsx("p",{className:"inspector-purpose","data-testid":"graph-inspector-purpose",children:x.purpose}),x.context?d.jsx("div",{className:"muted",children:Lr(x.context)}):null,x.file?d.jsxs("div",{className:"file-row",children:[d.jsx("div",{className:"file",children:Lr(x.file)}),c&&t.file_path?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-open-editor",onClick:()=>c(t.file_path,t.start_line),children:"Open in editor"}):null]}):null,d.jsx("div",{className:"muted",children:Lr(x.qualifiedName)}),d.jsxs("div",{className:"muted inspector-layer",children:["layer · ",x.layer]}),d.jsxs("div",{className:"muted inspector-degree","data-testid":"graph-inspector-degree",children:[x.degreeIn," in · ",x.degreeOut," out"]}),x.pathSummary?d.jsx("p",{className:"inspector-path","data-testid":"graph-inspector-path",children:x.pathSummary}):null,x.facts.length?d.jsx("dl",{className:"inspector-facts","data-testid":"graph-inspector-facts",children:x.facts.map(v=>d.jsxs("div",{className:"inspector-fact",children:[d.jsx("dt",{children:v.label}),d.jsx("dd",{children:Lr(v.value)})]},v.key))}):null,d.jsx(kp,{title:"Inputs",testId:"graph-inspector-inputs",links:x.inputs,extra:x.extraInputs,empty:"Nothing in this graph points here.",onSelect:u}),d.jsx(kp,{title:"Outputs",testId:"graph-inspector-outputs",links:x.outputs,extra:x.extraOutputs,empty:"This node does not point at anything in this graph.",onSelect:u}),a?d.jsx("p",{className:"whatif-hint","data-testid":"whatif-hint",children:y?"Walks a new path from this node with no git range. Isolate (next) only hides the rest of this map.":"Walks a new path from this node with no git range — as if this changed, regardless of Base/Head."}):null,d.jsxs("div",{className:"btn-row",children:[a?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-whatif",title:"Start a hypothetical walk from this node. Does not use Base/Head.",onClick:()=>a(t.id),children:"What if this changes"}):null,y?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-isolate",title:"Hide nodes that are not on a path from here to a sink. Does not start a new walk.",onClick:()=>y(t.id),children:"Isolate path to sinks"}):null,p?d.jsx("button",{type:"button",className:h?"btn primary":"btn","data-testid":"btn-pin-node",onClick:()=>p(h?null:t.id),children:h?"Unpin":"Pin"}):null]})]})}function kp({title:t,testId:r,links:o,extra:s,empty:a,onSelect:u}){return d.jsxs("section",{className:"inspector-section","data-testid":r,children:[d.jsxs("h3",{children:[t,d.jsx("span",{className:"count",children:o.length+s})]}),o.length?d.jsx("ul",{children:o.map((c,h)=>d.jsx("li",{children:u?d.jsxs("button",{type:"button",className:"inspector-link",onClick:()=>u(c.id),children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Lr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]}):d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"inspector-link-name",title:c.name,children:Lr(c.name)}),d.jsxs("span",{className:"inspector-link-meta",children:[c.typeLabel?`${c.typeLabel} · `:"",c.edgeLabel,c.inferred?" · inferred":""]})]})},`${c.edgeType}:${c.id}:${h}`))}):d.jsx("p",{className:"muted",children:a}),s?d.jsxs("p",{className:"muted",children:["+",s," more"]}):null]})}function Ju({nodes:t,edges:r,onWhatIf:o,focusPath:s,selectedId:a,onSelect:u,nodeRoles:c,testOverlay:h=!1,isolateSource:p,onIsolate:y,repoPath:x,onOpenFile:v,pinnedId:m,onPin:_}){const[k,j]=L.useState(null),b=a!==void 0?a:k,E=re=>{a===void 0&&j(re),u==null||u(re)},[R,w]=L.useState(null),[N,A]=L.useState(null),[$,F]=L.useState(new Set(_N)),[G,q]=L.useState(!1),[te,ee]=L.useState(""),[ne,K]=L.useState(!1),C=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,V=R??Uk(t.length),W=N??Yk(t.length),U=G?b:null,M=L.useMemo(()=>p?Kk(t,r,p):null,[t,r,p]),D=M?t.filter(re=>M.nodeIds.has(re.id)):t,H=M?r.filter(re=>M.edgeIds.has(re.id)):r,I=L.useMemo(()=>Xk(D,H,{detail:W,families:$,focusId:U,neighborhoodOnly:!!U}),[D,H,W,$,U]),z=L.useMemo(()=>`${I.nodes.map(re=>re.id).join("\0")}|${I.edges.map(re=>re.id).join("\0")}`,[I.nodes,I.edges]),ie=b?t.find(re=>re.id===b)??null:null,{rfNodes:oe,rfEdges:fe}=L.useMemo(()=>{const re=jN(I.nodes,I.edges,b,{roles:c,testOverlay:h});return C&&(re.rfEdges=re.rfEdges.map(Ne=>({...Ne,animated:!1}))),re},[I.nodes,I.edges,b,C,c,h]);L.useEffect(()=>{if(!s)return;const re=t.find(Ne=>Ne.file_path===s);re&&E(re.id)},[s,t]);const he=L.useMemo(()=>qk(t,te),[t,te]),pe=(re,Ne)=>{E(Ne.id)},Z=()=>{E(null),q(!1)},se=ie?d.jsx(bN,{node:ie,nodes:t,edges:r,onClose:Z,onWhatIf:o,onSelect:E,onOpenFile:v,pinned:m===ie.id,onPin:_,onIsolate:y?re=>{y(p===re?null:re)}:void 0}):null,me=re=>{F(Ne=>{const Ie=new Set(Ne);if(Ie.has(re)){if(Ie.size===1)return Ne;Ie.delete(re)}else Ie.add(re);return Ie})},ke=L.useMemo(()=>{const re=new Set;for(const Ne of t)re.add(_m(Ne.type));return re},[t]),ve=t.length-I.nodes.length;return d.jsxs("div",{className:"impact-graph",style:{flex:1,minHeight:0,position:"relative",display:"flex",flexDirection:"column"},children:[d.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[d.jsxs("div",{className:"seg","aria-label":"Graph projection",children:[d.jsx("button",{type:"button","data-testid":"graph-view-2d",className:V==="2d"?"active":"","aria-pressed":V==="2d",onClick:()=>w("2d"),children:"2D map"}),d.jsx("button",{type:"button","data-testid":"graph-view-3d",className:V==="3d"?"active":"","aria-pressed":V==="3d",onClick:()=>w("3d"),children:"3D layers"})]}),d.jsxs("div",{className:"seg","aria-label":"Graph detail",children:[d.jsx("button",{type:"button","data-testid":"graph-detail-overview",className:W==="overview"?"active":"","aria-pressed":W==="overview",onClick:()=>A("overview"),children:"Overview"}),d.jsx("button",{type:"button","data-testid":"graph-detail-full",className:W==="full"?"active":"","aria-pressed":W==="full",onClick:()=>A("full"),children:"Full"})]}),d.jsx("div",{className:"seg","aria-label":"Graph families",children:["django","stitch","react"].filter(re=>ke.has(re)).map(re=>d.jsx("button",{type:"button","data-testid":`graph-family-${re}`,className:$.has(re)?"active":"","aria-pressed":$.has(re),onClick:()=>me(re),children:re},re))}),d.jsx("button",{type:"button",className:G?"chip-btn active":"chip-btn","data-testid":"graph-neighborhood",disabled:!b,onClick:()=>q(re=>!re),children:G?"Neighborhood":"Focus neighbors"}),p?d.jsx("button",{type:"button",className:"chip-btn active","data-testid":"graph-isolate-clear",onClick:()=>y==null?void 0:y(null),children:"Path isolate"}):null,d.jsxs("label",{className:"graph-search",children:[d.jsx("span",{className:"sr-only",children:"Search nodes"}),d.jsx("input",{"data-testid":"graph-search",placeholder:"Find a node",value:te,onChange:re=>{ee(re.target.value),K(!0)},onFocus:()=>K(!0),onBlur:()=>window.setTimeout(()=>K(!1),150)}),ne&&te.trim()&&he.length?d.jsx("ul",{className:"graph-search-hits","data-testid":"graph-search-hits",children:he.map(re=>d.jsx("li",{children:d.jsxs("button",{type:"button",onMouseDown:Ne=>Ne.preventDefault(),onClick:()=>{E(re.id),ee(""),K(!1)},children:[re.name,d.jsx("span",{className:"muted",children:io(re.type)})]})},re.id))}):null]}),d.jsxs("span",{className:"muted graph-count",children:[I.nodes.length," nodes · ",I.edges.length," edges",ve?` · ${ve} hidden`:""]})]}),d.jsx("div",{className:"graph-stage",children:V==="3d"?d.jsxs("div",{className:"graph-3d","data-testid":"graph-3d",children:[d.jsx("p",{className:"graph-3d-hint",children:"Architecture layers are stacked in depth (Django → stitch → React). Drag to orbit, scroll to zoom, click a node to inspect it."}),d.jsx(L.Suspense,{fallback:d.jsx("p",{className:"muted graph-3d-hint",children:"Loading 3D layers…"}),children:d.jsx(yN,{nodes:I.nodes,edges:I.edges,selectedId:b,neighborIds:U?I.neighborIds:mN,onSelect:re=>{E(re),re||q(!1)}})}),se]}):d.jsxs(pm,{children:[d.jsxs(sk,{nodes:oe,edges:fe,nodeTypes:wN,edgeTypes:kN,fitView:!1,minZoom:.25,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,deleteKeyCode:null,onNodeClick:pe,onPaneClick:Z,proOptions:{hideAttribution:!1},"data-testid":"impact-graph",children:[d.jsx(NN,{topologyKey:z}),d.jsx(dk,{}),d.jsx(Rk,{pannable:!0,zoomable:!0,ariaLabel:"Impact graph overview",nodeColor:"var(--muted)",nodeStrokeColor:"transparent",nodeStrokeWidth:0,maskColor:"rgba(0, 0, 0, 0.45)",maskStrokeColor:"var(--accent)",maskStrokeWidth:1.4,bgColor:"var(--graph-bg)",style:{width:184,height:128}}),d.jsx(vk,{})]}),se]})})]})}function Sm(){const t=localStorage.getItem("loadpath.editor")||"auto";return t==="cursor"||t==="vscode"||t==="system"?t:"auto"}function EN(t){localStorage.setItem("loadpath.editor",t)}async function CN(t,r,o,s=Sm()){try{const a=await Re.openEditor(t,r,o??void 0,s);if(a.ok)return{ok:!0,message:`Opened ${r} in ${a.opened_with||"editor"}`};const u=a.urls||{},c=s==="vscode"?u.vscode:s==="cursor"?u.cursor:u.cursor||u.vscode;return c?(window.open(c,"_blank","noopener,noreferrer"),{ok:!0,message:`Opening ${r} via editor URL`}):{ok:!1,message:a.error||"Could not open editor"}}catch(a){return{ok:!1,message:a instanceof Error?a.message:String(a)}}}const Np=[{value:"HEAD",label:"HEAD",group:"preset"},{value:"HEAD~1",label:"HEAD~1",group:"preset"}],MN=["preset","branch","tag","commit"];function PN(t){var a;if(!(t!=null&&t.git))return[...Np];const r=((a=t.presets)!=null&&a.length?t.presets:Np.map(u=>u.value)).map(u=>({value:u,label:u,group:"preset"})),o=new Set(r.map(u=>u.value)),s=[...r];for(const u of t.branches||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.current?`${u.name} (current)`:u.name,detail:u.subject,group:"branch"}));for(const u of t.tags||[])o.has(u.name)||(o.add(u.name),s.push({value:u.name,label:u.name,detail:u.subject,group:"tag"}));for(const u of t.commits||[])o.has(u.sha)||(o.add(u.sha),s.push({value:u.sha,label:u.short,detail:u.subject,group:"commit"}));return s}function IN(t,r){const o=r.trim().toLowerCase();return o?t.filter(s=>s.value.toLowerCase().includes(o)||s.label.toLowerCase().includes(o)||(s.detail||"").toLowerCase().includes(o)):t}function RN(t){return MN.map(r=>({group:r,items:t.filter(o=>o.group===r)})).filter(r=>r.items.length>0)}function TN(t){return t==="preset"?"Common":t==="branch"?"Branches":t==="tag"?"Tags":"Recent commits"}function jp({value:t,onChange:r,placeholder:o,testId:s,menuTestId:a,refs:u,onNeedRefs:c}){const h=L.useId(),p=L.useRef(null),[y,x]=L.useState(!1),[v,m]=L.useState(null),[_,k]=L.useState(0),j=L.useMemo(()=>{const N=PN(u);return v===null?N:IN(N,v)},[u,v]),b=L.useMemo(()=>RN(j),[j]);L.useEffect(()=>{y&&c()},[y,c]),L.useEffect(()=>{k(0)},[v,y]);const E=()=>{x(!1),m(null)},R=N=>{r(N.value),E()},w=N=>{if(N.key==="ArrowDown"){if(N.preventDefault(),!y){x(!0);return}k(A=>Math.min(A+1,Math.max(j.length-1,0)))}else if(N.key==="ArrowUp"){if(N.preventDefault(),!y)return;k(A=>Math.max(A-1,0))}else if(N.key==="Enter"&&y){N.preventDefault();const A=j[_];A&&R(A)}else N.key==="Escape"&&y&&(N.preventDefault(),E())};return d.jsxs("div",{className:"combo",ref:p,onBlur:N=>{N.currentTarget.contains(N.relatedTarget)||E()},children:[d.jsxs("div",{className:"combo-row",children:[d.jsx("input",{"data-testid":s,value:t,placeholder:o,spellCheck:!1,role:"combobox","aria-expanded":y,"aria-controls":h,"aria-autocomplete":"list",onChange:N=>{r(N.target.value),y&&m(N.target.value)},onKeyDown:w}),d.jsx("button",{type:"button",className:"icon-btn combo-toggle","data-testid":`${s}-toggle`,"aria-label":"Show recent refs","aria-expanded":y,onMouseDown:N=>N.preventDefault(),onClick:()=>y?E():x(!0),children:d.jsx(k0,{})})]}),y?d.jsx("div",{className:"combo-menu",id:h,role:"listbox","data-testid":a,children:b.length===0?d.jsx("div",{className:"combo-empty muted",children:"No matching refs — the typed value is kept"}):b.map(N=>d.jsxs("div",{className:"combo-group",children:[d.jsx("div",{className:"combo-heading",children:TN(N.group)}),N.items.map(A=>{const $=j.indexOf(A);return d.jsxs("button",{type:"button",role:"option","aria-selected":$===_,className:$===_?"combo-option active":"combo-option","data-testid":`ref-option-${A.group}`,onMouseDown:F=>F.preventDefault(),onMouseEnter:()=>k($),onClick:()=>R(A),children:[d.jsx("span",{className:"combo-label",children:A.label}),A.detail?d.jsx("span",{className:"combo-detail",children:A.detail}):null]},`${A.group}:${A.value}`)})]},N.group))}):null]})}function LN({initialPath:t,onSelect:r,onClose:o}){const[s,a]=L.useState(null),[u,c]=L.useState(t),[h,p]=L.useState(null),[y,x]=L.useState(""),[v,m]=L.useState(!1),_=L.useRef(null),k=L.useRef(0),j=async w=>{const N=k.current+1;k.current=N,m(!0);try{const A=await Re.browse(w);if(k.current!==N)return;a(A),c(A.path),p(A.is_git?A.path:null),x("")}catch(A){if(k.current!==N)return;x(A instanceof Error?A.message:String(A))}finally{k.current===N&&m(!1)}};L.useEffect(()=>{var w,N;j(t),(w=_.current)==null||w.focus(),(N=_.current)==null||N.select()},[t]);const b=h||(s==null?void 0:s.path)||u,E=h&&h!==(s==null?void 0:s.path)?h.split(/[\\/]/).filter(Boolean).pop():s!=null&&s.is_git?"this repository":"this folder",R=w=>{w.key==="Escape"&&(w.preventDefault(),o())};return d.jsx("div",{className:"modal-backdrop","data-testid":"repo-explorer","data-overlay":"true",onClick:o,onKeyDown:R,children:d.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"explorer-title",onClick:w=>w.stopPropagation(),children:[d.jsxs("div",{className:"modal-head",children:[d.jsxs("div",{children:[d.jsx("h2",{id:"explorer-title",children:"Select repository"}),d.jsx("p",{className:"muted",children:"Browse to a git root, or paste the full path."})]}),d.jsx("button",{type:"button",className:"btn ghost","data-testid":"explorer-cancel",onClick:o,children:"Cancel"})]}),d.jsxs("form",{className:"explorer-path",onSubmit:w=>{w.preventDefault(),j(u)},children:[d.jsx("input",{ref:_,"data-testid":"explorer-path",value:u,onChange:w=>c(w.target.value),spellCheck:!1,"aria-label":"Directory path"}),d.jsx("button",{type:"button",className:"btn",disabled:!(s!=null&&s.parent),onClick:()=>(s==null?void 0:s.parent)&&void j(s.parent),children:"Up"}),d.jsx("button",{type:"button",className:"btn",onClick:()=>s&&void j(s.home),children:"Home"}),d.jsx("button",{type:"submit",className:"btn",children:"Go"})]}),y?d.jsx("div",{className:"error",role:"alert",children:y}):null,d.jsx("div",{className:"explorer-list",role:"listbox","aria-label":"Folders","aria-busy":v,children:s!=null&&s.entries.length?s.entries.map(w=>{const N=h===w.path;return d.jsxs("button",{type:"button",role:"option","aria-selected":N,className:N?"explorer-row active":"explorer-row","data-testid":"explorer-entry","data-path":w.path,onClick:()=>p(w.path),onDoubleClick:()=>void j(w.path),children:[d.jsx(Mp,{}),d.jsx("span",{className:"explorer-name",children:w.name}),w.is_git?d.jsx("span",{className:"chip git-badge",children:"git"}):null]},w.path)}):d.jsx("div",{className:"muted explorer-empty",children:v?"Loading…":"No folders here"})}),d.jsxs("div",{className:"modal-foot",children:[d.jsx("span",{className:"muted explorer-current",title:b,children:b}),d.jsxs("button",{type:"button",className:"btn primary","data-testid":"explorer-use",disabled:!b,onClick:()=>b&&r(b),children:["Use ",E]})]})]})})}const AN={scan:{start:0,end:20},extract:{start:20,end:88},boot:{start:88,end:94},stitch:{start:94,end:99},skipped:{start:100,end:100},done:{start:100,end:100}},$N=new Set(["scan","extract","boot","stitch"]);function zN(t){const r=t.phase||"";if(!r||r==="idle")return null;const o=AN[r];if(!o)return null;if(o.start===o.end)return o.end;const s=t.total||0;if(s<=0)return o.start;const a=Math.min(1,Math.max(0,(t.done||0)/s));return Math.round(o.start+(o.end-o.start)*a)}function DN(t){return!t.phase||t.phase==="idle"?null:typeof t.percent=="number"&&Number.isFinite(t.percent)?Math.max(0,Math.min(100,Math.round(t.percent))):zN(t)}const Gl=[{id:"obsidian",label:"Obsidian",group:"dark"},{id:"nord",label:"Nord",group:"dark"},{id:"solarized-dark",label:"Solarized Dark",group:"dark"},{id:"forest",label:"Forest",group:"dark"},{id:"rose",label:"Rose Pine",group:"dark"},{id:"amber",label:"Midnight Amber",group:"dark"},{id:"volcano",label:"Volcano",group:"dark"},{id:"lavender",label:"Lavender",group:"dark"},{id:"neon-noir",label:"Neon Noir",group:"dark"},{id:"synthwave",label:"Synthwave",group:"dark"},{id:"phosphor",label:"Phosphor",group:"dark"},{id:"aurora",label:"Aurora",group:"dark"},{id:"biolume",label:"Biolume",group:"dark"},{id:"carbon",label:"Carbon",group:"dark"},{id:"paper",label:"Paper",group:"light"},{id:"solarized-light",label:"Solarized Light",group:"light"},{id:"seafoam",label:"Seafoam",group:"light"},{id:"high-contrast",label:"High Contrast",group:"light"},{id:"sakura",label:"Sakura",group:"light"},{id:"citrus",label:"Citrus",group:"light"},{id:"peach",label:"Peach Fuzz",group:"light"},{id:"candy",label:"Cotton Candy",group:"light"},{id:"sky",label:"Clear Sky",group:"light"},{id:"coral",label:"Coral Reef",group:"light"}],ON="obsidian",km="loadpath.theme";function FN(t){return Gl.some(r=>r.id===t)}function Nm(){try{const t=localStorage.getItem(km)||"";if(FN(t))return t}catch{}return ON}function HN(t){var r;return((r=Gl.find(o=>o.id===t))==null?void 0:r.group)==="light"?"light":"dark"}function jm(t){document.documentElement.dataset.theme=t,document.documentElement.style.colorScheme=HN(t);try{localStorage.setItem(km,t)}catch{}}const ec=[{id:"review",label:"Review",testId:"tab-review",shortcut:"1",icon:v0},{id:"architecture",label:"Architecture",testId:"tab-architecture",shortcut:"2",icon:x0},{id:"graph",label:"Impact graph",testId:"tab-graph",shortcut:"3",icon:w0},{id:"prs",label:"Pull requests",testId:"tab-prs",shortcut:"4",icon:_0},{id:"settings",label:"Settings",testId:"tab-settings",shortcut:"5",icon:S0}];function tc(t,r,o){let s;try{s=new URL(t)}catch{return}if(s.protocol!=="https:"||s.username||s.password)return;const a=s.hostname.toLowerCase();a!==r&&!a.endsWith(`.${r}`)||s.pathname.startsWith(o)&&window.open(s.toString(),"_blank","noopener,noreferrer")}function BN(){var fo,Si,ho,po,go,ki,Yr,ln,an,un;const[t,r]=L.useState("review"),[o,s]=L.useState(localStorage.getItem("loadpath.repo")||""),[a,u]=L.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[c,h]=L.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,y]=L.useState(null),[x,v]=L.useState(null),[m,_]=L.useState(null),[k,j]=L.useState([]),[b,E]=L.useState("review"),[R,w]=L.useState(""),[N,A]=L.useState(""),[$,F]=L.useState(null),[G,q]=L.useState(!1),[te,ee]=L.useState(!1),[ne,K]=L.useState(""),[C,V]=L.useState({}),[W,U]=L.useState([]),[M,D]=L.useState([]),[H,I]=L.useState(localStorage.getItem("loadpath.scmRepo")||""),[z,ie]=L.useState(localStorage.getItem("loadpath.provider")||"github"),[oe,fe]=L.useState(localStorage.getItem("loadpath.prNumber")||""),[he,pe]=L.useState(localStorage.getItem("loadpath.dirty")==="1"),[Z,se]=L.useState(0),[me,ke]=L.useState(""),[ve,re]=L.useState(Nm),[Ne,Ie]=L.useState(!1),[Le,$e]=L.useState(!1),[lt,at]=L.useState(!1),[ut,Ge]=L.useState(null),[wt,Gt]=L.useState(null),[gt,mt]=L.useState(localStorage.getItem("loadpath.testOverlay")==="1"),[Ct,ct]=L.useState(null),[et,Dn]=L.useState(localStorage.getItem("loadpath.watch")==="1"),[Mt,kn]=L.useState([]),[oo,On]=L.useState(null),[gi,lr]=L.useState(null),[zr,Fn]=L.useState(null),[Dr,ar]=L.useState(()=>{try{return!!(localStorage.getItem("loadpath.lastReviewId")&&(localStorage.getItem("loadpath.repo")||"").trim())}catch{return!1}}),[ur,Ft]=L.useState(null),[dt,Hn]=L.useState(null),[Bn,Nn]=L.useState(!1),[Vn,jn]=L.useState(!1),it=L.useRef(o);it.current=o;const cr=L.useRef(he);cr.current=he;const bn=L.useRef(!1);bn.current=Le;const Pt=L.useRef(""),nn=L.useRef(""),mi=P=>{re(P),jm(P)},Ze=L.useRef(""),He=P=>{Ze.current=P,A(P)},En=P=>{let Y=0,ce=!1;F(0);const Ee=()=>{Re.indexProgress(P).then(Pe=>{if(!Ze.current)return;if(Pe.phase&&Pe.phase!=="idle"&&Pe.message&&He(Pe.message),$N.has(Pe.phase))ce=!0;else if(!ce)return;const gr=DN(Pe);gr!=null&&(Pe.phase==="scan"&&!Pe.done?Y=gr:Y=Math.max(Y,gr),F(Y))}).catch(()=>{})};Ee();const Me=window.setInterval(Ee,250);return()=>{window.clearInterval(Me),F(null)}};L.useEffect(()=>{Re.settings().then(V).catch(()=>{}).finally(()=>Ie(!0)),Re.repos().then(P=>j(P.repos)).catch(()=>{})},[]);const Wn=()=>o.trim()?!0:(w("Point at a local repository path first."),!1);L.useEffect(()=>{if(t!=="architecture"||!o.trim())return;const P=o;let Y=!1;return nn.current!==P&&Yn(P),Re.config(P).then(ce=>{!Y&&it.current===P&&lr(ce)}).catch(()=>{}),Re.architectureHealth(P).then(ce=>{!Y&&it.current===P&&Fn(ce)}).catch(()=>{}),()=>{Y=!0}},[t,o]);const rn=P=>{it.current=P,s(P),localStorage.setItem("loadpath.repo",P),P.trim()!==Pt.current&&(Pt.current="",Ft(null))},Or=L.useCallback(P=>{const Y=(P??it.current).trim();return!Y||Pt.current===Y?Promise.resolve():(Pt.current=Y,Re.gitRefs(Y).then(ce=>{it.current.trim()===Y&&Ft(ce)}).catch(()=>{Pt.current===Y&&(Pt.current="",Ft(null))}))},[]),on=(P,Y)=>{u(P),h(Y),localStorage.setItem("loadpath.base",P),localStorage.setItem("loadpath.head",Y)},It=(P,Y,ce)=>{ie(P),I(Y),localStorage.setItem("loadpath.provider",P),localStorage.setItem("loadpath.scmRepo",Y),ce!==void 0&&(fe(ce),localStorage.setItem("loadpath.prNumber",ce))},Xt=P=>{y(P),se(0),Ge(wt&&P.nodes.some(Y=>Y.id===wt)?wt:null),ct(null),On(null),P.what_if||(v(P),P.id&&localStorage.setItem("loadpath.lastReviewId",P.id))},Un=async P=>{try{const Y=await Re.reviews(P);kn(Y.reviews)}catch{kn([])}},yi=async P=>{try{Fn(await Re.architectureHealth(P))}catch{Fn(null)}},vi=P=>P==="github"?!!C.github_token_set:P==="gitlab"?!!C.gitlab_token_set:!!C.bitbucket_token_set,Rt=L.useCallback(async(P=z)=>{var Y;try{const ce=await Re.scmRepos(P);D(ce.repos),(Y=ce.user)!=null&&Y.login&&V(Ee=>({...Ee,...P==="github"?{github_user:ce.user.login}:P==="gitlab"?{gitlab_user:ce.user.login}:{bitbucket_user:ce.user.login}}))}catch{D([])}},[z]);L.useEffect(()=>{if(t!=="prs")return;let P=!1;return Rt(z).catch(()=>{P||D([])}),()=>{P=!0}},[t,z,Rt]),L.useEffect(()=>{if(!dt)return;let P=!1,Y=0;const ce=async()=>{try{const Ee=await Re.githubOAuthPoll(dt.flow_id);if(P)return;if(Ee.status==="complete"){Hn(null);const Me=await Re.settings();V(Me),K(Ee.user?`Signed in to GitHub as ${Ee.user}`:"Signed in to GitHub"),Rt("github");return}if(Ee.status==="pending"||Ee.status==="slow_down"){Y=window.setTimeout(ce,Math.max(Ee.interval||dt.interval,5)*1e3);return}Hn(null),w(Ee.status==="denied"?"GitHub sign-in was denied.":"GitHub sign-in expired. Try again.")}catch(Ee){if(P)return;Hn(null),w(Ee instanceof Error?Ee.message:String(Ee))}};return Y=window.setTimeout(ce,Math.max(dt.interval,5)*1e3),()=>{P=!0,window.clearTimeout(Y)}},[dt,Rt]),L.useEffect(()=>{if(!Bn)return;let P=!1,Y=0;const ce=Date.now(),Ee=async()=>{try{const Me=await Re.oauthStatus();if(P)return;if(Me.bitbucket.connected){Nn(!1);const Pe=await Re.settings();V(Pe),K(Me.bitbucket.user?`Signed in to Bitbucket as ${Me.bitbucket.user}`:"Signed in to Bitbucket"),Rt("bitbucket");return}if(Date.now()-ce>18e4){Nn(!1),w("Bitbucket sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(Ee,1500)}catch(Me){if(P)return;Nn(!1),w(Me instanceof Error?Me.message:String(Me))}};return Y=window.setTimeout(Ee,1500),()=>{P=!0,window.clearTimeout(Y)}},[Bn,Rt]),L.useEffect(()=>{if(!Vn)return;let P=!1,Y=0;const ce=Date.now(),Ee=async()=>{try{const Me=await Re.oauthStatus();if(P)return;if(Me.gitlab.connected){jn(!1);const Pe=await Re.settings();V(Pe),K(Me.gitlab.user?`Signed in to GitLab as ${Me.gitlab.user}`:"Signed in to GitLab"),Rt("gitlab");return}if(Date.now()-ce>18e4){jn(!1),w("GitLab sign-in timed out. Finish in the browser, or try again.");return}Y=window.setTimeout(Ee,1500)}catch(Me){if(P)return;jn(!1),w(Me instanceof Error?Me.message:String(Me))}};return Y=window.setTimeout(Ee,1500),()=>{P=!0,window.clearTimeout(Y)}},[Vn,Rt]);const Yn=async(P=o,Y=!1)=>{if(!P.trim())return null;nn.current=P,ee(!0);try{const ce=await Re.architecture(P,!1);it.current===P&&_(ce);const Ee=Re.architectureGraph(P).then(Me=>{it.current===P&&_(Pe=>Pe&&{...Pe,nodes:Me.nodes,edges:Me.edges,graph_pending:!1})});return Ee.catch(()=>{_(Me=>Me&&it.current===P?{...Me,graph_pending:!1}:Me)}).finally(()=>{nn.current===P&&ee(!1)}),Y&&await Ee,ce}catch(ce){throw it.current===P&&ee(!1),ce}},Fr=async P=>{const Y=P.trim();if(!(!Y||Y===it.current)){if(Ze.current){w("Wait for the current job to finish before switching workspace.");return}w(""),K(""),y(null),v(null),_(null),E("architecture"),rn(Y),q(!0),He(`Loading ${y0(Y)}…`);try{await Promise.all([Yn(Y),Or(Y)])}catch(ce){it.current===Y&&w(ce instanceof Error?ce.message:String(ce))}finally{it.current===Y&&(He(""),q(!1))}}},Gn=async()=>{if(Ze.current||!Wn())return;w(""),K(""),He("Tracing load path…"),rn(o),on(a,c);const P=En(o);try{const Y=await Re.review(o,a,c,!0,cr.current);Xt(Y),E("review"),r("review"),await Re.repos().then(ce=>j(ce.repos)).catch(()=>{}),await Promise.all([Yn(o),Un(o),yi(o)])}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{P(),He("")}},dr=async(P=!0)=>{if(Ze.current||!Wn())return;w(""),K(""),He(P?"Indexing…":"Full reindex…"),rn(o);const Y=En(o);try{await Re.index(o,P);const ce=await Yn(o);await Re.repos().then(Ee=>j(Ee.repos)).catch(()=>{}),ce!=null&&ce.indexed&&(E("architecture"),r("architecture"))}catch(ce){w(ce instanceof Error?ce.message:String(ce))}finally{Y(),He("")}},Ve=async()=>{if(!Ze.current&&Wn()){w(""),K(""),He("Detecting layout…"),rn(o);try{const P=await Re.init(o);K(P.message),await Re.repos().then(Y=>j(Y.repos)).catch(()=>{})}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},so=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),K("Copied markdown brief")}catch(P){w(P instanceof Error?P.message:String(P))}},Hr=async()=>{if(!Ze.current){if(p!=null&&p.what_if){w("What-if walks are hypothetical — they are not posted to a pull request. Restore the git-range walk first.");return}if(!(p!=null&&p.markdown)||!H||!oe){w("Pick a pull request first (Pull requests tab), then post the brief.");return}He("Posting Loadpath brief…");try{const P=await Re.postComment(z,H,Number(oe),p.markdown);K(P.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},xi=async()=>{if(!Ze.current){w(""),He("Fetching pull requests…");try{const P=await Re.prs(z,H,"open",o.trim()||void 0);U(P.pull_requests);const Y=M.find(ce=>ce.slug.toLowerCase()===H.trim().toLowerCase());Y!=null&&Y.local_path&&rn(Y.local_path)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},fr=async()=>{w("");try{const P=await Re.githubOAuthStart();Hn(P),tc(P.verification_uri_complete,"github.com","/login/device")}catch(P){w(P instanceof Error?P.message:String(P))}},lo=async()=>{w("");try{const P=await Re.bitbucketOAuthStart();Nn(!0),tc(P.authorize_url,"bitbucket.org","/site/oauth2/authorize")}catch(P){Nn(!1),w(P instanceof Error?P.message:String(P))}},wi=async()=>{w("");try{const P=await Re.gitlabOAuthStart();jn(!0),tc(P.authorize_url,new URL(P.authorize_url).hostname,"/oauth/authorize")}catch(P){jn(!1),w(P instanceof Error?P.message:String(P))}},Cn=async P=>{if(!(Ze.current||!o.trim())){w(""),He("Walking what-if path…");try{const Y=await Re.whatIf(o,P);K(`${Y.title} — ${Y.confidence.level} · ${(Y.sinks||[]).length} sinks`),Xt({...Y,markdown:Y.markdown||"",index:Y.index||(p==null?void 0:p.index),workspace:Y.workspace||(p==null?void 0:p.workspace)}),E("review"),r("review")}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},_t=()=>{if(x){Xt(x),E("review"),r("review"),K("Restored the last git-range walk");return}y(null),se(0),Ge(null),ct(null),On(null),E("architecture"),r("architecture"),K("")},ao=async P=>{var Me;if(Ze.current)return;It(P.provider,P.repo,String(P.number));const Y=M.find(Pe=>Pe.slug.toLowerCase()===P.repo.toLowerCase());Y!=null&&Y.local_path&&rn(Y.local_path),w(""),He(`Fetching ${P.provider} #${P.number}…`);const ce=(Y==null?void 0:Y.local_path)||o,Ee=ce?En(ce):()=>{};try{const Pe=await Re.reviewPr(P.provider,P.repo,P.number,(Y==null?void 0:Y.local_path)||o||void 0);Xt(Pe),Pe.pull_request&&typeof Pe.pull_request.repo_path=="string"&&rn(Pe.pull_request.repo_path),on(String(Pe.base||P.target_branch),String(Pe.head||P.source_branch)),E("review"),r("review"),typeof((Me=Pe.pull_request)==null?void 0:Me.repo_path)=="string"&&Un(Pe.pull_request.repo_path)}catch(Pe){on(P.base_sha||P.target_branch,P.head_sha||P.source_branch),r("review"),w(Pe instanceof Error?Pe.message:String(Pe))}finally{Ee(),He("")}},yt=async P=>{w("");try{V(await Re.oauthDisconnect(P)),z===P&&D([]),K(`Disconnected ${P}`)}catch(Y){w(Y instanceof Error?Y.message:String(Y))}},uo=async P=>{P.preventDefault();const Y=new FormData(P.currentTarget),ce={github_token:String(Y.get("github_token")||""),github_oauth_client_id:String(Y.get("github_oauth_client_id")||""),github_host:String(Y.get("github_host")||""),gitlab_token:String(Y.get("gitlab_token")||""),gitlab_host:String(Y.get("gitlab_host")||""),gitlab_oauth_client_id:String(Y.get("gitlab_oauth_client_id")||""),gitlab_oauth_client_secret:String(Y.get("gitlab_oauth_client_secret")||""),bitbucket_token:String(Y.get("bitbucket_token")||""),bitbucket_username:String(Y.get("bitbucket_username")||""),bitbucket_oauth_client_id:String(Y.get("bitbucket_oauth_client_id")||""),bitbucket_oauth_client_secret:String(Y.get("bitbucket_oauth_client_secret")||""),ai_provider:String(Y.get("ai_provider")||"none"),ai_api_key:String(Y.get("ai_api_key")||""),ai_model:String(Y.get("ai_model")||""),ai_base_url:String(Y.get("ai_base_url")||"")},Ee=k.length?{...ce,workspaces:k.map(Me=>({path:Me.path,name:Me.name}))}:ce;try{V(await Re.saveSettings(Ee)),K("Settings saved on this machine")}catch(Me){w(Me instanceof Error?Me.message:String(Me))}},co=async()=>{if(!(!p||Ze.current)){He("Residual analysis…");try{const P=await Re.residual(p);ke(P.note)}catch(P){w(P instanceof Error?P.message:String(P))}finally{He("")}}},Br=L.useRef(Gn);Br.current=Gn;const Mn=L.useRef(t);Mn.current=t;const Xn=L.useRef(!1);Xn.current=lt;const Pn=L.useRef(p);Pn.current=p;const qt=L.useRef(Z);qt.current=Z,L.useEffect(()=>{const P=localStorage.getItem("loadpath.lastReviewId"),Y=(localStorage.getItem("loadpath.repo")||"").trim();if(!P||!Y){ar(!1);return}let ce=!1;return Re.getReview(Y,P).then(Ee=>{ce||(Xt(Ee),on(Ee.base||localStorage.getItem("loadpath.base")||"HEAD~1",Ee.head||localStorage.getItem("loadpath.head")||"HEAD"),Un(Y),yi(Y))}).catch(()=>{}).finally(()=>{ce||ar(!1)}),()=>{ce=!0}},[]);const Vr=L.useRef("");L.useEffect(()=>{if(!et||!o.trim())return;let P=!1;const Y=async()=>{try{const Ee=await Re.workspaceStatus(o);if(P)return;Vr.current&&Ee.fingerprint!==Vr.current&&!Ze.current&&(pe(!0),cr.current=!0,localStorage.setItem("loadpath.dirty","1"),Br.current()),Vr.current=Ee.fingerprint}catch{}};Y();const ce=window.setInterval(Y,2e3);return()=>{P=!0,window.clearInterval(ce)}},[et,o]),L.useEffect(()=>{const P=Y=>{var Me;if((Y.metaKey||Y.ctrlKey)&&Y.key.toLowerCase()==="k"){Y.preventDefault(),at(Pe=>!Pe);return}if(Xn.current){Y.key==="Escape"&&(Y.preventDefault(),at(!1));return}if(bn.current){Y.key==="Escape"&&(Y.preventDefault(),$e(!1));return}const ce=Y.target;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.tagName==="SELECT"||ce.isContentEditable)){Y.key==="Escape"&&ce.blur();return}if(Y.key==="Escape"){w(""),K(""),Ge(wt),ct(null);return}if(Y.key==="j"||Y.key==="k"){const Pe=((Me=Pn.current)==null?void 0:Me.read_order)||[];if(!Pe.length)return;Y.preventDefault();const mo=qt.current,gr=Y.key==="j"?Math.min(Pe.length-1,mo+1):Math.max(0,mo-1);se(gr);return}const Ee=ec.find(Pe=>Pe.shortcut===Y.key);if(Ee&&!Y.metaKey&&!Y.ctrlKey&&!Y.altKey&&r(Ee.id),(Y.metaKey||Y.ctrlKey)&&Y.key==="Enter"){if(Mn.current==="settings"||Mn.current==="prs"||Ze.current)return;Y.preventDefault(),Br.current()}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[wt]);const Wr=async(P,Y)=>{if(!o.trim())return;const ce=await CN(o,P,Y);ce.ok?K(ce.message):w(ce.message)},hr=async()=>{if(p)try{const P=await Re.exportHtml(p),Y=URL.createObjectURL(P),ce=document.createElement("a");ce.href=Y,ce.download=`loadpath-${(p.id||"review").slice(0,8)}.html`,ce.click(),URL.revokeObjectURL(Y),K("Saved HTML brief")}catch(P){w(P instanceof Error?P.message:String(P))}},Ur=async P=>{if(o.trim()){He("Loading stored review…");try{const Y=await Re.getReview(o,P);Xt(Y),on(Y.base||a,Y.head||c),E("review"),r("review");const ce=Mt.findIndex(Me=>Me.id===P),Ee=ce>=0?Mt[ce+1]:void 0;if(Ee)try{On(await Re.reviewDiff(o,P,Ee.id))}catch{On(null)}}catch(Y){w(Y instanceof Error?Y.message:String(Y))}finally{He("")}}},sn={selectedId:ut,onSelect:Ge,nodeRoles:p==null?void 0:p.node_roles,testOverlay:gt,isolateSource:Ct,onIsolate:ct,repoPath:o,onOpenFile:Wr,pinnedId:wt,onPin:Gt},qn=[{id:"review",group:"Run",label:"Review this range",hint:"⌘/Ctrl+Enter",run:()=>void Gn()},...p!=null&&p.what_if?[{id:"exit-whatif",group:"Review",label:x?"Back to git-range walk":"Exit what-if walk",run:_t}]:[],{id:"index",group:"Run",label:"Index repository",run:()=>void dr(!0)},{id:"watch",group:"Run",label:et?"Stop watching working tree":"Watch working tree",run:()=>{const P=!et;Dn(P),localStorage.setItem("loadpath.watch",P?"1":"0")}},{id:"tests",group:"Graph",label:gt?"Hide test overlay":"Show test overlay",run:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")}},{id:"export",group:"Review",label:"Export HTML brief",run:()=>void hr()},...ec.map(P=>({id:`tab-${P.id}`,group:"Tabs",label:`Go to ${P.label}`,hint:P.shortcut,run:()=>r(P.id)})),...((p==null?void 0:p.nodes)||[]).slice(0,30).map(P=>({id:`node-${P.id}`,group:"Nodes",label:P.name,hint:io(P.type),run:()=>{Ge(P.id),r("graph")}})),...Mt.slice(0,12).map(P=>({id:`hist-${P.id}`,group:"History",label:P.title||P.id,hint:`${P.level||""} ${P.created_at||""}`.trim(),run:()=>void Ur(P.id)}))],_i=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.nodes)??[]:(p==null?void 0:p.nodes)??[],[b,m,p]),pr=L.useMemo(()=>b==="architecture"?(m==null?void 0:m.edges)??[]:(p==null?void 0:p.edges)??[],[b,m,p]),Fe=p!=null&&p.index?`${p.index.counts.nodes} nodes · ${p.index.counts.edges} edges`:m!=null&&m.indexed?`${m.counts.nodes} nodes · ${m.counts.edges} edges`:"Not indexed",vs=((p==null?void 0:p.findings)||[]).filter(P=>!P.waived);return d.jsxs("div",{className:"app",children:[d.jsx("a",{className:"skip",href:"#main",children:"Skip to content"}),d.jsxs("nav",{className:"rail","data-testid":"rail","aria-label":"Primary",children:[d.jsxs("div",{className:"brand",children:[d.jsx("div",{className:"brand-mark",children:"Loadpath"}),d.jsx("div",{className:"brand-sub",children:"Load-path review"})]}),ec.map(P=>{const Y=P.icon,ce=t===P.id;return d.jsxs("button",{type:"button","data-testid":P.testId,className:ce?"nav-item active":"nav-item","aria-current":ce?"page":void 0,"aria-label":P.label,onClick:()=>r(P.id),children:[d.jsx(Y,{}),d.jsx("span",{children:P.label})]},P.id)}),d.jsxs("div",{className:"theme-pick",children:[d.jsx("label",{htmlFor:"theme-select",children:"Theme"}),d.jsx("select",{id:"theme-select","data-testid":"theme-select",value:ve,onChange:P=>mi(P.target.value),children:["dark","light"].map(P=>d.jsx("optgroup",{label:P==="dark"?"Dark":"Light",children:Gl.filter(Y=>Y.group===P).map(Y=>d.jsx("option",{value:Y.id,children:Y.label},Y.id))},P))})]}),d.jsxs("div",{className:"rail-foot",children:[d.jsx("div",{className:"muted",role:"status",children:N||Fe}),d.jsxs("div",{className:"kbd-hint",children:[d.jsx("kbd",{children:"1"}),"–",d.jsx("kbd",{children:"5"})," tabs · ",d.jsx("kbd",{children:"⌘"}),d.jsx("kbd",{children:"K"})," palette · ",d.jsx("kbd",{children:"j"}),"/",d.jsx("kbd",{children:"k"})," read order"]})]})]}),d.jsxs("div",{className:"main",id:"main",children:[N?d.jsxs("div",{className:$!=null?"progress determinate":"progress",role:$!=null?"progressbar":"status","aria-label":N,"aria-live":"polite","aria-busy":"true","aria-valuemin":$!=null?0:void 0,"aria-valuemax":$!=null?100:void 0,"aria-valuenow":$??void 0,"data-testid":"progress",children:[d.jsx("i",{style:$!=null?{width:`${$}%`}:void 0}),d.jsx("span",{className:"sr-only",children:N})]}):null,d.jsxs("header",{className:"topbar","data-testid":"topbar",children:[k.length>0?d.jsxs("label",{className:"field workspace",children:[d.jsx("span",{children:"Workspace"}),d.jsxs("select",{"data-testid":"workspace-select",value:k.some(P=>P.path===o)?o:"",disabled:!!N,"aria-busy":G,onChange:P=>{P.target.value&&Fr(P.target.value)},children:[d.jsx("option",{value:"",children:"Indexed repos…"}),k.map(P=>d.jsxs("option",{value:P.path,children:[P.name,P.indexed?` (${P.counts.nodes})`:""]},P.path))]})]}):null,d.jsxs("label",{className:"field path",children:[d.jsx("span",{children:"Repository"}),d.jsxs("div",{className:"path-row",children:[d.jsx("input",{"data-testid":"repo-path",placeholder:"Local monorepo path",value:o,onChange:P=>{const Y=P.target.value;s(Y),Y.trim()!==Pt.current&&(Pt.current="",Ft(null))},spellCheck:!1}),d.jsx("button",{type:"button",className:"icon-btn","data-testid":"btn-browse-repo","aria-label":"Browse for a local repository",onClick:()=>$e(!0),children:d.jsx(Mp,{})})]})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Base"}),d.jsx(jp,{testId:"base-ref",menuTestId:"base-ref-menu",value:a,onChange:P=>on(P,c),placeholder:"base",refs:ur,onNeedRefs:Or})]}),d.jsxs("label",{className:"field ref",children:[d.jsx("span",{children:"Head"}),d.jsx(jp,{testId:"head-ref",menuTestId:"head-ref-menu",value:c,onChange:P=>on(a,P),placeholder:"head",refs:ur,onNeedRefs:Or})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Working tree"}),d.jsx("button",{type:"button",className:he?"chip-btn active":"chip-btn","data-testid":"btn-dirty","aria-pressed":he,onClick:()=>{const P=!he;pe(P),localStorage.setItem("loadpath.dirty",P?"1":"0")},children:he?"Include uncommitted":"Committed range"})]}),d.jsxs("label",{className:"field dirty",children:[d.jsx("span",{children:"Watch"}),d.jsx("button",{type:"button",className:et?"chip-btn active":"chip-btn","data-testid":"btn-watch","aria-pressed":et,onClick:()=>{const P=!et;Dn(P),localStorage.setItem("loadpath.watch",P?"1":"0")},children:et?"Watching":"Paused"})]}),p?d.jsxs("div",{className:`merge-box compact ${p.confidence.level}`,"data-testid":"merge-box",children:[d.jsx("div",{className:`level ${p.confidence.level}`,children:p.confidence.level.toUpperCase()}),d.jsxs("div",{className:"muted",children:[p.what_if?"what-if · ":"",p.confidence.covered_sinks,"/",p.confidence.sinks," sinks"]})]}):null,d.jsxs("div",{className:"topbar-actions",children:[d.jsx("button",{type:"button","data-testid":"btn-init",disabled:!!N,onClick:Ve,children:"Draft config"}),d.jsx("button",{type:"button","data-testid":"btn-index",disabled:!!N,onClick:()=>dr(!0),children:"Index"}),d.jsx("button",{type:"button","data-testid":"btn-review",className:"btn primary",disabled:!!N,onClick:Gn,children:"Review"})]})]}),d.jsxs("div",{className:"alerts",children:[R?d.jsxs("div",{className:"error","data-testid":"error",role:"alert",children:[d.jsx("span",{children:R}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>w(""),"aria-label":"Dismiss error",children:"×"})]}):null,ne?d.jsxs("div",{className:"banner","data-testid":"status-note",children:[d.jsx("span",{children:ne}),d.jsx("button",{type:"button",className:"dismiss",onClick:()=>K(""),"aria-label":"Dismiss",children:"×"})]}):null,((fo=p==null?void 0:p.index)!=null&&fo.stale||m!=null&&m.stale)&&(t==="review"||t==="architecture")?d.jsx("div",{className:"banner stale","data-testid":"index-stale",children:"Index is stale — files changed since the last extract. Index again before trusting this walk."}):null,((Si=p==null?void 0:p.index)==null?void 0:Si.django_boot)==="failed"||(m==null?void 0:m.django_boot)==="failed"?d.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((ho=p==null?void 0:p.index)==null?void 0:ho.django_boot_detail)||(m==null?void 0:m.django_boot_detail)||"django.setup() failed"}):null,(po=p==null?void 0:p.workspace)!=null&&po.dirty_overlaps_review&&t==="review"?d.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,p!=null&&p.what_if?d.jsxs("div",{className:"banner whatif","data-testid":"whatif-banner",children:[d.jsxs("span",{children:["Hypothetical walk from"," ",d.jsx("strong",{children:((go=p.node)==null?void 0:go.name)||"this node"}),". Loadpath ignored Base/Head and asked which sinks would feel this node change — not a filter of the current map."]}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-exit-whatif",onClick:_t,children:x?"Back to git range":"Back to architecture"})]}):null,G?d.jsx("div",{className:"banner","data-testid":"workspace-loading",children:N||"Loading workspace…"}):null]}),d.jsxs("div",{className:"stage","aria-busy":G||te,children:[t==="review"&&d.jsxs("div",{className:"content","data-testid":"review-layout",children:[d.jsx("aside",{className:"brief","data-testid":"brief",children:p?d.jsx(VN,{review:p,findings:vs,aiNote:me,busy:!!N,tourIndex:Z,onTour:se,onAskAi:co,onCopy:so,onPost:Hr,onSelect:Ge,onOpenFile:Wr,onExport:hr,history:Mt,diff:oo,onReopen:Ur,onWaiver:(P,Y)=>{o.trim()&&Re.addWaiver(o,P,Y||void 0,"from review").then(ce=>{lr(ce),K(`Waived ${P} in loadpath.yml`)})}}):Dr?d.jsxs("div",{className:"empty","data-testid":"review-restoring",children:[d.jsx("h2",{children:"Restoring last review"}),d.jsx("p",{children:"Loading the walk this machine stored last time Loadpath was open."})]}):d.jsxs("div",{className:"empty","data-testid":"review-empty",children:[d.jsx("h2",{children:"Trace the force of this diff"}),d.jsx("p",{children:"The graph is the architecture. The brief is where this change travels — not a hunk list."}),d.jsxs("ol",{children:[d.jsx("li",{children:"Point at a Django + React monorepo, or pick an indexed workspace."}),d.jsxs("li",{children:["Index it. Missing ",d.jsx("code",{children:"loadpath.yml"})," is drafted from ",d.jsx("code",{children:"manage.py"})," and"," ",d.jsx("code",{children:"src/features"}),"."]}),d.jsx("li",{children:"Review a git range, or open a pull request so base/head become a three-dot merge-base."})]})]})}),d.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?d.jsx(Ju,{nodes:p.nodes,edges:p.edges,onWhatIf:Cn,focusPath:(ki=p.read_order[Z])==null?void 0:ki.path,...sn}):null})]}),t==="architecture"&&d.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[d.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:m!=null&&m.indexed?d.jsx(WN,{architecture:m,busy:!!N,onReindex:()=>dr(!1),onReview:Gn,onSelect:Ge,config:gi,health:zr,onSaveConfig:P=>{Re.saveConfig(o,P).then(Y=>{lr(Y),K("Wrote loadpath.yml")})},onWaiver:(P,Y,ce)=>{Re.addWaiver(o,P,Y,ce).then(Ee=>{lr(Ee),K(`Waived ${P}`)})}}):G?d.jsx("p",{className:"muted","data-testid":"architecture-loading",children:"Loading the index summary…"}):d.jsx("p",{className:"muted","data-testid":"architecture-empty",children:"Index this repo to build the architecture graph. Review then walks that same graph for a git range — it does not start from a hunk list."})}),d.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:(te||m!=null&&m.graph_pending)&&!((m==null?void 0:m.nodes)||[]).length?d.jsxs("div",{className:"empty graph-loading","data-testid":"graph-loading",children:[d.jsx("h2",{children:"Drawing the architecture map…"}),d.jsx("p",{children:(Yr=m==null?void 0:m.counts)!=null&&Yr.nodes?`${m.counts.nodes} indexed nodes. The brief is ready while the graph loads.`:"Fetching the indexed graph."})]}):m!=null&&m.indexed?d.jsx(Ju,{nodes:m.nodes,edges:m.edges,onWhatIf:Cn,...sn,isolateSource:null,onIsolate:void 0}):null})]}),t==="graph"&&d.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%"},children:[d.jsxs("div",{className:"graph-modes",children:[d.jsxs("div",{className:"seg","aria-label":"Graph scope",children:[d.jsx("button",{type:"button","aria-pressed":b==="review","data-testid":"graph-mode-review",className:b==="review"?"active":"",onClick:()=>E("review"),children:"This review"}),d.jsx("button",{type:"button","aria-pressed":b==="architecture","data-testid":"graph-mode-architecture",className:b==="architecture"?"active":"",onClick:()=>E("architecture"),children:"Indexed architecture"})]}),d.jsxs("div",{className:"legend","aria-hidden":"true",children:[d.jsxs("span",{children:[d.jsx("i",{})," cheap"]}),d.jsxs("span",{children:[d.jsx("i",{className:"exp"})," expensive"]}),d.jsxs("span",{children:[d.jsx("i",{className:"crit"})," critical"]}),d.jsxs("span",{children:[d.jsx("i",{className:"dash"})," inferred"]}),d.jsxs("span",{children:[d.jsx("i",{className:"seed"})," changed"]}),d.jsxs("span",{children:[d.jsx("i",{className:"down"})," downstream"]})]}),d.jsx("button",{type:"button",className:gt?"chip-btn active":"chip-btn","data-testid":"graph-test-overlay","aria-pressed":gt,onClick:()=>{const P=!gt;mt(P),localStorage.setItem("loadpath.testOverlay",P?"1":"0")},children:"Tests"})]}),_i.length?d.jsx(Ju,{nodes:_i,edges:pr,onWhatIf:Cn,...sn,...b==="architecture"?{isolateSource:null,onIsolate:void 0,nodeRoles:void 0,testOverlay:!1}:{}}):te||m!=null&&m.graph_pending?d.jsx("p",{className:"empty","data-testid":"graph-loading",children:"Drawing the architecture map…"}):d.jsx("p",{className:"empty","data-testid":"graph-empty",children:"Index the repo or run a review first. Click a node to inspect it."})]}),t==="prs"&&d.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[d.jsxs("div",{className:"pr-toolbar",children:[d.jsxs("label",{className:"field provider",children:[d.jsx("span",{children:"Provider"}),d.jsxs("select",{"data-testid":"pr-provider",value:z,onChange:P=>It(P.target.value,H,oe),children:[d.jsx("option",{value:"github",children:"GitHub"}),d.jsx("option",{value:"gitlab",children:"GitLab"}),d.jsx("option",{value:"bitbucket",children:"Bitbucket"})]})]}),d.jsxs("label",{className:"field",children:[d.jsx("span",{children:"Repository"}),d.jsx("input",{"data-testid":"pr-repo",placeholder:M.length?"Search your repos":"owner/repo",value:H,onChange:P=>It(z,P.target.value,oe),list:"scm-repos",spellCheck:!1}),d.jsx("datalist",{id:"scm-repos",children:M.map(P=>d.jsxs("option",{value:P.slug,children:[P.private?"private":"public",P.local_path?" · local":""]},P.slug))})]}),d.jsx("button",{type:"button","data-testid":"btn-refresh-repos",className:"btn",disabled:!!N||!vi(z),onClick:()=>{Rt(z)},children:"My repos"}),d.jsx("button",{type:"button","data-testid":"btn-list-prs",className:"btn",disabled:!!N,onClick:xi,children:"List PRs"})]}),M.length>0?d.jsxs("p",{className:"muted scm-count","data-testid":"scm-repo-count",children:[M.length," ",z," repositor",M.length===1?"y":"ies",z==="github"&&C.github_user?` · @${String(C.github_user)}`:"",z==="gitlab"&&C.gitlab_user?` · @${String(C.gitlab_user)}`:"",z==="bitbucket"&&C.bitbucket_user?` · ${String(C.bitbucket_user)}`:""]}):null,W.length===0?d.jsxs("div",{className:"empty","data-testid":"pr-empty",children:[d.jsx("h2",{children:"No pull requests loaded"}),d.jsx("p",{children:"Sign in under Settings (or paste a token), load your repositories, then list open PRs. Reviewing a PR fills base and head from its SHAs."})]}):W.map(P=>{var Y;return d.jsxs("article",{className:"pr","data-testid":`pr-${P.number}`,children:[d.jsxs("h3",{children:["#",P.number," ",P.title]}),d.jsxs("div",{className:"pr-meta muted",children:[d.jsx("span",{className:`chip ${P.draft?"":"open"}`,children:P.draft?"draft":P.state}),d.jsx("span",{children:P.author}),d.jsxs("span",{children:[P.source_branch," → ",P.target_branch]}),P.loadpath?d.jsxs("span",{className:`chip ${P.loadpath.level||""}`,"data-testid":`pr-loadpath-${P.number}`,children:[((Y=P.loadpath.level)==null?void 0:Y.toUpperCase())||"REVIEWED",P.loadpath.contract_break&&P.loadpath.contract_break!=="none"?` · ${P.loadpath.contract_break}`:""]}):d.jsx("span",{className:"muted",children:"no Loadpath walk yet"})]}),d.jsxs("div",{className:"pr-actions",children:[d.jsxs("a",{href:P.url,target:"_blank",rel:"noreferrer",children:["Open on ",P.provider]}),d.jsx("button",{type:"button",className:"btn primary","data-testid":`pr-review-${P.number}`,onClick:()=>void ao(P),children:"Review this PR"})]})]},`${P.provider}-${P.number}`)})]}),t==="settings"&&Ne&&d.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:uo,children:[d.jsxs("div",{children:[d.jsx("h1",{children:"Settings"}),d.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. AI runs only on residual uncertainty the graph could not close."})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Appearance"}),d.jsx("p",{className:"muted",children:"Local to this browser. High contrast is a first-class theme, not an afterthought."}),d.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Gl.map(P=>d.jsxs("button",{type:"button","data-theme":P.id,className:ve===P.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${P.id}`,onClick:()=>mi(P.id),children:[d.jsx("div",{className:"swatch-bar","aria-hidden":"true"}),d.jsx("div",{className:"name",children:P.label}),d.jsx("div",{className:"group",children:P.group})]},P.id))})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Editor"}),d.jsx("p",{className:"muted",children:"Open files from the inspector and read-order in Cursor, VS Code, or the system handler."}),d.jsx("label",{htmlFor:"editor-pref",children:"Preferred editor"}),d.jsxs("select",{id:"editor-pref","data-testid":"editor-pref",defaultValue:Sm(),onChange:P=>EN(P.target.value),children:[d.jsx("option",{value:"auto",children:"Auto (Cursor, then VS Code)"}),d.jsx("option",{value:"cursor",children:"Cursor"}),d.jsx("option",{value:"vscode",children:"VS Code"}),d.jsx("option",{value:"system",children:"System default"})]})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Source control"}),d.jsx("p",{className:"muted",children:"Sign in with OAuth to list every repository the account can access. Tokens stay in ~/.loadpath/settings.json. A classic PAT still works if you prefer not to register an OAuth app."}),d.jsxs("div",{className:"scm-login","data-testid":"scm-github",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitHub"}),d.jsx("p",{className:"muted",children:C.github_token_set?C.github_user?`Signed in as @${String(C.github_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.github_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-github-disconnect",onClick:()=>void yt("github"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-github-login",disabled:!!dt||!C.github_oauth_ready,onClick:()=>void fr(),children:dt?"Waiting for GitHub…":"Sign in with GitHub"})})]}),dt?d.jsxs("p",{className:"oauth-code","data-testid":"github-user-code",children:["Enter ",d.jsx("code",{children:dt.user_code})," at GitHub if the browser did not fill it in."]}):null,C.github_oauth_ready?null:d.jsx("p",{className:"muted",children:"Sign-in needs a GitHub OAuth App with Device Flow enabled. Set LOADPATH_GITHUB_CLIENT_ID or paste the client ID below."}),d.jsx("label",{htmlFor:"github_oauth_client_id",children:"GitHub OAuth client ID"}),d.jsx("input",{id:"github_oauth_client_id",name:"github_oauth_client_id","data-testid":"github-oauth-client-id",placeholder:"Ov23…",defaultValue:String(C.github_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"github_token",children:"GitHub token (optional PAT)"}),d.jsx("input",{id:"github_token",name:"github_token",type:"password",placeholder:"ghp_…",autoComplete:"off"}),d.jsx("label",{htmlFor:"github_host",children:"GitHub host (Enterprise)"}),d.jsx("input",{id:"github_host",name:"github_host","data-testid":"github-host",placeholder:"github.com",defaultValue:String(C.github_host||""),autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-gitlab",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"GitLab"}),d.jsx("p",{className:"muted",children:C.gitlab_token_set?C.gitlab_user?`Signed in as @${String(C.gitlab_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.gitlab_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-gitlab-disconnect",onClick:()=>void yt("gitlab"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-gitlab-login",disabled:Vn||!C.gitlab_oauth_ready,onClick:()=>void wi(),children:Vn?"Waiting for GitLab…":"Sign in with GitLab"})})]}),d.jsx("label",{htmlFor:"gitlab_host",children:"GitLab host"}),d.jsx("input",{id:"gitlab_host",name:"gitlab_host","data-testid":"gitlab-host",placeholder:"gitlab.com",defaultValue:String(C.gitlab_host||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_id",children:"GitLab OAuth application ID"}),d.jsx("input",{id:"gitlab_oauth_client_id",name:"gitlab_oauth_client_id","data-testid":"gitlab-oauth-client-id",defaultValue:String(C.gitlab_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_oauth_client_secret",children:"GitLab OAuth secret"}),d.jsx("input",{id:"gitlab_oauth_client_secret",name:"gitlab_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"gitlab_token",children:"GitLab token (optional PAT)"}),d.jsx("input",{id:"gitlab_token",name:"gitlab_token",type:"password",placeholder:"glpat-…",autoComplete:"off"}),d.jsxs("div",{className:"scm-login","data-testid":"scm-bitbucket",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Bitbucket"}),d.jsx("p",{className:"muted",children:C.bitbucket_token_set?C.bitbucket_user?`Signed in as ${String(C.bitbucket_user)}`:"Token saved on this machine":"Not connected"})]}),d.jsx("div",{className:"btn-row",children:C.bitbucket_token_set?d.jsx("button",{type:"button",className:"btn","data-testid":"btn-bitbucket-disconnect",onClick:()=>void yt("bitbucket"),children:"Disconnect"}):d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-bitbucket-login",disabled:Bn||!C.bitbucket_oauth_ready,onClick:()=>void lo(),children:Bn?"Waiting for Bitbucket…":"Sign in with Bitbucket"})})]}),C.bitbucket_oauth_ready?null:d.jsxs("p",{className:"muted",children:["Sign-in needs a Bitbucket OAuth consumer (key + secret). Callback URL:"," ",d.jsx("code",{children:"/api/oauth/bitbucket/callback"})," on this app origin."]}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_id",children:"Bitbucket OAuth key"}),d.jsx("input",{id:"bitbucket_oauth_client_id",name:"bitbucket_oauth_client_id","data-testid":"bitbucket-oauth-client-id",defaultValue:String(C.bitbucket_oauth_client_id||""),autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_oauth_client_secret",children:"Bitbucket OAuth secret"}),d.jsx("input",{id:"bitbucket_oauth_client_secret",name:"bitbucket_oauth_client_secret",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_token",children:"Bitbucket token (optional app password)"}),d.jsx("input",{id:"bitbucket_token",name:"bitbucket_token",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"bitbucket_username",children:"Bitbucket username (app passwords)"}),d.jsx("input",{id:"bitbucket_username",name:"bitbucket_username",defaultValue:String(C.bitbucket_username||"")})]}),d.jsxs("section",{className:"settings-card",children:[d.jsx("h2",{children:"Residual AI"}),d.jsx("label",{htmlFor:"ai_provider",children:"Provider"}),d.jsxs("select",{id:"ai_provider",name:"ai_provider",defaultValue:String(((ln=C.ai)==null?void 0:ln.provider)||"none"),children:[d.jsx("option",{value:"none",children:"none (graph only)"}),d.jsx("option",{value:"anthropic",children:"Anthropic"}),d.jsx("option",{value:"openai",children:"OpenAI"}),d.jsx("option",{value:"grok",children:"Grok / xAI"}),d.jsx("option",{value:"deepseek",children:"DeepSeek"}),d.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),d.jsx("option",{value:"ollama",children:"Ollama local"})]}),d.jsx("label",{htmlFor:"ai_api_key",children:"API key"}),d.jsx("input",{id:"ai_api_key",name:"ai_api_key",type:"password",autoComplete:"off"}),d.jsx("label",{htmlFor:"ai_model",children:"Model"}),d.jsx("input",{id:"ai_model",name:"ai_model","data-testid":"ai-model",placeholder:"optional override",defaultValue:String(((an=C.ai)==null?void 0:an.model)||"")}),d.jsx("label",{htmlFor:"ai_base_url",children:"Base URL"}),d.jsx("input",{id:"ai_base_url",name:"ai_base_url","data-testid":"ai-base-url",placeholder:"optional, OpenAI-compatible",defaultValue:String(((un=C.ai)==null?void 0:un.base_url)||"")}),d.jsx("button",{className:"btn primary",type:"submit","data-testid":"btn-save-settings",children:"Save"})]})]})]})]}),d.jsx(p0,{open:lt,actions:qn,onClose:()=>at(!1)}),Le?d.jsx(LN,{initialPath:o,onClose:()=>$e(!1),onSelect:P=>{if(Ze.current){w("Wait for the current job to finish before switching workspace.");return}$e(!1),Fr(P)}}):null]})}function VN({review:t,findings:r,aiNote:o,busy:s,tourIndex:a,onTour:u,onAskAi:c,onCopy:h,onPost:p,onSelect:y,onOpenFile:x,onExport:v,history:m,diff:_,onReopen:k,onWaiver:j}){var E,R,w,N,A,$,F,G,q,te,ee,ne,K,C,V,W,U;const b=[...new Set(t.confidence.reasons||[])];return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:`merge-box ${t.confidence.level}`,children:[d.jsxs("div",{className:`level ${t.confidence.level}`,children:[t.confidence.level.toUpperCase()," — ",t.title]}),b.length?d.jsx("ul",{className:"reasons",children:b.map(M=>d.jsx("li",{children:M},M))}):null,t.what_if?d.jsx("span",{className:"chip whatif","data-testid":"whatif-chip",children:"what-if"}):null,t.low_risk?d.jsx("span",{className:"chip",children:"low-risk"}):null,t.change_kinds.map(M=>d.jsx("span",{className:"chip",children:Zo(M)},M)),(E=t.contract_break)!=null&&E.kind&&t.contract_break.kind!=="none"?d.jsxs("span",{className:`chip ${t.contract_break.kind==="breaking"?"blocker":""}`,"data-testid":"contract-kind",children:["contract ",t.contract_break.kind]}):null]}),d.jsxs("div",{className:"metrics",children:[d.jsxs("div",{className:"metric",children:[d.jsxs("div",{className:"n",children:[t.confidence.covered_sinks,"/",t.confidence.sinks]}),d.jsx("div",{className:"l",children:"Sinks tested"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:r.length}),d.jsx("div",{className:"l",children:"Findings"})]}),d.jsxs("div",{className:"metric",children:[d.jsx("div",{className:"n",children:t.residuals.length}),d.jsx("div",{className:"l",children:"Residuals"})]})]}),d.jsx("pre",{className:"headline",children:t.headline}),(t.checklist||[]).length?d.jsxs("details",{className:"section",open:!0,"data-testid":"merge-checklist",children:[d.jsxs("summary",{children:["Merge checklist"," ",d.jsx("span",{className:"count",children:(t.checklist||[]).filter(M=>M.status==="todo").length})]}),(t.checklist||[]).map(M=>d.jsxs("div",{className:`check-item ${M.status}`,children:[d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&y(M.node_id),children:[d.jsx("span",{className:`chip ${M.status}`,children:M.status}),M.title]}),M.detail?d.jsx("div",{className:"why",children:M.detail}):null,M.body?d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body||"")},children:"Copy test"}):null,M.kind==="finding"&&M.status==="todo"&&M.rule?d.jsx("button",{type:"button",className:"btn",onClick:()=>j(M.rule,M.node_id),children:"Waive in loadpath.yml"}):null]},M.id))]}):null,t.index?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Index ",d.jsx("span",{className:"count",children:t.index.counts.nodes})]}),d.jsxs("div",{className:"muted",children:["Walked ",t.index.counts.nodes," nodes / ",t.index.counts.edges," edges",t.index.reindex_skipped?" from an unchanged index":t.index.reindexed?" after an incremental refresh":" from the existing index",t.index.django_boot&&t.index.django_boot!=="off"?` · Django boot ${t.index.django_boot}`:"",(R=t.workspace)!=null&&R.three_dot?" · three-dot range":""]})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Read this ",d.jsx("span",{className:"count",children:t.read_order.length})]}),t.read_order.map((M,D)=>d.jsxs("div",{className:D===a?"read-item tour-current":"read-item",children:[d.jsxs("button",{type:"button",className:"linkish file",onClick:()=>u(D),children:[D+1,". ",M.path]}),d.jsx("div",{className:"why",children:M.why}),d.jsx("button",{type:"button",className:"btn",onClick:()=>x(M.path),children:"Open"})]},M.path)),t.read_order.length>0?d.jsxs("div",{className:"btn-row tour-row",children:[d.jsx("button",{type:"button",className:"btn","data-testid":"btn-tour-prev",disabled:a<=0,onClick:()=>u(Math.max(0,a-1)),children:"Previous"}),d.jsx("button",{type:"button",className:"btn primary","data-testid":"btn-tour-next",disabled:a>=t.read_order.length-1,onClick:()=>u(Math.min(t.read_order.length-1,a+1)),children:"Next in read order"}),d.jsxs("span",{className:"muted",children:[a+1,"/",t.read_order.length]})]}):null]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Clusters ",d.jsx("span",{className:"count",children:t.clusters.length})]}),t.clusters.map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:M.title})," — ",M.files.join(", ")]},M.id))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Architecture ",d.jsx("span",{className:"count",children:r.length})]}),r.length===0?d.jsx("div",{className:"muted",children:t.architecture_note}):r.map(M=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>M.node_id&&y(M.node_id),children:[d.jsx("span",{className:`chip ${M.severity}`,children:M.severity}),M.message]})},M.rule+M.message))]}),d.jsx(bm,{cards:t.deepening}),(N=(w=t.contract_break)==null?void 0:w.reasons)!=null&&N.length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Contract ",d.jsx("span",{className:"count",children:t.contract_break.kind})]}),t.contract_break.reasons.map(M=>d.jsx("div",{className:"muted",children:M},M)),($=(A=t.contract_break.sides)==null?void 0:A.rows)!=null&&$.length?d.jsxs("table",{className:"type-table","data-testid":"contract-sides",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Field"}),d.jsx("th",{children:"Serializer"}),d.jsx("th",{children:"Zod"}),d.jsx("th",{children:"GraphQL"})]})}),d.jsx("tbody",{children:t.contract_break.sides.rows.map(M=>d.jsxs("tr",{className:M.status,children:[d.jsx("td",{children:M.field}),d.jsx("td",{children:M.serializer?"yes":"—"}),d.jsx("td",{children:M.zod?"yes":"—"}),d.jsx("td",{children:M.graphql?"yes":"—"})]},M.field))})]}):null]}):null,(F=t.auth)!=null&&F.note?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Auth"}),d.jsx("div",{className:"muted",children:t.auth.note}),(t.auth.missing_permissions||[]).map(M=>d.jsxs("div",{className:"finding",children:[d.jsx("span",{className:"chip warning",children:"missing"}),M.name]},M.id))]}):null,(t.suggested_tests||[]).length?d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Suggested tests ",d.jsx("span",{className:"count",children:(G=t.suggested_tests)==null?void 0:G.length})]}),(t.suggested_tests||[]).map(M=>d.jsxs("div",{className:"residual",children:[d.jsx("strong",{children:M.title}),d.jsx("pre",{className:"headline",children:M.body}),d.jsx("button",{type:"button",className:"btn",onClick:()=>{navigator.clipboard.writeText(M.body)},children:"Copy sketch"})]},M.title))]}):null,(q=t.trend)!=null&&q.note?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Confidence trend"}),d.jsx("div",{className:"muted",children:t.trend.note}),(t.trend.points||[]).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[M.level," · ",nc(M.created_at),M.sinks!=null?` · ${M.sinks} sinks`:""]},M.id))]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Residual ",d.jsx("span",{className:"count",children:t.residuals.length})]}),d.jsx("p",{className:"muted",children:"AI is only used here, on what the graph could not close."}),t.residuals.map(M=>d.jsx("div",{className:"residual muted",children:M},M))]}),m.length?d.jsxs("details",{className:"section","data-testid":"review-history",children:[d.jsxs("summary",{children:["History ",d.jsx("span",{className:"count",children:m.length})]}),_?d.jsx("div",{className:"muted",children:_.note}):null,m.slice(0,12).map(M=>d.jsxs("button",{type:"button",className:M.id===t.id?"history-item current":"history-item",onClick:()=>k(M.id),children:[d.jsx("span",{className:`chip ${M.level||""}`,children:M.level||"walk"}),M.title||M.id.slice(0,8),d.jsx("span",{className:"muted",children:M.created_at?nc(M.created_at):""})]},M.id))]}):null,(ee=(te=t.evolution)==null?void 0:te.notes)!=null&&ee.length||(K=(ne=t.evolution)==null?void 0:ne.hotspots)!=null&&K.some(M=>M.commits)?d.jsxs("details",{className:"section",children:[d.jsx("summary",{children:"Churn & coupling"}),(((C=t.evolution)==null?void 0:C.notes)||[]).map(M=>d.jsx("div",{className:"muted",children:M},M)),(((V=t.evolution)==null?void 0:V.hotspots)||[]).filter(M=>M.commits).slice(0,6).map(M=>d.jsxs("div",{className:"muted",children:[d.jsx("span",{className:"file",children:M.path})," — ",M.commits," commits, bus factor ",M.bus_factor]},M.path))]}):null,d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:s,onClick:c,children:"Ask configured model"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-copy-markdown",onClick:h,children:"Copy markdown"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-export-html",onClick:v,children:"Save HTML"}),d.jsx("button",{type:"button",className:"btn","data-testid":"btn-post-comment",disabled:s||!!t.what_if,title:t.what_if?"Hypothetical walks are not posted to a pull request":void 0,onClick:p,children:"Post to PR"})]}),o?d.jsx("pre",{className:"headline",children:o}):null,d.jsx("div",{className:"kicker",children:"Reviewers"}),d.jsx("div",{className:"muted",children:t.suggested_reviewers.join(", ")||"—"}),(W=t.codeowners_reviewers)!=null&&W.length?d.jsxs("div",{className:"muted",children:["CODEOWNERS: ",t.codeowners_reviewers.join(", ")]}):null,(U=t.knowledge_owners)!=null&&U.length?d.jsxs("div",{className:"muted",children:["Knowledge: ",t.knowledge_owners.join(", ")]}):null]})}function WN({architecture:t,busy:r,onReindex:o,onReview:s,onSelect:a,config:u,health:c,onSaveConfig:h,onWaiver:p}){var x;const y=t.findings.filter(v=>!v.waived);return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"merge-box high",children:[d.jsxs("div",{className:"level high",children:["INDEXED — ",t.counts.nodes," nodes"]}),d.jsxs("div",{className:"muted",style:{marginTop:8},children:[t.indexed_at?`Last index ${nc(t.indexed_at)}`:"Indexed",t.incremental?" · incremental":" · full",t.stale?" · stale":"",t.django_boot&&t.django_boot!=="off"?` · Django boot ${t.django_boot}`:""]}),d.jsxs("span",{className:"chip",children:[t.counts.edges," edges"]}),t.has_config?d.jsx("span",{className:"chip",children:"loadpath.yml"}):null]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Bounded contexts"}),Object.values(t.contexts).map(v=>d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:v.name})," — ",(v.django_apps||[]).join(", ")||"no apps"," ·"," ",(v.owners||[]).join(", ")||"unowned"]},v.name))]}),d.jsxs("details",{className:"section",children:[d.jsxs("summary",{children:["Rules ",d.jsx("span",{className:"count",children:(t.rules||[]).length})]}),(t.rules||[]).map(v=>d.jsx("div",{className:"muted",children:v},v))]}),d.jsxs("details",{className:"section",open:!0,children:[d.jsxs("summary",{children:["Findings ",d.jsx("span",{className:"count",children:y.length})]}),y.length===0?d.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):y.map(v=>d.jsx("div",{className:"finding",children:d.jsxs("button",{type:"button",className:"linkish",onClick:()=>v.node_id&&a(v.node_id),children:[d.jsx("span",{className:`chip ${v.severity}`,children:v.severity}),v.message]})},v.rule+v.message))]}),d.jsx(bm,{cards:t.deepening}),(x=c==null?void 0:c.points)!=null&&x.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"architecture-health",children:[d.jsxs("summary",{children:["Health over time ",d.jsx("span",{className:"count",children:c.points.length})]}),d.jsx("div",{className:"sparkline","aria-hidden":"true",children:c.points.map(v=>d.jsx("i",{className:v.level||"",title:`${v.level} · ${v.findings} findings`,style:{height:`${8+Math.min(24,(v.findings||0)*4)}px`}},v.id||v.created_at))}),Object.entries(c.contexts).map(([v,m])=>{var _;return d.jsxs("div",{className:"muted",children:[d.jsx("strong",{children:v})," — last ",((_=m[m.length-1])==null?void 0:_.findings)??0," findings"]},v)})]}):null,u?d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"loadpath.yml"}),d.jsx(g0,{config:u,busy:r,onSave:h,onWaiver:p})]}):null,d.jsxs("details",{className:"section",open:!0,children:[d.jsx("summary",{children:"Types"}),d.jsx("table",{className:"type-table",children:d.jsx("tbody",{children:Object.entries(t.type_counts||{}).sort((v,m)=>m[1]-v[1]).slice(0,12).map(([v,m])=>d.jsxs("tr",{children:[d.jsx("td",{children:io(v)}),d.jsx("td",{children:m})]},v))})})]}),d.jsxs("div",{className:"btn-row",children:[d.jsx("button",{type:"button",className:"btn",disabled:r,onClick:o,"data-testid":"btn-full-reindex",children:"Full reindex"}),d.jsx("button",{type:"button",className:"btn primary",disabled:r,onClick:s,children:"Review against this index"})]})]})}function bm({cards:t}){const r=t||[];return r.length?d.jsxs("details",{className:"section",open:!0,"data-testid":"deepening-list",children:[d.jsxs("summary",{children:["Depth ",d.jsx("span",{className:"count",children:r.length})]}),d.jsx("p",{className:"muted",children:"Deepening opportunities: more behaviour behind a smaller interface, at a real seam."}),r.map(o=>d.jsxs("div",{className:"finding","data-testid":"deepening-card",children:[d.jsx("span",{className:`chip ${o.strength}`,children:m0(o.strength)}),o.top?d.jsx("span",{className:"chip",children:"top"}):null,d.jsx("strong",{children:o.title}),d.jsx("div",{className:"why",children:o.message}),o.deletion_test?d.jsxs("div",{className:"muted",children:["Deletion test: ",o.deletion_test]}):null,o.before&&o.after?d.jsxs("div",{className:"muted",children:[o.before," → ",o.after]}):null]},o.rule+o.title))]}):null}jm(Nm());d0.createRoot(document.getElementById("root")).render(d.jsx(L.StrictMode,{children:d.jsx(BN,{})}));export{Wk as L,GN as a,UN as c,d as j,YN as l,L as r,io as t}; diff --git a/src/loadpath/static/index.html b/src/loadpath/static/index.html index 877b685..39c4e6e 100644 --- a/src/loadpath/static/index.html +++ b/src/loadpath/static/index.html @@ -17,7 +17,7 @@ - + diff --git a/src/loadpath/workspace.py b/src/loadpath/workspace.py index 2c2d0ef..8720df3 100644 --- a/src/loadpath/workspace.py +++ b/src/loadpath/workspace.py @@ -210,11 +210,16 @@ def git_dirty_paths(repo_root: Path) -> list[str]: path = line[3:].strip() if " -> " in path: path = path.split(" -> ", 1)[1] - if path: + if path and not _is_loadpath_internal(path): paths.append(path) return paths +def _is_loadpath_internal(path: str) -> bool: + rel = path.replace("\\", "/").removeprefix("./").lstrip("/") + return rel == ".loadpath" or rel.startswith(".loadpath/") + + def workspace_status(repo_root: Path) -> dict[str, Any]: """Dirty paths plus a fingerprint so the UI can watch the working tree.""" repo_root = repo_root.resolve() diff --git a/tests/unit/test_experience.py b/tests/unit/test_experience.py index e4cf3b3..2c0e386 100644 --- a/tests/unit/test_experience.py +++ b/tests/unit/test_experience.py @@ -1,6 +1,6 @@ from __future__ import annotations -from loadpath.config import add_waiver, config_document, load_config, write_config +from loadpath.config import DEFAULT_RULES, add_waiver, config_document, load_config, write_config from loadpath.review.codeowners import owners_for_path, parse_codeowners, review_codeowners from loadpath.review.editor import editor_urls from loadpath.review.experience import ( @@ -33,6 +33,12 @@ def test_codeowners_last_match_wins(): assert owners_for_path("README.md", rules) == ["@docs"] +def test_codeowners_keeps_dot_directory_paths(): + rules = parse_codeowners("/.github/ @platform\n") + assert owners_for_path(".github/workflows/ci.yml", rules) == ["@platform"] + assert owners_for_path("./.github/CODEOWNERS", rules) == ["@platform"] + + def test_review_codeowners_from_github_file(tmp_path): repo = tmp_path / "repo" github = repo / ".github" @@ -212,6 +218,29 @@ def test_architecture_health_points(): assert health["contexts"]["billing"][-1]["findings"] == 1 +def test_architecture_health_keeps_newest_context_points(): + reviews = [] + for i in range(30, 0, -1): + reviews.append( + { + "id": str(i), + "created_at": f"2026-01-{i:02d}T00:00:00Z", + "payload": { + "confidence": {"level": "low"}, + "findings": [{"node_id": "n1", "waived": False}], + "edges": [], + "nodes": [{"id": "n1", "context": "billing"}], + }, + } + ) + health = architecture_health(reviews) + assert health["points"][0]["created_at"] == "2026-01-07T00:00:00Z" + assert health["points"][-1]["created_at"] == "2026-01-30T00:00:00Z" + series = health["contexts"]["billing"] + assert series[0]["created_at"] == "2026-01-07T00:00:00Z" + assert series[-1]["created_at"] == "2026-01-30T00:00:00Z" + + def test_file_marks_badge_prefers_seed(tmp_path): review = { "seed_ids": ["ser"], @@ -260,6 +289,25 @@ def test_write_config_and_waiver(tmp_path): assert "legacy" in (repo / "loadpath.yml").read_text() +def test_add_waiver_does_not_materialize_default_rules(tmp_path): + repo = tmp_path / "repo" + repo.mkdir() + (repo / "loadpath.yml").write_text("contexts:\n billing:\n django_apps: [billing]\n", encoding="utf-8") + add_waiver(repo, "leaked_seam", None, "legacy") + text = (repo / "loadpath.yml").read_text() + assert "legacy" in text + assert "django_root" not in text + assert sum(1 for rule in DEFAULT_RULES if rule in text) < len(DEFAULT_RULES) + + +def test_empty_rules_list_is_not_replaced_with_defaults(tmp_path): + repo = tmp_path / "repo" + repo.mkdir() + (repo / "loadpath.yml").write_text("contexts: {}\nrules: []\n", encoding="utf-8") + cfg = load_config(repo) + assert cfg.rules == [] + + def test_workspace_status_fingerprint_changes(tmp_path): repo = prepare_review_repo(tmp_path) clean = workspace_status(repo) @@ -273,6 +321,17 @@ def test_workspace_status_fingerprint_changes(tmp_path): assert later["fingerprint"] != dirty["fingerprint"] +def test_workspace_status_ignores_loadpath_db(tmp_path): + repo = prepare_review_repo(tmp_path) + before = workspace_status(repo) + db = repo / ".loadpath" / "graph.sqlite3" + db.parent.mkdir(parents=True) + db.write_bytes(b"sqlite") + after = workspace_status(repo) + assert after["fingerprint"] == before["fingerprint"] + assert not any(p.startswith(".loadpath") for p in after["dirty"]) + + def test_editor_urls_include_line(): from pathlib import Path diff --git a/tests/unit/test_scm_oauth.py b/tests/unit/test_scm_oauth.py index d73b6b1..123bd38 100644 --- a/tests/unit/test_scm_oauth.py +++ b/tests/unit/test_scm_oauth.py @@ -243,6 +243,21 @@ def test_scm_routes_reject_cross_origin(tmp_path, monkeypatch): assert client.get("/api/oauth/status", headers=headers).status_code == 403 assert client.post("/api/oauth/github/start", headers=headers).status_code == 403 assert client.post("/api/oauth/disconnect", json={"provider": "github"}, headers=headers).status_code == 403 + assert client.put( + "/api/config", + json={"repo_path": "/tmp", "rules": ["leaked_seam"]}, + headers=headers, + ).status_code == 403 + assert client.post( + "/api/config/waiver", + json={"repo_path": "/tmp", "rule": "leaked_seam"}, + headers=headers, + ).status_code == 403 + assert client.post( + "/api/open", + json={"repo_path": "/tmp", "path": "a.py"}, + headers=headers, + ).status_code == 403 def test_loopback_request_helper(): diff --git a/ui/src/App.tsx b/ui/src/App.tsx index 597c179..e510e8b 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -105,6 +105,8 @@ export function App() { const [gitlabWaiting, setGitlabWaiting] = useState(false); const repoRef = useRef(repo); repoRef.current = repo; + const dirtyRef = useRef(dirty); + dirtyRef.current = dirty; const explorerOpenRef = useRef(false); explorerOpenRef.current = explorerOpen; const gitRefsPath = useRef(""); @@ -433,9 +435,15 @@ export function App() { prev ? { ...prev, nodes: g.nodes, edges: g.edges, graph_pending: false } : prev, ); }); - graphP.catch(() => undefined).finally(() => { - if (repoRef.current === path) setGraphLoading(false); - }); + graphP + .catch(() => { + setArchitecture((prev) => + prev && repoRef.current === path ? { ...prev, graph_pending: false } : prev, + ); + }) + .finally(() => { + if (archHydratePath.current === path) setGraphLoading(false); + }); if (waitForGraph) await graphP; return report; } catch (e) { @@ -482,7 +490,7 @@ export function App() { persistRefs(base, head); const stopWatch = watchIndex(repo); try { - const r = await api.review(repo, base, head, true, dirty); + const r = await api.review(repo, base, head, true, dirtyRef.current); rememberReview(r); setGraphMode("review"); setTab("review"); @@ -797,6 +805,7 @@ export function App() { !busyRef.current ) { setDirty(true); + dirtyRef.current = true; localStorage.setItem("loadpath.dirty", "1"); void runReviewRef.current(); } @@ -900,7 +909,8 @@ export function App() { persistRefs(next.base || base, next.head || head); setGraphMode("review"); setTab("review"); - const previous = reviewHistory.find((item) => item.id !== id); + const idx = reviewHistory.findIndex((item) => item.id === id); + const previous = idx >= 0 ? reviewHistory[idx + 1] : undefined; if (previous) { try { setReviewDiff(await api.reviewDiff(repo, id, previous.id)); @@ -1055,7 +1065,8 @@ export function App() { {busy ? (
{graphNodes.length ? ( - + ) : graphLoading || architecture?.graph_pending ? (

Drawing the architecture map… diff --git a/ui/src/CommandPalette.tsx b/ui/src/CommandPalette.tsx index f98d23c..30936ae 100644 --- a/ui/src/CommandPalette.tsx +++ b/ui/src/CommandPalette.tsx @@ -46,7 +46,8 @@ export function CommandPalette({ }, [query]); if (!open) return null; - const current = hits[index]; + const shown = hits.slice(0, 40); + const current = shown[Math.min(index, Math.max(shown.length - 1, 0))]; const run = (action?: PaletteAction) => { if (!action) return; @@ -75,7 +76,7 @@ export function CommandPalette({ onClose(); } else if (e.key === "ArrowDown") { e.preventDefault(); - setIndex((i) => Math.min(hits.length - 1, i + 1)); + setIndex((i) => Math.min(Math.max(shown.length - 1, 0), i + 1)); } else if (e.key === "ArrowUp") { e.preventDefault(); setIndex((i) => Math.max(0, i - 1)); @@ -86,8 +87,8 @@ export function CommandPalette({ }} />

    - {hits.length === 0 ?
  • No matches
  • : null} - {hits.slice(0, 40).map((action, i) => ( + {shown.length === 0 ?
  • No matches
  • : null} + {shown.map((action, i) => (