diff --git a/README.md b/README.md index 7d800f1..c68f7a9 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,7 @@ AST is enough for review. If you need live `_meta` (db_table, resolved relations | `no_queryset_in_serializer` | Serializers must not run querysets | | `celery_tasks_must_be_idempotent_on_model_pk` | Celery and Dramatiq tasks take a model pk | | `queryset_nplusone` | Loops over querysets that touch related objects need `select_related` / `prefetch_related` | +| `queryset_missing_index` | `.filter()` / `.order_by()` on a field that has no `db_index` / `unique` | | `cascade_crosses_context` | `on_delete=CASCADE` must not blast into another bounded context | | `migration_blast_radius` | `RemoveField` / `DeleteModel` still referenced by the typed graph | diff --git a/fixtures/demo_monorepo/loadpath.yml b/fixtures/demo_monorepo/loadpath.yml index 0bc9fae..ed3cf25 100644 --- a/fixtures/demo_monorepo/loadpath.yml +++ b/fixtures/demo_monorepo/loadpath.yml @@ -26,6 +26,7 @@ rules: - no_queryset_in_serializer - celery_tasks_must_be_idempotent_on_model_pk - queryset_nplusone + - queryset_missing_index - cascade_crosses_context - migration_blast_radius django_root: backend diff --git a/loadpath.yml.example b/loadpath.yml.example index 0da7da2..0b1f0bd 100644 --- a/loadpath.yml.example +++ b/loadpath.yml.example @@ -25,6 +25,7 @@ rules: - no_queryset_in_serializer - celery_tasks_must_be_idempotent_on_model_pk - queryset_nplusone + - queryset_missing_index - cascade_crosses_context - migration_blast_radius django_root: backend diff --git a/src/loadpath/architecture/rules.py b/src/loadpath/architecture/rules.py index e692614..91e927e 100644 --- a/src/loadpath/architecture/rules.py +++ b/src/loadpath/architecture/rules.py @@ -16,6 +16,7 @@ "celery_tasks_must_be_idempotent_on_model_pk": "Celery and Dramatiq tasks must take a model pk/id, not a full object payload.", "async_tasks_must_be_idempotent_on_model_pk": "Celery and Dramatiq tasks must take a model pk/id, not a full object payload.", "queryset_nplusone": "Querysets iterated in a loop must select_related/prefetch_related related objects they touch.", + "queryset_missing_index": "filter/order_by on a field should match db_index/unique on that field.", "cascade_crosses_context": "on_delete=CASCADE must not blast into another bounded context.", "migration_blast_radius": "Destructive migrations must not drop fields/models still referenced on the load path.", } @@ -68,6 +69,8 @@ def evaluate(store: GraphStore, config: LoadpathConfig, changed_ids: set[str] | findings.extend(_task_idempotency(store, changed_ids)) if "queryset_nplusone" in enabled: findings.extend(_nplusone(store)) + if "queryset_missing_index" in enabled: + findings.extend(_missing_index(store)) if "cascade_crosses_context" in enabled: findings.extend(_cascade_crosses_context(store, config)) if "migration_blast_radius" in enabled: @@ -316,6 +319,51 @@ def _nplusone(store: GraphStore) -> list[Finding]: return out +def _missing_index(store: GraphStore) -> list[Finding]: + out: list[Finding] = [] + fields_by_name: dict[str, list[dict]] = {} + for field in store.nodes([NodeType.FIELD]): + fields_by_name.setdefault(field["name"], []).append(field) + indexed_types = {"ForeignKey", "OneToOneField", "ManyToManyField"} + for node in store.nodes(): + lookups = (node.get("extra") or {}).get("lookups") or [] + owner_app = (node.get("extra") or {}).get("app") + for hit in lookups: + for fname in hit.get("fields") or []: + matches = fields_by_name.get(fname) or [] + if owner_app: + scoped = [f for f in matches if (f.get("extra") or {}).get("app") == owner_app] + if scoped: + matches = scoped + if not matches: + continue + uncovered = [ + f + for f in matches + if not (f.get("extra") or {}).get("db_index") + and not (f.get("extra") or {}).get("unique") + and (f.get("extra") or {}).get("field_type") not in indexed_types + ] + if not uncovered: + continue + sample = uncovered[0] + out.append( + Finding( + rule="queryset_missing_index", + severity=RuleSeverity.WARNING, + message=( + f"{node['name']} {hit.get('kind')}s `{fname}` " + f"({node.get('file_path')}:{hit.get('line')}) but " + f"{sample.get('qualified_name')} has no db_index" + ), + node_id=node["id"], + file_path=node.get("file_path"), + extra={"field": fname, "kind": hit.get("kind"), "line": hit.get("line")}, + ) + ) + return out + + def _cascade_crosses_context(store: GraphStore, config: LoadpathConfig) -> list[Finding]: out: list[Finding] = [] fields = {n["id"]: n for n in store.nodes([NodeType.FIELD])} diff --git a/src/loadpath/config.py b/src/loadpath/config.py index 34c0dee..f69ae6b 100644 --- a/src/loadpath/config.py +++ b/src/loadpath/config.py @@ -13,6 +13,7 @@ "no_queryset_in_serializer", "celery_tasks_must_be_idempotent_on_model_pk", "queryset_nplusone", + "queryset_missing_index", "cascade_crosses_context", "migration_blast_radius", ] diff --git a/src/loadpath/extractors/django.py b/src/loadpath/extractors/django.py index 85b33e1..ab81687 100644 --- a/src/loadpath/extractors/django.py +++ b/src/loadpath/extractors/django.py @@ -268,6 +268,7 @@ def visit_Call(self, node: ast.Call) -> None: self._enqueue(node, fname, broker="celery") elif short in CELERY_CANVAS and self._looks_like_celery(fname): self.graph.residuals.append(f"Celery canvas {fname}() at {self.rel_path}:{node.lineno}") + self._enqueue_from_canvas(node) elif short == "send_task": self._send_task(node) elif short in DRAMATIQ_ENQUEUE and self._looks_like_dramatiq_send(fname): @@ -468,6 +469,20 @@ def _view(self, node: ast.ClassDef) -> None: Node(id=pid, type=NodeType.PERMISSION, name=perm, qualified_name=perm, extra={"from_view": qname}) ) self.add_edge(view.id, pid, EdgeType.HAS_PERMISSION) + for throttle in extra.get("throttles") or []: + tid = node_id(NodeType.THROTTLE, throttle) + self.graph.nodes.append( + Node( + id=tid, + type=NodeType.THROTTLE, + name=throttle, + qualified_name=throttle, + extra={"from_view": qname}, + ) + ) + self.add_edge(view.id, tid, EdgeType.HAS_PERMISSION) + if extra.get("pagination"): + extra["pagination_sink"] = True if queryset_model: self.add_edge( view.id, @@ -633,6 +648,18 @@ def _task_qname(self, fname: str) -> tuple[str, str, str]: break return app, short, f"{app}.{short}" + def _enqueue_from_canvas(self, node: ast.Call) -> None: + for arg in list(node.args) + [kw.value for kw in node.keywords]: + for child in ast.walk(arg): + if not isinstance(child, ast.Call): + continue + fname = _name(child.func) or "" + short = fname.split(".")[-1] + if short in CELERY_ENQUEUE or short in CELERY_SIGNATURE: + self._enqueue(child, fname, broker="celery") + elif short in DRAMATIQ_ENQUEUE: + self._enqueue(child, fname, broker="dramatiq") + def _enqueue_from_on_commit(self, node: ast.Call) -> None: for arg in list(node.args) + [kw.value for kw in node.keywords]: for child in ast.walk(arg): @@ -795,6 +822,13 @@ def _maybe_test(self, node: ast.FunctionDef) -> None: return qname = f"{self.app}.{node.name}" extra = {"app": self.app, "nodeid": f"{self.rel_path}::{node.name}"} + mentions: set[str] = set() + for child in ast.walk(node): + if isinstance(child, ast.Constant) and isinstance(child.value, str): + mentions.add(child.value) + elif isinstance(child, ast.Attribute): + mentions.add(child.attr) + extra["mentions"] = sorted(mentions) test = self.add_node(NodeType.TEST, node.name, qname, node.lineno, extra) # crude: referenced class names in the test become tested_by for child in ast.walk(node): @@ -993,6 +1027,9 @@ def extract_django_file(rel_path: str, source: str, config: LoadpathConfig) -> E from loadpath.orm.nplusone import apply_nplusone apply_nplusone(extractor.graph, tree) + from loadpath.orm.lookups import apply_lookups + + apply_lookups(extractor.graph, tree) return extractor.graph diff --git a/src/loadpath/extractors/react.py b/src/loadpath/extractors/react.py index b8322a0..4066bc9 100644 --- a/src/loadpath/extractors/react.py +++ b/src/loadpath/extractors/react.py @@ -58,7 +58,12 @@ r"""path\s*:\s*['"]([^'"]+)['"][^}]*?(?:element|Component)\s*:\s* None: + hits = scan_lookups(tree) + if not hits: + return + by_owner: dict[str, list[dict]] = {} + for item in hits: + by_owner.setdefault(item["owner"], []).append(item) + for owner_name, items in by_owner.items(): + owner = _owner_node(graph, owner_name) + if owner is None: + continue + bucket = list(owner.extra.get("lookups") or []) + bucket.extend(items) + owner.extra["lookups"] = bucket + + +def _owner_node(graph: ExtractedGraph, name: str | None): + if not name: + return None + candidates = [n for n in graph.nodes if n.name == name] + return next((n for n in candidates if n.type in PREFERRED_OWNERS), None) or ( + candidates[0] if candidates else None + ) + + +def scan_lookups(tree: ast.AST) -> list[dict]: + out: list[dict] = [] + + def visit_function(fn: ast.FunctionDef | ast.AsyncFunctionDef, owner: str) -> None: + for node in ast.walk(fn): + if not isinstance(node, ast.Call): + continue + short = node.func.attr if isinstance(node.func, ast.Attribute) else "" + if short not in {"filter", "exclude", "order_by", "get"}: + continue + fields: list[str] = [] + if short == "order_by": + for arg in node.args: + if isinstance(arg, ast.Constant) and isinstance(arg.value, str): + fields.append(arg.value.lstrip("-").split("__")[0]) + else: + for kw in node.keywords: + if kw.arg: + fields.append(kw.arg.split("__")[0]) + fields = [f for f in fields if f and f not in SKIP_LOOKUPS and not f.startswith("_")] + if not fields: + continue + out.append( + { + "owner": owner, + "kind": short, + "fields": fields, + "line": getattr(node, "lineno", 0), + } + ) + for stmt in fn.body: + if isinstance(stmt, (ast.FunctionDef, ast.AsyncFunctionDef)): + visit_function(stmt, stmt.name) + + if not isinstance(tree, ast.Module): + return out + for node in tree.body: + if isinstance(node, ast.ClassDef): + for stmt in node.body: + if isinstance(stmt, (ast.FunctionDef, ast.AsyncFunctionDef)): + visit_function(stmt, node.name) + elif isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)): + visit_function(node, node.name) + return out diff --git a/src/loadpath/orm/nplusone.py b/src/loadpath/orm/nplusone.py index 9b58d02..0d3b972 100644 --- a/src/loadpath/orm/nplusone.py +++ b/src/loadpath/orm/nplusone.py @@ -74,6 +74,7 @@ def _owner_node(graph: ExtractedGraph, name: str | None): def scan_nplusone(tree: ast.AST) -> list[NPlusOne]: findings: list[NPlusOne] = [] + returns = _return_map(tree) def visit_function(fn: ast.FunctionDef | ast.AsyncFunctionDef, owner: str) -> None: bindings: dict[str, ast.AST] = {} @@ -86,7 +87,7 @@ def walk_stmts(stmts: list[ast.stmt]) -> None: if isinstance(stmt, ast.ClassDef): continue if isinstance(stmt, ast.For): - _scan_for(stmt, bindings, owner, findings) + _scan_for(stmt, bindings, owner, findings, returns) walk_stmts(stmt.body) walk_stmts(stmt.orelse) continue @@ -133,13 +134,49 @@ def _bind(stmt: ast.AST, bindings: dict[str, ast.AST]) -> None: bindings[stmt.target.id] = stmt.value -def _scan_for(node: ast.For, bindings: dict[str, ast.AST], owner: str, findings: list[NPlusOne]) -> None: +def _return_map(tree: ast.AST) -> dict[str, ast.AST]: + """One-hop helper returns (module + class methods).""" + out: dict[str, ast.AST] = {} + + def take(fn: ast.FunctionDef | ast.AsyncFunctionDef) -> None: + for stmt in reversed(fn.body): + if isinstance(stmt, ast.Return) and stmt.value is not None: + out[fn.name] = stmt.value + return + + if not isinstance(tree, ast.Module): + return out + for node in tree.body: + if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)): + take(node) + elif isinstance(node, ast.ClassDef): + for stmt in node.body: + if isinstance(stmt, (ast.FunctionDef, ast.AsyncFunctionDef)): + take(stmt) + return out + + +def _resolve_iter(source: ast.AST, bindings: dict[str, ast.AST], returns: dict[str, ast.AST]) -> ast.AST: + if isinstance(source, ast.Name) and source.id in bindings: + source = bindings[source.id] + if isinstance(source, ast.Call): + name = _call_name(source) + if name in returns: + source = returns[name] + return source + + +def _scan_for( + node: ast.For, + bindings: dict[str, ast.AST], + owner: str, + findings: list[NPlusOne], + returns: dict[str, ast.AST] | None = None, +) -> None: if not isinstance(node.target, ast.Name): return loop_var = node.target.id - source = node.iter - if isinstance(source, ast.Name) and source.id in bindings: - source = bindings[source.id] + source = _resolve_iter(node.iter, bindings, returns or {}) qs_text, selects, prefetches, is_qs = _queryset_shape(source) if not is_qs: return @@ -219,16 +256,31 @@ def _queryset_shape(node: ast.AST) -> tuple[str, set[str], set[str], bool]: elif short == "prefetch_related": if cleared: prefetches.clear() - elif args: - prefetches.update(a.split("__")[0] for a in args) else: - prefetches.add("*") + string_args = [a for a in (_const_str(a) for a in call.args) if a] + prefetch_objs = [ + _const_str(arg.args[0]) + for arg in call.args + if isinstance(arg, ast.Call) and _call_name(arg) == "Prefetch" and arg.args + ] + if string_args: + prefetches.update(a.split("__")[0] for a in string_args) + for inner in prefetch_objs: + if inner: + prefetches.add(inner.split("__")[0]) + if not string_args and not prefetch_objs and not any( + isinstance(arg, ast.Call) and _call_name(arg) == "Prefetch" for arg in call.args + ): + if not call.args: + prefetches.add("*") for kw in call.keywords: val = kw.value if isinstance(val, ast.Call) and val.args: inner = _const_str(val.args[0]) if inner: prefetches.add(inner.split("__")[0]) + elif _const_str(val): + prefetches.add((_const_str(val) or "").split("__")[0]) return text, selects, prefetches, looks @@ -240,6 +292,8 @@ def _related_access(node: ast.AST, loop_var: str) -> tuple[str | None, str]: if not fields[0].startswith("_"): return "prefetch_related", fields[0] if isinstance(node, ast.Attribute): + if node.attr in {"all", "filter", "exclude", "count", "exists", "first", "last"}: + return None, "" root, fields = _attr_root(node) if root != loop_var or not fields: return None, "" diff --git a/src/loadpath/review/engine.py b/src/loadpath/review/engine.py index 42299f7..85b3faa 100644 --- a/src/loadpath/review/engine.py +++ b/src/loadpath/review/engine.py @@ -1,5 +1,6 @@ from __future__ import annotations +import re from datetime import datetime, timezone from pathlib import Path from uuid import uuid4 @@ -137,7 +138,95 @@ def _why(nodes: list[dict]) -> str: return ", ".join(sorted(set(types))[:4]) -def collect_residuals(store: GraphStore, impact_nodes: list[dict]) -> list[str]: +def _patch_names(diff: DiffSet | None) -> set[str]: + if diff is None: + return set() + names: set[str] = set() + for fd in diff.files: + for raw in (fd.patch or "").splitlines(): + if raw.startswith("+") or raw.startswith("-"): + if raw.startswith("+++") or raw.startswith("---"): + continue + names.update(re.findall(r"[A-Za-z_][A-Za-z0-9_]*", raw[1:])) + return names + + +def _test_field_residuals(impact_nodes: list[dict], diff: DiffSet | None) -> list[str]: + names = _patch_names(diff) + if not names: + return [] + mentions: set[str] = set() + for n in impact_nodes: + if n["type"] not in {NodeType.TEST.value, NodeType.REACT_TEST.value}: + continue + mentions.update((n.get("extra") or {}).get("mentions") or []) + out: list[str] = [] + seen: set[str] = set() + for n in impact_nodes: + if n["type"] not in {NodeType.FIELD.value, NodeType.SERIALIZER_FIELD.value}: + continue + fname = n.get("name") or "" + if fname in {"id", "pk"} or fname not in names: + continue + if fname in mentions: + continue + key = f"{n['type']}:{fname}" + if key in seen: + continue + seen.add(key) + out.append( + f"Test exists on the path but does not assert `{fname}` " + f"({n.get('file_path') or n.get('qualified_name')})" + ) + return out + + +def _react_path_residuals(impact_nodes: list[dict], diff: DiffSet | None) -> list[str]: + changed = set(diff.paths) if diff else set() + out: list[str] = [] + query_keys = [n for n in impact_nodes if n["type"] == NodeType.QUERY_KEY.value] + invalidations = [ + n for n in query_keys if (n.get("extra") or {}).get("invalidation") + ] + mutations = [ + n + for n in impact_nodes + if n["type"] == NodeType.HOOK.value + and ((n.get("extra") or {}).get("mutation") or "Mutation" in (n.get("name") or "")) + ] + if query_keys and mutations and not invalidations: + out.append( + "Mutation hook on the path does not invalidateQueries the queryKey this page reads" + ) + for n in impact_nodes: + extra = n.get("extra") or {} + if n["type"] == NodeType.PAGE.value and n.get("file_path") in changed: + if extra.get("has_error_boundary") is False: + out.append(f"{n['name']} has no ErrorBoundary/Suspense around the page") + if n["type"] in {NodeType.COMPONENT.value, NodeType.PAGE.value} and extra.get("form_fields"): + pass + field_names = { + n["name"] + for n in impact_nodes + if n["type"] in {NodeType.SERIALIZER_FIELD.value, NodeType.FIELD.value} + } & _patch_names(diff) + form_fields: set[str] = set() + for n in impact_nodes: + extra = n.get("extra") or {} + form_fields.update(extra.get("form_fields") or []) + if n["type"] == NodeType.FORM_SCHEMA.value: + form_fields.update(extra.get("fields") or []) + missing_form = sorted(field_names - form_fields - {"id", "pk"}) + if missing_form and form_fields: + out.append( + "Changed fields " + + ", ".join(f"`{f}`" for f in missing_form[:6]) + + " are not in the form defaultValues/Zod on this path" + ) + return out + + +def collect_residuals(store: GraphStore, impact_nodes: list[dict], diff: DiffSet | None = None) -> list[str]: residuals = [] tested = { e["src"] @@ -169,6 +258,8 @@ def collect_residuals(store: GraphStore, impact_nodes: list[dict]) -> list[str]: residuals.append( f"N+1 {accessed} in {n.get('file_path')}:{hit.get('line')} — {hit.get('suggested_fix')}" ) + residuals.extend(_test_field_residuals(impact_nodes, diff)) + residuals.extend(_react_path_residuals(impact_nodes, diff)) seen = set() out = [] for r in residuals: @@ -192,6 +283,19 @@ def suggested_reviewers(config: LoadpathConfig, impact_nodes: list[dict]) -> lis return out +def _knowledge_owners(evolution: dict) -> list[str]: + out: list[str] = [] + seen: set[str] = set() + for h in evolution.get("hotspots") or []: + if (h.get("commits") or 0) < 3: + continue + for author in h.get("authors") or []: + if author and author not in seen: + seen.add(author) + out.append(author) + return out[:8] + + def is_low_risk(kinds: list[str], confidence: dict, findings: list) -> bool: if any(not f.waived and f.severity.value == "blocker" for f in findings): return False @@ -251,7 +355,7 @@ def run_review( or (f.file_path and f.file_path in impact_files) or not impact_ids ] - residuals = collect_residuals(store, impact_nodes) + residuals = collect_residuals(store, impact_nodes, diff) evolution = analyze_evolution(repo_root, diff, impact_nodes, config) confidence = score_confidence(store, impact_nodes, impact_edges, scoped, residuals) if evolution.get("notes") and confidence["level"] == "high": @@ -268,6 +372,7 @@ def run_review( kinds = classify_change(impact_nodes, scoped, seeds=store.nodes_in_files(diff.paths)) read, skip = read_order_files(diff, impact_nodes) reviewers = suggested_reviewers(config, impact_nodes) + knowledge = _knowledge_owners(evolution) low_risk = is_low_risk(kinds, confidence, scoped) labels = ["loadpath:" + confidence["level"]] if low_risk: @@ -302,6 +407,7 @@ def run_review( "findings": [f.to_dict() for f in scoped], "residuals": residuals, "suggested_reviewers": reviewers, + "knowledge_owners": knowledge, "sinks": sinks, "tests_note": tests_note, "architecture_note": arch_note, diff --git a/src/loadpath/review/evolution.py b/src/loadpath/review/evolution.py index 7dde1f8..1481696 100644 --- a/src/loadpath/review/evolution.py +++ b/src/loadpath/review/evolution.py @@ -49,6 +49,7 @@ def analyze_evolution( pair_counts[pair] += 1 complexity = _complexity_for_diff(repo_root, diff) + functions = _changed_functions(repo_root, diff) hotspots = [] for path in impact_files: commits_n = file_commits.get(path, 0) @@ -90,16 +91,17 @@ def analyze_evolution( if len(coupling) >= 12: break - notes = _notes(hotspots, coupling) + notes = _notes(hotspots, coupling, functions) return { "hotspots": hotspots[:16], "change_coupling": coupling, + "functions": functions[:12], "notes": notes, "commits_sampled": len(commits), } -def _notes(hotspots: list[dict], coupling: list[dict]) -> list[str]: +def _notes(hotspots: list[dict], coupling: list[dict], functions: list[dict] | None = None) -> list[str]: notes: list[str] = [] for h in hotspots: if h["commits"] >= 5 and h["bus_factor"] == 1: @@ -123,6 +125,11 @@ def _notes(hotspots: list[dict], coupling: list[dict]) -> list[str]: notes.append( f"Temporal coupling {c['a']} ↔ {c['b']} ({c['together']} co-changes) — files move together" ) + for fn in functions or []: + if fn.get("complexity", 0) >= 12: + notes.append( + f"{fn['path']}::{fn['name']} changed with cyclomatic complexity {fn['complexity']}" + ) # unique preserve order seen: set[str] = set() out: list[str] = [] @@ -167,6 +174,31 @@ def _git_commits(repo_root: Path, limit: int) -> list[dict]: return commits +def _changed_functions(repo_root: Path, diff: DiffSet) -> list[dict]: + out: list[dict] = [] + for fd in diff.files: + if fd.skip or not fd.path.endswith(".py"): + continue + changed = _changed_lines(fd) + path = repo_root / fd.path + if not path.is_file(): + continue + try: + tree = ast.parse(path.read_text(encoding="utf-8", errors="replace")) + except SyntaxError: + continue + for node in ast.walk(tree): + if not isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)): + continue + start = getattr(node, "lineno", 0) or 0 + end = getattr(node, "end_lineno", start) or start + if changed and not any(start <= ln <= end for ln in changed): + continue + out.append({"path": fd.path, "name": node.name, "complexity": _cyclomatic(node)}) + out.sort(key=lambda f: f["complexity"], reverse=True) + return out + + def _complexity_for_diff(repo_root: Path, diff: DiffSet) -> dict[str, int]: out: dict[str, int] = {} for fd in diff.files: diff --git a/src/loadpath/review/render.py b/src/loadpath/review/render.py index 6e4a0ed..5919750 100644 --- a/src/loadpath/review/render.py +++ b/src/loadpath/review/render.py @@ -59,6 +59,11 @@ def render_markdown(review: dict) -> str: for c in (evolution.get("change_coupling") or [])[:4]: flag = " (cross-context)" if c.get("cross_context") else "" lines.append(f"- coupling `{c['a']}` ↔ `{c['b']}` ×{c['together']}{flag}") + for fn in (evolution.get("functions") or [])[:4]: + lines.append(f"- `{fn['path']}::{fn['name']}` cyclomatic {fn.get('complexity', 0)}") + knowledge = review.get("knowledge_owners") or [] + if knowledge: + lines += ["", "### Knowledge on this path", ", ".join(f"`{k}`" for k in knowledge)] index = review.get("index") or {} counts = index.get("counts") or review.get("counts") or {} if counts: diff --git a/src/loadpath/static/assets/index-Dmb_oKHM.js b/src/loadpath/static/assets/index-Dmb_oKHM.js new file mode 100644 index 0000000..945c3a1 --- /dev/null +++ b/src/loadpath/static/assets/index-Dmb_oKHM.js @@ -0,0 +1,62 @@ +(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))l(u);new MutationObserver(u=>{for(const c of u)if(c.type==="childList")for(const f of c.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&l(f)}).observe(document,{childList:!0,subtree:!0});function i(u){const c={};return u.integrity&&(c.integrity=u.integrity),u.referrerPolicy&&(c.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?c.credentials="include":u.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function l(u){if(u.ep)return;u.ep=!0;const c=i(u);fetch(u.href,c)}})();function Jh(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ha={exports:{}},Zo={},pa={exports:{}},Me={};/** + * @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 Ad;function E0(){if(Ad)return Me;Ad=1;var t=Symbol.for("react.element"),r=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),f=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.iterator;function m(M){return M===null||typeof M!="object"?null:(M=v&&M[v]||M["@@iterator"],typeof M=="function"?M:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,P={};function C(M,j,ne){this.props=M,this.context=j,this.refs=P,this.updater=ne||w}C.prototype.isReactComponent={},C.prototype.setState=function(M,j){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,j,"setState")},C.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function k(){}k.prototype=C.prototype;function z(M,j,ne){this.props=M,this.context=j,this.refs=P,this.updater=ne||w}var _=z.prototype=new k;_.constructor=z,S(_,C.prototype),_.isPureReactComponent=!0;var I=Array.isArray,H=Object.prototype.hasOwnProperty,$={current:null},B={key:!0,ref:!0,__self:!0,__source:!0};function X(M,j,ne){var re,ae={},fe=null,ce=null;if(j!=null)for(re in j.ref!==void 0&&(ce=j.ref),j.key!==void 0&&(fe=""+j.key),j)H.call(j,re)&&!B.hasOwnProperty(re)&&(ae[re]=j[re]);var K=arguments.length-2;if(K===1)ae.children=ne;else if(1>>1,j=A[M];if(0>>1;Mu(ae,O))feu(ce,ae)?(A[M]=ce,A[fe]=O,M=fe):(A[M]=ae,A[re]=O,M=re);else if(feu(ce,O))A[M]=ce,A[fe]=O,M=fe;else break e}}return L}function u(A,L){var O=A.sortIndex-L.sortIndex;return O!==0?O:A.id-L.id}if(typeof performance=="object"&&typeof performance.now=="function"){var c=performance;t.unstable_now=function(){return c.now()}}else{var f=Date,h=f.now();t.unstable_now=function(){return f.now()-h}}var p=[],y=[],g=1,v=null,m=3,w=!1,S=!1,P=!1,C=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,z=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function _(A){for(var L=i(y);L!==null;){if(L.callback===null)l(y);else if(L.startTime<=A)l(y),L.sortIndex=L.expirationTime,r(p,L);else break;L=i(y)}}function I(A){if(P=!1,_(A),!S)if(i(p)!==null)S=!0,V(H);else{var L=i(y);L!==null&&b(I,L.startTime-A)}}function H(A,L){S=!1,P&&(P=!1,k(X),X=-1),w=!0;var O=m;try{for(_(L),v=i(p);v!==null&&(!(v.expirationTime>L)||A&&!Z());){var M=v.callback;if(typeof M=="function"){v.callback=null,m=v.priorityLevel;var j=M(v.expirationTime<=L);L=t.unstable_now(),typeof j=="function"?v.callback=j:v===i(p)&&l(p),_(L)}else l(p);v=i(p)}if(v!==null)var ne=!0;else{var re=i(y);re!==null&&b(I,re.startTime-L),ne=!1}return ne}finally{v=null,m=O,w=!1}}var $=!1,B=null,X=-1,G=5,te=-1;function Z(){return!(t.unstable_now()-teA||125M?(A.sortIndex=O,r(y,A),i(p)===null&&A===i(y)&&(P?(k(X),X=-1):P=!0,b(I,O-M))):(A.sortIndex=j,r(p,A),S||w||(S=!0,V(H))),A},t.unstable_shouldYield=Z,t.unstable_wrapCallback=function(A){var L=m;return function(){var O=m;m=L;try{return A.apply(this,arguments)}finally{m=O}}}})(ya)),ya}var Hd;function I0(){return Hd||(Hd=1,ma.exports=P0()),ma.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 Vd;function T0(){if(Vd)return wt;Vd=1;var t=pi(),r=I0();function i(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,o=1;o"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]*$/,g={},v={};function m(e){return p.call(v,e)?!0:p.call(g,e)?!1:y.test(e)?v[e]=!0:(g[e]=!0,!1)}function w(e,n,o,s){if(o!==null&&o.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return s?!1:o!==null?!o.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function S(e,n,o,s){if(n===null||typeof n>"u"||w(e,n,o,s))return!0;if(s)return!1;if(o!==null)switch(o.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 P(e,n,o,s,a,d,x){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=s,this.attributeNamespace=a,this.mustUseProperty=o,this.propertyName=e,this.type=n,this.sanitizeURL=d,this.removeEmptyString=x}var C={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){C[e]=new P(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];C[n]=new P(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){C[e]=new P(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){C[e]=new P(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){C[e]=new P(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){C[e]=new P(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){C[e]=new P(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){C[e]=new P(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){C[e]=new P(e,5,!1,e.toLowerCase(),null,!1,!1)});var k=/[\-:]([a-z])/g;function z(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(k,z);C[n]=new P(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(k,z);C[n]=new P(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(k,z);C[n]=new P(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){C[e]=new P(e,1,!1,e.toLowerCase(),null,!1,!1)}),C.xlinkHref=new P("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){C[e]=new P(e,1,!1,e.toLowerCase(),null,!0,!0)});function _(e,n,o,s){var a=C.hasOwnProperty(n)?C[n]:null;(a!==null?a.type!==0:s||!(2T||a[x]!==d[T]){var R=` +`+a[x].replace(" at new "," at ");return e.displayName&&R.includes("")&&(R=R.replace("",e.displayName)),R}while(1<=x&&0<=T);break}}}finally{ne=!1,Error.prepareStackTrace=o}return(e=e?e.displayName||e.name:"")?j(e):""}function ae(e){switch(e.tag){case 5:return j(e.type);case 16:return j("Lazy");case 13:return j("Suspense");case 19:return j("SuspenseList");case 0:case 2:case 15:return e=re(e.type,!1),e;case 11:return e=re(e.type.render,!1),e;case 1:return e=re(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 B:return"Fragment";case $:return"Portal";case G:return"Profiler";case X:return"StrictMode";case J:return"Suspense";case N:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Z:return(e.displayName||"Context")+".Consumer";case te:return(e._context.displayName||"Context")+".Provider";case ee: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:fe(e.type)||"Memo";case V:n=e._payload,e=e._init;try{return fe(e(n))}catch{}}return null}function ce(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===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 K(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 pe(e){var n=se(e)?"checked":"value",o=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),s=""+e[n];if(!e.hasOwnProperty(n)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var a=o.get,d=o.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return a.call(this)},set:function(x){s=""+x,d.call(this,x)}}),Object.defineProperty(e,n,{enumerable:o.enumerable}),{getValue:function(){return s},setValue:function(x){s=""+x},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function we(e){e._valueTracker||(e._valueTracker=pe(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var o=n.getValue(),s="";return e&&(s=se(e)?e.checked?"true":"false":e.value),e=s,e!==o?(n.setValue(e),!0):!1}function me(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 o=n.checked;return O({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??e._wrapperState.initialChecked})}function Pe(e,n){var o=n.defaultValue==null?"":n.defaultValue,s=n.checked!=null?n.checked:n.defaultChecked;o=K(n.value!=null?n.value:o),e._wrapperState={initialChecked:s,initialValue:o,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Ie(e,n){n=n.checked,n!=null&&_(e,"checked",n,!1)}function Re(e,n){Ie(e,n);var o=K(n.value),s=n.type;if(o!=null)s==="number"?(o===0&&e.value===""||e.value!=o)&&(e.value=""+o):e.value!==""+o&&(e.value=""+o);else if(s==="submit"||s==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?nt(e,n.type,o):n.hasOwnProperty("defaultValue")&&nt(e,n.type,K(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function Ze(e,n,o){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var s=n.type;if(!(s!=="submit"&&s!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,o||n===e.value||(e.value=n),e.defaultValue=n}o=e.name,o!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,o!==""&&(e.name=o)}function nt(e,n,o){(n!=="number"||me(e.ownerDocument)!==e)&&(o==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+o&&(e.defaultValue=""+o))}var Qe=Array.isArray;function Ge(e,n,o,s){if(e=e.options,n){n={};for(var a=0;a"+n.valueOf().toString()+"",n=dt.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function F(e,n){if(n){var o=e.firstChild;if(o&&o===e.lastChild&&o.nodeType===3){o.nodeValue=n;return}}e.textContent=n}var Ce={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},Nt=["Webkit","ms","Moz","O"];Object.keys(Ce).forEach(function(e){Nt.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),Ce[n]=Ce[e]})});function Gn(e,n,o){return n==null||typeof n=="boolean"||n===""?"":o||typeof n!="number"||n===0||Ce.hasOwnProperty(e)&&Ce[e]?(""+n).trim():n+"px"}function Si(e,n){e=e.style;for(var o in n)if(n.hasOwnProperty(o)){var s=o.indexOf("--")===0,a=Gn(o,n[o],s);o==="float"&&(o="cssFloat"),s?e.setProperty(o,a):e[o]=a}}var _l=O({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 uo(e,n){if(n){if(_l[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(i(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(i(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(i(61))}if(n.style!=null&&typeof n.style!="object")throw Error(i(62))}}function ao(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 co=null;function fo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ho=null,kn=null,En=null;function _i(e){if(e=Do(e)){if(typeof ho!="function")throw Error(i(280));var n=e.stateNode;n&&(n=Zi(n),ho(e.stateNode,e.type,n))}}function ki(e){kn?En?En.push(e):En=[e]:kn=e}function Ei(){if(kn){var e=kn,n=En;if(En=kn=null,_i(e),n)for(e=0;e>>=0,e===0?32:31-(zl(e)/Rl|0)|0}var Mr=64,Pr=4194304;function Jn(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 fn(e,n){var o=e.pendingLanes;if(o===0)return 0;var s=0,a=e.suspendedLanes,d=e.pingedLanes,x=o&268435455;if(x!==0){var T=x&~a;T!==0?s=Jn(T):(d&=x,d!==0&&(s=Jn(d)))}else x=o&~a,x!==0?s=Jn(x):d!==0&&(s=Jn(d));if(s===0)return 0;if(n!==0&&n!==s&&(n&a)===0&&(a=s&-s,d=n&-n,a>=d||a===16&&(d&4194240)!==0))return n;if((s&4)!==0&&(s|=o&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=s;0o;o++)n.push(e);return n}function tr(e,n,o){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Mt(n),e[n]=o}function $l(e,n){var o=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 s=e.eventTimes;for(e=e.expirationTimes;0=Po),Mc=" ",Pc=!1;function Ic(e,n){switch(e){case"keyup":return xm.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Tc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var zr=!1;function Sm(e,n){switch(e){case"compositionend":return Tc(n);case"keypress":return n.which!==32?null:(Pc=!0,Mc);case"textInput":return e=n.data,e===Mc&&Pc?null:e;default:return null}}function _m(e,n){if(zr)return e==="compositionend"||!Xl&&Ic(e,n)?(e=Sc(),Vi=Vl=In=null,zr=!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:o,offset:n-e};e=s}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=Dc(o)}}function Fc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Fc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Hc(){for(var e=window,n=me();n instanceof e.HTMLIFrameElement;){try{var o=typeof n.contentWindow.location.href=="string"}catch{o=!1}if(o)e=n.contentWindow;else break;n=me(e.document)}return n}function Kl(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 jm(e){var n=Hc(),o=e.focusedElem,s=e.selectionRange;if(n!==o&&o&&o.ownerDocument&&Fc(o.ownerDocument.documentElement,o)){if(s!==null&&Kl(o)){if(n=s.start,e=s.end,e===void 0&&(e=n),"selectionStart"in o)o.selectionStart=n,o.selectionEnd=Math.min(e,o.value.length);else if(e=(n=o.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var a=o.textContent.length,d=Math.min(s.start,a);s=s.end===void 0?d:Math.min(s.end,a),!e.extend&&d>s&&(a=s,s=d,d=a),a=Oc(o,d);var x=Oc(o,s);a&&x&&(e.rangeCount!==1||e.anchorNode!==a.node||e.anchorOffset!==a.offset||e.focusNode!==x.node||e.focusOffset!==x.offset)&&(n=n.createRange(),n.setStart(a.node,a.offset),e.removeAllRanges(),d>s?(e.addRange(n),e.extend(x.node,x.offset)):(n.setEnd(x.node,x.offset),e.addRange(n)))}}for(n=[],e=o;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o=document.documentMode,Rr=null,ql=null,zo=null,Zl=!1;function Vc(e,n,o){var s=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Zl||Rr==null||Rr!==me(s)||(s=Rr,"selectionStart"in s&&Kl(s)?s={start:s.selectionStart,end:s.selectionEnd}:(s=(s.ownerDocument&&s.ownerDocument.defaultView||window).getSelection(),s={anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focusNode:s.focusNode,focusOffset:s.focusOffset}),zo&&jo(zo,s)||(zo=s,s=Gi(ql,"onSelect"),0Or||(e.current=cu[Or],cu[Or]=null,Or--)}function Ae(e,n){Or++,cu[Or]=e.current,e.current=n}var Rn={},lt=zn(Rn),gt=zn(!1),rr=Rn;function Fr(e,n){var o=e.type.contextTypes;if(!o)return Rn;var s=e.stateNode;if(s&&s.__reactInternalMemoizedUnmaskedChildContext===n)return s.__reactInternalMemoizedMaskedChildContext;var a={},d;for(d in o)a[d]=n[d];return s&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=a),a}function mt(e){return e=e.childContextTypes,e!=null}function Ji(){De(gt),De(lt)}function nf(e,n,o){if(lt.current!==Rn)throw Error(i(168));Ae(lt,n),Ae(gt,o)}function rf(e,n,o){var s=e.stateNode;if(n=n.childContextTypes,typeof s.getChildContext!="function")return o;s=s.getChildContext();for(var a in s)if(!(a in n))throw Error(i(108,ce(e)||"Unknown",a));return O({},o,s)}function es(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Rn,rr=lt.current,Ae(lt,e),Ae(gt,gt.current),!0}function of(e,n,o){var s=e.stateNode;if(!s)throw Error(i(169));o?(e=rf(e,n,rr),s.__reactInternalMemoizedMergedChildContext=e,De(gt),De(lt),Ae(lt,e)):De(gt),Ae(gt,o)}var hn=null,ts=!1,fu=!1;function sf(e){hn===null?hn=[e]:hn.push(e)}function bm(e){ts=!0,sf(e)}function Ln(){if(!fu&&hn!==null){fu=!0;var e=0,n=Le;try{var o=hn;for(Le=1;e>=x,a-=x,pn=1<<32-Mt(n)+a|o<Ee?(tt=ke,ke=null):tt=ke.sibling;var ze=oe(W,ke,Y[Ee],ue);if(ze===null){ke===null&&(ke=tt);break}e&&ke&&ze.alternate===null&&n(W,ke),D=d(ze,D,Ee),_e===null?xe=ze:_e.sibling=ze,_e=ze,ke=tt}if(Ee===Y.length)return o(W,ke),Fe&&ir(W,Ee),xe;if(ke===null){for(;EeEe?(tt=ke,ke=null):tt=ke.sibling;var bn=oe(W,ke,ze.value,ue);if(bn===null){ke===null&&(ke=tt);break}e&&ke&&bn.alternate===null&&n(W,ke),D=d(bn,D,Ee),_e===null?xe=bn:_e.sibling=bn,_e=bn,ke=tt}if(ze.done)return o(W,ke),Fe&&ir(W,Ee),xe;if(ke===null){for(;!ze.done;Ee++,ze=Y.next())ze=le(W,ze.value,ue),ze!==null&&(D=d(ze,D,Ee),_e===null?xe=ze:_e.sibling=ze,_e=ze);return Fe&&ir(W,Ee),xe}for(ke=s(W,ke);!ze.done;Ee++,ze=Y.next())ze=de(ke,W,Ee,ze.value,ue),ze!==null&&(e&&ze.alternate!==null&&ke.delete(ze.key===null?Ee:ze.key),D=d(ze,D,Ee),_e===null?xe=ze:_e.sibling=ze,_e=ze);return e&&ke.forEach(function(k0){return n(W,k0)}),Fe&&ir(W,Ee),xe}function We(W,D,Y,ue){if(typeof Y=="object"&&Y!==null&&Y.type===B&&Y.key===null&&(Y=Y.props.children),typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case H:e:{for(var xe=Y.key,_e=D;_e!==null;){if(_e.key===xe){if(xe=Y.type,xe===B){if(_e.tag===7){o(W,_e.sibling),D=a(_e,Y.props.children),D.return=W,W=D;break e}}else if(_e.elementType===xe||typeof xe=="object"&&xe!==null&&xe.$$typeof===V&&df(xe)===_e.type){o(W,_e.sibling),D=a(_e,Y.props),D.ref=Oo(W,_e,Y),D.return=W,W=D;break e}o(W,_e);break}else n(W,_e);_e=_e.sibling}Y.type===B?(D=hr(Y.props.children,W.mode,ue,Y.key),D.return=W,W=D):(ue=Is(Y.type,Y.key,Y.props,null,W.mode,ue),ue.ref=Oo(W,D,Y),ue.return=W,W=ue)}return x(W);case $:e:{for(_e=Y.key;D!==null;){if(D.key===_e)if(D.tag===4&&D.stateNode.containerInfo===Y.containerInfo&&D.stateNode.implementation===Y.implementation){o(W,D.sibling),D=a(D,Y.children||[]),D.return=W,W=D;break e}else{o(W,D);break}else n(W,D);D=D.sibling}D=ua(Y,W.mode,ue),D.return=W,W=D}return x(W);case V:return _e=Y._init,We(W,D,_e(Y._payload),ue)}if(Qe(Y))return ge(W,D,Y,ue);if(L(Y))return ye(W,D,Y,ue);is(W,Y)}return typeof Y=="string"&&Y!==""||typeof Y=="number"?(Y=""+Y,D!==null&&D.tag===6?(o(W,D.sibling),D=a(D,Y),D.return=W,W=D):(o(W,D),D=la(Y,W.mode,ue),D.return=W,W=D),x(W)):o(W,D)}return We}var br=hf(!0),pf=hf(!1),ss=zn(null),ls=null,Ur=null,yu=null;function vu(){yu=Ur=ls=null}function xu(e){var n=ss.current;De(ss),e._currentValue=n}function wu(e,n,o){for(;e!==null;){var s=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,s!==null&&(s.childLanes|=n)):s!==null&&(s.childLanes&n)!==n&&(s.childLanes|=n),e===o)break;e=e.return}}function Wr(e,n){ls=e,yu=Ur=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(yt=!0),e.firstContext=null)}function Ot(e){var n=e._currentValue;if(yu!==e)if(e={context:e,memoizedValue:n,next:null},Ur===null){if(ls===null)throw Error(i(308));Ur=e,ls.dependencies={lanes:0,firstContext:e}}else Ur=Ur.next=e;return n}var sr=null;function Su(e){sr===null?sr=[e]:sr.push(e)}function gf(e,n,o,s){var a=n.interleaved;return a===null?(o.next=o,Su(n)):(o.next=a.next,a.next=o),n.interleaved=o,mn(e,s)}function mn(e,n){e.lanes|=n;var o=e.alternate;for(o!==null&&(o.lanes|=n),o=e,e=e.return;e!==null;)e.childLanes|=n,o=e.alternate,o!==null&&(o.childLanes|=n),o=e,e=e.return;return o.tag===3?o.stateNode:null}var An=!1;function _u(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function mf(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 yn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function $n(e,n,o){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(Te&2)!==0){var a=s.pending;return a===null?n.next=n:(n.next=a.next,a.next=n),s.pending=n,mn(e,o)}return a=s.interleaved,a===null?(n.next=n,Su(s)):(n.next=a.next,a.next=n),s.interleaved=n,mn(e,o)}function us(e,n,o){if(n=n.updateQueue,n!==null&&(n=n.shared,(o&4194240)!==0)){var s=n.lanes;s&=e.pendingLanes,o|=s,n.lanes=o,Ir(e,o)}}function yf(e,n){var o=e.updateQueue,s=e.alternate;if(s!==null&&(s=s.updateQueue,o===s)){var a=null,d=null;if(o=o.firstBaseUpdate,o!==null){do{var x={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};d===null?a=d=x:d=d.next=x,o=o.next}while(o!==null);d===null?a=d=n:d=d.next=n}else a=d=n;o={baseState:s.baseState,firstBaseUpdate:a,lastBaseUpdate:d,shared:s.shared,effects:s.effects},e.updateQueue=o;return}e=o.lastBaseUpdate,e===null?o.firstBaseUpdate=n:e.next=n,o.lastBaseUpdate=n}function as(e,n,o,s){var a=e.updateQueue;An=!1;var d=a.firstBaseUpdate,x=a.lastBaseUpdate,T=a.shared.pending;if(T!==null){a.shared.pending=null;var R=T,q=R.next;R.next=null,x===null?d=q:x.next=q,x=R;var ie=e.alternate;ie!==null&&(ie=ie.updateQueue,T=ie.lastBaseUpdate,T!==x&&(T===null?ie.firstBaseUpdate=q:T.next=q,ie.lastBaseUpdate=R))}if(d!==null){var le=a.baseState;x=0,ie=q=R=null,T=d;do{var oe=T.lane,de=T.eventTime;if((s&oe)===oe){ie!==null&&(ie=ie.next={eventTime:de,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var ge=e,ye=T;switch(oe=n,de=o,ye.tag){case 1:if(ge=ye.payload,typeof ge=="function"){le=ge.call(de,le,oe);break e}le=ge;break e;case 3:ge.flags=ge.flags&-65537|128;case 0:if(ge=ye.payload,oe=typeof ge=="function"?ge.call(de,le,oe):ge,oe==null)break e;le=O({},le,oe);break e;case 2:An=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,oe=a.effects,oe===null?a.effects=[T]:oe.push(T))}else de={eventTime:de,lane:oe,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ie===null?(q=ie=de,R=le):ie=ie.next=de,x|=oe;if(T=T.next,T===null){if(T=a.shared.pending,T===null)break;oe=T,T=oe.next,oe.next=null,a.lastBaseUpdate=oe,a.shared.pending=null}}while(!0);if(ie===null&&(R=le),a.baseState=R,a.firstBaseUpdate=q,a.lastBaseUpdate=ie,n=a.shared.interleaved,n!==null){a=n;do x|=a.lane,a=a.next;while(a!==n)}else d===null&&(a.shared.lanes=0);ar|=x,e.lanes=x,e.memoizedState=le}}function vf(e,n,o){if(e=n.effects,n.effects=null,e!==null)for(n=0;no?o:4,e(!0);var s=Mu.transition;Mu.transition={};try{e(!1),n()}finally{Le=o,Mu.transition=s}}function Df(){return Ft().memoizedState}function Xm(e,n,o){var s=Hn(e);if(o={lane:s,action:o,hasEagerState:!1,eagerState:null,next:null},Of(e))Ff(n,o);else if(o=gf(e,n,o,s),o!==null){var a=pt();Xt(o,e,s,a),Hf(o,n,s)}}function Qm(e,n,o){var s=Hn(e),a={lane:s,action:o,hasEagerState:!1,eagerState:null,next:null};if(Of(e))Ff(n,a);else{var d=e.alternate;if(e.lanes===0&&(d===null||d.lanes===0)&&(d=n.lastRenderedReducer,d!==null))try{var x=n.lastRenderedState,T=d(x,o);if(a.hasEagerState=!0,a.eagerState=T,Bt(T,x)){var R=n.interleaved;R===null?(a.next=a,Su(n)):(a.next=R.next,R.next=a),n.interleaved=a;return}}catch{}finally{}o=gf(e,n,a,s),o!==null&&(a=pt(),Xt(o,e,s,a),Hf(o,n,s))}}function Of(e){var n=e.alternate;return e===Be||n!==null&&n===Be}function Ff(e,n){Bo=ds=!0;var o=e.pending;o===null?n.next=n:(n.next=o.next,o.next=n),e.pending=n}function Hf(e,n,o){if((o&4194240)!==0){var s=n.lanes;s&=e.pendingLanes,o|=s,n.lanes=o,Ir(e,o)}}var gs={readContext:Ot,useCallback:ut,useContext:ut,useEffect:ut,useImperativeHandle:ut,useInsertionEffect:ut,useLayoutEffect:ut,useMemo:ut,useReducer:ut,useRef:ut,useState:ut,useDebugValue:ut,useDeferredValue:ut,useTransition:ut,useMutableSource:ut,useSyncExternalStore:ut,useId:ut,unstable_isNewReconciler:!1},Gm={readContext:Ot,useCallback:function(e,n){return on().memoizedState=[e,n===void 0?null:n],e},useContext:Ot,useEffect:If,useImperativeHandle:function(e,n,o){return o=o!=null?o.concat([e]):null,hs(4194308,4,zf.bind(null,n,e),o)},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 o=on();return n=n===void 0?null:n,e=e(),o.memoizedState=[e,n],e},useReducer:function(e,n,o){var s=on();return n=o!==void 0?o(n):n,s.memoizedState=s.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},s.queue=e,e=e.dispatch=Xm.bind(null,Be,e),[s.memoizedState,e]},useRef:function(e){var n=on();return e={current:e},n.memoizedState=e},useState:Mf,useDebugValue:Lu,useDeferredValue:function(e){return on().memoizedState=e},useTransition:function(){var e=Mf(!1),n=e[0];return e=Ym.bind(null,e[1]),on().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,o){var s=Be,a=on();if(Fe){if(o===void 0)throw Error(i(407));o=o()}else{if(o=n(),et===null)throw Error(i(349));(ur&30)!==0||_f(s,n,o)}a.memoizedState=o;var d={value:o,getSnapshot:n};return a.queue=d,If(Ef.bind(null,s,d,e),[e]),s.flags|=2048,Wo(9,kf.bind(null,s,d,o,n),void 0,null),o},useId:function(){var e=on(),n=et.identifierPrefix;if(Fe){var o=gn,s=pn;o=(s&~(1<<32-Mt(s)-1)).toString(32)+o,n=":"+n+"R"+o,o=bo++,0<\/script>",e=e.removeChild(e.firstChild)):typeof s.is=="string"?e=x.createElement(o,{is:s.is}):(e=x.createElement(o),o==="select"&&(x=e,s.multiple?x.multiple=!0:s.size&&(x.size=s.size))):e=x.createElementNS(e,o),e[nn]=n,e[$o]=s,sd(e,n,!1,!1),n.stateNode=e;e:{switch(x=ao(o,s),o){case"dialog":$e("cancel",e),$e("close",e),a=s;break;case"iframe":case"object":case"embed":$e("load",e),a=s;break;case"video":case"audio":for(a=0;aKr&&(n.flags|=128,s=!0,Yo(d,!1),n.lanes=4194304)}else{if(!s)if(e=cs(x),e!==null){if(n.flags|=128,s=!0,o=e.updateQueue,o!==null&&(n.updateQueue=o,n.flags|=4),Yo(d,!0),d.tail===null&&d.tailMode==="hidden"&&!x.alternate&&!Fe)return at(n),null}else 2*He()-d.renderingStartTime>Kr&&o!==1073741824&&(n.flags|=128,s=!0,Yo(d,!1),n.lanes=4194304);d.isBackwards?(x.sibling=n.child,n.child=x):(o=d.last,o!==null?o.sibling=x:n.child=x,d.last=x)}return d.tail!==null?(n=d.tail,d.rendering=n,d.tail=n.sibling,d.renderingStartTime=He(),n.sibling=null,o=Ve.current,Ae(Ve,s?o&1|2:o&1),n):(at(n),null);case 22:case 23:return oa(),s=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==s&&(n.flags|=8192),s&&(n.mode&1)!==0?(jt&1073741824)!==0&&(at(n),n.subtreeFlags&6&&(n.flags|=8192)):at(n),null;case 24:return null;case 25:return null}throw Error(i(156,n.tag))}function r0(e,n){switch(hu(n),n.tag){case 1:return mt(n.type)&&Ji(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Yr(),De(gt),De(lt),Cu(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return Eu(n),null;case 13:if(De(Ve),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(i(340));Br()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return De(Ve),null;case 4:return Yr(),null;case 10:return xu(n.type._context),null;case 22:case 23:return oa(),null;case 24:return null;default:return null}}var xs=!1,ct=!1,o0=typeof WeakSet=="function"?WeakSet:Set,he=null;function Qr(e,n){var o=e.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(s){Ue(e,n,s)}else o.current=null}function Yu(e,n,o){try{o()}catch(s){Ue(e,n,s)}}var ad=!1;function i0(e,n){if(ou=Fi,e=Hc(),Kl(e)){if("selectionStart"in e)var o={start:e.selectionStart,end:e.selectionEnd};else e:{o=(o=e.ownerDocument)&&o.defaultView||window;var s=o.getSelection&&o.getSelection();if(s&&s.rangeCount!==0){o=s.anchorNode;var a=s.anchorOffset,d=s.focusNode;s=s.focusOffset;try{o.nodeType,d.nodeType}catch{o=null;break e}var x=0,T=-1,R=-1,q=0,ie=0,le=e,oe=null;t:for(;;){for(var de;le!==o||a!==0&&le.nodeType!==3||(T=x+a),le!==d||s!==0&&le.nodeType!==3||(R=x+s),le.nodeType===3&&(x+=le.nodeValue.length),(de=le.firstChild)!==null;)oe=le,le=de;for(;;){if(le===e)break t;if(oe===o&&++q===a&&(T=x),oe===d&&++ie===s&&(R=x),(de=le.nextSibling)!==null)break;le=oe,oe=le.parentNode}le=de}o=T===-1||R===-1?null:{start:T,end:R}}else o=null}o=o||{start:0,end:0}}else o=null;for(iu={focusedElem:e,selectionRange:o},Fi=!1,he=n;he!==null;)if(n=he,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,he=e;else for(;he!==null;){n=he;try{var ge=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(ge!==null){var ye=ge.memoizedProps,We=ge.memoizedState,W=n.stateNode,D=W.getSnapshotBeforeUpdate(n.elementType===n.type?ye:Ut(n.type,ye),We);W.__reactInternalSnapshotBeforeUpdate=D}break;case 3:var Y=n.stateNode.containerInfo;Y.nodeType===1?Y.textContent="":Y.nodeType===9&&Y.documentElement&&Y.removeChild(Y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(i(163))}}catch(ue){Ue(n,n.return,ue)}if(e=n.sibling,e!==null){e.return=n.return,he=e;break}he=n.return}return ge=ad,ad=!1,ge}function Xo(e,n,o){var s=n.updateQueue;if(s=s!==null?s.lastEffect:null,s!==null){var a=s=s.next;do{if((a.tag&e)===e){var d=a.destroy;a.destroy=void 0,d!==void 0&&Yu(n,o,d)}a=a.next}while(a!==s)}}function ws(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var o=n=n.next;do{if((o.tag&e)===e){var s=o.create;o.destroy=s()}o=o.next}while(o!==n)}}function Xu(e){var n=e.ref;if(n!==null){var o=e.stateNode;switch(e.tag){case 5:e=o;break;default:e=o}typeof n=="function"?n(e):n.current=e}}function cd(e){var n=e.alternate;n!==null&&(e.alternate=null,cd(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[nn],delete n[$o],delete n[au],delete n[Vm],delete n[Bm])),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 fd(e){return e.tag===5||e.tag===3||e.tag===4}function dd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||fd(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 Qu(e,n,o){var s=e.tag;if(s===5||s===6)e=e.stateNode,n?o.nodeType===8?o.parentNode.insertBefore(e,n):o.insertBefore(e,n):(o.nodeType===8?(n=o.parentNode,n.insertBefore(e,o)):(n=o,n.appendChild(e)),o=o._reactRootContainer,o!=null||n.onclick!==null||(n.onclick=qi));else if(s!==4&&(e=e.child,e!==null))for(Qu(e,n,o),e=e.sibling;e!==null;)Qu(e,n,o),e=e.sibling}function Gu(e,n,o){var s=e.tag;if(s===5||s===6)e=e.stateNode,n?o.insertBefore(e,n):o.appendChild(e);else if(s!==4&&(e=e.child,e!==null))for(Gu(e,n,o),e=e.sibling;e!==null;)Gu(e,n,o),e=e.sibling}var ot=null,Wt=!1;function Dn(e,n,o){for(o=o.child;o!==null;)hd(e,n,o),o=o.sibling}function hd(e,n,o){if(Ct&&typeof Ct.onCommitFiberUnmount=="function")try{Ct.onCommitFiberUnmount(Cr,o)}catch{}switch(o.tag){case 5:ct||Qr(o,n);case 6:var s=ot,a=Wt;ot=null,Dn(e,n,o),ot=s,Wt=a,ot!==null&&(Wt?(e=ot,o=o.stateNode,e.nodeType===8?e.parentNode.removeChild(o):e.removeChild(o)):ot.removeChild(o.stateNode));break;case 18:ot!==null&&(Wt?(e=ot,o=o.stateNode,e.nodeType===8?uu(e.parentNode,o):e.nodeType===1&&uu(e,o),No(e)):uu(ot,o.stateNode));break;case 4:s=ot,a=Wt,ot=o.stateNode.containerInfo,Wt=!0,Dn(e,n,o),ot=s,Wt=a;break;case 0:case 11:case 14:case 15:if(!ct&&(s=o.updateQueue,s!==null&&(s=s.lastEffect,s!==null))){a=s=s.next;do{var d=a,x=d.destroy;d=d.tag,x!==void 0&&((d&2)!==0||(d&4)!==0)&&Yu(o,n,x),a=a.next}while(a!==s)}Dn(e,n,o);break;case 1:if(!ct&&(Qr(o,n),s=o.stateNode,typeof s.componentWillUnmount=="function"))try{s.props=o.memoizedProps,s.state=o.memoizedState,s.componentWillUnmount()}catch(T){Ue(o,n,T)}Dn(e,n,o);break;case 21:Dn(e,n,o);break;case 22:o.mode&1?(ct=(s=ct)||o.memoizedState!==null,Dn(e,n,o),ct=s):Dn(e,n,o);break;default:Dn(e,n,o)}}function pd(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var o=e.stateNode;o===null&&(o=e.stateNode=new o0),n.forEach(function(s){var a=p0.bind(null,e,s);o.has(s)||(o.add(s),s.then(a,a))})}}function Yt(e,n){var o=n.deletions;if(o!==null)for(var s=0;sa&&(a=x),s&=~d}if(s=a,s=He()-s,s=(120>s?120:480>s?480:1080>s?1080:1920>s?1920:3e3>s?3e3:4320>s?4320:1960*l0(s/1960))-s,10e?16:e,Fn===null)var s=!1;else{if(e=Fn,Fn=null,Ns=0,(Te&6)!==0)throw Error(i(331));var a=Te;for(Te|=4,he=e.current;he!==null;){var d=he,x=d.child;if((he.flags&16)!==0){var T=d.deletions;if(T!==null){for(var R=0;RHe()-Zu?fr(e,0):qu|=o),xt(e,n)}function Md(e,n){n===0&&((e.mode&1)===0?n=1:(n=Pr,Pr<<=1,(Pr&130023424)===0&&(Pr=4194304)));var o=pt();e=mn(e,n),e!==null&&(tr(e,n,o),xt(e,o))}function h0(e){var n=e.memoizedState,o=0;n!==null&&(o=n.retryLane),Md(e,o)}function p0(e,n){var o=0;switch(e.tag){case 13:var s=e.stateNode,a=e.memoizedState;a!==null&&(o=a.retryLane);break;case 19:s=e.stateNode;break;default:throw Error(i(314))}s!==null&&s.delete(n),Md(e,o)}var Pd;Pd=function(e,n,o){if(e!==null)if(e.memoizedProps!==n.pendingProps||gt.current)yt=!0;else{if((e.lanes&o)===0&&(n.flags&128)===0)return yt=!1,t0(e,n,o);yt=(e.flags&131072)!==0}else yt=!1,Fe&&(n.flags&1048576)!==0&&lf(n,rs,n.index);switch(n.lanes=0,n.tag){case 2:var s=n.type;vs(e,n),e=n.pendingProps;var a=Fr(n,lt.current);Wr(n,o),a=Iu(null,n,s,e,a,o);var d=Tu();return n.flags|=1,typeof a=="object"&&a!==null&&typeof a.render=="function"&&a.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,mt(s)?(d=!0,es(n)):d=!1,n.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,_u(n),a.updater=ms,n.stateNode=a,a._reactInternals=n,$u(n,s,e,o),n=Hu(null,n,s,!0,d,o)):(n.tag=0,Fe&&d&&du(n),ht(null,n,a,o),n=n.child),n;case 16:s=n.elementType;e:{switch(vs(e,n),e=n.pendingProps,a=s._init,s=a(s._payload),n.type=s,a=n.tag=m0(s),e=Ut(s,e),a){case 0:n=Fu(null,n,s,e,o);break e;case 1:n=ed(null,n,s,e,o);break e;case 11:n=Gf(null,n,s,e,o);break e;case 14:n=Kf(null,n,s,Ut(s.type,e),o);break e}throw Error(i(306,s,""))}return n;case 0:return s=n.type,a=n.pendingProps,a=n.elementType===s?a:Ut(s,a),Fu(e,n,s,a,o);case 1:return s=n.type,a=n.pendingProps,a=n.elementType===s?a:Ut(s,a),ed(e,n,s,a,o);case 3:e:{if(td(n),e===null)throw Error(i(387));s=n.pendingProps,d=n.memoizedState,a=d.element,mf(e,n),as(n,s,null,o);var x=n.memoizedState;if(s=x.element,d.isDehydrated)if(d={element:s,isDehydrated:!1,cache:x.cache,pendingSuspenseBoundaries:x.pendingSuspenseBoundaries,transitions:x.transitions},n.updateQueue.baseState=d,n.memoizedState=d,n.flags&256){a=Xr(Error(i(423)),n),n=nd(e,n,s,o,a);break e}else if(s!==a){a=Xr(Error(i(424)),n),n=nd(e,n,s,o,a);break e}else for(Tt=jn(n.stateNode.containerInfo.firstChild),It=n,Fe=!0,bt=null,o=pf(n,null,s,o),n.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(Br(),s===a){n=vn(e,n,o);break e}ht(e,n,s,o)}n=n.child}return n;case 5:return xf(n),e===null&&gu(n),s=n.type,a=n.pendingProps,d=e!==null?e.memoizedProps:null,x=a.children,su(s,a)?x=null:d!==null&&su(s,d)&&(n.flags|=32),Jf(e,n),ht(e,n,x,o),n.child;case 6:return e===null&&gu(n),null;case 13:return rd(e,n,o);case 4:return ku(n,n.stateNode.containerInfo),s=n.pendingProps,e===null?n.child=br(n,null,s,o):ht(e,n,s,o),n.child;case 11:return s=n.type,a=n.pendingProps,a=n.elementType===s?a:Ut(s,a),Gf(e,n,s,a,o);case 7:return ht(e,n,n.pendingProps,o),n.child;case 8:return ht(e,n,n.pendingProps.children,o),n.child;case 12:return ht(e,n,n.pendingProps.children,o),n.child;case 10:e:{if(s=n.type._context,a=n.pendingProps,d=n.memoizedProps,x=a.value,Ae(ss,s._currentValue),s._currentValue=x,d!==null)if(Bt(d.value,x)){if(d.children===a.children&&!gt.current){n=vn(e,n,o);break e}}else for(d=n.child,d!==null&&(d.return=n);d!==null;){var T=d.dependencies;if(T!==null){x=d.child;for(var R=T.firstContext;R!==null;){if(R.context===s){if(d.tag===1){R=yn(-1,o&-o),R.tag=2;var q=d.updateQueue;if(q!==null){q=q.shared;var ie=q.pending;ie===null?R.next=R:(R.next=ie.next,ie.next=R),q.pending=R}}d.lanes|=o,R=d.alternate,R!==null&&(R.lanes|=o),wu(d.return,o,n),T.lanes|=o;break}R=R.next}}else if(d.tag===10)x=d.type===n.type?null:d.child;else if(d.tag===18){if(x=d.return,x===null)throw Error(i(341));x.lanes|=o,T=x.alternate,T!==null&&(T.lanes|=o),wu(x,o,n),x=d.sibling}else x=d.child;if(x!==null)x.return=d;else for(x=d;x!==null;){if(x===n){x=null;break}if(d=x.sibling,d!==null){d.return=x.return,x=d;break}x=x.return}d=x}ht(e,n,a.children,o),n=n.child}return n;case 9:return a=n.type,s=n.pendingProps.children,Wr(n,o),a=Ot(a),s=s(a),n.flags|=1,ht(e,n,s,o),n.child;case 14:return s=n.type,a=Ut(s,n.pendingProps),a=Ut(s.type,a),Kf(e,n,s,a,o);case 15:return qf(e,n,n.type,n.pendingProps,o);case 17:return s=n.type,a=n.pendingProps,a=n.elementType===s?a:Ut(s,a),vs(e,n),n.tag=1,mt(s)?(e=!0,es(n)):e=!1,Wr(n,o),Bf(n,s,a),$u(n,s,a,o),Hu(null,n,s,!0,e,o);case 19:return id(e,n,o);case 22:return Zf(e,n,o)}throw Error(i(156,n.tag))};function Id(e,n){return Ti(e,n)}function g0(e,n,o,s){this.tag=e,this.key=o,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=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Vt(e,n,o,s){return new g0(e,n,o,s)}function sa(e){return e=e.prototype,!(!e||!e.isReactComponent)}function m0(e){if(typeof e=="function")return sa(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ee)return 11;if(e===U)return 14}return 2}function Bn(e,n){var o=e.alternate;return o===null?(o=Vt(e.tag,n,e.key,e.mode),o.elementType=e.elementType,o.type=e.type,o.stateNode=e.stateNode,o.alternate=e,e.alternate=o):(o.pendingProps=n,o.type=e.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=e.flags&14680064,o.childLanes=e.childLanes,o.lanes=e.lanes,o.child=e.child,o.memoizedProps=e.memoizedProps,o.memoizedState=e.memoizedState,o.updateQueue=e.updateQueue,n=e.dependencies,o.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},o.sibling=e.sibling,o.index=e.index,o.ref=e.ref,o}function Is(e,n,o,s,a,d){var x=2;if(s=e,typeof e=="function")sa(e)&&(x=1);else if(typeof e=="string")x=5;else e:switch(e){case B:return hr(o.children,a,d,n);case X:x=8,a|=8;break;case G:return e=Vt(12,o,n,a|2),e.elementType=G,e.lanes=d,e;case J:return e=Vt(13,o,n,a),e.elementType=J,e.lanes=d,e;case N:return e=Vt(19,o,n,a),e.elementType=N,e.lanes=d,e;case b:return Ts(o,a,d,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case te:x=10;break e;case Z:x=9;break e;case ee:x=11;break e;case U:x=14;break e;case V:x=16,s=null;break e}throw Error(i(130,e==null?e:typeof e,""))}return n=Vt(x,o,n,a),n.elementType=e,n.type=s,n.lanes=d,n}function hr(e,n,o,s){return e=Vt(7,e,s,n),e.lanes=o,e}function Ts(e,n,o,s){return e=Vt(22,e,s,n),e.elementType=b,e.lanes=o,e.stateNode={isHidden:!1},e}function la(e,n,o){return e=Vt(6,e,null,n),e.lanes=o,e}function ua(e,n,o){return n=Vt(4,e.children!==null?e.children:[],e.key,n),n.lanes=o,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function y0(e,n,o,s,a){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=er(0),this.expirationTimes=er(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=er(0),this.identifierPrefix=s,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function aa(e,n,o,s,a,d,x,T,R){return e=new y0(e,n,o,T,R),n===1?(n=1,d===!0&&(n|=8)):n=0,d=Vt(3,null,null,n),e.current=d,d.stateNode=e,d.memoizedState={element:s,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},_u(d),e}function v0(e,n,o){var s=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),ga.exports=T0(),ga.exports}var bd;function j0(){if(bd)return Ds;bd=1;var t=ep();return Ds.createRoot=t.createRoot,Ds.hydrateRoot=t.hydrateRoot,Ds}var z0=j0();async function zt(t,r){const i=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!i.ok){const l=await i.text();throw new Error(l||i.statusText)}return i.json()}const St={health:()=>zt("/api/health"),settings:()=>zt("/api/settings"),saveSettings:t=>zt("/api/settings",{method:"PUT",body:JSON.stringify(t)}),repos:()=>zt("/api/repos"),index:(t,r=!0)=>zt("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>zt(`/api/index?repo_path=${encodeURIComponent(t)}`),architecture:t=>zt(`/api/architecture?repo_path=${encodeURIComponent(t)}`),review:(t,r,i,l=!0)=>zt("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:i||null,reindex:l,incremental:!0,three_dot:!0})}),init:(t,r=!1)=>zt("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,i,l)=>zt("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:i,markdown:l})}),graph:(t,r="full")=>zt(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,i="open")=>zt("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:i})}),residual:t=>zt("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})})};function Xe(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let i=0,l;i{}};function cl(){for(var t=0,r=arguments.length,i={},l;t=0&&(l=i.slice(u+1),i=i.slice(0,u)),i&&!r.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:l}})}Xs.prototype=cl.prototype={constructor:Xs,on:function(t,r){var i=this._,l=L0(t+"",i),u,c=-1,f=l.length;if(arguments.length<2){for(;++c0)for(var i=new Array(u),l=0,u,c;l=0&&(r=t.slice(0,i))!=="xmlns"&&(t=t.slice(i+1)),Wd.hasOwnProperty(r)?{space:Wd[r],local:t}:t}function $0(t){return function(){var r=this.ownerDocument,i=this.namespaceURI;return i===za&&r.documentElement.namespaceURI===za?r.createElement(t):r.createElementNS(i,t)}}function D0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function tp(t){var r=fl(t);return(r.local?D0:$0)(r)}function O0(){}function Xa(t){return t==null?O0:function(){return this.querySelector(t)}}function F0(t){typeof t!="function"&&(t=Xa(t));for(var r=this._groups,i=r.length,l=new Array(i),u=0;u=_&&(_=z+1);!(H=C[_])&&++_=0;)(f=l[u])&&(c&&f.compareDocumentPosition(c)^4&&c.parentNode.insertBefore(f,c),c=f);return this}function cy(t){t||(t=fy);function r(v,m){return v&&m?t(v.__data__,m.__data__):!v-!m}for(var i=this._groups,l=i.length,u=new Array(l),c=0;cr?1:t>=r?0:NaN}function dy(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function hy(){return Array.from(this)}function py(){for(var t=this._groups,r=0,i=t.length;r1?this.each((r==null?Ny:typeof r=="function"?My:Cy)(t,r,i??"")):no(this.node(),t)}function no(t,r){return t.style.getPropertyValue(r)||sp(t).getComputedStyle(t,null).getPropertyValue(r)}function Iy(t){return function(){delete this[t]}}function Ty(t,r){return function(){this[t]=r}}function jy(t,r){return function(){var i=r.apply(this,arguments);i==null?delete this[t]:this[t]=i}}function zy(t,r){return arguments.length>1?this.each((r==null?Iy:typeof r=="function"?jy:Ty)(t,r)):this.node()[t]}function lp(t){return t.trim().split(/^|\s+/)}function Qa(t){return t.classList||new up(t)}function up(t){this._node=t,this._names=lp(t.getAttribute("class")||"")}up.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 i=Qa(t),l=-1,u=r.length;++l=0&&(i=r.slice(l+1),r=r.slice(0,l)),{type:r,name:i}})}function sv(t){return function(){var r=this.__on;if(r){for(var i=0,l=-1,u=r.length,c;i()=>t;function Ra(t,{sourceEvent:r,subject:i,target:l,identifier:u,active:c,x:f,y:h,dx:p,dy:y,dispatch:g}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:i,enumerable:!0,configurable:!0},target:{value:l,enumerable:!0,configurable:!0},identifier:{value:u,enumerable:!0,configurable:!0},active:{value:c,enumerable:!0,configurable:!0},x:{value:f,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:g}})}Ra.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function mv(t){return!t.ctrlKey&&!t.button}function yv(){return this.parentNode}function vv(t,r){return r??{x:t.x,y:t.y}}function xv(){return navigator.maxTouchPoints||"ontouchstart"in this}function gp(){var t=mv,r=yv,i=vv,l=xv,u={},c=cl("start","drag","end"),f=0,h,p,y,g,v=0;function m(I){I.on("mousedown.drag",w).filter(l).on("touchstart.drag",C).on("touchmove.drag",k,gv).on("touchend.drag touchcancel.drag",z).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function w(I,H){if(!(g||!t.call(this,I,H))){var $=_(this,r.call(this,I,H),I,H,"mouse");$&&(Rt(I.view).on("mousemove.drag",S,ii).on("mouseup.drag",P,ii),hp(I.view),va(I),y=!1,h=I.clientX,p=I.clientY,$("start",I))}}function S(I){if(eo(I),!y){var H=I.clientX-h,$=I.clientY-p;y=H*H+$*$>v}u.mouse("drag",I)}function P(I){Rt(I.view).on("mousemove.drag mouseup.drag",null),pp(I.view,y),eo(I),u.mouse("end",I)}function C(I,H){if(t.call(this,I,H)){var $=I.changedTouches,B=r.call(this,I,H),X=$.length,G,te;for(G=0;G>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):i===8?Fs(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):i===4?Fs(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=Sv.exec(t))?new _t(r[1],r[2],r[3],1):(r=_v.exec(t))?new _t(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=kv.exec(t))?Fs(r[1],r[2],r[3],r[4]):(r=Ev.exec(t))?Fs(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=Nv.exec(t))?Zd(r[1],r[2]/100,r[3]/100,1):(r=Cv.exec(t))?Zd(r[1],r[2]/100,r[3]/100,r[4]):Yd.hasOwnProperty(t)?Gd(Yd[t]):t==="transparent"?new _t(NaN,NaN,NaN,0):null}function Gd(t){return new _t(t>>16&255,t>>8&255,t&255,1)}function Fs(t,r,i,l){return l<=0&&(t=r=i=NaN),new _t(t,r,i,l)}function Iv(t){return t instanceof mi||(t=vr(t)),t?(t=t.rgb(),new _t(t.r,t.g,t.b,t.opacity)):new _t}function La(t,r,i,l){return arguments.length===1?Iv(t):new _t(t,r,i,l??1)}function _t(t,r,i,l){this.r=+t,this.g=+r,this.b=+i,this.opacity=+l}Ga(_t,La,mp(mi,{brighter(t){return t=t==null?Js:Math.pow(Js,t),new _t(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?si:Math.pow(si,t),new _t(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new _t(mr(this.r),mr(this.g),mr(this.b),el(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:Kd,formatHex:Kd,formatHex8:Tv,formatRgb:qd,toString:qd}));function Kd(){return`#${gr(this.r)}${gr(this.g)}${gr(this.b)}`}function Tv(){return`#${gr(this.r)}${gr(this.g)}${gr(this.b)}${gr((isNaN(this.opacity)?1:this.opacity)*255)}`}function qd(){const t=el(this.opacity);return`${t===1?"rgb(":"rgba("}${mr(this.r)}, ${mr(this.g)}, ${mr(this.b)}${t===1?")":`, ${t})`}`}function el(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function mr(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function gr(t){return t=mr(t),(t<16?"0":"")+t.toString(16)}function Zd(t,r,i,l){return l<=0?t=r=i=NaN:i<=0||i>=1?t=r=NaN:r<=0&&(t=NaN),new Gt(t,r,i,l)}function yp(t){if(t instanceof Gt)return new Gt(t.h,t.s,t.l,t.opacity);if(t instanceof mi||(t=vr(t)),!t)return new Gt;if(t instanceof Gt)return t;t=t.rgb();var r=t.r/255,i=t.g/255,l=t.b/255,u=Math.min(r,i,l),c=Math.max(r,i,l),f=NaN,h=c-u,p=(c+u)/2;return h?(r===c?f=(i-l)/h+(i0&&p<1?0:f,new Gt(f,h,p,t.opacity)}function jv(t,r,i,l){return arguments.length===1?yp(t):new Gt(t,r,i,l??1)}function Gt(t,r,i,l){this.h=+t,this.s=+r,this.l=+i,this.opacity=+l}Ga(Gt,jv,mp(mi,{brighter(t){return t=t==null?Js:Math.pow(Js,t),new Gt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?si:Math.pow(si,t),new Gt(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,i=this.l,l=i+(i<.5?i:1-i)*r,u=2*i-l;return new _t(xa(t>=240?t-240:t+120,u,l),xa(t,u,l),xa(t<120?t+240:t-120,u,l),this.opacity)},clamp(){return new Gt(Jd(this.h),Hs(this.s),Hs(this.l),el(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=el(this.opacity);return`${t===1?"hsl(":"hsla("}${Jd(this.h)}, ${Hs(this.s)*100}%, ${Hs(this.l)*100}%${t===1?")":`, ${t})`}`}}));function Jd(t){return t=(t||0)%360,t<0?t+360:t}function Hs(t){return Math.max(0,Math.min(1,t||0))}function xa(t,r,i){return(t<60?r+(i-r)*t/60:t<180?i:t<240?r+(i-r)*(240-t)/60:r)*255}const Ka=t=>()=>t;function zv(t,r){return function(i){return t+i*r}}function Rv(t,r,i){return t=Math.pow(t,i),r=Math.pow(r,i)-t,i=1/i,function(l){return Math.pow(t+l*r,i)}}function Lv(t){return(t=+t)==1?vp:function(r,i){return i-r?Rv(r,i,t):Ka(isNaN(r)?i:r)}}function vp(t,r){var i=r-t;return i?zv(t,i):Ka(isNaN(t)?r:t)}const tl=(function t(r){var i=Lv(r);function l(u,c){var f=i((u=La(u)).r,(c=La(c)).r),h=i(u.g,c.g),p=i(u.b,c.b),y=vp(u.opacity,c.opacity);return function(g){return u.r=f(g),u.g=h(g),u.b=p(g),u.opacity=y(g),u+""}}return l.gamma=t,l})(1);function Av(t,r){r||(r=[]);var i=t?Math.min(r.length,t.length):0,l=r.slice(),u;return function(c){for(u=0;ui&&(c=r.slice(i,c),h[f]?h[f]+=c:h[++f]=c),(l=l[0])===(u=u[0])?h[f]?h[f]+=u:h[++f]=u:(h[++f]=null,p.push({i:f,x:ln(l,u)})),i=wa.lastIndex;return i180?g+=360:g-y>180&&(y+=360),m.push({i:v.push(u(v)+"rotate(",null,l)-2,x:ln(y,g)})):g&&v.push(u(v)+"rotate("+g+l)}function h(y,g,v,m){y!==g?m.push({i:v.push(u(v)+"skewX(",null,l)-2,x:ln(y,g)}):g&&v.push(u(v)+"skewX("+g+l)}function p(y,g,v,m,w,S){if(y!==v||g!==m){var P=w.push(u(w)+"scale(",null,",",null,")");S.push({i:P-4,x:ln(y,v)},{i:P-2,x:ln(g,m)})}else(v!==1||m!==1)&&w.push(u(w)+"scale("+v+","+m+")")}return function(y,g){var v=[],m=[];return y=t(y),g=t(g),c(y.translateX,y.translateY,g.translateX,g.translateY,v,m),f(y.rotate,g.rotate,v,m),h(y.skewX,g.skewX,v,m),p(y.scaleX,y.scaleY,g.scaleX,g.scaleY,v,m),y=g=null,function(w){for(var S=-1,P=m.length,C;++S=0&&t._call.call(void 0,r),t=t._next;--ro}function nh(){xr=(rl=ui.now())+dl,ro=ti=0;try{Kv()}finally{ro=0,Zv(),xr=0}}function qv(){var t=ui.now(),r=t-rl;r>_p&&(dl-=r,rl=t)}function Zv(){for(var t,r=nl,i,l=1/0;r;)r._call?(l>r._time&&(l=r._time),t=r,r=r._next):(i=r._next,r._next=null,r=t?t._next=i:nl=i);ni=t,Da(l)}function Da(t){if(!ro){ti&&(ti=clearTimeout(ti));var r=t-xr;r>24?(t<1/0&&(ti=setTimeout(nh,t-ui.now()-dl)),Jo&&(Jo=clearInterval(Jo))):(Jo||(rl=ui.now(),Jo=setInterval(qv,_p)),ro=1,kp(nh))}}function rh(t,r,i){var l=new ol;return r=r==null?0:+r,l.restart(u=>{l.stop(),t(u+r)},r,i),l}var Jv=cl("start","end","cancel","interrupt"),ex=[],Np=0,oh=1,Oa=2,Gs=3,ih=4,Fa=5,Ks=6;function hl(t,r,i,l,u,c){var f=t.__transition;if(!f)t.__transition={};else if(i in f)return;tx(t,i,{name:r,index:l,group:u,on:Jv,tween:ex,time:c.time,delay:c.delay,duration:c.duration,ease:c.ease,timer:null,state:Np})}function Za(t,r){var i=Jt(t,r);if(i.state>Np)throw new Error("too late; already scheduled");return i}function an(t,r){var i=Jt(t,r);if(i.state>Gs)throw new Error("too late; already running");return i}function Jt(t,r){var i=t.__transition;if(!i||!(i=i[r]))throw new Error("transition not found");return i}function tx(t,r,i){var l=t.__transition,u;l[r]=i,i.timer=Ep(c,0,i.time);function c(y){i.state=oh,i.timer.restart(f,i.delay,i.time),i.delay<=y&&f(y-i.delay)}function f(y){var g,v,m,w;if(i.state!==oh)return p();for(g in l)if(w=l[g],w.name===i.name){if(w.state===Gs)return rh(f);w.state===ih?(w.state=Ks,w.timer.stop(),w.on.call("interrupt",t,t.__data__,w.index,w.group),delete l[g]):+gOa&&l.state=0&&(r=r.slice(0,i)),!r||r==="start"})}function jx(t,r,i){var l,u,c=Tx(r)?Za:an;return function(){var f=c(this,t),h=f.on;h!==l&&(u=(l=h).copy()).on(r,i),f.on=u}}function zx(t,r){var i=this._id;return arguments.length<2?Jt(this.node(),i).on.on(t):this.each(jx(i,t,r))}function Rx(t){return function(){var r=this.parentNode;for(var i in this.__transition)if(+i!==t)return;r&&r.removeChild(this)}}function Lx(){return this.on("end.remove",Rx(this._id))}function Ax(t){var r=this._name,i=this._id;typeof t!="function"&&(t=Xa(t));for(var l=this._groups,u=l.length,c=new Array(u),f=0;f()=>t;function sw(t,{sourceEvent:r,target:i,transform:l,dispatch:u}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},transform:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}function Sn(t,r,i){this.k=t,this.x=r,this.y=i}Sn.prototype={constructor:Sn,scale:function(t){return t===1?this:new Sn(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new Sn(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 pl=new Sn(1,0,0);Ip.prototype=Sn.prototype;function Ip(t){for(;!t.__zoom;)if(!(t=t.parentNode))return pl;return t.__zoom}function Sa(t){t.stopImmediatePropagation()}function ei(t){t.preventDefault(),t.stopImmediatePropagation()}function lw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function uw(){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||pl}function aw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function cw(){return navigator.maxTouchPoints||"ontouchstart"in this}function fw(t,r,i){var l=t.invertX(r[0][0])-i[0][0],u=t.invertX(r[1][0])-i[1][0],c=t.invertY(r[0][1])-i[0][1],f=t.invertY(r[1][1])-i[1][1];return t.translate(u>l?(l+u)/2:Math.min(0,l)||Math.max(0,u),f>c?(c+f)/2:Math.min(0,c)||Math.max(0,f))}function Tp(){var t=lw,r=uw,i=fw,l=aw,u=cw,c=[0,1/0],f=[[-1/0,-1/0],[1/0,1/0]],h=250,p=Qs,y=cl("start","zoom","end"),g,v,m,w=500,S=150,P=0,C=10;function k(N){N.property("__zoom",sh).on("wheel.zoom",X,{passive:!1}).on("mousedown.zoom",G).on("dblclick.zoom",te).filter(u).on("touchstart.zoom",Z).on("touchmove.zoom",ee).on("touchend.zoom touchcancel.zoom",J).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}k.transform=function(N,U,V,b){var A=N.selection?N.selection():N;A.property("__zoom",sh),N!==A?H(N,U,V,b):A.interrupt().each(function(){$(this,arguments).event(b).start().zoom(null,typeof U=="function"?U.apply(this,arguments):U).end()})},k.scaleBy=function(N,U,V,b){k.scaleTo(N,function(){var A=this.__zoom.k,L=typeof U=="function"?U.apply(this,arguments):U;return A*L},V,b)},k.scaleTo=function(N,U,V,b){k.transform(N,function(){var A=r.apply(this,arguments),L=this.__zoom,O=V==null?I(A):typeof V=="function"?V.apply(this,arguments):V,M=L.invert(O),j=typeof U=="function"?U.apply(this,arguments):U;return i(_(z(L,j),O,M),A,f)},V,b)},k.translateBy=function(N,U,V,b){k.transform(N,function(){return i(this.__zoom.translate(typeof U=="function"?U.apply(this,arguments):U,typeof V=="function"?V.apply(this,arguments):V),r.apply(this,arguments),f)},null,b)},k.translateTo=function(N,U,V,b,A){k.transform(N,function(){var L=r.apply(this,arguments),O=this.__zoom,M=b==null?I(L):typeof b=="function"?b.apply(this,arguments):b;return i(pl.translate(M[0],M[1]).scale(O.k).translate(typeof U=="function"?-U.apply(this,arguments):-U,typeof V=="function"?-V.apply(this,arguments):-V),L,f)},b,A)};function z(N,U){return U=Math.max(c[0],Math.min(c[1],U)),U===N.k?N:new Sn(U,N.x,N.y)}function _(N,U,V){var b=U[0]-V[0]*N.k,A=U[1]-V[1]*N.k;return b===N.x&&A===N.y?N:new Sn(N.k,b,A)}function I(N){return[(+N[0][0]+ +N[1][0])/2,(+N[0][1]+ +N[1][1])/2]}function H(N,U,V,b){N.on("start.zoom",function(){$(this,arguments).event(b).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(b).end()}).tween("zoom",function(){var A=this,L=arguments,O=$(A,L).event(b),M=r.apply(A,L),j=V==null?I(M):typeof V=="function"?V.apply(A,L):V,ne=Math.max(M[1][0]-M[0][0],M[1][1]-M[0][1]),re=A.__zoom,ae=typeof U=="function"?U.apply(A,L):U,fe=p(re.invert(j).concat(ne/re.k),ae.invert(j).concat(ne/ae.k));return function(ce){if(ce===1)ce=ae;else{var K=fe(ce),se=ne/K[2];ce=new Sn(se,j[0]-K[0]*se,j[1]-K[1]*se)}O.zoom(null,ce)}})}function $(N,U,V){return!V&&N.__zooming||new B(N,U)}function B(N,U){this.that=N,this.args=U,this.active=0,this.sourceEvent=null,this.extent=r.apply(N,U),this.taps=0}B.prototype={event:function(N){return N&&(this.sourceEvent=N),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(N,U){return this.mouse&&N!=="mouse"&&(this.mouse[1]=U.invert(this.mouse[0])),this.touch0&&N!=="touch"&&(this.touch0[1]=U.invert(this.touch0[0])),this.touch1&&N!=="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(N){var U=Rt(this.that).datum();y.call(N,this.that,new sw(N,{sourceEvent:this.sourceEvent,target:k,transform:this.that.__zoom,dispatch:y}),U)}};function X(N,...U){if(!t.apply(this,arguments))return;var V=$(this,U).event(N),b=this.__zoom,A=Math.max(c[0],Math.min(c[1],b.k*Math.pow(2,l.apply(this,arguments)))),L=Qt(N);if(V.wheel)(V.mouse[0][0]!==L[0]||V.mouse[0][1]!==L[1])&&(V.mouse[1]=b.invert(V.mouse[0]=L)),clearTimeout(V.wheel);else{if(b.k===A)return;V.mouse=[L,b.invert(L)],qs(this),V.start()}ei(N),V.wheel=setTimeout(O,S),V.zoom("mouse",i(_(z(b,A),V.mouse[0],V.mouse[1]),V.extent,f));function O(){V.wheel=null,V.end()}}function G(N,...U){if(m||!t.apply(this,arguments))return;var V=N.currentTarget,b=$(this,U,!0).event(N),A=Rt(N.view).on("mousemove.zoom",j,!0).on("mouseup.zoom",ne,!0),L=Qt(N,V),O=N.clientX,M=N.clientY;hp(N.view),Sa(N),b.mouse=[L,this.__zoom.invert(L)],qs(this),b.start();function j(re){if(ei(re),!b.moved){var ae=re.clientX-O,fe=re.clientY-M;b.moved=ae*ae+fe*fe>P}b.event(re).zoom("mouse",i(_(b.that.__zoom,b.mouse[0]=Qt(re,V),b.mouse[1]),b.extent,f))}function ne(re){A.on("mousemove.zoom mouseup.zoom",null),pp(re.view,b.moved),ei(re),b.event(re).end()}}function te(N,...U){if(t.apply(this,arguments)){var V=this.__zoom,b=Qt(N.changedTouches?N.changedTouches[0]:N,this),A=V.invert(b),L=V.k*(N.shiftKey?.5:2),O=i(_(z(V,L),b,A),r.apply(this,U),f);ei(N),h>0?Rt(this).transition().duration(h).call(H,O,b,N):Rt(this).call(k.transform,O,b,N)}}function Z(N,...U){if(t.apply(this,arguments)){var V=N.touches,b=V.length,A=$(this,U,N.changedTouches.length===b).event(N),L,O,M,j;for(Sa(N),O=0;O`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:i,targetHandle:l})=>`Couldn't create edge for ${t} handle id: "${t==="source"?i:l}", 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.`},ai=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],jp=["Enter"," ","Escape"],zp={"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:i})=>`Moved selected node ${t}. New position, x: ${r}, y: ${i}`,"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 oo;(function(t){t.Strict="strict",t.Loose="loose"})(oo||(oo={}));var yr;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(yr||(yr={}));var ci;(function(t){t.Partial="partial",t.Full="full"})(ci||(ci={}));const Rp={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Xn;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Xn||(Xn={}));var il;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(il||(il={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const lh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function Lp(t){return t===null?null:t?"valid":"invalid"}const Ap=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,dw=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),ec=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),yi=(t,r=[0,0])=>{const{width:i,height:l}=en(t),u=t.origin??r,c=i*u[0],f=l*u[1];return{x:t.position.x-c,y:t.position.y-f}},hw=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let i=!1;const l=t.reduce((u,c)=>{const f=typeof c=="string";let h=!r.nodeLookup&&!f?c:void 0;return r.nodeLookup&&(h=f?r.nodeLookup.get(c):ec(c)?c:r.nodeLookup.get(c.id)),h?(i=!0,gl(u,sl(h,r.nodeOrigin))):u},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return i?ml(l):{x:0,y:0,width:0,height:0}},vi=(t,r={})=>{let i={x:1/0,y:1/0,x2:-1/0,y2:-1/0},l=!1;return t.forEach(u=>{(r.filter===void 0||r.filter(u))&&(i=gl(i,sl(u)),l=!0)}),l?ml(i):{x:0,y:0,width:0,height:0}},tc=(t,r,[i,l,u]=[0,0,1],c=!1,f=!1)=>{const h=(r.x-i)/u,p=(r.y-l)/u,y=r.width/u,g=r.height/u,v=[];for(const m of t.values()){const{measured:w,selectable:S=!0,hidden:P=!1}=m;if(f&&!S||P)continue;const C=w.width??m.width??m.initialWidth??0,k=w.height??m.height??m.initialHeight??0,{x:z,y:_}=m.internals.positionAbsolute,I=Fp(h,p,y,g,z,_,C,k),H=C*k,$=c&&I>0;(!m.internals.handleBounds||$||I>=H||m.dragging)&&v.push(m)}return v},pw=(t,r)=>{const i=new Set;return t.forEach(l=>{i.add(l.id)}),r.filter(l=>i.has(l.source)||i.has(l.target))};function gw(t,r){const i=new Map,l=r!=null&&r.nodes?new Set(r.nodes.map(u=>u.id)):null;return t.forEach(u=>{let c;if(r!=null&&r.includeHiddenNodes){const{width:f,height:h}=en(u);c=f>0&&h>0}else c=!!(u.measured.width&&u.measured.height&&!u.hidden);c&&(!l||l.has(u.id))&&i.set(u.id,u)}),i}async function mw({nodes:t,width:r,height:i,panZoom:l,minZoom:u,maxZoom:c},f){if(t.size===0)return!0;const h=gw(t,f),p=vi(h),y=rc(p,r,i,(f==null?void 0:f.minZoom)??u,(f==null?void 0:f.maxZoom)??c,(f==null?void 0:f.padding)??.1);return await l.setViewport(y,{duration:f==null?void 0:f.duration,ease:f==null?void 0:f.ease,interpolate:f==null?void 0:f.interpolate}),!0}function $p({nodeId:t,nextPosition:r,nodeLookup:i,nodeOrigin:l=[0,0],nodeExtent:u,onError:c}){const f=i.get(t),h=f.parentId?i.get(f.parentId):void 0,{x:p,y}=h?h.internals.positionAbsolute:{x:0,y:0},g=f.origin??l;let v=f.extent||u;if(f.extent==="parent"&&!f.expandParent)if(!h)c==null||c("005",Zt.error005());else{const{width:w,height:S}=en(h);w&&S&&(v=[[p,y],[p+w,y+S]])}else h&&Sr(f.extent)&&(v=[[f.extent[0][0]+p,f.extent[0][1]+y],[f.extent[1][0]+p,f.extent[1][1]+y]]);const m=Sr(v)?wr(r,v,f.measured):r;return(f.measured.width===void 0||f.measured.height===void 0)&&(c==null||c("015",Zt.error015())),{position:{x:m.x-p+(f.measured.width??0)*g[0],y:m.y-y+(f.measured.height??0)*g[1]},positionAbsolute:m}}async function yw({nodesToRemove:t=[],edgesToRemove:r=[],nodes:i,edges:l,onBeforeDelete:u}){const c=new Set(t.map(m=>m.id)),f=[];for(const m of i){if(m.deletable===!1)continue;const w=c.has(m.id),S=!w&&m.parentId&&f.find(P=>P.id===m.parentId);(w||S)&&f.push(m)}const h=new Set(r.map(m=>m.id)),p=l.filter(m=>m.deletable!==!1),g=pw(f,p);for(const m of p)h.has(m.id)&&!g.find(S=>S.id===m.id)&&g.push(m);if(!u)return{edges:g,nodes:f};const v=await u({nodes:f,edges:g});return typeof v=="boolean"?v?{edges:g,nodes:f}:{edges:[],nodes:[]}:v}const io=(t,r=0,i=1)=>Math.min(Math.max(t,r),i),wr=(t={x:0,y:0},r,i)=>({x:io(t.x,r[0][0],r[1][0]-((i==null?void 0:i.width)??0)),y:io(t.y,r[0][1],r[1][1]-((i==null?void 0:i.height)??0))});function Dp(t,r,i){const{width:l,height:u}=en(i),{x:c,y:f}=i.internals.positionAbsolute;return wr(t,[[c,f],[c+l,f+u]],r)}const uh=(t,r,i)=>ti?-io(Math.abs(t-i),1,r)/r:0,nc=(t,r,i=15,l=40)=>{const u=uh(t.x,l,r.width-l)*i,c=uh(t.y,l,r.height-l)*i;return[u,c]},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)}),Ha=({x:t,y:r,width:i,height:l})=>({x:t,y:r,x2:t+i,y2:r+l}),ml=({x:t,y:r,x2:i,y2:l})=>({x:t,y:r,width:i-t,height:l-r}),fi=(t,r=[0,0])=>{var u,c;const{x:i,y:l}=ec(t)?t.internals.positionAbsolute:yi(t,r);return{x:i,y:l,width:((u=t.measured)==null?void 0:u.width)??t.width??t.initialWidth??0,height:((c=t.measured)==null?void 0:c.height)??t.height??t.initialHeight??0}},sl=(t,r=[0,0])=>{var u,c;const{x:i,y:l}=ec(t)?t.internals.positionAbsolute:yi(t,r);return{x:i,y:l,x2:i+(((u=t.measured)==null?void 0:u.width)??t.width??t.initialWidth??0),y2:l+(((c=t.measured)==null?void 0:c.height)??t.height??t.initialHeight??0)}},Op=(t,r)=>ml(gl(Ha(t),Ha(r))),Fp=(t,r,i,l,u,c,f,h)=>{const p=Math.max(0,Math.min(t+i,u+f)-Math.max(t,u)),y=Math.max(0,Math.min(r+l,c+h)-Math.max(r,c));return Math.ceil(p*y)},ll=(t,r)=>Fp(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),ah=t=>Kt(t.width)&&Kt(t.height)&&Kt(t.x)&&Kt(t.y),Kt=t=>!isNaN(t)&&isFinite(t),Hp=(t,r)=>(i,l)=>{},xi=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),wi=({x:t,y:r},[i,l,u],c=!1,f=[1,1])=>{const h={x:(t-i)/u,y:(r-l)/u};return c?xi(h,f):h},so=({x:t,y:r},[i,l,u])=>({x:t*u+i,y:r*u+l});function Zr(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const i=parseFloat(t);if(!Number.isNaN(i))return Math.floor(i)}if(typeof t=="string"&&t.endsWith("%")){const i=parseFloat(t);if(!Number.isNaN(i))return Math.floor(r*i*.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 vw(t,r,i){if(typeof t=="string"||typeof t=="number"){const l=Zr(t,i),u=Zr(t,r);return{top:l,right:u,bottom:l,left:u,x:u*2,y:l*2}}if(typeof t=="object"){const l=Zr(t.top??t.y??0,i),u=Zr(t.bottom??t.y??0,i),c=Zr(t.left??t.x??0,r),f=Zr(t.right??t.x??0,r);return{top:l,right:f,bottom:u,left:c,x:c+f,y:l+u}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function xw(t,r,i,l,u,c){const{x:f,y:h}=so(t,[r,i,l]),{x:p,y}=so({x:t.x+t.width,y:t.y+t.height},[r,i,l]),g=u-p,v=c-y;return{left:Math.floor(f),top:Math.floor(h),right:Math.floor(g),bottom:Math.floor(v)}}const rc=(t,r,i,l,u,c)=>{const f=vw(c,r,i),h=(r-f.x)/t.width,p=(i-f.y)/t.height,y=Math.min(h,p),g=io(y,l,u),v=t.x+t.width/2,m=t.y+t.height/2,w=r/2-v*g,S=i/2-m*g,P=xw(t,w,S,g,r,i),C={left:Math.min(P.left-f.left,0),top:Math.min(P.top-f.top,0),right:Math.min(P.right-f.right,0),bottom:Math.min(P.bottom-f.bottom,0)};return{x:w-C.left+C.right,y:S-C.top+C.bottom,zoom:g}},di=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function Sr(t){return t!=null&&t!=="parent"}function en(t){var r,i;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((i=t.measured)==null?void 0:i.height)??t.height??t.initialHeight??0}}function Vp(t){var r,i;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((i=t.measured)==null?void 0:i.height)??t.height??t.initialHeight)!==void 0}function Bp(t,r={width:0,height:0},i,l,u){const c={...t},f=l.get(i);if(f){const h=f.origin||u;c.x+=f.internals.positionAbsolute.x-(r.width??0)*h[0],c.y+=f.internals.positionAbsolute.y-(r.height??0)*h[1]}return c}function ch(t,r){if(t.size!==r.size)return!1;for(const i of t)if(!r.has(i))return!1;return!0}function ww(){let t,r;return{promise:new Promise((l,u)=>{t=l,r=u}),resolve:t,reject:r}}function Sw(t){return{...zp,...t||{}}}function oi(t,{snapGrid:r=[0,0],snapToGrid:i=!1,transform:l,containerBounds:u}){const{x:c,y:f}=qt(t),h=wi({x:c-((u==null?void 0:u.left)??0),y:f-((u==null?void 0:u.top)??0)},l),{x:p,y}=i?xi(h,r):h;return{xSnapped:p,ySnapped:y,...h}}const oc=t=>({width:t.offsetWidth,height:t.offsetHeight}),bp=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},_w=["INPUT","SELECT","TEXTAREA"];function Up(t){var l,u;const r=((u=(l=t.composedPath)==null?void 0:l.call(t))==null?void 0:u[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:_w.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const Wp=t=>"clientX"in t,qt=(t,r)=>{var c,f;const i=Wp(t),l=i?t.clientX:(c=t.touches)==null?void 0:c[0].clientX,u=i?t.clientY:(f=t.touches)==null?void 0:f[0].clientY;return{x:l-((r==null?void 0:r.left)??0),y:u-((r==null?void 0:r.top)??0)}},fh=(t,r,i,l,u)=>{const c=r.querySelectorAll(`.${t}`);return!c||!c.length?null:Array.from(c).map(f=>{const h=f.getBoundingClientRect();return{id:f.getAttribute("data-handleid"),type:t,nodeId:u,position:f.getAttribute("data-handlepos"),x:(h.left-i.left)/l,y:(h.top-i.top)/l,...oc(f)}})};function Yp({sourceX:t,sourceY:r,targetX:i,targetY:l,sourceControlX:u,sourceControlY:c,targetControlX:f,targetControlY:h}){const p=t*.125+u*.375+f*.375+i*.125,y=r*.125+c*.375+h*.375+l*.125,g=Math.abs(p-t),v=Math.abs(y-r);return[p,y,g,v]}function bs(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function dh({pos:t,x1:r,y1:i,x2:l,y2:u,c}){switch(t){case Se.Left:return[r-bs(r-l,c),i];case Se.Right:return[r+bs(l-r,c),i];case Se.Top:return[r,i-bs(i-u,c)];case Se.Bottom:return[r,i+bs(u-i,c)]}}function Xp({sourceX:t,sourceY:r,sourcePosition:i=Se.Bottom,targetX:l,targetY:u,targetPosition:c=Se.Top,curvature:f=.25}){const[h,p]=dh({pos:i,x1:t,y1:r,x2:l,y2:u,c:f}),[y,g]=dh({pos:c,x1:l,y1:u,x2:t,y2:r,c:f}),[v,m,w,S]=Yp({sourceX:t,sourceY:r,targetX:l,targetY:u,sourceControlX:h,sourceControlY:p,targetControlX:y,targetControlY:g});return[`M${t},${r} C${h},${p} ${y},${g} ${l},${u}`,v,m,w,S]}function Qp({sourceX:t,sourceY:r,targetX:i,targetY:l}){const u=Math.abs(i-t)/2,c=i0}const Nw=({source:t,sourceHandle:r,target:i,targetHandle:l})=>`xy-edge__${t}${r||""}-${i}${l||""}`,Cw=(t,r)=>r.some(i=>i.source===t.source&&i.target===t.target&&(i.sourceHandle===t.sourceHandle||!i.sourceHandle&&!t.sourceHandle)&&(i.targetHandle===t.targetHandle||!i.targetHandle&&!t.targetHandle)),Mw=(t,r,i={})=>{var c;if(!t.source||!t.target)return(c=i.onError)==null||c.call(i,"006",Zt.error006()),r;const l=i.getEdgeId||Nw;let u;return Ap(t)?u={...t}:u={...t,id:l(t)},Cw(u,r)?r:(u.sourceHandle===null&&delete u.sourceHandle,u.targetHandle===null&&delete u.targetHandle,r.concat(u))};function Gp({sourceX:t,sourceY:r,targetX:i,targetY:l}){const[u,c,f,h]=Qp({sourceX:t,sourceY:r,targetX:i,targetY:l});return[`M ${t},${r}L ${i},${l}`,u,c,f,h]}const hh={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},Pw=({source:t,sourcePosition:r=Se.Bottom,target:i})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function Iw({source:t,sourcePosition:r=Se.Bottom,target:i,targetPosition:l=Se.Top,center:u,offset:c,stepPosition:f}){const h=hh[r],p=hh[l],y={x:t.x+h.x*c,y:t.y+h.y*c},g={x:i.x+p.x*c,y:i.y+p.y*c},v=Pw({source:y,sourcePosition:r,target:g}),m=v.x!==0?"x":"y",w=v[m];let S=[],P,C;const k={x:0,y:0},z={x:0,y:0},[,,_,I]=Qp({sourceX:t.x,sourceY:t.y,targetX:i.x,targetY:i.y});if(h[m]*p[m]===-1){m==="x"?(P=u.x??y.x+(g.x-y.x)*f,C=u.y??(y.y+g.y)/2):(P=u.x??(y.x+g.x)/2,C=u.y??y.y+(g.y-y.y)*f);const X=[{x:P,y:y.y},{x:P,y:g.y}],G=[{x:y.x,y:C},{x:g.x,y:C}];h[m]===w?S=m==="x"?X:G:S=m==="x"?G:X}else{const X=[{x:y.x,y:g.y}],G=[{x:g.x,y:y.y}];if(m==="x"?S=h.x===w?G:X:S=h.y===w?X:G,r===l){const N=Math.abs(t[m]-i[m]);if(N<=c){const U=Math.min(c-1,c-N);h[m]===w?k[m]=(y[m]>t[m]?-1:1)*U:z[m]=(g[m]>i[m]?-1:1)*U}}if(r!==l){const N=m==="x"?"y":"x",U=h[m]===p[N],V=y[N]>g[N],b=y[N]=J?(P=(te.x+Z.x)/2,C=S[0].y):(P=S[0].x,C=(te.y+Z.y)/2)}const H={x:y.x+k.x,y:y.y+k.y},$={x:g.x+z.x,y:g.y+z.y};return[[t,...H.x!==S[0].x||H.y!==S[0].y?[H]:[],...S,...$.x!==S[S.length-1].x||$.y!==S[S.length-1].y?[$]:[],i],P,C,_,I]}function Tw(t,r,i,l){const u=Math.min(ph(t,r)/2,ph(r,i)/2,l),{x:c,y:f}=r;if(t.x===c&&c===i.x||t.y===f&&f===i.y)return`L${c} ${f}`;if(t.y===f){const y=t.xi.id===r):t[0])||null}function Ba(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(l=>`${l}=${t[l]}`).join("&")}`:""}function zw(t,{id:r,defaultColor:i,defaultMarkerStart:l,defaultMarkerEnd:u}){const c=new Set;return t.reduce((f,h)=>([h.markerStart||l,h.markerEnd||u].forEach(p=>{if(p&&typeof p=="object"){const y=Ba(p,r);c.has(y)||(f.push({id:y,color:p.color||i,...p}),c.add(y))}}),f),[]).sort((f,h)=>f.id.localeCompare(h.id))}const Kp=1e3,Rw=10,ic={nodeOrigin:[0,0],nodeExtent:ai,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Lw={...ic,checkEquality:!0};function sc(t,r){const i={...t};for(const l in r)r[l]!==void 0&&(i[l]=r[l]);return i}function Aw(t,r,i){const l=sc(ic,i);for(const u of t.values())if(u.parentId)uc(u,t,r,l);else{const c=yi(u,l.nodeOrigin),f=Sr(u.extent)?u.extent:l.nodeExtent,h=wr(c,f,en(u));u.internals.positionAbsolute=h}}function $w(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const i=[],l=[];for(const u of t.handles){const c={id:u.id,width:u.width??1,height:u.height??1,nodeId:t.id,x:u.x,y:u.y,position:u.position,type:u.type};u.type==="source"?i.push(c):u.type==="target"&&l.push(c)}return{source:i,target:l}}function lc(t){return t==="manual"}function ba(t,r,i,l={}){var g,v;const u=sc(Lw,l),c={i:0},f=new Map(r),h=u!=null&&u.elevateNodesOnSelect&&!lc(u.zIndexMode)?Kp:0;let p=t.length>0,y=!1;r.clear(),i.clear();for(const m of t){let w=f.get(m.id);if(u.checkEquality&&m===(w==null?void 0:w.internals.userNode))r.set(m.id,w);else{const S=yi(m,u.nodeOrigin),P=Sr(m.extent)?m.extent:u.nodeExtent,C=wr(S,P,en(m));w={...u.defaults,...m,measured:{width:(g=m.measured)==null?void 0:g.width,height:(v=m.measured)==null?void 0:v.height},internals:{positionAbsolute:C,handleBounds:$w(m,w),z:qp(m,h,u.zIndexMode),userNode:m}},r.set(m.id,w)}(w.measured===void 0||w.measured.width===void 0||w.measured.height===void 0)&&!w.hidden&&(p=!1),m.parentId&&uc(w,r,i,l,c),y||(y=m.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:y}}function Dw(t,r){if(!t.parentId)return;const i=r.get(t.parentId);i?i.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function uc(t,r,i,l,u){const{elevateNodesOnSelect:c,nodeOrigin:f,nodeExtent:h,zIndexMode:p}=sc(ic,l),y=t.parentId,g=r.get(y);if(!g){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}Dw(t,i),u&&!g.parentId&&g.internals.rootParentIndex===void 0&&p==="auto"&&(g.internals.rootParentIndex=++u.i,g.internals.z=g.internals.z+u.i*Rw),u&&g.internals.rootParentIndex!==void 0&&(u.i=g.internals.rootParentIndex);const v=c&&!lc(p)?Kp:0,{x:m,y:w,z:S}=Ow(t,g,f,h,v,p),{positionAbsolute:P}=t.internals,C=m!==P.x||w!==P.y;(C||S!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:C?{x:m,y:w}:P,z:S}})}function qp(t,r,i){const l=Kt(t.zIndex)?t.zIndex:0;return lc(i)?l:l+(t.selected?r:0)}function Ow(t,r,i,l,u,c){const{x:f,y:h}=r.internals.positionAbsolute,p=en(t),y=yi(t,i),g=Sr(t.extent)?wr(y,t.extent,p):y;let v=wr({x:f+g.x,y:h+g.y},l,p);t.extent==="parent"&&(v=Dp(v,p,r));const m=qp(t,u,c),w=r.internals.z??0;return{x:v.x,y:v.y,z:w>=m?w+1:m}}function ac(t,r,i,l=[0,0]){var f;const u=[],c=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const y=((f=c.get(h.parentId))==null?void 0:f.expandedRect)??fi(p),g=Op(y,h.rect);c.set(h.parentId,{expandedRect:g,parent:p})}return c.size>0&&c.forEach(({expandedRect:h,parent:p},y)=>{var _;const g=p.internals.positionAbsolute,v=en(p),m=p.origin??l,w=h.x0||S>0||k||z)&&(u.push({id:y,type:"position",position:{x:p.position.x-w+k,y:p.position.y-S+z}}),(_=i.get(y))==null||_.forEach(I=>{t.some(H=>H.id===I.id)||u.push({id:I.id,type:"position",position:{x:I.position.x+w,y:I.position.y+S}})})),(v.width0){const w=ac(m,r,i,u);y.push(...w)}return{changes:y,updatedInternals:p}}async function Hw({delta:t,panZoom:r,transform:i,translateExtent:l,width:u,height:c}){if(!r||!t.x&&!t.y)return!1;const f=await r.setViewportConstrained({x:i[0]+t.x,y:i[1]+t.y,zoom:i[2]},[[0,0],[u,c]],l);return!!f&&(f.x!==i[0]||f.y!==i[1]||f.k!==i[2])}function vh(t,r,i,l,u,c){let f=u;const h=l.get(f)||new Map;l.set(f,h.set(i,r)),f=`${u}-${t}`;const p=l.get(f)||new Map;if(l.set(f,p.set(i,r)),c){f=`${u}-${t}-${c}`;const y=l.get(f)||new Map;l.set(f,y.set(i,r))}}function Zp(t,r,i){t.clear(),r.clear();for(const l of i){const{source:u,target:c,sourceHandle:f=null,targetHandle:h=null}=l,p={edgeId:l.id,source:u,target:c,sourceHandle:f,targetHandle:h},y=`${u}-${f}--${c}-${h}`,g=`${c}-${h}--${u}-${f}`;vh("source",p,g,t,u,f),vh("target",p,y,t,c,h),r.set(l.id,l)}}function Jp(t,r){if(!t.parentId)return!1;const i=r.get(t.parentId);return i?i.selected?!0:Jp(i,r):!1}function xh(t,r,i){var u;let l=t;do{if((u=l==null?void 0:l.matches)!=null&&u.call(l,r))return!0;if(l===i)return!1;l=l==null?void 0:l.parentElement}while(l);return!1}function Vw(t,r,i,l){const u=new Map;for(const[c,f]of t)if((f.selected||f.id===l)&&(!f.parentId||!Jp(f,t))&&(f.draggable||r&&typeof f.draggable>"u")){const h=t.get(c);h&&u.set(c,{id:c,position:h.position||{x:0,y:0},distance:{x:i.x-h.internals.positionAbsolute.x,y:i.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 u}function _a({nodeId:t,dragItems:r,nodeLookup:i,dragging:l=!0}){var f,h,p;const u=[];for(const[y,g]of r){const v=(f=i.get(y))==null?void 0:f.internals.userNode;v&&u.push({...v,position:g.position,dragging:l})}if(!t)return[u[0],u];const c=(h=i.get(t))==null?void 0:h.internals.userNode;return[c?{...c,position:((p=r.get(t))==null?void 0:p.position)||c.position,dragging:l}:u[0],u]}function Bw({dragItems:t,snapGrid:r,x:i,y:l}){const u=t.values().next().value;if(!u)return null;const c={x:i-u.distance.x,y:l-u.distance.y},f=xi(c,r);return{x:f.x-c.x,y:f.y-c.y}}function bw({onNodeMouseDown:t,getStoreItems:r,onDragStart:i,onDrag:l,onDragStop:u}){let c={x:null,y:null},f=0,h=new Map,p=!1,y={x:0,y:0},g=null,v=!1,m=null,w=!1,S=!1,P=null;function C({noDragClassName:z,handleSelector:_,domNode:I,isSelectable:H,nodeId:$,nodeClickDistance:B=0}){m=Rt(I);function X({x:ee,y:J}){const{nodeLookup:N,nodeExtent:U,snapGrid:V,snapToGrid:b,nodeOrigin:A,onNodeDrag:L,onSelectionDrag:O,onError:M,updateNodePositions:j}=r();c={x:ee,y:J};let ne=!1;const re=h.size>1,ae=re&&U?Ha(vi(h)):null,fe=re&&b?Bw({dragItems:h,snapGrid:V,x:ee,y:J}):null;for(const[ce,K]of h){if(!N.has(ce))continue;let se={x:ee-K.distance.x,y:J-K.distance.y};b&&(se=fe?{x:Math.round(se.x+fe.x),y:Math.round(se.y+fe.y)}:xi(se,V));let pe=null;if(re&&U&&!K.extent&&ae){const{positionAbsolute:me}=K.internals,Ne=me.x-ae.x+U[0][0],Pe=me.x+K.measured.width-ae.x2+U[1][0],Ie=me.y-ae.y+U[0][1],Re=me.y+K.measured.height-ae.y2+U[1][1];pe=[[Ne,Ie],[Pe,Re]]}const{position:we,positionAbsolute:ve}=$p({nodeId:ce,nextPosition:se,nodeLookup:N,nodeExtent:pe||U,nodeOrigin:A,onError:M});ne=ne||K.position.x!==we.x||K.position.y!==we.y,K.position=we,K.internals.positionAbsolute=ve}if(S=S||ne,!!ne&&(j(h,!0),P&&(l||L||!$&&O))){const[ce,K]=_a({nodeId:$,dragItems:h,nodeLookup:N});l==null||l(P,h,ce,K),L==null||L(P,ce,K),$||O==null||O(P,K)}}async function G(){if(!g)return;const{transform:ee,panBy:J,autoPanSpeed:N,autoPanOnNodeDrag:U}=r();if(!U){p=!1,cancelAnimationFrame(f);return}const[V,b]=nc(y,g,N);(V!==0||b!==0)&&(c.x=(c.x??0)-V/ee[2],c.y=(c.y??0)-b/ee[2],await J({x:V,y:b})&&X(c)),f=requestAnimationFrame(G)}function te(ee){var re;const{nodeLookup:J,multiSelectionActive:N,nodesDraggable:U,transform:V,snapGrid:b,snapToGrid:A,selectNodesOnDrag:L,onNodeDragStart:O,onSelectionDragStart:M,unselectNodesAndEdges:j}=r();v=!0,(!L||!H)&&!N&&$&&((re=J.get($))!=null&&re.selected||j()),H&&L&&$&&(t==null||t($));const ne=oi(ee.sourceEvent,{transform:V,snapGrid:b,snapToGrid:A,containerBounds:g});if(c=ne,h=Vw(J,U,ne,$),h.size>0&&(i||O||!$&&M)){const[ae,fe]=_a({nodeId:$,dragItems:h,nodeLookup:J});i==null||i(ee.sourceEvent,h,ae,fe),O==null||O(ee.sourceEvent,ae,fe),$||M==null||M(ee.sourceEvent,fe)}}const Z=gp().clickDistance(B).on("start",ee=>{const{domNode:J,nodeDragThreshold:N,transform:U,snapGrid:V,snapToGrid:b}=r();g=(J==null?void 0:J.getBoundingClientRect())||null,w=!1,S=!1,P=ee.sourceEvent,N===0&&te(ee),c=oi(ee.sourceEvent,{transform:U,snapGrid:V,snapToGrid:b,containerBounds:g}),y=qt(ee.sourceEvent,g)}).on("drag",ee=>{const{autoPanOnNodeDrag:J,transform:N,snapGrid:U,snapToGrid:V,nodeDragThreshold:b,nodeLookup:A}=r(),L=oi(ee.sourceEvent,{transform:N,snapGrid:U,snapToGrid:V,containerBounds:g});if(P=ee.sourceEvent,(ee.sourceEvent.type==="touchmove"&&ee.sourceEvent.touches.length>1||$&&!A.has($))&&(w=!0),!w){if(!p&&J&&v&&(p=!0,G()),!v){const O=qt(ee.sourceEvent,g),M=O.x-y.x,j=O.y-y.y;Math.sqrt(M*M+j*j)>b&&te(ee)}(c.x!==L.xSnapped||c.y!==L.ySnapped)&&h&&v&&(y=qt(ee.sourceEvent,g),X(L))}}).on("end",ee=>{if(!v||w){w&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,v=!1,cancelAnimationFrame(f),h.size>0){const{nodeLookup:J,updateNodePositions:N,onNodeDragStop:U,onSelectionDragStop:V}=r();if(S&&(N(h,!1),S=!1),u||U||!$&&V){const[b,A]=_a({nodeId:$,dragItems:h,nodeLookup:J,dragging:!1});u==null||u(ee.sourceEvent,h,b,A),U==null||U(ee.sourceEvent,b,A),$||V==null||V(ee.sourceEvent,A)}}}).filter(ee=>{const J=ee.target;return!ee.button&&(!z||!xh(J,`.${z}`,I))&&(!_||xh(J,_,I))});m.call(Z)}function k(){m==null||m.on(".drag",null)}return{update:C,destroy:k}}function Uw(t,r,i){const l=[],u={x:t.x-i,y:t.y-i,width:i*2,height:i*2};for(const c of r.values())ll(u,fi(c))>0&&l.push(c);return l}const Ww=250;function Yw(t,r,i,l){var h,p;let u=[],c=1/0;const f=Uw(t,i,r+Ww);for(const y of f){const g=[...((h=y.internals.handleBounds)==null?void 0:h.source)??[],...((p=y.internals.handleBounds)==null?void 0:p.target)??[]];for(const v of g){if(l.nodeId===v.nodeId&&l.type===v.type&&l.id===v.id)continue;const{x:m,y:w}=_r(y,v,v.position,!0),S=Math.sqrt(Math.pow(m-t.x,2)+Math.pow(w-t.y,2));S>r||(S1){const y=l.type==="source"?"target":"source";return u.find(g=>g.type===y)??u[0]}return u[0]}function eg(t,r,i,l,u,c=!1){var y,g,v;const f=l.get(t);if(!f)return null;const h=u==="strict"?(y=f.internals.handleBounds)==null?void 0:y[r]:[...((g=f.internals.handleBounds)==null?void 0:g.source)??[],...((v=f.internals.handleBounds)==null?void 0:v.target)??[]],p=(i?h==null?void 0:h.find(m=>m.id===i):h==null?void 0:h[0])??null;return p&&c?{...p,..._r(f,p,p.position,!0)}:p}function tg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function Xw(t,r){let i=null;return r?i=!0:t&&!r&&(i=!1),i}const ng=()=>!0;function Qw(t,{connectionMode:r,connectionRadius:i,handleId:l,nodeId:u,edgeUpdaterType:c,isTarget:f,domNode:h,nodeLookup:p,lib:y,autoPanOnConnect:g,flowId:v,panBy:m,cancelConnection:w,onConnectStart:S,onConnect:P,onConnectEnd:C,isValidConnection:k=ng,onReconnectEnd:z,updateConnection:_,getTransform:I,getFromHandle:H,autoPanSpeed:$,dragThreshold:B=1,handleDomNode:X}){const G=bp(t.target);let te=0,Z;const{x:ee,y:J}=qt(t),N=tg(c,X),U=h==null?void 0:h.getBoundingClientRect();let V=!1;if(!U||!N)return;const b=eg(u,N,l,p,r);if(!b)return;let A=qt(t,U),L=!1,O=null,M=!1,j=null;function ne(){if(!g||!U)return;const[we,ve]=nc(A,U,$);m({x:we,y:ve}),te=requestAnimationFrame(ne)}const re={...b,nodeId:u,type:N,position:b.position},ae=p.get(u);let ce={inProgress:!0,isValid:null,from:_r(ae,re,Se.Left,!0),fromHandle:re,fromPosition:re.position,fromNode:ae,to:A,toHandle:null,toPosition:lh[re.position],toNode:null,pointer:A};function K(){V=!0,_(ce),S==null||S(t,{nodeId:u,handleId:l,handleType:N})}B===0&&K();function se(we){if(!V){const{x:Re,y:Ze}=qt(we),nt=Re-ee,Qe=Ze-J;if(!(nt*nt+Qe*Qe>B*B))return;K()}if(!H()||!re){pe(we);return}const ve=I();A=qt(we,U),Z=Yw(wi(A,ve,!1,[1,1]),i,p,re),L||(ne(),L=!0);const me=rg(we,{handle:Z,connectionMode:r,fromNodeId:u,fromHandleId:l,fromType:f?"target":"source",isValidConnection:k,doc:G,lib:y,flowId:v,nodeLookup:p});j=me.handleDomNode,O=me.connection,M=Xw(!!Z,me.isValid);const Ne=p.get(u),Pe=Ne?_r(Ne,re,Se.Left,!0):ce.from,Ie={...ce,from:Pe,isValid:M,to:me.toHandle&&M?so({x:me.toHandle.x,y:me.toHandle.y},ve):A,toHandle:me.toHandle,toPosition:M&&me.toHandle?me.toHandle.position:lh[re.position],toNode:me.toHandle?p.get(me.toHandle.nodeId):null,pointer:A};_(Ie),ce=Ie}function pe(we){if(!("touches"in we&&we.touches.length>0)){if(V){(Z||j)&&O&&M&&(P==null||P(O));const{inProgress:ve,...me}=ce,Ne={...me,toPosition:ce.toHandle?ce.toPosition:null};C==null||C(we,Ne),c&&(z==null||z(we,Ne))}w(),cancelAnimationFrame(te),L=!1,M=!1,O=null,j=null,G.removeEventListener("mousemove",se),G.removeEventListener("mouseup",pe),G.removeEventListener("touchmove",se),G.removeEventListener("touchend",pe)}}G.addEventListener("mousemove",se),G.addEventListener("mouseup",pe),G.addEventListener("touchmove",se),G.addEventListener("touchend",pe)}function rg(t,{handle:r,connectionMode:i,fromNodeId:l,fromHandleId:u,fromType:c,doc:f,lib:h,flowId:p,isValidConnection:y=ng,nodeLookup:g}){const v=c==="target",m=r?f.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:w,y:S}=qt(t),P=f.elementFromPoint(w,S),C=P!=null&&P.classList.contains(`${h}-flow__handle`)?P:m,k={handleDomNode:C,isValid:!1,connection:null,toHandle:null};if(C){const z=tg(void 0,C),_=C.getAttribute("data-nodeid"),I=C.getAttribute("data-handleid"),H=C.classList.contains("connectable"),$=C.classList.contains("connectableend");if(!_||!z)return k;const B={source:v?_:l,sourceHandle:v?I:u,target:v?l:_,targetHandle:v?u:I};k.connection=B;const G=H&&$&&(i===oo.Strict?v&&z==="source"||!v&&z==="target":_!==l||I!==u);k.isValid=G&&y(B),k.toHandle=eg(_,z,I,g,i,!0)}return k}const Ua={onPointerDown:Qw,isValid:rg};function Gw({domNode:t,panZoom:r,getTransform:i,getViewScale:l}){const u=Rt(t);function c({translateExtent:h,width:p,height:y,zoomStep:g=1,pannable:v=!0,zoomable:m=!0,inversePan:w=!1}){const S=_=>{if(_.sourceEvent.type!=="wheel"||!r)return;const I=i(),H=_.sourceEvent.ctrlKey&&di()?10:1,$=-_.sourceEvent.deltaY*(_.sourceEvent.deltaMode===1?.05:_.sourceEvent.deltaMode?1:.002)*g,B=I[2]*Math.pow(2,$*H);r.scaleTo(B)};let P=[0,0];const C=_=>{(_.sourceEvent.type==="mousedown"||_.sourceEvent.type==="touchstart")&&(P=[_.sourceEvent.clientX??_.sourceEvent.touches[0].clientX,_.sourceEvent.clientY??_.sourceEvent.touches[0].clientY])},k=_=>{const I=i();if(_.sourceEvent.type!=="mousemove"&&_.sourceEvent.type!=="touchmove"||!r)return;const H=[_.sourceEvent.clientX??_.sourceEvent.touches[0].clientX,_.sourceEvent.clientY??_.sourceEvent.touches[0].clientY],$=[H[0]-P[0],H[1]-P[1]];P=H;const B=l()*Math.max(I[2],Math.log(I[2]))*(w?-1:1),X={x:I[0]-$[0]*B,y:I[1]-$[1]*B},G=[[0,0],[p,y]];r.setViewportConstrained({x:X.x,y:X.y,zoom:I[2]},G,h)},z=Tp().on("start",C).on("zoom",v?k:null).on("zoom.wheel",m?S:null);u.call(z,{})}function f(){u.on("zoom",null)}return{update:c,destroy:f,pointer:Qt}}const yl=t=>({x:t.x,y:t.y,zoom:t.k}),ka=({x:t,y:r,zoom:i})=>pl.translate(t,r).scale(i),Yn=(t,r)=>t.target.closest(`.${r}`),og=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),Kw=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Ea=(t,r=0,i=Kw,l=()=>{})=>{const u=typeof r=="number"&&r>0;return u||l(),u?t.transition().duration(r).ease(i).on("end",l):t},ig=t=>{const r=t.ctrlKey&&di()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function qw({zoomPanValues:t,noWheelClassName:r,d3Selection:i,d3Zoom:l,panOnScrollMode:u,panOnScrollSpeed:c,zoomOnPinch:f,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:y}){return g=>{if(Yn(g,r))return g.ctrlKey&&g.preventDefault(),!1;g.preventDefault(),g.stopImmediatePropagation();const v=i.property("__zoom").k||1;if(g.ctrlKey&&f){const C=Qt(g),k=ig(g),z=v*Math.pow(2,k);l.scaleTo(i,z,C,g);return}const m=g.deltaMode===1?20:1;let w=u===yr.Vertical?0:g.deltaX*m,S=u===yr.Horizontal?0:g.deltaY*m;!di()&&g.shiftKey&&u!==yr.Vertical&&(w=g.deltaY*m,S=0),l.translateBy(i,-(w/v)*c,-(S/v)*c,{internal:!0});const P=yl(i.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(g,P):(t.isPanScrolling=!0,h==null||h(g,P)),t.panScrollTimeout=setTimeout(()=>{y==null||y(g,P),t.isPanScrolling=!1},150)}}function Zw({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:i}){return function(l,u){const c=l.type==="wheel",f=!r&&c&&!l.ctrlKey,h=Yn(l,t);if(l.ctrlKey&&c&&h&&l.preventDefault(),f||h)return null;l.preventDefault(),i.call(this,l,u)}}function Jw({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:i}){return l=>{var c,f,h;if((c=l.sourceEvent)!=null&&c.internal)return;const u=yl(l.transform);t.mouseButton=((f=l.sourceEvent)==null?void 0:f.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=u,((h=l.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),i&&(i==null||i(l.sourceEvent,u))}}function e1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:i,onTransformChange:l,onPanZoom:u}){return c=>{var f,h;t.usedRightMouseButton=!!(i&&og(r,t.mouseButton??0)),(f=c.sourceEvent)!=null&&f.sync||l([c.transform.x,c.transform.y,c.transform.k]),u&&!((h=c.sourceEvent)!=null&&h.internal)&&(u==null||u(c.sourceEvent,yl(c.transform)))}}function t1({zoomPanValues:t,panOnDrag:r,panOnScroll:i,onDraggingChange:l,onPanZoomEnd:u,onPaneContextMenu:c}){return f=>{var h;if(!((h=f.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,c&&og(r,t.mouseButton??0)&&!t.usedRightMouseButton&&f.sourceEvent&&c(f.sourceEvent),t.usedRightMouseButton=!1,l(!1),u)){const p=yl(f.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{u==null||u(f.sourceEvent,p)},i?150:0)}}}function n1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:i,zoomOnPinch:l,panOnDrag:u,panOnScroll:c,zoomOnDoubleClick:f,userSelectionActive:h,noWheelClassName:p,noPanClassName:y,lib:g,connectionInProgress:v}){return m=>{var k;const w=r||i,S=l&&m.ctrlKey,P=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(Yn(m,`${g}-flow__node`)||Yn(m,`${g}-flow__edge`)||Yn(m,`${g}-flow__selection`)||Yn(m,`${g}-flow__nodesselection`)))return!0;if(!u&&!w&&!c&&!f&&!l||h||v&&!P||Yn(m,p)&&P||Yn(m,y)&&(!P||c&&P&&!r)||!l&&m.ctrlKey&&P)return!1;if(!l&&m.type==="touchstart"&&((k=m.touches)==null?void 0:k.length)>1)return m.preventDefault(),!1;if(!w&&!c&&!S&&P||!u&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(u)&&!u.includes(m.button)&&m.type==="mousedown")return!1;const C=Array.isArray(u)&&u.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||P||t)&&C}}function r1({domNode:t,minZoom:r,maxZoom:i,translateExtent:l,viewport:u,onPanZoom:c,onPanZoomStart:f,onPanZoomEnd:h,onDraggingChange:p}){const y={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},g=t.getBoundingClientRect();let v=[[0,0],[g.width,g.height]];const m=typeof ResizeObserver<"u"?new ResizeObserver(J=>{const N=J[0];N&&(v=[[0,0],[N.contentRect.width,N.contentRect.height]])}):null;m==null||m.observe(t);const w=Tp().extent(()=>v).scaleExtent([r,i]).translateExtent(l),S=Rt(t).call(w);I({x:u.x,y:u.y,zoom:io(u.zoom,r,i)},[[0,0],[g.width,g.height]],l);const P=S.on("wheel.zoom"),C=S.on("dblclick.zoom");w.wheelDelta(ig);async function k(J,N){return S?new Promise(U=>{w==null||w.interpolate((N==null?void 0:N.interpolate)==="linear"?ri:Qs).transform(Ea(S,N==null?void 0:N.duration,N==null?void 0:N.ease,()=>U(!0)),J)}):!1}function z({noWheelClassName:J,noPanClassName:N,onPaneContextMenu:U,userSelectionActive:V,panOnScroll:b,panOnDrag:A,panOnScrollMode:L,panOnScrollSpeed:O,preventScrolling:M,zoomOnPinch:j,zoomOnScroll:ne,zoomOnDoubleClick:re,panActivationKeyPressed:ae=!1,zoomActivationKeyPressed:fe,lib:ce,onTransformChange:K,connectionInProgress:se,paneClickDistance:pe,selectionOnDrag:we}){V&&!y.isZoomingOrPanning&&_();const ve=b&&!fe&&!V;w.clickDistance(we?1/0:!Kt(pe)||pe<0?0:pe);const me=ve?qw({zoomPanValues:y,noWheelClassName:J,d3Selection:S,d3Zoom:w,panOnScrollMode:L,panOnScrollSpeed:O,zoomOnPinch:j,onPanZoomStart:f,onPanZoom:c,onPanZoomEnd:h}):Zw({noWheelClassName:J,preventScrolling:M,d3ZoomHandler:P});S.on("wheel.zoom",me,{passive:!1});const Ne=Jw({zoomPanValues:y,onDraggingChange:p,onPanZoomStart:f});w.on("start",Ne);const Pe=e1({zoomPanValues:y,panOnDrag:A,onPaneContextMenu:!!U,onPanZoom:c,onTransformChange:K});w.on("zoom",Pe);const Ie=t1({zoomPanValues:y,panOnDrag:A,panOnScroll:b,onPaneContextMenu:U,onPanZoomEnd:h,onDraggingChange:p});w.on("end",Ie);const Re=n1({panActivationKeyPressed:ae,zoomActivationKeyPressed:fe,panOnDrag:A,zoomOnScroll:ne,panOnScroll:b,zoomOnDoubleClick:re,zoomOnPinch:j,userSelectionActive:V,noPanClassName:N,noWheelClassName:J,lib:ce,connectionInProgress:se});w.filter(Re),re?S.on("dblclick.zoom",C):S.on("dblclick.zoom",null)}function _(){w.on("zoom",null)}async function I(J,N,U){const V=ka(J),b=w==null?void 0:w.constrain()(V,N,U);return b&&await k(b),b}async function H(J,N){const U=ka(J);return await k(U,N),U}function $(J){if(S){const N=ka(J),U=S.property("__zoom");(U.k!==J.zoom||U.x!==J.x||U.y!==J.y)&&(w==null||w.transform(S,N,null,{sync:!0}))}}function B(){const J=S?Ip(S.node()):{x:0,y:0,k:1};return{x:J.x,y:J.y,zoom:J.k}}async function X(J,N){return S?new Promise(U=>{w==null||w.interpolate((N==null?void 0:N.interpolate)==="linear"?ri:Qs).scaleTo(Ea(S,N==null?void 0:N.duration,N==null?void 0:N.ease,()=>U(!0)),J)}):!1}async function G(J,N){return S?new Promise(U=>{w==null||w.interpolate((N==null?void 0:N.interpolate)==="linear"?ri:Qs).scaleBy(Ea(S,N==null?void 0:N.duration,N==null?void 0:N.ease,()=>U(!0)),J)}):!1}function te(J){w==null||w.scaleExtent(J)}function Z(J){w==null||w.translateExtent(J)}function ee(J){const N=!Kt(J)||J<0?0:J;w==null||w.clickDistance(N)}return{update:z,destroy:_,setViewport:H,setViewportConstrained:I,getViewport:B,scaleTo:X,scaleBy:G,setScaleExtent:te,setTranslateExtent:Z,syncViewport:$,setClickDistance:ee}}var lo;(function(t){t.Line="line",t.Handle="handle"})(lo||(lo={}));function o1({width:t,prevWidth:r,height:i,prevHeight:l,affectsX:u,affectsY:c}){const f=t-r,h=i-l,p=[f>0?1:f<0?-1:0,h>0?1:h<0?-1:0];return f&&u&&(p[0]=p[0]*-1),h&&c&&(p[1]=p[1]*-1),p}function wh(t){const r=t.includes("right")||t.includes("left"),i=t.includes("bottom")||t.includes("top"),l=t.includes("left"),u=t.includes("top");return{isHorizontal:r,isVertical:i,affectsX:l,affectsY:u}}function Un(t,r){return Math.max(0,r-t)}function Wn(t,r){return Math.max(0,t-r)}function Us(t,r,i){return Math.max(0,r-t,t-i)}function Sh(t,r){return t?!r:r}function i1(t,r,i,l,u,c,f,h){let{affectsX:p,affectsY:y}=r;const{isHorizontal:g,isVertical:v}=r,m=g&&v,{xSnapped:w,ySnapped:S}=i,{minWidth:P,maxWidth:C,minHeight:k,maxHeight:z}=l,{x:_,y:I,width:H,height:$,aspectRatio:B}=t;let X=Math.floor(g?w-t.pointerX:0),G=Math.floor(v?S-t.pointerY:0);const te=H+(p?-X:X),Z=$+(y?-G:G),ee=-c[0]*H,J=-c[1]*$;let N=Us(te,P,C),U=Us(Z,k,z);if(f){let A=0,L=0;p&&X<0?A=Un(_+X+ee,f[0][0]):!p&&X>0&&(A=Wn(_+te+ee,f[1][0])),y&&G<0?L=Un(I+G+J,f[0][1]):!y&&G>0&&(L=Wn(I+Z+J,f[1][1])),N=Math.max(N,A),U=Math.max(U,L)}if(h){let A=0,L=0;p&&X>0?A=Wn(_+X,h[0][0]):!p&&X<0&&(A=Un(_+te,h[1][0])),y&&G>0?L=Wn(I+G,h[0][1]):!y&&G<0&&(L=Un(I+Z,h[1][1])),N=Math.max(N,A),U=Math.max(U,L)}if(u){if(g){const A=Us(te/B,k,z)*B;if(N=Math.max(N,A),f){let L=0;!p&&!y||p&&!y&&m?L=Wn(I+J+te/B,f[1][1])*B:L=Un(I+J+(p?X:-X)/B,f[0][1])*B,N=Math.max(N,L)}if(h){let L=0;!p&&!y||p&&!y&&m?L=Un(I+te/B,h[1][1])*B:L=Wn(I+(p?X:-X)/B,h[0][1])*B,N=Math.max(N,L)}}if(v){const A=Us(Z*B,P,C)/B;if(U=Math.max(U,A),f){let L=0;!p&&!y||y&&!p&&m?L=Wn(_+Z*B+ee,f[1][0])/B:L=Un(_+(y?G:-G)*B+ee,f[0][0])/B,U=Math.max(U,L)}if(h){let L=0;!p&&!y||y&&!p&&m?L=Un(_+Z*B,h[1][0])/B:L=Wn(_+(y?G:-G)*B,h[0][0])/B,U=Math.max(U,L)}}}G=G+(G<0?U:-U),X=X+(X<0?N:-N),u&&(m?te>Z*B?G=(Sh(p,y)?-X:X)/B:X=(Sh(p,y)?-G:G)*B:g?(G=X/B,y=p):(X=G*B,p=y));const V=p?_+X:_,b=y?I+G:I;return{width:H+(p?-X:X),height:$+(y?-G:G),x:c[0]*X*(p?-1:1)+V,y:c[1]*G*(y?-1:1)+b}}const sg={width:0,height:0,x:0,y:0},s1={...sg,pointerX:0,pointerY:0,aspectRatio:1};function l1(t,r,i){const l=r.position.x+t.position.x,u=r.position.y+t.position.y,c=t.measured.width??0,f=t.measured.height??0,h=i[0]*c,p=i[1]*f;return[[l-h,u-p],[l+c-h,u+f-p]]}function u1({domNode:t,nodeId:r,getStoreItems:i,onChange:l,onEnd:u}){const c=Rt(t);let f={controlDirection:wh("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:g,keepAspectRatio:v,resizeDirection:m,onResizeStart:w,onResize:S,onResizeEnd:P,shouldResize:C}){let k={...sg},z={...s1};f={boundaries:g,resizeDirection:m,keepAspectRatio:v,controlDirection:wh(y)};let _,I=null,H=[],$,B,X,G=!1;const te=gp().on("start",Z=>{const{nodeLookup:ee,transform:J,snapGrid:N,snapToGrid:U,nodeOrigin:V,paneDomNode:b}=i();if(_=ee.get(r),!_)return;I=(b==null?void 0:b.getBoundingClientRect())??null;const{xSnapped:A,ySnapped:L}=oi(Z.sourceEvent,{transform:J,snapGrid:N,snapToGrid:U,containerBounds:I});k={width:_.measured.width??0,height:_.measured.height??0,x:_.position.x??0,y:_.position.y??0},z={...k,pointerX:A,pointerY:L,aspectRatio:k.width/k.height},$=void 0,B=Sr(_.extent)?_.extent:void 0,_.parentId&&(_.extent==="parent"||_.expandParent)&&($=ee.get(_.parentId)),$&&_.extent==="parent"&&(B=[[0,0],[$.measured.width,$.measured.height]]),H=[],X=void 0;for(const[O,M]of ee)if(M.parentId===r&&(H.push({id:O,position:{...M.position},extent:M.extent}),M.extent==="parent"||M.expandParent)){const j=l1(M,_,M.origin??V);X?X=[[Math.min(j[0][0],X[0][0]),Math.min(j[0][1],X[0][1])],[Math.max(j[1][0],X[1][0]),Math.max(j[1][1],X[1][1])]]:X=j}w==null||w(Z,{...k})}).on("drag",Z=>{const{transform:ee,snapGrid:J,snapToGrid:N,nodeOrigin:U}=i(),V=oi(Z.sourceEvent,{transform:ee,snapGrid:J,snapToGrid:N,containerBounds:I}),b=[];if(!_)return;const{x:A,y:L,width:O,height:M}=k,j={},ne=_.origin??U,{width:re,height:ae,x:fe,y:ce}=i1(z,f.controlDirection,V,f.boundaries,f.keepAspectRatio,ne,B,X),K=re!==O,se=ae!==M,pe=fe!==A&&K,we=ce!==L&&se;if(!pe&&!we&&!K&&!se)return;if((pe||we||ne[0]===1||ne[1]===1)&&(j.x=pe?fe:k.x,j.y=we?ce:k.y,k.x=j.x,k.y=j.y,H.length>0)){const Pe=fe-A,Ie=ce-L;for(const Re of H)Re.position={x:Re.position.x-Pe+ne[0]*(re-O),y:Re.position.y-Ie+ne[1]*(ae-M)},b.push(Re)}if((K||se)&&(j.width=K&&(!f.resizeDirection||f.resizeDirection==="horizontal")?re:k.width,j.height=se&&(!f.resizeDirection||f.resizeDirection==="vertical")?ae:k.height,k.width=j.width,k.height=j.height),$&&_.expandParent){const Pe=ne[0]*(j.width??0);j.x&&j.x{G&&(P==null||P(Z,{...k}),u==null||u({...k}),G=!1)});c.call(te)}function p(){c.on(".drag",null)}return{update:h,destroy:p}}var Na={exports:{}},Ca={},Ma={exports:{}},Pa={};/** + * @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 _h;function a1(){if(_h)return Pa;_h=1;var t=pi();function r(v,m){return v===m&&(v!==0||1/v===1/m)||v!==v&&m!==m}var i=typeof Object.is=="function"?Object.is:r,l=t.useState,u=t.useEffect,c=t.useLayoutEffect,f=t.useDebugValue;function h(v,m){var w=m(),S=l({inst:{value:w,getSnapshot:m}}),P=S[0].inst,C=S[1];return c(function(){P.value=w,P.getSnapshot=m,p(P)&&C({inst:P})},[v,w,m]),u(function(){return p(P)&&C({inst:P}),v(function(){p(P)&&C({inst:P})})},[v]),f(w),w}function p(v){var m=v.getSnapshot;v=v.value;try{var w=m();return!i(v,w)}catch{return!0}}function y(v,m){return m()}var g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:h;return Pa.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:g,Pa}var kh;function c1(){return kh||(kh=1,Ma.exports=a1()),Ma.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 Eh;function f1(){if(Eh)return Ca;Eh=1;var t=pi(),r=c1();function i(y,g){return y===g&&(y!==0||1/y===1/g)||y!==y&&g!==g}var l=typeof Object.is=="function"?Object.is:i,u=r.useSyncExternalStore,c=t.useRef,f=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Ca.useSyncExternalStoreWithSelector=function(y,g,v,m,w){var S=c(null);if(S.current===null){var P={hasValue:!1,value:null};S.current=P}else P=S.current;S=h(function(){function k($){if(!z){if(z=!0,_=$,$=m($),w!==void 0&&P.hasValue){var B=P.value;if(w(B,$))return I=B}return I=$}if(B=I,l(_,$))return B;var X=m($);return w!==void 0&&w(B,X)?(_=$,B):(_=$,I=X)}var z=!1,_,I,H=v===void 0?null:v;return[function(){return k(g())},H===null?void 0:function(){return k(H())}]},[g,v,m,w]);var C=u(y,S[0],S[1]);return f(function(){P.hasValue=!0,P.value=C},[C]),p(C),C},Ca}var Nh;function d1(){return Nh||(Nh=1,Na.exports=f1()),Na.exports}var h1=d1();const p1=Jh(h1),g1={},Ch=t=>{let r;const i=new Set,l=(g,v)=>{const m=typeof g=="function"?g(r):g;if(!Object.is(m,r)){const w=r;r=v??(typeof m!="object"||m===null)?m:Object.assign({},r,m),i.forEach(S=>S(r,w))}},u=()=>r,p={setState:l,getState:u,getInitialState:()=>y,subscribe:g=>(i.add(g),()=>i.delete(g)),destroy:()=>{(g1?"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."),i.clear()}},y=r=t(l,u,p);return p},m1=t=>t?Ch(t):Ch,{useDebugValue:y1}=M0,{useSyncExternalStoreWithSelector:v1}=p1,x1=t=>t;function lg(t,r=x1,i){const l=v1(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,i);return y1(l),l}const Mh=(t,r)=>{const i=m1(t),l=(u,c=r)=>lg(i,u,c);return Object.assign(l,i),l},w1=(t,r)=>t?Mh(t,r):Mh;function be(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[l,u]of t)if(!Object.is(u,r.get(l)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const l of t)if(!r.has(l))return!1;return!0}const i=Object.keys(t);if(i.length!==Object.keys(r).length)return!1;for(const l of i)if(!Object.prototype.hasOwnProperty.call(r,l)||!Object.is(t[l],r[l]))return!1;return!0}ep();const vl=Q.createContext(null),S1=vl.Provider,ug=Zt.error001("react");function je(t,r){const i=Q.useContext(vl);if(i===null)throw new Error(ug);return lg(i,t,r)}function Oe(){const t=Q.useContext(vl);if(t===null)throw new Error(ug);return Q.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Ph={display:"none"},_1={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",cg="react-flow__edge-desc",k1="react-flow__aria-live",E1=t=>t.ariaLiveMessage,N1=t=>t.ariaLabelConfig;function C1({rfId:t}){const r=je(E1);return E.jsx("div",{id:`${k1}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:_1,children:r})}function M1({rfId:t,disableKeyboardA11y:r}){const i=je(N1);return E.jsxs(E.Fragment,{children:[E.jsx("div",{id:`${ag}-${t}`,style:Ph,children:r?i["node.a11yDescription.default"]:i["node.a11yDescription.keyboardDisabled"]}),E.jsx("div",{id:`${cg}-${t}`,style:Ph,children:i["edge.a11yDescription.default"]}),!r&&E.jsx(C1,{rfId:t})]})}const xl=Q.forwardRef(({position:t="top-left",children:r,className:i,style:l,...u},c)=>{const f=`${t}`.split("-");return E.jsx("div",{className:Xe(["react-flow__panel",i,...f]),style:l,ref:c,...u,children:r})});xl.displayName="Panel";const Ih="https://reactflow.dev?utm_source=attribution";function P1({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:E.jsx(xl,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Ih}`,children:E.jsx("a",{href:Ih,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const I1=t=>{const r=[],i=[];for(const[,l]of t.nodeLookup)l.selected&&r.push(l.internals.userNode);for(const[,l]of t.edgeLookup)l.selected&&i.push(l);return{selectedNodes:r,selectedEdges:i}},Ws=t=>t.id;function T1(t,r){return be(t.selectedNodes.map(Ws),r.selectedNodes.map(Ws))&&be(t.selectedEdges.map(Ws),r.selectedEdges.map(Ws))}function j1({onSelectionChange:t}){const r=Oe(),{selectedNodes:i,selectedEdges:l}=je(I1,T1);return Q.useEffect(()=>{const u={nodes:i,edges:l};t==null||t(u),r.getState().onSelectionChangeHandlers.forEach(c=>c(u))},[i,l,t]),null}const z1=t=>!!t.onSelectionChangeHandlers;function R1({onSelectionChange:t}){const r=je(z1);return t||r?E.jsx(j1,{onSelectionChange:t}):null}const fg=[0,0],L1={x:0,y:0,zoom:1},A1=["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"],Th=[...A1,"rfId"],$1=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}),jh={translateExtent:ai,nodeOrigin:fg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function D1(t){const{setNodes:r,setEdges:i,setMinZoom:l,setMaxZoom:u,setTranslateExtent:c,setNodeExtent:f,reset:h,setDefaultNodesAndEdges:p}=je($1,be),y=Oe();Q.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{g.current=jh,h()}),[]);const g=Q.useRef(jh);return Q.useEffect(()=>{for(const v of Th){const m=t[v],w=g.current[v];m!==w&&(typeof t[v]>"u"||(v==="nodes"?r(m):v==="edges"?i(m):v==="minZoom"?l(m):v==="maxZoom"?u(m):v==="translateExtent"?c(m):v==="nodeExtent"?f(m):v==="ariaLabelConfig"?y.setState({ariaLabelConfig:Sw(m)}):v==="fitView"?y.setState({fitViewQueued:m}):v==="fitViewOptions"?y.setState({fitViewOptions:m}):y.setState({[v]:m})))}g.current=t},Th.map(v=>t[v])),null}function zh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function O1(t){var l;const[r,i]=Q.useState(t==="system"?null:t);return Q.useEffect(()=>{if(t!=="system"){i(t);return}const u=zh(),c=()=>i(u!=null&&u.matches?"dark":"light");return c(),u==null||u.addEventListener("change",c),()=>{u==null||u.removeEventListener("change",c)}},[t]),r!==null?r:(l=zh())!=null&&l.matches?"dark":"light"}const Rh=typeof document<"u"?document:null;function hi(t=null,r={target:Rh,actInsideInputWithModifier:!0}){const[i,l]=Q.useState(!1),u=Q.useRef(!1),c=Q.useRef(new Set([])),[f,h]=Q.useMemo(()=>{if(t!==null){const y=(Array.isArray(t)?t:[t]).filter(v=>typeof v=="string").map(v=>v.replace(/\+/g,` +`).replace(` + +`,` ++`).split(` +`)),g=y.reduce((v,m)=>v.concat(...m),[]);return[y,g]}return[[],[]]},[t]);return Q.useEffect(()=>{const p=(r==null?void 0:r.target)??Rh,y=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const g=w=>{var C,k;if(u.current=w.ctrlKey||w.metaKey||w.shiftKey||w.altKey,(!u.current||u.current&&!y)&&Up(w))return!1;const P=Ah(w.code,h);if(c.current.add(w[P]),Lh(f,c.current,!1)){const z=((k=(C=w.composedPath)==null?void 0:C.call(w))==null?void 0:k[0])||w.target,_=(z==null?void 0:z.nodeName)==="BUTTON"||(z==null?void 0:z.nodeName)==="A";r.preventDefault!==!1&&(u.current||!_)&&w.preventDefault(),l(!0)}},v=w=>{const S=Ah(w.code,h);Lh(f,c.current,!0)?(l(!1),c.current.clear()):c.current.delete(w[S]),w.key==="Meta"&&c.current.clear(),u.current=!1},m=()=>{c.current.clear(),l(!1)};return p==null||p.addEventListener("keydown",g),p==null||p.addEventListener("keyup",v),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{p==null||p.removeEventListener("keydown",g),p==null||p.removeEventListener("keyup",v),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,l]),i}function Lh(t,r,i){return t.filter(l=>i||l.length===r.size).some(l=>l.every(u=>r.has(u)))}function Ah(t,r){return r.includes(t)?"code":"key"}const F1=()=>{const t=Oe();return Q.useMemo(()=>({zoomIn:async r=>{const{panZoom:i}=t.getState();return i?i.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:i}=t.getState();return i?i.scaleBy(1/1.2,r):!1},zoomTo:async(r,i)=>{const{panZoom:l}=t.getState();return l?l.scaleTo(r,i):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,i)=>{const{transform:[l,u,c],panZoom:f}=t.getState();return f?(await f.setViewport({x:r.x??l,y:r.y??u,zoom:r.zoom??c},i),!0):!1},getViewport:()=>{const[r,i,l]=t.getState().transform;return{x:r,y:i,zoom:l}},setCenter:async(r,i,l)=>t.getState().setCenter(r,i,l),fitBounds:async(r,i)=>{const{width:l,height:u,minZoom:c,maxZoom:f,panZoom:h}=t.getState(),p=rc(r,l,u,c,f,(i==null?void 0:i.padding)??.1);return h?(await h.setViewport(p,{duration:i==null?void 0:i.duration,ease:i==null?void 0:i.ease,interpolate:i==null?void 0:i.interpolate}),!0):!1},screenToFlowPosition:(r,i={})=>{const{transform:l,snapGrid:u,snapToGrid:c,domNode:f}=t.getState();if(!f)return r;const{x:h,y:p}=f.getBoundingClientRect(),y={x:r.x-h,y:r.y-p},g=i.snapGrid??u,v=i.snapToGrid??c;return wi(y,l,v,g)},flowToScreenPosition:r=>{const{transform:i,domNode:l}=t.getState();if(!l)return r;const{x:u,y:c}=l.getBoundingClientRect(),f=so(r,i);return{x:f.x+u,y:f.y+c}}}),[])};function dg(t,r){const i=[],l=new Map,u=[];for(const c of t)if(c.type==="add"){u.push(c);continue}else if(c.type==="remove"||c.type==="replace")l.set(c.id,[c]);else{const f=l.get(c.id);f?f.push(c):l.set(c.id,[c])}for(const c of r){const f=l.get(c.id);if(!f){i.push(c);continue}if(f[0].type==="remove")continue;if(f[0].type==="replace"){i.push({...f[0].item});continue}const h={...c};for(const p of f)H1(p,h);i.push(h)}return u.length&&u.forEach(c=>{c.index!==void 0?i.splice(c.index,0,{...c.item}):i.push({...c.item})}),i}function H1(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 V1(t,r){return dg(t,r)}function B1(t,r){return dg(t,r)}function pr(t,r){return{id:t,type:"select",selected:r}}function Jr(t,r=new Set,i=!1){const l=[];for(const[u,c]of t){const f=r.has(u);!(c.selected===void 0&&!f)&&c.selected!==f&&(i&&(c.selected=f),l.push(pr(c.id,f)))}return l}function $h({items:t=[],lookup:r}){var u;const i=[],l=new Map(t.map(c=>[c.id,c]));for(const[c,f]of t.entries()){const h=r.get(f.id),p=((u=h==null?void 0:h.internals)==null?void 0:u.userNode)??h;p!==void 0&&p!==f&&i.push({id:f.id,item:f,type:"replace"}),p===void 0&&i.push({item:f,type:"add",index:c})}for(const[c]of r)l.get(c)===void 0&&i.push({id:c,type:"remove"});return i}function Dh(t){return{id:t.id,type:"remove"}}const b1=Hp();function U1(t,r,i={}){return Mw(t,r,{...i,onError:i.onError??b1})}const Oh=t=>dw(t),W1=t=>Ap(t);function hg(t){return Q.forwardRef(t)}const pg=typeof window<"u"?Q.useLayoutEffect:Q.useEffect;function Fh(t){const[r,i]=Q.useState(BigInt(0)),[l]=Q.useState(()=>Y1(()=>i(u=>u+BigInt(1))));return pg(()=>{const u=l.get();u.length&&(t(u),l.reset())},[r]),l}function Y1(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:i=>{r.push(i),t()}}}const gg=Q.createContext(null);function X1({children:t}){const r=Oe(),i=Q.useCallback(h=>{const{nodes:p=[],setNodes:y,hasDefaultNodes:g,onNodesChange:v,nodeLookup:m,fitViewQueued:w,onNodesChangeMiddlewareMap:S}=r.getState();let P=p;for(const k of h)P=typeof k=="function"?k(P):k;let C=$h({items:P,lookup:m});for(const k of S.values())C=k(C);g&&y(P),C.length>0?v==null||v(C):w&&window.requestAnimationFrame(()=>{const{fitViewQueued:k,nodes:z,setNodes:_}=r.getState();k&&_(z)})},[]),l=Fh(i),u=Q.useCallback(h=>{const{edges:p=[],setEdges:y,hasDefaultEdges:g,onEdgesChange:v,edgeLookup:m}=r.getState();let w=p;for(const S of h)w=typeof S=="function"?S(w):S;g?y(w):v&&v($h({items:w,lookup:m}))},[]),c=Fh(u),f=Q.useMemo(()=>({nodeQueue:l,edgeQueue:c}),[]);return E.jsx(gg.Provider,{value:f,children:t})}function Q1(){const t=Q.useContext(gg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const G1=t=>!!t.panZoom;function cc(){const t=F1(),r=Oe(),i=Q1(),l=je(G1),u=Q.useMemo(()=>{const c=v=>r.getState().nodeLookup.get(v),f=v=>{i.nodeQueue.push(v)},h=v=>{i.edgeQueue.push(v)},p=v=>{var k,z;const{nodeLookup:m,nodeOrigin:w}=r.getState(),S=Oh(v)?v:m.get(v.id),P=S.parentId?Bp(S.position,S.measured,S.parentId,m,w):S.position,C={...S,position:P,width:((k=S.measured)==null?void 0:k.width)??S.width,height:((z=S.measured)==null?void 0:z.height)??S.height};return fi(C)},y=(v,m,w={replace:!1})=>{f(S=>S.map(P=>{if(P.id===v){const C=typeof m=="function"?m(P):m;return w.replace&&Oh(C)?C:{...P,...C}}return P}))},g=(v,m,w={replace:!1})=>{h(S=>S.map(P=>{if(P.id===v){const C=typeof m=="function"?m(P):m;return w.replace&&W1(C)?C:{...P,...C}}return P}))};return{getNodes:()=>r.getState().nodes.map(v=>({...v})),getNode:v=>{var m;return(m=c(v))==null?void 0:m.internals.userNode},getInternalNode:c,getEdges:()=>{const{edges:v=[]}=r.getState();return v.map(m=>({...m}))},getEdge:v=>r.getState().edgeLookup.get(v),setNodes:f,setEdges:h,addNodes:v=>{const m=Array.isArray(v)?v:[v];i.nodeQueue.push(w=>[...w,...m])},addEdges:v=>{const m=Array.isArray(v)?v:[v];i.edgeQueue.push(w=>[...w,...m])},toObject:()=>{const{nodes:v=[],edges:m=[],transform:w}=r.getState(),[S,P,C]=w;return{nodes:v.map(k=>({...k})),edges:m.map(k=>({...k})),viewport:{x:S,y:P,zoom:C}}},deleteElements:async({nodes:v=[],edges:m=[]})=>{const{nodes:w,edges:S,onNodesDelete:P,onEdgesDelete:C,triggerNodeChanges:k,triggerEdgeChanges:z,onDelete:_,onBeforeDelete:I}=r.getState(),{nodes:H,edges:$}=await yw({nodesToRemove:v,edgesToRemove:m,nodes:w,edges:S,onBeforeDelete:I}),B=$.length>0,X=H.length>0;if(B){const G=$.map(Dh);C==null||C($),z(G)}if(X){const G=H.map(Dh);P==null||P(H),k(G)}return(X||B)&&(_==null||_({nodes:H,edges:$})),{deletedNodes:H,deletedEdges:$}},getIntersectingNodes:(v,m=!0,w)=>{const S=ah(v),P=S?v:p(v),C=w!==void 0;return P?(w||r.getState().nodes).filter(k=>{const z=r.getState().nodeLookup.get(k.id);if(z&&!S&&(k.id===v.id||!z.internals.positionAbsolute))return!1;const _=fi(C?k:z),I=ll(_,P);return m&&I>0||I>=_.width*_.height||I>=P.width*P.height}):[]},isNodeIntersecting:(v,m,w=!0)=>{const P=ah(v)?v:p(v);if(!P)return!1;const C=ll(P,m);return w&&C>0||C>=m.width*m.height||C>=P.width*P.height},updateNode:y,updateNodeData:(v,m,w={replace:!1})=>{y(v,S=>{const P=typeof m=="function"?m(S):m;return w.replace?{...S,data:P}:{...S,data:{...S.data,...P}}},w)},updateEdge:g,updateEdgeData:(v,m,w={replace:!1})=>{g(v,S=>{const P=typeof m=="function"?m(S):m;return w.replace?{...S,data:P}:{...S,data:{...S.data,...P}}},w)},getNodesBounds:v=>{const{nodeLookup:m,nodeOrigin:w}=r.getState();return hw(v,{nodeLookup:m,nodeOrigin:w})},getHandleConnections:({type:v,id:m,nodeId:w})=>{var S;return Array.from(((S=r.getState().connectionLookup.get(`${w}-${v}${m?`-${m}`:""}`))==null?void 0:S.values())??[])},getNodeConnections:({type:v,handleId:m,nodeId:w})=>{var S;return Array.from(((S=r.getState().connectionLookup.get(`${w}${v?m?`-${v}-${m}`:`-${v}`:""}`))==null?void 0:S.values())??[])},fitView:async v=>{const m=r.getState().fitViewResolver??ww();return r.setState({fitViewQueued:!0,fitViewOptions:v,fitViewResolver:m}),i.nodeQueue.push(w=>[...w]),m.promise}}},[]);return Q.useMemo(()=>({...u,...t,viewportInitialized:l}),[l])}const Hh=t=>t.selected,K1=typeof window<"u"?window:void 0;function q1({deleteKeyCode:t,multiSelectionKeyCode:r}){const i=Oe(),{deleteElements:l}=cc(),u=hi(t,{actInsideInputWithModifier:!1}),c=hi(r,{target:K1});Q.useEffect(()=>{if(u){const{edges:f,nodes:h}=i.getState();l({nodes:h.filter(Hh),edges:f.filter(Hh)}),i.setState({nodesSelectionActive:!1})}},[u]),Q.useEffect(()=>{i.setState({multiSelectionActive:c})},[c])}function Z1(t){const r=Oe();Q.useEffect(()=>{const i=()=>{var u,c,f,h;if(!t.current||!(((c=(u=t.current).checkVisibility)==null?void 0:c.call(u))??!0))return!1;const l=oc(t.current);(l.height===0||l.width===0)&&((h=(f=r.getState()).onError)==null||h.call(f,"004",Zt.error004())),r.setState({width:l.width||500,height:l.height||500})};if(t.current){i(),window.addEventListener("resize",i);const l=new ResizeObserver(()=>i());return l.observe(t.current),()=>{window.removeEventListener("resize",i),l&&t.current&&l.unobserve(t.current)}}},[])}const wl={position:"absolute",width:"100%",height:"100%",top:0,left:0},J1=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function eS({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:i=!0,panOnScroll:l=!1,panActivationKeyPressed:u,panOnScrollSpeed:c=.5,panOnScrollMode:f=yr.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:y,translateExtent:g,minZoom:v,maxZoom:m,zoomActivationKeyCode:w,preventScrolling:S=!0,children:P,noWheelClassName:C,noPanClassName:k,onViewportChange:z,isControlledViewport:_,paneClickDistance:I,selectionOnDrag:H}){const $=Oe(),B=Q.useRef(null),{userSelectionActive:X,lib:G,connectionInProgress:te}=je(J1,be),Z=hi(w),ee=Q.useRef();Z1(B);const J=Q.useCallback(N=>{z==null||z({x:N[0],y:N[1],zoom:N[2]}),_||$.setState({transform:N})},[z,_]);return Q.useEffect(()=>{if(B.current){ee.current=r1({domNode:B.current,minZoom:v,maxZoom:m,translateExtent:g,viewport:y,onDraggingChange:b=>$.setState(A=>A.paneDragging===b?A:{paneDragging:b}),onPanZoomStart:(b,A)=>{const{onViewportChangeStart:L,onMoveStart:O}=$.getState();O==null||O(b,A),L==null||L(A)},onPanZoom:(b,A)=>{const{onViewportChange:L,onMove:O}=$.getState();O==null||O(b,A),L==null||L(A)},onPanZoomEnd:(b,A)=>{const{onViewportChangeEnd:L,onMoveEnd:O}=$.getState();O==null||O(b,A),L==null||L(A)}});const{x:N,y:U,zoom:V}=ee.current.getViewport();return $.setState({panZoom:ee.current,transform:[N,U,V],domNode:B.current.closest(".react-flow")}),()=>{var b;(b=ee.current)==null||b.destroy()}}},[]),Q.useEffect(()=>{var N;(N=ee.current)==null||N.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:i,panOnScroll:l,panActivationKeyPressed:u,panOnScrollSpeed:c,panOnScrollMode:f,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:Z,preventScrolling:S,noPanClassName:k,userSelectionActive:X,noWheelClassName:C,lib:G,onTransformChange:J,connectionInProgress:te,selectionOnDrag:H,paneClickDistance:I})},[t,r,i,l,u,c,f,h,p,Z,S,k,X,C,G,J,te,H,I]),E.jsx("div",{className:"react-flow__renderer",ref:B,style:wl,children:P})}const tS=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function nS(){const{userSelectionActive:t,userSelectionRect:r}=je(tS,be);return t&&r?E.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 Ia=(t,r)=>i=>{i.target===r.current&&(t==null||t(i))},rS=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function oS({isSelecting:t,selectionKeyPressed:r,selectionMode:i=ci.Full,panOnDrag:l,autoPanOnSelection:u,paneClickDistance:c,selectionOnDrag:f,onSelectionStart:h,onSelectionEnd:p,onPaneClick:y,onPaneContextMenu:g,onPaneScroll:v,onPaneMouseEnter:m,onPaneMouseMove:w,onPaneMouseLeave:S,children:P}){const C=Q.useRef(0),k=Oe(),{userSelectionActive:z,elementsSelectable:_,dragging:I,panBy:H,autoPanSpeed:$}=je(rS,be),B=_&&(t||z),X=Q.useRef(null),G=Q.useRef(),te=Q.useRef(new Set),Z=Q.useRef(new Set),ee=Q.useRef(!1),J=Q.useRef(!1),N=Q.useRef({x:0,y:0}),U=Q.useRef(!1),V=K=>{if(J.current||ee.current||k.getState().connection.inProgress){J.current=!1,ee.current=!1;return}y==null||y(K),k.getState().resetSelectedElements(),k.setState({nodesSelectionActive:!1})},b=K=>{if(Array.isArray(l)&&(l!=null&&l.includes(2))){K.preventDefault();return}g==null||g(K)},A=v?K=>v(K):void 0,L=K=>{J.current&&(K.stopPropagation(),J.current=!1)},O=K=>{var Re,Ze;if(K.pointerType==="touch"&&l!==!1&&!r)return;const{domNode:se,transform:pe}=k.getState();if(G.current=se==null?void 0:se.getBoundingClientRect(),!G.current)return;const we=K.target===X.current;if(!we&&!!K.target.closest(".nokey")||!t||!(f&&we||r)||K.button!==0||!K.isPrimary)return;(Ze=(Re=K.target)==null?void 0:Re.setPointerCapture)==null||Ze.call(Re,K.pointerId),J.current=!1;const{x:Ne,y:Pe}=qt(K.nativeEvent,G.current),Ie=wi({x:Ne,y:Pe},pe);k.setState({userSelectionRect:{width:0,height:0,startX:Ie.x,startY:Ie.y,x:Ne,y:Pe}}),we||(K.stopPropagation(),K.preventDefault())};function M(K,se){const{userSelectionRect:pe}=k.getState();if(!pe)return;const{transform:we,nodeLookup:ve,edgeLookup:me,connectionLookup:Ne,triggerNodeChanges:Pe,triggerEdgeChanges:Ie,defaultEdgeOptions:Re}=k.getState(),Ze={x:pe.startX,y:pe.startY},{x:nt,y:Qe}=so(Ze,we),Ge={startX:Ze.x,startY:Ze.y,x:Krt.id)),Z.current=new Set;const Et=(Re==null?void 0:Re.selectable)??!0;for(const rt of te.current){const ft=Ne.get(rt);if(ft)for(const{edgeId:st}of ft.values()){const dt=me.get(st);dt&&(dt.selectable??Et)&&Z.current.add(st)}}if(!ch(At,te.current)){const rt=Jr(ve,te.current,!0);Pe(rt)}if(!ch(kt,Z.current)){const rt=Jr(me,Z.current);Ie(rt)}k.setState({userSelectionRect:Ge,userSelectionActive:!0,nodesSelectionActive:!1})}function j(){if(!u||!G.current)return;const[K,se]=nc(N.current,G.current,$);H({x:K,y:se}).then(pe=>{if(!J.current||!pe){C.current=requestAnimationFrame(j);return}const{x:we,y:ve}=N.current;M(we,ve),C.current=requestAnimationFrame(j)})}const ne=()=>{cancelAnimationFrame(C.current),C.current=0,U.current=!1};Q.useEffect(()=>()=>ne(),[]);const re=K=>{const{userSelectionRect:se,transform:pe,resetSelectedElements:we}=k.getState();if(!G.current||!se)return;const{x:ve,y:me}=qt(K.nativeEvent,G.current);N.current={x:ve,y:me};const Ne=so({x:se.startX,y:se.startY},pe);if(!J.current){const Pe=r?0:c;if(Math.hypot(ve-Ne.x,me-Ne.y)<=Pe)return;we(),h==null||h(K)}J.current=!0,U.current||(j(),U.current=!0),M(ve,me)},ae=K=>{var se,pe;if(!B){K.target===X.current&&k.getState().connection.inProgress&&(ee.current=!0);return}K.button===0&&((pe=(se=K.target)==null?void 0:se.releasePointerCapture)==null||pe.call(se,K.pointerId),!z&&K.target===X.current&&k.getState().userSelectionRect&&(V==null||V(K)),k.setState({userSelectionActive:!1,userSelectionRect:null}),J.current&&(p==null||p(K),k.setState({nodesSelectionActive:te.current.size>0})),ne())},fe=K=>{var se,pe;(pe=(se=K.target)==null?void 0:se.releasePointerCapture)==null||pe.call(se,K.pointerId),ne()},ce=l===!0||Array.isArray(l)&&l.includes(0);return E.jsxs("div",{className:Xe(["react-flow__pane",{draggable:ce,dragging:I,selection:t}]),onClick:B?void 0:Ia(V,X),onContextMenu:Ia(b,X),onWheel:Ia(A,X),onPointerEnter:B?void 0:m,onPointerMove:B?re:w,onPointerUp:ae,onPointerCancel:B?fe:void 0,onPointerDownCapture:B?O:void 0,onClickCapture:B?L:void 0,onPointerLeave:S,ref:X,style:wl,children:[P,E.jsx(nS,{})]})}function Wa({id:t,store:r,unselect:i=!1,nodeRef:l}){const{addSelectedNodes:u,unselectNodesAndEdges:c,multiSelectionActive:f,nodeLookup:h,onError:p}=r.getState(),y=h.get(t);if(!y){p==null||p("012",Zt.error012(t));return}r.setState({nodesSelectionActive:!1}),y.selected?(i||y.selected&&f)&&(c({nodes:[y],edges:[]}),requestAnimationFrame(()=>{var g;return(g=l==null?void 0:l.current)==null?void 0:g.blur()})):u([t])}function mg({nodeRef:t,disabled:r=!1,noDragClassName:i,handleSelector:l,nodeId:u,isSelectable:c,nodeClickDistance:f}){const h=Oe(),[p,y]=Q.useState(!1),g=Q.useRef();return Q.useEffect(()=>{if(!r)return g.current=bw({getStoreItems:()=>h.getState(),onNodeMouseDown:v=>{Wa({id:v,store:h,nodeRef:t})},onDragStart:()=>{y(!0)},onDragStop:()=>{y(!1)}}),()=>{var v;(v=g.current)==null||v.destroy(),g.current=void 0}},[r,h,t]),Q.useEffect(()=>{r||!t.current||!g.current||g.current.update({noDragClassName:i,handleSelector:l,domNode:t.current,isSelectable:c,nodeId:u,nodeClickDistance:f})},[i,l,r,c,t,u,f]),p}const iS=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function yg(){const t=Oe();return Q.useCallback(i=>{const{nodeExtent:l,snapToGrid:u,snapGrid:c,nodesDraggable:f,onError:h,updateNodePositions:p,nodeLookup:y,nodeOrigin:g}=t.getState(),v=new Map,m=iS(f),w=u?c[0]:5,S=u?c[1]:5,P=i.direction.x*w*i.factor,C=i.direction.y*S*i.factor;for(const[,k]of y){if(!m(k))continue;let z={x:k.internals.positionAbsolute.x+P,y:k.internals.positionAbsolute.y+C};u&&(z=xi(z,c));const{position:_,positionAbsolute:I}=$p({nodeId:k.id,nextPosition:z,nodeLookup:y,nodeExtent:l,nodeOrigin:g,onError:h});k.position=_,k.internals.positionAbsolute=I,v.set(k.id,k)}p(v)},[])}const fc=Q.createContext(null),sS=fc.Provider;fc.Consumer;const vg=()=>Q.useContext(fc),lS=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),xg=Q.createContext(null);function uS({children:t}){const r=je(lS,be);return E.jsx(xg.Provider,{value:r,children:t})}function aS(){const t=Q.useContext(xg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const cS={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},fS=(t,r,i)=>l=>{const{connectionClickStartHandle:u,connectionMode:c,connection:f}=l,{fromHandle:h,toHandle:p,isValid:y}=f;if(!h&&!u)return cS;const g=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===i;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===i,connectingTo:g,clickConnecting:(u==null?void 0:u.nodeId)===t&&(u==null?void 0:u.id)===r&&(u==null?void 0:u.type)===i,isPossibleEndHandle:c===oo.Strict?(h==null?void 0:h.type)!==i:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!u,valid:g&&y}};function dS({type:t="source",position:r=Se.Top,isValidConnection:i,isConnectable:l=!0,isConnectableStart:u=!0,isConnectableEnd:c=!0,id:f,onConnect:h,children:p,className:y,onMouseDown:g,onTouchStart:v,...m},w){var U,V;const S=f||null,P=t==="target",C=Oe(),k=vg(),{connectOnClick:z,noPanClassName:_,rfId:I}=aS(),{connectingFrom:H,connectingTo:$,clickConnecting:B,isPossibleEndHandle:X,connectionInProcess:G,clickConnectionInProcess:te,valid:Z}=je(fS(k,S,t),be);k||(V=(U=C.getState()).onError)==null||V.call(U,"010",Zt.error010());const ee=b=>{const{defaultEdgeOptions:A,onConnect:L,hasDefaultEdges:O}=C.getState(),M={...A,...b};if(O){const{edges:j,setEdges:ne,onError:re}=C.getState();ne(U1(M,j,{onError:re}))}L==null||L(M),h==null||h(M)},J=b=>{if(!k)return;const A=Wp(b.nativeEvent);if(u&&(A&&b.button===0||!A)){const L=C.getState();Ua.onPointerDown(b.nativeEvent,{handleDomNode:b.currentTarget,autoPanOnConnect:L.autoPanOnConnect,connectionMode:L.connectionMode,connectionRadius:L.connectionRadius,domNode:L.domNode,nodeLookup:L.nodeLookup,lib:L.lib,isTarget:P,handleId:S,nodeId:k,flowId:L.rfId,panBy:L.panBy,cancelConnection:L.cancelConnection,onConnectStart:L.onConnectStart,onConnectEnd:(...O)=>{var M,j;return(j=(M=C.getState()).onConnectEnd)==null?void 0:j.call(M,...O)},updateConnection:L.updateConnection,onConnect:ee,isValidConnection:i||((...O)=>{var M,j;return((j=(M=C.getState()).isValidConnection)==null?void 0:j.call(M,...O))??!0}),getTransform:()=>C.getState().transform,getFromHandle:()=>C.getState().connection.fromHandle,autoPanSpeed:L.autoPanSpeed,dragThreshold:L.connectionDragThreshold})}A?g==null||g(b):v==null||v(b)},N=b=>{const{onClickConnectStart:A,onClickConnectEnd:L,connectionClickStartHandle:O,connectionMode:M,isValidConnection:j,lib:ne,rfId:re,nodeLookup:ae,connection:fe}=C.getState();if(!k||!O&&!u)return;if(!O){A==null||A(b.nativeEvent,{nodeId:k,handleId:S,handleType:t}),C.setState({connectionClickStartHandle:{nodeId:k,type:t,id:S}});return}const ce=bp(b.target),K=i||j,{connection:se,isValid:pe}=Ua.isValid(b.nativeEvent,{handle:{nodeId:k,id:S,type:t},connectionMode:M,fromNodeId:O.nodeId,fromHandleId:O.id||null,fromType:O.type,isValidConnection:K,flowId:re,doc:ce,lib:ne,nodeLookup:ae});pe&&se&&ee(se);const we=structuredClone(fe);delete we.inProgress,we.toPosition=we.toHandle?we.toHandle.position:null,L==null||L(b,we),C.setState({connectionClickStartHandle:null})};return E.jsx("div",{"data-handleid":S,"data-nodeid":k,"data-handlepos":r,"data-id":`${I}-${k}-${S}-${t}`,className:Xe(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",_,y,{source:!P,target:P,connectable:l,connectablestart:u,connectableend:c,clickconnecting:B,connectingfrom:H,connectingto:$,valid:Z,connectionindicator:l&&(!G||X)&&(G||te?c:u)}]),onMouseDown:J,onTouchStart:J,onClick:z?N:void 0,ref:w,...m,children:p})}const ul=Q.memo(hg(dS));function hS({data:t,isConnectable:r,sourcePosition:i=Se.Bottom}){return E.jsxs(E.Fragment,{children:[t==null?void 0:t.label,E.jsx(ul,{type:"source",position:i,isConnectable:r})]})}function pS({data:t,isConnectable:r,targetPosition:i=Se.Top,sourcePosition:l=Se.Bottom}){return E.jsxs(E.Fragment,{children:[E.jsx(ul,{type:"target",position:i,isConnectable:r}),t==null?void 0:t.label,E.jsx(ul,{type:"source",position:l,isConnectable:r})]})}function gS(){return null}function mS({data:t,isConnectable:r,targetPosition:i=Se.Top}){return E.jsxs(E.Fragment,{children:[E.jsx(ul,{type:"target",position:i,isConnectable:r}),t==null?void 0:t.label]})}const al={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Vh={input:hS,default:pS,output:mS,group:gS};function yS(t){var r,i,l,u;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((i=t.style)==null?void 0:i.height)}:{width:t.width??((l=t.style)==null?void 0:l.width),height:t.height??((u=t.style)==null?void 0:u.height)}}const vS=t=>{const{width:r,height:i,x:l,y:u}=vi(t.nodeLookup,{filter:c=>!!c.selected});return{width:Kt(r)?r:null,height:Kt(i)?i:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${l}px,${u}px)`}};function xS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:i}){const l=Oe(),{width:u,height:c,transformString:f,userSelectionActive:h}=je(vS,be),p=yg(),y=Q.useRef(null);Q.useEffect(()=>{var w;i||(w=y.current)==null||w.focus({preventScroll:!0})},[i]);const g=!h&&u!==null&&c!==null;if(mg({nodeRef:y,disabled:!g}),!g)return null;const v=t?w=>{const S=l.getState().nodes.filter(P=>P.selected);t(w,S)}:void 0,m=w=>{Object.prototype.hasOwnProperty.call(al,w.key)&&(w.preventDefault(),p({direction:al[w.key],factor:w.shiftKey?4:1}))};return E.jsx("div",{className:Xe(["react-flow__nodesselection","react-flow__container",r]),style:{transform:f},children:E.jsx("div",{ref:y,className:"react-flow__nodesselection-rect",onContextMenu:v,tabIndex:i?void 0:-1,onKeyDown:i?void 0:m,style:{width:u,height:c}})})}const Bh=typeof window<"u"?window:void 0,wS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function wg({children:t,onPaneClick:r,onPaneMouseEnter:i,onPaneMouseMove:l,onPaneMouseLeave:u,onPaneContextMenu:c,onPaneScroll:f,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:y,selectionOnDrag:g,selectionMode:v,onSelectionStart:m,onSelectionEnd:w,multiSelectionKeyCode:S,panActivationKeyCode:P,zoomActivationKeyCode:C,elementsSelectable:k,zoomOnScroll:z,zoomOnPinch:_,panOnScroll:I,panOnScrollSpeed:H,panOnScrollMode:$,zoomOnDoubleClick:B,panOnDrag:X,autoPanOnSelection:G,defaultViewport:te,translateExtent:Z,minZoom:ee,maxZoom:J,preventScrolling:N,onSelectionContextMenu:U,noWheelClassName:V,noPanClassName:b,disableKeyboardA11y:A,onViewportChange:L,isControlledViewport:O}){const{nodesSelectionActive:M,userSelectionActive:j}=je(wS,be),ne=hi(y,{target:Bh}),re=hi(P,{target:Bh}),ae=re||X,fe=re||I,ce=g&&ae!==!0,K=ne||j||ce;return q1({deleteKeyCode:p,multiSelectionKeyCode:S}),E.jsx(eS,{onPaneContextMenu:c,elementsSelectable:k,zoomOnScroll:z,zoomOnPinch:_,panOnScroll:fe,panActivationKeyPressed:re,panOnScrollSpeed:H,panOnScrollMode:$,zoomOnDoubleClick:B,panOnDrag:!ne&&ae,defaultViewport:te,translateExtent:Z,minZoom:ee,maxZoom:J,zoomActivationKeyCode:C,preventScrolling:N,noWheelClassName:V,noPanClassName:b,onViewportChange:L,isControlledViewport:O,paneClickDistance:h,selectionOnDrag:ce,children:E.jsxs(oS,{onSelectionStart:m,onSelectionEnd:w,onPaneClick:r,onPaneMouseEnter:i,onPaneMouseMove:l,onPaneMouseLeave:u,onPaneContextMenu:c,onPaneScroll:f,panOnDrag:ae,autoPanOnSelection:G,isSelecting:!!K,selectionMode:v,selectionKeyPressed:ne,paneClickDistance:h,selectionOnDrag:ce,children:[t,M&&E.jsx(xS,{onSelectionContextMenu:U,noPanClassName:b,disableKeyboardA11y:A})]})})}wg.displayName="FlowRenderer";const SS=Q.memo(wg),_S=t=>r=>t?tc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(i=>i.id):Array.from(r.nodeLookup.keys());function kS(t){return je(Q.useCallback(_S(t),[t]),be)}const ES=t=>t.updateNodeInternals;function NS(){const t=je(ES),[r]=Q.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(i=>{const l=new Map;i.forEach(u=>{const c=u.target.getAttribute("data-id");l.set(c,{id:c,nodeElement:u.target,force:!0})}),t(l)}));return Q.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function CS({node:t,nodeType:r,hasDimensions:i,resizeObserver:l}){const u=Oe(),c=Q.useRef(null),f=Q.useRef(null),h=Q.useRef(t.sourcePosition),p=Q.useRef(t.targetPosition),y=Q.useRef(r),g=i&&!!t.internals.handleBounds;return Q.useEffect(()=>{c.current&&!t.hidden&&(!g||f.current!==c.current)&&(f.current&&(l==null||l.unobserve(f.current)),l==null||l.observe(c.current),f.current=c.current)},[g,t.hidden]),Q.useEffect(()=>()=>{f.current&&(l==null||l.unobserve(f.current),f.current=null)},[]),Q.useEffect(()=>{if(c.current){const v=y.current!==r,m=h.current!==t.sourcePosition,w=p.current!==t.targetPosition;(v||m||w)&&(y.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,u.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:c.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),c}function MS({id:t,onClick:r,onMouseEnter:i,onMouseMove:l,onMouseLeave:u,onContextMenu:c,onDoubleClick:f,nodesDraggable:h,elementsSelectable:p,nodesConnectable:y,nodesFocusable:g,resizeObserver:v,noDragClassName:m,noPanClassName:w,disableKeyboardA11y:S,rfId:P,nodeTypes:C,nodeClickDistance:k,onError:z}){const{node:_,internals:I,isParent:H}=je(K=>{const se=K.nodeLookup.get(t),pe=K.parentLookup.has(t);return{node:se,internals:se.internals,isParent:pe}},be);let $=_.type||"default",B=(C==null?void 0:C[$])||Vh[$];B===void 0&&(z==null||z("003",Zt.error003($)),$="default",B=(C==null?void 0:C.default)||Vh.default);const X=!!(_.draggable||h&&typeof _.draggable>"u"),G=!!(_.selectable||p&&typeof _.selectable>"u"),te=!!(_.connectable||y&&typeof _.connectable>"u"),Z=!!(_.focusable||g&&typeof _.focusable>"u"),ee=Oe(),J=Vp(_),N=CS({node:_,nodeType:$,hasDimensions:J,resizeObserver:v}),U=mg({nodeRef:N,disabled:_.hidden||!X,noDragClassName:m,handleSelector:_.dragHandle,nodeId:t,isSelectable:G,nodeClickDistance:k}),V=yg();if(_.hidden)return null;const b=en(_),A=yS(_),L=G||X||r||i||l||u,O=i?K=>i(K,{...I.userNode}):void 0,M=l?K=>l(K,{...I.userNode}):void 0,j=u?K=>u(K,{...I.userNode}):void 0,ne=c?K=>c(K,{...I.userNode}):void 0,re=f?K=>f(K,{...I.userNode}):void 0,ae=K=>{const{selectNodesOnDrag:se,nodeDragThreshold:pe}=ee.getState();G&&(!se||!X||pe>0)&&Wa({id:t,store:ee,nodeRef:N}),r&&r(K,{...I.userNode})},fe=K=>{if(!(Up(K.nativeEvent)||S)){if(jp.includes(K.key)&&G){const se=K.key==="Escape";Wa({id:t,store:ee,unselect:se,nodeRef:N})}else if(X&&_.selected&&Object.prototype.hasOwnProperty.call(al,K.key)){K.preventDefault();const{ariaLabelConfig:se}=ee.getState();ee.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:K.key.replace("Arrow","").toLowerCase(),x:~~I.positionAbsolute.x,y:~~I.positionAbsolute.y})}),V({direction:al[K.key],factor:K.shiftKey?4:1})}}},ce=()=>{var Ne;if(S||!((Ne=N.current)!=null&&Ne.matches(":focus-visible")))return;const{transform:K,width:se,height:pe,autoPanOnNodeFocus:we,setCenter:ve}=ee.getState();if(!we)return;tc(new Map([[t,_]]),{x:0,y:0,width:se,height:pe},K,!0).length>0||ve(_.position.x+b.width/2,_.position.y+b.height/2,{zoom:K[2]})};return E.jsx("div",{className:Xe(["react-flow__node",`react-flow__node-${$}`,{[w]:X},_.className,{selected:_.selected,selectable:G,parent:H,draggable:X,dragging:U}]),ref:N,style:{zIndex:I.z,transform:`translate(${I.positionAbsolute.x}px,${I.positionAbsolute.y}px)`,pointerEvents:L?"all":"none",visibility:J?"visible":"hidden",..._.style,...A},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:O,onMouseMove:M,onMouseLeave:j,onContextMenu:ne,onClick:ae,onDoubleClick:re,onKeyDown:Z?fe:void 0,tabIndex:Z?0:void 0,onFocus:Z?ce:void 0,role:_.ariaRole??(Z?"group":void 0),"aria-roledescription":"node","aria-describedby":S?void 0:`${ag}-${P}`,"aria-label":_.ariaLabel,..._.domAttributes,children:E.jsx(sS,{value:t,children:E.jsx(B,{id:t,data:_.data,type:$,positionAbsoluteX:I.positionAbsolute.x,positionAbsoluteY:I.positionAbsolute.y,selected:_.selected??!1,selectable:G,draggable:X,deletable:_.deletable??!0,isConnectable:te,sourcePosition:_.sourcePosition,targetPosition:_.targetPosition,dragging:U,dragHandle:_.dragHandle,zIndex:I.z,parentId:_.parentId,...b})})})}var PS=Q.memo(MS);const IS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Sg(t){const{nodesConnectable:r,nodesFocusable:i,elementsSelectable:l,onError:u}=je(IS,be),c=kS(t.onlyRenderVisibleElements),f=NS();return E.jsx("div",{className:"react-flow__nodes",style:wl,children:c.map(h=>E.jsx(PS,{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:f,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:i,elementsSelectable:l,nodeClickDistance:t.nodeClickDistance,onError:u},h))})}Sg.displayName="NodeRenderer";const TS=Q.memo(Sg);function jS(t){return je(Q.useCallback(i=>{if(!t)return i.edges.map(u=>u.id);const l=[];if(i.width&&i.height)for(const u of i.edges){const c=i.nodeLookup.get(u.source),f=i.nodeLookup.get(u.target);c&&f&&Ew({sourceNode:c,targetNode:f,width:i.width,height:i.height,transform:i.transform})&&l.push(u.id)}return l},[t]),be)}const zS=({color:t="none",strokeWidth:r=1})=>{const i={strokeWidth:r,...t&&{stroke:t}};return E.jsx("polyline",{className:"arrow",style:i,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},RS=({color:t="none",strokeWidth:r=1})=>{const i={strokeWidth:r,...t&&{stroke:t,fill:t}};return E.jsx("polyline",{className:"arrowclosed",style:i,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},bh={[il.Arrow]:zS,[il.ArrowClosed]:RS};function LS(t){const r=Oe();return Q.useMemo(()=>{var u,c;return Object.prototype.hasOwnProperty.call(bh,t)?bh[t]:((c=(u=r.getState()).onError)==null||c.call(u,"009",Zt.error009(t)),null)},[t])}const AS=({id:t,type:r,color:i,width:l=12.5,height:u=12.5,markerUnits:c="strokeWidth",strokeWidth:f,orient:h="auto-start-reverse"})=>{const p=LS(r);return p?E.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${l}`,markerHeight:`${u}`,viewBox:"-10 -10 20 20",markerUnits:c,orient:h,refX:"0",refY:"0",children:E.jsx(p,{color:i,strokeWidth:f})}):null},_g=({defaultColor:t,rfId:r})=>{const i=je(c=>c.edges),l=je(c=>c.defaultEdgeOptions),u=Q.useMemo(()=>zw(i,{id:r,defaultColor:t,defaultMarkerStart:l==null?void 0:l.markerStart,defaultMarkerEnd:l==null?void 0:l.markerEnd}),[i,l,r,t]);return u.length?E.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:E.jsx("defs",{children:u.map(c=>E.jsx(AS,{id:c.id,type:c.type,color:c.color,width:c.width,height:c.height,markerUnits:c.markerUnits,strokeWidth:c.strokeWidth,orient:c.orient},c.id))})}):null};_g.displayName="MarkerDefinitions";var $S=Q.memo(_g);function kg({x:t,y:r,label:i,labelStyle:l,labelShowBg:u=!0,labelBgStyle:c,labelBgPadding:f=[2,4],labelBgBorderRadius:h=2,children:p,className:y,...g}){const[v,m]=Q.useState({x:1,y:0,width:0,height:0}),w=Xe(["react-flow__edge-textwrapper",y]),S=Q.useRef(null);return Q.useEffect(()=>{if(S.current){const P=S.current.getBBox();m({x:P.x,y:P.y,width:P.width,height:P.height})}},[i]),i?E.jsxs("g",{transform:`translate(${t-v.width/2} ${r-v.height/2})`,className:w,visibility:v.width?"visible":"hidden",...g,children:[u&&E.jsx("rect",{width:v.width+2*f[0],x:-f[0],y:-f[1],height:v.height+2*f[1],className:"react-flow__edge-textbg",style:c,rx:h,ry:h}),E.jsx("text",{className:"react-flow__edge-text",y:v.height/2,dy:"0.3em",ref:S,style:l,children:i}),p]}):null}kg.displayName="EdgeText";const DS=Q.memo(kg);function Sl({path:t,labelX:r,labelY:i,label:l,labelStyle:u,labelShowBg:c,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:y=20,...g}){return E.jsxs(E.Fragment,{children:[E.jsx("path",{...g,d:t,fill:"none",className:Xe(["react-flow__edge-path",g.className])}),y?E.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:y,className:"react-flow__edge-interaction"}):null,l&&Kt(r)&&Kt(i)?E.jsx(DS,{x:r,y:i,label:l,labelStyle:u,labelShowBg:c,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function Uh({pos:t,x1:r,y1:i,x2:l,y2:u}){return t===Se.Left||t===Se.Right?[.5*(r+l),i]:[r,.5*(i+u)]}function Eg({sourceX:t,sourceY:r,sourcePosition:i=Se.Bottom,targetX:l,targetY:u,targetPosition:c=Se.Top}){const[f,h]=Uh({pos:i,x1:t,y1:r,x2:l,y2:u}),[p,y]=Uh({pos:c,x1:l,y1:u,x2:t,y2:r}),[g,v,m,w]=Yp({sourceX:t,sourceY:r,targetX:l,targetY:u,sourceControlX:f,sourceControlY:h,targetControlX:p,targetControlY:y});return[`M${t},${r} C${f},${h} ${p},${y} ${l},${u}`,g,v,m,w]}function Ng(t){return Q.memo(({id:r,sourceX:i,sourceY:l,targetX:u,targetY:c,sourcePosition:f,targetPosition:h,label:p,labelStyle:y,labelShowBg:g,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:w,style:S,markerEnd:P,markerStart:C,interactionWidth:k})=>{const[z,_,I]=Eg({sourceX:i,sourceY:l,sourcePosition:f,targetX:u,targetY:c,targetPosition:h}),H=t.isInternal?void 0:r;return E.jsx(Sl,{id:H,path:z,labelX:_,labelY:I,label:p,labelStyle:y,labelShowBg:g,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:w,style:S,markerEnd:P,markerStart:C,interactionWidth:k})})}const OS=Ng({isInternal:!1}),Cg=Ng({isInternal:!0});OS.displayName="SimpleBezierEdge";Cg.displayName="SimpleBezierEdgeInternal";function Mg(t){return Q.memo(({id:r,sourceX:i,sourceY:l,targetX:u,targetY:c,label:f,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:g,labelBgBorderRadius:v,style:m,sourcePosition:w=Se.Bottom,targetPosition:S=Se.Top,markerEnd:P,markerStart:C,pathOptions:k,interactionWidth:z})=>{const[_,I,H]=Va({sourceX:i,sourceY:l,sourcePosition:w,targetX:u,targetY:c,targetPosition:S,borderRadius:k==null?void 0:k.borderRadius,offset:k==null?void 0:k.offset,stepPosition:k==null?void 0:k.stepPosition}),$=t.isInternal?void 0:r;return E.jsx(Sl,{id:$,path:_,labelX:I,labelY:H,label:f,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:g,labelBgBorderRadius:v,style:m,markerEnd:P,markerStart:C,interactionWidth:z})})}const Pg=Mg({isInternal:!1}),Ig=Mg({isInternal:!0});Pg.displayName="SmoothStepEdge";Ig.displayName="SmoothStepEdgeInternal";function Tg(t){return Q.memo(({id:r,...i})=>{var u;const l=t.isInternal?void 0:r;return E.jsx(Pg,{...i,id:l,pathOptions:Q.useMemo(()=>{var c;return{borderRadius:0,offset:(c=i.pathOptions)==null?void 0:c.offset}},[(u=i.pathOptions)==null?void 0:u.offset])})})}const FS=Tg({isInternal:!1}),jg=Tg({isInternal:!0});FS.displayName="StepEdge";jg.displayName="StepEdgeInternal";function zg(t){return Q.memo(({id:r,sourceX:i,sourceY:l,targetX:u,targetY:c,label:f,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:g,labelBgBorderRadius:v,style:m,markerEnd:w,markerStart:S,interactionWidth:P})=>{const[C,k,z]=Gp({sourceX:i,sourceY:l,targetX:u,targetY:c}),_=t.isInternal?void 0:r;return E.jsx(Sl,{id:_,path:C,labelX:k,labelY:z,label:f,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:g,labelBgBorderRadius:v,style:m,markerEnd:w,markerStart:S,interactionWidth:P})})}const HS=zg({isInternal:!1}),Rg=zg({isInternal:!0});HS.displayName="StraightEdge";Rg.displayName="StraightEdgeInternal";function Lg(t){return Q.memo(({id:r,sourceX:i,sourceY:l,targetX:u,targetY:c,sourcePosition:f=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:y,labelShowBg:g,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:w,style:S,markerEnd:P,markerStart:C,pathOptions:k,interactionWidth:z})=>{const[_,I,H]=Xp({sourceX:i,sourceY:l,sourcePosition:f,targetX:u,targetY:c,targetPosition:h,curvature:k==null?void 0:k.curvature}),$=t.isInternal?void 0:r;return E.jsx(Sl,{id:$,path:_,labelX:I,labelY:H,label:p,labelStyle:y,labelShowBg:g,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:w,style:S,markerEnd:P,markerStart:C,interactionWidth:z})})}const VS=Lg({isInternal:!1}),Ag=Lg({isInternal:!0});VS.displayName="BezierEdge";Ag.displayName="BezierEdgeInternal";const Wh={default:Ag,straight:Rg,step:jg,smoothstep:Ig,simplebezier:Cg},Yh={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},BS=(t,r,i)=>i===Se.Left?t-r:i===Se.Right?t+r:t,bS=(t,r,i)=>i===Se.Top?t-r:i===Se.Bottom?t+r:t,Xh="react-flow__edgeupdater";function Qh({position:t,centerX:r,centerY:i,radius:l=10,onMouseDown:u,onMouseEnter:c,onMouseOut:f,type:h}){return E.jsx("circle",{onMouseDown:u,onMouseEnter:c,onMouseOut:f,className:Xe([Xh,`${Xh}-${h}`]),cx:BS(r,l,t),cy:bS(i,l,t),r:l,stroke:"transparent",fill:"transparent"})}function US({isReconnectable:t,reconnectRadius:r,edge:i,sourceX:l,sourceY:u,targetX:c,targetY:f,sourcePosition:h,targetPosition:p,onReconnect:y,onReconnectStart:g,onReconnectEnd:v,setReconnecting:m,setUpdateHover:w}){const S=Oe(),P=(I,H)=>{if(I.button!==0)return;const{autoPanOnConnect:$,domNode:B,connectionMode:X,connectionRadius:G,lib:te,onConnectStart:Z,cancelConnection:ee,nodeLookup:J,rfId:N,panBy:U,updateConnection:V}=S.getState(),b=H.type==="target",A=(M,j)=>{m(!1),v==null||v(M,i,H.type,j)},L=M=>y==null?void 0:y(i,M),O=(M,j)=>{m(!0),g==null||g(I,i,H.type),Z==null||Z(M,j)};Ua.onPointerDown(I.nativeEvent,{autoPanOnConnect:$,connectionMode:X,connectionRadius:G,domNode:B,handleId:H.id,nodeId:H.nodeId,nodeLookup:J,isTarget:b,edgeUpdaterType:H.type,lib:te,flowId:N,cancelConnection:ee,panBy:U,isValidConnection:(...M)=>{var j,ne;return((ne=(j=S.getState()).isValidConnection)==null?void 0:ne.call(j,...M))??!0},onConnect:L,onConnectStart:O,onConnectEnd:(...M)=>{var j,ne;return(ne=(j=S.getState()).onConnectEnd)==null?void 0:ne.call(j,...M)},onReconnectEnd:A,updateConnection:V,getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,dragThreshold:S.getState().connectionDragThreshold,handleDomNode:I.currentTarget})},C=I=>P(I,{nodeId:i.target,id:i.targetHandle??null,type:"target"}),k=I=>P(I,{nodeId:i.source,id:i.sourceHandle??null,type:"source"}),z=()=>w(!0),_=()=>w(!1);return E.jsxs(E.Fragment,{children:[(t===!0||t==="source")&&E.jsx(Qh,{position:h,centerX:l,centerY:u,radius:r,onMouseDown:C,onMouseEnter:z,onMouseOut:_,type:"source"}),(t===!0||t==="target")&&E.jsx(Qh,{position:p,centerX:c,centerY:f,radius:r,onMouseDown:k,onMouseEnter:z,onMouseOut:_,type:"target"})]})}function WS({id:t,edgesFocusable:r,edgesReconnectable:i,elementsSelectable:l,onClick:u,onDoubleClick:c,onContextMenu:f,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,reconnectRadius:g,onReconnect:v,onReconnectStart:m,onReconnectEnd:w,rfId:S,edgeTypes:P,noPanClassName:C,onError:k,disableKeyboardA11y:z}){let _=je(ve=>ve.edgeLookup.get(t));const I=je(ve=>ve.defaultEdgeOptions);_=I?{...I,..._}:_;let H=_.type||"default",$=(P==null?void 0:P[H])||Wh[H];$===void 0&&(k==null||k("011",Zt.error011(H)),H="default",$=(P==null?void 0:P.default)||Wh.default);const B=!!(_.focusable||r&&typeof _.focusable>"u"),X=typeof v<"u"&&(_.reconnectable||i&&typeof _.reconnectable>"u"),G=!!(_.selectable||l&&typeof _.selectable>"u"),te=Q.useRef(null),[Z,ee]=Q.useState(!1),[J,N]=Q.useState(!1),U=Oe(),{zIndex:V=_.zIndex,sourceX:b,sourceY:A,targetX:L,targetY:O,sourcePosition:M,targetPosition:j}=je(Q.useCallback(ve=>{const me=ve.nodeLookup.get(_.source),Ne=ve.nodeLookup.get(_.target);if(!me||!Ne)return Yh;const Pe=jw({id:t,sourceNode:me,targetNode:Ne,sourceHandle:_.sourceHandle||null,targetHandle:_.targetHandle||null,connectionMode:ve.connectionMode,onError:k}),Ie=kw({selected:_.selected,zIndex:_.zIndex,sourceNode:me,targetNode:Ne,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Pe||Yh,zIndex:Ie}},[_.source,_.target,_.sourceHandle,_.targetHandle,_.selected,_.zIndex,k]),be),ne=Q.useMemo(()=>_.markerStart?`url('#${Ba(_.markerStart,S)}')`:void 0,[_.markerStart,S]),re=Q.useMemo(()=>_.markerEnd?`url('#${Ba(_.markerEnd,S)}')`:void 0,[_.markerEnd,S]);if(_.hidden||b===null||A===null||L===null||O===null)return null;const ae=ve=>{var Ie;const{addSelectedEdges:me,unselectNodesAndEdges:Ne,multiSelectionActive:Pe}=U.getState();G&&(U.setState({nodesSelectionActive:!1}),_.selected&&Pe?(Ne({nodes:[],edges:[_]}),(Ie=te.current)==null||Ie.blur()):me([t])),u&&u(ve,_)},fe=c?ve=>{c(ve,{..._})}:void 0,ce=f?ve=>{f(ve,{..._})}:void 0,K=h?ve=>{h(ve,{..._})}:void 0,se=p?ve=>{p(ve,{..._})}:void 0,pe=y?ve=>{y(ve,{..._})}:void 0,we=ve=>{var me;if(!z&&jp.includes(ve.key)&&G){const{unselectNodesAndEdges:Ne,addSelectedEdges:Pe}=U.getState();ve.key==="Escape"?((me=te.current)==null||me.blur(),Ne({edges:[_]})):Pe([t])}};return E.jsx("svg",{style:{zIndex:V},children:E.jsxs("g",{className:Xe(["react-flow__edge",`react-flow__edge-${H}`,_.className,C,{selected:_.selected,animated:_.animated,inactive:!G&&!u,updating:Z,selectable:G}]),onClick:ae,onDoubleClick:fe,onContextMenu:ce,onMouseEnter:K,onMouseMove:se,onMouseLeave:pe,onKeyDown:B?we:void 0,tabIndex:B?0:void 0,role:_.ariaRole??(B?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":_.ariaLabel===null?void 0:_.ariaLabel||`Edge from ${_.source} to ${_.target}`,"aria-describedby":B?`${cg}-${S}`:void 0,ref:te,..._.domAttributes,children:[!J&&E.jsx($,{id:t,source:_.source,target:_.target,type:_.type,selected:_.selected,animated:_.animated,selectable:G,deletable:_.deletable??!0,label:_.label,labelStyle:_.labelStyle,labelShowBg:_.labelShowBg,labelBgStyle:_.labelBgStyle,labelBgPadding:_.labelBgPadding,labelBgBorderRadius:_.labelBgBorderRadius,sourceX:b,sourceY:A,targetX:L,targetY:O,sourcePosition:M,targetPosition:j,data:_.data,style:_.style,sourceHandleId:_.sourceHandle,targetHandleId:_.targetHandle,markerStart:ne,markerEnd:re,pathOptions:"pathOptions"in _?_.pathOptions:void 0,interactionWidth:_.interactionWidth}),X&&E.jsx(US,{edge:_,isReconnectable:X,reconnectRadius:g,onReconnect:v,onReconnectStart:m,onReconnectEnd:w,sourceX:b,sourceY:A,targetX:L,targetY:O,sourcePosition:M,targetPosition:j,setUpdateHover:ee,setReconnecting:N})]})})}var YS=Q.memo(WS);const XS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function $g({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:i,edgeTypes:l,noPanClassName:u,onReconnect:c,onEdgeContextMenu:f,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:y,onEdgeClick:g,reconnectRadius:v,onEdgeDoubleClick:m,onReconnectStart:w,onReconnectEnd:S,disableKeyboardA11y:P}){const{edgesFocusable:C,edgesReconnectable:k,elementsSelectable:z,onError:_}=je(XS,be),I=jS(r);return E.jsxs("div",{className:"react-flow__edges",children:[E.jsx($S,{defaultColor:t,rfId:i}),I.map(H=>E.jsx(YS,{id:H,edgesFocusable:C,edgesReconnectable:k,elementsSelectable:z,noPanClassName:u,onReconnect:c,onContextMenu:f,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,onClick:g,reconnectRadius:v,onDoubleClick:m,onReconnectStart:w,onReconnectEnd:S,rfId:i,onError:_,edgeTypes:l,disableKeyboardA11y:P},H))]})}$g.displayName="EdgeRenderer";const QS=Q.memo($g),Gh=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function GS({children:t}){const r=Oe(),i=Q.useRef(null),[l]=Q.useState(()=>r.getState().transform);return pg(()=>{let u=null;const c=()=>{const f=r.getState().transform;u&&f[0]===u[0]&&f[1]===u[1]&&f[2]===u[2]||(u=f,i.current&&(i.current.style.transform=Gh(f)))};return c(),r.subscribe(c)},[r]),E.jsx("div",{ref:i,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:Gh(l)},children:t})}function KS(t){const r=cc(),i=Q.useRef(!1);Q.useEffect(()=>{!i.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),i.current=!0)},[t,r.viewportInitialized])}const qS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function ZS(t){const r=je(qS),i=Oe();return Q.useEffect(()=>{t&&(r==null||r(t),i.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function JS(t){return t.connection.inProgress?{...t.connection,to:wi(t.connection.to,t.transform)}:{...t.connection}}function e_(t){return JS}function t_(t){const r=e_();return je(r,be)}const n_=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function r_({containerStyle:t,style:r,type:i,component:l}){const{nodesConnectable:u,width:c,height:f,isValid:h,inProgress:p}=je(n_,be);return!(c&&u&&p)?null:E.jsx("svg",{style:t,width:c,height:f,className:"react-flow__connectionline react-flow__container",children:E.jsx("g",{className:Xe(["react-flow__connection",Lp(h)]),children:E.jsx(Dg,{style:r,type:i,CustomComponent:l,isValid:h})})})}const Dg=({style:t,type:r=Xn.Bezier,CustomComponent:i,isValid:l})=>{const{inProgress:u,from:c,fromNode:f,fromHandle:h,fromPosition:p,to:y,toNode:g,toHandle:v,toPosition:m,pointer:w}=t_();if(!u)return;if(i)return E.jsx(i,{connectionLineType:r,connectionLineStyle:t,fromNode:f,fromHandle:h,fromX:c.x,fromY:c.y,toX:y.x,toY:y.y,fromPosition:p,toPosition:m,connectionStatus:Lp(l),toNode:g,toHandle:v,pointer:w});let S="";const P={sourceX:c.x,sourceY:c.y,sourcePosition:p,targetX:y.x,targetY:y.y,targetPosition:m};switch(r){case Xn.Bezier:[S]=Xp(P);break;case Xn.SimpleBezier:[S]=Eg(P);break;case Xn.Step:[S]=Va({...P,borderRadius:0});break;case Xn.SmoothStep:[S]=Va(P);break;default:[S]=Gp(P)}return E.jsx("path",{d:S,fill:"none",className:"react-flow__connection-path",style:t})};Dg.displayName="ConnectionLine";const o_={};function Kh(t=o_){Q.useRef(t),Oe(),Q.useEffect(()=>{},[t])}function i_(){Oe(),Q.useRef(!1),Q.useEffect(()=>{},[])}function Og({nodeTypes:t,edgeTypes:r,onInit:i,onNodeClick:l,onEdgeClick:u,onNodeDoubleClick:c,onEdgeDoubleClick:f,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:g,onSelectionContextMenu:v,onSelectionStart:m,onSelectionEnd:w,connectionLineType:S,connectionLineStyle:P,connectionLineComponent:C,connectionLineContainerStyle:k,selectionKeyCode:z,selectionOnDrag:_,selectionMode:I,multiSelectionKeyCode:H,panActivationKeyCode:$,zoomActivationKeyCode:B,deleteKeyCode:X,onlyRenderVisibleElements:G,elementsSelectable:te,defaultViewport:Z,translateExtent:ee,minZoom:J,maxZoom:N,preventScrolling:U,defaultMarkerColor:V,zoomOnScroll:b,zoomOnPinch:A,panOnScroll:L,panOnScrollSpeed:O,panOnScrollMode:M,zoomOnDoubleClick:j,panOnDrag:ne,autoPanOnSelection:re,onPaneClick:ae,onPaneMouseEnter:fe,onPaneMouseMove:ce,onPaneMouseLeave:K,onPaneScroll:se,onPaneContextMenu:pe,paneClickDistance:we,nodeClickDistance:ve,onEdgeContextMenu:me,onEdgeMouseEnter:Ne,onEdgeMouseMove:Pe,onEdgeMouseLeave:Ie,reconnectRadius:Re,onReconnect:Ze,onReconnectStart:nt,onReconnectEnd:Qe,noDragClassName:Ge,noWheelClassName:At,noPanClassName:kt,disableKeyboardA11y:Et,nodeExtent:rt,rfId:ft,viewport:st,onViewportChange:dt,nodesDraggable:cn}){return Kh(t),Kh(r),i_(),KS(i),ZS(st),E.jsx(SS,{onPaneClick:ae,onPaneMouseEnter:fe,onPaneMouseMove:ce,onPaneMouseLeave:K,onPaneContextMenu:pe,onPaneScroll:se,paneClickDistance:we,deleteKeyCode:X,selectionKeyCode:z,selectionOnDrag:_,selectionMode:I,onSelectionStart:m,onSelectionEnd:w,multiSelectionKeyCode:H,panActivationKeyCode:$,zoomActivationKeyCode:B,elementsSelectable:te,zoomOnScroll:b,zoomOnPinch:A,zoomOnDoubleClick:j,panOnScroll:L,panOnScrollSpeed:O,panOnScrollMode:M,panOnDrag:ne,autoPanOnSelection:re,defaultViewport:Z,translateExtent:ee,minZoom:J,maxZoom:N,onSelectionContextMenu:v,preventScrolling:U,noDragClassName:Ge,noWheelClassName:At,noPanClassName:kt,disableKeyboardA11y:Et,onViewportChange:dt,isControlledViewport:!!st,children:E.jsxs(GS,{children:[E.jsx(QS,{edgeTypes:r,onEdgeClick:u,onEdgeDoubleClick:f,onReconnect:Ze,onReconnectStart:nt,onReconnectEnd:Qe,onlyRenderVisibleElements:G,onEdgeContextMenu:me,onEdgeMouseEnter:Ne,onEdgeMouseMove:Pe,onEdgeMouseLeave:Ie,reconnectRadius:Re,defaultMarkerColor:V,noPanClassName:kt,disableKeyboardA11y:Et,rfId:ft}),E.jsx(r_,{style:P,type:S,component:C,containerStyle:k}),E.jsx("div",{className:"react-flow__edgelabel-renderer"}),E.jsx(TS,{nodeTypes:t,onNodeClick:l,onNodeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:g,nodeClickDistance:ve,onlyRenderVisibleElements:G,noPanClassName:kt,noDragClassName:Ge,disableKeyboardA11y:Et,nodeExtent:rt,rfId:ft,nodesDraggable:cn}),E.jsx("div",{className:"react-flow__viewport-portal"})]})})}Og.displayName="GraphView";const s_=Q.memo(Og),l_=Hp(),qh=({nodes:t,edges:r,defaultNodes:i,defaultEdges:l,width:u,height:c,fitView:f,fitViewOptions:h,minZoom:p=.5,maxZoom:y=2,nodeOrigin:g,nodeExtent:v,zIndexMode:m="basic"}={})=>{const w=new Map,S=new Map,P=new Map,C=new Map,k=l??r??[],z=i??t??[],_=g??[0,0],I=v??ai;Zp(P,C,k);const{nodesInitialized:H}=ba(z,w,S,{nodeOrigin:_,nodeExtent:I,zIndexMode:m});let $=[0,0,1];if(f&&u&&c){const B=vi(w,{filter:Z=>!!((Z.width||Z.initialWidth)&&(Z.height||Z.initialHeight))}),{x:X,y:G,zoom:te}=rc(B,u,c,p,y,(h==null?void 0:h.padding)??.1);$=[X,G,te]}return{rfId:"1",width:u??0,height:c??0,transform:$,nodes:z,nodesInitialized:H,nodeLookup:w,parentLookup:S,edges:k,edgeLookup:C,connectionLookup:P,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:i!==void 0,hasDefaultEdges:l!==void 0,panZoom:null,minZoom:p,maxZoom:y,translateExtent:ai,nodeExtent:I,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:oo.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:_,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:f??!1,fitViewOptions:h,fitViewResolver:null,connection:{...Rp},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:l_,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:zp,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},u_=({nodes:t,edges:r,defaultNodes:i,defaultEdges:l,width:u,height:c,fitView:f,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:g,nodeExtent:v,zIndexMode:m})=>w1((w,S)=>{async function P(){const{nodeLookup:C,panZoom:k,fitViewOptions:z,fitViewResolver:_,width:I,height:H,minZoom:$,maxZoom:B}=S();k&&(await mw({nodes:C,width:I,height:H,panZoom:k,minZoom:$,maxZoom:B},z),_==null||_.resolve(!0),w({fitViewResolver:null}))}return{...qh({nodes:t,edges:r,width:u,height:c,fitView:f,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:g,nodeExtent:v,defaultNodes:i,defaultEdges:l,zIndexMode:m}),setNodes:C=>{const{nodeLookup:k,parentLookup:z,nodeOrigin:_,nodeExtent:I,elevateNodesOnSelect:H,fitViewQueued:$,zIndexMode:B,nodesSelectionActive:X}=S(),{nodesInitialized:G,hasSelectedNodes:te}=ba(C,k,z,{nodeOrigin:_,nodeExtent:I,elevateNodesOnSelect:H,checkEquality:!0,zIndexMode:B}),Z=X&&te;$&&G?(P(),w({nodes:C,nodesInitialized:G,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:Z})):w({nodes:C,nodesInitialized:G,nodesSelectionActive:Z})},setEdges:C=>{const{connectionLookup:k,edgeLookup:z}=S();Zp(k,z,C),w({edges:C})},setDefaultNodesAndEdges:(C,k)=>{if(C){const{setNodes:z}=S();z(C),w({hasDefaultNodes:!0})}if(k){const{setEdges:z}=S();z(k),w({hasDefaultEdges:!0})}},updateNodeInternals:C=>{const{triggerNodeChanges:k,nodeLookup:z,parentLookup:_,domNode:I,nodeOrigin:H,nodeExtent:$,debug:B,fitViewQueued:X,zIndexMode:G}=S(),{changes:te,updatedInternals:Z}=Fw(C,z,_,I,H,$,G);Z&&(Aw(z,_,{nodeOrigin:H,nodeExtent:$,zIndexMode:G}),X?(P(),w({fitViewQueued:!1,fitViewOptions:void 0})):w({}),(te==null?void 0:te.length)>0&&(B&&console.log("React Flow: trigger node changes",te),k==null||k(te)))},updateNodePositions:(C,k=!1)=>{const z=[];let _=[];const{nodeLookup:I,triggerNodeChanges:H,connection:$,updateConnection:B,onNodesChangeMiddlewareMap:X}=S();for(const[G,te]of C){const Z=I.get(G),ee=!!(Z!=null&&Z.expandParent&&(Z!=null&&Z.parentId)&&(te!=null&&te.position)),J={id:G,type:"position",position:ee?{x:Math.max(0,te.position.x),y:Math.max(0,te.position.y)}:te.position,dragging:k};if(Z&&$.inProgress&&$.fromNode.id===Z.id){const N=_r(Z,$.fromHandle,Se.Left,!0);B({...$,from:N})}ee&&Z.parentId&&z.push({id:G,parentId:Z.parentId,rect:{...te.internals.positionAbsolute,width:te.measured.width??0,height:te.measured.height??0}}),_.push(J)}if(z.length>0){const{parentLookup:G,nodeOrigin:te}=S(),Z=ac(z,I,G,te);_.push(...Z)}for(const G of X.values())_=G(_);H(_)},triggerNodeChanges:C=>{const{onNodesChange:k,setNodes:z,nodes:_,hasDefaultNodes:I,debug:H}=S();if(C!=null&&C.length){if(I){const $=V1(C,_);z($)}H&&console.log("React Flow: trigger node changes",C),k==null||k(C)}},triggerEdgeChanges:C=>{const{onEdgesChange:k,setEdges:z,edges:_,hasDefaultEdges:I,debug:H}=S();if(C!=null&&C.length){if(I){const $=B1(C,_);z($)}H&&console.log("React Flow: trigger edge changes",C),k==null||k(C)}},addSelectedNodes:C=>{const{multiSelectionActive:k,edgeLookup:z,nodeLookup:_,triggerNodeChanges:I,triggerEdgeChanges:H}=S();if(k){const $=C.map(B=>pr(B,!0));I($);return}I(Jr(_,new Set([...C]),!0)),H(Jr(z))},addSelectedEdges:C=>{const{multiSelectionActive:k,edgeLookup:z,nodeLookup:_,triggerNodeChanges:I,triggerEdgeChanges:H}=S();if(k){const $=C.map(B=>pr(B,!0));H($);return}H(Jr(z,new Set([...C]))),I(Jr(_,new Set,!0))},unselectNodesAndEdges:({nodes:C,edges:k}={})=>{const{edges:z,nodes:_,nodeLookup:I,triggerNodeChanges:H,triggerEdgeChanges:$}=S(),B=C||_,X=k||z,G=[];for(const Z of B){if(!Z.selected)continue;const ee=I.get(Z.id);ee&&(ee.selected=!1),G.push(pr(Z.id,!1))}const te=[];for(const Z of X)Z.selected&&te.push(pr(Z.id,!1));H(G),$(te)},setMinZoom:C=>{const{panZoom:k,maxZoom:z}=S();k==null||k.setScaleExtent([C,z]),w({minZoom:C})},setMaxZoom:C=>{const{panZoom:k,minZoom:z}=S();k==null||k.setScaleExtent([z,C]),w({maxZoom:C})},setTranslateExtent:C=>{var k;(k=S().panZoom)==null||k.setTranslateExtent(C),w({translateExtent:C})},resetSelectedElements:()=>{const{edges:C,nodes:k,triggerNodeChanges:z,triggerEdgeChanges:_,elementsSelectable:I}=S();if(!I)return;const H=k.reduce((B,X)=>X.selected?[...B,pr(X.id,!1)]:B,[]),$=C.reduce((B,X)=>X.selected?[...B,pr(X.id,!1)]:B,[]);z(H),_($)},setNodeExtent:C=>{const{nodes:k,nodeLookup:z,parentLookup:_,nodeOrigin:I,elevateNodesOnSelect:H,nodeExtent:$,zIndexMode:B}=S();C[0][0]===$[0][0]&&C[0][1]===$[0][1]&&C[1][0]===$[1][0]&&C[1][1]===$[1][1]||(ba(k,z,_,{nodeOrigin:I,nodeExtent:C,elevateNodesOnSelect:H,checkEquality:!1,zIndexMode:B}),w({nodeExtent:C}))},panBy:C=>{const{transform:k,width:z,height:_,panZoom:I,translateExtent:H}=S();return Hw({delta:C,panZoom:I,transform:k,translateExtent:H,width:z,height:_})},setCenter:async(C,k,z)=>{const{width:_,height:I,maxZoom:H,panZoom:$}=S();if(!$)return!1;const B=typeof(z==null?void 0:z.zoom)<"u"?z.zoom:H;return await $.setViewport({x:_/2-C*B,y:I/2-k*B,zoom:B},{duration:z==null?void 0:z.duration,ease:z==null?void 0:z.ease,interpolate:z==null?void 0:z.interpolate}),!0},cancelConnection:()=>{w({connection:{...Rp}})},updateConnection:C=>{w({connection:C})},reset:()=>w({...qh()})}},Object.is);function Fg({initialNodes:t,initialEdges:r,defaultNodes:i,defaultEdges:l,initialWidth:u,initialHeight:c,initialMinZoom:f,initialMaxZoom:h,initialFitViewOptions:p,fitView:y,nodeOrigin:g,nodeExtent:v,zIndexMode:m,children:w}){const[S]=Q.useState(()=>u_({nodes:t,edges:r,defaultNodes:i,defaultEdges:l,width:u,height:c,fitView:y,minZoom:f,maxZoom:h,fitViewOptions:p,nodeOrigin:g,nodeExtent:v,zIndexMode:m}));return E.jsx(S1,{value:S,children:E.jsx(X1,{children:E.jsx(uS,{children:w})})})}function a_({children:t,nodes:r,edges:i,defaultNodes:l,defaultEdges:u,width:c,height:f,fitView:h,fitViewOptions:p,minZoom:y,maxZoom:g,nodeOrigin:v,nodeExtent:m,zIndexMode:w}){return Q.useContext(vl)?E.jsx(E.Fragment,{children:t}):E.jsx(Fg,{initialNodes:r,initialEdges:i,defaultNodes:l,defaultEdges:u,initialWidth:c,initialHeight:f,fitView:h,initialFitViewOptions:p,initialMinZoom:y,initialMaxZoom:g,nodeOrigin:v,nodeExtent:m,zIndexMode:w,children:t})}const c_={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function f_({nodes:t,edges:r,defaultNodes:i,defaultEdges:l,className:u,nodeTypes:c,edgeTypes:f,onNodeClick:h,onEdgeClick:p,onInit:y,onMove:g,onMoveStart:v,onMoveEnd:m,onConnect:w,onConnectStart:S,onConnectEnd:P,onClickConnectStart:C,onClickConnectEnd:k,onNodeMouseEnter:z,onNodeMouseMove:_,onNodeMouseLeave:I,onNodeContextMenu:H,onNodeDoubleClick:$,onNodeDragStart:B,onNodeDrag:X,onNodeDragStop:G,onNodesDelete:te,onEdgesDelete:Z,onDelete:ee,onSelectionChange:J,onSelectionDragStart:N,onSelectionDrag:U,onSelectionDragStop:V,onSelectionContextMenu:b,onSelectionStart:A,onSelectionEnd:L,onBeforeDelete:O,connectionMode:M,connectionLineType:j=Xn.Bezier,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ae,deleteKeyCode:fe="Backspace",selectionKeyCode:ce="Shift",selectionOnDrag:K=!1,selectionMode:se=ci.Full,panActivationKeyCode:pe="Space",multiSelectionKeyCode:we=di()?"Meta":"Control",zoomActivationKeyCode:ve=di()?"Meta":"Control",snapToGrid:me,snapGrid:Ne,onlyRenderVisibleElements:Pe=!1,selectNodesOnDrag:Ie,nodesDraggable:Re,autoPanOnNodeFocus:Ze,nodesConnectable:nt,nodesFocusable:Qe,nodeOrigin:Ge=fg,edgesFocusable:At,edgesReconnectable:kt,elementsSelectable:Et=!0,defaultViewport:rt=L1,minZoom:ft=.5,maxZoom:st=2,translateExtent:dt=ai,preventScrolling:cn=!0,nodeExtent:F,defaultMarkerColor:Ce="#b1b1b7",zoomOnScroll:Nt=!0,zoomOnPinch:Gn=!0,panOnScroll:Si=!1,panOnScrollSpeed:_l=.5,panOnScrollMode:uo=yr.Free,zoomOnDoubleClick:ao=!0,panOnDrag:co=!0,onPaneClick:fo,onPaneMouseEnter:ho,onPaneMouseMove:kn,onPaneMouseLeave:En,onPaneScroll:_i,onPaneContextMenu:ki,paneClickDistance:Ei=1,nodeClickDistance:Ni=0,children:Ci,onReconnect:po,onReconnectStart:Mi,onReconnectEnd:Kn,onEdgeContextMenu:go,onEdgeDoubleClick:qn,onEdgeMouseEnter:kl,onEdgeMouseMove:Zn,onEdgeMouseLeave:kr,reconnectRadius:Er=10,onNodesChange:mo,onEdgesChange:El,noDragClassName:Nl="nodrag",noWheelClassName:Cl="nowheel",noPanClassName:tn="nopan",fitView:yo,fitViewOptions:vo,connectOnClick:Ml,attributionPosition:Pi,proOptions:Ii,defaultEdgeOptions:Ti,elevateNodesOnSelect:ji=!0,elevateEdgesOnSelect:Pl=!1,disableKeyboardA11y:zi=!1,autoPanOnConnect:He,autoPanOnNodeDrag:Il,autoPanOnSelection:xo=!0,autoPanSpeed:Ri,connectionRadius:Nr,isValidConnection:Tl,onError:Li,style:Cr,id:Ct,nodeDragThreshold:jl,connectionDragThreshold:Mt,viewport:zl,onViewportChange:Rl,width:Ll,height:Mr,colorMode:Pr="light",debug:Jn,onScroll:fn,ariaLabelConfig:Al,zIndexMode:Ai="basic",...wo},$i){const er=Ct||"1",tr=O1(Pr),$l=Q.useCallback(Ir=>{Ir.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),fn==null||fn(Ir)},[fn]);return E.jsx("div",{"data-testid":"rf__wrapper",...wo,onScroll:$l,style:{...Cr,...c_},ref:$i,className:Xe(["react-flow",u,tr]),id:Ct,role:"application",children:E.jsxs(a_,{nodes:t,edges:r,width:Ll,height:Mr,fitView:yo,fitViewOptions:vo,minZoom:ft,maxZoom:st,nodeOrigin:Ge,nodeExtent:F,zIndexMode:Ai,children:[E.jsx(D1,{nodes:t,edges:r,defaultNodes:i,defaultEdges:l,onConnect:w,onConnectStart:S,onConnectEnd:P,onClickConnectStart:C,onClickConnectEnd:k,nodesDraggable:Re,autoPanOnNodeFocus:Ze,nodesConnectable:nt,nodesFocusable:Qe,edgesFocusable:At,edgesReconnectable:kt,elementsSelectable:Et,elevateNodesOnSelect:ji,elevateEdgesOnSelect:Pl,minZoom:ft,maxZoom:st,nodeExtent:F,onNodesChange:mo,onEdgesChange:El,snapToGrid:me,snapGrid:Ne,connectionMode:M,translateExtent:dt,connectOnClick:Ml,defaultEdgeOptions:Ti,fitView:yo,fitViewOptions:vo,onNodesDelete:te,onEdgesDelete:Z,onDelete:ee,onNodeDragStart:B,onNodeDrag:X,onNodeDragStop:G,onSelectionDrag:U,onSelectionDragStart:N,onSelectionDragStop:V,onMove:g,onMoveStart:v,onMoveEnd:m,noPanClassName:tn,nodeOrigin:Ge,rfId:er,autoPanOnConnect:He,autoPanOnNodeDrag:Il,autoPanSpeed:Ri,onError:Li,connectionRadius:Nr,isValidConnection:Tl,selectNodesOnDrag:Ie,nodeDragThreshold:jl,connectionDragThreshold:Mt,onBeforeDelete:O,debug:Jn,ariaLabelConfig:Al,zIndexMode:Ai}),E.jsx(s_,{onInit:y,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:z,onNodeMouseMove:_,onNodeMouseLeave:I,onNodeContextMenu:H,onNodeDoubleClick:$,nodeTypes:c,edgeTypes:f,connectionLineType:j,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ae,selectionKeyCode:ce,selectionOnDrag:K,selectionMode:se,deleteKeyCode:fe,multiSelectionKeyCode:we,panActivationKeyCode:pe,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Pe,defaultViewport:rt,translateExtent:dt,minZoom:ft,maxZoom:st,preventScrolling:cn,zoomOnScroll:Nt,zoomOnPinch:Gn,zoomOnDoubleClick:ao,panOnScroll:Si,panOnScrollSpeed:_l,panOnScrollMode:uo,panOnDrag:co,autoPanOnSelection:xo,onPaneClick:fo,onPaneMouseEnter:ho,onPaneMouseMove:kn,onPaneMouseLeave:En,onPaneScroll:_i,onPaneContextMenu:ki,paneClickDistance:Ei,nodeClickDistance:Ni,onSelectionContextMenu:b,onSelectionStart:A,onSelectionEnd:L,onReconnect:po,onReconnectStart:Mi,onReconnectEnd:Kn,onEdgeContextMenu:go,onEdgeDoubleClick:qn,onEdgeMouseEnter:kl,onEdgeMouseMove:Zn,onEdgeMouseLeave:kr,reconnectRadius:Er,defaultMarkerColor:Ce,noDragClassName:Nl,noWheelClassName:Cl,noPanClassName:tn,rfId:er,disableKeyboardA11y:zi,nodeExtent:F,viewport:zl,onViewportChange:Rl,nodesDraggable:Re}),E.jsx(R1,{onSelectionChange:J}),Ci,E.jsx(P1,{proOptions:Ii,position:Pi}),E.jsx(M1,{rfId:er,disableKeyboardA11y:zi})]})})}var d_=hg(f_);function h_({dimensions:t,lineWidth:r,variant:i,className:l}){return E.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:Xe(["react-flow__background-pattern",i,l])})}function p_({radius:t,className:r}){return E.jsx("circle",{cx:t,cy:t,r:t,className:Xe(["react-flow__background-pattern","dots",r])})}var Qn;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Qn||(Qn={}));const g_={[Qn.Dots]:1,[Qn.Lines]:1,[Qn.Cross]:6},m_=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function Hg({id:t,variant:r=Qn.Dots,gap:i=20,size:l,lineWidth:u=1,offset:c=0,color:f,bgColor:h,style:p,className:y,patternClassName:g}){const v=Q.useRef(null),{transform:m,patternId:w}=je(m_,be),S=l||g_[r],P=r===Qn.Dots,C=r===Qn.Cross,k=Array.isArray(i)?i:[i,i],z=[k[0]*m[2]||1,k[1]*m[2]||1],_=S*m[2],I=Array.isArray(c)?c:[c,c],H=C?[_,_]:z,$=[I[0]*m[2]+H[0]/2,I[1]*m[2]+H[1]/2],B=`${w}${t||""}`;return E.jsxs("svg",{className:Xe(["react-flow__background",y]),style:{...p,...wl,"--xy-background-color-props":h,"--xy-background-pattern-color-props":f},ref:v,"data-testid":"rf__background",children:[E.jsx("pattern",{id:B,x:m[0]%z[0],y:m[1]%z[1],width:z[0],height:z[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:P?E.jsx(p_,{radius:_/2,className:g}):E.jsx(h_,{dimensions:H,lineWidth:u,variant:r,className:g})}),E.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${B})`})]})}Hg.displayName="Background";const y_=Q.memo(Hg);function v_(){return E.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:E.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function x_(){return E.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:E.jsx("path",{d:"M0 0h32v4.2H0z"})})}function w_(){return E.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:E.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 S_(){return E.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:E.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 __(){return E.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:E.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 Ys({children:t,className:r,...i}){return E.jsx("button",{type:"button",className:Xe(["react-flow__controls-button",r]),...i,children:t})}const k_=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function Vg({style:t,showZoom:r=!0,showFitView:i=!0,showInteractive:l=!0,fitViewOptions:u,onZoomIn:c,onZoomOut:f,onFitView:h,onInteractiveChange:p,className:y,children:g,position:v="bottom-left",orientation:m="vertical","aria-label":w}){const S=Oe(),{isInteractive:P,minZoomReached:C,maxZoomReached:k,ariaLabelConfig:z}=je(k_,be),{zoomIn:_,zoomOut:I,fitView:H}=cc(),$=()=>{_(),c==null||c()},B=()=>{I(),f==null||f()},X=()=>{H(u),h==null||h()},G=()=>{S.setState({nodesDraggable:!P,nodesConnectable:!P,elementsSelectable:!P}),p==null||p(!P)},te=m==="horizontal"?"horizontal":"vertical";return E.jsxs(xl,{className:Xe(["react-flow__controls",te,y]),position:v,style:t,"data-testid":"rf__controls","aria-label":w??z["controls.ariaLabel"],children:[r&&E.jsxs(E.Fragment,{children:[E.jsx(Ys,{onClick:$,className:"react-flow__controls-zoomin",title:z["controls.zoomIn.ariaLabel"],"aria-label":z["controls.zoomIn.ariaLabel"],disabled:k,children:E.jsx(v_,{})}),E.jsx(Ys,{onClick:B,className:"react-flow__controls-zoomout",title:z["controls.zoomOut.ariaLabel"],"aria-label":z["controls.zoomOut.ariaLabel"],disabled:C,children:E.jsx(x_,{})})]}),i&&E.jsx(Ys,{className:"react-flow__controls-fitview",onClick:X,title:z["controls.fitView.ariaLabel"],"aria-label":z["controls.fitView.ariaLabel"],children:E.jsx(w_,{})}),l&&E.jsx(Ys,{className:"react-flow__controls-interactive",onClick:G,title:z["controls.interactive.ariaLabel"],"aria-label":z["controls.interactive.ariaLabel"],children:P?E.jsx(__,{}):E.jsx(S_,{})}),g]})}Vg.displayName="Controls";const E_=Q.memo(Vg);function N_({id:t,x:r,y:i,width:l,height:u,style:c,color:f,strokeColor:h,strokeWidth:p,className:y,borderRadius:g,shapeRendering:v,selected:m,onClick:w}){const{background:S,backgroundColor:P}=c||{},C=f||S||P;return E.jsx("rect",{className:Xe(["react-flow__minimap-node",{selected:m},y]),x:r,y:i,rx:g,ry:g,width:l,height:u,style:{fill:C,stroke:h,strokeWidth:p},shapeRendering:v,onClick:w?k=>w(k,t):void 0})}const C_=Q.memo(N_),M_=t=>t.nodes.map(r=>r.id),Ta=t=>t instanceof Function?t:()=>t;function P_({nodeStrokeColor:t,nodeColor:r,nodeClassName:i="",nodeBorderRadius:l=5,nodeStrokeWidth:u,nodeComponent:c=C_,onClick:f}){const h=je(M_,be),p=Ta(r),y=Ta(t),g=Ta(i),v=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return E.jsx(E.Fragment,{children:h.map(m=>E.jsx(T_,{id:m,nodeColorFunc:p,nodeStrokeColorFunc:y,nodeClassNameFunc:g,nodeBorderRadius:l,nodeStrokeWidth:u,NodeComponent:c,onClick:f,shapeRendering:v},m))})}function I_({id:t,nodeColorFunc:r,nodeStrokeColorFunc:i,nodeClassNameFunc:l,nodeBorderRadius:u,nodeStrokeWidth:c,shapeRendering:f,NodeComponent:h,onClick:p}){const{node:y,x:g,y:v,width:m,height:w}=je(S=>{const P=S.nodeLookup.get(t);if(!P)return{node:void 0,x:0,y:0,width:0,height:0};const C=P.internals.userNode,{x:k,y:z}=P.internals.positionAbsolute,{width:_,height:I}=en(C);return{node:C,x:k,y:z,width:_,height:I}},be);return!y||y.hidden||!Vp(y)?null:E.jsx(h,{x:g,y:v,width:m,height:w,style:y.style,selected:!!y.selected,className:l(y),color:r(y),borderRadius:u,strokeColor:i(y),strokeWidth:c,shapeRendering:f,onClick:p,id:y.id})}const T_=Q.memo(I_);var j_=Q.memo(P_);const z_=200,R_=150,L_=t=>!t.hidden,A_=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?Op(vi(t.nodeLookup,{filter:L_}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},Zh=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,$_=(t,r)=>Zh(t.viewBB,r.viewBB)&&Zh(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,D_="react-flow__minimap-desc";function Bg({style:t,className:r,nodeStrokeColor:i,nodeColor:l,nodeClassName:u="",nodeBorderRadius:c=5,nodeStrokeWidth:f,nodeComponent:h,bgColor:p,maskColor:y,maskStrokeColor:g,maskStrokeWidth:v,position:m="bottom-right",onClick:w,onNodeClick:S,pannable:P=!1,zoomable:C=!1,ariaLabel:k,inversePan:z,zoomStep:_=1,offsetScale:I=5}){const H=Oe(),$=Q.useRef(null),{boundingRect:B,viewBB:X,rfId:G,panZoom:te,translateExtent:Z,flowWidth:ee,flowHeight:J,ariaLabelConfig:N}=je(A_,$_),U=(t==null?void 0:t.width)??z_,V=(t==null?void 0:t.height)??R_,b=B.width/U,A=B.height/V,L=Math.max(b,A),O=L*U,M=L*V,j=I*L,ne=B.x-(O-B.width)/2-j,re=B.y-(M-B.height)/2-j,ae=O+j*2,fe=M+j*2,ce=`${D_}-${G}`,K=Q.useRef(0),se=Q.useRef();K.current=L,Q.useEffect(()=>{if($.current&&te)return se.current=Gw({domNode:$.current,panZoom:te,getTransform:()=>H.getState().transform,getViewScale:()=>K.current}),()=>{var me;(me=se.current)==null||me.destroy()}},[te]),Q.useEffect(()=>{var me;(me=se.current)==null||me.update({translateExtent:Z,width:ee,height:J,inversePan:z,pannable:P,zoomStep:_,zoomable:C})},[P,C,z,_,Z,ee,J]);const pe=w?me=>{var Ie;const[Ne,Pe]=((Ie=se.current)==null?void 0:Ie.pointer(me))||[0,0];w(me,{x:Ne,y:Pe})}:void 0,we=S?Q.useCallback((me,Ne)=>{const Pe=H.getState().nodeLookup.get(Ne).internals.userNode;S(me,Pe)},[]):void 0,ve=k??N["minimap.ariaLabel"];return E.jsx(xl,{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 g=="string"?g:void 0,"--xy-minimap-mask-stroke-width-props":typeof v=="number"?v*L:void 0,"--xy-minimap-node-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-node-stroke-color-props":typeof i=="string"?i:void 0,"--xy-minimap-node-stroke-width-props":typeof f=="number"?f:void 0},className:Xe(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:E.jsxs("svg",{width:U,height:V,viewBox:`${ne} ${re} ${ae} ${fe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ce,ref:$,onClick:pe,children:[ve&&E.jsx("title",{id:ce,children:ve}),E.jsx(j_,{onClick:we,nodeColor:l,nodeStrokeColor:i,nodeBorderRadius:c,nodeClassName:u,nodeStrokeWidth:f,nodeComponent:h}),E.jsx("path",{className:"react-flow__minimap-mask",d:`M${ne-j},${re-j}h${ae+j*2}v${fe+j*2}h${-ae-j*2}z + M${X.x},${X.y}h${X.width}v${X.height}h${-X.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Bg.displayName="MiniMap";const O_=Q.memo(Bg),F_=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,H_={[lo.Line]:"right",[lo.Handle]:"bottom-right"};function V_({nodeId:t,position:r,variant:i=lo.Handle,className:l,style:u=void 0,children:c,color:f,minWidth:h=10,minHeight:p=10,maxWidth:y=Number.MAX_VALUE,maxHeight:g=Number.MAX_VALUE,keepAspectRatio:v=!1,resizeDirection:m,autoScale:w=!0,shouldResize:S,onResizeStart:P,onResize:C,onResizeEnd:k}){const z=vg(),_=typeof t=="string"?t:z,I=Oe(),H=Q.useRef(null),$=i===lo.Handle,B=je(Q.useCallback(F_($&&w),[$,w]),be),X=Q.useRef(null),G=r??H_[i];Q.useEffect(()=>{if(!(!H.current||!_))return X.current||(X.current=u1({domNode:H.current,nodeId:_,getStoreItems:()=>{const{nodeLookup:Z,transform:ee,snapGrid:J,snapToGrid:N,nodeOrigin:U,domNode:V}=I.getState();return{nodeLookup:Z,transform:ee,snapGrid:J,snapToGrid:N,nodeOrigin:U,paneDomNode:V}},onChange:(Z,ee)=>{const{triggerNodeChanges:J,nodeLookup:N,parentLookup:U,nodeOrigin:V}=I.getState(),b=[],A={x:Z.x,y:Z.y},L=N.get(_);if(L&&L.expandParent&&L.parentId){const O=L.origin??V,M=Z.width??L.measured.width??0,j=Z.height??L.measured.height??0,ne={id:L.id,parentId:L.parentId,rect:{width:M,height:j,...Bp({x:Z.x??L.position.x,y:Z.y??L.position.y},{width:M,height:j},L.parentId,N,O)}},re=ac([ne],N,U,V);b.push(...re),A.x=Z.x?Math.max(O[0]*M,Z.x):void 0,A.y=Z.y?Math.max(O[1]*j,Z.y):void 0}if(A.x!==void 0&&A.y!==void 0){const O={id:_,type:"position",position:{...A}};b.push(O)}if(Z.width!==void 0&&Z.height!==void 0){const M={id:_,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:Z.width,height:Z.height}};b.push(M)}for(const O of ee){const M={...O,type:"position"};b.push(M)}J(b)},onEnd:({width:Z,height:ee})=>{const J={id:_,type:"dimensions",resizing:!1,dimensions:{width:Z,height:ee}};I.getState().triggerNodeChanges([J])}})),X.current.update({controlPosition:G,boundaries:{minWidth:h,minHeight:p,maxWidth:y,maxHeight:g},keepAspectRatio:v,resizeDirection:m,onResizeStart:P,onResize:C,onResizeEnd:k,shouldResize:S}),()=>{var Z;(Z=X.current)==null||Z.destroy()}},[G,h,p,y,g,v,P,C,k,S]);const te=G.split("-");return E.jsx("div",{className:Xe(["react-flow__resize-control","nodrag",...te,i,l]),ref:H,style:{...u,scale:B,...f&&{[$?"backgroundColor":"borderColor"]:f}},children:c})}Q.memo(V_);const B_={"arch.context":0,"django.app":0,"django.route":1,"django.url_name":1,"django.view":2,"django.viewset_action":2,"django.permission":2,"django.serializer":3,"django.serializer_field":4,"django.service":4,"django.model":5,"django.field":6,"django.relation":6,"django.task":7,"django.receiver":7,"django.signal":7,"django.test":7,"django.migration_op":7,"django.admin":7,"openapi.path":8,"react.api_client":9,"react.query_key":10,"react.hook":10,"react.feature":10,"react.route":11,"react.page":11,"react.component":12,"react.form_schema":13,"react.test":13,"react.context":12};function b_(t){return B_[t]??8}function U_(t){const r=new Map;for(const l of t){const u=b_(l.type),c=r.get(u)??[];c.push(l),r.set(u,c)}const i=new Map;for(const[l,u]of r)u.sort((c,f)=>c.name.localeCompare(f.name)),u.forEach((c,f)=>{i.set(c.id,{x:l*240,y:f*92})});return i}const W_={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function Y_({data:t}){return E.jsxs("div",{className:"lp-node",children:[E.jsx("div",{className:"t",children:t.type.split(".").pop()}),E.jsx("div",{className:"n",children:t.name})]})}const X_={load:Y_};function ja({nodes:t,edges:r}){const i=U_(t),l=t.map(c=>({id:c.id,type:"load",position:i.get(c.id)??{x:0,y:0},data:{name:c.name,type:c.type,file:c.file_path}})),u=r.filter(c=>t.some(f=>f.id===c.src)&&t.some(f=>f.id===c.dst)).map(c=>({id:c.id,source:c.src,target:c.dst,animated:c.weight==="critical",style:{stroke:W_[c.weight]||"var(--edge-cheap)",strokeWidth:c.weight==="critical"?2.4:1.2,strokeDasharray:c.confidence<.8?"6 4":void 0},label:c.type.replaceAll("_"," "),labelStyle:{fill:"var(--muted)",fontSize:9}}));return E.jsx(Fg,{children:E.jsxs(d_,{nodes:l,edges:u,nodeTypes:X_,fitView:!0,minZoom:.2,"data-testid":"impact-graph",children:[E.jsx(y_,{}),E.jsx(O_,{pannable:!0,zoomable:!0}),E.jsx(E_,{})]})})}const Ya=[{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:"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"}],Q_="obsidian",bg="loadpath.theme";function G_(t){return Ya.some(r=>r.id===t)}function Ug(){try{const t=localStorage.getItem(bg)||"";if(G_(t))return t}catch{}return Q_}function Wg(t){document.documentElement.dataset.theme=t;try{localStorage.setItem(bg,t)}catch{}}function K_(){var Re,Ze,nt,Qe,Ge,At,kt,Et,rt,ft,st,dt,cn;const[t,r]=Q.useState("review"),[i,l]=Q.useState(localStorage.getItem("loadpath.repo")||""),[u,c]=Q.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[f,h]=Q.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,y]=Q.useState(null),[g,v]=Q.useState(null),[m,w]=Q.useState([]),[S,P]=Q.useState("review"),[C,k]=Q.useState(""),[z,_]=Q.useState(""),[I,H]=Q.useState(""),[$,B]=Q.useState({}),[X,G]=Q.useState([]),[te,Z]=Q.useState(localStorage.getItem("loadpath.scmRepo")||""),[ee,J]=Q.useState(localStorage.getItem("loadpath.provider")||"github"),[N,U]=Q.useState(localStorage.getItem("loadpath.prNumber")||""),[V,b]=Q.useState(""),[A,L]=Q.useState(Ug),O=Q.useRef(i);O.current=i;const M=F=>{L(F),Wg(F)};Q.useEffect(()=>{St.settings().then(B).catch(()=>{}),St.repos().then(F=>w(F.repos)).catch(()=>{})},[]),Q.useEffect(()=>{if(t!=="architecture"||!i)return;const F=i;let Ce=!1;return St.architecture(F).then(Nt=>{!Ce&&O.current===F&&v(Nt)}).catch(()=>{}),()=>{Ce=!0}},[t,i]);const j=F=>{l(F),localStorage.setItem("loadpath.repo",F)},ne=(F,Ce)=>{c(F),h(Ce),localStorage.setItem("loadpath.base",F),localStorage.setItem("loadpath.head",Ce)},re=(F,Ce,Nt)=>{J(F),Z(Ce),localStorage.setItem("loadpath.provider",F),localStorage.setItem("loadpath.scmRepo",Ce),Nt!==void 0&&(U(Nt),localStorage.setItem("loadpath.prNumber",Nt))},ae=async(F=i)=>{if(!F)return null;const Ce=await St.architecture(F);return O.current===F&&v(Ce),Ce},fe=async()=>{k(""),H(""),_("Tracing load path…"),j(i),ne(u,f);try{const F=await St.review(i,u,f,!0);y(F),P("review"),r("review"),await St.repos().then(Ce=>w(Ce.repos)).catch(()=>{}),await ae(i)}catch(F){k(F instanceof Error?F.message:String(F))}finally{_("")}},ce=async(F=!0)=>{k(""),H(""),_(F?"Indexing…":"Full reindex…"),j(i);try{await St.index(i,F);const Ce=await ae(i);await St.repos().then(Nt=>w(Nt.repos)).catch(()=>{}),Ce!=null&&Ce.indexed&&(P("architecture"),r("architecture"))}catch(Ce){k(Ce instanceof Error?Ce.message:String(Ce))}finally{_("")}},K=async()=>{k(""),H(""),_("Detecting layout…"),j(i);try{const F=await St.init(i);H(F.message),await St.repos().then(Ce=>w(Ce.repos)).catch(()=>{})}catch(F){k(F instanceof Error?F.message:String(F))}finally{_("")}},se=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),H("Copied markdown brief")}catch(F){k(F instanceof Error?F.message:String(F))}},pe=async()=>{if(!(p!=null&&p.markdown)||!te||!N){k("Pick a pull request first (Pull requests tab), then post the brief.");return}_("Posting Loadpath brief…");try{const F=await St.postComment(ee,te,Number(N),p.markdown);H(F.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(F){k(F instanceof Error?F.message:String(F))}finally{_("")}},we=async()=>{k(""),_("Fetching pull requests…");try{const F=await St.prs(ee,te);G(F.pull_requests)}catch(F){k(F instanceof Error?F.message:String(F))}finally{_("")}},ve=async F=>{F.preventDefault();const Ce=new FormData(F.currentTarget),Nt={github_token:String(Ce.get("github_token")||""),bitbucket_token:String(Ce.get("bitbucket_token")||""),bitbucket_username:String(Ce.get("bitbucket_username")||""),ai_provider:String(Ce.get("ai_provider")||"none"),ai_api_key:String(Ce.get("ai_api_key")||""),ai_model:String(Ce.get("ai_model")||""),ai_base_url:String(Ce.get("ai_base_url")||""),workspaces:m.length?m.map(Gn=>({path:Gn.path,name:Gn.name})):i?[{path:i,name:i.split(/[\\/]/).pop()}]:[]};B(await St.saveSettings(Nt))},me=async()=>{if(p){_("Residual analysis…");try{const F=await St.residual(p);b(F.note)}catch(F){k(F instanceof Error?F.message:String(F))}finally{_("")}}},Ne=Q.useMemo(()=>S==="architecture"?(g==null?void 0:g.nodes)??[]:(p==null?void 0:p.nodes)??[],[S,g,p]),Pe=Q.useMemo(()=>S==="architecture"?(g==null?void 0:g.edges)??[]:(p==null?void 0:p.edges)??[],[S,g,p]),Ie=p!=null&&p.index?`${p.index.counts.nodes} nodes / ${p.index.counts.edges} edges · ${p.index.incremental?"incremental":"full"}${p.index.stale?" · STALE":""}${p.index.django_boot&&p.index.django_boot!=="off"?` · boot ${p.index.django_boot}`:""}`:g!=null&&g.indexed?`${g.counts.nodes} nodes / ${g.counts.edges} edges indexed${g.stale?" · STALE":""}`:"Not indexed";return E.jsxs("div",{className:"app",children:[E.jsxs("nav",{className:"rail","data-testid":"rail",children:[E.jsx("div",{className:"brand",children:"Loadpath"}),E.jsx("button",{"data-testid":"tab-review",className:t==="review"?"active":"",onClick:()=>r("review"),children:"Review"}),E.jsx("button",{"data-testid":"tab-architecture",className:t==="architecture"?"active":"",onClick:()=>r("architecture"),children:"Architecture"}),E.jsx("button",{"data-testid":"tab-graph",className:t==="graph"?"active":"",onClick:()=>r("graph"),children:"Impact graph"}),E.jsx("button",{"data-testid":"tab-prs",className:t==="prs"?"active":"",onClick:()=>r("prs"),children:"Pull requests"}),E.jsx("button",{"data-testid":"tab-settings",className:t==="settings"?"active":"",onClick:()=>r("settings"),children:"Settings"}),E.jsxs("div",{className:"theme-pick",children:[E.jsx("label",{htmlFor:"theme-select",children:"Theme"}),E.jsx("select",{id:"theme-select","data-testid":"theme-select",value:A,onChange:F=>M(F.target.value),children:Ya.map(F=>E.jsx("option",{value:F.id,children:F.label},F.id))})]}),E.jsx("div",{style:{flex:1}}),E.jsx("div",{className:"muted",children:z||Ie})]}),E.jsxs("div",{className:"main",children:[E.jsxs("div",{className:"topbar","data-testid":"topbar",children:[m.length>0?E.jsxs("select",{"data-testid":"workspace-select",value:m.some(F=>F.path===i)?i:"",onChange:F=>{F.target.value&&j(F.target.value)},children:[E.jsx("option",{value:"",children:"Indexed repos…"}),m.map(F=>E.jsxs("option",{value:F.path,children:[F.name,F.indexed?` (${F.counts.nodes})`:""]},F.path))]}):null,E.jsx("input",{"data-testid":"repo-path",className:"path",placeholder:"Local monorepo path",value:i,onChange:F=>l(F.target.value)}),E.jsx("input",{"data-testid":"base-ref",value:u,onChange:F=>ne(F.target.value,f),placeholder:"base"}),E.jsx("input",{"data-testid":"head-ref",value:f,onChange:F=>ne(u,F.target.value),placeholder:"head"}),E.jsx("button",{"data-testid":"btn-init",onClick:K,children:"Draft config"}),E.jsx("button",{"data-testid":"btn-index",onClick:()=>ce(!0),children:"Index"}),E.jsx("button",{"data-testid":"btn-review",className:"btn primary",onClick:fe,children:"Review"})]}),C?E.jsx("div",{className:"error",children:C}):null,I?E.jsx("div",{className:"banner","data-testid":"status-note",children:I}):null,((Re=p==null?void 0:p.index)!=null&&Re.stale||g!=null&&g.stale)&&(t==="review"||t==="architecture")?E.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,((Ze=p==null?void 0:p.index)==null?void 0:Ze.django_boot)==="failed"||(g==null?void 0:g.django_boot)==="failed"?E.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((nt=p==null?void 0:p.index)==null?void 0:nt.django_boot_detail)||(g==null?void 0:g.django_boot_detail)||"django.setup() failed"}):null,(Qe=p==null?void 0:p.workspace)!=null&&Qe.dirty_overlaps_review&&t==="review"?E.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,t==="review"&&E.jsxs("div",{className:"content","data-testid":"review-layout",children:[E.jsx("aside",{className:"brief","data-testid":"brief",children:p?E.jsxs(E.Fragment,{children:[E.jsxs("div",{className:`level ${p.confidence.level}`,children:[p.confidence.level.toUpperCase()," — ",p.title]}),p.low_risk?E.jsx("span",{className:"chip",children:"loadpath:low-risk"}):null,p.change_kinds.map(F=>E.jsx("span",{className:"chip",children:F.replaceAll("_"," ")},F)),E.jsx("pre",{className:"headline",children:p.headline}),p.index?E.jsxs(E.Fragment,{children:[E.jsx("div",{className:"kicker",children:"Index"}),E.jsxs("div",{className:"muted",children:["Walked ",p.index.counts.nodes," nodes / ",p.index.counts.edges," edges",p.index.reindex_skipped?" from an unchanged index":p.index.reindexed?" after an incremental refresh":" from the existing index",p.index.django_boot&&p.index.django_boot!=="off"?` · Django boot ${p.index.django_boot}`:"",(Ge=p.workspace)!=null&&Ge.three_dot?" · three-dot range":""]})]}):null,E.jsx("div",{className:"kicker",children:"Read this"}),p.read_order.map(F=>E.jsxs("div",{children:[E.jsx("span",{className:"file",children:F.path}),E.jsx("div",{className:"muted",children:F.why})]},F.path)),E.jsx("div",{className:"kicker",children:"Clusters"}),p.clusters.map(F=>E.jsxs("div",{className:"muted",children:[E.jsx("strong",{children:F.title})," — ",F.files.join(", ")]},F.id)),E.jsx("div",{className:"kicker",children:"Architecture"}),p.findings.filter(F=>!F.waived).length===0?E.jsx("div",{className:"muted",children:p.architecture_note}):p.findings.filter(F=>!F.waived).map(F=>E.jsxs("div",{className:"muted",children:[E.jsx("span",{className:`chip ${F.severity}`,children:F.severity}),F.message]},F.rule+F.message)),E.jsx("div",{className:"kicker",children:"Residual (AI only here)"}),p.residuals.map(F=>E.jsx("div",{className:"muted",children:F},F)),(kt=(At=p.evolution)==null?void 0:At.notes)!=null&&kt.length||(rt=(Et=p.evolution)==null?void 0:Et.hotspots)!=null&&rt.some(F=>F.commits)?E.jsxs(E.Fragment,{children:[E.jsx("div",{className:"kicker",children:"Churn & coupling"}),(((ft=p.evolution)==null?void 0:ft.notes)||[]).map(F=>E.jsx("div",{className:"muted",children:F},F)),(((st=p.evolution)==null?void 0:st.hotspots)||[]).filter(F=>F.commits).slice(0,6).map(F=>E.jsxs("div",{className:"muted",children:[E.jsx("span",{className:"file",children:F.path})," — ",F.commits," commits, bus factor ",F.bus_factor]},F.path))]}):null,E.jsxs("div",{className:"btn-row",children:[E.jsx("button",{className:"btn",onClick:me,children:"Ask configured model"}),E.jsx("button",{className:"btn","data-testid":"btn-copy-markdown",onClick:se,children:"Copy markdown"}),E.jsx("button",{className:"btn","data-testid":"btn-post-comment",onClick:pe,children:"Post to PR"})]}),V?E.jsx("pre",{className:"headline",children:V}):null,E.jsx("div",{className:"kicker",children:"Reviewers"}),E.jsx("div",{className:"muted",children:p.suggested_reviewers.join(", ")||"—"}),(dt=p.knowledge_owners)!=null&&dt.length?E.jsxs("div",{className:"muted",children:["Knowledge: ",p.knowledge_owners.join(", ")]}):null]}):E.jsxs("div",{className:"empty","data-testid":"review-empty",children:[E.jsx("p",{children:"The graph is the architecture. The brief is the force of this diff — not a hunk list."}),E.jsxs("ol",{children:[E.jsx("li",{children:"Point at a Django + React monorepo (or pick an indexed workspace)."}),E.jsxs("li",{children:["Index it. Missing ",E.jsx("code",{children:"loadpath.yml"})," is drafted from ",E.jsx("code",{children:"manage.py"})," and"," ",E.jsx("code",{children:"src/features"}),"."]}),E.jsx("li",{children:"Review a git range, or pick a pull request so base/head become a three-dot merge-base."})]})]})}),E.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?E.jsx(ja,{nodes:p.nodes,edges:p.edges}):null})]}),t==="architecture"&&E.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[E.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:g!=null&&g.indexed?E.jsxs(E.Fragment,{children:[E.jsxs("div",{className:"level high",children:["INDEXED — ",g.counts.nodes," nodes"]}),E.jsxs("span",{className:"chip",children:[g.counts.edges," edges"]}),g.has_config?E.jsx("span",{className:"chip",children:"loadpath.yml"}):null,E.jsxs("div",{className:"muted",style:{marginTop:8},children:[g.indexed_at?`Last index ${g.indexed_at}`:"Indexed",g.incremental?" · incremental":" · full",g.stale?" · stale":"",g.django_boot&&g.django_boot!=="off"?` · Django boot ${g.django_boot}`:""]}),E.jsx("div",{className:"kicker",children:"Bounded contexts"}),Object.values(g.contexts).map(F=>E.jsxs("div",{className:"muted",children:[E.jsx("strong",{children:F.name})," — ",(F.django_apps||[]).join(", ")||"no apps"," ·"," ",(F.owners||[]).join(", ")||"unowned"]},F.name)),E.jsx("div",{className:"kicker",children:"Rules"}),(g.rules||[]).map(F=>E.jsx("div",{className:"muted",children:F},F)),E.jsx("div",{className:"kicker",children:"Findings on the indexed graph"}),g.findings.filter(F=>!F.waived).length===0?E.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):g.findings.filter(F=>!F.waived).map(F=>E.jsxs("div",{className:"muted",children:[E.jsx("span",{className:`chip ${F.severity}`,children:F.severity}),F.message]},F.rule+F.message)),E.jsx("div",{className:"kicker",children:"Types"}),E.jsx("div",{className:"muted",children:Object.entries(g.type_counts||{}).sort((F,Ce)=>Ce[1]-F[1]).slice(0,12).map(([F,Ce])=>`${F.split(".").pop()} ${Ce}`).join(" · ")}),E.jsx("button",{className:"btn",style:{marginTop:12},onClick:()=>ce(!1),"data-testid":"btn-full-reindex",children:"Full reindex"}),E.jsx("button",{className:"btn primary",style:{marginTop:8},onClick:fe,children:"Review against this index"})]}):E.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."})}),E.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:g!=null&&g.indexed?E.jsx(ja,{nodes:g.nodes,edges:g.edges}):null})]}),t==="graph"&&E.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%",display:"flex",flexDirection:"column"},children:[E.jsxs("div",{className:"graph-modes",children:[E.jsx("button",{"data-testid":"graph-mode-review",className:S==="review"?"active":"",onClick:()=>P("review"),children:"This review"}),E.jsx("button",{"data-testid":"graph-mode-architecture",className:S==="architecture"?"active":"",onClick:()=>P("architecture"),children:"Indexed architecture"})]}),Ne.length?E.jsx("div",{style:{flex:1,minHeight:0},children:E.jsx(ja,{nodes:Ne,edges:Pe})}):E.jsx("p",{className:"muted",children:"Index the repo or run a review first."})]}),t==="prs"&&E.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[E.jsxs("div",{className:"topbar",style:{border:0,padding:0,marginBottom:12},children:[E.jsxs("select",{"data-testid":"pr-provider",value:ee,onChange:F=>re(F.target.value,te,N),children:[E.jsx("option",{value:"github",children:"GitHub"}),E.jsx("option",{value:"bitbucket",children:"Bitbucket"})]}),E.jsx("input",{"data-testid":"pr-repo",className:"path",placeholder:"owner/repo",value:te,onChange:F=>re(ee,F.target.value,N)}),E.jsx("button",{"data-testid":"btn-list-prs",onClick:we,children:"List PRs"})]}),X.map(F=>E.jsxs("article",{className:"pr","data-testid":`pr-${F.number}`,children:[E.jsxs("h3",{children:["#",F.number," ",F.title]}),E.jsxs("div",{className:"muted",children:[F.author," · ",F.source_branch," → ",F.target_branch," · ",F.provider]}),E.jsxs("a",{href:F.url,target:"_blank",rel:"noreferrer",children:["Open on ",F.provider]}),E.jsx("div",{children:E.jsx("button",{className:"btn",onClick:()=>{ne(F.base_sha||F.target_branch,F.head_sha||F.source_branch),re(F.provider,F.repo,String(F.number)),r("review")},children:"Review this branch range"})})]},`${F.provider}-${F.number}`))]}),t==="settings"&&E.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:ve,children:[E.jsx("h1",{children:"Keys & providers"}),E.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. GitHub and Bitbucket power the PR list. Indexed repos are remembered as workspaces. AI is used only for residual uncertainty the graph could not close."}),E.jsx("h1",{children:"Theme"}),E.jsx("p",{className:"muted",children:"Appearance is local to this browser. Pick a palette that matches how you review."}),E.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Ya.map(F=>E.jsxs("button",{type:"button",className:A===F.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${F.id}`,onClick:()=>M(F.id),children:[E.jsx("div",{className:"name",children:F.label}),E.jsx("div",{className:"group",children:F.group})]},F.id))}),E.jsx("label",{children:"GitHub token"}),E.jsx("input",{name:"github_token",type:"password",placeholder:"ghp_…"}),E.jsx("label",{children:"Bitbucket token"}),E.jsx("input",{name:"bitbucket_token",type:"password"}),E.jsx("label",{children:"Bitbucket username (app passwords)"}),E.jsx("input",{name:"bitbucket_username",defaultValue:String($.bitbucket_username||"")}),E.jsx("label",{children:"AI provider"}),E.jsxs("select",{name:"ai_provider",defaultValue:String(((cn=$.ai)==null?void 0:cn.provider)||"none"),children:[E.jsx("option",{value:"none",children:"none (graph only)"}),E.jsx("option",{value:"anthropic",children:"Anthropic"}),E.jsx("option",{value:"openai",children:"OpenAI"}),E.jsx("option",{value:"grok",children:"Grok / xAI"}),E.jsx("option",{value:"deepseek",children:"DeepSeek"}),E.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),E.jsx("option",{value:"ollama",children:"Ollama local"})]}),E.jsx("label",{children:"AI API key"}),E.jsx("input",{name:"ai_api_key",type:"password"}),E.jsx("label",{children:"Model"}),E.jsx("input",{name:"ai_model",placeholder:"optional override"}),E.jsx("label",{children:"Base URL"}),E.jsx("input",{name:"ai_base_url",placeholder:"optional, OpenAI-compatible"}),E.jsx("button",{className:"btn primary",type:"submit",children:"Save"})]})]})]})}Wg(Ug());z0.createRoot(document.getElementById("root")).render(E.jsx(Q.StrictMode,{children:E.jsx(K_,{})})); diff --git a/src/loadpath/static/assets/index-mbetuo0f.js b/src/loadpath/static/assets/index-mbetuo0f.js deleted file mode 100644 index 6daa482..0000000 --- a/src/loadpath/static/assets/index-mbetuo0f.js +++ /dev/null @@ -1,62 +0,0 @@ -(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))l(u);new MutationObserver(u=>{for(const c of u)if(c.type==="childList")for(const f of c.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&l(f)}).observe(document,{childList:!0,subtree:!0});function i(u){const c={};return u.integrity&&(c.integrity=u.integrity),u.referrerPolicy&&(c.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?c.credentials="include":u.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function l(u){if(u.ep)return;u.ep=!0;const c=i(u);fetch(u.href,c)}})();function Jh(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ha={exports:{}},qo={},pa={exports:{}},Me={};/** - * @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 Ad;function k0(){if(Ad)return Me;Ad=1;var t=Symbol.for("react.element"),r=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),f=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),v=Symbol.iterator;function m(M){return M===null||typeof M!="object"?null:(M=v&&M[v]||M["@@iterator"],typeof M=="function"?M:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,P={};function C(M,z,ne){this.props=M,this.context=z,this.refs=P,this.updater=ne||w}C.prototype.isReactComponent={},C.prototype.setState=function(M,z){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,z,"setState")},C.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function E(){}E.prototype=C.prototype;function j(M,z,ne){this.props=M,this.context=z,this.refs=P,this.updater=ne||w}var _=j.prototype=new E;_.constructor=j,S(_,C.prototype),_.isPureReactComponent=!0;var I=Array.isArray,F=Object.prototype.hasOwnProperty,$={current:null},B={key:!0,ref:!0,__self:!0,__source:!0};function X(M,z,ne){var re,ae={},fe=null,ce=null;if(z!=null)for(re in z.ref!==void 0&&(ce=z.ref),z.key!==void 0&&(fe=""+z.key),z)F.call(z,re)&&!B.hasOwnProperty(re)&&(ae[re]=z[re]);var K=arguments.length-2;if(K===1)ae.children=ne;else if(1>>1,z=A[M];if(0>>1;Mu(ae,O))feu(ce,ae)?(A[M]=ce,A[fe]=O,M=fe):(A[M]=ae,A[re]=O,M=re);else if(feu(ce,O))A[M]=ce,A[fe]=O,M=fe;else break e}}return L}function u(A,L){var O=A.sortIndex-L.sortIndex;return O!==0?O:A.id-L.id}if(typeof performance=="object"&&typeof performance.now=="function"){var c=performance;t.unstable_now=function(){return c.now()}}else{var f=Date,h=f.now();t.unstable_now=function(){return f.now()-h}}var p=[],y=[],g=1,v=null,m=3,w=!1,S=!1,P=!1,C=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function _(A){for(var L=i(y);L!==null;){if(L.callback===null)l(y);else if(L.startTime<=A)l(y),L.sortIndex=L.expirationTime,r(p,L);else break;L=i(y)}}function I(A){if(P=!1,_(A),!S)if(i(p)!==null)S=!0,H(F);else{var L=i(y);L!==null&&b(I,L.startTime-A)}}function F(A,L){S=!1,P&&(P=!1,E(X),X=-1),w=!0;var O=m;try{for(_(L),v=i(p);v!==null&&(!(v.expirationTime>L)||A&&!Z());){var M=v.callback;if(typeof M=="function"){v.callback=null,m=v.priorityLevel;var z=M(v.expirationTime<=L);L=t.unstable_now(),typeof z=="function"?v.callback=z:v===i(p)&&l(p),_(L)}else l(p);v=i(p)}if(v!==null)var ne=!0;else{var re=i(y);re!==null&&b(I,re.startTime-L),ne=!1}return ne}finally{v=null,m=O,w=!1}}var $=!1,B=null,X=-1,G=5,te=-1;function Z(){return!(t.unstable_now()-teA||125M?(A.sortIndex=O,r(y,A),i(p)===null&&A===i(y)&&(P?(E(X),X=-1):P=!0,b(I,O-M))):(A.sortIndex=z,r(p,A),S||w||(S=!0,H(F))),A},t.unstable_shouldYield=Z,t.unstable_wrapCallback=function(A){var L=m;return function(){var O=m;m=L;try{return A.apply(this,arguments)}finally{m=O}}}})(ya)),ya}var Hd;function I0(){return Hd||(Hd=1,ma.exports=P0()),ma.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 Vd;function T0(){if(Vd)return St;Vd=1;var t=hi(),r=I0();function i(e){for(var n="https://reactjs.org/docs/error-decoder.html?invariant="+e,o=1;o"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]*$/,g={},v={};function m(e){return p.call(v,e)?!0:p.call(g,e)?!1:y.test(e)?v[e]=!0:(g[e]=!0,!1)}function w(e,n,o,s){if(o!==null&&o.type===0)return!1;switch(typeof n){case"function":case"symbol":return!0;case"boolean":return s?!1:o!==null?!o.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function S(e,n,o,s){if(n===null||typeof n>"u"||w(e,n,o,s))return!0;if(s)return!1;if(o!==null)switch(o.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 P(e,n,o,s,a,d,x){this.acceptsBooleans=n===2||n===3||n===4,this.attributeName=s,this.attributeNamespace=a,this.mustUseProperty=o,this.propertyName=e,this.type=n,this.sanitizeURL=d,this.removeEmptyString=x}var C={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){C[e]=new P(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var n=e[0];C[n]=new P(n,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){C[e]=new P(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){C[e]=new P(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){C[e]=new P(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){C[e]=new P(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){C[e]=new P(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){C[e]=new P(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){C[e]=new P(e,5,!1,e.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function j(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,j);C[n]=new P(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,j);C[n]=new P(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,j);C[n]=new P(n,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){C[e]=new P(e,1,!1,e.toLowerCase(),null,!1,!1)}),C.xlinkHref=new P("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){C[e]=new P(e,1,!1,e.toLowerCase(),null,!0,!0)});function _(e,n,o,s){var a=C.hasOwnProperty(n)?C[n]:null;(a!==null?a.type!==0:s||!(2T||a[x]!==d[T]){var R=` -`+a[x].replace(" at new "," at ");return e.displayName&&R.includes("")&&(R=R.replace("",e.displayName)),R}while(1<=x&&0<=T);break}}}finally{ne=!1,Error.prepareStackTrace=o}return(e=e?e.displayName||e.name:"")?z(e):""}function ae(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=re(e.type,!1),e;case 11:return e=re(e.type.render,!1),e;case 1:return e=re(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 B:return"Fragment";case $:return"Portal";case G:return"Profiler";case X:return"StrictMode";case J:return"Suspense";case N:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Z:return(e.displayName||"Context")+".Consumer";case te:return(e._context.displayName||"Context")+".Provider";case ee: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:fe(e.type)||"Memo";case H:n=e._payload,e=e._init;try{return fe(e(n))}catch{}}return null}function ce(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===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 K(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 pe(e){var n=se(e)?"checked":"value",o=Object.getOwnPropertyDescriptor(e.constructor.prototype,n),s=""+e[n];if(!e.hasOwnProperty(n)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var a=o.get,d=o.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return a.call(this)},set:function(x){s=""+x,d.call(this,x)}}),Object.defineProperty(e,n,{enumerable:o.enumerable}),{getValue:function(){return s},setValue:function(x){s=""+x},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function we(e){e._valueTracker||(e._valueTracker=pe(e))}function ve(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var o=n.getValue(),s="";return e&&(s=se(e)?e.checked?"true":"false":e.value),e=s,e!==o?(n.setValue(e),!0):!1}function me(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 Ce(e,n){var o=n.checked;return O({},n,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:o??e._wrapperState.initialChecked})}function Pe(e,n){var o=n.defaultValue==null?"":n.defaultValue,s=n.checked!=null?n.checked:n.defaultChecked;o=K(n.value!=null?n.value:o),e._wrapperState={initialChecked:s,initialValue:o,controlled:n.type==="checkbox"||n.type==="radio"?n.checked!=null:n.value!=null}}function Ie(e,n){n=n.checked,n!=null&&_(e,"checked",n,!1)}function Re(e,n){Ie(e,n);var o=K(n.value),s=n.type;if(o!=null)s==="number"?(o===0&&e.value===""||e.value!=o)&&(e.value=""+o):e.value!==""+o&&(e.value=""+o);else if(s==="submit"||s==="reset"){e.removeAttribute("value");return}n.hasOwnProperty("value")?nt(e,n.type,o):n.hasOwnProperty("defaultValue")&&nt(e,n.type,K(n.defaultValue)),n.checked==null&&n.defaultChecked!=null&&(e.defaultChecked=!!n.defaultChecked)}function Ze(e,n,o){if(n.hasOwnProperty("value")||n.hasOwnProperty("defaultValue")){var s=n.type;if(!(s!=="submit"&&s!=="reset"||n.value!==void 0&&n.value!==null))return;n=""+e._wrapperState.initialValue,o||n===e.value||(e.value=n),e.defaultValue=n}o=e.name,o!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,o!==""&&(e.name=o)}function nt(e,n,o){(n!=="number"||me(e.ownerDocument)!==e)&&(o==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+o&&(e.defaultValue=""+o))}var Qe=Array.isArray;function Ge(e,n,o,s){if(e=e.options,n){n={};for(var a=0;a"+n.valueOf().toString()+"",n=ht.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;n.firstChild;)e.appendChild(n.firstChild)}});function Ne(e,n){if(n){var o=e.firstChild;if(o&&o===e.lastChild&&o.nodeType===3){o.nodeValue=n;return}}e.textContent=n}var ot={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},Sr=["Webkit","ms","Moz","O"];Object.keys(ot).forEach(function(e){Sr.forEach(function(n){n=n+e.charAt(0).toUpperCase()+e.substring(1),ot[n]=ot[e]})});function wi(e,n,o){return n==null||typeof n=="boolean"||n===""?"":o||typeof n!="number"||n===0||ot.hasOwnProperty(e)&&ot[e]?(""+n).trim():n+"px"}function Si(e,n){e=e.style;for(var o in n)if(n.hasOwnProperty(o)){var s=o.indexOf("--")===0,a=wi(o,n[o],s);o==="float"&&(o="cssFloat"),s?e.setProperty(o,a):e[o]=a}}var _l=O({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 lo(e,n){if(n){if(_l[e]&&(n.children!=null||n.dangerouslySetInnerHTML!=null))throw Error(i(137,e));if(n.dangerouslySetInnerHTML!=null){if(n.children!=null)throw Error(i(60));if(typeof n.dangerouslySetInnerHTML!="object"||!("__html"in n.dangerouslySetInnerHTML))throw Error(i(61))}if(n.style!=null&&typeof n.style!="object")throw Error(i(62))}}function uo(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 ao=null;function co(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var fo=null,_n=null,En=null;function _i(e){if(e=$o(e)){if(typeof fo!="function")throw Error(i(280));var n=e.stateNode;n&&(n=Zi(n),fo(e.stateNode,e.type,n))}}function Ei(e){_n?En?En.push(e):En=[e]:_n=e}function ki(){if(_n){var e=_n,n=En;if(En=_n=null,_i(e),n)for(e=0;e>>=0,e===0?32:31-(jl(e)/Rl|0)|0}var Cr=64,Mr=4194304;function qn(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 cn(e,n){var o=e.pendingLanes;if(o===0)return 0;var s=0,a=e.suspendedLanes,d=e.pingedLanes,x=o&268435455;if(x!==0){var T=x&~a;T!==0?s=qn(T):(d&=x,d!==0&&(s=qn(d)))}else x=o&~a,x!==0?s=qn(x):d!==0&&(s=qn(d));if(s===0)return 0;if(n!==0&&n!==s&&(n&a)===0&&(a=s&-s,d=n&-n,a>=d||a===16&&(d&4194240)!==0))return n;if((s&4)!==0&&(s|=o&16),n=e.entangledLanes,n!==0)for(e=e.entanglements,n&=s;0o;o++)n.push(e);return n}function Jn(e,n,o){e.pendingLanes|=n,n!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,n=31-Mt(n),e[n]=o}function $l(e,n){var o=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 s=e.eventTimes;for(e=e.expirationTimes;0=Mo),Mc=" ",Pc=!1;function Ic(e,n){switch(e){case"keyup":return xm.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Tc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var zr=!1;function Sm(e,n){switch(e){case"compositionend":return Tc(n);case"keypress":return n.which!==32?null:(Pc=!0,Mc);case"textInput":return e=n.data,e===Mc&&Pc?null:e;default:return null}}function _m(e,n){if(zr)return e==="compositionend"||!Xl&&Ic(e,n)?(e=Sc(),Vi=Vl=Pn=null,zr=!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:o,offset:n-e};e=s}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=Dc(o)}}function Fc(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Fc(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Hc(){for(var e=window,n=me();n instanceof e.HTMLIFrameElement;){try{var o=typeof n.contentWindow.location.href=="string"}catch{o=!1}if(o)e=n.contentWindow;else break;n=me(e.document)}return n}function Kl(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 zm(e){var n=Hc(),o=e.focusedElem,s=e.selectionRange;if(n!==o&&o&&o.ownerDocument&&Fc(o.ownerDocument.documentElement,o)){if(s!==null&&Kl(o)){if(n=s.start,e=s.end,e===void 0&&(e=n),"selectionStart"in o)o.selectionStart=n,o.selectionEnd=Math.min(e,o.value.length);else if(e=(n=o.ownerDocument||document)&&n.defaultView||window,e.getSelection){e=e.getSelection();var a=o.textContent.length,d=Math.min(s.start,a);s=s.end===void 0?d:Math.min(s.end,a),!e.extend&&d>s&&(a=s,s=d,d=a),a=Oc(o,d);var x=Oc(o,s);a&&x&&(e.rangeCount!==1||e.anchorNode!==a.node||e.anchorOffset!==a.offset||e.focusNode!==x.node||e.focusOffset!==x.offset)&&(n=n.createRange(),n.setStart(a.node,a.offset),e.removeAllRanges(),d>s?(e.addRange(n),e.extend(x.node,x.offset)):(n.setEnd(x.node,x.offset),e.addRange(n)))}}for(n=[],e=o;e=e.parentNode;)e.nodeType===1&&n.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof o.focus=="function"&&o.focus(),o=0;o=document.documentMode,jr=null,ql=null,zo=null,Zl=!1;function Vc(e,n,o){var s=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Zl||jr==null||jr!==me(s)||(s=jr,"selectionStart"in s&&Kl(s)?s={start:s.selectionStart,end:s.selectionEnd}:(s=(s.ownerDocument&&s.ownerDocument.defaultView||window).getSelection(),s={anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focusNode:s.focusNode,focusOffset:s.focusOffset}),zo&&To(zo,s)||(zo=s,s=Gi(ql,"onSelect"),0Dr||(e.current=cu[Dr],cu[Dr]=null,Dr--)}function Ae(e,n){Dr++,cu[Dr]=e.current,e.current=n}var jn={},ut=zn(jn),mt=zn(!1),tr=jn;function Or(e,n){var o=e.type.contextTypes;if(!o)return jn;var s=e.stateNode;if(s&&s.__reactInternalMemoizedUnmaskedChildContext===n)return s.__reactInternalMemoizedMaskedChildContext;var a={},d;for(d in o)a[d]=n[d];return s&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=n,e.__reactInternalMemoizedMaskedChildContext=a),a}function yt(e){return e=e.childContextTypes,e!=null}function Ji(){De(mt),De(ut)}function nf(e,n,o){if(ut.current!==jn)throw Error(i(168));Ae(ut,n),Ae(mt,o)}function rf(e,n,o){var s=e.stateNode;if(n=n.childContextTypes,typeof s.getChildContext!="function")return o;s=s.getChildContext();for(var a in s)if(!(a in n))throw Error(i(108,ce(e)||"Unknown",a));return O({},o,s)}function es(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||jn,tr=ut.current,Ae(ut,e),Ae(mt,mt.current),!0}function of(e,n,o){var s=e.stateNode;if(!s)throw Error(i(169));o?(e=rf(e,n,tr),s.__reactInternalMemoizedMergedChildContext=e,De(mt),De(ut),Ae(ut,e)):De(mt),Ae(mt,o)}var dn=null,ts=!1,fu=!1;function sf(e){dn===null?dn=[e]:dn.push(e)}function bm(e){ts=!0,sf(e)}function Rn(){if(!fu&&dn!==null){fu=!0;var e=0,n=Le;try{var o=dn;for(Le=1;e>=x,a-=x,hn=1<<32-Mt(n)+a|o<ke?(tt=Ee,Ee=null):tt=Ee.sibling;var je=oe(W,Ee,Y[ke],ue);if(je===null){Ee===null&&(Ee=tt);break}e&&Ee&&je.alternate===null&&n(W,Ee),D=d(je,D,ke),_e===null?xe=je:_e.sibling=je,_e=je,Ee=tt}if(ke===Y.length)return o(W,Ee),Fe&&rr(W,ke),xe;if(Ee===null){for(;keke?(tt=Ee,Ee=null):tt=Ee.sibling;var Bn=oe(W,Ee,je.value,ue);if(Bn===null){Ee===null&&(Ee=tt);break}e&&Ee&&Bn.alternate===null&&n(W,Ee),D=d(Bn,D,ke),_e===null?xe=Bn:_e.sibling=Bn,_e=Bn,Ee=tt}if(je.done)return o(W,Ee),Fe&&rr(W,ke),xe;if(Ee===null){for(;!je.done;ke++,je=Y.next())je=le(W,je.value,ue),je!==null&&(D=d(je,D,ke),_e===null?xe=je:_e.sibling=je,_e=je);return Fe&&rr(W,ke),xe}for(Ee=s(W,Ee);!je.done;ke++,je=Y.next())je=de(Ee,W,ke,je.value,ue),je!==null&&(e&&je.alternate!==null&&Ee.delete(je.key===null?ke:je.key),D=d(je,D,ke),_e===null?xe=je:_e.sibling=je,_e=je);return e&&Ee.forEach(function(E0){return n(W,E0)}),Fe&&rr(W,ke),xe}function We(W,D,Y,ue){if(typeof Y=="object"&&Y!==null&&Y.type===B&&Y.key===null&&(Y=Y.props.children),typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case F:e:{for(var xe=Y.key,_e=D;_e!==null;){if(_e.key===xe){if(xe=Y.type,xe===B){if(_e.tag===7){o(W,_e.sibling),D=a(_e,Y.props.children),D.return=W,W=D;break e}}else if(_e.elementType===xe||typeof xe=="object"&&xe!==null&&xe.$$typeof===H&&df(xe)===_e.type){o(W,_e.sibling),D=a(_e,Y.props),D.ref=Do(W,_e,Y),D.return=W,W=D;break e}o(W,_e);break}else n(W,_e);_e=_e.sibling}Y.type===B?(D=fr(Y.props.children,W.mode,ue,Y.key),D.return=W,W=D):(ue=Is(Y.type,Y.key,Y.props,null,W.mode,ue),ue.ref=Do(W,D,Y),ue.return=W,W=ue)}return x(W);case $:e:{for(_e=Y.key;D!==null;){if(D.key===_e)if(D.tag===4&&D.stateNode.containerInfo===Y.containerInfo&&D.stateNode.implementation===Y.implementation){o(W,D.sibling),D=a(D,Y.children||[]),D.return=W,W=D;break e}else{o(W,D);break}else n(W,D);D=D.sibling}D=ua(Y,W.mode,ue),D.return=W,W=D}return x(W);case H:return _e=Y._init,We(W,D,_e(Y._payload),ue)}if(Qe(Y))return ge(W,D,Y,ue);if(L(Y))return ye(W,D,Y,ue);is(W,Y)}return typeof Y=="string"&&Y!==""||typeof Y=="number"?(Y=""+Y,D!==null&&D.tag===6?(o(W,D.sibling),D=a(D,Y),D.return=W,W=D):(o(W,D),D=la(Y,W.mode,ue),D.return=W,W=D),x(W)):o(W,D)}return We}var Br=hf(!0),pf=hf(!1),ss=zn(null),ls=null,br=null,yu=null;function vu(){yu=br=ls=null}function xu(e){var n=ss.current;De(ss),e._currentValue=n}function wu(e,n,o){for(;e!==null;){var s=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,s!==null&&(s.childLanes|=n)):s!==null&&(s.childLanes&n)!==n&&(s.childLanes|=n),e===o)break;e=e.return}}function Ur(e,n){ls=e,yu=br=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&n)!==0&&(vt=!0),e.firstContext=null)}function Ot(e){var n=e._currentValue;if(yu!==e)if(e={context:e,memoizedValue:n,next:null},br===null){if(ls===null)throw Error(i(308));br=e,ls.dependencies={lanes:0,firstContext:e}}else br=br.next=e;return n}var or=null;function Su(e){or===null?or=[e]:or.push(e)}function gf(e,n,o,s){var a=n.interleaved;return a===null?(o.next=o,Su(n)):(o.next=a.next,a.next=o),n.interleaved=o,gn(e,s)}function gn(e,n){e.lanes|=n;var o=e.alternate;for(o!==null&&(o.lanes|=n),o=e,e=e.return;e!==null;)e.childLanes|=n,o=e.alternate,o!==null&&(o.childLanes|=n),o=e,e=e.return;return o.tag===3?o.stateNode:null}var Ln=!1;function _u(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function mf(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 mn(e,n){return{eventTime:e,lane:n,tag:0,payload:null,callback:null,next:null}}function An(e,n,o){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(Te&2)!==0){var a=s.pending;return a===null?n.next=n:(n.next=a.next,a.next=n),s.pending=n,gn(e,o)}return a=s.interleaved,a===null?(n.next=n,Su(s)):(n.next=a.next,a.next=n),s.interleaved=n,gn(e,o)}function us(e,n,o){if(n=n.updateQueue,n!==null&&(n=n.shared,(o&4194240)!==0)){var s=n.lanes;s&=e.pendingLanes,o|=s,n.lanes=o,Pr(e,o)}}function yf(e,n){var o=e.updateQueue,s=e.alternate;if(s!==null&&(s=s.updateQueue,o===s)){var a=null,d=null;if(o=o.firstBaseUpdate,o!==null){do{var x={eventTime:o.eventTime,lane:o.lane,tag:o.tag,payload:o.payload,callback:o.callback,next:null};d===null?a=d=x:d=d.next=x,o=o.next}while(o!==null);d===null?a=d=n:d=d.next=n}else a=d=n;o={baseState:s.baseState,firstBaseUpdate:a,lastBaseUpdate:d,shared:s.shared,effects:s.effects},e.updateQueue=o;return}e=o.lastBaseUpdate,e===null?o.firstBaseUpdate=n:e.next=n,o.lastBaseUpdate=n}function as(e,n,o,s){var a=e.updateQueue;Ln=!1;var d=a.firstBaseUpdate,x=a.lastBaseUpdate,T=a.shared.pending;if(T!==null){a.shared.pending=null;var R=T,q=R.next;R.next=null,x===null?d=q:x.next=q,x=R;var ie=e.alternate;ie!==null&&(ie=ie.updateQueue,T=ie.lastBaseUpdate,T!==x&&(T===null?ie.firstBaseUpdate=q:T.next=q,ie.lastBaseUpdate=R))}if(d!==null){var le=a.baseState;x=0,ie=q=R=null,T=d;do{var oe=T.lane,de=T.eventTime;if((s&oe)===oe){ie!==null&&(ie=ie.next={eventTime:de,lane:0,tag:T.tag,payload:T.payload,callback:T.callback,next:null});e:{var ge=e,ye=T;switch(oe=n,de=o,ye.tag){case 1:if(ge=ye.payload,typeof ge=="function"){le=ge.call(de,le,oe);break e}le=ge;break e;case 3:ge.flags=ge.flags&-65537|128;case 0:if(ge=ye.payload,oe=typeof ge=="function"?ge.call(de,le,oe):ge,oe==null)break e;le=O({},le,oe);break e;case 2:Ln=!0}}T.callback!==null&&T.lane!==0&&(e.flags|=64,oe=a.effects,oe===null?a.effects=[T]:oe.push(T))}else de={eventTime:de,lane:oe,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ie===null?(q=ie=de,R=le):ie=ie.next=de,x|=oe;if(T=T.next,T===null){if(T=a.shared.pending,T===null)break;oe=T,T=oe.next,oe.next=null,a.lastBaseUpdate=oe,a.shared.pending=null}}while(!0);if(ie===null&&(R=le),a.baseState=R,a.firstBaseUpdate=q,a.lastBaseUpdate=ie,n=a.shared.interleaved,n!==null){a=n;do x|=a.lane,a=a.next;while(a!==n)}else d===null&&(a.shared.lanes=0);lr|=x,e.lanes=x,e.memoizedState=le}}function vf(e,n,o){if(e=n.effects,n.effects=null,e!==null)for(n=0;no?o:4,e(!0);var s=Mu.transition;Mu.transition={};try{e(!1),n()}finally{Le=o,Mu.transition=s}}function Df(){return Ft().memoizedState}function Xm(e,n,o){var s=Fn(e);if(o={lane:s,action:o,hasEagerState:!1,eagerState:null,next:null},Of(e))Ff(n,o);else if(o=gf(e,n,o,s),o!==null){var a=gt();Xt(o,e,s,a),Hf(o,n,s)}}function Qm(e,n,o){var s=Fn(e),a={lane:s,action:o,hasEagerState:!1,eagerState:null,next:null};if(Of(e))Ff(n,a);else{var d=e.alternate;if(e.lanes===0&&(d===null||d.lanes===0)&&(d=n.lastRenderedReducer,d!==null))try{var x=n.lastRenderedState,T=d(x,o);if(a.hasEagerState=!0,a.eagerState=T,Bt(T,x)){var R=n.interleaved;R===null?(a.next=a,Su(n)):(a.next=R.next,R.next=a),n.interleaved=a;return}}catch{}finally{}o=gf(e,n,a,s),o!==null&&(a=gt(),Xt(o,e,s,a),Hf(o,n,s))}}function Of(e){var n=e.alternate;return e===Be||n!==null&&n===Be}function Ff(e,n){Vo=ds=!0;var o=e.pending;o===null?n.next=n:(n.next=o.next,o.next=n),e.pending=n}function Hf(e,n,o){if((o&4194240)!==0){var s=n.lanes;s&=e.pendingLanes,o|=s,n.lanes=o,Pr(e,o)}}var gs={readContext:Ot,useCallback:at,useContext:at,useEffect:at,useImperativeHandle:at,useInsertionEffect:at,useLayoutEffect:at,useMemo:at,useReducer:at,useRef:at,useState:at,useDebugValue:at,useDeferredValue:at,useTransition:at,useMutableSource:at,useSyncExternalStore:at,useId:at,unstable_isNewReconciler:!1},Gm={readContext:Ot,useCallback:function(e,n){return on().memoizedState=[e,n===void 0?null:n],e},useContext:Ot,useEffect:If,useImperativeHandle:function(e,n,o){return o=o!=null?o.concat([e]):null,hs(4194308,4,jf.bind(null,n,e),o)},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 o=on();return n=n===void 0?null:n,e=e(),o.memoizedState=[e,n],e},useReducer:function(e,n,o){var s=on();return n=o!==void 0?o(n):n,s.memoizedState=s.baseState=n,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},s.queue=e,e=e.dispatch=Xm.bind(null,Be,e),[s.memoizedState,e]},useRef:function(e){var n=on();return e={current:e},n.memoizedState=e},useState:Mf,useDebugValue:Lu,useDeferredValue:function(e){return on().memoizedState=e},useTransition:function(){var e=Mf(!1),n=e[0];return e=Ym.bind(null,e[1]),on().memoizedState=e,[n,e]},useMutableSource:function(){},useSyncExternalStore:function(e,n,o){var s=Be,a=on();if(Fe){if(o===void 0)throw Error(i(407));o=o()}else{if(o=n(),et===null)throw Error(i(349));(sr&30)!==0||_f(s,n,o)}a.memoizedState=o;var d={value:o,getSnapshot:n};return a.queue=d,If(kf.bind(null,s,d,e),[e]),s.flags|=2048,Uo(9,Ef.bind(null,s,d,o,n),void 0,null),o},useId:function(){var e=on(),n=et.identifierPrefix;if(Fe){var o=pn,s=hn;o=(s&~(1<<32-Mt(s)-1)).toString(32)+o,n=":"+n+"R"+o,o=Bo++,0<\/script>",e=e.removeChild(e.firstChild)):typeof s.is=="string"?e=x.createElement(o,{is:s.is}):(e=x.createElement(o),o==="select"&&(x=e,s.multiple?x.multiple=!0:s.size&&(x.size=s.size))):e=x.createElementNS(e,o),e[nn]=n,e[Ao]=s,sd(e,n,!1,!1),n.stateNode=e;e:{switch(x=uo(o,s),o){case"dialog":$e("cancel",e),$e("close",e),a=s;break;case"iframe":case"object":case"embed":$e("load",e),a=s;break;case"video":case"audio":for(a=0;aGr&&(n.flags|=128,s=!0,Wo(d,!1),n.lanes=4194304)}else{if(!s)if(e=cs(x),e!==null){if(n.flags|=128,s=!0,o=e.updateQueue,o!==null&&(n.updateQueue=o,n.flags|=4),Wo(d,!0),d.tail===null&&d.tailMode==="hidden"&&!x.alternate&&!Fe)return ct(n),null}else 2*He()-d.renderingStartTime>Gr&&o!==1073741824&&(n.flags|=128,s=!0,Wo(d,!1),n.lanes=4194304);d.isBackwards?(x.sibling=n.child,n.child=x):(o=d.last,o!==null?o.sibling=x:n.child=x,d.last=x)}return d.tail!==null?(n=d.tail,d.rendering=n,d.tail=n.sibling,d.renderingStartTime=He(),n.sibling=null,o=Ve.current,Ae(Ve,s?o&1|2:o&1),n):(ct(n),null);case 22:case 23:return oa(),s=n.memoizedState!==null,e!==null&&e.memoizedState!==null!==s&&(n.flags|=8192),s&&(n.mode&1)!==0?(zt&1073741824)!==0&&(ct(n),n.subtreeFlags&6&&(n.flags|=8192)):ct(n),null;case 24:return null;case 25:return null}throw Error(i(156,n.tag))}function r0(e,n){switch(hu(n),n.tag){case 1:return yt(n.type)&&Ji(),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Wr(),De(mt),De(ut),Cu(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 5:return ku(n),null;case 13:if(De(Ve),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(i(340));Vr()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return De(Ve),null;case 4:return Wr(),null;case 10:return xu(n.type._context),null;case 22:case 23:return oa(),null;case 24:return null;default:return null}}var xs=!1,ft=!1,o0=typeof WeakSet=="function"?WeakSet:Set,he=null;function Xr(e,n){var o=e.ref;if(o!==null)if(typeof o=="function")try{o(null)}catch(s){Ue(e,n,s)}else o.current=null}function Yu(e,n,o){try{o()}catch(s){Ue(e,n,s)}}var ad=!1;function i0(e,n){if(ou=Fi,e=Hc(),Kl(e)){if("selectionStart"in e)var o={start:e.selectionStart,end:e.selectionEnd};else e:{o=(o=e.ownerDocument)&&o.defaultView||window;var s=o.getSelection&&o.getSelection();if(s&&s.rangeCount!==0){o=s.anchorNode;var a=s.anchorOffset,d=s.focusNode;s=s.focusOffset;try{o.nodeType,d.nodeType}catch{o=null;break e}var x=0,T=-1,R=-1,q=0,ie=0,le=e,oe=null;t:for(;;){for(var de;le!==o||a!==0&&le.nodeType!==3||(T=x+a),le!==d||s!==0&&le.nodeType!==3||(R=x+s),le.nodeType===3&&(x+=le.nodeValue.length),(de=le.firstChild)!==null;)oe=le,le=de;for(;;){if(le===e)break t;if(oe===o&&++q===a&&(T=x),oe===d&&++ie===s&&(R=x),(de=le.nextSibling)!==null)break;le=oe,oe=le.parentNode}le=de}o=T===-1||R===-1?null:{start:T,end:R}}else o=null}o=o||{start:0,end:0}}else o=null;for(iu={focusedElem:e,selectionRange:o},Fi=!1,he=n;he!==null;)if(n=he,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,he=e;else for(;he!==null;){n=he;try{var ge=n.alternate;if((n.flags&1024)!==0)switch(n.tag){case 0:case 11:case 15:break;case 1:if(ge!==null){var ye=ge.memoizedProps,We=ge.memoizedState,W=n.stateNode,D=W.getSnapshotBeforeUpdate(n.elementType===n.type?ye:Ut(n.type,ye),We);W.__reactInternalSnapshotBeforeUpdate=D}break;case 3:var Y=n.stateNode.containerInfo;Y.nodeType===1?Y.textContent="":Y.nodeType===9&&Y.documentElement&&Y.removeChild(Y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(i(163))}}catch(ue){Ue(n,n.return,ue)}if(e=n.sibling,e!==null){e.return=n.return,he=e;break}he=n.return}return ge=ad,ad=!1,ge}function Yo(e,n,o){var s=n.updateQueue;if(s=s!==null?s.lastEffect:null,s!==null){var a=s=s.next;do{if((a.tag&e)===e){var d=a.destroy;a.destroy=void 0,d!==void 0&&Yu(n,o,d)}a=a.next}while(a!==s)}}function ws(e,n){if(n=n.updateQueue,n=n!==null?n.lastEffect:null,n!==null){var o=n=n.next;do{if((o.tag&e)===e){var s=o.create;o.destroy=s()}o=o.next}while(o!==n)}}function Xu(e){var n=e.ref;if(n!==null){var o=e.stateNode;switch(e.tag){case 5:e=o;break;default:e=o}typeof n=="function"?n(e):n.current=e}}function cd(e){var n=e.alternate;n!==null&&(e.alternate=null,cd(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&(delete n[nn],delete n[Ao],delete n[au],delete n[Vm],delete n[Bm])),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 fd(e){return e.tag===5||e.tag===3||e.tag===4}function dd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||fd(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 Qu(e,n,o){var s=e.tag;if(s===5||s===6)e=e.stateNode,n?o.nodeType===8?o.parentNode.insertBefore(e,n):o.insertBefore(e,n):(o.nodeType===8?(n=o.parentNode,n.insertBefore(e,o)):(n=o,n.appendChild(e)),o=o._reactRootContainer,o!=null||n.onclick!==null||(n.onclick=qi));else if(s!==4&&(e=e.child,e!==null))for(Qu(e,n,o),e=e.sibling;e!==null;)Qu(e,n,o),e=e.sibling}function Gu(e,n,o){var s=e.tag;if(s===5||s===6)e=e.stateNode,n?o.insertBefore(e,n):o.appendChild(e);else if(s!==4&&(e=e.child,e!==null))for(Gu(e,n,o),e=e.sibling;e!==null;)Gu(e,n,o),e=e.sibling}var it=null,Wt=!1;function $n(e,n,o){for(o=o.child;o!==null;)hd(e,n,o),o=o.sibling}function hd(e,n,o){if(Ct&&typeof Ct.onCommitFiberUnmount=="function")try{Ct.onCommitFiberUnmount(Nr,o)}catch{}switch(o.tag){case 5:ft||Xr(o,n);case 6:var s=it,a=Wt;it=null,$n(e,n,o),it=s,Wt=a,it!==null&&(Wt?(e=it,o=o.stateNode,e.nodeType===8?e.parentNode.removeChild(o):e.removeChild(o)):it.removeChild(o.stateNode));break;case 18:it!==null&&(Wt?(e=it,o=o.stateNode,e.nodeType===8?uu(e.parentNode,o):e.nodeType===1&&uu(e,o),ko(e)):uu(it,o.stateNode));break;case 4:s=it,a=Wt,it=o.stateNode.containerInfo,Wt=!0,$n(e,n,o),it=s,Wt=a;break;case 0:case 11:case 14:case 15:if(!ft&&(s=o.updateQueue,s!==null&&(s=s.lastEffect,s!==null))){a=s=s.next;do{var d=a,x=d.destroy;d=d.tag,x!==void 0&&((d&2)!==0||(d&4)!==0)&&Yu(o,n,x),a=a.next}while(a!==s)}$n(e,n,o);break;case 1:if(!ft&&(Xr(o,n),s=o.stateNode,typeof s.componentWillUnmount=="function"))try{s.props=o.memoizedProps,s.state=o.memoizedState,s.componentWillUnmount()}catch(T){Ue(o,n,T)}$n(e,n,o);break;case 21:$n(e,n,o);break;case 22:o.mode&1?(ft=(s=ft)||o.memoizedState!==null,$n(e,n,o),ft=s):$n(e,n,o);break;default:$n(e,n,o)}}function pd(e){var n=e.updateQueue;if(n!==null){e.updateQueue=null;var o=e.stateNode;o===null&&(o=e.stateNode=new o0),n.forEach(function(s){var a=p0.bind(null,e,s);o.has(s)||(o.add(s),s.then(a,a))})}}function Yt(e,n){var o=n.deletions;if(o!==null)for(var s=0;sa&&(a=x),s&=~d}if(s=a,s=He()-s,s=(120>s?120:480>s?480:1080>s?1080:1920>s?1920:3e3>s?3e3:4320>s?4320:1960*l0(s/1960))-s,10e?16:e,On===null)var s=!1;else{if(e=On,On=null,Ns=0,(Te&6)!==0)throw Error(i(331));var a=Te;for(Te|=4,he=e.current;he!==null;){var d=he,x=d.child;if((he.flags&16)!==0){var T=d.deletions;if(T!==null){for(var R=0;RHe()-Zu?ar(e,0):qu|=o),wt(e,n)}function Md(e,n){n===0&&((e.mode&1)===0?n=1:(n=Mr,Mr<<=1,(Mr&130023424)===0&&(Mr=4194304)));var o=gt();e=gn(e,n),e!==null&&(Jn(e,n,o),wt(e,o))}function h0(e){var n=e.memoizedState,o=0;n!==null&&(o=n.retryLane),Md(e,o)}function p0(e,n){var o=0;switch(e.tag){case 13:var s=e.stateNode,a=e.memoizedState;a!==null&&(o=a.retryLane);break;case 19:s=e.stateNode;break;default:throw Error(i(314))}s!==null&&s.delete(n),Md(e,o)}var Pd;Pd=function(e,n,o){if(e!==null)if(e.memoizedProps!==n.pendingProps||mt.current)vt=!0;else{if((e.lanes&o)===0&&(n.flags&128)===0)return vt=!1,t0(e,n,o);vt=(e.flags&131072)!==0}else vt=!1,Fe&&(n.flags&1048576)!==0&&lf(n,rs,n.index);switch(n.lanes=0,n.tag){case 2:var s=n.type;vs(e,n),e=n.pendingProps;var a=Or(n,ut.current);Ur(n,o),a=Iu(null,n,s,e,a,o);var d=Tu();return n.flags|=1,typeof a=="object"&&a!==null&&typeof a.render=="function"&&a.$$typeof===void 0?(n.tag=1,n.memoizedState=null,n.updateQueue=null,yt(s)?(d=!0,es(n)):d=!1,n.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,_u(n),a.updater=ms,n.stateNode=a,a._reactInternals=n,$u(n,s,e,o),n=Hu(null,n,s,!0,d,o)):(n.tag=0,Fe&&d&&du(n),pt(null,n,a,o),n=n.child),n;case 16:s=n.elementType;e:{switch(vs(e,n),e=n.pendingProps,a=s._init,s=a(s._payload),n.type=s,a=n.tag=m0(s),e=Ut(s,e),a){case 0:n=Fu(null,n,s,e,o);break e;case 1:n=ed(null,n,s,e,o);break e;case 11:n=Gf(null,n,s,e,o);break e;case 14:n=Kf(null,n,s,Ut(s.type,e),o);break e}throw Error(i(306,s,""))}return n;case 0:return s=n.type,a=n.pendingProps,a=n.elementType===s?a:Ut(s,a),Fu(e,n,s,a,o);case 1:return s=n.type,a=n.pendingProps,a=n.elementType===s?a:Ut(s,a),ed(e,n,s,a,o);case 3:e:{if(td(n),e===null)throw Error(i(387));s=n.pendingProps,d=n.memoizedState,a=d.element,mf(e,n),as(n,s,null,o);var x=n.memoizedState;if(s=x.element,d.isDehydrated)if(d={element:s,isDehydrated:!1,cache:x.cache,pendingSuspenseBoundaries:x.pendingSuspenseBoundaries,transitions:x.transitions},n.updateQueue.baseState=d,n.memoizedState=d,n.flags&256){a=Yr(Error(i(423)),n),n=nd(e,n,s,o,a);break e}else if(s!==a){a=Yr(Error(i(424)),n),n=nd(e,n,s,o,a);break e}else for(Tt=Tn(n.stateNode.containerInfo.firstChild),It=n,Fe=!0,bt=null,o=pf(n,null,s,o),n.child=o;o;)o.flags=o.flags&-3|4096,o=o.sibling;else{if(Vr(),s===a){n=yn(e,n,o);break e}pt(e,n,s,o)}n=n.child}return n;case 5:return xf(n),e===null&&gu(n),s=n.type,a=n.pendingProps,d=e!==null?e.memoizedProps:null,x=a.children,su(s,a)?x=null:d!==null&&su(s,d)&&(n.flags|=32),Jf(e,n),pt(e,n,x,o),n.child;case 6:return e===null&&gu(n),null;case 13:return rd(e,n,o);case 4:return Eu(n,n.stateNode.containerInfo),s=n.pendingProps,e===null?n.child=Br(n,null,s,o):pt(e,n,s,o),n.child;case 11:return s=n.type,a=n.pendingProps,a=n.elementType===s?a:Ut(s,a),Gf(e,n,s,a,o);case 7:return pt(e,n,n.pendingProps,o),n.child;case 8:return pt(e,n,n.pendingProps.children,o),n.child;case 12:return pt(e,n,n.pendingProps.children,o),n.child;case 10:e:{if(s=n.type._context,a=n.pendingProps,d=n.memoizedProps,x=a.value,Ae(ss,s._currentValue),s._currentValue=x,d!==null)if(Bt(d.value,x)){if(d.children===a.children&&!mt.current){n=yn(e,n,o);break e}}else for(d=n.child,d!==null&&(d.return=n);d!==null;){var T=d.dependencies;if(T!==null){x=d.child;for(var R=T.firstContext;R!==null;){if(R.context===s){if(d.tag===1){R=mn(-1,o&-o),R.tag=2;var q=d.updateQueue;if(q!==null){q=q.shared;var ie=q.pending;ie===null?R.next=R:(R.next=ie.next,ie.next=R),q.pending=R}}d.lanes|=o,R=d.alternate,R!==null&&(R.lanes|=o),wu(d.return,o,n),T.lanes|=o;break}R=R.next}}else if(d.tag===10)x=d.type===n.type?null:d.child;else if(d.tag===18){if(x=d.return,x===null)throw Error(i(341));x.lanes|=o,T=x.alternate,T!==null&&(T.lanes|=o),wu(x,o,n),x=d.sibling}else x=d.child;if(x!==null)x.return=d;else for(x=d;x!==null;){if(x===n){x=null;break}if(d=x.sibling,d!==null){d.return=x.return,x=d;break}x=x.return}d=x}pt(e,n,a.children,o),n=n.child}return n;case 9:return a=n.type,s=n.pendingProps.children,Ur(n,o),a=Ot(a),s=s(a),n.flags|=1,pt(e,n,s,o),n.child;case 14:return s=n.type,a=Ut(s,n.pendingProps),a=Ut(s.type,a),Kf(e,n,s,a,o);case 15:return qf(e,n,n.type,n.pendingProps,o);case 17:return s=n.type,a=n.pendingProps,a=n.elementType===s?a:Ut(s,a),vs(e,n),n.tag=1,yt(s)?(e=!0,es(n)):e=!1,Ur(n,o),Bf(n,s,a),$u(n,s,a,o),Hu(null,n,s,!0,e,o);case 19:return id(e,n,o);case 22:return Zf(e,n,o)}throw Error(i(156,n.tag))};function Id(e,n){return Ti(e,n)}function g0(e,n,o,s){this.tag=e,this.key=o,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=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Vt(e,n,o,s){return new g0(e,n,o,s)}function sa(e){return e=e.prototype,!(!e||!e.isReactComponent)}function m0(e){if(typeof e=="function")return sa(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ee)return 11;if(e===U)return 14}return 2}function Vn(e,n){var o=e.alternate;return o===null?(o=Vt(e.tag,n,e.key,e.mode),o.elementType=e.elementType,o.type=e.type,o.stateNode=e.stateNode,o.alternate=e,e.alternate=o):(o.pendingProps=n,o.type=e.type,o.flags=0,o.subtreeFlags=0,o.deletions=null),o.flags=e.flags&14680064,o.childLanes=e.childLanes,o.lanes=e.lanes,o.child=e.child,o.memoizedProps=e.memoizedProps,o.memoizedState=e.memoizedState,o.updateQueue=e.updateQueue,n=e.dependencies,o.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},o.sibling=e.sibling,o.index=e.index,o.ref=e.ref,o}function Is(e,n,o,s,a,d){var x=2;if(s=e,typeof e=="function")sa(e)&&(x=1);else if(typeof e=="string")x=5;else e:switch(e){case B:return fr(o.children,a,d,n);case X:x=8,a|=8;break;case G:return e=Vt(12,o,n,a|2),e.elementType=G,e.lanes=d,e;case J:return e=Vt(13,o,n,a),e.elementType=J,e.lanes=d,e;case N:return e=Vt(19,o,n,a),e.elementType=N,e.lanes=d,e;case b:return Ts(o,a,d,n);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case te:x=10;break e;case Z:x=9;break e;case ee:x=11;break e;case U:x=14;break e;case H:x=16,s=null;break e}throw Error(i(130,e==null?e:typeof e,""))}return n=Vt(x,o,n,a),n.elementType=e,n.type=s,n.lanes=d,n}function fr(e,n,o,s){return e=Vt(7,e,s,n),e.lanes=o,e}function Ts(e,n,o,s){return e=Vt(22,e,s,n),e.elementType=b,e.lanes=o,e.stateNode={isHidden:!1},e}function la(e,n,o){return e=Vt(6,e,null,n),e.lanes=o,e}function ua(e,n,o){return n=Vt(4,e.children!==null?e.children:[],e.key,n),n.lanes=o,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function y0(e,n,o,s,a){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=Zn(0),this.expirationTimes=Zn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Zn(0),this.identifierPrefix=s,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function aa(e,n,o,s,a,d,x,T,R){return e=new y0(e,n,o,T,R),n===1?(n=1,d===!0&&(n|=8)):n=0,d=Vt(3,null,null,n),e.current=d,d.stateNode=e,d.memoizedState={element:s,isDehydrated:o,cache:null,transitions:null,pendingSuspenseBoundaries:null},_u(d),e}function v0(e,n,o){var s=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(r){console.error(r)}}return t(),ga.exports=T0(),ga.exports}var bd;function z0(){if(bd)return Ds;bd=1;var t=ep();return Ds.createRoot=t.createRoot,Ds.hydrateRoot=t.hydrateRoot,Ds}var j0=z0();async function jt(t,r){const i=await fetch(t,{...r,headers:{"Content-Type":"application/json",...(r==null?void 0:r.headers)||{}}});if(!i.ok){const l=await i.text();throw new Error(l||i.statusText)}return i.json()}const _t={health:()=>jt("/api/health"),settings:()=>jt("/api/settings"),saveSettings:t=>jt("/api/settings",{method:"PUT",body:JSON.stringify(t)}),repos:()=>jt("/api/repos"),index:(t,r=!0)=>jt("/api/index",{method:"POST",body:JSON.stringify({repo_path:t,incremental:r})}),indexStatus:t=>jt(`/api/index?repo_path=${encodeURIComponent(t)}`),architecture:t=>jt(`/api/architecture?repo_path=${encodeURIComponent(t)}`),review:(t,r,i,l=!0)=>jt("/api/review",{method:"POST",body:JSON.stringify({repo_path:t,base:r,head:i||null,reindex:l,incremental:!0,three_dot:!0})}),init:(t,r=!1)=>jt("/api/init",{method:"POST",body:JSON.stringify({repo_path:t,overwrite:r})}),postComment:(t,r,i,l)=>jt("/api/prs/comment",{method:"POST",body:JSON.stringify({provider:t,repo:r,number:i,markdown:l})}),graph:(t,r="full")=>jt(`/api/graph?repo_path=${encodeURIComponent(t)}&scope=${r}`),prs:(t,r,i="open")=>jt("/api/prs",{method:"POST",body:JSON.stringify({provider:t,repo:r,state:i})}),residual:t=>jt("/api/ai/residual",{method:"POST",body:JSON.stringify({review:t})})};function Xe(t){if(typeof t=="string"||typeof t=="number")return""+t;let r="";if(Array.isArray(t))for(let i=0,l;i{}};function cl(){for(var t=0,r=arguments.length,i={},l;t=0&&(l=i.slice(u+1),i=i.slice(0,u)),i&&!r.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:l}})}Xs.prototype=cl.prototype={constructor:Xs,on:function(t,r){var i=this._,l=L0(t+"",i),u,c=-1,f=l.length;if(arguments.length<2){for(;++c0)for(var i=new Array(u),l=0,u,c;l=0&&(r=t.slice(0,i))!=="xmlns"&&(t=t.slice(i+1)),Wd.hasOwnProperty(r)?{space:Wd[r],local:t}:t}function $0(t){return function(){var r=this.ownerDocument,i=this.namespaceURI;return i===ja&&r.documentElement.namespaceURI===ja?r.createElement(t):r.createElementNS(i,t)}}function D0(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function tp(t){var r=fl(t);return(r.local?D0:$0)(r)}function O0(){}function Xa(t){return t==null?O0:function(){return this.querySelector(t)}}function F0(t){typeof t!="function"&&(t=Xa(t));for(var r=this._groups,i=r.length,l=new Array(i),u=0;u=_&&(_=j+1);!(F=C[_])&&++_=0;)(f=l[u])&&(c&&f.compareDocumentPosition(c)^4&&c.parentNode.insertBefore(f,c),c=f);return this}function cy(t){t||(t=fy);function r(v,m){return v&&m?t(v.__data__,m.__data__):!v-!m}for(var i=this._groups,l=i.length,u=new Array(l),c=0;cr?1:t>=r?0:NaN}function dy(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function hy(){return Array.from(this)}function py(){for(var t=this._groups,r=0,i=t.length;r1?this.each((r==null?Ny:typeof r=="function"?My:Cy)(t,r,i??"")):to(this.node(),t)}function to(t,r){return t.style.getPropertyValue(r)||sp(t).getComputedStyle(t,null).getPropertyValue(r)}function Iy(t){return function(){delete this[t]}}function Ty(t,r){return function(){this[t]=r}}function zy(t,r){return function(){var i=r.apply(this,arguments);i==null?delete this[t]:this[t]=i}}function jy(t,r){return arguments.length>1?this.each((r==null?Iy:typeof r=="function"?zy:Ty)(t,r)):this.node()[t]}function lp(t){return t.trim().split(/^|\s+/)}function Qa(t){return t.classList||new up(t)}function up(t){this._node=t,this._names=lp(t.getAttribute("class")||"")}up.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 i=Qa(t),l=-1,u=r.length;++l=0&&(i=r.slice(l+1),r=r.slice(0,l)),{type:r,name:i}})}function sv(t){return function(){var r=this.__on;if(r){for(var i=0,l=-1,u=r.length,c;i()=>t;function Ra(t,{sourceEvent:r,subject:i,target:l,identifier:u,active:c,x:f,y:h,dx:p,dy:y,dispatch:g}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},subject:{value:i,enumerable:!0,configurable:!0},target:{value:l,enumerable:!0,configurable:!0},identifier:{value:u,enumerable:!0,configurable:!0},active:{value:c,enumerable:!0,configurable:!0},x:{value:f,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:g}})}Ra.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function mv(t){return!t.ctrlKey&&!t.button}function yv(){return this.parentNode}function vv(t,r){return r??{x:t.x,y:t.y}}function xv(){return navigator.maxTouchPoints||"ontouchstart"in this}function gp(){var t=mv,r=yv,i=vv,l=xv,u={},c=cl("start","drag","end"),f=0,h,p,y,g,v=0;function m(I){I.on("mousedown.drag",w).filter(l).on("touchstart.drag",C).on("touchmove.drag",E,gv).on("touchend.drag touchcancel.drag",j).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function w(I,F){if(!(g||!t.call(this,I,F))){var $=_(this,r.call(this,I,F),I,F,"mouse");$&&(Rt(I.view).on("mousemove.drag",S,oi).on("mouseup.drag",P,oi),hp(I.view),va(I),y=!1,h=I.clientX,p=I.clientY,$("start",I))}}function S(I){if(Jr(I),!y){var F=I.clientX-h,$=I.clientY-p;y=F*F+$*$>v}u.mouse("drag",I)}function P(I){Rt(I.view).on("mousemove.drag mouseup.drag",null),pp(I.view,y),Jr(I),u.mouse("end",I)}function C(I,F){if(t.call(this,I,F)){var $=I.changedTouches,B=r.call(this,I,F),X=$.length,G,te;for(G=0;G>8&15|r>>4&240,r>>4&15|r&240,(r&15)<<4|r&15,1):i===8?Fs(r>>24&255,r>>16&255,r>>8&255,(r&255)/255):i===4?Fs(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=Sv.exec(t))?new Et(r[1],r[2],r[3],1):(r=_v.exec(t))?new Et(r[1]*255/100,r[2]*255/100,r[3]*255/100,1):(r=Ev.exec(t))?Fs(r[1],r[2],r[3],r[4]):(r=kv.exec(t))?Fs(r[1]*255/100,r[2]*255/100,r[3]*255/100,r[4]):(r=Nv.exec(t))?Zd(r[1],r[2]/100,r[3]/100,1):(r=Cv.exec(t))?Zd(r[1],r[2]/100,r[3]/100,r[4]):Yd.hasOwnProperty(t)?Gd(Yd[t]):t==="transparent"?new Et(NaN,NaN,NaN,0):null}function Gd(t){return new Et(t>>16&255,t>>8&255,t&255,1)}function Fs(t,r,i,l){return l<=0&&(t=r=i=NaN),new Et(t,r,i,l)}function Iv(t){return t instanceof gi||(t=mr(t)),t?(t=t.rgb(),new Et(t.r,t.g,t.b,t.opacity)):new Et}function La(t,r,i,l){return arguments.length===1?Iv(t):new Et(t,r,i,l??1)}function Et(t,r,i,l){this.r=+t,this.g=+r,this.b=+i,this.opacity=+l}Ga(Et,La,mp(gi,{brighter(t){return t=t==null?Js:Math.pow(Js,t),new Et(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?ii:Math.pow(ii,t),new Et(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Et(pr(this.r),pr(this.g),pr(this.b),el(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:Kd,formatHex:Kd,formatHex8:Tv,formatRgb:qd,toString:qd}));function Kd(){return`#${hr(this.r)}${hr(this.g)}${hr(this.b)}`}function Tv(){return`#${hr(this.r)}${hr(this.g)}${hr(this.b)}${hr((isNaN(this.opacity)?1:this.opacity)*255)}`}function qd(){const t=el(this.opacity);return`${t===1?"rgb(":"rgba("}${pr(this.r)}, ${pr(this.g)}, ${pr(this.b)}${t===1?")":`, ${t})`}`}function el(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function pr(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function hr(t){return t=pr(t),(t<16?"0":"")+t.toString(16)}function Zd(t,r,i,l){return l<=0?t=r=i=NaN:i<=0||i>=1?t=r=NaN:r<=0&&(t=NaN),new Gt(t,r,i,l)}function yp(t){if(t instanceof Gt)return new Gt(t.h,t.s,t.l,t.opacity);if(t instanceof gi||(t=mr(t)),!t)return new Gt;if(t instanceof Gt)return t;t=t.rgb();var r=t.r/255,i=t.g/255,l=t.b/255,u=Math.min(r,i,l),c=Math.max(r,i,l),f=NaN,h=c-u,p=(c+u)/2;return h?(r===c?f=(i-l)/h+(i0&&p<1?0:f,new Gt(f,h,p,t.opacity)}function zv(t,r,i,l){return arguments.length===1?yp(t):new Gt(t,r,i,l??1)}function Gt(t,r,i,l){this.h=+t,this.s=+r,this.l=+i,this.opacity=+l}Ga(Gt,zv,mp(gi,{brighter(t){return t=t==null?Js:Math.pow(Js,t),new Gt(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?ii:Math.pow(ii,t),new Gt(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,i=this.l,l=i+(i<.5?i:1-i)*r,u=2*i-l;return new Et(xa(t>=240?t-240:t+120,u,l),xa(t,u,l),xa(t<120?t+240:t-120,u,l),this.opacity)},clamp(){return new Gt(Jd(this.h),Hs(this.s),Hs(this.l),el(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=el(this.opacity);return`${t===1?"hsl(":"hsla("}${Jd(this.h)}, ${Hs(this.s)*100}%, ${Hs(this.l)*100}%${t===1?")":`, ${t})`}`}}));function Jd(t){return t=(t||0)%360,t<0?t+360:t}function Hs(t){return Math.max(0,Math.min(1,t||0))}function xa(t,r,i){return(t<60?r+(i-r)*t/60:t<180?i:t<240?r+(i-r)*(240-t)/60:r)*255}const Ka=t=>()=>t;function jv(t,r){return function(i){return t+i*r}}function Rv(t,r,i){return t=Math.pow(t,i),r=Math.pow(r,i)-t,i=1/i,function(l){return Math.pow(t+l*r,i)}}function Lv(t){return(t=+t)==1?vp:function(r,i){return i-r?Rv(r,i,t):Ka(isNaN(r)?i:r)}}function vp(t,r){var i=r-t;return i?jv(t,i):Ka(isNaN(t)?r:t)}const tl=(function t(r){var i=Lv(r);function l(u,c){var f=i((u=La(u)).r,(c=La(c)).r),h=i(u.g,c.g),p=i(u.b,c.b),y=vp(u.opacity,c.opacity);return function(g){return u.r=f(g),u.g=h(g),u.b=p(g),u.opacity=y(g),u+""}}return l.gamma=t,l})(1);function Av(t,r){r||(r=[]);var i=t?Math.min(r.length,t.length):0,l=r.slice(),u;return function(c){for(u=0;ui&&(c=r.slice(i,c),h[f]?h[f]+=c:h[++f]=c),(l=l[0])===(u=u[0])?h[f]?h[f]+=u:h[++f]=u:(h[++f]=null,p.push({i:f,x:ln(l,u)})),i=wa.lastIndex;return i180?g+=360:g-y>180&&(y+=360),m.push({i:v.push(u(v)+"rotate(",null,l)-2,x:ln(y,g)})):g&&v.push(u(v)+"rotate("+g+l)}function h(y,g,v,m){y!==g?m.push({i:v.push(u(v)+"skewX(",null,l)-2,x:ln(y,g)}):g&&v.push(u(v)+"skewX("+g+l)}function p(y,g,v,m,w,S){if(y!==v||g!==m){var P=w.push(u(w)+"scale(",null,",",null,")");S.push({i:P-4,x:ln(y,v)},{i:P-2,x:ln(g,m)})}else(v!==1||m!==1)&&w.push(u(w)+"scale("+v+","+m+")")}return function(y,g){var v=[],m=[];return y=t(y),g=t(g),c(y.translateX,y.translateY,g.translateX,g.translateY,v,m),f(y.rotate,g.rotate,v,m),h(y.skewX,g.skewX,v,m),p(y.scaleX,y.scaleY,g.scaleX,g.scaleY,v,m),y=g=null,function(w){for(var S=-1,P=m.length,C;++S=0&&t._call.call(void 0,r),t=t._next;--no}function nh(){yr=(rl=li.now())+dl,no=ei=0;try{Kv()}finally{no=0,Zv(),yr=0}}function qv(){var t=li.now(),r=t-rl;r>_p&&(dl-=r,rl=t)}function Zv(){for(var t,r=nl,i,l=1/0;r;)r._call?(l>r._time&&(l=r._time),t=r,r=r._next):(i=r._next,r._next=null,r=t?t._next=i:nl=i);ti=t,Da(l)}function Da(t){if(!no){ei&&(ei=clearTimeout(ei));var r=t-yr;r>24?(t<1/0&&(ei=setTimeout(nh,t-li.now()-dl)),Zo&&(Zo=clearInterval(Zo))):(Zo||(rl=li.now(),Zo=setInterval(qv,_p)),no=1,Ep(nh))}}function rh(t,r,i){var l=new ol;return r=r==null?0:+r,l.restart(u=>{l.stop(),t(u+r)},r,i),l}var Jv=cl("start","end","cancel","interrupt"),ex=[],Np=0,oh=1,Oa=2,Gs=3,ih=4,Fa=5,Ks=6;function hl(t,r,i,l,u,c){var f=t.__transition;if(!f)t.__transition={};else if(i in f)return;tx(t,i,{name:r,index:l,group:u,on:Jv,tween:ex,time:c.time,delay:c.delay,duration:c.duration,ease:c.ease,timer:null,state:Np})}function Za(t,r){var i=Jt(t,r);if(i.state>Np)throw new Error("too late; already scheduled");return i}function an(t,r){var i=Jt(t,r);if(i.state>Gs)throw new Error("too late; already running");return i}function Jt(t,r){var i=t.__transition;if(!i||!(i=i[r]))throw new Error("transition not found");return i}function tx(t,r,i){var l=t.__transition,u;l[r]=i,i.timer=kp(c,0,i.time);function c(y){i.state=oh,i.timer.restart(f,i.delay,i.time),i.delay<=y&&f(y-i.delay)}function f(y){var g,v,m,w;if(i.state!==oh)return p();for(g in l)if(w=l[g],w.name===i.name){if(w.state===Gs)return rh(f);w.state===ih?(w.state=Ks,w.timer.stop(),w.on.call("interrupt",t,t.__data__,w.index,w.group),delete l[g]):+gOa&&l.state=0&&(r=r.slice(0,i)),!r||r==="start"})}function zx(t,r,i){var l,u,c=Tx(r)?Za:an;return function(){var f=c(this,t),h=f.on;h!==l&&(u=(l=h).copy()).on(r,i),f.on=u}}function jx(t,r){var i=this._id;return arguments.length<2?Jt(this.node(),i).on.on(t):this.each(zx(i,t,r))}function Rx(t){return function(){var r=this.parentNode;for(var i in this.__transition)if(+i!==t)return;r&&r.removeChild(this)}}function Lx(){return this.on("end.remove",Rx(this._id))}function Ax(t){var r=this._name,i=this._id;typeof t!="function"&&(t=Xa(t));for(var l=this._groups,u=l.length,c=new Array(u),f=0;f()=>t;function sw(t,{sourceEvent:r,target:i,transform:l,dispatch:u}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:r,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},transform:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}function wn(t,r,i){this.k=t,this.x=r,this.y=i}wn.prototype={constructor:wn,scale:function(t){return t===1?this:new wn(this.k*t,this.x,this.y)},translate:function(t,r){return t===0&r===0?this:new wn(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 pl=new wn(1,0,0);Ip.prototype=wn.prototype;function Ip(t){for(;!t.__zoom;)if(!(t=t.parentNode))return pl;return t.__zoom}function Sa(t){t.stopImmediatePropagation()}function Jo(t){t.preventDefault(),t.stopImmediatePropagation()}function lw(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function uw(){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||pl}function aw(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function cw(){return navigator.maxTouchPoints||"ontouchstart"in this}function fw(t,r,i){var l=t.invertX(r[0][0])-i[0][0],u=t.invertX(r[1][0])-i[1][0],c=t.invertY(r[0][1])-i[0][1],f=t.invertY(r[1][1])-i[1][1];return t.translate(u>l?(l+u)/2:Math.min(0,l)||Math.max(0,u),f>c?(c+f)/2:Math.min(0,c)||Math.max(0,f))}function Tp(){var t=lw,r=uw,i=fw,l=aw,u=cw,c=[0,1/0],f=[[-1/0,-1/0],[1/0,1/0]],h=250,p=Qs,y=cl("start","zoom","end"),g,v,m,w=500,S=150,P=0,C=10;function E(N){N.property("__zoom",sh).on("wheel.zoom",X,{passive:!1}).on("mousedown.zoom",G).on("dblclick.zoom",te).filter(u).on("touchstart.zoom",Z).on("touchmove.zoom",ee).on("touchend.zoom touchcancel.zoom",J).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(N,U,H,b){var A=N.selection?N.selection():N;A.property("__zoom",sh),N!==A?F(N,U,H,b):A.interrupt().each(function(){$(this,arguments).event(b).start().zoom(null,typeof U=="function"?U.apply(this,arguments):U).end()})},E.scaleBy=function(N,U,H,b){E.scaleTo(N,function(){var A=this.__zoom.k,L=typeof U=="function"?U.apply(this,arguments):U;return A*L},H,b)},E.scaleTo=function(N,U,H,b){E.transform(N,function(){var A=r.apply(this,arguments),L=this.__zoom,O=H==null?I(A):typeof H=="function"?H.apply(this,arguments):H,M=L.invert(O),z=typeof U=="function"?U.apply(this,arguments):U;return i(_(j(L,z),O,M),A,f)},H,b)},E.translateBy=function(N,U,H,b){E.transform(N,function(){return i(this.__zoom.translate(typeof U=="function"?U.apply(this,arguments):U,typeof H=="function"?H.apply(this,arguments):H),r.apply(this,arguments),f)},null,b)},E.translateTo=function(N,U,H,b,A){E.transform(N,function(){var L=r.apply(this,arguments),O=this.__zoom,M=b==null?I(L):typeof b=="function"?b.apply(this,arguments):b;return i(pl.translate(M[0],M[1]).scale(O.k).translate(typeof U=="function"?-U.apply(this,arguments):-U,typeof H=="function"?-H.apply(this,arguments):-H),L,f)},b,A)};function j(N,U){return U=Math.max(c[0],Math.min(c[1],U)),U===N.k?N:new wn(U,N.x,N.y)}function _(N,U,H){var b=U[0]-H[0]*N.k,A=U[1]-H[1]*N.k;return b===N.x&&A===N.y?N:new wn(N.k,b,A)}function I(N){return[(+N[0][0]+ +N[1][0])/2,(+N[0][1]+ +N[1][1])/2]}function F(N,U,H,b){N.on("start.zoom",function(){$(this,arguments).event(b).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(b).end()}).tween("zoom",function(){var A=this,L=arguments,O=$(A,L).event(b),M=r.apply(A,L),z=H==null?I(M):typeof H=="function"?H.apply(A,L):H,ne=Math.max(M[1][0]-M[0][0],M[1][1]-M[0][1]),re=A.__zoom,ae=typeof U=="function"?U.apply(A,L):U,fe=p(re.invert(z).concat(ne/re.k),ae.invert(z).concat(ne/ae.k));return function(ce){if(ce===1)ce=ae;else{var K=fe(ce),se=ne/K[2];ce=new wn(se,z[0]-K[0]*se,z[1]-K[1]*se)}O.zoom(null,ce)}})}function $(N,U,H){return!H&&N.__zooming||new B(N,U)}function B(N,U){this.that=N,this.args=U,this.active=0,this.sourceEvent=null,this.extent=r.apply(N,U),this.taps=0}B.prototype={event:function(N){return N&&(this.sourceEvent=N),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(N,U){return this.mouse&&N!=="mouse"&&(this.mouse[1]=U.invert(this.mouse[0])),this.touch0&&N!=="touch"&&(this.touch0[1]=U.invert(this.touch0[0])),this.touch1&&N!=="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(N){var U=Rt(this.that).datum();y.call(N,this.that,new sw(N,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:y}),U)}};function X(N,...U){if(!t.apply(this,arguments))return;var H=$(this,U).event(N),b=this.__zoom,A=Math.max(c[0],Math.min(c[1],b.k*Math.pow(2,l.apply(this,arguments)))),L=Qt(N);if(H.wheel)(H.mouse[0][0]!==L[0]||H.mouse[0][1]!==L[1])&&(H.mouse[1]=b.invert(H.mouse[0]=L)),clearTimeout(H.wheel);else{if(b.k===A)return;H.mouse=[L,b.invert(L)],qs(this),H.start()}Jo(N),H.wheel=setTimeout(O,S),H.zoom("mouse",i(_(j(b,A),H.mouse[0],H.mouse[1]),H.extent,f));function O(){H.wheel=null,H.end()}}function G(N,...U){if(m||!t.apply(this,arguments))return;var H=N.currentTarget,b=$(this,U,!0).event(N),A=Rt(N.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",ne,!0),L=Qt(N,H),O=N.clientX,M=N.clientY;hp(N.view),Sa(N),b.mouse=[L,this.__zoom.invert(L)],qs(this),b.start();function z(re){if(Jo(re),!b.moved){var ae=re.clientX-O,fe=re.clientY-M;b.moved=ae*ae+fe*fe>P}b.event(re).zoom("mouse",i(_(b.that.__zoom,b.mouse[0]=Qt(re,H),b.mouse[1]),b.extent,f))}function ne(re){A.on("mousemove.zoom mouseup.zoom",null),pp(re.view,b.moved),Jo(re),b.event(re).end()}}function te(N,...U){if(t.apply(this,arguments)){var H=this.__zoom,b=Qt(N.changedTouches?N.changedTouches[0]:N,this),A=H.invert(b),L=H.k*(N.shiftKey?.5:2),O=i(_(j(H,L),b,A),r.apply(this,U),f);Jo(N),h>0?Rt(this).transition().duration(h).call(F,O,b,N):Rt(this).call(E.transform,O,b,N)}}function Z(N,...U){if(t.apply(this,arguments)){var H=N.touches,b=H.length,A=$(this,U,N.changedTouches.length===b).event(N),L,O,M,z;for(Sa(N),O=0;O`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:i,targetHandle:l})=>`Couldn't create edge for ${t} handle id: "${t==="source"?i:l}", 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.`},ui=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],zp=["Enter"," ","Escape"],jp={"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:i})=>`Moved selected node ${t}. New position, x: ${r}, y: ${i}`,"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 ro;(function(t){t.Strict="strict",t.Loose="loose"})(ro||(ro={}));var gr;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(gr||(gr={}));var ai;(function(t){t.Partial="partial",t.Full="full"})(ai||(ai={}));const Rp={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Yn;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Yn||(Yn={}));var il;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(il||(il={}));var Se;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(Se||(Se={}));const lh={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function Lp(t){return t===null?null:t?"valid":"invalid"}const Ap=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,dw=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),ec=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),mi=(t,r=[0,0])=>{const{width:i,height:l}=en(t),u=t.origin??r,c=i*u[0],f=l*u[1];return{x:t.position.x-c,y:t.position.y-f}},hw=(t,r={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};let i=!1;const l=t.reduce((u,c)=>{const f=typeof c=="string";let h=!r.nodeLookup&&!f?c:void 0;return r.nodeLookup&&(h=f?r.nodeLookup.get(c):ec(c)?c:r.nodeLookup.get(c.id)),h?(i=!0,gl(u,sl(h,r.nodeOrigin))):u},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return i?ml(l):{x:0,y:0,width:0,height:0}},yi=(t,r={})=>{let i={x:1/0,y:1/0,x2:-1/0,y2:-1/0},l=!1;return t.forEach(u=>{(r.filter===void 0||r.filter(u))&&(i=gl(i,sl(u)),l=!0)}),l?ml(i):{x:0,y:0,width:0,height:0}},tc=(t,r,[i,l,u]=[0,0,1],c=!1,f=!1)=>{const h=(r.x-i)/u,p=(r.y-l)/u,y=r.width/u,g=r.height/u,v=[];for(const m of t.values()){const{measured:w,selectable:S=!0,hidden:P=!1}=m;if(f&&!S||P)continue;const C=w.width??m.width??m.initialWidth??0,E=w.height??m.height??m.initialHeight??0,{x:j,y:_}=m.internals.positionAbsolute,I=Fp(h,p,y,g,j,_,C,E),F=C*E,$=c&&I>0;(!m.internals.handleBounds||$||I>=F||m.dragging)&&v.push(m)}return v},pw=(t,r)=>{const i=new Set;return t.forEach(l=>{i.add(l.id)}),r.filter(l=>i.has(l.source)||i.has(l.target))};function gw(t,r){const i=new Map,l=r!=null&&r.nodes?new Set(r.nodes.map(u=>u.id)):null;return t.forEach(u=>{let c;if(r!=null&&r.includeHiddenNodes){const{width:f,height:h}=en(u);c=f>0&&h>0}else c=!!(u.measured.width&&u.measured.height&&!u.hidden);c&&(!l||l.has(u.id))&&i.set(u.id,u)}),i}async function mw({nodes:t,width:r,height:i,panZoom:l,minZoom:u,maxZoom:c},f){if(t.size===0)return!0;const h=gw(t,f),p=yi(h),y=rc(p,r,i,(f==null?void 0:f.minZoom)??u,(f==null?void 0:f.maxZoom)??c,(f==null?void 0:f.padding)??.1);return await l.setViewport(y,{duration:f==null?void 0:f.duration,ease:f==null?void 0:f.ease,interpolate:f==null?void 0:f.interpolate}),!0}function $p({nodeId:t,nextPosition:r,nodeLookup:i,nodeOrigin:l=[0,0],nodeExtent:u,onError:c}){const f=i.get(t),h=f.parentId?i.get(f.parentId):void 0,{x:p,y}=h?h.internals.positionAbsolute:{x:0,y:0},g=f.origin??l;let v=f.extent||u;if(f.extent==="parent"&&!f.expandParent)if(!h)c==null||c("005",Zt.error005());else{const{width:w,height:S}=en(h);w&&S&&(v=[[p,y],[p+w,y+S]])}else h&&xr(f.extent)&&(v=[[f.extent[0][0]+p,f.extent[0][1]+y],[f.extent[1][0]+p,f.extent[1][1]+y]]);const m=xr(v)?vr(r,v,f.measured):r;return(f.measured.width===void 0||f.measured.height===void 0)&&(c==null||c("015",Zt.error015())),{position:{x:m.x-p+(f.measured.width??0)*g[0],y:m.y-y+(f.measured.height??0)*g[1]},positionAbsolute:m}}async function yw({nodesToRemove:t=[],edgesToRemove:r=[],nodes:i,edges:l,onBeforeDelete:u}){const c=new Set(t.map(m=>m.id)),f=[];for(const m of i){if(m.deletable===!1)continue;const w=c.has(m.id),S=!w&&m.parentId&&f.find(P=>P.id===m.parentId);(w||S)&&f.push(m)}const h=new Set(r.map(m=>m.id)),p=l.filter(m=>m.deletable!==!1),g=pw(f,p);for(const m of p)h.has(m.id)&&!g.find(S=>S.id===m.id)&&g.push(m);if(!u)return{edges:g,nodes:f};const v=await u({nodes:f,edges:g});return typeof v=="boolean"?v?{edges:g,nodes:f}:{edges:[],nodes:[]}:v}const oo=(t,r=0,i=1)=>Math.min(Math.max(t,r),i),vr=(t={x:0,y:0},r,i)=>({x:oo(t.x,r[0][0],r[1][0]-((i==null?void 0:i.width)??0)),y:oo(t.y,r[0][1],r[1][1]-((i==null?void 0:i.height)??0))});function Dp(t,r,i){const{width:l,height:u}=en(i),{x:c,y:f}=i.internals.positionAbsolute;return vr(t,[[c,f],[c+l,f+u]],r)}const uh=(t,r,i)=>ti?-oo(Math.abs(t-i),1,r)/r:0,nc=(t,r,i=15,l=40)=>{const u=uh(t.x,l,r.width-l)*i,c=uh(t.y,l,r.height-l)*i;return[u,c]},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)}),Ha=({x:t,y:r,width:i,height:l})=>({x:t,y:r,x2:t+i,y2:r+l}),ml=({x:t,y:r,x2:i,y2:l})=>({x:t,y:r,width:i-t,height:l-r}),ci=(t,r=[0,0])=>{var u,c;const{x:i,y:l}=ec(t)?t.internals.positionAbsolute:mi(t,r);return{x:i,y:l,width:((u=t.measured)==null?void 0:u.width)??t.width??t.initialWidth??0,height:((c=t.measured)==null?void 0:c.height)??t.height??t.initialHeight??0}},sl=(t,r=[0,0])=>{var u,c;const{x:i,y:l}=ec(t)?t.internals.positionAbsolute:mi(t,r);return{x:i,y:l,x2:i+(((u=t.measured)==null?void 0:u.width)??t.width??t.initialWidth??0),y2:l+(((c=t.measured)==null?void 0:c.height)??t.height??t.initialHeight??0)}},Op=(t,r)=>ml(gl(Ha(t),Ha(r))),Fp=(t,r,i,l,u,c,f,h)=>{const p=Math.max(0,Math.min(t+i,u+f)-Math.max(t,u)),y=Math.max(0,Math.min(r+l,c+h)-Math.max(r,c));return Math.ceil(p*y)},ll=(t,r)=>Fp(t.x,t.y,t.width,t.height,r.x,r.y,r.width,r.height),ah=t=>Kt(t.width)&&Kt(t.height)&&Kt(t.x)&&Kt(t.y),Kt=t=>!isNaN(t)&&isFinite(t),Hp=(t,r)=>(i,l)=>{},vi=(t,r=[1,1])=>({x:r[0]*Math.round(t.x/r[0]),y:r[1]*Math.round(t.y/r[1])}),xi=({x:t,y:r},[i,l,u],c=!1,f=[1,1])=>{const h={x:(t-i)/u,y:(r-l)/u};return c?vi(h,f):h},io=({x:t,y:r},[i,l,u])=>({x:t*u+i,y:r*u+l});function qr(t,r){if(typeof t=="number")return Math.floor((r-r/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const i=parseFloat(t);if(!Number.isNaN(i))return Math.floor(i)}if(typeof t=="string"&&t.endsWith("%")){const i=parseFloat(t);if(!Number.isNaN(i))return Math.floor(r*i*.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 vw(t,r,i){if(typeof t=="string"||typeof t=="number"){const l=qr(t,i),u=qr(t,r);return{top:l,right:u,bottom:l,left:u,x:u*2,y:l*2}}if(typeof t=="object"){const l=qr(t.top??t.y??0,i),u=qr(t.bottom??t.y??0,i),c=qr(t.left??t.x??0,r),f=qr(t.right??t.x??0,r);return{top:l,right:f,bottom:u,left:c,x:c+f,y:l+u}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function xw(t,r,i,l,u,c){const{x:f,y:h}=io(t,[r,i,l]),{x:p,y}=io({x:t.x+t.width,y:t.y+t.height},[r,i,l]),g=u-p,v=c-y;return{left:Math.floor(f),top:Math.floor(h),right:Math.floor(g),bottom:Math.floor(v)}}const rc=(t,r,i,l,u,c)=>{const f=vw(c,r,i),h=(r-f.x)/t.width,p=(i-f.y)/t.height,y=Math.min(h,p),g=oo(y,l,u),v=t.x+t.width/2,m=t.y+t.height/2,w=r/2-v*g,S=i/2-m*g,P=xw(t,w,S,g,r,i),C={left:Math.min(P.left-f.left,0),top:Math.min(P.top-f.top,0),right:Math.min(P.right-f.right,0),bottom:Math.min(P.bottom-f.bottom,0)};return{x:w-C.left+C.right,y:S-C.top+C.bottom,zoom:g}},fi=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function xr(t){return t!=null&&t!=="parent"}function en(t){var r,i;return{width:((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth??0,height:((i=t.measured)==null?void 0:i.height)??t.height??t.initialHeight??0}}function Vp(t){var r,i;return(((r=t.measured)==null?void 0:r.width)??t.width??t.initialWidth)!==void 0&&(((i=t.measured)==null?void 0:i.height)??t.height??t.initialHeight)!==void 0}function Bp(t,r={width:0,height:0},i,l,u){const c={...t},f=l.get(i);if(f){const h=f.origin||u;c.x+=f.internals.positionAbsolute.x-(r.width??0)*h[0],c.y+=f.internals.positionAbsolute.y-(r.height??0)*h[1]}return c}function ch(t,r){if(t.size!==r.size)return!1;for(const i of t)if(!r.has(i))return!1;return!0}function ww(){let t,r;return{promise:new Promise((l,u)=>{t=l,r=u}),resolve:t,reject:r}}function Sw(t){return{...jp,...t||{}}}function ri(t,{snapGrid:r=[0,0],snapToGrid:i=!1,transform:l,containerBounds:u}){const{x:c,y:f}=qt(t),h=xi({x:c-((u==null?void 0:u.left)??0),y:f-((u==null?void 0:u.top)??0)},l),{x:p,y}=i?vi(h,r):h;return{xSnapped:p,ySnapped:y,...h}}const oc=t=>({width:t.offsetWidth,height:t.offsetHeight}),bp=t=>{var r;return((r=t==null?void 0:t.getRootNode)==null?void 0:r.call(t))||(window==null?void 0:window.document)},_w=["INPUT","SELECT","TEXTAREA"];function Up(t){var l,u;const r=((u=(l=t.composedPath)==null?void 0:l.call(t))==null?void 0:u[0])||t.target;return(r==null?void 0:r.nodeType)!==1?!1:_w.includes(r.nodeName)||r.hasAttribute("contenteditable")||!!r.closest(".nokey")}const Wp=t=>"clientX"in t,qt=(t,r)=>{var c,f;const i=Wp(t),l=i?t.clientX:(c=t.touches)==null?void 0:c[0].clientX,u=i?t.clientY:(f=t.touches)==null?void 0:f[0].clientY;return{x:l-((r==null?void 0:r.left)??0),y:u-((r==null?void 0:r.top)??0)}},fh=(t,r,i,l,u)=>{const c=r.querySelectorAll(`.${t}`);return!c||!c.length?null:Array.from(c).map(f=>{const h=f.getBoundingClientRect();return{id:f.getAttribute("data-handleid"),type:t,nodeId:u,position:f.getAttribute("data-handlepos"),x:(h.left-i.left)/l,y:(h.top-i.top)/l,...oc(f)}})};function Yp({sourceX:t,sourceY:r,targetX:i,targetY:l,sourceControlX:u,sourceControlY:c,targetControlX:f,targetControlY:h}){const p=t*.125+u*.375+f*.375+i*.125,y=r*.125+c*.375+h*.375+l*.125,g=Math.abs(p-t),v=Math.abs(y-r);return[p,y,g,v]}function bs(t,r){return t>=0?.5*t:r*25*Math.sqrt(-t)}function dh({pos:t,x1:r,y1:i,x2:l,y2:u,c}){switch(t){case Se.Left:return[r-bs(r-l,c),i];case Se.Right:return[r+bs(l-r,c),i];case Se.Top:return[r,i-bs(i-u,c)];case Se.Bottom:return[r,i+bs(u-i,c)]}}function Xp({sourceX:t,sourceY:r,sourcePosition:i=Se.Bottom,targetX:l,targetY:u,targetPosition:c=Se.Top,curvature:f=.25}){const[h,p]=dh({pos:i,x1:t,y1:r,x2:l,y2:u,c:f}),[y,g]=dh({pos:c,x1:l,y1:u,x2:t,y2:r,c:f}),[v,m,w,S]=Yp({sourceX:t,sourceY:r,targetX:l,targetY:u,sourceControlX:h,sourceControlY:p,targetControlX:y,targetControlY:g});return[`M${t},${r} C${h},${p} ${y},${g} ${l},${u}`,v,m,w,S]}function Qp({sourceX:t,sourceY:r,targetX:i,targetY:l}){const u=Math.abs(i-t)/2,c=i0}const Nw=({source:t,sourceHandle:r,target:i,targetHandle:l})=>`xy-edge__${t}${r||""}-${i}${l||""}`,Cw=(t,r)=>r.some(i=>i.source===t.source&&i.target===t.target&&(i.sourceHandle===t.sourceHandle||!i.sourceHandle&&!t.sourceHandle)&&(i.targetHandle===t.targetHandle||!i.targetHandle&&!t.targetHandle)),Mw=(t,r,i={})=>{var c;if(!t.source||!t.target)return(c=i.onError)==null||c.call(i,"006",Zt.error006()),r;const l=i.getEdgeId||Nw;let u;return Ap(t)?u={...t}:u={...t,id:l(t)},Cw(u,r)?r:(u.sourceHandle===null&&delete u.sourceHandle,u.targetHandle===null&&delete u.targetHandle,r.concat(u))};function Gp({sourceX:t,sourceY:r,targetX:i,targetY:l}){const[u,c,f,h]=Qp({sourceX:t,sourceY:r,targetX:i,targetY:l});return[`M ${t},${r}L ${i},${l}`,u,c,f,h]}const hh={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},Pw=({source:t,sourcePosition:r=Se.Bottom,target:i})=>r===Se.Left||r===Se.Right?t.xMath.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2));function Iw({source:t,sourcePosition:r=Se.Bottom,target:i,targetPosition:l=Se.Top,center:u,offset:c,stepPosition:f}){const h=hh[r],p=hh[l],y={x:t.x+h.x*c,y:t.y+h.y*c},g={x:i.x+p.x*c,y:i.y+p.y*c},v=Pw({source:y,sourcePosition:r,target:g}),m=v.x!==0?"x":"y",w=v[m];let S=[],P,C;const E={x:0,y:0},j={x:0,y:0},[,,_,I]=Qp({sourceX:t.x,sourceY:t.y,targetX:i.x,targetY:i.y});if(h[m]*p[m]===-1){m==="x"?(P=u.x??y.x+(g.x-y.x)*f,C=u.y??(y.y+g.y)/2):(P=u.x??(y.x+g.x)/2,C=u.y??y.y+(g.y-y.y)*f);const X=[{x:P,y:y.y},{x:P,y:g.y}],G=[{x:y.x,y:C},{x:g.x,y:C}];h[m]===w?S=m==="x"?X:G:S=m==="x"?G:X}else{const X=[{x:y.x,y:g.y}],G=[{x:g.x,y:y.y}];if(m==="x"?S=h.x===w?G:X:S=h.y===w?X:G,r===l){const N=Math.abs(t[m]-i[m]);if(N<=c){const U=Math.min(c-1,c-N);h[m]===w?E[m]=(y[m]>t[m]?-1:1)*U:j[m]=(g[m]>i[m]?-1:1)*U}}if(r!==l){const N=m==="x"?"y":"x",U=h[m]===p[N],H=y[N]>g[N],b=y[N]=J?(P=(te.x+Z.x)/2,C=S[0].y):(P=S[0].x,C=(te.y+Z.y)/2)}const F={x:y.x+E.x,y:y.y+E.y},$={x:g.x+j.x,y:g.y+j.y};return[[t,...F.x!==S[0].x||F.y!==S[0].y?[F]:[],...S,...$.x!==S[S.length-1].x||$.y!==S[S.length-1].y?[$]:[],i],P,C,_,I]}function Tw(t,r,i,l){const u=Math.min(ph(t,r)/2,ph(r,i)/2,l),{x:c,y:f}=r;if(t.x===c&&c===i.x||t.y===f&&f===i.y)return`L${c} ${f}`;if(t.y===f){const y=t.xi.id===r):t[0])||null}function Ba(t,r){return t?typeof t=="string"?t:`${r?`${r}__`:""}${Object.keys(t).sort().map(l=>`${l}=${t[l]}`).join("&")}`:""}function jw(t,{id:r,defaultColor:i,defaultMarkerStart:l,defaultMarkerEnd:u}){const c=new Set;return t.reduce((f,h)=>([h.markerStart||l,h.markerEnd||u].forEach(p=>{if(p&&typeof p=="object"){const y=Ba(p,r);c.has(y)||(f.push({id:y,color:p.color||i,...p}),c.add(y))}}),f),[]).sort((f,h)=>f.id.localeCompare(h.id))}const Kp=1e3,Rw=10,ic={nodeOrigin:[0,0],nodeExtent:ui,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Lw={...ic,checkEquality:!0};function sc(t,r){const i={...t};for(const l in r)r[l]!==void 0&&(i[l]=r[l]);return i}function Aw(t,r,i){const l=sc(ic,i);for(const u of t.values())if(u.parentId)uc(u,t,r,l);else{const c=mi(u,l.nodeOrigin),f=xr(u.extent)?u.extent:l.nodeExtent,h=vr(c,f,en(u));u.internals.positionAbsolute=h}}function $w(t,r){if(!t.handles)return t.measured?r==null?void 0:r.internals.handleBounds:void 0;const i=[],l=[];for(const u of t.handles){const c={id:u.id,width:u.width??1,height:u.height??1,nodeId:t.id,x:u.x,y:u.y,position:u.position,type:u.type};u.type==="source"?i.push(c):u.type==="target"&&l.push(c)}return{source:i,target:l}}function lc(t){return t==="manual"}function ba(t,r,i,l={}){var g,v;const u=sc(Lw,l),c={i:0},f=new Map(r),h=u!=null&&u.elevateNodesOnSelect&&!lc(u.zIndexMode)?Kp:0;let p=t.length>0,y=!1;r.clear(),i.clear();for(const m of t){let w=f.get(m.id);if(u.checkEquality&&m===(w==null?void 0:w.internals.userNode))r.set(m.id,w);else{const S=mi(m,u.nodeOrigin),P=xr(m.extent)?m.extent:u.nodeExtent,C=vr(S,P,en(m));w={...u.defaults,...m,measured:{width:(g=m.measured)==null?void 0:g.width,height:(v=m.measured)==null?void 0:v.height},internals:{positionAbsolute:C,handleBounds:$w(m,w),z:qp(m,h,u.zIndexMode),userNode:m}},r.set(m.id,w)}(w.measured===void 0||w.measured.width===void 0||w.measured.height===void 0)&&!w.hidden&&(p=!1),m.parentId&&uc(w,r,i,l,c),y||(y=m.selected??!1)}return{nodesInitialized:p,hasSelectedNodes:y}}function Dw(t,r){if(!t.parentId)return;const i=r.get(t.parentId);i?i.set(t.id,t):r.set(t.parentId,new Map([[t.id,t]]))}function uc(t,r,i,l,u){const{elevateNodesOnSelect:c,nodeOrigin:f,nodeExtent:h,zIndexMode:p}=sc(ic,l),y=t.parentId,g=r.get(y);if(!g){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}Dw(t,i),u&&!g.parentId&&g.internals.rootParentIndex===void 0&&p==="auto"&&(g.internals.rootParentIndex=++u.i,g.internals.z=g.internals.z+u.i*Rw),u&&g.internals.rootParentIndex!==void 0&&(u.i=g.internals.rootParentIndex);const v=c&&!lc(p)?Kp:0,{x:m,y:w,z:S}=Ow(t,g,f,h,v,p),{positionAbsolute:P}=t.internals,C=m!==P.x||w!==P.y;(C||S!==t.internals.z)&&r.set(t.id,{...t,internals:{...t.internals,positionAbsolute:C?{x:m,y:w}:P,z:S}})}function qp(t,r,i){const l=Kt(t.zIndex)?t.zIndex:0;return lc(i)?l:l+(t.selected?r:0)}function Ow(t,r,i,l,u,c){const{x:f,y:h}=r.internals.positionAbsolute,p=en(t),y=mi(t,i),g=xr(t.extent)?vr(y,t.extent,p):y;let v=vr({x:f+g.x,y:h+g.y},l,p);t.extent==="parent"&&(v=Dp(v,p,r));const m=qp(t,u,c),w=r.internals.z??0;return{x:v.x,y:v.y,z:w>=m?w+1:m}}function ac(t,r,i,l=[0,0]){var f;const u=[],c=new Map;for(const h of t){const p=r.get(h.parentId);if(!p)continue;const y=((f=c.get(h.parentId))==null?void 0:f.expandedRect)??ci(p),g=Op(y,h.rect);c.set(h.parentId,{expandedRect:g,parent:p})}return c.size>0&&c.forEach(({expandedRect:h,parent:p},y)=>{var _;const g=p.internals.positionAbsolute,v=en(p),m=p.origin??l,w=h.x0||S>0||E||j)&&(u.push({id:y,type:"position",position:{x:p.position.x-w+E,y:p.position.y-S+j}}),(_=i.get(y))==null||_.forEach(I=>{t.some(F=>F.id===I.id)||u.push({id:I.id,type:"position",position:{x:I.position.x+w,y:I.position.y+S}})})),(v.width0){const w=ac(m,r,i,u);y.push(...w)}return{changes:y,updatedInternals:p}}async function Hw({delta:t,panZoom:r,transform:i,translateExtent:l,width:u,height:c}){if(!r||!t.x&&!t.y)return!1;const f=await r.setViewportConstrained({x:i[0]+t.x,y:i[1]+t.y,zoom:i[2]},[[0,0],[u,c]],l);return!!f&&(f.x!==i[0]||f.y!==i[1]||f.k!==i[2])}function vh(t,r,i,l,u,c){let f=u;const h=l.get(f)||new Map;l.set(f,h.set(i,r)),f=`${u}-${t}`;const p=l.get(f)||new Map;if(l.set(f,p.set(i,r)),c){f=`${u}-${t}-${c}`;const y=l.get(f)||new Map;l.set(f,y.set(i,r))}}function Zp(t,r,i){t.clear(),r.clear();for(const l of i){const{source:u,target:c,sourceHandle:f=null,targetHandle:h=null}=l,p={edgeId:l.id,source:u,target:c,sourceHandle:f,targetHandle:h},y=`${u}-${f}--${c}-${h}`,g=`${c}-${h}--${u}-${f}`;vh("source",p,g,t,u,f),vh("target",p,y,t,c,h),r.set(l.id,l)}}function Jp(t,r){if(!t.parentId)return!1;const i=r.get(t.parentId);return i?i.selected?!0:Jp(i,r):!1}function xh(t,r,i){var u;let l=t;do{if((u=l==null?void 0:l.matches)!=null&&u.call(l,r))return!0;if(l===i)return!1;l=l==null?void 0:l.parentElement}while(l);return!1}function Vw(t,r,i,l){const u=new Map;for(const[c,f]of t)if((f.selected||f.id===l)&&(!f.parentId||!Jp(f,t))&&(f.draggable||r&&typeof f.draggable>"u")){const h=t.get(c);h&&u.set(c,{id:c,position:h.position||{x:0,y:0},distance:{x:i.x-h.internals.positionAbsolute.x,y:i.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 u}function _a({nodeId:t,dragItems:r,nodeLookup:i,dragging:l=!0}){var f,h,p;const u=[];for(const[y,g]of r){const v=(f=i.get(y))==null?void 0:f.internals.userNode;v&&u.push({...v,position:g.position,dragging:l})}if(!t)return[u[0],u];const c=(h=i.get(t))==null?void 0:h.internals.userNode;return[c?{...c,position:((p=r.get(t))==null?void 0:p.position)||c.position,dragging:l}:u[0],u]}function Bw({dragItems:t,snapGrid:r,x:i,y:l}){const u=t.values().next().value;if(!u)return null;const c={x:i-u.distance.x,y:l-u.distance.y},f=vi(c,r);return{x:f.x-c.x,y:f.y-c.y}}function bw({onNodeMouseDown:t,getStoreItems:r,onDragStart:i,onDrag:l,onDragStop:u}){let c={x:null,y:null},f=0,h=new Map,p=!1,y={x:0,y:0},g=null,v=!1,m=null,w=!1,S=!1,P=null;function C({noDragClassName:j,handleSelector:_,domNode:I,isSelectable:F,nodeId:$,nodeClickDistance:B=0}){m=Rt(I);function X({x:ee,y:J}){const{nodeLookup:N,nodeExtent:U,snapGrid:H,snapToGrid:b,nodeOrigin:A,onNodeDrag:L,onSelectionDrag:O,onError:M,updateNodePositions:z}=r();c={x:ee,y:J};let ne=!1;const re=h.size>1,ae=re&&U?Ha(yi(h)):null,fe=re&&b?Bw({dragItems:h,snapGrid:H,x:ee,y:J}):null;for(const[ce,K]of h){if(!N.has(ce))continue;let se={x:ee-K.distance.x,y:J-K.distance.y};b&&(se=fe?{x:Math.round(se.x+fe.x),y:Math.round(se.y+fe.y)}:vi(se,H));let pe=null;if(re&&U&&!K.extent&&ae){const{positionAbsolute:me}=K.internals,Ce=me.x-ae.x+U[0][0],Pe=me.x+K.measured.width-ae.x2+U[1][0],Ie=me.y-ae.y+U[0][1],Re=me.y+K.measured.height-ae.y2+U[1][1];pe=[[Ce,Ie],[Pe,Re]]}const{position:we,positionAbsolute:ve}=$p({nodeId:ce,nextPosition:se,nodeLookup:N,nodeExtent:pe||U,nodeOrigin:A,onError:M});ne=ne||K.position.x!==we.x||K.position.y!==we.y,K.position=we,K.internals.positionAbsolute=ve}if(S=S||ne,!!ne&&(z(h,!0),P&&(l||L||!$&&O))){const[ce,K]=_a({nodeId:$,dragItems:h,nodeLookup:N});l==null||l(P,h,ce,K),L==null||L(P,ce,K),$||O==null||O(P,K)}}async function G(){if(!g)return;const{transform:ee,panBy:J,autoPanSpeed:N,autoPanOnNodeDrag:U}=r();if(!U){p=!1,cancelAnimationFrame(f);return}const[H,b]=nc(y,g,N);(H!==0||b!==0)&&(c.x=(c.x??0)-H/ee[2],c.y=(c.y??0)-b/ee[2],await J({x:H,y:b})&&X(c)),f=requestAnimationFrame(G)}function te(ee){var re;const{nodeLookup:J,multiSelectionActive:N,nodesDraggable:U,transform:H,snapGrid:b,snapToGrid:A,selectNodesOnDrag:L,onNodeDragStart:O,onSelectionDragStart:M,unselectNodesAndEdges:z}=r();v=!0,(!L||!F)&&!N&&$&&((re=J.get($))!=null&&re.selected||z()),F&&L&&$&&(t==null||t($));const ne=ri(ee.sourceEvent,{transform:H,snapGrid:b,snapToGrid:A,containerBounds:g});if(c=ne,h=Vw(J,U,ne,$),h.size>0&&(i||O||!$&&M)){const[ae,fe]=_a({nodeId:$,dragItems:h,nodeLookup:J});i==null||i(ee.sourceEvent,h,ae,fe),O==null||O(ee.sourceEvent,ae,fe),$||M==null||M(ee.sourceEvent,fe)}}const Z=gp().clickDistance(B).on("start",ee=>{const{domNode:J,nodeDragThreshold:N,transform:U,snapGrid:H,snapToGrid:b}=r();g=(J==null?void 0:J.getBoundingClientRect())||null,w=!1,S=!1,P=ee.sourceEvent,N===0&&te(ee),c=ri(ee.sourceEvent,{transform:U,snapGrid:H,snapToGrid:b,containerBounds:g}),y=qt(ee.sourceEvent,g)}).on("drag",ee=>{const{autoPanOnNodeDrag:J,transform:N,snapGrid:U,snapToGrid:H,nodeDragThreshold:b,nodeLookup:A}=r(),L=ri(ee.sourceEvent,{transform:N,snapGrid:U,snapToGrid:H,containerBounds:g});if(P=ee.sourceEvent,(ee.sourceEvent.type==="touchmove"&&ee.sourceEvent.touches.length>1||$&&!A.has($))&&(w=!0),!w){if(!p&&J&&v&&(p=!0,G()),!v){const O=qt(ee.sourceEvent,g),M=O.x-y.x,z=O.y-y.y;Math.sqrt(M*M+z*z)>b&&te(ee)}(c.x!==L.xSnapped||c.y!==L.ySnapped)&&h&&v&&(y=qt(ee.sourceEvent,g),X(L))}}).on("end",ee=>{if(!v||w){w&&h.size>0&&r().updateNodePositions(h,!1);return}if(p=!1,v=!1,cancelAnimationFrame(f),h.size>0){const{nodeLookup:J,updateNodePositions:N,onNodeDragStop:U,onSelectionDragStop:H}=r();if(S&&(N(h,!1),S=!1),u||U||!$&&H){const[b,A]=_a({nodeId:$,dragItems:h,nodeLookup:J,dragging:!1});u==null||u(ee.sourceEvent,h,b,A),U==null||U(ee.sourceEvent,b,A),$||H==null||H(ee.sourceEvent,A)}}}).filter(ee=>{const J=ee.target;return!ee.button&&(!j||!xh(J,`.${j}`,I))&&(!_||xh(J,_,I))});m.call(Z)}function E(){m==null||m.on(".drag",null)}return{update:C,destroy:E}}function Uw(t,r,i){const l=[],u={x:t.x-i,y:t.y-i,width:i*2,height:i*2};for(const c of r.values())ll(u,ci(c))>0&&l.push(c);return l}const Ww=250;function Yw(t,r,i,l){var h,p;let u=[],c=1/0;const f=Uw(t,i,r+Ww);for(const y of f){const g=[...((h=y.internals.handleBounds)==null?void 0:h.source)??[],...((p=y.internals.handleBounds)==null?void 0:p.target)??[]];for(const v of g){if(l.nodeId===v.nodeId&&l.type===v.type&&l.id===v.id)continue;const{x:m,y:w}=wr(y,v,v.position,!0),S=Math.sqrt(Math.pow(m-t.x,2)+Math.pow(w-t.y,2));S>r||(S1){const y=l.type==="source"?"target":"source";return u.find(g=>g.type===y)??u[0]}return u[0]}function eg(t,r,i,l,u,c=!1){var y,g,v;const f=l.get(t);if(!f)return null;const h=u==="strict"?(y=f.internals.handleBounds)==null?void 0:y[r]:[...((g=f.internals.handleBounds)==null?void 0:g.source)??[],...((v=f.internals.handleBounds)==null?void 0:v.target)??[]],p=(i?h==null?void 0:h.find(m=>m.id===i):h==null?void 0:h[0])??null;return p&&c?{...p,...wr(f,p,p.position,!0)}:p}function tg(t,r){return t||(r!=null&&r.classList.contains("target")?"target":r!=null&&r.classList.contains("source")?"source":null)}function Xw(t,r){let i=null;return r?i=!0:t&&!r&&(i=!1),i}const ng=()=>!0;function Qw(t,{connectionMode:r,connectionRadius:i,handleId:l,nodeId:u,edgeUpdaterType:c,isTarget:f,domNode:h,nodeLookup:p,lib:y,autoPanOnConnect:g,flowId:v,panBy:m,cancelConnection:w,onConnectStart:S,onConnect:P,onConnectEnd:C,isValidConnection:E=ng,onReconnectEnd:j,updateConnection:_,getTransform:I,getFromHandle:F,autoPanSpeed:$,dragThreshold:B=1,handleDomNode:X}){const G=bp(t.target);let te=0,Z;const{x:ee,y:J}=qt(t),N=tg(c,X),U=h==null?void 0:h.getBoundingClientRect();let H=!1;if(!U||!N)return;const b=eg(u,N,l,p,r);if(!b)return;let A=qt(t,U),L=!1,O=null,M=!1,z=null;function ne(){if(!g||!U)return;const[we,ve]=nc(A,U,$);m({x:we,y:ve}),te=requestAnimationFrame(ne)}const re={...b,nodeId:u,type:N,position:b.position},ae=p.get(u);let ce={inProgress:!0,isValid:null,from:wr(ae,re,Se.Left,!0),fromHandle:re,fromPosition:re.position,fromNode:ae,to:A,toHandle:null,toPosition:lh[re.position],toNode:null,pointer:A};function K(){H=!0,_(ce),S==null||S(t,{nodeId:u,handleId:l,handleType:N})}B===0&&K();function se(we){if(!H){const{x:Re,y:Ze}=qt(we),nt=Re-ee,Qe=Ze-J;if(!(nt*nt+Qe*Qe>B*B))return;K()}if(!F()||!re){pe(we);return}const ve=I();A=qt(we,U),Z=Yw(xi(A,ve,!1,[1,1]),i,p,re),L||(ne(),L=!0);const me=rg(we,{handle:Z,connectionMode:r,fromNodeId:u,fromHandleId:l,fromType:f?"target":"source",isValidConnection:E,doc:G,lib:y,flowId:v,nodeLookup:p});z=me.handleDomNode,O=me.connection,M=Xw(!!Z,me.isValid);const Ce=p.get(u),Pe=Ce?wr(Ce,re,Se.Left,!0):ce.from,Ie={...ce,from:Pe,isValid:M,to:me.toHandle&&M?io({x:me.toHandle.x,y:me.toHandle.y},ve):A,toHandle:me.toHandle,toPosition:M&&me.toHandle?me.toHandle.position:lh[re.position],toNode:me.toHandle?p.get(me.toHandle.nodeId):null,pointer:A};_(Ie),ce=Ie}function pe(we){if(!("touches"in we&&we.touches.length>0)){if(H){(Z||z)&&O&&M&&(P==null||P(O));const{inProgress:ve,...me}=ce,Ce={...me,toPosition:ce.toHandle?ce.toPosition:null};C==null||C(we,Ce),c&&(j==null||j(we,Ce))}w(),cancelAnimationFrame(te),L=!1,M=!1,O=null,z=null,G.removeEventListener("mousemove",se),G.removeEventListener("mouseup",pe),G.removeEventListener("touchmove",se),G.removeEventListener("touchend",pe)}}G.addEventListener("mousemove",se),G.addEventListener("mouseup",pe),G.addEventListener("touchmove",se),G.addEventListener("touchend",pe)}function rg(t,{handle:r,connectionMode:i,fromNodeId:l,fromHandleId:u,fromType:c,doc:f,lib:h,flowId:p,isValidConnection:y=ng,nodeLookup:g}){const v=c==="target",m=r?f.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:w,y:S}=qt(t),P=f.elementFromPoint(w,S),C=P!=null&&P.classList.contains(`${h}-flow__handle`)?P:m,E={handleDomNode:C,isValid:!1,connection:null,toHandle:null};if(C){const j=tg(void 0,C),_=C.getAttribute("data-nodeid"),I=C.getAttribute("data-handleid"),F=C.classList.contains("connectable"),$=C.classList.contains("connectableend");if(!_||!j)return E;const B={source:v?_:l,sourceHandle:v?I:u,target:v?l:_,targetHandle:v?u:I};E.connection=B;const G=F&&$&&(i===ro.Strict?v&&j==="source"||!v&&j==="target":_!==l||I!==u);E.isValid=G&&y(B),E.toHandle=eg(_,j,I,g,i,!0)}return E}const Ua={onPointerDown:Qw,isValid:rg};function Gw({domNode:t,panZoom:r,getTransform:i,getViewScale:l}){const u=Rt(t);function c({translateExtent:h,width:p,height:y,zoomStep:g=1,pannable:v=!0,zoomable:m=!0,inversePan:w=!1}){const S=_=>{if(_.sourceEvent.type!=="wheel"||!r)return;const I=i(),F=_.sourceEvent.ctrlKey&&fi()?10:1,$=-_.sourceEvent.deltaY*(_.sourceEvent.deltaMode===1?.05:_.sourceEvent.deltaMode?1:.002)*g,B=I[2]*Math.pow(2,$*F);r.scaleTo(B)};let P=[0,0];const C=_=>{(_.sourceEvent.type==="mousedown"||_.sourceEvent.type==="touchstart")&&(P=[_.sourceEvent.clientX??_.sourceEvent.touches[0].clientX,_.sourceEvent.clientY??_.sourceEvent.touches[0].clientY])},E=_=>{const I=i();if(_.sourceEvent.type!=="mousemove"&&_.sourceEvent.type!=="touchmove"||!r)return;const F=[_.sourceEvent.clientX??_.sourceEvent.touches[0].clientX,_.sourceEvent.clientY??_.sourceEvent.touches[0].clientY],$=[F[0]-P[0],F[1]-P[1]];P=F;const B=l()*Math.max(I[2],Math.log(I[2]))*(w?-1:1),X={x:I[0]-$[0]*B,y:I[1]-$[1]*B},G=[[0,0],[p,y]];r.setViewportConstrained({x:X.x,y:X.y,zoom:I[2]},G,h)},j=Tp().on("start",C).on("zoom",v?E:null).on("zoom.wheel",m?S:null);u.call(j,{})}function f(){u.on("zoom",null)}return{update:c,destroy:f,pointer:Qt}}const yl=t=>({x:t.x,y:t.y,zoom:t.k}),Ea=({x:t,y:r,zoom:i})=>pl.translate(t,r).scale(i),Wn=(t,r)=>t.target.closest(`.${r}`),og=(t,r)=>r===2&&Array.isArray(t)&&t.includes(2),Kw=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,ka=(t,r=0,i=Kw,l=()=>{})=>{const u=typeof r=="number"&&r>0;return u||l(),u?t.transition().duration(r).ease(i).on("end",l):t},ig=t=>{const r=t.ctrlKey&&fi()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*r};function qw({zoomPanValues:t,noWheelClassName:r,d3Selection:i,d3Zoom:l,panOnScrollMode:u,panOnScrollSpeed:c,zoomOnPinch:f,onPanZoomStart:h,onPanZoom:p,onPanZoomEnd:y}){return g=>{if(Wn(g,r))return g.ctrlKey&&g.preventDefault(),!1;g.preventDefault(),g.stopImmediatePropagation();const v=i.property("__zoom").k||1;if(g.ctrlKey&&f){const C=Qt(g),E=ig(g),j=v*Math.pow(2,E);l.scaleTo(i,j,C,g);return}const m=g.deltaMode===1?20:1;let w=u===gr.Vertical?0:g.deltaX*m,S=u===gr.Horizontal?0:g.deltaY*m;!fi()&&g.shiftKey&&u!==gr.Vertical&&(w=g.deltaY*m,S=0),l.translateBy(i,-(w/v)*c,-(S/v)*c,{internal:!0});const P=yl(i.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?p==null||p(g,P):(t.isPanScrolling=!0,h==null||h(g,P)),t.panScrollTimeout=setTimeout(()=>{y==null||y(g,P),t.isPanScrolling=!1},150)}}function Zw({noWheelClassName:t,preventScrolling:r,d3ZoomHandler:i}){return function(l,u){const c=l.type==="wheel",f=!r&&c&&!l.ctrlKey,h=Wn(l,t);if(l.ctrlKey&&c&&h&&l.preventDefault(),f||h)return null;l.preventDefault(),i.call(this,l,u)}}function Jw({zoomPanValues:t,onDraggingChange:r,onPanZoomStart:i}){return l=>{var c,f,h;if((c=l.sourceEvent)!=null&&c.internal)return;const u=yl(l.transform);t.mouseButton=((f=l.sourceEvent)==null?void 0:f.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=u,((h=l.sourceEvent)==null?void 0:h.type)==="mousedown"&&r(!0),i&&(i==null||i(l.sourceEvent,u))}}function e1({zoomPanValues:t,panOnDrag:r,onPaneContextMenu:i,onTransformChange:l,onPanZoom:u}){return c=>{var f,h;t.usedRightMouseButton=!!(i&&og(r,t.mouseButton??0)),(f=c.sourceEvent)!=null&&f.sync||l([c.transform.x,c.transform.y,c.transform.k]),u&&!((h=c.sourceEvent)!=null&&h.internal)&&(u==null||u(c.sourceEvent,yl(c.transform)))}}function t1({zoomPanValues:t,panOnDrag:r,panOnScroll:i,onDraggingChange:l,onPanZoomEnd:u,onPaneContextMenu:c}){return f=>{var h;if(!((h=f.sourceEvent)!=null&&h.internal)&&(t.isZoomingOrPanning=!1,c&&og(r,t.mouseButton??0)&&!t.usedRightMouseButton&&f.sourceEvent&&c(f.sourceEvent),t.usedRightMouseButton=!1,l(!1),u)){const p=yl(f.transform);t.prevViewport=p,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{u==null||u(f.sourceEvent,p)},i?150:0)}}}function n1({panActivationKeyPressed:t,zoomActivationKeyPressed:r,zoomOnScroll:i,zoomOnPinch:l,panOnDrag:u,panOnScroll:c,zoomOnDoubleClick:f,userSelectionActive:h,noWheelClassName:p,noPanClassName:y,lib:g,connectionInProgress:v}){return m=>{var E;const w=r||i,S=l&&m.ctrlKey,P=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(Wn(m,`${g}-flow__node`)||Wn(m,`${g}-flow__edge`)||Wn(m,`${g}-flow__selection`)||Wn(m,`${g}-flow__nodesselection`)))return!0;if(!u&&!w&&!c&&!f&&!l||h||v&&!P||Wn(m,p)&&P||Wn(m,y)&&(!P||c&&P&&!r)||!l&&m.ctrlKey&&P)return!1;if(!l&&m.type==="touchstart"&&((E=m.touches)==null?void 0:E.length)>1)return m.preventDefault(),!1;if(!w&&!c&&!S&&P||!u&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(u)&&!u.includes(m.button)&&m.type==="mousedown")return!1;const C=Array.isArray(u)&&u.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||P||t)&&C}}function r1({domNode:t,minZoom:r,maxZoom:i,translateExtent:l,viewport:u,onPanZoom:c,onPanZoomStart:f,onPanZoomEnd:h,onDraggingChange:p}){const y={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},g=t.getBoundingClientRect();let v=[[0,0],[g.width,g.height]];const m=typeof ResizeObserver<"u"?new ResizeObserver(J=>{const N=J[0];N&&(v=[[0,0],[N.contentRect.width,N.contentRect.height]])}):null;m==null||m.observe(t);const w=Tp().extent(()=>v).scaleExtent([r,i]).translateExtent(l),S=Rt(t).call(w);I({x:u.x,y:u.y,zoom:oo(u.zoom,r,i)},[[0,0],[g.width,g.height]],l);const P=S.on("wheel.zoom"),C=S.on("dblclick.zoom");w.wheelDelta(ig);async function E(J,N){return S?new Promise(U=>{w==null||w.interpolate((N==null?void 0:N.interpolate)==="linear"?ni:Qs).transform(ka(S,N==null?void 0:N.duration,N==null?void 0:N.ease,()=>U(!0)),J)}):!1}function j({noWheelClassName:J,noPanClassName:N,onPaneContextMenu:U,userSelectionActive:H,panOnScroll:b,panOnDrag:A,panOnScrollMode:L,panOnScrollSpeed:O,preventScrolling:M,zoomOnPinch:z,zoomOnScroll:ne,zoomOnDoubleClick:re,panActivationKeyPressed:ae=!1,zoomActivationKeyPressed:fe,lib:ce,onTransformChange:K,connectionInProgress:se,paneClickDistance:pe,selectionOnDrag:we}){H&&!y.isZoomingOrPanning&&_();const ve=b&&!fe&&!H;w.clickDistance(we?1/0:!Kt(pe)||pe<0?0:pe);const me=ve?qw({zoomPanValues:y,noWheelClassName:J,d3Selection:S,d3Zoom:w,panOnScrollMode:L,panOnScrollSpeed:O,zoomOnPinch:z,onPanZoomStart:f,onPanZoom:c,onPanZoomEnd:h}):Zw({noWheelClassName:J,preventScrolling:M,d3ZoomHandler:P});S.on("wheel.zoom",me,{passive:!1});const Ce=Jw({zoomPanValues:y,onDraggingChange:p,onPanZoomStart:f});w.on("start",Ce);const Pe=e1({zoomPanValues:y,panOnDrag:A,onPaneContextMenu:!!U,onPanZoom:c,onTransformChange:K});w.on("zoom",Pe);const Ie=t1({zoomPanValues:y,panOnDrag:A,panOnScroll:b,onPaneContextMenu:U,onPanZoomEnd:h,onDraggingChange:p});w.on("end",Ie);const Re=n1({panActivationKeyPressed:ae,zoomActivationKeyPressed:fe,panOnDrag:A,zoomOnScroll:ne,panOnScroll:b,zoomOnDoubleClick:re,zoomOnPinch:z,userSelectionActive:H,noPanClassName:N,noWheelClassName:J,lib:ce,connectionInProgress:se});w.filter(Re),re?S.on("dblclick.zoom",C):S.on("dblclick.zoom",null)}function _(){w.on("zoom",null)}async function I(J,N,U){const H=Ea(J),b=w==null?void 0:w.constrain()(H,N,U);return b&&await E(b),b}async function F(J,N){const U=Ea(J);return await E(U,N),U}function $(J){if(S){const N=Ea(J),U=S.property("__zoom");(U.k!==J.zoom||U.x!==J.x||U.y!==J.y)&&(w==null||w.transform(S,N,null,{sync:!0}))}}function B(){const J=S?Ip(S.node()):{x:0,y:0,k:1};return{x:J.x,y:J.y,zoom:J.k}}async function X(J,N){return S?new Promise(U=>{w==null||w.interpolate((N==null?void 0:N.interpolate)==="linear"?ni:Qs).scaleTo(ka(S,N==null?void 0:N.duration,N==null?void 0:N.ease,()=>U(!0)),J)}):!1}async function G(J,N){return S?new Promise(U=>{w==null||w.interpolate((N==null?void 0:N.interpolate)==="linear"?ni:Qs).scaleBy(ka(S,N==null?void 0:N.duration,N==null?void 0:N.ease,()=>U(!0)),J)}):!1}function te(J){w==null||w.scaleExtent(J)}function Z(J){w==null||w.translateExtent(J)}function ee(J){const N=!Kt(J)||J<0?0:J;w==null||w.clickDistance(N)}return{update:j,destroy:_,setViewport:F,setViewportConstrained:I,getViewport:B,scaleTo:X,scaleBy:G,setScaleExtent:te,setTranslateExtent:Z,syncViewport:$,setClickDistance:ee}}var so;(function(t){t.Line="line",t.Handle="handle"})(so||(so={}));function o1({width:t,prevWidth:r,height:i,prevHeight:l,affectsX:u,affectsY:c}){const f=t-r,h=i-l,p=[f>0?1:f<0?-1:0,h>0?1:h<0?-1:0];return f&&u&&(p[0]=p[0]*-1),h&&c&&(p[1]=p[1]*-1),p}function wh(t){const r=t.includes("right")||t.includes("left"),i=t.includes("bottom")||t.includes("top"),l=t.includes("left"),u=t.includes("top");return{isHorizontal:r,isVertical:i,affectsX:l,affectsY:u}}function bn(t,r){return Math.max(0,r-t)}function Un(t,r){return Math.max(0,t-r)}function Us(t,r,i){return Math.max(0,r-t,t-i)}function Sh(t,r){return t?!r:r}function i1(t,r,i,l,u,c,f,h){let{affectsX:p,affectsY:y}=r;const{isHorizontal:g,isVertical:v}=r,m=g&&v,{xSnapped:w,ySnapped:S}=i,{minWidth:P,maxWidth:C,minHeight:E,maxHeight:j}=l,{x:_,y:I,width:F,height:$,aspectRatio:B}=t;let X=Math.floor(g?w-t.pointerX:0),G=Math.floor(v?S-t.pointerY:0);const te=F+(p?-X:X),Z=$+(y?-G:G),ee=-c[0]*F,J=-c[1]*$;let N=Us(te,P,C),U=Us(Z,E,j);if(f){let A=0,L=0;p&&X<0?A=bn(_+X+ee,f[0][0]):!p&&X>0&&(A=Un(_+te+ee,f[1][0])),y&&G<0?L=bn(I+G+J,f[0][1]):!y&&G>0&&(L=Un(I+Z+J,f[1][1])),N=Math.max(N,A),U=Math.max(U,L)}if(h){let A=0,L=0;p&&X>0?A=Un(_+X,h[0][0]):!p&&X<0&&(A=bn(_+te,h[1][0])),y&&G>0?L=Un(I+G,h[0][1]):!y&&G<0&&(L=bn(I+Z,h[1][1])),N=Math.max(N,A),U=Math.max(U,L)}if(u){if(g){const A=Us(te/B,E,j)*B;if(N=Math.max(N,A),f){let L=0;!p&&!y||p&&!y&&m?L=Un(I+J+te/B,f[1][1])*B:L=bn(I+J+(p?X:-X)/B,f[0][1])*B,N=Math.max(N,L)}if(h){let L=0;!p&&!y||p&&!y&&m?L=bn(I+te/B,h[1][1])*B:L=Un(I+(p?X:-X)/B,h[0][1])*B,N=Math.max(N,L)}}if(v){const A=Us(Z*B,P,C)/B;if(U=Math.max(U,A),f){let L=0;!p&&!y||y&&!p&&m?L=Un(_+Z*B+ee,f[1][0])/B:L=bn(_+(y?G:-G)*B+ee,f[0][0])/B,U=Math.max(U,L)}if(h){let L=0;!p&&!y||y&&!p&&m?L=bn(_+Z*B,h[1][0])/B:L=Un(_+(y?G:-G)*B,h[0][0])/B,U=Math.max(U,L)}}}G=G+(G<0?U:-U),X=X+(X<0?N:-N),u&&(m?te>Z*B?G=(Sh(p,y)?-X:X)/B:X=(Sh(p,y)?-G:G)*B:g?(G=X/B,y=p):(X=G*B,p=y));const H=p?_+X:_,b=y?I+G:I;return{width:F+(p?-X:X),height:$+(y?-G:G),x:c[0]*X*(p?-1:1)+H,y:c[1]*G*(y?-1:1)+b}}const sg={width:0,height:0,x:0,y:0},s1={...sg,pointerX:0,pointerY:0,aspectRatio:1};function l1(t,r,i){const l=r.position.x+t.position.x,u=r.position.y+t.position.y,c=t.measured.width??0,f=t.measured.height??0,h=i[0]*c,p=i[1]*f;return[[l-h,u-p],[l+c-h,u+f-p]]}function u1({domNode:t,nodeId:r,getStoreItems:i,onChange:l,onEnd:u}){const c=Rt(t);let f={controlDirection:wh("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:g,keepAspectRatio:v,resizeDirection:m,onResizeStart:w,onResize:S,onResizeEnd:P,shouldResize:C}){let E={...sg},j={...s1};f={boundaries:g,resizeDirection:m,keepAspectRatio:v,controlDirection:wh(y)};let _,I=null,F=[],$,B,X,G=!1;const te=gp().on("start",Z=>{const{nodeLookup:ee,transform:J,snapGrid:N,snapToGrid:U,nodeOrigin:H,paneDomNode:b}=i();if(_=ee.get(r),!_)return;I=(b==null?void 0:b.getBoundingClientRect())??null;const{xSnapped:A,ySnapped:L}=ri(Z.sourceEvent,{transform:J,snapGrid:N,snapToGrid:U,containerBounds:I});E={width:_.measured.width??0,height:_.measured.height??0,x:_.position.x??0,y:_.position.y??0},j={...E,pointerX:A,pointerY:L,aspectRatio:E.width/E.height},$=void 0,B=xr(_.extent)?_.extent:void 0,_.parentId&&(_.extent==="parent"||_.expandParent)&&($=ee.get(_.parentId)),$&&_.extent==="parent"&&(B=[[0,0],[$.measured.width,$.measured.height]]),F=[],X=void 0;for(const[O,M]of ee)if(M.parentId===r&&(F.push({id:O,position:{...M.position},extent:M.extent}),M.extent==="parent"||M.expandParent)){const z=l1(M,_,M.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}w==null||w(Z,{...E})}).on("drag",Z=>{const{transform:ee,snapGrid:J,snapToGrid:N,nodeOrigin:U}=i(),H=ri(Z.sourceEvent,{transform:ee,snapGrid:J,snapToGrid:N,containerBounds:I}),b=[];if(!_)return;const{x:A,y:L,width:O,height:M}=E,z={},ne=_.origin??U,{width:re,height:ae,x:fe,y:ce}=i1(j,f.controlDirection,H,f.boundaries,f.keepAspectRatio,ne,B,X),K=re!==O,se=ae!==M,pe=fe!==A&&K,we=ce!==L&&se;if(!pe&&!we&&!K&&!se)return;if((pe||we||ne[0]===1||ne[1]===1)&&(z.x=pe?fe:E.x,z.y=we?ce:E.y,E.x=z.x,E.y=z.y,F.length>0)){const Pe=fe-A,Ie=ce-L;for(const Re of F)Re.position={x:Re.position.x-Pe+ne[0]*(re-O),y:Re.position.y-Ie+ne[1]*(ae-M)},b.push(Re)}if((K||se)&&(z.width=K&&(!f.resizeDirection||f.resizeDirection==="horizontal")?re:E.width,z.height=se&&(!f.resizeDirection||f.resizeDirection==="vertical")?ae:E.height,E.width=z.width,E.height=z.height),$&&_.expandParent){const Pe=ne[0]*(z.width??0);z.x&&z.x{G&&(P==null||P(Z,{...E}),u==null||u({...E}),G=!1)});c.call(te)}function p(){c.on(".drag",null)}return{update:h,destroy:p}}var Na={exports:{}},Ca={},Ma={exports:{}},Pa={};/** - * @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 _h;function a1(){if(_h)return Pa;_h=1;var t=hi();function r(v,m){return v===m&&(v!==0||1/v===1/m)||v!==v&&m!==m}var i=typeof Object.is=="function"?Object.is:r,l=t.useState,u=t.useEffect,c=t.useLayoutEffect,f=t.useDebugValue;function h(v,m){var w=m(),S=l({inst:{value:w,getSnapshot:m}}),P=S[0].inst,C=S[1];return c(function(){P.value=w,P.getSnapshot=m,p(P)&&C({inst:P})},[v,w,m]),u(function(){return p(P)&&C({inst:P}),v(function(){p(P)&&C({inst:P})})},[v]),f(w),w}function p(v){var m=v.getSnapshot;v=v.value;try{var w=m();return!i(v,w)}catch{return!0}}function y(v,m){return m()}var g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:h;return Pa.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:g,Pa}var Eh;function c1(){return Eh||(Eh=1,Ma.exports=a1()),Ma.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 kh;function f1(){if(kh)return Ca;kh=1;var t=hi(),r=c1();function i(y,g){return y===g&&(y!==0||1/y===1/g)||y!==y&&g!==g}var l=typeof Object.is=="function"?Object.is:i,u=r.useSyncExternalStore,c=t.useRef,f=t.useEffect,h=t.useMemo,p=t.useDebugValue;return Ca.useSyncExternalStoreWithSelector=function(y,g,v,m,w){var S=c(null);if(S.current===null){var P={hasValue:!1,value:null};S.current=P}else P=S.current;S=h(function(){function E($){if(!j){if(j=!0,_=$,$=m($),w!==void 0&&P.hasValue){var B=P.value;if(w(B,$))return I=B}return I=$}if(B=I,l(_,$))return B;var X=m($);return w!==void 0&&w(B,X)?(_=$,B):(_=$,I=X)}var j=!1,_,I,F=v===void 0?null:v;return[function(){return E(g())},F===null?void 0:function(){return E(F())}]},[g,v,m,w]);var C=u(y,S[0],S[1]);return f(function(){P.hasValue=!0,P.value=C},[C]),p(C),C},Ca}var Nh;function d1(){return Nh||(Nh=1,Na.exports=f1()),Na.exports}var h1=d1();const p1=Jh(h1),g1={},Ch=t=>{let r;const i=new Set,l=(g,v)=>{const m=typeof g=="function"?g(r):g;if(!Object.is(m,r)){const w=r;r=v??(typeof m!="object"||m===null)?m:Object.assign({},r,m),i.forEach(S=>S(r,w))}},u=()=>r,p={setState:l,getState:u,getInitialState:()=>y,subscribe:g=>(i.add(g),()=>i.delete(g)),destroy:()=>{(g1?"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."),i.clear()}},y=r=t(l,u,p);return p},m1=t=>t?Ch(t):Ch,{useDebugValue:y1}=M0,{useSyncExternalStoreWithSelector:v1}=p1,x1=t=>t;function lg(t,r=x1,i){const l=v1(t.subscribe,t.getState,t.getServerState||t.getInitialState,r,i);return y1(l),l}const Mh=(t,r)=>{const i=m1(t),l=(u,c=r)=>lg(i,u,c);return Object.assign(l,i),l},w1=(t,r)=>t?Mh(t,r):Mh;function be(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[l,u]of t)if(!Object.is(u,r.get(l)))return!1;return!0}if(t instanceof Set&&r instanceof Set){if(t.size!==r.size)return!1;for(const l of t)if(!r.has(l))return!1;return!0}const i=Object.keys(t);if(i.length!==Object.keys(r).length)return!1;for(const l of i)if(!Object.prototype.hasOwnProperty.call(r,l)||!Object.is(t[l],r[l]))return!1;return!0}ep();const vl=Q.createContext(null),S1=vl.Provider,ug=Zt.error001("react");function ze(t,r){const i=Q.useContext(vl);if(i===null)throw new Error(ug);return lg(i,t,r)}function Oe(){const t=Q.useContext(vl);if(t===null)throw new Error(ug);return Q.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const Ph={display:"none"},_1={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",cg="react-flow__edge-desc",E1="react-flow__aria-live",k1=t=>t.ariaLiveMessage,N1=t=>t.ariaLabelConfig;function C1({rfId:t}){const r=ze(k1);return k.jsx("div",{id:`${E1}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:_1,children:r})}function M1({rfId:t,disableKeyboardA11y:r}){const i=ze(N1);return k.jsxs(k.Fragment,{children:[k.jsx("div",{id:`${ag}-${t}`,style:Ph,children:r?i["node.a11yDescription.default"]:i["node.a11yDescription.keyboardDisabled"]}),k.jsx("div",{id:`${cg}-${t}`,style:Ph,children:i["edge.a11yDescription.default"]}),!r&&k.jsx(C1,{rfId:t})]})}const xl=Q.forwardRef(({position:t="top-left",children:r,className:i,style:l,...u},c)=>{const f=`${t}`.split("-");return k.jsx("div",{className:Xe(["react-flow__panel",i,...f]),style:l,ref:c,...u,children:r})});xl.displayName="Panel";const Ih="https://reactflow.dev?utm_source=attribution";function P1({proOptions:t,position:r="bottom-right"}){return t!=null&&t.hideAttribution?null:k.jsx(xl,{position:r,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Ih}`,children:k.jsx("a",{href:Ih,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const I1=t=>{const r=[],i=[];for(const[,l]of t.nodeLookup)l.selected&&r.push(l.internals.userNode);for(const[,l]of t.edgeLookup)l.selected&&i.push(l);return{selectedNodes:r,selectedEdges:i}},Ws=t=>t.id;function T1(t,r){return be(t.selectedNodes.map(Ws),r.selectedNodes.map(Ws))&&be(t.selectedEdges.map(Ws),r.selectedEdges.map(Ws))}function z1({onSelectionChange:t}){const r=Oe(),{selectedNodes:i,selectedEdges:l}=ze(I1,T1);return Q.useEffect(()=>{const u={nodes:i,edges:l};t==null||t(u),r.getState().onSelectionChangeHandlers.forEach(c=>c(u))},[i,l,t]),null}const j1=t=>!!t.onSelectionChangeHandlers;function R1({onSelectionChange:t}){const r=ze(j1);return t||r?k.jsx(z1,{onSelectionChange:t}):null}const fg=[0,0],L1={x:0,y:0,zoom:1},A1=["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"],Th=[...A1,"rfId"],$1=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}),zh={translateExtent:ui,nodeOrigin:fg,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function D1(t){const{setNodes:r,setEdges:i,setMinZoom:l,setMaxZoom:u,setTranslateExtent:c,setNodeExtent:f,reset:h,setDefaultNodesAndEdges:p}=ze($1,be),y=Oe();Q.useEffect(()=>(p(t.defaultNodes,t.defaultEdges),()=>{g.current=zh,h()}),[]);const g=Q.useRef(zh);return Q.useEffect(()=>{for(const v of Th){const m=t[v],w=g.current[v];m!==w&&(typeof t[v]>"u"||(v==="nodes"?r(m):v==="edges"?i(m):v==="minZoom"?l(m):v==="maxZoom"?u(m):v==="translateExtent"?c(m):v==="nodeExtent"?f(m):v==="ariaLabelConfig"?y.setState({ariaLabelConfig:Sw(m)}):v==="fitView"?y.setState({fitViewQueued:m}):v==="fitViewOptions"?y.setState({fitViewOptions:m}):y.setState({[v]:m})))}g.current=t},Th.map(v=>t[v])),null}function jh(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function O1(t){var l;const[r,i]=Q.useState(t==="system"?null:t);return Q.useEffect(()=>{if(t!=="system"){i(t);return}const u=jh(),c=()=>i(u!=null&&u.matches?"dark":"light");return c(),u==null||u.addEventListener("change",c),()=>{u==null||u.removeEventListener("change",c)}},[t]),r!==null?r:(l=jh())!=null&&l.matches?"dark":"light"}const Rh=typeof document<"u"?document:null;function di(t=null,r={target:Rh,actInsideInputWithModifier:!0}){const[i,l]=Q.useState(!1),u=Q.useRef(!1),c=Q.useRef(new Set([])),[f,h]=Q.useMemo(()=>{if(t!==null){const y=(Array.isArray(t)?t:[t]).filter(v=>typeof v=="string").map(v=>v.replace(/\+/g,` -`).replace(` - -`,` -+`).split(` -`)),g=y.reduce((v,m)=>v.concat(...m),[]);return[y,g]}return[[],[]]},[t]);return Q.useEffect(()=>{const p=(r==null?void 0:r.target)??Rh,y=(r==null?void 0:r.actInsideInputWithModifier)??!0;if(t!==null){const g=w=>{var C,E;if(u.current=w.ctrlKey||w.metaKey||w.shiftKey||w.altKey,(!u.current||u.current&&!y)&&Up(w))return!1;const P=Ah(w.code,h);if(c.current.add(w[P]),Lh(f,c.current,!1)){const j=((E=(C=w.composedPath)==null?void 0:C.call(w))==null?void 0:E[0])||w.target,_=(j==null?void 0:j.nodeName)==="BUTTON"||(j==null?void 0:j.nodeName)==="A";r.preventDefault!==!1&&(u.current||!_)&&w.preventDefault(),l(!0)}},v=w=>{const S=Ah(w.code,h);Lh(f,c.current,!0)?(l(!1),c.current.clear()):c.current.delete(w[S]),w.key==="Meta"&&c.current.clear(),u.current=!1},m=()=>{c.current.clear(),l(!1)};return p==null||p.addEventListener("keydown",g),p==null||p.addEventListener("keyup",v),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{p==null||p.removeEventListener("keydown",g),p==null||p.removeEventListener("keyup",v),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,l]),i}function Lh(t,r,i){return t.filter(l=>i||l.length===r.size).some(l=>l.every(u=>r.has(u)))}function Ah(t,r){return r.includes(t)?"code":"key"}const F1=()=>{const t=Oe();return Q.useMemo(()=>({zoomIn:async r=>{const{panZoom:i}=t.getState();return i?i.scaleBy(1.2,r):!1},zoomOut:async r=>{const{panZoom:i}=t.getState();return i?i.scaleBy(1/1.2,r):!1},zoomTo:async(r,i)=>{const{panZoom:l}=t.getState();return l?l.scaleTo(r,i):!1},getZoom:()=>t.getState().transform[2],setViewport:async(r,i)=>{const{transform:[l,u,c],panZoom:f}=t.getState();return f?(await f.setViewport({x:r.x??l,y:r.y??u,zoom:r.zoom??c},i),!0):!1},getViewport:()=>{const[r,i,l]=t.getState().transform;return{x:r,y:i,zoom:l}},setCenter:async(r,i,l)=>t.getState().setCenter(r,i,l),fitBounds:async(r,i)=>{const{width:l,height:u,minZoom:c,maxZoom:f,panZoom:h}=t.getState(),p=rc(r,l,u,c,f,(i==null?void 0:i.padding)??.1);return h?(await h.setViewport(p,{duration:i==null?void 0:i.duration,ease:i==null?void 0:i.ease,interpolate:i==null?void 0:i.interpolate}),!0):!1},screenToFlowPosition:(r,i={})=>{const{transform:l,snapGrid:u,snapToGrid:c,domNode:f}=t.getState();if(!f)return r;const{x:h,y:p}=f.getBoundingClientRect(),y={x:r.x-h,y:r.y-p},g=i.snapGrid??u,v=i.snapToGrid??c;return xi(y,l,v,g)},flowToScreenPosition:r=>{const{transform:i,domNode:l}=t.getState();if(!l)return r;const{x:u,y:c}=l.getBoundingClientRect(),f=io(r,i);return{x:f.x+u,y:f.y+c}}}),[])};function dg(t,r){const i=[],l=new Map,u=[];for(const c of t)if(c.type==="add"){u.push(c);continue}else if(c.type==="remove"||c.type==="replace")l.set(c.id,[c]);else{const f=l.get(c.id);f?f.push(c):l.set(c.id,[c])}for(const c of r){const f=l.get(c.id);if(!f){i.push(c);continue}if(f[0].type==="remove")continue;if(f[0].type==="replace"){i.push({...f[0].item});continue}const h={...c};for(const p of f)H1(p,h);i.push(h)}return u.length&&u.forEach(c=>{c.index!==void 0?i.splice(c.index,0,{...c.item}):i.push({...c.item})}),i}function H1(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 V1(t,r){return dg(t,r)}function B1(t,r){return dg(t,r)}function dr(t,r){return{id:t,type:"select",selected:r}}function Zr(t,r=new Set,i=!1){const l=[];for(const[u,c]of t){const f=r.has(u);!(c.selected===void 0&&!f)&&c.selected!==f&&(i&&(c.selected=f),l.push(dr(c.id,f)))}return l}function $h({items:t=[],lookup:r}){var u;const i=[],l=new Map(t.map(c=>[c.id,c]));for(const[c,f]of t.entries()){const h=r.get(f.id),p=((u=h==null?void 0:h.internals)==null?void 0:u.userNode)??h;p!==void 0&&p!==f&&i.push({id:f.id,item:f,type:"replace"}),p===void 0&&i.push({item:f,type:"add",index:c})}for(const[c]of r)l.get(c)===void 0&&i.push({id:c,type:"remove"});return i}function Dh(t){return{id:t.id,type:"remove"}}const b1=Hp();function U1(t,r,i={}){return Mw(t,r,{...i,onError:i.onError??b1})}const Oh=t=>dw(t),W1=t=>Ap(t);function hg(t){return Q.forwardRef(t)}const pg=typeof window<"u"?Q.useLayoutEffect:Q.useEffect;function Fh(t){const[r,i]=Q.useState(BigInt(0)),[l]=Q.useState(()=>Y1(()=>i(u=>u+BigInt(1))));return pg(()=>{const u=l.get();u.length&&(t(u),l.reset())},[r]),l}function Y1(t){let r=[];return{get:()=>r,reset:()=>{r=[]},push:i=>{r.push(i),t()}}}const gg=Q.createContext(null);function X1({children:t}){const r=Oe(),i=Q.useCallback(h=>{const{nodes:p=[],setNodes:y,hasDefaultNodes:g,onNodesChange:v,nodeLookup:m,fitViewQueued:w,onNodesChangeMiddlewareMap:S}=r.getState();let P=p;for(const E of h)P=typeof E=="function"?E(P):E;let C=$h({items:P,lookup:m});for(const E of S.values())C=E(C);g&&y(P),C.length>0?v==null||v(C):w&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:j,setNodes:_}=r.getState();E&&_(j)})},[]),l=Fh(i),u=Q.useCallback(h=>{const{edges:p=[],setEdges:y,hasDefaultEdges:g,onEdgesChange:v,edgeLookup:m}=r.getState();let w=p;for(const S of h)w=typeof S=="function"?S(w):S;g?y(w):v&&v($h({items:w,lookup:m}))},[]),c=Fh(u),f=Q.useMemo(()=>({nodeQueue:l,edgeQueue:c}),[]);return k.jsx(gg.Provider,{value:f,children:t})}function Q1(){const t=Q.useContext(gg);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const G1=t=>!!t.panZoom;function cc(){const t=F1(),r=Oe(),i=Q1(),l=ze(G1),u=Q.useMemo(()=>{const c=v=>r.getState().nodeLookup.get(v),f=v=>{i.nodeQueue.push(v)},h=v=>{i.edgeQueue.push(v)},p=v=>{var E,j;const{nodeLookup:m,nodeOrigin:w}=r.getState(),S=Oh(v)?v:m.get(v.id),P=S.parentId?Bp(S.position,S.measured,S.parentId,m,w):S.position,C={...S,position:P,width:((E=S.measured)==null?void 0:E.width)??S.width,height:((j=S.measured)==null?void 0:j.height)??S.height};return ci(C)},y=(v,m,w={replace:!1})=>{f(S=>S.map(P=>{if(P.id===v){const C=typeof m=="function"?m(P):m;return w.replace&&Oh(C)?C:{...P,...C}}return P}))},g=(v,m,w={replace:!1})=>{h(S=>S.map(P=>{if(P.id===v){const C=typeof m=="function"?m(P):m;return w.replace&&W1(C)?C:{...P,...C}}return P}))};return{getNodes:()=>r.getState().nodes.map(v=>({...v})),getNode:v=>{var m;return(m=c(v))==null?void 0:m.internals.userNode},getInternalNode:c,getEdges:()=>{const{edges:v=[]}=r.getState();return v.map(m=>({...m}))},getEdge:v=>r.getState().edgeLookup.get(v),setNodes:f,setEdges:h,addNodes:v=>{const m=Array.isArray(v)?v:[v];i.nodeQueue.push(w=>[...w,...m])},addEdges:v=>{const m=Array.isArray(v)?v:[v];i.edgeQueue.push(w=>[...w,...m])},toObject:()=>{const{nodes:v=[],edges:m=[],transform:w}=r.getState(),[S,P,C]=w;return{nodes:v.map(E=>({...E})),edges:m.map(E=>({...E})),viewport:{x:S,y:P,zoom:C}}},deleteElements:async({nodes:v=[],edges:m=[]})=>{const{nodes:w,edges:S,onNodesDelete:P,onEdgesDelete:C,triggerNodeChanges:E,triggerEdgeChanges:j,onDelete:_,onBeforeDelete:I}=r.getState(),{nodes:F,edges:$}=await yw({nodesToRemove:v,edgesToRemove:m,nodes:w,edges:S,onBeforeDelete:I}),B=$.length>0,X=F.length>0;if(B){const G=$.map(Dh);C==null||C($),j(G)}if(X){const G=F.map(Dh);P==null||P(F),E(G)}return(X||B)&&(_==null||_({nodes:F,edges:$})),{deletedNodes:F,deletedEdges:$}},getIntersectingNodes:(v,m=!0,w)=>{const S=ah(v),P=S?v:p(v),C=w!==void 0;return P?(w||r.getState().nodes).filter(E=>{const j=r.getState().nodeLookup.get(E.id);if(j&&!S&&(E.id===v.id||!j.internals.positionAbsolute))return!1;const _=ci(C?E:j),I=ll(_,P);return m&&I>0||I>=_.width*_.height||I>=P.width*P.height}):[]},isNodeIntersecting:(v,m,w=!0)=>{const P=ah(v)?v:p(v);if(!P)return!1;const C=ll(P,m);return w&&C>0||C>=m.width*m.height||C>=P.width*P.height},updateNode:y,updateNodeData:(v,m,w={replace:!1})=>{y(v,S=>{const P=typeof m=="function"?m(S):m;return w.replace?{...S,data:P}:{...S,data:{...S.data,...P}}},w)},updateEdge:g,updateEdgeData:(v,m,w={replace:!1})=>{g(v,S=>{const P=typeof m=="function"?m(S):m;return w.replace?{...S,data:P}:{...S,data:{...S.data,...P}}},w)},getNodesBounds:v=>{const{nodeLookup:m,nodeOrigin:w}=r.getState();return hw(v,{nodeLookup:m,nodeOrigin:w})},getHandleConnections:({type:v,id:m,nodeId:w})=>{var S;return Array.from(((S=r.getState().connectionLookup.get(`${w}-${v}${m?`-${m}`:""}`))==null?void 0:S.values())??[])},getNodeConnections:({type:v,handleId:m,nodeId:w})=>{var S;return Array.from(((S=r.getState().connectionLookup.get(`${w}${v?m?`-${v}-${m}`:`-${v}`:""}`))==null?void 0:S.values())??[])},fitView:async v=>{const m=r.getState().fitViewResolver??ww();return r.setState({fitViewQueued:!0,fitViewOptions:v,fitViewResolver:m}),i.nodeQueue.push(w=>[...w]),m.promise}}},[]);return Q.useMemo(()=>({...u,...t,viewportInitialized:l}),[l])}const Hh=t=>t.selected,K1=typeof window<"u"?window:void 0;function q1({deleteKeyCode:t,multiSelectionKeyCode:r}){const i=Oe(),{deleteElements:l}=cc(),u=di(t,{actInsideInputWithModifier:!1}),c=di(r,{target:K1});Q.useEffect(()=>{if(u){const{edges:f,nodes:h}=i.getState();l({nodes:h.filter(Hh),edges:f.filter(Hh)}),i.setState({nodesSelectionActive:!1})}},[u]),Q.useEffect(()=>{i.setState({multiSelectionActive:c})},[c])}function Z1(t){const r=Oe();Q.useEffect(()=>{const i=()=>{var u,c,f,h;if(!t.current||!(((c=(u=t.current).checkVisibility)==null?void 0:c.call(u))??!0))return!1;const l=oc(t.current);(l.height===0||l.width===0)&&((h=(f=r.getState()).onError)==null||h.call(f,"004",Zt.error004())),r.setState({width:l.width||500,height:l.height||500})};if(t.current){i(),window.addEventListener("resize",i);const l=new ResizeObserver(()=>i());return l.observe(t.current),()=>{window.removeEventListener("resize",i),l&&t.current&&l.unobserve(t.current)}}},[])}const wl={position:"absolute",width:"100%",height:"100%",top:0,left:0},J1=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function eS({onPaneContextMenu:t,zoomOnScroll:r=!0,zoomOnPinch:i=!0,panOnScroll:l=!1,panActivationKeyPressed:u,panOnScrollSpeed:c=.5,panOnScrollMode:f=gr.Free,zoomOnDoubleClick:h=!0,panOnDrag:p=!0,defaultViewport:y,translateExtent:g,minZoom:v,maxZoom:m,zoomActivationKeyCode:w,preventScrolling:S=!0,children:P,noWheelClassName:C,noPanClassName:E,onViewportChange:j,isControlledViewport:_,paneClickDistance:I,selectionOnDrag:F}){const $=Oe(),B=Q.useRef(null),{userSelectionActive:X,lib:G,connectionInProgress:te}=ze(J1,be),Z=di(w),ee=Q.useRef();Z1(B);const J=Q.useCallback(N=>{j==null||j({x:N[0],y:N[1],zoom:N[2]}),_||$.setState({transform:N})},[j,_]);return Q.useEffect(()=>{if(B.current){ee.current=r1({domNode:B.current,minZoom:v,maxZoom:m,translateExtent:g,viewport:y,onDraggingChange:b=>$.setState(A=>A.paneDragging===b?A:{paneDragging:b}),onPanZoomStart:(b,A)=>{const{onViewportChangeStart:L,onMoveStart:O}=$.getState();O==null||O(b,A),L==null||L(A)},onPanZoom:(b,A)=>{const{onViewportChange:L,onMove:O}=$.getState();O==null||O(b,A),L==null||L(A)},onPanZoomEnd:(b,A)=>{const{onViewportChangeEnd:L,onMoveEnd:O}=$.getState();O==null||O(b,A),L==null||L(A)}});const{x:N,y:U,zoom:H}=ee.current.getViewport();return $.setState({panZoom:ee.current,transform:[N,U,H],domNode:B.current.closest(".react-flow")}),()=>{var b;(b=ee.current)==null||b.destroy()}}},[]),Q.useEffect(()=>{var N;(N=ee.current)==null||N.update({onPaneContextMenu:t,zoomOnScroll:r,zoomOnPinch:i,panOnScroll:l,panActivationKeyPressed:u,panOnScrollSpeed:c,panOnScrollMode:f,zoomOnDoubleClick:h,panOnDrag:p,zoomActivationKeyPressed:Z,preventScrolling:S,noPanClassName:E,userSelectionActive:X,noWheelClassName:C,lib:G,onTransformChange:J,connectionInProgress:te,selectionOnDrag:F,paneClickDistance:I})},[t,r,i,l,u,c,f,h,p,Z,S,E,X,C,G,J,te,F,I]),k.jsx("div",{className:"react-flow__renderer",ref:B,style:wl,children:P})}const tS=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function nS(){const{userSelectionActive:t,userSelectionRect:r}=ze(tS,be);return t&&r?k.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 Ia=(t,r)=>i=>{i.target===r.current&&(t==null||t(i))},rS=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function oS({isSelecting:t,selectionKeyPressed:r,selectionMode:i=ai.Full,panOnDrag:l,autoPanOnSelection:u,paneClickDistance:c,selectionOnDrag:f,onSelectionStart:h,onSelectionEnd:p,onPaneClick:y,onPaneContextMenu:g,onPaneScroll:v,onPaneMouseEnter:m,onPaneMouseMove:w,onPaneMouseLeave:S,children:P}){const C=Q.useRef(0),E=Oe(),{userSelectionActive:j,elementsSelectable:_,dragging:I,panBy:F,autoPanSpeed:$}=ze(rS,be),B=_&&(t||j),X=Q.useRef(null),G=Q.useRef(),te=Q.useRef(new Set),Z=Q.useRef(new Set),ee=Q.useRef(!1),J=Q.useRef(!1),N=Q.useRef({x:0,y:0}),U=Q.useRef(!1),H=K=>{if(J.current||ee.current||E.getState().connection.inProgress){J.current=!1,ee.current=!1;return}y==null||y(K),E.getState().resetSelectedElements(),E.setState({nodesSelectionActive:!1})},b=K=>{if(Array.isArray(l)&&(l!=null&&l.includes(2))){K.preventDefault();return}g==null||g(K)},A=v?K=>v(K):void 0,L=K=>{J.current&&(K.stopPropagation(),J.current=!1)},O=K=>{var Re,Ze;if(K.pointerType==="touch"&&l!==!1&&!r)return;const{domNode:se,transform:pe}=E.getState();if(G.current=se==null?void 0:se.getBoundingClientRect(),!G.current)return;const we=K.target===X.current;if(!we&&!!K.target.closest(".nokey")||!t||!(f&&we||r)||K.button!==0||!K.isPrimary)return;(Ze=(Re=K.target)==null?void 0:Re.setPointerCapture)==null||Ze.call(Re,K.pointerId),J.current=!1;const{x:Ce,y:Pe}=qt(K.nativeEvent,G.current),Ie=xi({x:Ce,y:Pe},pe);E.setState({userSelectionRect:{width:0,height:0,startX:Ie.x,startY:Ie.y,x:Ce,y:Pe}}),we||(K.stopPropagation(),K.preventDefault())};function M(K,se){const{userSelectionRect:pe}=E.getState();if(!pe)return;const{transform:we,nodeLookup:ve,edgeLookup:me,connectionLookup:Ce,triggerNodeChanges:Pe,triggerEdgeChanges:Ie,defaultEdgeOptions:Re}=E.getState(),Ze={x:pe.startX,y:pe.startY},{x:nt,y:Qe}=io(Ze,we),Ge={startX:Ze.x,startY:Ze.y,x:Krt.id)),Z.current=new Set;const Nt=(Re==null?void 0:Re.selectable)??!0;for(const rt of te.current){const dt=Ce.get(rt);if(dt)for(const{edgeId:lt}of dt.values()){const ht=me.get(lt);ht&&(ht.selectable??Nt)&&Z.current.add(lt)}}if(!ch(At,te.current)){const rt=Zr(ve,te.current,!0);Pe(rt)}if(!ch(kt,Z.current)){const rt=Zr(me,Z.current);Ie(rt)}E.setState({userSelectionRect:Ge,userSelectionActive:!0,nodesSelectionActive:!1})}function z(){if(!u||!G.current)return;const[K,se]=nc(N.current,G.current,$);F({x:K,y:se}).then(pe=>{if(!J.current||!pe){C.current=requestAnimationFrame(z);return}const{x:we,y:ve}=N.current;M(we,ve),C.current=requestAnimationFrame(z)})}const ne=()=>{cancelAnimationFrame(C.current),C.current=0,U.current=!1};Q.useEffect(()=>()=>ne(),[]);const re=K=>{const{userSelectionRect:se,transform:pe,resetSelectedElements:we}=E.getState();if(!G.current||!se)return;const{x:ve,y:me}=qt(K.nativeEvent,G.current);N.current={x:ve,y:me};const Ce=io({x:se.startX,y:se.startY},pe);if(!J.current){const Pe=r?0:c;if(Math.hypot(ve-Ce.x,me-Ce.y)<=Pe)return;we(),h==null||h(K)}J.current=!0,U.current||(z(),U.current=!0),M(ve,me)},ae=K=>{var se,pe;if(!B){K.target===X.current&&E.getState().connection.inProgress&&(ee.current=!0);return}K.button===0&&((pe=(se=K.target)==null?void 0:se.releasePointerCapture)==null||pe.call(se,K.pointerId),!j&&K.target===X.current&&E.getState().userSelectionRect&&(H==null||H(K)),E.setState({userSelectionActive:!1,userSelectionRect:null}),J.current&&(p==null||p(K),E.setState({nodesSelectionActive:te.current.size>0})),ne())},fe=K=>{var se,pe;(pe=(se=K.target)==null?void 0:se.releasePointerCapture)==null||pe.call(se,K.pointerId),ne()},ce=l===!0||Array.isArray(l)&&l.includes(0);return k.jsxs("div",{className:Xe(["react-flow__pane",{draggable:ce,dragging:I,selection:t}]),onClick:B?void 0:Ia(H,X),onContextMenu:Ia(b,X),onWheel:Ia(A,X),onPointerEnter:B?void 0:m,onPointerMove:B?re:w,onPointerUp:ae,onPointerCancel:B?fe:void 0,onPointerDownCapture:B?O:void 0,onClickCapture:B?L:void 0,onPointerLeave:S,ref:X,style:wl,children:[P,k.jsx(nS,{})]})}function Wa({id:t,store:r,unselect:i=!1,nodeRef:l}){const{addSelectedNodes:u,unselectNodesAndEdges:c,multiSelectionActive:f,nodeLookup:h,onError:p}=r.getState(),y=h.get(t);if(!y){p==null||p("012",Zt.error012(t));return}r.setState({nodesSelectionActive:!1}),y.selected?(i||y.selected&&f)&&(c({nodes:[y],edges:[]}),requestAnimationFrame(()=>{var g;return(g=l==null?void 0:l.current)==null?void 0:g.blur()})):u([t])}function mg({nodeRef:t,disabled:r=!1,noDragClassName:i,handleSelector:l,nodeId:u,isSelectable:c,nodeClickDistance:f}){const h=Oe(),[p,y]=Q.useState(!1),g=Q.useRef();return Q.useEffect(()=>{if(!r)return g.current=bw({getStoreItems:()=>h.getState(),onNodeMouseDown:v=>{Wa({id:v,store:h,nodeRef:t})},onDragStart:()=>{y(!0)},onDragStop:()=>{y(!1)}}),()=>{var v;(v=g.current)==null||v.destroy(),g.current=void 0}},[r,h,t]),Q.useEffect(()=>{r||!t.current||!g.current||g.current.update({noDragClassName:i,handleSelector:l,domNode:t.current,isSelectable:c,nodeId:u,nodeClickDistance:f})},[i,l,r,c,t,u,f]),p}const iS=t=>r=>r.selected&&(r.draggable||t&&typeof r.draggable>"u");function yg(){const t=Oe();return Q.useCallback(i=>{const{nodeExtent:l,snapToGrid:u,snapGrid:c,nodesDraggable:f,onError:h,updateNodePositions:p,nodeLookup:y,nodeOrigin:g}=t.getState(),v=new Map,m=iS(f),w=u?c[0]:5,S=u?c[1]:5,P=i.direction.x*w*i.factor,C=i.direction.y*S*i.factor;for(const[,E]of y){if(!m(E))continue;let j={x:E.internals.positionAbsolute.x+P,y:E.internals.positionAbsolute.y+C};u&&(j=vi(j,c));const{position:_,positionAbsolute:I}=$p({nodeId:E.id,nextPosition:j,nodeLookup:y,nodeExtent:l,nodeOrigin:g,onError:h});E.position=_,E.internals.positionAbsolute=I,v.set(E.id,E)}p(v)},[])}const fc=Q.createContext(null),sS=fc.Provider;fc.Consumer;const vg=()=>Q.useContext(fc),lS=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),xg=Q.createContext(null);function uS({children:t}){const r=ze(lS,be);return k.jsx(xg.Provider,{value:r,children:t})}function aS(){const t=Q.useContext(xg);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const cS={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},fS=(t,r,i)=>l=>{const{connectionClickStartHandle:u,connectionMode:c,connection:f}=l,{fromHandle:h,toHandle:p,isValid:y}=f;if(!h&&!u)return cS;const g=(p==null?void 0:p.nodeId)===t&&(p==null?void 0:p.id)===r&&(p==null?void 0:p.type)===i;return{connectingFrom:(h==null?void 0:h.nodeId)===t&&(h==null?void 0:h.id)===r&&(h==null?void 0:h.type)===i,connectingTo:g,clickConnecting:(u==null?void 0:u.nodeId)===t&&(u==null?void 0:u.id)===r&&(u==null?void 0:u.type)===i,isPossibleEndHandle:c===ro.Strict?(h==null?void 0:h.type)!==i:t!==(h==null?void 0:h.nodeId)||r!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!u,valid:g&&y}};function dS({type:t="source",position:r=Se.Top,isValidConnection:i,isConnectable:l=!0,isConnectableStart:u=!0,isConnectableEnd:c=!0,id:f,onConnect:h,children:p,className:y,onMouseDown:g,onTouchStart:v,...m},w){var U,H;const S=f||null,P=t==="target",C=Oe(),E=vg(),{connectOnClick:j,noPanClassName:_,rfId:I}=aS(),{connectingFrom:F,connectingTo:$,clickConnecting:B,isPossibleEndHandle:X,connectionInProcess:G,clickConnectionInProcess:te,valid:Z}=ze(fS(E,S,t),be);E||(H=(U=C.getState()).onError)==null||H.call(U,"010",Zt.error010());const ee=b=>{const{defaultEdgeOptions:A,onConnect:L,hasDefaultEdges:O}=C.getState(),M={...A,...b};if(O){const{edges:z,setEdges:ne,onError:re}=C.getState();ne(U1(M,z,{onError:re}))}L==null||L(M),h==null||h(M)},J=b=>{if(!E)return;const A=Wp(b.nativeEvent);if(u&&(A&&b.button===0||!A)){const L=C.getState();Ua.onPointerDown(b.nativeEvent,{handleDomNode:b.currentTarget,autoPanOnConnect:L.autoPanOnConnect,connectionMode:L.connectionMode,connectionRadius:L.connectionRadius,domNode:L.domNode,nodeLookup:L.nodeLookup,lib:L.lib,isTarget:P,handleId:S,nodeId:E,flowId:L.rfId,panBy:L.panBy,cancelConnection:L.cancelConnection,onConnectStart:L.onConnectStart,onConnectEnd:(...O)=>{var M,z;return(z=(M=C.getState()).onConnectEnd)==null?void 0:z.call(M,...O)},updateConnection:L.updateConnection,onConnect:ee,isValidConnection:i||((...O)=>{var M,z;return((z=(M=C.getState()).isValidConnection)==null?void 0:z.call(M,...O))??!0}),getTransform:()=>C.getState().transform,getFromHandle:()=>C.getState().connection.fromHandle,autoPanSpeed:L.autoPanSpeed,dragThreshold:L.connectionDragThreshold})}A?g==null||g(b):v==null||v(b)},N=b=>{const{onClickConnectStart:A,onClickConnectEnd:L,connectionClickStartHandle:O,connectionMode:M,isValidConnection:z,lib:ne,rfId:re,nodeLookup:ae,connection:fe}=C.getState();if(!E||!O&&!u)return;if(!O){A==null||A(b.nativeEvent,{nodeId:E,handleId:S,handleType:t}),C.setState({connectionClickStartHandle:{nodeId:E,type:t,id:S}});return}const ce=bp(b.target),K=i||z,{connection:se,isValid:pe}=Ua.isValid(b.nativeEvent,{handle:{nodeId:E,id:S,type:t},connectionMode:M,fromNodeId:O.nodeId,fromHandleId:O.id||null,fromType:O.type,isValidConnection:K,flowId:re,doc:ce,lib:ne,nodeLookup:ae});pe&&se&&ee(se);const we=structuredClone(fe);delete we.inProgress,we.toPosition=we.toHandle?we.toHandle.position:null,L==null||L(b,we),C.setState({connectionClickStartHandle:null})};return k.jsx("div",{"data-handleid":S,"data-nodeid":E,"data-handlepos":r,"data-id":`${I}-${E}-${S}-${t}`,className:Xe(["react-flow__handle",`react-flow__handle-${r}`,"nodrag",_,y,{source:!P,target:P,connectable:l,connectablestart:u,connectableend:c,clickconnecting:B,connectingfrom:F,connectingto:$,valid:Z,connectionindicator:l&&(!G||X)&&(G||te?c:u)}]),onMouseDown:J,onTouchStart:J,onClick:j?N:void 0,ref:w,...m,children:p})}const ul=Q.memo(hg(dS));function hS({data:t,isConnectable:r,sourcePosition:i=Se.Bottom}){return k.jsxs(k.Fragment,{children:[t==null?void 0:t.label,k.jsx(ul,{type:"source",position:i,isConnectable:r})]})}function pS({data:t,isConnectable:r,targetPosition:i=Se.Top,sourcePosition:l=Se.Bottom}){return k.jsxs(k.Fragment,{children:[k.jsx(ul,{type:"target",position:i,isConnectable:r}),t==null?void 0:t.label,k.jsx(ul,{type:"source",position:l,isConnectable:r})]})}function gS(){return null}function mS({data:t,isConnectable:r,targetPosition:i=Se.Top}){return k.jsxs(k.Fragment,{children:[k.jsx(ul,{type:"target",position:i,isConnectable:r}),t==null?void 0:t.label]})}const al={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Vh={input:hS,default:pS,output:mS,group:gS};function yS(t){var r,i,l,u;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((r=t.style)==null?void 0:r.width),height:t.height??t.initialHeight??((i=t.style)==null?void 0:i.height)}:{width:t.width??((l=t.style)==null?void 0:l.width),height:t.height??((u=t.style)==null?void 0:u.height)}}const vS=t=>{const{width:r,height:i,x:l,y:u}=yi(t.nodeLookup,{filter:c=>!!c.selected});return{width:Kt(r)?r:null,height:Kt(i)?i:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${l}px,${u}px)`}};function xS({onSelectionContextMenu:t,noPanClassName:r,disableKeyboardA11y:i}){const l=Oe(),{width:u,height:c,transformString:f,userSelectionActive:h}=ze(vS,be),p=yg(),y=Q.useRef(null);Q.useEffect(()=>{var w;i||(w=y.current)==null||w.focus({preventScroll:!0})},[i]);const g=!h&&u!==null&&c!==null;if(mg({nodeRef:y,disabled:!g}),!g)return null;const v=t?w=>{const S=l.getState().nodes.filter(P=>P.selected);t(w,S)}:void 0,m=w=>{Object.prototype.hasOwnProperty.call(al,w.key)&&(w.preventDefault(),p({direction:al[w.key],factor:w.shiftKey?4:1}))};return k.jsx("div",{className:Xe(["react-flow__nodesselection","react-flow__container",r]),style:{transform:f},children:k.jsx("div",{ref:y,className:"react-flow__nodesselection-rect",onContextMenu:v,tabIndex:i?void 0:-1,onKeyDown:i?void 0:m,style:{width:u,height:c}})})}const Bh=typeof window<"u"?window:void 0,wS=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function wg({children:t,onPaneClick:r,onPaneMouseEnter:i,onPaneMouseMove:l,onPaneMouseLeave:u,onPaneContextMenu:c,onPaneScroll:f,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:y,selectionOnDrag:g,selectionMode:v,onSelectionStart:m,onSelectionEnd:w,multiSelectionKeyCode:S,panActivationKeyCode:P,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:j,zoomOnPinch:_,panOnScroll:I,panOnScrollSpeed:F,panOnScrollMode:$,zoomOnDoubleClick:B,panOnDrag:X,autoPanOnSelection:G,defaultViewport:te,translateExtent:Z,minZoom:ee,maxZoom:J,preventScrolling:N,onSelectionContextMenu:U,noWheelClassName:H,noPanClassName:b,disableKeyboardA11y:A,onViewportChange:L,isControlledViewport:O}){const{nodesSelectionActive:M,userSelectionActive:z}=ze(wS,be),ne=di(y,{target:Bh}),re=di(P,{target:Bh}),ae=re||X,fe=re||I,ce=g&&ae!==!0,K=ne||z||ce;return q1({deleteKeyCode:p,multiSelectionKeyCode:S}),k.jsx(eS,{onPaneContextMenu:c,elementsSelectable:E,zoomOnScroll:j,zoomOnPinch:_,panOnScroll:fe,panActivationKeyPressed:re,panOnScrollSpeed:F,panOnScrollMode:$,zoomOnDoubleClick:B,panOnDrag:!ne&&ae,defaultViewport:te,translateExtent:Z,minZoom:ee,maxZoom:J,zoomActivationKeyCode:C,preventScrolling:N,noWheelClassName:H,noPanClassName:b,onViewportChange:L,isControlledViewport:O,paneClickDistance:h,selectionOnDrag:ce,children:k.jsxs(oS,{onSelectionStart:m,onSelectionEnd:w,onPaneClick:r,onPaneMouseEnter:i,onPaneMouseMove:l,onPaneMouseLeave:u,onPaneContextMenu:c,onPaneScroll:f,panOnDrag:ae,autoPanOnSelection:G,isSelecting:!!K,selectionMode:v,selectionKeyPressed:ne,paneClickDistance:h,selectionOnDrag:ce,children:[t,M&&k.jsx(xS,{onSelectionContextMenu:U,noPanClassName:b,disableKeyboardA11y:A})]})})}wg.displayName="FlowRenderer";const SS=Q.memo(wg),_S=t=>r=>t?tc(r.nodeLookup,{x:0,y:0,width:r.width,height:r.height},r.transform,!0).map(i=>i.id):Array.from(r.nodeLookup.keys());function ES(t){return ze(Q.useCallback(_S(t),[t]),be)}const kS=t=>t.updateNodeInternals;function NS(){const t=ze(kS),[r]=Q.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(i=>{const l=new Map;i.forEach(u=>{const c=u.target.getAttribute("data-id");l.set(c,{id:c,nodeElement:u.target,force:!0})}),t(l)}));return Q.useEffect(()=>()=>{r==null||r.disconnect()},[r]),r}function CS({node:t,nodeType:r,hasDimensions:i,resizeObserver:l}){const u=Oe(),c=Q.useRef(null),f=Q.useRef(null),h=Q.useRef(t.sourcePosition),p=Q.useRef(t.targetPosition),y=Q.useRef(r),g=i&&!!t.internals.handleBounds;return Q.useEffect(()=>{c.current&&!t.hidden&&(!g||f.current!==c.current)&&(f.current&&(l==null||l.unobserve(f.current)),l==null||l.observe(c.current),f.current=c.current)},[g,t.hidden]),Q.useEffect(()=>()=>{f.current&&(l==null||l.unobserve(f.current),f.current=null)},[]),Q.useEffect(()=>{if(c.current){const v=y.current!==r,m=h.current!==t.sourcePosition,w=p.current!==t.targetPosition;(v||m||w)&&(y.current=r,h.current=t.sourcePosition,p.current=t.targetPosition,u.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:c.current,force:!0}]])))}},[t.id,r,t.sourcePosition,t.targetPosition]),c}function MS({id:t,onClick:r,onMouseEnter:i,onMouseMove:l,onMouseLeave:u,onContextMenu:c,onDoubleClick:f,nodesDraggable:h,elementsSelectable:p,nodesConnectable:y,nodesFocusable:g,resizeObserver:v,noDragClassName:m,noPanClassName:w,disableKeyboardA11y:S,rfId:P,nodeTypes:C,nodeClickDistance:E,onError:j}){const{node:_,internals:I,isParent:F}=ze(K=>{const se=K.nodeLookup.get(t),pe=K.parentLookup.has(t);return{node:se,internals:se.internals,isParent:pe}},be);let $=_.type||"default",B=(C==null?void 0:C[$])||Vh[$];B===void 0&&(j==null||j("003",Zt.error003($)),$="default",B=(C==null?void 0:C.default)||Vh.default);const X=!!(_.draggable||h&&typeof _.draggable>"u"),G=!!(_.selectable||p&&typeof _.selectable>"u"),te=!!(_.connectable||y&&typeof _.connectable>"u"),Z=!!(_.focusable||g&&typeof _.focusable>"u"),ee=Oe(),J=Vp(_),N=CS({node:_,nodeType:$,hasDimensions:J,resizeObserver:v}),U=mg({nodeRef:N,disabled:_.hidden||!X,noDragClassName:m,handleSelector:_.dragHandle,nodeId:t,isSelectable:G,nodeClickDistance:E}),H=yg();if(_.hidden)return null;const b=en(_),A=yS(_),L=G||X||r||i||l||u,O=i?K=>i(K,{...I.userNode}):void 0,M=l?K=>l(K,{...I.userNode}):void 0,z=u?K=>u(K,{...I.userNode}):void 0,ne=c?K=>c(K,{...I.userNode}):void 0,re=f?K=>f(K,{...I.userNode}):void 0,ae=K=>{const{selectNodesOnDrag:se,nodeDragThreshold:pe}=ee.getState();G&&(!se||!X||pe>0)&&Wa({id:t,store:ee,nodeRef:N}),r&&r(K,{...I.userNode})},fe=K=>{if(!(Up(K.nativeEvent)||S)){if(zp.includes(K.key)&&G){const se=K.key==="Escape";Wa({id:t,store:ee,unselect:se,nodeRef:N})}else if(X&&_.selected&&Object.prototype.hasOwnProperty.call(al,K.key)){K.preventDefault();const{ariaLabelConfig:se}=ee.getState();ee.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:K.key.replace("Arrow","").toLowerCase(),x:~~I.positionAbsolute.x,y:~~I.positionAbsolute.y})}),H({direction:al[K.key],factor:K.shiftKey?4:1})}}},ce=()=>{var Ce;if(S||!((Ce=N.current)!=null&&Ce.matches(":focus-visible")))return;const{transform:K,width:se,height:pe,autoPanOnNodeFocus:we,setCenter:ve}=ee.getState();if(!we)return;tc(new Map([[t,_]]),{x:0,y:0,width:se,height:pe},K,!0).length>0||ve(_.position.x+b.width/2,_.position.y+b.height/2,{zoom:K[2]})};return k.jsx("div",{className:Xe(["react-flow__node",`react-flow__node-${$}`,{[w]:X},_.className,{selected:_.selected,selectable:G,parent:F,draggable:X,dragging:U}]),ref:N,style:{zIndex:I.z,transform:`translate(${I.positionAbsolute.x}px,${I.positionAbsolute.y}px)`,pointerEvents:L?"all":"none",visibility:J?"visible":"hidden",..._.style,...A},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:O,onMouseMove:M,onMouseLeave:z,onContextMenu:ne,onClick:ae,onDoubleClick:re,onKeyDown:Z?fe:void 0,tabIndex:Z?0:void 0,onFocus:Z?ce:void 0,role:_.ariaRole??(Z?"group":void 0),"aria-roledescription":"node","aria-describedby":S?void 0:`${ag}-${P}`,"aria-label":_.ariaLabel,..._.domAttributes,children:k.jsx(sS,{value:t,children:k.jsx(B,{id:t,data:_.data,type:$,positionAbsoluteX:I.positionAbsolute.x,positionAbsoluteY:I.positionAbsolute.y,selected:_.selected??!1,selectable:G,draggable:X,deletable:_.deletable??!0,isConnectable:te,sourcePosition:_.sourcePosition,targetPosition:_.targetPosition,dragging:U,dragHandle:_.dragHandle,zIndex:I.z,parentId:_.parentId,...b})})})}var PS=Q.memo(MS);const IS=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Sg(t){const{nodesConnectable:r,nodesFocusable:i,elementsSelectable:l,onError:u}=ze(IS,be),c=ES(t.onlyRenderVisibleElements),f=NS();return k.jsx("div",{className:"react-flow__nodes",style:wl,children:c.map(h=>k.jsx(PS,{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:f,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:r,nodesFocusable:i,elementsSelectable:l,nodeClickDistance:t.nodeClickDistance,onError:u},h))})}Sg.displayName="NodeRenderer";const TS=Q.memo(Sg);function zS(t){return ze(Q.useCallback(i=>{if(!t)return i.edges.map(u=>u.id);const l=[];if(i.width&&i.height)for(const u of i.edges){const c=i.nodeLookup.get(u.source),f=i.nodeLookup.get(u.target);c&&f&&kw({sourceNode:c,targetNode:f,width:i.width,height:i.height,transform:i.transform})&&l.push(u.id)}return l},[t]),be)}const jS=({color:t="none",strokeWidth:r=1})=>{const i={strokeWidth:r,...t&&{stroke:t}};return k.jsx("polyline",{className:"arrow",style:i,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},RS=({color:t="none",strokeWidth:r=1})=>{const i={strokeWidth:r,...t&&{stroke:t,fill:t}};return k.jsx("polyline",{className:"arrowclosed",style:i,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},bh={[il.Arrow]:jS,[il.ArrowClosed]:RS};function LS(t){const r=Oe();return Q.useMemo(()=>{var u,c;return Object.prototype.hasOwnProperty.call(bh,t)?bh[t]:((c=(u=r.getState()).onError)==null||c.call(u,"009",Zt.error009(t)),null)},[t])}const AS=({id:t,type:r,color:i,width:l=12.5,height:u=12.5,markerUnits:c="strokeWidth",strokeWidth:f,orient:h="auto-start-reverse"})=>{const p=LS(r);return p?k.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${l}`,markerHeight:`${u}`,viewBox:"-10 -10 20 20",markerUnits:c,orient:h,refX:"0",refY:"0",children:k.jsx(p,{color:i,strokeWidth:f})}):null},_g=({defaultColor:t,rfId:r})=>{const i=ze(c=>c.edges),l=ze(c=>c.defaultEdgeOptions),u=Q.useMemo(()=>jw(i,{id:r,defaultColor:t,defaultMarkerStart:l==null?void 0:l.markerStart,defaultMarkerEnd:l==null?void 0:l.markerEnd}),[i,l,r,t]);return u.length?k.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:k.jsx("defs",{children:u.map(c=>k.jsx(AS,{id:c.id,type:c.type,color:c.color,width:c.width,height:c.height,markerUnits:c.markerUnits,strokeWidth:c.strokeWidth,orient:c.orient},c.id))})}):null};_g.displayName="MarkerDefinitions";var $S=Q.memo(_g);function Eg({x:t,y:r,label:i,labelStyle:l,labelShowBg:u=!0,labelBgStyle:c,labelBgPadding:f=[2,4],labelBgBorderRadius:h=2,children:p,className:y,...g}){const[v,m]=Q.useState({x:1,y:0,width:0,height:0}),w=Xe(["react-flow__edge-textwrapper",y]),S=Q.useRef(null);return Q.useEffect(()=>{if(S.current){const P=S.current.getBBox();m({x:P.x,y:P.y,width:P.width,height:P.height})}},[i]),i?k.jsxs("g",{transform:`translate(${t-v.width/2} ${r-v.height/2})`,className:w,visibility:v.width?"visible":"hidden",...g,children:[u&&k.jsx("rect",{width:v.width+2*f[0],x:-f[0],y:-f[1],height:v.height+2*f[1],className:"react-flow__edge-textbg",style:c,rx:h,ry:h}),k.jsx("text",{className:"react-flow__edge-text",y:v.height/2,dy:"0.3em",ref:S,style:l,children:i}),p]}):null}Eg.displayName="EdgeText";const DS=Q.memo(Eg);function Sl({path:t,labelX:r,labelY:i,label:l,labelStyle:u,labelShowBg:c,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:y=20,...g}){return k.jsxs(k.Fragment,{children:[k.jsx("path",{...g,d:t,fill:"none",className:Xe(["react-flow__edge-path",g.className])}),y?k.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:y,className:"react-flow__edge-interaction"}):null,l&&Kt(r)&&Kt(i)?k.jsx(DS,{x:r,y:i,label:l,labelStyle:u,labelShowBg:c,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function Uh({pos:t,x1:r,y1:i,x2:l,y2:u}){return t===Se.Left||t===Se.Right?[.5*(r+l),i]:[r,.5*(i+u)]}function kg({sourceX:t,sourceY:r,sourcePosition:i=Se.Bottom,targetX:l,targetY:u,targetPosition:c=Se.Top}){const[f,h]=Uh({pos:i,x1:t,y1:r,x2:l,y2:u}),[p,y]=Uh({pos:c,x1:l,y1:u,x2:t,y2:r}),[g,v,m,w]=Yp({sourceX:t,sourceY:r,targetX:l,targetY:u,sourceControlX:f,sourceControlY:h,targetControlX:p,targetControlY:y});return[`M${t},${r} C${f},${h} ${p},${y} ${l},${u}`,g,v,m,w]}function Ng(t){return Q.memo(({id:r,sourceX:i,sourceY:l,targetX:u,targetY:c,sourcePosition:f,targetPosition:h,label:p,labelStyle:y,labelShowBg:g,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:w,style:S,markerEnd:P,markerStart:C,interactionWidth:E})=>{const[j,_,I]=kg({sourceX:i,sourceY:l,sourcePosition:f,targetX:u,targetY:c,targetPosition:h}),F=t.isInternal?void 0:r;return k.jsx(Sl,{id:F,path:j,labelX:_,labelY:I,label:p,labelStyle:y,labelShowBg:g,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:w,style:S,markerEnd:P,markerStart:C,interactionWidth:E})})}const OS=Ng({isInternal:!1}),Cg=Ng({isInternal:!0});OS.displayName="SimpleBezierEdge";Cg.displayName="SimpleBezierEdgeInternal";function Mg(t){return Q.memo(({id:r,sourceX:i,sourceY:l,targetX:u,targetY:c,label:f,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:g,labelBgBorderRadius:v,style:m,sourcePosition:w=Se.Bottom,targetPosition:S=Se.Top,markerEnd:P,markerStart:C,pathOptions:E,interactionWidth:j})=>{const[_,I,F]=Va({sourceX:i,sourceY:l,sourcePosition:w,targetX:u,targetY:c,targetPosition:S,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 k.jsx(Sl,{id:$,path:_,labelX:I,labelY:F,label:f,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:g,labelBgBorderRadius:v,style:m,markerEnd:P,markerStart:C,interactionWidth:j})})}const Pg=Mg({isInternal:!1}),Ig=Mg({isInternal:!0});Pg.displayName="SmoothStepEdge";Ig.displayName="SmoothStepEdgeInternal";function Tg(t){return Q.memo(({id:r,...i})=>{var u;const l=t.isInternal?void 0:r;return k.jsx(Pg,{...i,id:l,pathOptions:Q.useMemo(()=>{var c;return{borderRadius:0,offset:(c=i.pathOptions)==null?void 0:c.offset}},[(u=i.pathOptions)==null?void 0:u.offset])})})}const FS=Tg({isInternal:!1}),zg=Tg({isInternal:!0});FS.displayName="StepEdge";zg.displayName="StepEdgeInternal";function jg(t){return Q.memo(({id:r,sourceX:i,sourceY:l,targetX:u,targetY:c,label:f,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:g,labelBgBorderRadius:v,style:m,markerEnd:w,markerStart:S,interactionWidth:P})=>{const[C,E,j]=Gp({sourceX:i,sourceY:l,targetX:u,targetY:c}),_=t.isInternal?void 0:r;return k.jsx(Sl,{id:_,path:C,labelX:E,labelY:j,label:f,labelStyle:h,labelShowBg:p,labelBgStyle:y,labelBgPadding:g,labelBgBorderRadius:v,style:m,markerEnd:w,markerStart:S,interactionWidth:P})})}const HS=jg({isInternal:!1}),Rg=jg({isInternal:!0});HS.displayName="StraightEdge";Rg.displayName="StraightEdgeInternal";function Lg(t){return Q.memo(({id:r,sourceX:i,sourceY:l,targetX:u,targetY:c,sourcePosition:f=Se.Bottom,targetPosition:h=Se.Top,label:p,labelStyle:y,labelShowBg:g,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:w,style:S,markerEnd:P,markerStart:C,pathOptions:E,interactionWidth:j})=>{const[_,I,F]=Xp({sourceX:i,sourceY:l,sourcePosition:f,targetX:u,targetY:c,targetPosition:h,curvature:E==null?void 0:E.curvature}),$=t.isInternal?void 0:r;return k.jsx(Sl,{id:$,path:_,labelX:I,labelY:F,label:p,labelStyle:y,labelShowBg:g,labelBgStyle:v,labelBgPadding:m,labelBgBorderRadius:w,style:S,markerEnd:P,markerStart:C,interactionWidth:j})})}const VS=Lg({isInternal:!1}),Ag=Lg({isInternal:!0});VS.displayName="BezierEdge";Ag.displayName="BezierEdgeInternal";const Wh={default:Ag,straight:Rg,step:zg,smoothstep:Ig,simplebezier:Cg},Yh={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},BS=(t,r,i)=>i===Se.Left?t-r:i===Se.Right?t+r:t,bS=(t,r,i)=>i===Se.Top?t-r:i===Se.Bottom?t+r:t,Xh="react-flow__edgeupdater";function Qh({position:t,centerX:r,centerY:i,radius:l=10,onMouseDown:u,onMouseEnter:c,onMouseOut:f,type:h}){return k.jsx("circle",{onMouseDown:u,onMouseEnter:c,onMouseOut:f,className:Xe([Xh,`${Xh}-${h}`]),cx:BS(r,l,t),cy:bS(i,l,t),r:l,stroke:"transparent",fill:"transparent"})}function US({isReconnectable:t,reconnectRadius:r,edge:i,sourceX:l,sourceY:u,targetX:c,targetY:f,sourcePosition:h,targetPosition:p,onReconnect:y,onReconnectStart:g,onReconnectEnd:v,setReconnecting:m,setUpdateHover:w}){const S=Oe(),P=(I,F)=>{if(I.button!==0)return;const{autoPanOnConnect:$,domNode:B,connectionMode:X,connectionRadius:G,lib:te,onConnectStart:Z,cancelConnection:ee,nodeLookup:J,rfId:N,panBy:U,updateConnection:H}=S.getState(),b=F.type==="target",A=(M,z)=>{m(!1),v==null||v(M,i,F.type,z)},L=M=>y==null?void 0:y(i,M),O=(M,z)=>{m(!0),g==null||g(I,i,F.type),Z==null||Z(M,z)};Ua.onPointerDown(I.nativeEvent,{autoPanOnConnect:$,connectionMode:X,connectionRadius:G,domNode:B,handleId:F.id,nodeId:F.nodeId,nodeLookup:J,isTarget:b,edgeUpdaterType:F.type,lib:te,flowId:N,cancelConnection:ee,panBy:U,isValidConnection:(...M)=>{var z,ne;return((ne=(z=S.getState()).isValidConnection)==null?void 0:ne.call(z,...M))??!0},onConnect:L,onConnectStart:O,onConnectEnd:(...M)=>{var z,ne;return(ne=(z=S.getState()).onConnectEnd)==null?void 0:ne.call(z,...M)},onReconnectEnd:A,updateConnection:H,getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,dragThreshold:S.getState().connectionDragThreshold,handleDomNode:I.currentTarget})},C=I=>P(I,{nodeId:i.target,id:i.targetHandle??null,type:"target"}),E=I=>P(I,{nodeId:i.source,id:i.sourceHandle??null,type:"source"}),j=()=>w(!0),_=()=>w(!1);return k.jsxs(k.Fragment,{children:[(t===!0||t==="source")&&k.jsx(Qh,{position:h,centerX:l,centerY:u,radius:r,onMouseDown:C,onMouseEnter:j,onMouseOut:_,type:"source"}),(t===!0||t==="target")&&k.jsx(Qh,{position:p,centerX:c,centerY:f,radius:r,onMouseDown:E,onMouseEnter:j,onMouseOut:_,type:"target"})]})}function WS({id:t,edgesFocusable:r,edgesReconnectable:i,elementsSelectable:l,onClick:u,onDoubleClick:c,onContextMenu:f,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,reconnectRadius:g,onReconnect:v,onReconnectStart:m,onReconnectEnd:w,rfId:S,edgeTypes:P,noPanClassName:C,onError:E,disableKeyboardA11y:j}){let _=ze(ve=>ve.edgeLookup.get(t));const I=ze(ve=>ve.defaultEdgeOptions);_=I?{...I,..._}:_;let F=_.type||"default",$=(P==null?void 0:P[F])||Wh[F];$===void 0&&(E==null||E("011",Zt.error011(F)),F="default",$=(P==null?void 0:P.default)||Wh.default);const B=!!(_.focusable||r&&typeof _.focusable>"u"),X=typeof v<"u"&&(_.reconnectable||i&&typeof _.reconnectable>"u"),G=!!(_.selectable||l&&typeof _.selectable>"u"),te=Q.useRef(null),[Z,ee]=Q.useState(!1),[J,N]=Q.useState(!1),U=Oe(),{zIndex:H=_.zIndex,sourceX:b,sourceY:A,targetX:L,targetY:O,sourcePosition:M,targetPosition:z}=ze(Q.useCallback(ve=>{const me=ve.nodeLookup.get(_.source),Ce=ve.nodeLookup.get(_.target);if(!me||!Ce)return Yh;const Pe=zw({id:t,sourceNode:me,targetNode:Ce,sourceHandle:_.sourceHandle||null,targetHandle:_.targetHandle||null,connectionMode:ve.connectionMode,onError:E}),Ie=Ew({selected:_.selected,zIndex:_.zIndex,sourceNode:me,targetNode:Ce,elevateOnSelect:ve.elevateEdgesOnSelect,zIndexMode:ve.zIndexMode});return{...Pe||Yh,zIndex:Ie}},[_.source,_.target,_.sourceHandle,_.targetHandle,_.selected,_.zIndex,E]),be),ne=Q.useMemo(()=>_.markerStart?`url('#${Ba(_.markerStart,S)}')`:void 0,[_.markerStart,S]),re=Q.useMemo(()=>_.markerEnd?`url('#${Ba(_.markerEnd,S)}')`:void 0,[_.markerEnd,S]);if(_.hidden||b===null||A===null||L===null||O===null)return null;const ae=ve=>{var Ie;const{addSelectedEdges:me,unselectNodesAndEdges:Ce,multiSelectionActive:Pe}=U.getState();G&&(U.setState({nodesSelectionActive:!1}),_.selected&&Pe?(Ce({nodes:[],edges:[_]}),(Ie=te.current)==null||Ie.blur()):me([t])),u&&u(ve,_)},fe=c?ve=>{c(ve,{..._})}:void 0,ce=f?ve=>{f(ve,{..._})}:void 0,K=h?ve=>{h(ve,{..._})}:void 0,se=p?ve=>{p(ve,{..._})}:void 0,pe=y?ve=>{y(ve,{..._})}:void 0,we=ve=>{var me;if(!j&&zp.includes(ve.key)&&G){const{unselectNodesAndEdges:Ce,addSelectedEdges:Pe}=U.getState();ve.key==="Escape"?((me=te.current)==null||me.blur(),Ce({edges:[_]})):Pe([t])}};return k.jsx("svg",{style:{zIndex:H},children:k.jsxs("g",{className:Xe(["react-flow__edge",`react-flow__edge-${F}`,_.className,C,{selected:_.selected,animated:_.animated,inactive:!G&&!u,updating:Z,selectable:G}]),onClick:ae,onDoubleClick:fe,onContextMenu:ce,onMouseEnter:K,onMouseMove:se,onMouseLeave:pe,onKeyDown:B?we:void 0,tabIndex:B?0:void 0,role:_.ariaRole??(B?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":_.ariaLabel===null?void 0:_.ariaLabel||`Edge from ${_.source} to ${_.target}`,"aria-describedby":B?`${cg}-${S}`:void 0,ref:te,..._.domAttributes,children:[!J&&k.jsx($,{id:t,source:_.source,target:_.target,type:_.type,selected:_.selected,animated:_.animated,selectable:G,deletable:_.deletable??!0,label:_.label,labelStyle:_.labelStyle,labelShowBg:_.labelShowBg,labelBgStyle:_.labelBgStyle,labelBgPadding:_.labelBgPadding,labelBgBorderRadius:_.labelBgBorderRadius,sourceX:b,sourceY:A,targetX:L,targetY:O,sourcePosition:M,targetPosition:z,data:_.data,style:_.style,sourceHandleId:_.sourceHandle,targetHandleId:_.targetHandle,markerStart:ne,markerEnd:re,pathOptions:"pathOptions"in _?_.pathOptions:void 0,interactionWidth:_.interactionWidth}),X&&k.jsx(US,{edge:_,isReconnectable:X,reconnectRadius:g,onReconnect:v,onReconnectStart:m,onReconnectEnd:w,sourceX:b,sourceY:A,targetX:L,targetY:O,sourcePosition:M,targetPosition:z,setUpdateHover:ee,setReconnecting:N})]})})}var YS=Q.memo(WS);const XS=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function $g({defaultMarkerColor:t,onlyRenderVisibleElements:r,rfId:i,edgeTypes:l,noPanClassName:u,onReconnect:c,onEdgeContextMenu:f,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:y,onEdgeClick:g,reconnectRadius:v,onEdgeDoubleClick:m,onReconnectStart:w,onReconnectEnd:S,disableKeyboardA11y:P}){const{edgesFocusable:C,edgesReconnectable:E,elementsSelectable:j,onError:_}=ze(XS,be),I=zS(r);return k.jsxs("div",{className:"react-flow__edges",children:[k.jsx($S,{defaultColor:t,rfId:i}),I.map(F=>k.jsx(YS,{id:F,edgesFocusable:C,edgesReconnectable:E,elementsSelectable:j,noPanClassName:u,onReconnect:c,onContextMenu:f,onMouseEnter:h,onMouseMove:p,onMouseLeave:y,onClick:g,reconnectRadius:v,onDoubleClick:m,onReconnectStart:w,onReconnectEnd:S,rfId:i,onError:_,edgeTypes:l,disableKeyboardA11y:P},F))]})}$g.displayName="EdgeRenderer";const QS=Q.memo($g),Gh=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function GS({children:t}){const r=Oe(),i=Q.useRef(null),[l]=Q.useState(()=>r.getState().transform);return pg(()=>{let u=null;const c=()=>{const f=r.getState().transform;u&&f[0]===u[0]&&f[1]===u[1]&&f[2]===u[2]||(u=f,i.current&&(i.current.style.transform=Gh(f)))};return c(),r.subscribe(c)},[r]),k.jsx("div",{ref:i,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:Gh(l)},children:t})}function KS(t){const r=cc(),i=Q.useRef(!1);Q.useEffect(()=>{!i.current&&r.viewportInitialized&&t&&(setTimeout(()=>t(r),1),i.current=!0)},[t,r.viewportInitialized])}const qS=t=>{var r;return(r=t.panZoom)==null?void 0:r.syncViewport};function ZS(t){const r=ze(qS),i=Oe();return Q.useEffect(()=>{t&&(r==null||r(t),i.setState({transform:[t.x,t.y,t.zoom]}))},[t,r]),null}function JS(t){return t.connection.inProgress?{...t.connection,to:xi(t.connection.to,t.transform)}:{...t.connection}}function e_(t){return JS}function t_(t){const r=e_();return ze(r,be)}const n_=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function r_({containerStyle:t,style:r,type:i,component:l}){const{nodesConnectable:u,width:c,height:f,isValid:h,inProgress:p}=ze(n_,be);return!(c&&u&&p)?null:k.jsx("svg",{style:t,width:c,height:f,className:"react-flow__connectionline react-flow__container",children:k.jsx("g",{className:Xe(["react-flow__connection",Lp(h)]),children:k.jsx(Dg,{style:r,type:i,CustomComponent:l,isValid:h})})})}const Dg=({style:t,type:r=Yn.Bezier,CustomComponent:i,isValid:l})=>{const{inProgress:u,from:c,fromNode:f,fromHandle:h,fromPosition:p,to:y,toNode:g,toHandle:v,toPosition:m,pointer:w}=t_();if(!u)return;if(i)return k.jsx(i,{connectionLineType:r,connectionLineStyle:t,fromNode:f,fromHandle:h,fromX:c.x,fromY:c.y,toX:y.x,toY:y.y,fromPosition:p,toPosition:m,connectionStatus:Lp(l),toNode:g,toHandle:v,pointer:w});let S="";const P={sourceX:c.x,sourceY:c.y,sourcePosition:p,targetX:y.x,targetY:y.y,targetPosition:m};switch(r){case Yn.Bezier:[S]=Xp(P);break;case Yn.SimpleBezier:[S]=kg(P);break;case Yn.Step:[S]=Va({...P,borderRadius:0});break;case Yn.SmoothStep:[S]=Va(P);break;default:[S]=Gp(P)}return k.jsx("path",{d:S,fill:"none",className:"react-flow__connection-path",style:t})};Dg.displayName="ConnectionLine";const o_={};function Kh(t=o_){Q.useRef(t),Oe(),Q.useEffect(()=>{},[t])}function i_(){Oe(),Q.useRef(!1),Q.useEffect(()=>{},[])}function Og({nodeTypes:t,edgeTypes:r,onInit:i,onNodeClick:l,onEdgeClick:u,onNodeDoubleClick:c,onEdgeDoubleClick:f,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:g,onSelectionContextMenu:v,onSelectionStart:m,onSelectionEnd:w,connectionLineType:S,connectionLineStyle:P,connectionLineComponent:C,connectionLineContainerStyle:E,selectionKeyCode:j,selectionOnDrag:_,selectionMode:I,multiSelectionKeyCode:F,panActivationKeyCode:$,zoomActivationKeyCode:B,deleteKeyCode:X,onlyRenderVisibleElements:G,elementsSelectable:te,defaultViewport:Z,translateExtent:ee,minZoom:J,maxZoom:N,preventScrolling:U,defaultMarkerColor:H,zoomOnScroll:b,zoomOnPinch:A,panOnScroll:L,panOnScrollSpeed:O,panOnScrollMode:M,zoomOnDoubleClick:z,panOnDrag:ne,autoPanOnSelection:re,onPaneClick:ae,onPaneMouseEnter:fe,onPaneMouseMove:ce,onPaneMouseLeave:K,onPaneScroll:se,onPaneContextMenu:pe,paneClickDistance:we,nodeClickDistance:ve,onEdgeContextMenu:me,onEdgeMouseEnter:Ce,onEdgeMouseMove:Pe,onEdgeMouseLeave:Ie,reconnectRadius:Re,onReconnect:Ze,onReconnectStart:nt,onReconnectEnd:Qe,noDragClassName:Ge,noWheelClassName:At,noPanClassName:kt,disableKeyboardA11y:Nt,nodeExtent:rt,rfId:dt,viewport:lt,onViewportChange:ht,nodesDraggable:V}){return Kh(t),Kh(r),i_(),KS(i),ZS(lt),k.jsx(SS,{onPaneClick:ae,onPaneMouseEnter:fe,onPaneMouseMove:ce,onPaneMouseLeave:K,onPaneContextMenu:pe,onPaneScroll:se,paneClickDistance:we,deleteKeyCode:X,selectionKeyCode:j,selectionOnDrag:_,selectionMode:I,onSelectionStart:m,onSelectionEnd:w,multiSelectionKeyCode:F,panActivationKeyCode:$,zoomActivationKeyCode:B,elementsSelectable:te,zoomOnScroll:b,zoomOnPinch:A,zoomOnDoubleClick:z,panOnScroll:L,panOnScrollSpeed:O,panOnScrollMode:M,panOnDrag:ne,autoPanOnSelection:re,defaultViewport:Z,translateExtent:ee,minZoom:J,maxZoom:N,onSelectionContextMenu:v,preventScrolling:U,noDragClassName:Ge,noWheelClassName:At,noPanClassName:kt,disableKeyboardA11y:Nt,onViewportChange:ht,isControlledViewport:!!lt,children:k.jsxs(GS,{children:[k.jsx(QS,{edgeTypes:r,onEdgeClick:u,onEdgeDoubleClick:f,onReconnect:Ze,onReconnectStart:nt,onReconnectEnd:Qe,onlyRenderVisibleElements:G,onEdgeContextMenu:me,onEdgeMouseEnter:Ce,onEdgeMouseMove:Pe,onEdgeMouseLeave:Ie,reconnectRadius:Re,defaultMarkerColor:H,noPanClassName:kt,disableKeyboardA11y:Nt,rfId:dt}),k.jsx(r_,{style:P,type:S,component:C,containerStyle:E}),k.jsx("div",{className:"react-flow__edgelabel-renderer"}),k.jsx(TS,{nodeTypes:t,onNodeClick:l,onNodeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:y,onNodeContextMenu:g,nodeClickDistance:ve,onlyRenderVisibleElements:G,noPanClassName:kt,noDragClassName:Ge,disableKeyboardA11y:Nt,nodeExtent:rt,rfId:dt,nodesDraggable:V}),k.jsx("div",{className:"react-flow__viewport-portal"})]})})}Og.displayName="GraphView";const s_=Q.memo(Og),l_=Hp(),qh=({nodes:t,edges:r,defaultNodes:i,defaultEdges:l,width:u,height:c,fitView:f,fitViewOptions:h,minZoom:p=.5,maxZoom:y=2,nodeOrigin:g,nodeExtent:v,zIndexMode:m="basic"}={})=>{const w=new Map,S=new Map,P=new Map,C=new Map,E=l??r??[],j=i??t??[],_=g??[0,0],I=v??ui;Zp(P,C,E);const{nodesInitialized:F}=ba(j,w,S,{nodeOrigin:_,nodeExtent:I,zIndexMode:m});let $=[0,0,1];if(f&&u&&c){const B=yi(w,{filter:Z=>!!((Z.width||Z.initialWidth)&&(Z.height||Z.initialHeight))}),{x:X,y:G,zoom:te}=rc(B,u,c,p,y,(h==null?void 0:h.padding)??.1);$=[X,G,te]}return{rfId:"1",width:u??0,height:c??0,transform:$,nodes:j,nodesInitialized:F,nodeLookup:w,parentLookup:S,edges:E,edgeLookup:C,connectionLookup:P,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:i!==void 0,hasDefaultEdges:l!==void 0,panZoom:null,minZoom:p,maxZoom:y,translateExtent:ui,nodeExtent:I,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:ro.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:_,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:f??!1,fitViewOptions:h,fitViewResolver:null,connection:{...Rp},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:l_,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:jp,zIndexMode:m,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},u_=({nodes:t,edges:r,defaultNodes:i,defaultEdges:l,width:u,height:c,fitView:f,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:g,nodeExtent:v,zIndexMode:m})=>w1((w,S)=>{async function P(){const{nodeLookup:C,panZoom:E,fitViewOptions:j,fitViewResolver:_,width:I,height:F,minZoom:$,maxZoom:B}=S();E&&(await mw({nodes:C,width:I,height:F,panZoom:E,minZoom:$,maxZoom:B},j),_==null||_.resolve(!0),w({fitViewResolver:null}))}return{...qh({nodes:t,edges:r,width:u,height:c,fitView:f,fitViewOptions:h,minZoom:p,maxZoom:y,nodeOrigin:g,nodeExtent:v,defaultNodes:i,defaultEdges:l,zIndexMode:m}),setNodes:C=>{const{nodeLookup:E,parentLookup:j,nodeOrigin:_,nodeExtent:I,elevateNodesOnSelect:F,fitViewQueued:$,zIndexMode:B,nodesSelectionActive:X}=S(),{nodesInitialized:G,hasSelectedNodes:te}=ba(C,E,j,{nodeOrigin:_,nodeExtent:I,elevateNodesOnSelect:F,checkEquality:!0,zIndexMode:B}),Z=X&&te;$&&G?(P(),w({nodes:C,nodesInitialized:G,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:Z})):w({nodes:C,nodesInitialized:G,nodesSelectionActive:Z})},setEdges:C=>{const{connectionLookup:E,edgeLookup:j}=S();Zp(E,j,C),w({edges:C})},setDefaultNodesAndEdges:(C,E)=>{if(C){const{setNodes:j}=S();j(C),w({hasDefaultNodes:!0})}if(E){const{setEdges:j}=S();j(E),w({hasDefaultEdges:!0})}},updateNodeInternals:C=>{const{triggerNodeChanges:E,nodeLookup:j,parentLookup:_,domNode:I,nodeOrigin:F,nodeExtent:$,debug:B,fitViewQueued:X,zIndexMode:G}=S(),{changes:te,updatedInternals:Z}=Fw(C,j,_,I,F,$,G);Z&&(Aw(j,_,{nodeOrigin:F,nodeExtent:$,zIndexMode:G}),X?(P(),w({fitViewQueued:!1,fitViewOptions:void 0})):w({}),(te==null?void 0:te.length)>0&&(B&&console.log("React Flow: trigger node changes",te),E==null||E(te)))},updateNodePositions:(C,E=!1)=>{const j=[];let _=[];const{nodeLookup:I,triggerNodeChanges:F,connection:$,updateConnection:B,onNodesChangeMiddlewareMap:X}=S();for(const[G,te]of C){const Z=I.get(G),ee=!!(Z!=null&&Z.expandParent&&(Z!=null&&Z.parentId)&&(te!=null&&te.position)),J={id:G,type:"position",position:ee?{x:Math.max(0,te.position.x),y:Math.max(0,te.position.y)}:te.position,dragging:E};if(Z&&$.inProgress&&$.fromNode.id===Z.id){const N=wr(Z,$.fromHandle,Se.Left,!0);B({...$,from:N})}ee&&Z.parentId&&j.push({id:G,parentId:Z.parentId,rect:{...te.internals.positionAbsolute,width:te.measured.width??0,height:te.measured.height??0}}),_.push(J)}if(j.length>0){const{parentLookup:G,nodeOrigin:te}=S(),Z=ac(j,I,G,te);_.push(...Z)}for(const G of X.values())_=G(_);F(_)},triggerNodeChanges:C=>{const{onNodesChange:E,setNodes:j,nodes:_,hasDefaultNodes:I,debug:F}=S();if(C!=null&&C.length){if(I){const $=V1(C,_);j($)}F&&console.log("React Flow: trigger node changes",C),E==null||E(C)}},triggerEdgeChanges:C=>{const{onEdgesChange:E,setEdges:j,edges:_,hasDefaultEdges:I,debug:F}=S();if(C!=null&&C.length){if(I){const $=B1(C,_);j($)}F&&console.log("React Flow: trigger edge changes",C),E==null||E(C)}},addSelectedNodes:C=>{const{multiSelectionActive:E,edgeLookup:j,nodeLookup:_,triggerNodeChanges:I,triggerEdgeChanges:F}=S();if(E){const $=C.map(B=>dr(B,!0));I($);return}I(Zr(_,new Set([...C]),!0)),F(Zr(j))},addSelectedEdges:C=>{const{multiSelectionActive:E,edgeLookup:j,nodeLookup:_,triggerNodeChanges:I,triggerEdgeChanges:F}=S();if(E){const $=C.map(B=>dr(B,!0));F($);return}F(Zr(j,new Set([...C]))),I(Zr(_,new Set,!0))},unselectNodesAndEdges:({nodes:C,edges:E}={})=>{const{edges:j,nodes:_,nodeLookup:I,triggerNodeChanges:F,triggerEdgeChanges:$}=S(),B=C||_,X=E||j,G=[];for(const Z of B){if(!Z.selected)continue;const ee=I.get(Z.id);ee&&(ee.selected=!1),G.push(dr(Z.id,!1))}const te=[];for(const Z of X)Z.selected&&te.push(dr(Z.id,!1));F(G),$(te)},setMinZoom:C=>{const{panZoom:E,maxZoom:j}=S();E==null||E.setScaleExtent([C,j]),w({minZoom:C})},setMaxZoom:C=>{const{panZoom:E,minZoom:j}=S();E==null||E.setScaleExtent([j,C]),w({maxZoom:C})},setTranslateExtent:C=>{var E;(E=S().panZoom)==null||E.setTranslateExtent(C),w({translateExtent:C})},resetSelectedElements:()=>{const{edges:C,nodes:E,triggerNodeChanges:j,triggerEdgeChanges:_,elementsSelectable:I}=S();if(!I)return;const F=E.reduce((B,X)=>X.selected?[...B,dr(X.id,!1)]:B,[]),$=C.reduce((B,X)=>X.selected?[...B,dr(X.id,!1)]:B,[]);j(F),_($)},setNodeExtent:C=>{const{nodes:E,nodeLookup:j,parentLookup:_,nodeOrigin:I,elevateNodesOnSelect:F,nodeExtent:$,zIndexMode:B}=S();C[0][0]===$[0][0]&&C[0][1]===$[0][1]&&C[1][0]===$[1][0]&&C[1][1]===$[1][1]||(ba(E,j,_,{nodeOrigin:I,nodeExtent:C,elevateNodesOnSelect:F,checkEquality:!1,zIndexMode:B}),w({nodeExtent:C}))},panBy:C=>{const{transform:E,width:j,height:_,panZoom:I,translateExtent:F}=S();return Hw({delta:C,panZoom:I,transform:E,translateExtent:F,width:j,height:_})},setCenter:async(C,E,j)=>{const{width:_,height:I,maxZoom:F,panZoom:$}=S();if(!$)return!1;const B=typeof(j==null?void 0:j.zoom)<"u"?j.zoom:F;return await $.setViewport({x:_/2-C*B,y:I/2-E*B,zoom:B},{duration:j==null?void 0:j.duration,ease:j==null?void 0:j.ease,interpolate:j==null?void 0:j.interpolate}),!0},cancelConnection:()=>{w({connection:{...Rp}})},updateConnection:C=>{w({connection:C})},reset:()=>w({...qh()})}},Object.is);function Fg({initialNodes:t,initialEdges:r,defaultNodes:i,defaultEdges:l,initialWidth:u,initialHeight:c,initialMinZoom:f,initialMaxZoom:h,initialFitViewOptions:p,fitView:y,nodeOrigin:g,nodeExtent:v,zIndexMode:m,children:w}){const[S]=Q.useState(()=>u_({nodes:t,edges:r,defaultNodes:i,defaultEdges:l,width:u,height:c,fitView:y,minZoom:f,maxZoom:h,fitViewOptions:p,nodeOrigin:g,nodeExtent:v,zIndexMode:m}));return k.jsx(S1,{value:S,children:k.jsx(X1,{children:k.jsx(uS,{children:w})})})}function a_({children:t,nodes:r,edges:i,defaultNodes:l,defaultEdges:u,width:c,height:f,fitView:h,fitViewOptions:p,minZoom:y,maxZoom:g,nodeOrigin:v,nodeExtent:m,zIndexMode:w}){return Q.useContext(vl)?k.jsx(k.Fragment,{children:t}):k.jsx(Fg,{initialNodes:r,initialEdges:i,defaultNodes:l,defaultEdges:u,initialWidth:c,initialHeight:f,fitView:h,initialFitViewOptions:p,initialMinZoom:y,initialMaxZoom:g,nodeOrigin:v,nodeExtent:m,zIndexMode:w,children:t})}const c_={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function f_({nodes:t,edges:r,defaultNodes:i,defaultEdges:l,className:u,nodeTypes:c,edgeTypes:f,onNodeClick:h,onEdgeClick:p,onInit:y,onMove:g,onMoveStart:v,onMoveEnd:m,onConnect:w,onConnectStart:S,onConnectEnd:P,onClickConnectStart:C,onClickConnectEnd:E,onNodeMouseEnter:j,onNodeMouseMove:_,onNodeMouseLeave:I,onNodeContextMenu:F,onNodeDoubleClick:$,onNodeDragStart:B,onNodeDrag:X,onNodeDragStop:G,onNodesDelete:te,onEdgesDelete:Z,onDelete:ee,onSelectionChange:J,onSelectionDragStart:N,onSelectionDrag:U,onSelectionDragStop:H,onSelectionContextMenu:b,onSelectionStart:A,onSelectionEnd:L,onBeforeDelete:O,connectionMode:M,connectionLineType:z=Yn.Bezier,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ae,deleteKeyCode:fe="Backspace",selectionKeyCode:ce="Shift",selectionOnDrag:K=!1,selectionMode:se=ai.Full,panActivationKeyCode:pe="Space",multiSelectionKeyCode:we=fi()?"Meta":"Control",zoomActivationKeyCode:ve=fi()?"Meta":"Control",snapToGrid:me,snapGrid:Ce,onlyRenderVisibleElements:Pe=!1,selectNodesOnDrag:Ie,nodesDraggable:Re,autoPanOnNodeFocus:Ze,nodesConnectable:nt,nodesFocusable:Qe,nodeOrigin:Ge=fg,edgesFocusable:At,edgesReconnectable:kt,elementsSelectable:Nt=!0,defaultViewport:rt=L1,minZoom:dt=.5,maxZoom:lt=2,translateExtent:ht=ui,preventScrolling:V=!0,nodeExtent:Ne,defaultMarkerColor:ot="#b1b1b7",zoomOnScroll:Sr=!0,zoomOnPinch:wi=!0,panOnScroll:Si=!1,panOnScrollSpeed:_l=.5,panOnScrollMode:lo=gr.Free,zoomOnDoubleClick:uo=!0,panOnDrag:ao=!0,onPaneClick:co,onPaneMouseEnter:fo,onPaneMouseMove:_n,onPaneMouseLeave:En,onPaneScroll:_i,onPaneContextMenu:Ei,paneClickDistance:ki=1,nodeClickDistance:Ni=0,children:Ci,onReconnect:ho,onReconnectStart:Mi,onReconnectEnd:Qn,onEdgeContextMenu:po,onEdgeDoubleClick:Gn,onEdgeMouseEnter:El,onEdgeMouseMove:Kn,onEdgeMouseLeave:_r,reconnectRadius:Er=10,onNodesChange:go,onEdgesChange:kl,noDragClassName:Nl="nodrag",noWheelClassName:Cl="nowheel",noPanClassName:tn="nopan",fitView:mo,fitViewOptions:yo,connectOnClick:Ml,attributionPosition:Pi,proOptions:Ii,defaultEdgeOptions:Ti,elevateNodesOnSelect:zi=!0,elevateEdgesOnSelect:Pl=!1,disableKeyboardA11y:ji=!1,autoPanOnConnect:He,autoPanOnNodeDrag:Il,autoPanOnSelection:vo=!0,autoPanSpeed:Ri,connectionRadius:kr,isValidConnection:Tl,onError:Li,style:Nr,id:Ct,nodeDragThreshold:zl,connectionDragThreshold:Mt,viewport:jl,onViewportChange:Rl,width:Ll,height:Cr,colorMode:Mr="light",debug:qn,onScroll:cn,ariaLabelConfig:Al,zIndexMode:Ai="basic",...xo},$i){const Zn=Ct||"1",Jn=O1(Mr),$l=Q.useCallback(Pr=>{Pr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),cn==null||cn(Pr)},[cn]);return k.jsx("div",{"data-testid":"rf__wrapper",...xo,onScroll:$l,style:{...Nr,...c_},ref:$i,className:Xe(["react-flow",u,Jn]),id:Ct,role:"application",children:k.jsxs(a_,{nodes:t,edges:r,width:Ll,height:Cr,fitView:mo,fitViewOptions:yo,minZoom:dt,maxZoom:lt,nodeOrigin:Ge,nodeExtent:Ne,zIndexMode:Ai,children:[k.jsx(D1,{nodes:t,edges:r,defaultNodes:i,defaultEdges:l,onConnect:w,onConnectStart:S,onConnectEnd:P,onClickConnectStart:C,onClickConnectEnd:E,nodesDraggable:Re,autoPanOnNodeFocus:Ze,nodesConnectable:nt,nodesFocusable:Qe,edgesFocusable:At,edgesReconnectable:kt,elementsSelectable:Nt,elevateNodesOnSelect:zi,elevateEdgesOnSelect:Pl,minZoom:dt,maxZoom:lt,nodeExtent:Ne,onNodesChange:go,onEdgesChange:kl,snapToGrid:me,snapGrid:Ce,connectionMode:M,translateExtent:ht,connectOnClick:Ml,defaultEdgeOptions:Ti,fitView:mo,fitViewOptions:yo,onNodesDelete:te,onEdgesDelete:Z,onDelete:ee,onNodeDragStart:B,onNodeDrag:X,onNodeDragStop:G,onSelectionDrag:U,onSelectionDragStart:N,onSelectionDragStop:H,onMove:g,onMoveStart:v,onMoveEnd:m,noPanClassName:tn,nodeOrigin:Ge,rfId:Zn,autoPanOnConnect:He,autoPanOnNodeDrag:Il,autoPanSpeed:Ri,onError:Li,connectionRadius:kr,isValidConnection:Tl,selectNodesOnDrag:Ie,nodeDragThreshold:zl,connectionDragThreshold:Mt,onBeforeDelete:O,debug:qn,ariaLabelConfig:Al,zIndexMode:Ai}),k.jsx(s_,{onInit:y,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:j,onNodeMouseMove:_,onNodeMouseLeave:I,onNodeContextMenu:F,onNodeDoubleClick:$,nodeTypes:c,edgeTypes:f,connectionLineType:z,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ae,selectionKeyCode:ce,selectionOnDrag:K,selectionMode:se,deleteKeyCode:fe,multiSelectionKeyCode:we,panActivationKeyCode:pe,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Pe,defaultViewport:rt,translateExtent:ht,minZoom:dt,maxZoom:lt,preventScrolling:V,zoomOnScroll:Sr,zoomOnPinch:wi,zoomOnDoubleClick:uo,panOnScroll:Si,panOnScrollSpeed:_l,panOnScrollMode:lo,panOnDrag:ao,autoPanOnSelection:vo,onPaneClick:co,onPaneMouseEnter:fo,onPaneMouseMove:_n,onPaneMouseLeave:En,onPaneScroll:_i,onPaneContextMenu:Ei,paneClickDistance:ki,nodeClickDistance:Ni,onSelectionContextMenu:b,onSelectionStart:A,onSelectionEnd:L,onReconnect:ho,onReconnectStart:Mi,onReconnectEnd:Qn,onEdgeContextMenu:po,onEdgeDoubleClick:Gn,onEdgeMouseEnter:El,onEdgeMouseMove:Kn,onEdgeMouseLeave:_r,reconnectRadius:Er,defaultMarkerColor:ot,noDragClassName:Nl,noWheelClassName:Cl,noPanClassName:tn,rfId:Zn,disableKeyboardA11y:ji,nodeExtent:Ne,viewport:jl,onViewportChange:Rl,nodesDraggable:Re}),k.jsx(R1,{onSelectionChange:J}),Ci,k.jsx(P1,{proOptions:Ii,position:Pi}),k.jsx(M1,{rfId:Zn,disableKeyboardA11y:ji})]})})}var d_=hg(f_);function h_({dimensions:t,lineWidth:r,variant:i,className:l}){return k.jsx("path",{strokeWidth:r,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:Xe(["react-flow__background-pattern",i,l])})}function p_({radius:t,className:r}){return k.jsx("circle",{cx:t,cy:t,r:t,className:Xe(["react-flow__background-pattern","dots",r])})}var Xn;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Xn||(Xn={}));const g_={[Xn.Dots]:1,[Xn.Lines]:1,[Xn.Cross]:6},m_=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function Hg({id:t,variant:r=Xn.Dots,gap:i=20,size:l,lineWidth:u=1,offset:c=0,color:f,bgColor:h,style:p,className:y,patternClassName:g}){const v=Q.useRef(null),{transform:m,patternId:w}=ze(m_,be),S=l||g_[r],P=r===Xn.Dots,C=r===Xn.Cross,E=Array.isArray(i)?i:[i,i],j=[E[0]*m[2]||1,E[1]*m[2]||1],_=S*m[2],I=Array.isArray(c)?c:[c,c],F=C?[_,_]:j,$=[I[0]*m[2]+F[0]/2,I[1]*m[2]+F[1]/2],B=`${w}${t||""}`;return k.jsxs("svg",{className:Xe(["react-flow__background",y]),style:{...p,...wl,"--xy-background-color-props":h,"--xy-background-pattern-color-props":f},ref:v,"data-testid":"rf__background",children:[k.jsx("pattern",{id:B,x:m[0]%j[0],y:m[1]%j[1],width:j[0],height:j[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:P?k.jsx(p_,{radius:_/2,className:g}):k.jsx(h_,{dimensions:F,lineWidth:u,variant:r,className:g})}),k.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${B})`})]})}Hg.displayName="Background";const y_=Q.memo(Hg);function v_(){return k.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:k.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function x_(){return k.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:k.jsx("path",{d:"M0 0h32v4.2H0z"})})}function w_(){return k.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:k.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 S_(){return k.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:k.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 __(){return k.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:k.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 Ys({children:t,className:r,...i}){return k.jsx("button",{type:"button",className:Xe(["react-flow__controls-button",r]),...i,children:t})}const E_=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function Vg({style:t,showZoom:r=!0,showFitView:i=!0,showInteractive:l=!0,fitViewOptions:u,onZoomIn:c,onZoomOut:f,onFitView:h,onInteractiveChange:p,className:y,children:g,position:v="bottom-left",orientation:m="vertical","aria-label":w}){const S=Oe(),{isInteractive:P,minZoomReached:C,maxZoomReached:E,ariaLabelConfig:j}=ze(E_,be),{zoomIn:_,zoomOut:I,fitView:F}=cc(),$=()=>{_(),c==null||c()},B=()=>{I(),f==null||f()},X=()=>{F(u),h==null||h()},G=()=>{S.setState({nodesDraggable:!P,nodesConnectable:!P,elementsSelectable:!P}),p==null||p(!P)},te=m==="horizontal"?"horizontal":"vertical";return k.jsxs(xl,{className:Xe(["react-flow__controls",te,y]),position:v,style:t,"data-testid":"rf__controls","aria-label":w??j["controls.ariaLabel"],children:[r&&k.jsxs(k.Fragment,{children:[k.jsx(Ys,{onClick:$,className:"react-flow__controls-zoomin",title:j["controls.zoomIn.ariaLabel"],"aria-label":j["controls.zoomIn.ariaLabel"],disabled:E,children:k.jsx(v_,{})}),k.jsx(Ys,{onClick:B,className:"react-flow__controls-zoomout",title:j["controls.zoomOut.ariaLabel"],"aria-label":j["controls.zoomOut.ariaLabel"],disabled:C,children:k.jsx(x_,{})})]}),i&&k.jsx(Ys,{className:"react-flow__controls-fitview",onClick:X,title:j["controls.fitView.ariaLabel"],"aria-label":j["controls.fitView.ariaLabel"],children:k.jsx(w_,{})}),l&&k.jsx(Ys,{className:"react-flow__controls-interactive",onClick:G,title:j["controls.interactive.ariaLabel"],"aria-label":j["controls.interactive.ariaLabel"],children:P?k.jsx(__,{}):k.jsx(S_,{})}),g]})}Vg.displayName="Controls";const k_=Q.memo(Vg);function N_({id:t,x:r,y:i,width:l,height:u,style:c,color:f,strokeColor:h,strokeWidth:p,className:y,borderRadius:g,shapeRendering:v,selected:m,onClick:w}){const{background:S,backgroundColor:P}=c||{},C=f||S||P;return k.jsx("rect",{className:Xe(["react-flow__minimap-node",{selected:m},y]),x:r,y:i,rx:g,ry:g,width:l,height:u,style:{fill:C,stroke:h,strokeWidth:p},shapeRendering:v,onClick:w?E=>w(E,t):void 0})}const C_=Q.memo(N_),M_=t=>t.nodes.map(r=>r.id),Ta=t=>t instanceof Function?t:()=>t;function P_({nodeStrokeColor:t,nodeColor:r,nodeClassName:i="",nodeBorderRadius:l=5,nodeStrokeWidth:u,nodeComponent:c=C_,onClick:f}){const h=ze(M_,be),p=Ta(r),y=Ta(t),g=Ta(i),v=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return k.jsx(k.Fragment,{children:h.map(m=>k.jsx(T_,{id:m,nodeColorFunc:p,nodeStrokeColorFunc:y,nodeClassNameFunc:g,nodeBorderRadius:l,nodeStrokeWidth:u,NodeComponent:c,onClick:f,shapeRendering:v},m))})}function I_({id:t,nodeColorFunc:r,nodeStrokeColorFunc:i,nodeClassNameFunc:l,nodeBorderRadius:u,nodeStrokeWidth:c,shapeRendering:f,NodeComponent:h,onClick:p}){const{node:y,x:g,y:v,width:m,height:w}=ze(S=>{const P=S.nodeLookup.get(t);if(!P)return{node:void 0,x:0,y:0,width:0,height:0};const C=P.internals.userNode,{x:E,y:j}=P.internals.positionAbsolute,{width:_,height:I}=en(C);return{node:C,x:E,y:j,width:_,height:I}},be);return!y||y.hidden||!Vp(y)?null:k.jsx(h,{x:g,y:v,width:m,height:w,style:y.style,selected:!!y.selected,className:l(y),color:r(y),borderRadius:u,strokeColor:i(y),strokeWidth:c,shapeRendering:f,onClick:p,id:y.id})}const T_=Q.memo(I_);var z_=Q.memo(P_);const j_=200,R_=150,L_=t=>!t.hidden,A_=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?Op(yi(t.nodeLookup,{filter:L_}),r):r,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},Zh=(t,r)=>t.x===r.x&&t.y===r.y&&t.width===r.width&&t.height===r.height,$_=(t,r)=>Zh(t.viewBB,r.viewBB)&&Zh(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,D_="react-flow__minimap-desc";function Bg({style:t,className:r,nodeStrokeColor:i,nodeColor:l,nodeClassName:u="",nodeBorderRadius:c=5,nodeStrokeWidth:f,nodeComponent:h,bgColor:p,maskColor:y,maskStrokeColor:g,maskStrokeWidth:v,position:m="bottom-right",onClick:w,onNodeClick:S,pannable:P=!1,zoomable:C=!1,ariaLabel:E,inversePan:j,zoomStep:_=1,offsetScale:I=5}){const F=Oe(),$=Q.useRef(null),{boundingRect:B,viewBB:X,rfId:G,panZoom:te,translateExtent:Z,flowWidth:ee,flowHeight:J,ariaLabelConfig:N}=ze(A_,$_),U=(t==null?void 0:t.width)??j_,H=(t==null?void 0:t.height)??R_,b=B.width/U,A=B.height/H,L=Math.max(b,A),O=L*U,M=L*H,z=I*L,ne=B.x-(O-B.width)/2-z,re=B.y-(M-B.height)/2-z,ae=O+z*2,fe=M+z*2,ce=`${D_}-${G}`,K=Q.useRef(0),se=Q.useRef();K.current=L,Q.useEffect(()=>{if($.current&&te)return se.current=Gw({domNode:$.current,panZoom:te,getTransform:()=>F.getState().transform,getViewScale:()=>K.current}),()=>{var me;(me=se.current)==null||me.destroy()}},[te]),Q.useEffect(()=>{var me;(me=se.current)==null||me.update({translateExtent:Z,width:ee,height:J,inversePan:j,pannable:P,zoomStep:_,zoomable:C})},[P,C,j,_,Z,ee,J]);const pe=w?me=>{var Ie;const[Ce,Pe]=((Ie=se.current)==null?void 0:Ie.pointer(me))||[0,0];w(me,{x:Ce,y:Pe})}:void 0,we=S?Q.useCallback((me,Ce)=>{const Pe=F.getState().nodeLookup.get(Ce).internals.userNode;S(me,Pe)},[]):void 0,ve=E??N["minimap.ariaLabel"];return k.jsx(xl,{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 g=="string"?g:void 0,"--xy-minimap-mask-stroke-width-props":typeof v=="number"?v*L:void 0,"--xy-minimap-node-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-node-stroke-color-props":typeof i=="string"?i:void 0,"--xy-minimap-node-stroke-width-props":typeof f=="number"?f:void 0},className:Xe(["react-flow__minimap",r]),"data-testid":"rf__minimap",children:k.jsxs("svg",{width:U,height:H,viewBox:`${ne} ${re} ${ae} ${fe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ce,ref:$,onClick:pe,children:[ve&&k.jsx("title",{id:ce,children:ve}),k.jsx(z_,{onClick:we,nodeColor:l,nodeStrokeColor:i,nodeBorderRadius:c,nodeClassName:u,nodeStrokeWidth:f,nodeComponent:h}),k.jsx("path",{className:"react-flow__minimap-mask",d:`M${ne-z},${re-z}h${ae+z*2}v${fe+z*2}h${-ae-z*2}z - M${X.x},${X.y}h${X.width}v${X.height}h${-X.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Bg.displayName="MiniMap";const O_=Q.memo(Bg),F_=t=>r=>t?`${Math.max(1/r.transform[2],1)}`:void 0,H_={[so.Line]:"right",[so.Handle]:"bottom-right"};function V_({nodeId:t,position:r,variant:i=so.Handle,className:l,style:u=void 0,children:c,color:f,minWidth:h=10,minHeight:p=10,maxWidth:y=Number.MAX_VALUE,maxHeight:g=Number.MAX_VALUE,keepAspectRatio:v=!1,resizeDirection:m,autoScale:w=!0,shouldResize:S,onResizeStart:P,onResize:C,onResizeEnd:E}){const j=vg(),_=typeof t=="string"?t:j,I=Oe(),F=Q.useRef(null),$=i===so.Handle,B=ze(Q.useCallback(F_($&&w),[$,w]),be),X=Q.useRef(null),G=r??H_[i];Q.useEffect(()=>{if(!(!F.current||!_))return X.current||(X.current=u1({domNode:F.current,nodeId:_,getStoreItems:()=>{const{nodeLookup:Z,transform:ee,snapGrid:J,snapToGrid:N,nodeOrigin:U,domNode:H}=I.getState();return{nodeLookup:Z,transform:ee,snapGrid:J,snapToGrid:N,nodeOrigin:U,paneDomNode:H}},onChange:(Z,ee)=>{const{triggerNodeChanges:J,nodeLookup:N,parentLookup:U,nodeOrigin:H}=I.getState(),b=[],A={x:Z.x,y:Z.y},L=N.get(_);if(L&&L.expandParent&&L.parentId){const O=L.origin??H,M=Z.width??L.measured.width??0,z=Z.height??L.measured.height??0,ne={id:L.id,parentId:L.parentId,rect:{width:M,height:z,...Bp({x:Z.x??L.position.x,y:Z.y??L.position.y},{width:M,height:z},L.parentId,N,O)}},re=ac([ne],N,U,H);b.push(...re),A.x=Z.x?Math.max(O[0]*M,Z.x):void 0,A.y=Z.y?Math.max(O[1]*z,Z.y):void 0}if(A.x!==void 0&&A.y!==void 0){const O={id:_,type:"position",position:{...A}};b.push(O)}if(Z.width!==void 0&&Z.height!==void 0){const M={id:_,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:Z.width,height:Z.height}};b.push(M)}for(const O of ee){const M={...O,type:"position"};b.push(M)}J(b)},onEnd:({width:Z,height:ee})=>{const J={id:_,type:"dimensions",resizing:!1,dimensions:{width:Z,height:ee}};I.getState().triggerNodeChanges([J])}})),X.current.update({controlPosition:G,boundaries:{minWidth:h,minHeight:p,maxWidth:y,maxHeight:g},keepAspectRatio:v,resizeDirection:m,onResizeStart:P,onResize:C,onResizeEnd:E,shouldResize:S}),()=>{var Z;(Z=X.current)==null||Z.destroy()}},[G,h,p,y,g,v,P,C,E,S]);const te=G.split("-");return k.jsx("div",{className:Xe(["react-flow__resize-control","nodrag",...te,i,l]),ref:F,style:{...u,scale:B,...f&&{[$?"backgroundColor":"borderColor"]:f}},children:c})}Q.memo(V_);const B_={"arch.context":0,"django.app":0,"django.route":1,"django.url_name":1,"django.view":2,"django.viewset_action":2,"django.permission":2,"django.serializer":3,"django.serializer_field":4,"django.service":4,"django.model":5,"django.field":6,"django.relation":6,"django.task":7,"django.receiver":7,"django.signal":7,"django.test":7,"django.migration_op":7,"django.admin":7,"openapi.path":8,"react.api_client":9,"react.query_key":10,"react.hook":10,"react.feature":10,"react.route":11,"react.page":11,"react.component":12,"react.form_schema":13,"react.test":13,"react.context":12};function b_(t){return B_[t]??8}function U_(t){const r=new Map;for(const l of t){const u=b_(l.type),c=r.get(u)??[];c.push(l),r.set(u,c)}const i=new Map;for(const[l,u]of r)u.sort((c,f)=>c.name.localeCompare(f.name)),u.forEach((c,f)=>{i.set(c.id,{x:l*240,y:f*92})});return i}const W_={cheap:"var(--edge-cheap)",expensive:"var(--edge-expensive)",critical:"var(--edge-critical)"};function Y_({data:t}){return k.jsxs("div",{className:"lp-node",children:[k.jsx("div",{className:"t",children:t.type.split(".").pop()}),k.jsx("div",{className:"n",children:t.name})]})}const X_={load:Y_};function za({nodes:t,edges:r}){const i=U_(t),l=t.map(c=>({id:c.id,type:"load",position:i.get(c.id)??{x:0,y:0},data:{name:c.name,type:c.type,file:c.file_path}})),u=r.filter(c=>t.some(f=>f.id===c.src)&&t.some(f=>f.id===c.dst)).map(c=>({id:c.id,source:c.src,target:c.dst,animated:c.weight==="critical",style:{stroke:W_[c.weight]||"var(--edge-cheap)",strokeWidth:c.weight==="critical"?2.4:1.2,strokeDasharray:c.confidence<.8?"6 4":void 0},label:c.type.replaceAll("_"," "),labelStyle:{fill:"var(--muted)",fontSize:9}}));return k.jsx(Fg,{children:k.jsxs(d_,{nodes:l,edges:u,nodeTypes:X_,fitView:!0,minZoom:.2,"data-testid":"impact-graph",children:[k.jsx(y_,{}),k.jsx(O_,{pannable:!0,zoomable:!0}),k.jsx(k_,{})]})})}const Ya=[{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:"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"}],Q_="obsidian",bg="loadpath.theme";function G_(t){return Ya.some(r=>r.id===t)}function Ug(){try{const t=localStorage.getItem(bg)||"";if(G_(t))return t}catch{}return Q_}function Wg(t){document.documentElement.dataset.theme=t;try{localStorage.setItem(bg,t)}catch{}}function K_(){var Re,Ze,nt,Qe,Ge,At,kt,Nt,rt,dt,lt,ht;const[t,r]=Q.useState("review"),[i,l]=Q.useState(localStorage.getItem("loadpath.repo")||""),[u,c]=Q.useState(localStorage.getItem("loadpath.base")||"HEAD~1"),[f,h]=Q.useState(localStorage.getItem("loadpath.head")||"HEAD"),[p,y]=Q.useState(null),[g,v]=Q.useState(null),[m,w]=Q.useState([]),[S,P]=Q.useState("review"),[C,E]=Q.useState(""),[j,_]=Q.useState(""),[I,F]=Q.useState(""),[$,B]=Q.useState({}),[X,G]=Q.useState([]),[te,Z]=Q.useState(localStorage.getItem("loadpath.scmRepo")||""),[ee,J]=Q.useState(localStorage.getItem("loadpath.provider")||"github"),[N,U]=Q.useState(localStorage.getItem("loadpath.prNumber")||""),[H,b]=Q.useState(""),[A,L]=Q.useState(Ug),O=Q.useRef(i);O.current=i;const M=V=>{L(V),Wg(V)};Q.useEffect(()=>{_t.settings().then(B).catch(()=>{}),_t.repos().then(V=>w(V.repos)).catch(()=>{})},[]),Q.useEffect(()=>{if(t!=="architecture"||!i)return;const V=i;let Ne=!1;return _t.architecture(V).then(ot=>{!Ne&&O.current===V&&v(ot)}).catch(()=>{}),()=>{Ne=!0}},[t,i]);const z=V=>{l(V),localStorage.setItem("loadpath.repo",V)},ne=(V,Ne)=>{c(V),h(Ne),localStorage.setItem("loadpath.base",V),localStorage.setItem("loadpath.head",Ne)},re=(V,Ne,ot)=>{J(V),Z(Ne),localStorage.setItem("loadpath.provider",V),localStorage.setItem("loadpath.scmRepo",Ne),ot!==void 0&&(U(ot),localStorage.setItem("loadpath.prNumber",ot))},ae=async(V=i)=>{if(!V)return null;const Ne=await _t.architecture(V);return O.current===V&&v(Ne),Ne},fe=async()=>{E(""),F(""),_("Tracing load path…"),z(i),ne(u,f);try{const V=await _t.review(i,u,f,!0);y(V),P("review"),r("review"),await _t.repos().then(Ne=>w(Ne.repos)).catch(()=>{}),await ae(i)}catch(V){E(V instanceof Error?V.message:String(V))}finally{_("")}},ce=async(V=!0)=>{E(""),F(""),_(V?"Indexing…":"Full reindex…"),z(i);try{await _t.index(i,V);const Ne=await ae(i);await _t.repos().then(ot=>w(ot.repos)).catch(()=>{}),Ne!=null&&Ne.indexed&&(P("architecture"),r("architecture"))}catch(Ne){E(Ne instanceof Error?Ne.message:String(Ne))}finally{_("")}},K=async()=>{E(""),F(""),_("Detecting layout…"),z(i);try{const V=await _t.init(i);F(V.message),await _t.repos().then(Ne=>w(Ne.repos)).catch(()=>{})}catch(V){E(V instanceof Error?V.message:String(V))}finally{_("")}},se=async()=>{if(p!=null&&p.markdown)try{await navigator.clipboard.writeText(p.markdown),F("Copied markdown brief")}catch(V){E(V instanceof Error?V.message:String(V))}},pe=async()=>{if(!(p!=null&&p.markdown)||!te||!N){E("Pick a pull request first (Pull requests tab), then post the brief.");return}_("Posting Loadpath brief…");try{const V=await _t.postComment(ee,te,Number(N),p.markdown);F(V.updated?"Updated the Loadpath PR comment":"Posted the Loadpath PR comment")}catch(V){E(V instanceof Error?V.message:String(V))}finally{_("")}},we=async()=>{E(""),_("Fetching pull requests…");try{const V=await _t.prs(ee,te);G(V.pull_requests)}catch(V){E(V instanceof Error?V.message:String(V))}finally{_("")}},ve=async V=>{V.preventDefault();const Ne=new FormData(V.currentTarget),ot={github_token:String(Ne.get("github_token")||""),bitbucket_token:String(Ne.get("bitbucket_token")||""),bitbucket_username:String(Ne.get("bitbucket_username")||""),ai_provider:String(Ne.get("ai_provider")||"none"),ai_api_key:String(Ne.get("ai_api_key")||""),ai_model:String(Ne.get("ai_model")||""),ai_base_url:String(Ne.get("ai_base_url")||""),workspaces:m.length?m.map(Sr=>({path:Sr.path,name:Sr.name})):i?[{path:i,name:i.split(/[\\/]/).pop()}]:[]};B(await _t.saveSettings(ot))},me=async()=>{if(p){_("Residual analysis…");try{const V=await _t.residual(p);b(V.note)}catch(V){E(V instanceof Error?V.message:String(V))}finally{_("")}}},Ce=Q.useMemo(()=>S==="architecture"?(g==null?void 0:g.nodes)??[]:(p==null?void 0:p.nodes)??[],[S,g,p]),Pe=Q.useMemo(()=>S==="architecture"?(g==null?void 0:g.edges)??[]:(p==null?void 0:p.edges)??[],[S,g,p]),Ie=p!=null&&p.index?`${p.index.counts.nodes} nodes / ${p.index.counts.edges} edges · ${p.index.incremental?"incremental":"full"}${p.index.stale?" · STALE":""}${p.index.django_boot&&p.index.django_boot!=="off"?` · boot ${p.index.django_boot}`:""}`:g!=null&&g.indexed?`${g.counts.nodes} nodes / ${g.counts.edges} edges indexed${g.stale?" · STALE":""}`:"Not indexed";return k.jsxs("div",{className:"app",children:[k.jsxs("nav",{className:"rail","data-testid":"rail",children:[k.jsx("div",{className:"brand",children:"Loadpath"}),k.jsx("button",{"data-testid":"tab-review",className:t==="review"?"active":"",onClick:()=>r("review"),children:"Review"}),k.jsx("button",{"data-testid":"tab-architecture",className:t==="architecture"?"active":"",onClick:()=>r("architecture"),children:"Architecture"}),k.jsx("button",{"data-testid":"tab-graph",className:t==="graph"?"active":"",onClick:()=>r("graph"),children:"Impact graph"}),k.jsx("button",{"data-testid":"tab-prs",className:t==="prs"?"active":"",onClick:()=>r("prs"),children:"Pull requests"}),k.jsx("button",{"data-testid":"tab-settings",className:t==="settings"?"active":"",onClick:()=>r("settings"),children:"Settings"}),k.jsxs("div",{className:"theme-pick",children:[k.jsx("label",{htmlFor:"theme-select",children:"Theme"}),k.jsx("select",{id:"theme-select","data-testid":"theme-select",value:A,onChange:V=>M(V.target.value),children:Ya.map(V=>k.jsx("option",{value:V.id,children:V.label},V.id))})]}),k.jsx("div",{style:{flex:1}}),k.jsx("div",{className:"muted",children:j||Ie})]}),k.jsxs("div",{className:"main",children:[k.jsxs("div",{className:"topbar","data-testid":"topbar",children:[m.length>0?k.jsxs("select",{"data-testid":"workspace-select",value:m.some(V=>V.path===i)?i:"",onChange:V=>{V.target.value&&z(V.target.value)},children:[k.jsx("option",{value:"",children:"Indexed repos…"}),m.map(V=>k.jsxs("option",{value:V.path,children:[V.name,V.indexed?` (${V.counts.nodes})`:""]},V.path))]}):null,k.jsx("input",{"data-testid":"repo-path",className:"path",placeholder:"Local monorepo path",value:i,onChange:V=>l(V.target.value)}),k.jsx("input",{"data-testid":"base-ref",value:u,onChange:V=>ne(V.target.value,f),placeholder:"base"}),k.jsx("input",{"data-testid":"head-ref",value:f,onChange:V=>ne(u,V.target.value),placeholder:"head"}),k.jsx("button",{"data-testid":"btn-init",onClick:K,children:"Draft config"}),k.jsx("button",{"data-testid":"btn-index",onClick:()=>ce(!0),children:"Index"}),k.jsx("button",{"data-testid":"btn-review",className:"btn primary",onClick:fe,children:"Review"})]}),C?k.jsx("div",{className:"error",children:C}):null,I?k.jsx("div",{className:"banner","data-testid":"status-note",children:I}):null,((Re=p==null?void 0:p.index)!=null&&Re.stale||g!=null&&g.stale)&&(t==="review"||t==="architecture")?k.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,((Ze=p==null?void 0:p.index)==null?void 0:Ze.django_boot)==="failed"||(g==null?void 0:g.django_boot)==="failed"?k.jsx("div",{className:"banner warn","data-testid":"django-boot-failed",children:((nt=p==null?void 0:p.index)==null?void 0:nt.django_boot_detail)||(g==null?void 0:g.django_boot_detail)||"django.setup() failed"}):null,(Qe=p==null?void 0:p.workspace)!=null&&Qe.dirty_overlaps_review&&t==="review"?k.jsxs("div",{className:"banner warn","data-testid":"dirty-tree",children:["Uncommitted files overlap this review: ",(p.workspace.dirty_overlap||[]).slice(0,6).join(", ")]}):null,t==="review"&&k.jsxs("div",{className:"content","data-testid":"review-layout",children:[k.jsx("aside",{className:"brief","data-testid":"brief",children:p?k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:`level ${p.confidence.level}`,children:[p.confidence.level.toUpperCase()," — ",p.title]}),p.low_risk?k.jsx("span",{className:"chip",children:"loadpath:low-risk"}):null,p.change_kinds.map(V=>k.jsx("span",{className:"chip",children:V.replaceAll("_"," ")},V)),k.jsx("pre",{className:"headline",children:p.headline}),p.index?k.jsxs(k.Fragment,{children:[k.jsx("div",{className:"kicker",children:"Index"}),k.jsxs("div",{className:"muted",children:["Walked ",p.index.counts.nodes," nodes / ",p.index.counts.edges," edges",p.index.reindex_skipped?" from an unchanged index":p.index.reindexed?" after an incremental refresh":" from the existing index",p.index.django_boot&&p.index.django_boot!=="off"?` · Django boot ${p.index.django_boot}`:"",(Ge=p.workspace)!=null&&Ge.three_dot?" · three-dot range":""]})]}):null,k.jsx("div",{className:"kicker",children:"Read this"}),p.read_order.map(V=>k.jsxs("div",{children:[k.jsx("span",{className:"file",children:V.path}),k.jsx("div",{className:"muted",children:V.why})]},V.path)),k.jsx("div",{className:"kicker",children:"Clusters"}),p.clusters.map(V=>k.jsxs("div",{className:"muted",children:[k.jsx("strong",{children:V.title})," — ",V.files.join(", ")]},V.id)),k.jsx("div",{className:"kicker",children:"Architecture"}),p.findings.filter(V=>!V.waived).length===0?k.jsx("div",{className:"muted",children:p.architecture_note}):p.findings.filter(V=>!V.waived).map(V=>k.jsxs("div",{className:"muted",children:[k.jsx("span",{className:`chip ${V.severity}`,children:V.severity}),V.message]},V.rule+V.message)),k.jsx("div",{className:"kicker",children:"Residual (AI only here)"}),p.residuals.map(V=>k.jsx("div",{className:"muted",children:V},V)),(kt=(At=p.evolution)==null?void 0:At.notes)!=null&&kt.length||(rt=(Nt=p.evolution)==null?void 0:Nt.hotspots)!=null&&rt.some(V=>V.commits)?k.jsxs(k.Fragment,{children:[k.jsx("div",{className:"kicker",children:"Churn & coupling"}),(((dt=p.evolution)==null?void 0:dt.notes)||[]).map(V=>k.jsx("div",{className:"muted",children:V},V)),(((lt=p.evolution)==null?void 0:lt.hotspots)||[]).filter(V=>V.commits).slice(0,6).map(V=>k.jsxs("div",{className:"muted",children:[k.jsx("span",{className:"file",children:V.path})," — ",V.commits," commits, bus factor ",V.bus_factor]},V.path))]}):null,k.jsxs("div",{className:"btn-row",children:[k.jsx("button",{className:"btn",onClick:me,children:"Ask configured model"}),k.jsx("button",{className:"btn","data-testid":"btn-copy-markdown",onClick:se,children:"Copy markdown"}),k.jsx("button",{className:"btn","data-testid":"btn-post-comment",onClick:pe,children:"Post to PR"})]}),H?k.jsx("pre",{className:"headline",children:H}):null,k.jsx("div",{className:"kicker",children:"Reviewers"}),k.jsx("div",{className:"muted",children:p.suggested_reviewers.join(", ")||"—"})]}):k.jsxs("div",{className:"empty","data-testid":"review-empty",children:[k.jsx("p",{children:"The graph is the architecture. The brief is the force of this diff — not a hunk list."}),k.jsxs("ol",{children:[k.jsx("li",{children:"Point at a Django + React monorepo (or pick an indexed workspace)."}),k.jsxs("li",{children:["Index it. Missing ",k.jsx("code",{children:"loadpath.yml"})," is drafted from ",k.jsx("code",{children:"manage.py"})," and"," ",k.jsx("code",{children:"src/features"}),"."]}),k.jsx("li",{children:"Review a git range, or pick a pull request so base/head become a three-dot merge-base."})]})]})}),k.jsx("div",{className:"graph-wrap","data-testid":"review-graph",children:p?k.jsx(za,{nodes:p.nodes,edges:p.edges}):null})]}),t==="architecture"&&k.jsxs("div",{className:"content","data-testid":"architecture-panel",children:[k.jsx("aside",{className:"brief","data-testid":"architecture-brief",children:g!=null&&g.indexed?k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"level high",children:["INDEXED — ",g.counts.nodes," nodes"]}),k.jsxs("span",{className:"chip",children:[g.counts.edges," edges"]}),g.has_config?k.jsx("span",{className:"chip",children:"loadpath.yml"}):null,k.jsxs("div",{className:"muted",style:{marginTop:8},children:[g.indexed_at?`Last index ${g.indexed_at}`:"Indexed",g.incremental?" · incremental":" · full",g.stale?" · stale":"",g.django_boot&&g.django_boot!=="off"?` · Django boot ${g.django_boot}`:""]}),k.jsx("div",{className:"kicker",children:"Bounded contexts"}),Object.values(g.contexts).map(V=>k.jsxs("div",{className:"muted",children:[k.jsx("strong",{children:V.name})," — ",(V.django_apps||[]).join(", ")||"no apps"," ·"," ",(V.owners||[]).join(", ")||"unowned"]},V.name)),k.jsx("div",{className:"kicker",children:"Rules"}),(g.rules||[]).map(V=>k.jsx("div",{className:"muted",children:V},V)),k.jsx("div",{className:"kicker",children:"Findings on the indexed graph"}),g.findings.filter(V=>!V.waived).length===0?k.jsx("div",{className:"muted",children:"No architecture rule hits on the full graph."}):g.findings.filter(V=>!V.waived).map(V=>k.jsxs("div",{className:"muted",children:[k.jsx("span",{className:`chip ${V.severity}`,children:V.severity}),V.message]},V.rule+V.message)),k.jsx("div",{className:"kicker",children:"Types"}),k.jsx("div",{className:"muted",children:Object.entries(g.type_counts||{}).sort((V,Ne)=>Ne[1]-V[1]).slice(0,12).map(([V,Ne])=>`${V.split(".").pop()} ${Ne}`).join(" · ")}),k.jsx("button",{className:"btn",style:{marginTop:12},onClick:()=>ce(!1),"data-testid":"btn-full-reindex",children:"Full reindex"}),k.jsx("button",{className:"btn primary",style:{marginTop:8},onClick:fe,children:"Review against this index"})]}):k.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."})}),k.jsx("div",{className:"graph-wrap","data-testid":"architecture-graph",children:g!=null&&g.indexed?k.jsx(za,{nodes:g.nodes,edges:g.edges}):null})]}),t==="graph"&&k.jsxs("div",{className:"graph-wrap","data-testid":"graph-full",style:{height:"100%",display:"flex",flexDirection:"column"},children:[k.jsxs("div",{className:"graph-modes",children:[k.jsx("button",{"data-testid":"graph-mode-review",className:S==="review"?"active":"",onClick:()=>P("review"),children:"This review"}),k.jsx("button",{"data-testid":"graph-mode-architecture",className:S==="architecture"?"active":"",onClick:()=>P("architecture"),children:"Indexed architecture"})]}),Ce.length?k.jsx("div",{style:{flex:1,minHeight:0},children:k.jsx(za,{nodes:Ce,edges:Pe})}):k.jsx("p",{className:"muted",children:"Index the repo or run a review first."})]}),t==="prs"&&k.jsxs("div",{className:"pr-list","data-testid":"pr-list",children:[k.jsxs("div",{className:"topbar",style:{border:0,padding:0,marginBottom:12},children:[k.jsxs("select",{"data-testid":"pr-provider",value:ee,onChange:V=>re(V.target.value,te,N),children:[k.jsx("option",{value:"github",children:"GitHub"}),k.jsx("option",{value:"bitbucket",children:"Bitbucket"})]}),k.jsx("input",{"data-testid":"pr-repo",className:"path",placeholder:"owner/repo",value:te,onChange:V=>re(ee,V.target.value,N)}),k.jsx("button",{"data-testid":"btn-list-prs",onClick:we,children:"List PRs"})]}),X.map(V=>k.jsxs("article",{className:"pr","data-testid":`pr-${V.number}`,children:[k.jsxs("h3",{children:["#",V.number," ",V.title]}),k.jsxs("div",{className:"muted",children:[V.author," · ",V.source_branch," → ",V.target_branch," · ",V.provider]}),k.jsxs("a",{href:V.url,target:"_blank",rel:"noreferrer",children:["Open on ",V.provider]}),k.jsx("div",{children:k.jsx("button",{className:"btn",onClick:()=>{ne(V.base_sha||V.target_branch,V.head_sha||V.source_branch),re(V.provider,V.repo,String(V.number)),r("review")},children:"Review this branch range"})})]},`${V.provider}-${V.number}`))]}),t==="settings"&&k.jsxs("form",{className:"settings","data-testid":"settings-form",onSubmit:ve,children:[k.jsx("h1",{children:"Keys & providers"}),k.jsx("p",{className:"muted",children:"Tokens stay on this machine in ~/.loadpath/settings.json. GitHub and Bitbucket power the PR list. Indexed repos are remembered as workspaces. AI is used only for residual uncertainty the graph could not close."}),k.jsx("h1",{children:"Theme"}),k.jsx("p",{className:"muted",children:"Appearance is local to this browser. Pick a palette that matches how you review."}),k.jsx("div",{className:"theme-grid","data-testid":"theme-grid",children:Ya.map(V=>k.jsxs("button",{type:"button",className:A===V.id?"theme-swatch active":"theme-swatch","data-testid":`theme-${V.id}`,onClick:()=>M(V.id),children:[k.jsx("div",{className:"name",children:V.label}),k.jsx("div",{className:"group",children:V.group})]},V.id))}),k.jsx("label",{children:"GitHub token"}),k.jsx("input",{name:"github_token",type:"password",placeholder:"ghp_…"}),k.jsx("label",{children:"Bitbucket token"}),k.jsx("input",{name:"bitbucket_token",type:"password"}),k.jsx("label",{children:"Bitbucket username (app passwords)"}),k.jsx("input",{name:"bitbucket_username",defaultValue:String($.bitbucket_username||"")}),k.jsx("label",{children:"AI provider"}),k.jsxs("select",{name:"ai_provider",defaultValue:String(((ht=$.ai)==null?void 0:ht.provider)||"none"),children:[k.jsx("option",{value:"none",children:"none (graph only)"}),k.jsx("option",{value:"anthropic",children:"Anthropic"}),k.jsx("option",{value:"openai",children:"OpenAI"}),k.jsx("option",{value:"grok",children:"Grok / xAI"}),k.jsx("option",{value:"deepseek",children:"DeepSeek"}),k.jsx("option",{value:"cursor",children:"Cursor-compatible (OpenAI protocol)"}),k.jsx("option",{value:"ollama",children:"Ollama local"})]}),k.jsx("label",{children:"AI API key"}),k.jsx("input",{name:"ai_api_key",type:"password"}),k.jsx("label",{children:"Model"}),k.jsx("input",{name:"ai_model",placeholder:"optional override"}),k.jsx("label",{children:"Base URL"}),k.jsx("input",{name:"ai_base_url",placeholder:"optional, OpenAI-compatible"}),k.jsx("button",{className:"btn primary",type:"submit",children:"Save"})]})]})]})}Wg(Ug());j0.createRoot(document.getElementById("root")).render(k.jsx(Q.StrictMode,{children:k.jsx(K_,{})})); diff --git a/src/loadpath/static/index.html b/src/loadpath/static/index.html index f3e7436..7fcbdee 100644 --- a/src/loadpath/static/index.html +++ b/src/loadpath/static/index.html @@ -15,7 +15,7 @@ - + diff --git a/src/loadpath/types.py b/src/loadpath/types.py index c605122..f0eed83 100644 --- a/src/loadpath/types.py +++ b/src/loadpath/types.py @@ -119,6 +119,7 @@ class EdgeWeight(StrEnum): NodeType.TASK, NodeType.MIGRATION_OP, NodeType.PERMISSION, + NodeType.THROTTLE, NodeType.ADMIN, NodeType.MANAGEMENT_COMMAND, NodeType.OPENAPI_PATH, diff --git a/tests/integration/test_review_vertical_slice.py b/tests/integration/test_review_vertical_slice.py index 4b763bb..7408ba5 100644 --- a/tests/integration/test_review_vertical_slice.py +++ b/tests/integration/test_review_vertical_slice.py @@ -41,6 +41,8 @@ def test_serializer_field_change_traces_to_react_form(tmp_path: Path): assert any(n["type"] == "react.page" and n["name"] == "InvoicePage" for n in review["nodes"]) assert not any(n["name"] in {"MePage", "MeView", "MeSerializer"} for n in review["nodes"]) assert review["suggested_reviewers"] == ["billing-team"] + assert "knowledge_owners" in review + assert not any(f["rule"] == "queryset_missing_index" for f in review["findings"] if not f.get("waived")) assert any(e["type"] == "consumed_by_client" for e in review["edges"]) assert any(e["type"] == "matches_schema" for e in review["edges"]) diff --git a/tests/unit/test_architecture_rules.py b/tests/unit/test_architecture_rules.py index e31b5f4..b22ccb1 100644 --- a/tests/unit/test_architecture_rules.py +++ b/tests/unit/test_architecture_rules.py @@ -123,3 +123,12 @@ def test_migration_blast_radius_keyword_order(tmp_path: Path): assert hits assert any("total" in f.message for f in hits) store.close() + + +def test_missing_index_on_unindexed_filter(tmp_path: Path): + store = index_repo(FIXTURE, db_path=tmp_path / "g.sqlite3", incremental=False) + findings = evaluate(store, load_config(FIXTURE)) + hits = [f for f in findings if f.rule == "queryset_missing_index" and not f.waived] + assert hits + assert any("status" in f.message for f in hits) + store.close() diff --git a/tests/unit/test_django_extractors.py b/tests/unit/test_django_extractors.py index 2d62cc3..a19410b 100644 --- a/tests/unit/test_django_extractors.py +++ b/tests/unit/test_django_extractors.py @@ -340,3 +340,72 @@ def overdue_account_emails(): g = extract_django_file("backend/billing/services.py", src, _cfg()) svc = next(n for n in g.nodes if n.name == "overdue_account_emails") assert svc.extra.get("nplusone") + + +def test_nplusone_one_hop_helper_return(): + src = """ +from billing.models import Invoice + +def recent(): + return Invoice.objects.filter(status="open") + +def overdue_account_emails(): + names = [] + for invoice in recent(): + names.append(invoice.account.email) + return names +""" + g = extract_django_file("backend/billing/services.py", src, _cfg()) + svc = next(n for n in g.nodes if n.name == "overdue_account_emails") + assert svc.extra.get("nplusone") + assert "account" in svc.extra["nplusone"][0]["accessed"] + + +def test_nplusone_prefetch_object_covers_related(): + src = """ +from django.db.models import Prefetch +from billing.models import Invoice + +def overdue_account_emails(): + names = [] + for invoice in Invoice.objects.prefetch_related(Prefetch("lines")): + names.append(list(invoice.lines.all())) + return names +""" + g = extract_django_file("backend/billing/services.py", src, _cfg()) + svc = next(n for n in g.nodes if n.name == "overdue_account_emails") + assert not svc.extra.get("nplusone") + + +def test_lookups_recorded_on_service(): + src = """ +from billing.models import Invoice + +def overdue_account_emails(): + return Invoice.objects.filter(status="open").order_by("created_at") +""" + g = extract_django_file("backend/billing/services.py", src, _cfg()) + svc = next(n for n in g.nodes if n.name == "overdue_account_emails") + kinds = {h["kind"] for h in svc.extra.get("lookups") or []} + assert "filter" in kinds + assert "order_by" in kinds + + +def test_pytest_mentions_serializer_field(): + source = (FIXTURE / "backend/billing/tests.py").read_text() + g = extract_django_file("backend/billing/tests.py", source, _cfg()) + test = next(n for n in g.nodes if n.name == "test_serializer_includes_total") + assert "total" in (test.extra.get("mentions") or []) + + +def test_throttles_are_nodes(): + src = """ +from rest_framework.viewsets import ModelViewSet +from rest_framework.throttling import UserRateThrottle + +class InvoiceViewSet(ModelViewSet): + throttle_classes = [UserRateThrottle] + serializer_class = object +""" + g = extract_django_file("backend/billing/views.py", src, _cfg()) + assert any(n.type is NodeType.THROTTLE and n.name == "UserRateThrottle" for n in g.nodes) diff --git a/tests/unit/test_evolution.py b/tests/unit/test_evolution.py index 3545cc0..ddac48a 100644 --- a/tests/unit/test_evolution.py +++ b/tests/unit/test_evolution.py @@ -83,3 +83,8 @@ def test_complexity_does_not_count_unchanged_sibling_methods(tmp_path: Path): scores = _complexity_for_diff(repo, diff) # changed() has one if → ~2, not the sibling's three nested ifs assert scores.get("mod.py", 0) < 6 + from loadpath.review.evolution import _changed_functions + + fns = {f["name"]: f["complexity"] for f in _changed_functions(repo, diff)} + assert "changed" in fns + assert "unchanged" not in fns diff --git a/tests/unit/test_react_extractors.py b/tests/unit/test_react_extractors.py index 66a8586..0035d63 100644 --- a/tests/unit/test_react_extractors.py +++ b/tests/unit/test_react_extractors.py @@ -71,3 +71,37 @@ def test_feature_context_from_path(): ) pages = [n for n in g.nodes if n.type in {NodeType.PAGE, NodeType.HOOK}] assert any(n.context == "identity" for n in pages) + + +def test_form_default_values_and_missing_boundary(): + g = extract_react_file( + "frontend/src/features/billing/InvoiceForm.tsx", + (FIXTURE / "frontend/src/features/billing/InvoiceForm.tsx").read_text(), + _cfg(), + ) + form = next(n for n in g.nodes if n.name == "InvoiceForm") + assert "total" in (form.extra.get("form_fields") or []) + page = extract_react_file( + "frontend/src/features/billing/InvoicePage.tsx", + (FIXTURE / "frontend/src/features/billing/InvoicePage.tsx").read_text(), + _cfg(), + ) + invoice_page = next(n for n in page.nodes if n.name == "InvoicePage") + assert invoice_page.extra.get("has_error_boundary") is False + + +def test_invalidate_queries_marked(): + src = """ +export function useSaveInvoice() { + return useMutation({ + mutationFn: save, + onSuccess: () => queryClient.invalidateQueries({ queryKey: ["invoice", id] }), + }); +} +""" + g = extract_react_file("frontend/src/features/billing/useSaveInvoice.ts", src, _cfg()) + keys = [n for n in g.nodes if n.type is NodeType.QUERY_KEY] + assert keys + assert any((n.extra or {}).get("invalidation") for n in keys) + hook = next(n for n in g.nodes if n.name == "useSaveInvoice") + assert hook.extra.get("mutation") is True diff --git a/ui/src/App.tsx b/ui/src/App.tsx index 2e849b9..0758671 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -430,6 +430,9 @@ export function App() { {aiNote ?
{aiNote}
: null}
Reviewers
{review.suggested_reviewers.join(", ") || "—"}
+ {review.knowledge_owners?.length ? ( +
Knowledge: {review.knowledge_owners.join(", ")}
+ ) : null} ) : (
diff --git a/ui/src/types.ts b/ui/src/types.ts index 9c91ecc..8f27e9b 100644 --- a/ui/src/types.ts +++ b/ui/src/types.ts @@ -48,6 +48,7 @@ export type Review = { findings: Finding[]; residuals: string[]; suggested_reviewers: string[]; + knowledge_owners?: string[]; sinks: { id: string; type: string; name: string }[]; tests_note: string; architecture_note: string;